Commit 4a3a57f8 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

app/brush_select.c app/gradient_select.c call the PDB callback from the

1999-10-29  Michael Natterer  <mitch@gimp.org>

	* app/brush_select.c
	* app/gradient_select.c
	* app/pattern_select.c: call the PDB callback from the context
	callback because it gets called on every change.

	* app/interface.c: the tool buttons had the wrong private tooltips
	attached.

	* app/gimphelp.c: call the help browser with plug_in_run() instead
	of procedural_db_execute() to make it really ansynchronous.
	Added a GtkTipsQuery tooltips inspector which gets invoked by
	<Shift>+F1. Did some illegal juggling with the tips_query's
	"parent" pointer which may cause problems, so I made the stuff
	disable-able with #ifdef's.
	Is there a proper way to create a tips_query widget without having
	to show it somewhere??
parent e5528e6c
1999-10-29 Michael Natterer <mitch@gimp.org>
* app/brush_select.c
* app/gradient_select.c
* app/pattern_select.c: call the PDB callback from the context
callback because it gets called on every change.
* app/interface.c: the tool buttons had the wrong private tooltips
attached.
* app/gimphelp.c: call the help browser with plug_in_run() instead
of procedural_db_execute() to make it really ansynchronous.
Added a GtkTipsQuery tooltips inspector which gets invoked by
<Shift>+F1. Did some illegal juggling with the tips_query's
"parent" pointer which may cause problems, so I made the stuff
disable-able with #ifdef's.
Is there a proper way to create a tips_query widget without having
to show it somewhere??
Thu Oct 28 23:22:34 BST 1999 Andy Thomas <alt@gimp.org>
* app/gimpimage.c
......@@ -9,7 +28,7 @@ Thu Oct 28 23:22:34 BST 1999 Andy Thomas <alt@gimp.org>
Fixed the way the plugin added layers. Preview stuff does not now
get corrupted.
1999-10-28 Michael Natterer <mitschel@cs.tu-berlin.de>
1999-10-28 Michael Natterer <mitch@gimp.org>
* app/Makefile.am
* app/gradient_select.h
......@@ -52,7 +71,7 @@ Thu Oct 28 23:22:34 BST 1999 Andy Thomas <alt@gimp.org>
* app/palette.c
* app/palette_entries.h
* app/palette_select.[ch]: removed the special
Palette[Entries|Entry]P poiner type.
Palette[Entries|Entry]P pointer type.
* app/devices.c: added gradients to the device status dialog.
......
......@@ -754,7 +754,12 @@ brush_select_brush_changed (GimpContext *context,
BrushSelect *bsp)
{
if (brush)
brush_select_select (bsp, brush);
{
brush_select_select (bsp, brush);
if (bsp->callback_name)
brush_change_callbacks (bsp, FALSE);
}
}
static void
......@@ -768,6 +773,9 @@ brush_select_opacity_changed (GimpContext *context,
opacity * 100.0);
gtk_signal_handler_unblock_by_data (GTK_OBJECT (bsp->opacity_data), bsp);
if (bsp->callback_name)
brush_change_callbacks (bsp, FALSE);
}
static void
......@@ -776,6 +784,9 @@ brush_select_paint_mode_changed (GimpContext *context,
BrushSelect *bsp)
{
gtk_option_menu_set_history (GTK_OPTION_MENU (bsp->option_menu), paint_mode);
if (bsp->callback_name)
brush_change_callbacks (bsp, FALSE);
}
static void
......@@ -1557,9 +1568,6 @@ brush_select_events (GtkWidget *widget,
/* Close the brush popup window */
brush_popup_close (bsp);
/* Call any callbacks registered */
brush_change_callbacks (bsp, FALSE);
}
break;
......@@ -1641,11 +1649,6 @@ opacity_scale_update (GtkAdjustment *adjustment,
bsp = (BrushSelect *) data;
gimp_context_set_opacity (bsp->context, adjustment->value / 100.0);
if (bsp != brush_select_dialog)
{
brush_change_callbacks (bsp, FALSE);
}
}
static void
......@@ -1657,11 +1660,6 @@ paint_mode_menu_callback (GtkWidget *widget,
bsp = (BrushSelect *) gtk_object_get_user_data (GTK_OBJECT (widget));
gimp_context_set_paint_mode (bsp->context, (LayerModeEffects) data);
if (bsp != brush_select_dialog)
{
brush_change_callbacks (bsp, FALSE);
}
}
static void
......
......@@ -384,7 +384,7 @@ create_tools (GtkWidget *parent)
gtk_tooltips_set_tip (tool_tips, button,
gettext(tool_info[j].tool_desc),
tool_info[i].private_tip);
tool_info[j].private_tip);
gtk_widget_show (pixmap);
gtk_widget_show (alignment);
......
......@@ -384,7 +384,7 @@ create_tools (GtkWidget *parent)
gtk_tooltips_set_tip (tool_tips, button,
gettext(tool_info[j].tool_desc),
tool_info[i].private_tip);
tool_info[j].private_tip);
gtk_widget_show (pixmap);
gtk_widget_show (alignment);
......
......@@ -28,6 +28,8 @@
#include "libgimp/gimpintl.h"
#define USE_TIPS_QUERY
/* The standard help function */
void
gimp_standard_help_func (gpointer help_data)
......@@ -53,20 +55,100 @@ gimp_help_callback (GtkWidget *widget,
(* help_function) (help_data);
}
/* Do all the actual GtkTipsQuery calls in idle functions and check for
* some widget holding a grab before starting the query because strange
* things happen if (1) the help browser pops up while the query has
* grabbed the pointer or (2) the query grabs the pointer while some
* other part of the gimp has grabbed it (e.g. the move tool, eek)
*/
#ifdef USE_TIPS_QUERY
static gint
gimp_help_tips_query_idle_show_help (gpointer help_data)
{
gimp_help ((gchar *) help_data);
return FALSE;
}
static gint
gimp_help_tips_query_widget_selected (GtkWidget *tips_query,
GtkWidget *widget,
const gchar *tip_text,
const gchar *tip_private,
GdkEventButton *event,
gpointer func_data)
{
if (widget && tip_private && use_help)
gtk_idle_add ((GtkFunction) gimp_help_tips_query_idle_show_help,
(gpointer) tip_private);
return TRUE;
}
static gint
gimp_help_tips_query_idle_start (gpointer tips_query)
{
if (! gtk_grab_get_current ())
gtk_tips_query_start_query (GTK_TIPS_QUERY (tips_query));
return FALSE;
}
static void
gimp_help_tips_query_start (GtkWidget *widget,
gpointer tips_query)
{
if (! GTK_TIPS_QUERY (tips_query)->in_query)
gtk_idle_add ((GtkFunction) gimp_help_tips_query_idle_start, tips_query);
}
#endif
void
gimp_help_connect_help_accel (GtkWidget *widget,
GimpHelpFunc help_func,
gpointer help_data)
{
GtkAccelGroup *accel_group;
static guint help_signal_id = 0;
if (! help_func)
static guint help_signal_id = 0;
#ifdef USE_TIPS_QUERY
static guint tips_query_signal_id = 0;
static GtkWidget *tips_query = NULL;
#endif
if (!help_func)
return;
/* create the help signal if not already done */
/* set up the help signals and tips query widget */
if (! help_signal_id)
{
#ifdef USE_TIPS_QUERY
tips_query = gtk_tips_query_new ();
gtk_signal_connect (GTK_OBJECT (tips_query), "widget_selected",
GTK_SIGNAL_FUNC (gimp_help_tips_query_widget_selected),
NULL);
/* FIXME: EEEEEEEEEEEEEEEEEEEEK, this is very ugly and forbidden...
* does anyone know a way to do this tips query stuff without
* having to attach to some parent widget???
*/
tips_query->parent = widget;
gtk_widget_realize (tips_query);
tips_query_signal_id =
gtk_object_class_user_signal_new (GTK_OBJECT (widget)->klass,
"tips_query",
GTK_RUN_LAST,
gtk_signal_default_marshaller,
GTK_TYPE_NONE,
0,
NULL);
#endif
help_signal_id =
gtk_object_class_user_signal_new (GTK_OBJECT (widget)->klass,
"help",
......@@ -87,17 +169,30 @@ gimp_help_connect_help_accel (GtkWidget *widget,
GTK_SIGNAL_FUNC (gimp_help_callback),
(gpointer) help_func);
#ifdef USE_TIPS_QUERY
gtk_signal_connect (GTK_OBJECT (widget), "tips_query",
GTK_SIGNAL_FUNC (gimp_help_tips_query_start),
(gpointer) tips_query);
#endif
/* a new accelerator group for this widget */
accel_group = gtk_accel_group_new ();
/* FIXME: does not work for some reason...
gtk_widget_add_accelerator (widget, "help", accel_group,
GDK_F1, 0, GTK_ACCEL_LOCKED);
gtk_widget_add_accelerator (widget, "tips_query", accel_group,
GDK_F1, GDK_SHIFT_MASK, GTK_ACCEL_LOCKED);
*/
/* ...while using this internal stuff works */
gtk_accel_group_add (accel_group, GDK_F1, 0, 0,
GTK_OBJECT (widget), "help");
#ifdef USE_TIPS_QUERY
gtk_accel_group_add (accel_group, GDK_F1, GDK_SHIFT_MASK, 0,
GTK_OBJECT (widget), "tips_query");
#endif
gtk_accel_group_attach (accel_group, GTK_OBJECT (widget));
}
......@@ -106,14 +201,16 @@ void
gimp_help (gchar *help_page)
{
ProcRecord *proc_rec;
Argument *return_vals;
gint nreturn_vals;
/* Check if a help browser is already running */
proc_rec = procedural_db_lookup ("extension_gimp_help_browser_temp");
if (proc_rec == NULL)
{
Argument *args = NULL;
proc_rec = procedural_db_lookup ("extension_gimp_help_browser");
if (proc_rec == NULL)
{
g_message (_("Could not find the GIMP Help Browser procedure.\n"
......@@ -122,21 +219,27 @@ gimp_help (gchar *help_page)
return;
}
return_vals =
procedural_db_run_proc ("extension_gimp_help_browser",
&nreturn_vals,
PDB_INT32, RUN_INTERACTIVE,
PDB_STRING, help_page,
PDB_END);
args = g_new (Argument, 2);
args[0].arg_type = PDB_INT32;
args[0].value.pdb_int = RUN_INTERACTIVE;
args[1].arg_type = PDB_STRING;
args[1].value.pdb_pointer = help_page;
plug_in_run (proc_rec, args, 2, FALSE, TRUE, 0);
g_free (args);
}
else
{
Argument *return_vals;
gint nreturn_vals;
return_vals =
procedural_db_run_proc ("extension_gimp_help_browser_temp",
&nreturn_vals,
PDB_STRING, help_page,
PDB_END);
}
procedural_db_run_proc ("extension_gimp_help_browser_temp",
&nreturn_vals,
PDB_STRING, help_page,
PDB_END);
procedural_db_destroy_args (return_vals, nreturn_vals);
procedural_db_destroy_args (return_vals, nreturn_vals);
}
}
......@@ -459,11 +459,6 @@ gradient_select_update_all (gint row,
gsp = (GradientSelect *) list->data;
gtk_clist_set_text (GTK_CLIST (gsp->clist), row, 1, gradient->name);
/* Are we updating one that is selected in a popup dialog? */
if ((gradient == gimp_context_get_gradient (gsp->context)) &&
(gsp != gradient_select_dialog))
gradient_change_callbacks (gsp, FALSE);
}
}
......@@ -489,7 +484,12 @@ gradient_select_gradient_changed (GimpContext *context,
GradientSelect *gsp)
{
if (gradient)
gradient_select_select (gsp, gradient);
{
gradient_select_select (gsp, gradient);
if (gsp->callback_name)
gradient_change_callbacks (gsp, FALSE);
}
}
static void
......@@ -529,11 +529,6 @@ gradient_select_list_item_update (GtkWidget *widget,
gimp_context_set_gradient (gsp->context, (gradient_t *) list->data);
gtk_signal_handler_unblock_by_data (GTK_OBJECT (gsp->context), gsp);
if (gsp != gradient_select_dialog)
{
gradient_change_callbacks (gsp, FALSE);
}
}
static void
......
......@@ -754,7 +754,12 @@ brush_select_brush_changed (GimpContext *context,
BrushSelect *bsp)
{
if (brush)
brush_select_select (bsp, brush);
{
brush_select_select (bsp, brush);
if (bsp->callback_name)
brush_change_callbacks (bsp, FALSE);
}
}
static void
......@@ -768,6 +773,9 @@ brush_select_opacity_changed (GimpContext *context,
opacity * 100.0);
gtk_signal_handler_unblock_by_data (GTK_OBJECT (bsp->opacity_data), bsp);
if (bsp->callback_name)
brush_change_callbacks (bsp, FALSE);
}
static void
......@@ -776,6 +784,9 @@ brush_select_paint_mode_changed (GimpContext *context,
BrushSelect *bsp)
{
gtk_option_menu_set_history (GTK_OPTION_MENU (bsp->option_menu), paint_mode);
if (bsp->callback_name)
brush_change_callbacks (bsp, FALSE);
}
static void
......@@ -1557,9 +1568,6 @@ brush_select_events (GtkWidget *widget,
/* Close the brush popup window */
brush_popup_close (bsp);
/* Call any callbacks registered */
brush_change_callbacks (bsp, FALSE);
}
break;
......@@ -1641,11 +1649,6 @@ opacity_scale_update (GtkAdjustment *adjustment,
bsp = (BrushSelect *) data;
gimp_context_set_opacity (bsp->context, adjustment->value / 100.0);
if (bsp != brush_select_dialog)
{
brush_change_callbacks (bsp, FALSE);
}
}
static void
......@@ -1657,11 +1660,6 @@ paint_mode_menu_callback (GtkWidget *widget,
bsp = (BrushSelect *) gtk_object_get_user_data (GTK_OBJECT (widget));
gimp_context_set_paint_mode (bsp->context, (LayerModeEffects) data);
if (bsp != brush_select_dialog)
{
brush_change_callbacks (bsp, FALSE);
}
}
static void
......
......@@ -459,11 +459,6 @@ gradient_select_update_all (gint row,
gsp = (GradientSelect *) list->data;
gtk_clist_set_text (GTK_CLIST (gsp->clist), row, 1, gradient->name);
/* Are we updating one that is selected in a popup dialog? */
if ((gradient == gimp_context_get_gradient (gsp->context)) &&
(gsp != gradient_select_dialog))
gradient_change_callbacks (gsp, FALSE);
}
}
......@@ -489,7 +484,12 @@ gradient_select_gradient_changed (GimpContext *context,
GradientSelect *gsp)
{
if (gradient)
gradient_select_select (gsp, gradient);
{
gradient_select_select (gsp, gradient);
if (gsp->callback_name)
gradient_change_callbacks (gsp, FALSE);
}
}
static void
......@@ -529,11 +529,6 @@ gradient_select_list_item_update (GtkWidget *widget,
gimp_context_set_gradient (gsp->context, (gradient_t *) list->data);
gtk_signal_handler_unblock_by_data (GTK_OBJECT (gsp->context), gsp);
if (gsp != gradient_select_dialog)
{
gradient_change_callbacks (gsp, FALSE);
}
}
static void
......
......@@ -425,7 +425,12 @@ pattern_select_pattern_changed (GimpContext *context,
PatternSelect *psp)
{
if (pattern)
pattern_select_select (psp, pattern->index);
{
pattern_select_select (psp, pattern->index);
if (psp->callback_name)
pattern_change_callbacks (psp, FALSE);
}
}
static void
......@@ -936,9 +941,6 @@ pattern_select_events (GtkWidget *widget,
/* Close the brush popup window */
pattern_popup_close (psp);
/* Call any callbacks registered */
pattern_change_callbacks (psp, FALSE);
}
break;
......
......@@ -384,7 +384,7 @@ create_tools (GtkWidget *parent)
gtk_tooltips_set_tip (tool_tips, button,
gettext(tool_info[j].tool_desc),
tool_info[i].private_tip);
tool_info[j].private_tip);
gtk_widget_show (pixmap);
gtk_widget_show (alignment);
......
......@@ -425,7 +425,12 @@ pattern_select_pattern_changed (GimpContext *context,
PatternSelect *psp)
{
if (pattern)
pattern_select_select (psp, pattern->index);
{
pattern_select_select (psp, pattern->index);
if (psp->callback_name)
pattern_change_callbacks (psp, FALSE);
}
}
static void
......@@ -936,9 +941,6 @@ pattern_select_events (GtkWidget *widget,
/* Close the brush popup window */
pattern_popup_close (psp);
/* Call any callbacks registered */
pattern_change_callbacks (psp, FALSE);
}
break;
......
......@@ -28,6 +28,8 @@
#include "libgimp/gimpintl.h"
#define USE_TIPS_QUERY
/* The standard help function */
void
gimp_standard_help_func (gpointer help_data)
......@@ -53,20 +55,100 @@ gimp_help_callback (GtkWidget *widget,
(* help_function) (help_data);
}
/* Do all the actual GtkTipsQuery calls in idle functions and check for
* some widget holding a grab before starting the query because strange
* things happen if (1) the help browser pops up while the query has
* grabbed the pointer or (2) the query grabs the pointer while some
* other part of the gimp has grabbed it (e.g. the move tool, eek)
*/
#ifdef USE_TIPS_QUERY
static gint
gimp_help_tips_query_idle_show_help (gpointer help_data)
{
gimp_help ((gchar *) help_data);
return FALSE;
}
static gint
gimp_help_tips_query_widget_selected (GtkWidget *tips_query,
GtkWidget *widget,
const gchar *tip_text,
const gchar *tip_private,
GdkEventButton *event,
gpointer func_data)
{
if (widget && tip_private && use_help)
gtk_idle_add ((GtkFunction) gimp_help_tips_query_idle_show_help,
(gpointer) tip_private);
return TRUE;
}
static gint
gimp_help_tips_query_idle_start (gpointer tips_query)
{
if (! gtk_grab_get_current ())
gtk_tips_query_start_query (GTK_TIPS_QUERY (tips_query));
return FALSE;
}
static void
gimp_help_tips_query_start (GtkWidget *widget,
gpointer tips_query)
{
if (! GTK_TIPS_QUERY (tips_query)->in_query)
gtk_idle_add ((GtkFunction) gimp_help_tips_query_idle_start, tips_query);
}
#endif
void
gimp_help_connect_help_accel (GtkWidget *widget,
GimpHelpFunc help_func,
gpointer help_data)
{
GtkAccelGroup *accel_group;
static guint help_signal_id = 0;
if (! help_func)
static guint help_signal_id = 0;
#ifdef USE_TIPS_QUERY
static guint tips_query_signal_id = 0;
static GtkWidget *tips_query = NULL;
#endif
if (!help_func)
return;
/* create the help signal if not already done */
/* set up the help signals and tips query widget */
if (! help_signal_id)
{
#ifdef USE_TIPS_QUERY
tips_query = gtk_tips_query_new ();
gtk_signal_connect (GTK_OBJECT (tips_query), "widget_selected",
GTK_SIGNAL_FUNC (gimp_help_tips_query_widget_selected),
NULL);
/* FIXME: EEEEEEEEEEEEEEEEEEEEK, this is very ugly and forbidden...
* does anyone know a way to do this tips query stuff without
* having to attach to some parent widget???
*/
tips_query->parent = widget;
gtk_widget_realize (tips_query);
tips_query_signal_id =
gtk_object_class_user_signal_new (GTK_OBJECT (widget)->klass,
"tips_query",
GTK_RUN_LAST,
gtk_signal_default_marshaller,
GTK_TYPE_NONE,
0,
NULL);
#endif
help_signal_id =
gtk_object_class_user_signal_new (GTK_OBJECT (widget)->klass,
"help",
......@@ -87,17 +169,30 @@ gimp_help_connect_help_accel (GtkWidget *widget,
GTK_SIGNAL_FUNC (gimp_help_callback),
(gpointer) help_func);
#ifdef USE_TIPS_QUERY
gtk_signal_connect (GTK_OBJECT (widget), "tips_query",
GTK_SIGNAL_FUNC (gimp_help_tips_query_start),
(gpointer) tips_query);
#endif
/* a new accelerator group for this widget */
accel_group = gtk_accel_group_new ();
/* FIXME: does not work for some reason...
gtk_widget_add_accelerator (widget, "help", accel_group,
GDK_F1, 0, GTK_ACCEL_LOCKED);
gtk_widget_add_accelerator (widget, "tips_query", accel_group,
GDK_F1, GDK_SHIFT_MASK, GTK_ACCEL_LOCKED);
*/
/* ...while using this internal stuff works */
gtk_accel_group_add (accel_group, GDK_F1, 0, 0,
GTK_OBJECT (widget), "help");
#ifdef USE_TIPS_QUERY
gtk_accel_group_add (accel_group, GDK_F1, GDK_SHIFT_MASK, 0,
GTK_OBJECT (widget), "tips_query");
#endif
gtk_accel_group_attach (accel_group, GTK_OBJECT (widget));
}
......@@ -106,14 +201,16 @@ void
gimp_help (gchar *help_page)
{
ProcRecord *proc_rec;
Argument *return_vals;
gint nreturn_vals;
/* Check if a help browser is already running */
proc_rec = procedural_db_lookup ("extension_gimp_help_browser_temp");
if (proc_rec == NULL)
{
Argument *args = NULL;
proc_rec = procedural_db_lookup ("extension_gimp_help_browser");
if (proc_rec == NULL)
{
g_message (_("Could not find the GIMP Help Browser procedure.\n"
......@@ -122,21 +219,27 @@ gimp_help (gchar *help_page)
return;
}
return_vals =
procedural_db_run_proc ("extension_gimp_help_browser",
&nreturn_vals,
PDB_INT32, RUN_INTERACTIVE,
PDB_STRING, help_page,
PDB_END);
args = g_new (Argument, 2);
args[0].arg_type = PDB_INT32;
args[0].value.pdb_int = RUN_INTERACTIVE;
args[1].arg_type = PDB_STRING;
args[1].value.pdb_pointer = help_page;
plug_in_run (proc_rec, args, 2, FALSE, TRUE, 0);
g_free (args);
}
else
{
Argument *return_vals;
gint nreturn_vals;