After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 54529 - make AccelGroup and AccelLabel work with GObjects rather than GtkObjects/GtkWidgets
make AccelGroup and AccelLabel work with GObjects rather than GtkObjects/GtkW...
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
1.3.x
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2001-05-12 10:15 UTC by James Henstridge
Modified: 2011-02-04 16:09 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
first go at AccelGroup/AccelLabel patch (37.52 KB, patch)
2001-05-12 10:16 UTC, James Henstridge
none Details | Review
revised patch that also converts GtkAccelGroup to a GObject (44.79 KB, patch)
2001-07-15 07:38 UTC, James Henstridge
none Details | Review

Description James Henstridge 2001-05-12 10:15:18 UTC
First a bit of rationale for this patch:

I was thinking about what would be needed to do an action based menuing
system where the menu items in the menu activate action objects.  For
accelerators to work properly in a system like this, the accelerators
should be attached to the action objects rather than menu items.  This is
so that two menu items associated with the same action would display the
same accelerator (the GtkAccelLabel for the menu items would point at the
action object).

The attached patch is the first try at the changes to gtk+ necessary to do
a menu system like this.  It still has a few issues.

The first part is a patch to GtkAccelGroup that allows accelerators to be
set on arbitrary GObjects rather than just GtkObjects.  It has one issue at
the moment though.  In two places it connects to the "destroy" signal of
the object.

In the second case, it connects gtk_accel_group_delete_entries to clean up
the list of entries associated with an object.  This could probably be
changed to use g_object_set_qdata_full so we can set a GDestroyNotify. 
Some of the g_object_get_qdata calls would need to be changed to
g_object_steal_qdata for this to work.

In the first case, the function is gtk_accel_group_object_destroy which
actually uses the object passed as an argument, which makes it more
difficult to use as a GDestroyNotify.  The one idea I came up with was to
traverse the attach_objects GSList of the first accel group in free_list to
find the object with ref_count==0 (which will be the object being
finalized).  But this seems very hackish.

The second part of the patch is to allow GtkAccelLabel to watch
accelerators on arbitrary GObjects rather than just GtkWidgets.  It changes
the accel_widget property to accel_object, and the
gtk_accel_label_set_accel_widget function to
gtk_accel_label_set_accel_object (a compatibility macro was also added).  I
also converted GtkAccelLabel over to properties rather than gtk 1.2 style args.

If the issues in the AccelGroup part of the patch can't be resolved, I can
put together a patch that only contains the AccelLabel parts.
Comment 1 James Henstridge 2001-05-12 10:16:48 UTC
Created attachment 531 [details] [review]
first go at AccelGroup/AccelLabel patch
Comment 2 James Henstridge 2001-05-20 07:47:11 UTC
Another useful feature would be to delegate which object accelerator
changes go to in gtk_menu_key_press().  This would be needed for
dynamic accelerator changing to work correctly if the menu item was
just acting as a proxy for an action object.  I haven't done a patch
for this yet.
Comment 3 James Henstridge 2001-07-15 07:38:51 UTC
Created attachment 742 [details] [review]
revised patch that also converts GtkAccelGroup to a GObject
Comment 4 James Henstridge 2001-07-15 07:45:02 UTC
attached update patch.  This one doesn't rely on the accel object
having a destroy signal (it uses weak refs and destroy notifiers).  It
also converts GtkAccelGroup to a GObject which fixes bug #55799.
Comment 5 James Henstridge 2001-07-29 12:51:03 UTC
patch applied to CVS