[Xfce4-commits] <xfce4-clipman-plugin:master> actions: Add "skip-action-on-key-down" option

Mike Massonnet noreply at xfce.org
Mon Oct 24 23:40:01 CEST 2011


Updating branch refs/heads/master
         to 1f1aa61509b6c57b119ae0baf16e1bf50b7056e9 (commit)
       from 22e591e64c145ee775769c9bb048093235b7417f (commit)

commit 1f1aa61509b6c57b119ae0baf16e1bf50b7056e9
Author: Mike Massonnet <mmassonnet at xfce.org>
Date:   Mon Oct 24 23:35:32 2011 +0200

    actions: Add "skip-action-on-key-down" option
    
    This option lets the user skip the actions popup menu by holding
    the Control key down when the selection is done, by default it's
    set to false.
    
    The Xfconf property /tweaks/skip-action-key-down is binded to it.

 panel-plugin/actions.c |   71 ++++++++++++++++++++++++++++++++++++++++++++++++
 panel-plugin/common.h  |    1 +
 panel-plugin/plugin.c  |    2 +
 3 files changed, 74 insertions(+), 0 deletions(-)

diff --git a/panel-plugin/actions.c b/panel-plugin/actions.c
index a01fb35..ad2ae74 100644
--- a/panel-plugin/actions.c
+++ b/panel-plugin/actions.c
@@ -57,9 +57,23 @@ struct _ClipmanActionsPrivate
   GFileMonitor         *file_monitor;
   GSList               *entries;
   GtkWidget            *menu;
+  gboolean              skip_action_on_key_down;
+};
+
+enum
+{
+  SKIP_ACTION_ON_KEY_DOWN = 1,
 };
 
 static void             clipman_actions_finalize            (GObject *object);
+static void             clipman_actions_set_property        (GObject *object,
+                                                             guint property_id,
+                                                             const GValue *value,
+                                                             GParamSpec *pspec);
+static void             clipman_actions_get_property        (GObject *object,
+                                                             guint property_id,
+                                                             GValue *value,
+                                                             GParamSpec *pspec);
 
 /*
  * Misc functions declarations
@@ -672,6 +686,16 @@ clipman_actions_match_with_menu (ClipmanActions *actions,
   ClipmanActionsEntry *entry;
   GtkWidget *mi;
   GSList *l, *entries;
+  GdkModifierType state;
+
+  if (actions->priv->skip_action_on_key_down)
+    {
+      gdk_window_get_pointer (NULL, NULL, NULL, &state);
+      if (state & GDK_CONTROL_MASK)
+        {
+          return;
+        }
+    }
 
   entries = clipman_actions_match (actions, group, text);
 
@@ -881,6 +905,15 @@ clipman_actions_class_init (ClipmanActionsClass *klass)
 
   object_class = G_OBJECT_CLASS (klass);
   object_class->finalize = clipman_actions_finalize;
+  object_class->set_property = clipman_actions_set_property;
+  object_class->get_property = clipman_actions_get_property;
+
+  g_object_class_install_property (object_class, SKIP_ACTION_ON_KEY_DOWN,
+                                   g_param_spec_boolean ("skip-action-on-key-down",
+                                                         "SkipActionOnKeyDown",
+                                                         "Skip the action if the Control key is pressed down",
+                                                         DEFAULT_SKIP_ACTION_ON_KEY_DOWN,
+                                                         G_PARAM_CONSTRUCT|G_PARAM_READWRITE));
 }
 
 static void
@@ -912,3 +945,41 @@ clipman_actions_finalize (GObject *object)
   g_object_unref (actions->priv->file);
 }
 
+static void
+clipman_actions_set_property (GObject *object,
+                              guint property_id,
+                              const GValue *value,
+                              GParamSpec *pspec)
+{
+  ClipmanActionsPrivate *priv = CLIPMAN_ACTIONS (object)->priv;
+
+  switch (property_id)
+    {
+    case SKIP_ACTION_ON_KEY_DOWN:
+      priv->skip_action_on_key_down = g_value_get_boolean (value);
+      break;
+
+    default:
+      break;
+    }
+}
+
+static void
+clipman_actions_get_property (GObject *object,
+                              guint property_id,
+                              GValue *value,
+                              GParamSpec *pspec)
+{
+  ClipmanActionsPrivate *priv = CLIPMAN_ACTIONS (object)->priv;
+
+  switch (property_id)
+    {
+    case SKIP_ACTION_ON_KEY_DOWN:
+      g_value_set_boolean (value, priv->skip_action_on_key_down);
+      break;
+
+    default:
+      break;
+    }
+}
+
diff --git a/panel-plugin/common.h b/panel-plugin/common.h
index 9542979..bab4795 100644
--- a/panel-plugin/common.h
+++ b/panel-plugin/common.h
@@ -28,6 +28,7 @@
 #define DEFAULT_SAVE_ON_QUIT                            TRUE
 #define DEFAULT_REVERSE_ORDER                           FALSE
 #define DEFAULT_REORDER_ITEMS                           TRUE
+#define DEFAULT_SKIP_ACTION_ON_KEY_DOWN                 FALSE
 
 /* Collector */
 #define DEFAULT_ADD_PRIMARY_CLIPBOARD                   FALSE
diff --git a/panel-plugin/plugin.c b/panel-plugin/plugin.c
index 3582035..7a3d3ae 100644
--- a/panel-plugin/plugin.c
+++ b/panel-plugin/plugin.c
@@ -86,6 +86,8 @@ plugin_register (void)
 
   /* ClipmanActions */
   plugin->actions = clipman_actions_get ();
+  xfconf_g_property_bind  (plugin->channel, "/tweaks/skip-action-on-key-down",
+                           G_TYPE_BOOLEAN, plugin->actions, "skip-action-on-key-down");
 
   /* ClipmanHistory */
   plugin->history = clipman_history_get ();


More information about the Xfce4-commits mailing list