Add sokoke_gtk_action_count_modifiers helper function

This commit is contained in:
André Stösel 2010-06-18 23:27:29 +02:00 committed by Christian Dywan
parent 89e72b73d3
commit 6556d71273
3 changed files with 40 additions and 0 deletions

View file

@ -149,5 +149,10 @@ namespace Midori {
public class WebSettings : WebKit.WebSettings { public class WebSettings : WebKit.WebSettings {
public 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);
}
} }

View file

@ -1682,6 +1682,39 @@ sokoke_window_activate_key (GtkWindow* window,
return FALSE; 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: * sokoke_file_chooser_dialog_new:
* @title: a window title, or %NULL * @title: a window title, or %NULL

View file

@ -227,6 +227,8 @@ sokoke_replace_variables (const gchar* template,
gboolean gboolean
sokoke_window_activate_key (GtkWindow* window, sokoke_window_activate_key (GtkWindow* window,
GdkEventKey* event); GdkEventKey* event);
guint
sokoke_gtk_action_count_modifiers (GtkAction* action);
GtkWidget* GtkWidget*
sokoke_file_chooser_dialog_new (const gchar* title, sokoke_file_chooser_dialog_new (const gchar* title,