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 699289 - API request: MenuItem has no function to set label markup
API request: MenuItem has no function to set label markup
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Documentation
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2013-04-30 08:13 UTC by Luc Pi
Modified: 2013-05-20 22:50 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
0001-Add-doc-to-set-markup-and-accelerator-on-a-MenuItem.patch (1.92 KB, patch)
2013-05-11 08:18 UTC, Luc Pi
committed Details | Review
0002-typo.patch (600 bytes, patch)
2013-05-11 08:23 UTC, Luc Pi
committed Details | Review

Description Luc Pi 2013-04-30 08:13:58 UTC
There is no direct function to set markup on a MenuItem.

An example when markup is used is for text formatting menu items (see gnote/tomboy as an example), so the label reflects the formatting.

The workaround is
to know that the MenuItem is also a Bin, and that its child is a Label. Then we can call gtk_label_set_markup().


I suggest to add:

GtkWidget * gtk_menu_item_new_with_markup (const gchar *label);
void        gtk_menu_item_set_markup      (GtkMenuItem *menu_item,
                                           const gchar *label);
void        gtk_menu_item_set_markup_with_mnemonic
                                          (GtkMenuItem *menu_item,
                                           const gchar *label);
gboolean    gtk_menu_item_get_use_markup  (GtkMenuItem *menu_item);
void        gtk_menu_item_set_use_markup  (GtkMenuItem *menu_item);
                                           gboolean     setting);



(I can provide a patch, if it makes sense)
Comment 1 Matthias Clasen 2013-05-04 23:20:53 UTC
> The workaround is
> to know that the MenuItem is also a Bin, and that its child is a Label. Then we
> can call gtk_label_set_markup().

Not a workaround - with the current crop of menu item widgets, it is expected.
Comment 2 Luc Pi 2013-05-05 03:38:12 UTC
From an application developer point of view, looking at the documentation, it is hidden. You have to discover it. You need a certain knowledge of GTK+ to figure it out. You can create a menu item with a label, mnemonic, but no markup.

GtkWidget *         gtk_menu_item_new                   (void);
GtkWidget *         gtk_menu_item_new_with_label        (const gchar *label);
GtkWidget *         gtk_menu_item_new_with_mnemonic     (const gchar *label);
void                gtk_menu_item_set_label             (GtkMenuItem *menu_item,
                                                         const gchar *label);

You could possibly guess that the menu item hosts a label, but again there is no such GtkWidget* get_label().

You need to get a good view on the object hierarchy and packing system to figure out that you can get the label as the child of the menu item taken as a bin.

Certainly a piece of cake for an advanced GTK+ developer, but not for everybody.

Maybe the API could be a bit more consistent here.


I think that this is at least missing in the documentation.
Comment 3 Matthias Clasen 2013-05-06 11:13:00 UTC
> You need a certain knowledge of GTK+ to figure it out.

Thats generally true when using any complex library.

Closing this since I don't want to carry around more open documentation bugs - feel free to reopen if you have a patch to attach.
Comment 4 Luc Pi 2013-05-11 08:18:24 UTC
Created attachment 243832 [details] [review]
0001-Add-doc-to-set-markup-and-accelerator-on-a-MenuItem.patch

this fixes also bug 699290.
Comment 5 Luc Pi 2013-05-11 08:23:13 UTC
Created attachment 243833 [details] [review]
0002-typo.patch

Not related to this bug report, but that's a typo I meant to report long ago. Maybe it could be fixed at the same time. Let me know if you want a separated report.
Comment 6 Matthias Clasen 2013-05-17 02:54:59 UTC
Review of attachment 243832 [details] [review]:

ok
Comment 7 Matthias Clasen 2013-05-17 02:55:19 UTC
Review of attachment 243833 [details] [review]:

ok
Comment 8 Luc Pi 2013-05-20 03:53:34 UTC
Thanks