Merge lp:~ted/libdbusmenu/lp903200 into lp:libdbusmenu/0.6

Proposed by Ted Gould
Status: Merged
Approved by: Charles Kerr
Approved revision: 381
Merged at revision: 412
Proposed branch: lp:~ted/libdbusmenu/lp903200
Merge into: lp:libdbusmenu/0.6
Diff against target: 68 lines (+39/-4)
1 file modified
libdbusmenu-gtk/genericmenuitem.c (+39/-4)
To merge this branch: bzr merge lp:~ted/libdbusmenu/lp903200
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve
Review via email: mp+101257@code.launchpad.net

Description of the change

Being more explicit about what is a mnemonic and what is not.

To post a comment you must log in.
Revision history for this message
Charles Kerr (charlesk) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'libdbusmenu-gtk/genericmenuitem.c'
--- libdbusmenu-gtk/genericmenuitem.c 2012-03-01 22:25:25 +0000
+++ libdbusmenu-gtk/genericmenuitem.c 2012-04-09 17:14:18 +0000
@@ -216,6 +216,31 @@
216 return g_strdup(values[disposition].default_color);216 return g_strdup(values[disposition].default_color);
217}217}
218218
219/* Check to see if we've got mnemonic stuff goin' on */
220static gboolean
221has_mnemonic (const gchar * string, gboolean previous_underscore)
222{
223 if (string == NULL || string[0] == '\0') {
224 return FALSE;
225 }
226
227 if (g_utf8_get_char(string) == '_') {
228 if (previous_underscore) {
229 return has_mnemonic(g_utf8_next_char(string), FALSE);
230 } else {
231 return has_mnemonic(g_utf8_next_char(string), TRUE);
232 }
233 } else {
234 if (previous_underscore) {
235 return TRUE;
236 } else {
237 return has_mnemonic(g_utf8_next_char(string), FALSE);
238 }
239 }
240
241 return FALSE;
242}
243
219/* Set the label on the item */244/* Set the label on the item */
220static void245static void
221set_label (GtkMenuItem * menu_item, const gchar * in_label)246set_label (GtkMenuItem * menu_item, const gchar * in_label)
@@ -287,11 +312,15 @@
287 if (labelw == NULL) {312 if (labelw == NULL) {
288 /* Build it */313 /* Build it */
289 labelw = GTK_LABEL(gtk_accel_label_new(local_label));314 labelw = GTK_LABEL(gtk_accel_label_new(local_label));
290 gtk_label_set_use_underline(GTK_LABEL(labelw), TRUE);
291 gtk_label_set_use_markup(GTK_LABEL(labelw), TRUE);315 gtk_label_set_use_markup(GTK_LABEL(labelw), TRUE);
292 gtk_misc_set_alignment(GTK_MISC(labelw), 0.0, 0.5);316 gtk_misc_set_alignment(GTK_MISC(labelw), 0.0, 0.5);
293 gtk_accel_label_set_accel_widget(GTK_ACCEL_LABEL(labelw), GTK_WIDGET(menu_item));317
294 gtk_label_set_markup_with_mnemonic(labelw, local_label);318 if (has_mnemonic(in_label, FALSE)) {
319 gtk_label_set_use_underline(GTK_LABEL(labelw), TRUE);
320 gtk_accel_label_set_accel_widget(GTK_ACCEL_LABEL(labelw), GTK_WIDGET(menu_item));
321 gtk_label_set_markup_with_mnemonic(labelw, local_label);
322 }
323
295 gtk_widget_show(GTK_WIDGET(labelw));324 gtk_widget_show(GTK_WIDGET(labelw));
296325
297 /* Check to see if it needs to be in the bin for this326 /* Check to see if it needs to be in the bin for this
@@ -309,7 +338,13 @@
309 getting in. */338 getting in. */
310 suppress_update = TRUE;339 suppress_update = TRUE;
311 } else {340 } else {
312 gtk_label_set_markup_with_mnemonic(labelw, local_label);341 if (has_mnemonic(in_label, FALSE)) {
342 gtk_label_set_use_underline(GTK_LABEL(labelw), TRUE);
343 gtk_accel_label_set_accel_widget(GTK_ACCEL_LABEL(labelw), GTK_WIDGET(menu_item));
344 gtk_label_set_markup_with_mnemonic(labelw, local_label);
345 } else {
346 gtk_label_set_markup(labelw, local_label);
347 }
313 }348 }
314 }349 }
315350

Subscribers

People subscribed via source and target branches

to all changes: