[gtkmm] Application: Add set_accels_for_action(), deprecating add_accelerator().



commit bfd407a27d04aefbe1bca6272d9c8d08ebac45fb
Author: Murray Cumming <murrayc murrayc com>
Date:   Tue Apr 8 09:51:48 2014 +0200

    Application: Add set_accels_for_action(), deprecating add_accelerator().
    
    * gtk/src/application.[hg|ccg]: Deprecate add_accelerator() and
      remove_accelerator() because they have been deprecated in the
      latest unstable GTK+ code:
      See https://bugzilla.gnome.org/show_bug.cgi?id=708905#c8
      Add set_accels_for_action(), set_accel_for_action() and
      unset_accels_for_action() to replace them, using the new
      gtk_application_set_accels_for_action() function.

 gtk/src/application.ccg |    8 ++++++++
 gtk/src/application.hg  |   23 ++++++++++++++---------
 2 files changed, 22 insertions(+), 9 deletions(-)
---
diff --git a/gtk/src/application.ccg b/gtk/src/application.ccg
index 62707ea..50d2d8c 100644
--- a/gtk/src/application.ccg
+++ b/gtk/src/application.ccg
@@ -182,4 +182,12 @@ void Application::set_accel_for_action(const Glib::ustring& detailed_action_name
   set_accels_for_action(detailed_action_name, vec);
 }
 
+void Application::unset_accels_for_action(const Glib::ustring& detailed_action_name)
+{
+  //gtk_application_set_accels_for_action() can take an empty array, but not NULL.
+  //See https://bugzilla.gnome.org/show_bug.cgi?id=708905#c10
+  std::vector<Glib::ustring> vec;
+  set_accels_for_action(detailed_action_name, vec);
+}
+
 } // namespace Gtk
diff --git a/gtk/src/application.hg b/gtk/src/application.hg
index 25f7f38..376bc6b 100644
--- a/gtk/src/application.hg
+++ b/gtk/src/application.hg
@@ -301,11 +301,9 @@ public:
 
   _WRAP_METHOD(void set_menubar(const Glib::RefPtr<Gio::MenuModel>& menubar), gtk_application_set_menubar)
 
-  //TODO: Add a *_variant() version that takes a VariantBase, add a templated method, and remove this method 
when we can break ABI:
-  _WRAP_METHOD(void add_accelerator(const Glib::ustring& accelerator, const Glib::ustring& action_name, 
GVariant* parameter{?}), gtk_application_add_accelerator)
+  _WRAP_METHOD(void add_accelerator(const Glib::ustring& accelerator, const Glib::ustring& action_name, 
GVariant* parameter{?}), gtk_application_add_accelerator, deprecated "Use set_accels_for_action() instead.")
 
-  //TODO: Add a *_variant() version that takes a VariantBase, add a templated method, and remove this method 
when we can break ABI:
-  _WRAP_METHOD(void remove_accelerator(const Glib::ustring& action_name, GVariant* parameter{?}), 
gtk_application_remove_accelerator)
+  _WRAP_METHOD(void remove_accelerator(const Glib::ustring& action_name, GVariant* parameter{?}), 
gtk_application_remove_accelerator, deprecated "Use set_accels_for_action() or unset_accels_for_action() 
instead.")
 
   _WRAP_METHOD(guint inhibit(Window& window, ApplicationInhibitFlags flags, const Glib::ustring& reason), 
gtk_application_inhibit)
   _WRAP_METHOD(void uninhibit(guint cookie), gtk_application_uninhibit)
@@ -326,14 +324,11 @@ public:
 #m4 _CONVERSION(`const std::vector<Glib::ustring>&',`const 
gchar*-const*',`Glib::ArrayHandler<Glib::ustring>::vector_to_array($3).data ()')
   _WRAP_METHOD(void set_accels_for_action(const Glib::ustring& detailed_action_name, const 
std::vector<Glib::ustring>& accels), gtk_application_set_accels_for_action)
 
-  //TODO: Add unset_accels_for_action().
-  //See https://bugzilla.gnome.org/show_bug.cgi?id=726623
-
-  //Note: add_accelerator() is very similar to this, though it doesn't take the detailed action name.
-  //Hopefully it will be deprecated: https://bugzilla.gnome.org/show_bug.cgi?id=708905#c5
   /** Sets a keyboard accelerator that will trigger the
    * given action. It will be the primary 
    * accelerator, which may be displayed in the UI.
+   *
+   * See unset_accels_for_action().
    * 
    * @param detailed_action_name A detailed action name, specifying an action
    * and target to associate accelerators with.
@@ -343,6 +338,16 @@ public:
    */
   void set_accel_for_action(const Glib::ustring& detailed_action_name, const Glib::ustring& accel);
 
+  /** Unsets a keyboard accelerator that will trigger the
+   * given action. See set_accels_for_action() and set_accel_for_action().
+   * 
+   * @param detailed_action_name A detailed action name, specifying an action
+   * and target to associate accelerators with.
+   *
+   * @newin{3,12}
+   */
+  void unset_accels_for_action(const Glib::ustring& detailed_action_name);
+
   _WRAP_PROPERTY("app-menu", Glib::RefPtr<Gio::MenuModel>)
   _WRAP_PROPERTY("menubar", Glib::RefPtr<Gio::MenuModel>)
   _WRAP_PROPERTY("register-session", bool)


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