[glib/wip/menus-rebase2: 18/64] GMenuItem: cleanup action/target setters



commit af07470addcde8fa178a20c7903e15e36226c60b
Author: Ryan Lortie <desrt desrt ca>
Date:   Mon Jul 11 01:45:45 2011 +0200

    GMenuItem: cleanup action/target setters
    
    Drop excessively redundant functions and improve semantics of those that
    remain.

 gio/gmenu.c |   60 +++++++++++++++++++++++-----------------------------------
 gio/gmenu.h |    7 ------
 2 files changed, 24 insertions(+), 43 deletions(-)
---
diff --git a/gio/gmenu.c b/gio/gmenu.c
index 1e3e7f5..c5a8500 100644
--- a/gio/gmenu.c
+++ b/gio/gmenu.c
@@ -417,42 +417,24 @@ g_menu_item_set_section (GMenuItem  *menu_item,
 }
 
 void
-g_menu_item_set_action (GMenuItem   *menu_item,
-                        const gchar *action)
-{
-  g_menu_item_set_attribute (menu_item, G_MENU_ATTRIBUTE_ACTION, "s", action);
-  g_menu_item_set_attribute (menu_item, G_MENU_ATTRIBUTE_TARGET, NULL);
-}
-
-void
-g_menu_item_set_target_value (GMenuItem *menu_item,
-                              GVariant  *target)
-{
-  g_menu_item_set_attribute (menu_item, G_MENU_ATTRIBUTE_TARGET, "v", target);
-}
-
-void
-g_menu_item_set_target (GMenuItem   *menu_item,
-                        const gchar *format_string,
-                        ...)
-{
-  GVariant *value;
-  va_list ap;
-
-  va_start (ap, format_string);
-  value = g_variant_new_va (format_string, NULL, &ap);
-  va_end (ap);
-
-  g_menu_item_set_target_value (menu_item, value);
-}
-
-void
 g_menu_item_set_action_and_target_value (GMenuItem   *menu_item,
                                          const gchar *action,
                                          GVariant    *target_value)
 {
-  g_menu_item_set_action (menu_item, action);
-  g_menu_item_set_target_value (menu_item, target_value);
+  GVariant *action_value;
+
+  if (action != NULL)
+    {
+      action_value = g_variant_new_string (action);
+    }
+  else
+    {
+      action_value = NULL;
+      target_value = NULL;
+    }
+
+  g_menu_item_set_attribute_value (menu_item, G_MENU_ATTRIBUTE_ACTION, action_value);
+  g_menu_item_set_attribute_value (menu_item, G_MENU_ATTRIBUTE_TARGET, target_value);
 }
 
 void
@@ -462,11 +444,17 @@ g_menu_item_set_action_and_target (GMenuItem   *menu_item,
                                    ...)
 {
   GVariant *value;
-  va_list ap;
 
-  va_start (ap, format_string);
-  value = g_variant_new_va (format_string, NULL, &ap);
-  va_end (ap);
+  if (format_string != NULL)
+    {
+      va_list ap;
+
+      va_start (ap, format_string);
+      value = g_variant_new_va (format_string, NULL, &ap);
+      va_end (ap);
+    }
+  else
+    value = NULL;
 
   g_menu_item_set_action_and_target_value (menu_item, action, value);
 }
diff --git a/gio/gmenu.h b/gio/gmenu.h
index 59a48a5..286820c 100644
--- a/gio/gmenu.h
+++ b/gio/gmenu.h
@@ -128,13 +128,6 @@ void                    g_menu_item_set_submenu                         (GMenuIt
                                                                          GMenuModel         *submenu);
 void                    g_menu_item_set_section                         (GMenuItem          *menu_item,
                                                                          GMenuModel         *section);
-void                    g_menu_item_set_action                          (GMenuItem          *menu_item,
-                                                                         const gchar        *action);
-void                    g_menu_item_set_target_value                    (GMenuItem          *menu_item,
-                                                                         GVariant           *target);
-void                    g_menu_item_set_target                          (GMenuItem          *menu_item,
-                                                                         const gchar        *format_string,
-                                                                         ...);
 void                    g_menu_item_set_action_and_target_value         (GMenuItem          *menu_item,
                                                                          const gchar        *action,
                                                                          GVariant           *target_value);



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