307
308
g_return_if_fail (parent_shell != NULL);
308
309
g_warn_if_fail (object == menu_item);
310
unity_gtk_menu_shell_handle_item_notify (parent_shell, item, pspec);
311
unity_gtk_menu_shell_handle_item_notify (parent_shell, item, g_param_spec_get_name (pspec));
372
unity_gtk_menu_item_finalize (GObject *object)
374
UnityGtkMenuItem *item;
376
g_return_if_fail (UNITY_GTK_IS_MENU_ITEM (object));
378
item = UNITY_GTK_MENU_ITEM (object);
380
g_free (item->label);
383
G_OBJECT_CLASS (unity_gtk_menu_item_parent_class)->finalize (object);
371
387
unity_gtk_menu_item_class_init (UnityGtkMenuItemClass *klass)
373
389
GObjectClass *object_class = G_OBJECT_CLASS (klass);
375
391
object_class->dispose = unity_gtk_menu_item_dispose;
392
object_class->finalize = unity_gtk_menu_item_finalize;
416
433
GtkWidget *submenu = gtk_menu_item_get_submenu (menu_item);
418
435
if (submenu != NULL)
419
item->child_shell = unity_gtk_menu_shell_new (GTK_MENU_SHELL (submenu));
436
item->child_shell = unity_gtk_menu_shell_new_internal (GTK_MENU_SHELL (submenu));
422
439
item->child_shell_valid = TRUE;
482
g_strdup_no_mnemonics (const gchar *str)
491
string = g_malloc (strlen (str) + 1);
495
for (in = str; *in != '\0'; in++)
508
/* double underscores are not accelerator markers */
516
/* trailing underscores are not accelerator markers */
465
529
unity_gtk_menu_item_get_label (UnityGtkMenuItem *item)
469
531
g_return_val_if_fail (UNITY_GTK_IS_MENU_ITEM (item), NULL);
470
532
g_return_val_if_fail (item->menu_item != NULL, NULL);
472
label = gtk_menu_item_get_label (item->menu_item);
474
if (label != NULL && label[0] != '\0')
534
if (item->label == NULL)
476
if (GTK_IS_IMAGE_MENU_ITEM (item->menu_item))
536
const gchar *label = gtk_menu_item_get_label (item->menu_item);
538
if (label != NULL && label[0] != '\0')
478
GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (item->menu_item);
480
if (gtk_image_menu_item_get_use_stock (image_menu_item))
540
if (GTK_IS_IMAGE_MENU_ITEM (item->menu_item))
482
GtkStockItem stock_item;
484
if (gtk_stock_lookup (label, &stock_item))
485
label = stock_item.label;
542
GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (item->menu_item);
544
if (gtk_image_menu_item_get_use_stock (image_menu_item))
546
GtkStockItem stock_item;
548
if (gtk_stock_lookup (label, &stock_item))
549
label = stock_item.label;
554
if (label == NULL || label[0] == '\0')
555
label = gtk_menu_item_get_nth_label (item->menu_item, 0);
557
if (label != NULL && label[0] != '\0')
559
if (item->parent_shell == NULL || item->parent_shell->has_mnemonics)
560
item->label = g_strdup (label);
562
item->label = g_strdup_no_mnemonics (label);
490
if (label == NULL || label[0] == '\0')
491
label = gtk_menu_item_get_nth_label (item->menu_item, 0);
493
return label != NULL && label[0] != '\0' ? label : NULL;