GNOME Bugzilla – Bug 103456
New function gtk_widget_get_mnemonic_labels() requested.
Last modified: 2011-02-04 16:12:26 UTC
In a comment in bug 72249 Havoc stated: We should add a GTK function: GList* gtk_widget_get_mnemonic_labels(GtkWidget *w); Should be possible to implement sanely on the GTK level. This would then allow us to avoid keeping labelled-by properties updated manually.
Would also need change notification to be useful. I'd like to see a detailed API proposal before comitting as to whether this is a good idea or not. Would also be a real pain to implement, I suspect, but that's just a detail... Putting on 2.4 API freeze for the moment.
Created attachment 13743 [details] [review] Proposed patch
The proposed patch is a suggested API and implementation. I have not added change notification.
padraig, owen: This bug is blocking us (it's creating a problem since we need it for GNOME 2.4 !). Owen, have you had a chance to review this API? Can we agree to fix this for gtk-2.4? Without this fix, we are having significant issues making combo-boxes usable for screenreader users.
GTK+-2.4 will *not* be in GNOME-2.4. I'll try to look at this soon, but it has no relevance for GNOME-2.4.
Patch comments: * The doc comment needs to describe the memory management for the returned GList. Actually, I think the memory management and the name should match gtk_widget_list_accel_closure(), gtk_window_list_toplevels(). * There is some problems with the cleanup of the mnemonic widget setup, do to the fact that weak_notify() occurs at destroy time, gtk_label_set_mnemonic_widget (label, entry); g_object_ref (entry); gtk_widget_destroy (entry); /* label->mnemonic_widget is cleared */ gtk_widget_destroy (label); /* label is freed, still in gtk_widget_get_mnemonic_widgets result */ For this reason label_mnemonic_widget_weak_notify() should call _gtk_widget_remove_mnemonic_label(). * I think gtk_widget_add/remove_mnemonic_label() should be public, not private. GtkLabel should not be conceptually tied to be part of the GTK+ core. * The doc comment for gtk_widget_get_mnemonic_labels() could use some expansion ... "is a mnemonic widget" isn't very clear. Perhaps: "is the target of a mnemonic (see, for example, gtk_label_set_mnemonic_widget())" Other than that looks good to me. Let's ignore the subject of change notification for the moment.
Created attachment 18482 [details] [review] Updated patch
Will this be reviewed for GTK 2.4?
It's on the 2.4 API freeze milestone, hence it will be reviewed prior to freezing the 2.4 API.
*** Bug 79327 has been marked as a duplicate of this bug. ***
Created attachment 24772 [details] [review] Patch as applied
Applied with various changes: - Fixed indentation in gtkwidget.h - Added g_return_if_fails, to add/remove mnemonic_label() - Added API docs for add/remove mnemonic_label() - Fixed return value docs for list_mnemonic_label to describe memory managemnt - Make the lists stored in qdata GSList not GList - Prepend not append to the lists stored internerally "efficiency" but here done just for consistency. - Use g_object_set_qdata_full() not to avoid having to check for every widget at finalization. (Note the use of steal_qdata() .. this isn't the most efficient thing if we have a lot of labels, but it's really simple for the normal case.) - Add gtk_widget_remove_mnemonic_label() to the needed place in gtk_label_set_mnemoniC_widget(). - My comment about label_mnemonic_widget_weak_notify() calling remove_mnemonic_label is wrong since you must not operate on the object in a weak notifier. The right fix was to clear the mnemonic_label list in gtk_widget_real_destroy() (Patch actually set mnemonic_widget to NULL before calling gtk_widget_remove_mnemonic_label (label->mnemonic_widget) Wed Feb 25 12:21:32 2004 Owen Taylor <otaylor@redhat.com> * gtk/gtkwidget.[ch] gtk/gtklabel.c: Patch from Padraig O'Briain to add gtk_widget_add/remove_mnemonic_label, gtk_widget_get_mnemonic_labels(). (#103456)
*** Bug 72251 has been marked as a duplicate of this bug. ***