[Xfce4-commits] <midori:master> Add sokoke_gtk_action_count_modifiers helper function

Christian Dywan noreply at xfce.org
Sat Jun 19 00:38:03 CEST 2010


Updating branch refs/heads/master
         to 6556d71273cf8a5dc179fda80985b5ed3a2c5fa9 (commit)
       from 89e72b73d34f176c3002e79f52219a9647593d3b (commit)

commit 6556d71273cf8a5dc179fda80985b5ed3a2c5fa9
Author: André Stösel <Midori-Plugin at PyIT.de>
Date:   Fri Jun 18 23:27:29 2010 +0200

    Add sokoke_gtk_action_count_modifiers helper function

 midori/midori.vapi |    5 +++++
 midori/sokoke.c    |   33 +++++++++++++++++++++++++++++++++
 midori/sokoke.h    |    2 ++
 3 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/midori/midori.vapi b/midori/midori.vapi
index eb0f1f2..8e04493 100644
--- a/midori/midori.vapi
+++ b/midori/midori.vapi
@@ -149,5 +149,10 @@ namespace Midori {
     public class WebSettings : WebKit.WebSettings {
         public WebSettings ();
     }
+
+    [CCode (cheader_filename = "midori/sokoke.h", lower_case_cprefix = "sokoke_")]
+    namespace Sokoke {
+        public static uint gtk_action_count_modifiers (Gtk.Action action);
+    }
 }
 
diff --git a/midori/sokoke.c b/midori/sokoke.c
index e8ade3a..c6e8614 100644
--- a/midori/sokoke.c
+++ b/midori/sokoke.c
@@ -1683,6 +1683,39 @@ sokoke_window_activate_key (GtkWindow*   window,
 }
 
 /**
+ * sokoke_gtk_action_count_modifiers:
+ * @action: a #GtkAction
+ *
+ * Counts the number of modifiers in the accelerator
+ * belonging to the action.
+ *
+ * Return value: the number of modifiers
+ **/
+guint
+sokoke_gtk_action_count_modifier (GtkAction* action)
+{
+    GtkAccelKey key;
+    gint mods, cmods = 0;
+    const gchar* accel_path;
+
+    g_return_val_if_fail (GTK_IS_ACTION (action), 0);
+
+    accel_path = gtk_action_get_accel_path (action);
+    if (accel_path)
+        if (gtk_accel_map_lookup_entry (accel_path, &key))
+        {
+            mods = key.accel_mods;
+            while (mods)
+            {
+                if (1 & mods >> 0)
+                    cmods++;
+                mods = mods >> 1;
+            }
+        }
+    return cmods;
+}
+
+/**
  * sokoke_file_chooser_dialog_new:
  * @title: a window title, or %NULL
  * @window: a parent #GtkWindow, or %NULL
diff --git a/midori/sokoke.h b/midori/sokoke.h
index 46da82e..187cea7 100644
--- a/midori/sokoke.h
+++ b/midori/sokoke.h
@@ -227,6 +227,8 @@ sokoke_replace_variables                (const gchar* template,
 gboolean
 sokoke_window_activate_key              (GtkWindow*      window,
                                          GdkEventKey*    event);
+guint
+sokoke_gtk_action_count_modifiers       (GtkAction* action);
 
 GtkWidget*
 sokoke_file_chooser_dialog_new          (const gchar*         title,



More information about the Xfce4-commits mailing list