From c2c98d9e120a0ed4493c7743c9e79ef5b71fb5b1 Mon Sep 17 00:00:00 2001 From: Tim Janik Date: Thu, 22 Mar 2001 13:44:00 +0000 Subject: [PATCH] some cleanups, fixed mnemonic_widget handling, added PROP_MNEMONIC_WIDGET. Thu Mar 22 13:01:44 2001 Tim Janik * gtk/gtklabel.[hc]: some cleanups, fixed mnemonic_widget handling, added PROP_MNEMONIC_WIDGET. * gtk/gtkwindow.c (gtk_window_activate_mnemonic): (gtk_window_remove_mnemonic): (gtk_window_add_mnemonic): fixed assertions. (gtk_window_activate_mnemonic): constrain modifier checks to those permitted by gtk_accelerator_get_default_mod_mask(). got rid of gtk_window_get_default_accel_group(). * gtk/gtkwidget.c (gtk_widget_real_activate_mnemonic): handle non activatable widgets either by focussing or a warning. added a signal accumulator to ::activate_mnemonic which stops the emission once a handler returned TRUE. --- ChangeLog | 17 ++ ChangeLog.pre-2-0 | 17 ++ ChangeLog.pre-2-10 | 17 ++ ChangeLog.pre-2-2 | 17 ++ ChangeLog.pre-2-4 | 17 ++ ChangeLog.pre-2-6 | 17 ++ ChangeLog.pre-2-8 | 17 ++ docs/reference/gtk/tmpl/gtk-unused.sgml | 105 +++++----- docs/reference/gtk/tmpl/gtkbutton.sgml | 20 -- docs/reference/gtk/tmpl/gtkitemfactory.sgml | 2 + docs/reference/gtk/tmpl/gtklabel.sgml | 17 +- docs/reference/gtk/tmpl/gtkmenu.sgml | 18 -- docs/reference/gtk/tmpl/gtksignal.sgml | 219 ++++++++++++-------- docs/reference/gtk/tmpl/gtktypeutils.sgml | 20 +- docs/reference/gtk/tmpl/gtkwidget.sgml | 9 + docs/reference/gtk/tmpl/gtkwindow.sgml | 9 - gtk/gtklabel.c | 72 +++++-- gtk/gtklabel.h | 72 +++---- gtk/gtknotebook.c | 13 +- gtk/gtkwidget.c | 59 ++++-- gtk/gtkwidget.h | 9 +- gtk/gtkwindow.c | 72 +++---- gtk/gtkwindow.h | 3 - gtk/testgtk.c | 4 - tests/testgtk.c | 4 - 25 files changed, 497 insertions(+), 349 deletions(-) diff --git a/ChangeLog b/ChangeLog index 638ed8455b..6d3f0fcced 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +Thu Mar 22 13:01:44 2001 Tim Janik + + * gtk/gtklabel.[hc]: some cleanups, fixed mnemonic_widget handling, + added PROP_MNEMONIC_WIDGET. + + * gtk/gtkwindow.c (gtk_window_activate_mnemonic): + (gtk_window_remove_mnemonic): + (gtk_window_add_mnemonic): fixed assertions. + (gtk_window_activate_mnemonic): constrain modifier checks to those + permitted by gtk_accelerator_get_default_mod_mask(). + got rid of gtk_window_get_default_accel_group(). + + * gtk/gtkwidget.c (gtk_widget_real_activate_mnemonic): handle non + activatable widgets either by focussing or a warning. + added a signal accumulator to ::activate_mnemonic which stops the + emission once a handler returned TRUE. + 2001-03-22 Havoc Pennington * gtk/gtktoolbar.c (gtk_toolbar_insert_stock): handle mnemonics in diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 638ed8455b..6d3f0fcced 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,20 @@ +Thu Mar 22 13:01:44 2001 Tim Janik + + * gtk/gtklabel.[hc]: some cleanups, fixed mnemonic_widget handling, + added PROP_MNEMONIC_WIDGET. + + * gtk/gtkwindow.c (gtk_window_activate_mnemonic): + (gtk_window_remove_mnemonic): + (gtk_window_add_mnemonic): fixed assertions. + (gtk_window_activate_mnemonic): constrain modifier checks to those + permitted by gtk_accelerator_get_default_mod_mask(). + got rid of gtk_window_get_default_accel_group(). + + * gtk/gtkwidget.c (gtk_widget_real_activate_mnemonic): handle non + activatable widgets either by focussing or a warning. + added a signal accumulator to ::activate_mnemonic which stops the + emission once a handler returned TRUE. + 2001-03-22 Havoc Pennington * gtk/gtktoolbar.c (gtk_toolbar_insert_stock): handle mnemonics in diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 638ed8455b..6d3f0fcced 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,20 @@ +Thu Mar 22 13:01:44 2001 Tim Janik + + * gtk/gtklabel.[hc]: some cleanups, fixed mnemonic_widget handling, + added PROP_MNEMONIC_WIDGET. + + * gtk/gtkwindow.c (gtk_window_activate_mnemonic): + (gtk_window_remove_mnemonic): + (gtk_window_add_mnemonic): fixed assertions. + (gtk_window_activate_mnemonic): constrain modifier checks to those + permitted by gtk_accelerator_get_default_mod_mask(). + got rid of gtk_window_get_default_accel_group(). + + * gtk/gtkwidget.c (gtk_widget_real_activate_mnemonic): handle non + activatable widgets either by focussing or a warning. + added a signal accumulator to ::activate_mnemonic which stops the + emission once a handler returned TRUE. + 2001-03-22 Havoc Pennington * gtk/gtktoolbar.c (gtk_toolbar_insert_stock): handle mnemonics in diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 638ed8455b..6d3f0fcced 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,20 @@ +Thu Mar 22 13:01:44 2001 Tim Janik + + * gtk/gtklabel.[hc]: some cleanups, fixed mnemonic_widget handling, + added PROP_MNEMONIC_WIDGET. + + * gtk/gtkwindow.c (gtk_window_activate_mnemonic): + (gtk_window_remove_mnemonic): + (gtk_window_add_mnemonic): fixed assertions. + (gtk_window_activate_mnemonic): constrain modifier checks to those + permitted by gtk_accelerator_get_default_mod_mask(). + got rid of gtk_window_get_default_accel_group(). + + * gtk/gtkwidget.c (gtk_widget_real_activate_mnemonic): handle non + activatable widgets either by focussing or a warning. + added a signal accumulator to ::activate_mnemonic which stops the + emission once a handler returned TRUE. + 2001-03-22 Havoc Pennington * gtk/gtktoolbar.c (gtk_toolbar_insert_stock): handle mnemonics in diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 638ed8455b..6d3f0fcced 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,20 @@ +Thu Mar 22 13:01:44 2001 Tim Janik + + * gtk/gtklabel.[hc]: some cleanups, fixed mnemonic_widget handling, + added PROP_MNEMONIC_WIDGET. + + * gtk/gtkwindow.c (gtk_window_activate_mnemonic): + (gtk_window_remove_mnemonic): + (gtk_window_add_mnemonic): fixed assertions. + (gtk_window_activate_mnemonic): constrain modifier checks to those + permitted by gtk_accelerator_get_default_mod_mask(). + got rid of gtk_window_get_default_accel_group(). + + * gtk/gtkwidget.c (gtk_widget_real_activate_mnemonic): handle non + activatable widgets either by focussing or a warning. + added a signal accumulator to ::activate_mnemonic which stops the + emission once a handler returned TRUE. + 2001-03-22 Havoc Pennington * gtk/gtktoolbar.c (gtk_toolbar_insert_stock): handle mnemonics in diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 638ed8455b..6d3f0fcced 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,20 @@ +Thu Mar 22 13:01:44 2001 Tim Janik + + * gtk/gtklabel.[hc]: some cleanups, fixed mnemonic_widget handling, + added PROP_MNEMONIC_WIDGET. + + * gtk/gtkwindow.c (gtk_window_activate_mnemonic): + (gtk_window_remove_mnemonic): + (gtk_window_add_mnemonic): fixed assertions. + (gtk_window_activate_mnemonic): constrain modifier checks to those + permitted by gtk_accelerator_get_default_mod_mask(). + got rid of gtk_window_get_default_accel_group(). + + * gtk/gtkwidget.c (gtk_widget_real_activate_mnemonic): handle non + activatable widgets either by focussing or a warning. + added a signal accumulator to ::activate_mnemonic which stops the + emission once a handler returned TRUE. + 2001-03-22 Havoc Pennington * gtk/gtktoolbar.c (gtk_toolbar_insert_stock): handle mnemonics in diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 638ed8455b..6d3f0fcced 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,20 @@ +Thu Mar 22 13:01:44 2001 Tim Janik + + * gtk/gtklabel.[hc]: some cleanups, fixed mnemonic_widget handling, + added PROP_MNEMONIC_WIDGET. + + * gtk/gtkwindow.c (gtk_window_activate_mnemonic): + (gtk_window_remove_mnemonic): + (gtk_window_add_mnemonic): fixed assertions. + (gtk_window_activate_mnemonic): constrain modifier checks to those + permitted by gtk_accelerator_get_default_mod_mask(). + got rid of gtk_window_get_default_accel_group(). + + * gtk/gtkwidget.c (gtk_widget_real_activate_mnemonic): handle non + activatable widgets either by focussing or a warning. + added a signal accumulator to ::activate_mnemonic which stops the + emission once a handler returned TRUE. + 2001-03-22 Havoc Pennington * gtk/gtktoolbar.c (gtk_toolbar_insert_stock): handle mnemonics in diff --git a/docs/reference/gtk/tmpl/gtk-unused.sgml b/docs/reference/gtk/tmpl/gtk-unused.sgml index 0c19d12762..420f3b311c 100644 --- a/docs/reference/gtk/tmpl/gtk-unused.sgml +++ b/docs/reference/gtk/tmpl/gtk-unused.sgml @@ -445,24 +445,6 @@ The position of the cursor. - - -A simple function pointer to get invoked when the -signal is emitted. This allows you tie a hook to the signal type, -so that it will trap all emissions of that signal, from any object. - - -You may not attach these to signals created with the -#GTK_RUN_NO_HOOKS flag. - - -@object: -@signal_id: -@n_params: -@params: -@data: -@Returns: - A set of bit flags used to specify the filter being set @@ -497,6 +479,12 @@ gtk_font_selection_set_filter(). @tentative_match: @tentative_match_len: + + + + + + Setting this with a GtkType of GTK_TYPE_SIGNAL connects @@ -734,6 +722,24 @@ Sets the default size of child buttons. @min_width: minimum default width for child buttons. @min_height: minimum default height for child buttons. + + + + + +@uline_label: +@accel_group: +@Returns: + + + + + + +@stock_id: +@accel_group: +@Returns: + Initializes a previously allocated #GtkCList widget for use. This should not @@ -842,6 +848,31 @@ Get the type of GtkIdentifier. @Returns: GtkType -- the enumerated type of something. + + + + + +@label: +@str: +@Returns: + + + + + + +@menu: +@Returns: + + + + + + +@menu: +@Returns: + Private function to get an argument and argument info from an object. @@ -1056,20 +1087,6 @@ Internal function. @ruler: the gtkruler - - -Add an emission hook for a type of signal, for any object. - - -@signal_id: the type of signal to hook for. -@hook_func: the function to invoke to handle the emission hook. -@data: the user data passed in to hook_func. -@Returns: the id (that you may pass as a parameter -to gtk_signal_remove_emission_hook()). -@i: -@h: -@d: - Add an emission hook for a type of signal, for any object. @@ -1109,12 +1126,6 @@ This function is labeled private. @object: the object whose signal handlers should be destroyed. - - - - - - Find out the recursion depth of emissions for a particular type @@ -1156,16 +1167,6 @@ Obtain information about a signal. which contains all the information, or NULL. The pointer is allocated just for you: you must g_free() it. - - -Delete an emission hook. (see gtk_signal_add_emission_hook()) - - -@signal_id: the id of the signal type. -@hook_id: the id of the emission handler, returned by add_emission_hook(). -@i: -@h: - These set default functions to call when the user didn't @@ -1331,3 +1332,11 @@ Set the varargs type for a fundamental type @foreign_type. fundamental type. @varargs_type: Must be a GtkType which is either structured or flag, or NONE. + + + + + +@window: +@Returns: + diff --git a/docs/reference/gtk/tmpl/gtkbutton.sgml b/docs/reference/gtk/tmpl/gtkbutton.sgml index c7dda98a4c..db22ccf659 100644 --- a/docs/reference/gtk/tmpl/gtkbutton.sgml +++ b/docs/reference/gtk/tmpl/gtkbutton.sgml @@ -45,26 +45,6 @@ text. @Returns: The newly created #GtkButton widget. - - - - - -@uline_label: -@accel_group: -@Returns: - - - - - - - -@stock_id: -@accel_group: -@Returns: - - Emits a #GtkButton::pressed signal to the given #GtkButton. diff --git a/docs/reference/gtk/tmpl/gtkitemfactory.sgml b/docs/reference/gtk/tmpl/gtkitemfactory.sgml index 8c4dd6a9d2..18c4cc601d 100644 --- a/docs/reference/gtk/tmpl/gtkitemfactory.sgml +++ b/docs/reference/gtk/tmpl/gtkitemfactory.sgml @@ -76,6 +76,8 @@ GtkItemFactory @callback: @callback_action: @item_type: +@extra_data: +@extra_data2: diff --git a/docs/reference/gtk/tmpl/gtklabel.sgml b/docs/reference/gtk/tmpl/gtklabel.sgml index 40e7d1d347..b168ac0e2c 100644 --- a/docs/reference/gtk/tmpl/gtklabel.sgml +++ b/docs/reference/gtk/tmpl/gtklabel.sgml @@ -64,16 +64,6 @@ gtk_label_set_pattern(). @str: - - - - - -@label: -@str: -@Returns: - - The pattern of underlines you want under the existing text within the @@ -183,7 +173,12 @@ pointer, it isn't copied. - + + + + + + diff --git a/docs/reference/gtk/tmpl/gtkmenu.sgml b/docs/reference/gtk/tmpl/gtkmenu.sgml index 7ba3409198..f68992453f 100644 --- a/docs/reference/gtk/tmpl/gtkmenu.sgml +++ b/docs/reference/gtk/tmpl/gtkmenu.sgml @@ -171,24 +171,6 @@ Set the #GtkAccelGroup which holds global accelerators for the menu. @Returns: - - - - - -@menu: -@Returns: - - - - - - - -@menu: -@Returns: - - Sets the title string for the menu. The title is displayed when the menu diff --git a/docs/reference/gtk/tmpl/gtksignal.sgml b/docs/reference/gtk/tmpl/gtksignal.sgml index 1bb805c8ba..11705206fd 100644 --- a/docs/reference/gtk/tmpl/gtksignal.sgml +++ b/docs/reference/gtk/tmpl/gtksignal.sgml @@ -157,6 +157,25 @@ you might have to write a marshaller. @field: + + +A simple function pointer to get invoked when the +signal is emitted. This allows you tie a hook to the signal type, +so that it will trap all emissions of that signal, from any object. + + +You may not attach these to signals created with the +#GTK_RUN_NO_HOOKS flag. + + +@object: +@signal_id: +@n_params: +@params: +@data: +@Returns: + + These configure the signal's emission. They control @@ -232,6 +251,13 @@ to the signal. @GTK_RUN_ACTION: @GTK_RUN_NO_HOOKS: + + + + + + + Create a new signal type. (This is usually done in the @@ -289,7 +315,7 @@ you don't want a return value. the callbacks. - + Given the name of the signal and the type of object it connects to, get the signal's identifying integer. Emitting the signal @@ -299,13 +325,12 @@ by number is somewhat faster than using the name each time. It also tries the ancestors of the given type. -@Returns: the signal's identifying number, or 0 if no signal was found. - @name: the signal's name, e.g. clicked. @object_type: the type that the signal operates on, e.g. #GTK_TYPE_BUTTON. +@Returns: the signal's identifying number, or 0 if no signal was found. - + Given the signal's identifier, find its name. @@ -313,9 +338,8 @@ Given the signal's identifier, find its name. Two different signals may have the same name, if they have differing types. -@Returns: the signal name, or NULL if the signal number was invalid. - @signal_id: the signal's identifying number. +@Returns: the signal name, or NULL if the signal number was invalid. @@ -383,7 +407,7 @@ an array of GtkArgs instead of using C's varargs mechanism. followed by one which is a pointer to the return type. - + This function aborts a signal's current emission. @@ -397,11 +421,11 @@ It will print a warning if used on a signal which isn't being emitted. -@i: -@s: - @object: the object whose signal handlers you wish to stop. @signal_id: the signal identifier, as returned by gtk_signal_lookup(). + +@i: +@s: @@ -417,7 +441,7 @@ except it will lookup the signal id for you. @name: the name of the signal you wish to stop. - + Attach a function pointer and user data to a signal for a particular object. @@ -456,38 +480,38 @@ static void attach_print_signal(GtkButton* button, gint to_print) -@o: -@s: -@f: -@d: -@Returns: the connection id. - @object: the object associated with the signal, e.g. if a button is getting pressed, this is that button. @name: name of the signal. @func: function pointer to attach to the signal. @func_data: value to pass as to your function (through the marshaller). +@Returns: the connection id. + +@o: +@s: +@f: +@d: - + Attach a function pointer and user data to a signal so that this handler will be called after the other handlers. -@o: -@s: -@f: -@d: -@Returns: the unique identifier for this attachment: the connection id. - @object: the object associated with the signal. @name: name of the signal. @func: function pointer to attach to the signal. @func_data: value to pass as to your function (through the marshaller). +@Returns: the unique identifier for this attachment: the connection id. + +@o: +@s: +@f: +@d: - + This function is for registering a callback that will call another object's callback. That is, @@ -508,21 +532,21 @@ gtk_signal_connect_object(button, "clicked", gtk_widget_show, window); -@o: -@s: -@f: -@d: -@Returns: the connection id. - @object: the object which emits the signal. @name: the name of the signal. @func: the function to callback. @slot_object: the object to pass as the first parameter to func. (Though it pretends to take an object, you can really pass any gpointer as the #slot_object .) +@Returns: the connection id. + +@o: +@s: +@f: +@d: - + Attach a signal hook to a signal, passing in an alternate object as the first parameter, and guaranteeing @@ -530,16 +554,16 @@ that the default handler and all normal handlers are called first. -@o: -@s: -@f: -@d: -@Returns: the connection id. - @object: the object associated with the signal. @name: name of the signal. @func: function pointer to attach to the signal. @slot_object: the object to pass as the first parameter to #func. +@Returns: the connection id. + +@o: +@s: +@f: +@d: @@ -628,98 +652,95 @@ should signal the removal of this signal. @name: name of the signal. - + Destroy a user-defined handler connection. - @object: the object which the handler pertains to. @handler_id: the connection id. - + Destroy all connections for a particular object, with the given function-pointer and user-data. -@o: -@f: -@d: - @object: the object which emits the signal. @func: the function pointer to search for. @data: the user data to search for. + +@o: +@f: +@d: - + Destroy all connections for a particular object, with the given user-data. -@o: -@d: - @object: the object which emits the signal. @data: the user data to search for. + +@o: +@d: - + Prevent an user-defined handler from being invoked. All other signal processing will go on as normal, but this particular handler will ignore it. - @object: the object which emits the signal to block. @handler_id: the connection id. - + Prevent a user-defined handler from being invoked, by reference to the user-defined handler's function pointer and user data. (It may result in multiple hooks being blocked, if you've called connect multiple times.) -@o: -@f: -@d: - @object: the object which emits the signal to block. @func: the function pointer of the handler to block. @data: the user data of the handler to block. + +@o: +@f: +@d: - + Prevent all user-defined handlers with a certain user data from being invoked. -@o: -@d: - @object: the object which emits the signal we want to block. @data: the user data of the handlers to block. + +@o: +@d: - + Undo a block, by connection id. Note that undoing a block doesn't necessarily make the hook callable, because if you block a hook twice, you must unblock it twice. - @object: the object which emits the signal we want to unblock. @handler_id: the emission handler identifier, as returned by gtk_signal_connect(), etc. - + Undo a block, by function pointer and data. Note that undoing a block doesn't @@ -727,29 +748,29 @@ necessarily make the hook callable, because if you block a hook twice, you must unblock it twice. -@o: -@f: -@d: - @object: the object which emits the signal we want to unblock. @func: the function pointer to search for. @data: the user data to search for. + +@o: +@f: +@d: - + Undo block(s), to all signals for a particular object with a particular user-data pointer -@o: -@d: - @object: the object which emits the signal we want to unblock. @data: the user data to search for. + +@o: +@d: - + Returns a connection id corresponding to a given signal id and object. @@ -760,36 +781,64 @@ may opt to not emit the signal if no one is attached anyway, thus saving the cost of building the arguments. -@i: -@s: -@b: -@Returns: the connection id, if a connection was found. 0 otherwise. - @object: the object to search for the desired user-defined handler. @signal_id: the number of the signal to search for. @may_be_blocked: whether it is acceptable to return a blocked handler. +@Returns: the connection id, if a connection was found. 0 otherwise. + +@i: +@s: +@b: - + Returns a connection id corresponding to a given signal id, object, function pointer and user data. -@o: -@s: -@b: -@f: -@d: -@Returns: the connection id, if a handler was found. 0 otherwise. - @object: the object to search for the desired handler. @signal_id: the number of the signal to search for. @may_be_blocked: whether it is acceptable to return a blocked handler. @func: the function pointer to search for. @data: the user data to search for. +@Returns: the connection id, if a handler was found. 0 otherwise. + +@o: +@s: +@b: +@f: +@d: + + + + +Add an emission hook for a type of signal, for any object. + + +@signal_id: the type of signal to hook for. +@hook_func: the function to invoke to handle the emission hook. +@data: the user data passed in to hook_func. +@Returns: the id (that you may pass as a parameter +to gtk_signal_remove_emission_hook()). + +@i: +@h: +@d: + + + + +Delete an emission hook. (see gtk_signal_add_emission_hook()) + + +@signal_id: the id of the signal type. +@hook_id: the id of the emission handler, returned by add_emission_hook(). + +@i: +@h: diff --git a/docs/reference/gtk/tmpl/gtktypeutils.sgml b/docs/reference/gtk/tmpl/gtktypeutils.sgml index 16a7e543fe..6295e2dfa1 100644 --- a/docs/reference/gtk/tmpl/gtktypeutils.sgml +++ b/docs/reference/gtk/tmpl/gtktypeutils.sgml @@ -560,33 +560,30 @@ Create a new, unique type. @type_info: must not be null, and @type_info->type_name must also not be null. - + -@Returns: a pointer to the name of a type, or NULL if it has none. - @type: a GtkType +@Returns: a pointer to the name of a type, or NULL if it has none. - + Get the internal representation of a type given its name. -@Returns: a GtkType - @name: the name of a gtk type +@Returns: a GtkType - + -@Returns: the GtkType of the parent - @type: a GtkType +@Returns: the GtkType of the parent @@ -611,16 +608,15 @@ has all the proper initializers called. @Returns: gpointer to a GtkTypeObject - + Look in the type hierarchy to see if @type has @is_a_type among its ancestors. Do so with a simple lookup, not a loop. -@Returns: - @type: GtkType @is_a_type: GtkType +@Returns: diff --git a/docs/reference/gtk/tmpl/gtkwidget.sgml b/docs/reference/gtk/tmpl/gtkwidget.sgml index 6f1e03319d..f5349f94d2 100644 --- a/docs/reference/gtk/tmpl/gtkwidget.sgml +++ b/docs/reference/gtk/tmpl/gtkwidget.sgml @@ -1247,6 +1247,15 @@ GtkWidget @Returns: + + + + + +@widget: the object which received the signal. +@arg1: +@Returns: + diff --git a/docs/reference/gtk/tmpl/gtkwindow.sgml b/docs/reference/gtk/tmpl/gtkwindow.sgml index c3db63e8c2..cd300a2606 100644 --- a/docs/reference/gtk/tmpl/gtkwindow.sgml +++ b/docs/reference/gtk/tmpl/gtkwindow.sgml @@ -236,15 +236,6 @@ it's larger @Returns: - - - - - -@window: -@Returns: - - diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c index a269f8634f..42d6300f56 100644 --- a/gtk/gtklabel.c +++ b/gtk/gtklabel.c @@ -54,7 +54,8 @@ enum { PROP_PATTERN, PROP_WRAP, PROP_SELECTABLE, - PROP_MNEMONIC_KEYVAL + PROP_MNEMONIC_KEYVAL, + PROP_MNEMONIC_WIDGET }; static void gtk_label_class_init (GtkLabelClass *klass); @@ -67,6 +68,7 @@ static void gtk_label_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); +static void gtk_label_destroy (GtkObject *object); static void gtk_label_finalize (GObject *object); static void gtk_label_size_request (GtkWidget *widget, GtkRequisition *requisition); @@ -158,17 +160,16 @@ static void gtk_label_class_init (GtkLabelClass *class) { GObjectClass *gobject_class = G_OBJECT_CLASS (class); - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass*) class; - widget_class = (GtkWidgetClass*) class; - + GtkObjectClass *object_class = GTK_OBJECT_CLASS (class); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class); + parent_class = gtk_type_class (GTK_TYPE_MISC); gobject_class->set_property = gtk_label_set_property; gobject_class->get_property = gtk_label_get_property; gobject_class->finalize = gtk_label_finalize; + + object_class->destroy = gtk_label_destroy; widget_class->size_request = gtk_label_size_request; widget_class->size_allocate = gtk_label_size_allocate; @@ -248,13 +249,20 @@ gtk_label_class_init (GtkLabelClass *class) g_object_class_install_property (gobject_class, PROP_MNEMONIC_KEYVAL, g_param_spec_uint ("mnemonic_keyval", - _("Mnemonic accelerator key value"), + _("Mnemonic key"), _("The mnemonic accelerator key for this label."), 0, G_MAXUINT, GDK_VoidSymbol, G_PARAM_READABLE)); - + g_object_class_install_property (gobject_class, + PROP_MNEMONIC_WIDGET, + g_param_spec_object ("mnemonic_widget", + _("Mnemonic widget"), + _("The widget to be activated when the label's mnemonic " + "key is pressed."), + GTK_TYPE_WIDGET, + G_PARAM_READWRITE)); } static void @@ -297,6 +305,9 @@ gtk_label_set_property (GObject *object, case PROP_SELECTABLE: gtk_label_set_selectable (label, g_value_get_boolean (value)); break; + case PROP_MNEMONIC_WIDGET: + gtk_label_set_mnemonic_widget (label, (GtkWidget*) g_value_get_object (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -339,6 +350,9 @@ gtk_label_get_property (GObject *object, case PROP_MNEMONIC_KEYVAL: g_value_set_uint (value, label->mnemonic_keyval); break; + case PROP_MNEMONIC_WIDGET: + g_value_set_object (value, (GObject*) label->mnemonic_widget); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -425,21 +439,21 @@ gtk_label_activate_mnemonic (GtkWidget *widget, if (GTK_LABEL (widget)->mnemonic_widget) return gtk_widget_activate_mnemonic (GTK_LABEL (widget)->mnemonic_widget, group_cycling); - /* Try to find the widget to activate by traversing the widget - * hierarachy. + /* Try to find the widget to activate by traversing the + * widget's ancestry. */ - parent = widget->parent; while (parent) { if (GTK_WIDGET_CAN_FOCUS (parent) || (!group_cycling && GTK_WIDGET_GET_CLASS (parent)->activate_signal) || - (parent->parent && GTK_IS_NOTEBOOK (parent->parent)) || + (parent->parent && GTK_IS_NOTEBOOK (parent->parent)) || (GTK_IS_MENU_ITEM (parent))) return gtk_widget_activate_mnemonic (parent, group_cycling); parent = parent->parent; } + /* barf if there was nothing to activate */ g_warning ("Couldn't find a target for a mnemonic activation."); gdk_beep (); @@ -447,11 +461,12 @@ gtk_label_activate_mnemonic (GtkWidget *widget, } static void -gtk_label_setup_mnemonic (GtkLabel *label, guint last_key) +gtk_label_setup_mnemonic (GtkLabel *label, + guint last_key) { GtkWidget *toplevel; - if ((last_key != GDK_VoidSymbol) && label->mnemonic_window) + if (last_key != GDK_VoidSymbol && label->mnemonic_window) gtk_window_remove_mnemonic (label->mnemonic_window, last_key, GTK_WIDGET (label)); @@ -499,13 +514,18 @@ gtk_label_hierarchy_changed (GtkWidget *widget) * mnemonic collisions and toggle focus between the colliding widgets otherwise. **/ void -gtk_label_set_mnemonic_widget (GtkLabel *label, - GtkWidget *widget) +gtk_label_set_mnemonic_widget (GtkLabel *label, + GtkWidget *widget) { g_return_if_fail (GTK_IS_LABEL (label)); - g_return_if_fail (GTK_IS_WIDGET (widget)); + if (widget) + g_return_if_fail (GTK_IS_WIDGET (widget)); + if (label->mnemonic_widget) + gtk_widget_unref (label->mnemonic_widget); label->mnemonic_widget = widget; + if (label->mnemonic_widget) + gtk_widget_ref (label->mnemonic_widget); } @@ -584,7 +604,8 @@ gtk_label_set_attributes_internal (GtkLabel *label, /* Calculates text, attrs and mnemonic_keyval from - * label, use_underline and use_markup */ + * label, use_underline and use_markup + */ static void gtk_label_recalculate (GtkLabel *label) { @@ -604,6 +625,7 @@ gtk_label_recalculate (GtkLabel *label) if (!label->use_underline) { guint keyval = label->mnemonic_keyval; + label->mnemonic_keyval = GDK_VoidSymbol; gtk_label_setup_mnemonic (label, keyval); } @@ -873,6 +895,16 @@ gtk_label_get (GtkLabel *label, *str = label->text; } +static void +gtk_label_destroy (GtkObject *object) +{ + GtkLabel *label = GTK_LABEL (object); + + gtk_label_set_mnemonic_widget (label, NULL); + + GTK_OBJECT_CLASS (parent_class)->destroy (object); +} + static void gtk_label_finalize (GObject *object) { @@ -1497,6 +1529,7 @@ window_to_layout_coords (GtkLabel *label, } } +#if 0 static void layout_to_window_coords (GtkLabel *label, gint *x, @@ -1522,6 +1555,7 @@ layout_to_window_coords (GtkLabel *label, *y -= widget->allocation.y; /* go to selection window */ } } +#endif static void get_layout_index (GtkLabel *label, diff --git a/gtk/gtklabel.h b/gtk/gtklabel.h index 3e3d783e4a..bef1ca491e 100644 --- a/gtk/gtklabel.h +++ b/gtk/gtklabel.h @@ -79,46 +79,38 @@ struct _GtkLabelClass GtkMiscClass parent_class; }; -GtkType gtk_label_get_type (void) G_GNUC_CONST; -GtkWidget *gtk_label_new (const char *str); -GtkWidget *gtk_label_new_with_mnemonic (const char *str); - -void gtk_label_set_text (GtkLabel *label, - const char *str); -G_CONST_RETURN gchar *gtk_label_get_text (GtkLabel *label); - -void gtk_label_set_attributes (GtkLabel *label, - PangoAttrList *attrs); - -void gtk_label_set_markup (GtkLabel *label, - const gchar *str); -void gtk_label_set_markup_with_mnemonic (GtkLabel *label, - const gchar *str); - -guint gtk_label_get_mnemonic_keyval (GtkLabel *label); -void gtk_label_set_justify (GtkLabel *label, - GtkJustification jtype); -void gtk_label_set_pattern (GtkLabel *label, - const gchar *pattern); -void gtk_label_set_line_wrap (GtkLabel *label, - gboolean wrap); - -void gtk_label_set_text_with_mnemonic (GtkLabel *label, - const gchar *string); -void gtk_label_set_mnemonic_widget (GtkLabel *label, - GtkWidget *widget); - -void gtk_label_set_selectable (GtkLabel *label, - gboolean setting); -gboolean gtk_label_get_selectable (GtkLabel *label); - -void gtk_label_select_region (GtkLabel *label, - gint start_offset, - gint end_offset); - -void gtk_label_get_layout_offsets (GtkLabel *label, - gint *x, - gint *y); +GtkType gtk_label_get_type (void) G_GNUC_CONST; +GtkWidget* gtk_label_new (const char *str); +GtkWidget* gtk_label_new_with_mnemonic (const char *str); +void gtk_label_set_text (GtkLabel *label, + const char *str); +G_CONST_RETURN gchar* gtk_label_get_text (GtkLabel *label); +void gtk_label_set_attributes (GtkLabel *label, + PangoAttrList *attrs); +void gtk_label_set_markup (GtkLabel *label, + const gchar *str); +void gtk_label_set_markup_with_mnemonic (GtkLabel *label, + const gchar *str); +guint gtk_label_get_mnemonic_keyval (GtkLabel *label); +void gtk_label_set_mnemonic_widget (GtkLabel *label, + GtkWidget *widget); +void gtk_label_set_text_with_mnemonic (GtkLabel *label, + const gchar *string); +void gtk_label_set_justify (GtkLabel *label, + GtkJustification jtype); +void gtk_label_set_pattern (GtkLabel *label, + const gchar *pattern); +void gtk_label_set_line_wrap (GtkLabel *label, + gboolean wrap); +void gtk_label_set_selectable (GtkLabel *label, + gboolean setting); +gboolean gtk_label_get_selectable (GtkLabel *label); +void gtk_label_select_region (GtkLabel *label, + gint start_offset, + gint end_offset); +void gtk_label_get_layout_offsets (GtkLabel *label, + gint *x, + gint *y); #ifndef GTK_DISABLE_COMPAT_H # define gtk_label_set gtk_label_set_text diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index 390538de91..1ee200d4d8 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -3638,18 +3638,17 @@ gtk_notebook_activate_mnemonic_switch_page (GtkWidget *child, gpointer data) { GtkNotebook *notebook = GTK_NOTEBOOK (data); - GtkNotebookPage *page; GList *list; - + list = g_list_find_custom (notebook->children, child, gtk_notebook_page_compare_tab); - if (!list) - return TRUE; + if (list) + { + GtkNotebookPage *page = list->data; + gtk_notebook_switch_page (notebook, page, -1); + } - page = list->data; - - gtk_notebook_switch_page (notebook, page, -1); return TRUE; } diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index c63ff4a590..52cf619ad8 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -252,6 +252,22 @@ gtk_widget_get_type (void) return widget_type; } +static gboolean +accumulator_stop_handled_emission (GSignalInvocationHint *ihint, + GValue *return_accu, + const GValue *handler_return, + gpointer data) +{ + gboolean continue_emission; + gboolean signal_handled; + + signal_handled = g_value_get_boolean (handler_return); + g_value_set_boolean (return_accu, signal_handled); + continue_emission = !signal_handled; + + return continue_emission; +} + /***************************************** * gtk_widget_class_init: * @@ -465,13 +481,14 @@ gtk_widget_class_init (GtkWidgetClass *klass) gtk_accel_group_create_remove (GTK_CLASS_TYPE (object_class), GTK_RUN_LAST, GTK_SIGNAL_OFFSET (GtkWidgetClass, remove_accelerator)); widget_signals[ACTIVATE_MNEMONIC] = - gtk_signal_new ("activate_mnemonic", - GTK_RUN_LAST, - GTK_CLASS_TYPE (object_class), - GTK_SIGNAL_OFFSET (GtkWidgetClass, activate_mnemonic), - gtk_marshal_BOOLEAN__BOOLEAN, - GTK_TYPE_BOOL, 1, - GTK_TYPE_BOOL); + g_signal_newc ("activate_mnemonic", + GTK_CLASS_TYPE (object_class), + GTK_RUN_LAST, + GTK_SIGNAL_OFFSET (GtkWidgetClass, activate_mnemonic), + accumulator_stop_handled_emission, NULL, + gtk_marshal_BOOLEAN__BOOLEAN, + GTK_TYPE_BOOL, 1, + GTK_TYPE_BOOL); widget_signals[GRAB_FOCUS] = gtk_signal_new ("grab_focus", GTK_RUN_LAST | GTK_RUN_ACTION, @@ -2191,17 +2208,18 @@ gboolean gtk_widget_activate_mnemonic (GtkWidget *widget, gboolean group_cycling) { - gboolean handled = FALSE; + gboolean handled; g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE); + group_cycling = group_cycling != FALSE; if (!GTK_WIDGET_IS_SENSITIVE (widget)) - return TRUE; - - gtk_signal_emit_by_name (GTK_OBJECT (widget), - "activate_mnemonic", - group_cycling, - &handled); + handled = TRUE; + else + gtk_signal_emit (GTK_OBJECT (widget), + widget_signals[ACTIVATE_MNEMONIC], + group_cycling, + &handled); return handled; } @@ -2209,14 +2227,19 @@ static gboolean gtk_widget_real_activate_mnemonic (GtkWidget *widget, gboolean group_cycling) { - if (group_cycling) - gtk_widget_grab_focus (widget); - else if (!group_cycling) + if (!group_cycling && GTK_WIDGET_GET_CLASS (widget)->activate_signal) gtk_widget_activate (widget); + else if (GTK_WIDGET_CAN_FOCUS (widget)) + gtk_widget_grab_focus (widget); + else + { + g_warning ("widget `%s' isn't suitable for mnemonic activation", + G_OBJECT_TYPE_NAME (widget)); + gdk_beep (); + } return TRUE; } - static gint gtk_widget_real_key_press_event (GtkWidget *widget, GdkEventKey *event) diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index dbad8c98e8..1d5d4bee85 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -55,11 +55,13 @@ typedef enum GTK_HAS_FOCUS = 1 << 12, /* widget is allowed to receive the default via gtk_widget_grab_default - * and will reserve space to draw the default if possible */ + * and will reserve space to draw the default if possible + */ GTK_CAN_DEFAULT = 1 << 13, /* the widget currently is receiving the default action and should be drawn - * appropriately if possible */ + * appropriately if possible + */ GTK_HAS_DEFAULT = 1 << 14, GTK_HAS_GRAB = 1 << 15, @@ -69,7 +71,8 @@ typedef enum GTK_APP_PAINTABLE = 1 << 19, /* the widget when focused will receive the default action and have - * HAS_DEFAULT set even if there is a different widget set as default */ + * HAS_DEFAULT set even if there is a different widget set as default + */ GTK_RECEIVES_DEFAULT = 1 << 20, GTK_DOUBLE_BUFFERED = 1 << 21 diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 62067deacb..a61ca77414 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -822,29 +822,6 @@ gtk_window_remove_accel_group (GtkWindow *window, gtk_accel_group_detach (accel_group, GTK_OBJECT (window)); } -GtkAccelGroup* -gtk_window_get_default_accel_group (GtkWindow *window) -{ - GtkAccelGroup *group; - - g_return_val_if_fail (GTK_IS_WINDOW (window), NULL); - - group = gtk_object_get_data (GTK_OBJECT (window), - "gtk-accel-group"); - - if (group == NULL) - { - group = gtk_accel_group_new (); - gtk_window_add_accel_group (window, group); - gtk_object_set_data (GTK_OBJECT (window), - "gtk-accel-group", - group); - gtk_accel_group_unref (group); - } - - return group; -} - void gtk_window_add_mnemonic (GtkWindow *window, guint keyval, @@ -853,17 +830,18 @@ gtk_window_add_mnemonic (GtkWindow *window, GtkWindowMnemonic key; GtkWindowMnemonic *mnemonic; - g_return_if_fail (window != NULL); g_return_if_fail (GTK_IS_WINDOW (window)); g_return_if_fail (GTK_IS_WIDGET (target)); key.window = window; key.keyval = keyval; - mnemonic = g_hash_table_lookup (mnemonic_hash_table, &key); if (mnemonic) - mnemonic->targets = g_slist_prepend (mnemonic->targets, target); + { + g_return_if_fail (g_slist_find (mnemonic->targets, target) == NULL); + mnemonic->targets = g_slist_prepend (mnemonic->targets, target); + } else { mnemonic = g_new (GtkWindowMnemonic, 1); @@ -881,26 +859,20 @@ gtk_window_remove_mnemonic (GtkWindow *window, GtkWindowMnemonic key; GtkWindowMnemonic *mnemonic; - g_return_if_fail (window != NULL); g_return_if_fail (GTK_IS_WINDOW (window)); g_return_if_fail (GTK_IS_WIDGET (target)); key.window = window; key.keyval = keyval; - mnemonic = g_hash_table_lookup (mnemonic_hash_table, &key); - g_assert (mnemonic); + g_return_if_fail (mnemonic && g_slist_find (mnemonic->targets, target) != NULL); - if (mnemonic) + mnemonic->targets = g_slist_remove (mnemonic->targets, target); + if (mnemonic->targets == NULL) { - mnemonic->targets = g_slist_remove (mnemonic->targets, target); - - if (mnemonic->targets == NULL) - { - g_hash_table_remove (mnemonic_hash_table, mnemonic); - g_free (mnemonic); - } + g_hash_table_remove (mnemonic_hash_table, mnemonic); + g_free (mnemonic); } } @@ -915,15 +887,13 @@ gtk_window_activate_mnemonic (GtkWindow *window, GtkWidget *widget, *chosen_widget; gboolean overloaded; - g_return_val_if_fail (window != NULL, FALSE); g_return_val_if_fail (GTK_IS_WINDOW (window), FALSE); - if (modifier != window->mnemonic_modifier) + if (window->mnemonic_modifier != (modifier & gtk_accelerator_get_default_mod_mask ())) return FALSE; key.window = window; key.keyval = keyval; - mnemonic = g_hash_table_lookup (mnemonic_hash_table, &key); if (!mnemonic) @@ -953,9 +923,11 @@ gtk_window_activate_mnemonic (GtkWindow *window, if (chosen_widget) { /* For round robin we put the activated entry on - * the end of the list after activation */ + * the end of the list after activation + */ mnemonic->targets = g_slist_remove (mnemonic->targets, chosen_widget); mnemonic->targets = g_slist_append (mnemonic->targets, chosen_widget); + return gtk_widget_activate_mnemonic (chosen_widget, overloaded); } return FALSE; @@ -965,8 +937,8 @@ void gtk_window_set_mnemonic_modifier (GtkWindow *window, GdkModifierType modifier) { - g_return_if_fail (window != NULL); g_return_if_fail (GTK_IS_WINDOW (window)); + g_return_if_fail ((modifier & ~GDK_MODIFIER_MASK) == 0); window->mnemonic_modifier = modifier; } @@ -975,7 +947,6 @@ void gtk_window_set_position (GtkWindow *window, GtkWindowPosition position) { - g_return_if_fail (window != NULL); g_return_if_fail (GTK_IS_WINDOW (window)); window->position = position; @@ -1539,6 +1510,14 @@ gtk_window_mnemonic_hash_remove (gpointer key, if (mnemonic->window == window) { + if (mnemonic->targets) + { + gchar *name = gtk_accelerator_name (mnemonic->keyval, 0); + + g_warning ("mnemonic \"%s\" wasn't removed for widget (%p)", + name, mnemonic->targets->data); + g_free (name); + } g_slist_free (mnemonic->targets); g_free (mnemonic); @@ -2064,12 +2043,9 @@ gtk_window_key_press_event (GtkWidget *widget, handled = FALSE; - if (window->focus_widget && - window->focus_widget != widget && + if (window->focus_widget && window->focus_widget != widget && GTK_WIDGET_IS_SENSITIVE (window->focus_widget)) - { - handled = gtk_widget_event (window->focus_widget, (GdkEvent*) event); - } + handled = gtk_widget_event (window->focus_widget, (GdkEvent*) event); if (!handled) handled = gtk_window_activate_mnemonic (window, diff --git a/gtk/gtkwindow.h b/gtk/gtkwindow.h index 0de5aa5e6f..04e015c858 100644 --- a/gtk/gtkwindow.h +++ b/gtk/gtkwindow.h @@ -174,9 +174,6 @@ void gtk_window_set_modal (GtkWindow *window, gboolean modal); GList* gtk_window_list_toplevels (void); -/* Get the "built-in" accel group (convenience thing) */ -GtkAccelGroup* gtk_window_get_default_accel_group (GtkWindow *window); - void gtk_window_add_mnemonic (GtkWindow *window, guint keyval, GtkWidget *target); diff --git a/gtk/testgtk.c b/gtk/testgtk.c index 49c405b0d7..b44d880c6f 100644 --- a/gtk/testgtk.c +++ b/gtk/testgtk.c @@ -166,12 +166,8 @@ create_buttons (void) if (!window) { - GtkAccelGroup *accel_group; - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - accel_group = gtk_window_get_default_accel_group (GTK_WINDOW (window)); - gtk_signal_connect (GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC (gtk_widget_destroyed), &window); diff --git a/tests/testgtk.c b/tests/testgtk.c index 49c405b0d7..b44d880c6f 100644 --- a/tests/testgtk.c +++ b/tests/testgtk.c @@ -166,12 +166,8 @@ create_buttons (void) if (!window) { - GtkAccelGroup *accel_group; - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - accel_group = gtk_window_get_default_accel_group (GTK_WINDOW (window)); - gtk_signal_connect (GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC (gtk_widget_destroyed), &window);