]> spindle.queued.net Git - midori/commitdiff
Add sokoke_gtk_action_count_modifiers helper function
authorAndré Stösel <Midori-Plugin@PyIT.de>
Fri, 18 Jun 2010 21:27:29 +0000 (23:27 +0200)
committerChristian Dywan <christian@twotoasts.de>
Fri, 18 Jun 2010 22:32:58 +0000 (00:32 +0200)
midori/midori.vapi
midori/sokoke.c
midori/sokoke.h

index eb0f1f297911ababc07dc5f6635fa7547fc2802e..8e04493a77f54c58386d4df431731e16a86b280c 100644 (file)
@@ -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);
+    }
 }
 
index e8ade3af89eb5c403e17f8891e3a23daba4a8a6c..c6e8614a6c8a0065b540e36b1fa0e64e3084c1f0 100644 (file)
@@ -1682,6 +1682,39 @@ sokoke_window_activate_key (GtkWindow*   window,
     return FALSE;
 }
 
+/**
+ * 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
index 46da82e821d5fe4c1bdacadafcce7264047d2c7d..187cea76c88b5ce4e1b47204d2359e93e47bc70c 100644 (file)
@@ -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,