[glibmm] Gio::MenuItem: Add set_action(), unset_target() and unset_action_and_target().



commit f6849fb3462456a9890c65de8a97a60b08cc49d5
Author: Murray Cumming <murrayc murrayc com>
Date:   Tue Oct 8 10:14:56 2013 +0200

    Gio::MenuItem: Add set_action(), unset_target() and unset_action_and_target().
    
    * gio/src/menuitem.[hg|ccg]: set_action() and unset_target()
      replace set_action_and_target(action), which is now deprecated.

 gio/src/menuitem.ccg |   18 ++++++++++++++++++
 gio/src/menuitem.hg  |   25 +++++++++++++++++++++++--
 2 files changed, 41 insertions(+), 2 deletions(-)
---
diff --git a/gio/src/menuitem.ccg b/gio/src/menuitem.ccg
index ed4c6e3..de96ad3 100644
--- a/gio/src/menuitem.ccg
+++ b/gio/src/menuitem.ccg
@@ -50,6 +50,24 @@ void MenuItem::set_action_and_target(const Glib::ustring& action)
   g_menu_item_set_action_and_target_value(gobj(), action.c_str(), 0);
 }
 
+void MenuItem::set_action(const Glib::ustring& action)
+{
+  g_menu_item_set_action_and_target_value(gobj(), action.c_str(), 0);
+}
+
+void MenuItem::unset_target()
+{
+  const gchar *action_name = 0;
+  g_menu_item_get_attribute (gobj(), G_MENU_ATTRIBUTE_ACTION, "&s", &action_name);
+ 
+  g_menu_item_set_action_and_target_value(gobj(), action_name, 0);
+}
+
+void MenuItem::unset_action_and_target()
+{
+  g_menu_item_set_action_and_target_value(gobj(), 0, 0);
+}
+
 void MenuItem::unset_icon()
 {
   g_menu_item_set_icon(gobj(), 0);
diff --git a/gio/src/menuitem.hg b/gio/src/menuitem.hg
index e7eb6c3..31eeae0 100644
--- a/gio/src/menuitem.hg
+++ b/gio/src/menuitem.hg
@@ -124,12 +124,33 @@ GMenuItem * g_menu_item_new_section                 (const Glib::ustring& label,
   // Ignore varargs function.
   _IGNORE(g_menu_item_get_attribute)
 
-  //TODO: Rename this to unset_action_target() and deprecate this one.
+_DEPRECATE_IFDEF_START
   /** Unsets the target for the specified @a action.
+   * @deprecate Use set_action() or unset_target() instead.
    */
   void set_action_and_target(const Glib::ustring& action);
+_DEPRECATE_IFDEF_END
 
-  //TODO: Add unset_action_and_target().
+  /** Sets the action for the menu item.
+   * See set_action_and_target().
+   *
+   * @newin{2,38}
+   */
+  void set_action(const Glib::ustring& action);
+
+  /** Unsets the target for the menu item.
+   * See set_action_and_target().
+   *
+   * @newin{2,38}
+   */
+  void unset_target();
+
+  /** Unsets the action and target for the menu item.
+   * See set_action_and_target().
+   *
+   * @newin{2,38}.
+   */
+  void unset_action_and_target();
 
   _WRAP_METHOD(void set_action_and_target(const Glib::ustring& action, const Glib::VariantBase& 
target_value), g_menu_item_set_action_and_target_value)
   _IGNORE(g_menu_item_set_action_and_target)


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