[totem] disc-recorder: Hide menu items when unavailable



commit 895e5339f759fda1624d5d8b160fc76d8778dacc
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Jan 8 17:02:55 2014 +0100

    disc-recorder: Hide menu items when unavailable
    
    https://bugzilla.gnome.org/show_bug.cgi?id=721797

 .../brasero-disc-recorder/totem-disc-recorder.c    |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/src/plugins/brasero-disc-recorder/totem-disc-recorder.c 
b/src/plugins/brasero-disc-recorder/totem-disc-recorder.c
index 6198ec0..56d4892 100644
--- a/src/plugins/brasero-disc-recorder/totem-disc-recorder.c
+++ b/src/plugins/brasero-disc-recorder/totem-disc-recorder.c
@@ -335,6 +335,20 @@ totem_disc_recorder_file_opened (TotemObject *totem,
 }
 
 static void
+menu_append_hidden (GMenu      *menu,
+                   const char *label,
+                   const char *detailed_action)
+{
+       GMenuItem *item;
+
+       item = g_menu_item_new (label, detailed_action);
+       g_menu_item_set_attribute_value (item, "hidden-when",
+                                        g_variant_new_string ("action-disabled"));
+       g_menu_append_item (menu, item);
+       g_object_unref (item);
+}
+
+static void
 impl_activate (PeasActivatable *plugin)
 {
        TotemDiscRecorderPlugin *pi = TOTEM_DISC_RECORDER_PLUGIN (plugin);
@@ -377,9 +391,9 @@ impl_activate (PeasActivatable *plugin)
 
        /* Install the menu */
        menu = totem_object_get_menu_section (priv->totem, "burn-placeholder");
-       g_menu_append (G_MENU (menu), _("_Create Video Disc..."), "app.media-optical-video-new");
-       g_menu_append (G_MENU (menu), _("Copy Vide_o DVD..."), "app.media-optical-copy");
-       g_menu_append (G_MENU (menu), _("Copy (S)VCD..."), "app.media-optical-copy-vcd");
+       menu_append_hidden (G_MENU (menu), _("_Create Video Disc..."), "app.media-optical-video-new");
+       menu_append_hidden (G_MENU (menu), _("Copy Vide_o DVD..."), "app.media-optical-copy");
+       menu_append_hidden (G_MENU (menu), _("Copy (S)VCD..."), "app.media-optical-copy-vcd");
 
        if (!totem_object_is_paused (priv->totem) && !totem_object_is_playing (priv->totem)) {
                set_menu_items_state (pi, FALSE, FALSE, FALSE);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]