[Xfce4-commits] <xfce4-xkb-plugin:master> Make scrolling the plugin button cycle through layouts (bug #6533).

Jérôme Guelfucci noreply at xfce.org
Fri Apr 29 20:08:01 CEST 2011


Updating branch refs/heads/master
         to d1586e84d41ea4ef2469f9604d7e6854aa0bcbad (commit)
       from bdcdddb5ae6a2fda9bfd2a5fd39d8ac29ea613fb (commit)

commit d1586e84d41ea4ef2469f9604d7e6854aa0bcbad
Author: Jérôme Guelfucci <jeromeg at xfce.org>
Date:   Fri Apr 29 19:08:12 2011 +0200

    Make scrolling the plugin button cycle through layouts (bug #6533).
    
    Add a function to cycle in reverse order for the other scroll direction.

 panel-plugin/xfce4-xkb-plugin.c |    3 +++
 panel-plugin/xkb-callbacks.c    |   22 ++++++++++++++++++++++
 panel-plugin/xkb-callbacks.h    |    6 +++++-
 panel-plugin/xkb-config.c       |    9 +++++++++
 panel-plugin/xkb-config.h       |    1 +
 5 files changed, 40 insertions(+), 1 deletions(-)

diff --git a/panel-plugin/xfce4-xkb-plugin.c b/panel-plugin/xfce4-xkb-plugin.c
index 6ccc6d9..74741cd 100644
--- a/panel-plugin/xfce4-xkb-plugin.c
+++ b/panel-plugin/xfce4-xkb-plugin.c
@@ -182,6 +182,9 @@ xkb_new (XfcePanelPlugin *plugin)
 
     gtk_widget_show (xkb->btn);
     g_signal_connect (xkb->btn, "clicked", G_CALLBACK (xkb_plugin_button_clicked), xkb);
+    g_signal_connect (xkb->btn, "scroll-event",
+                      G_CALLBACK (xkb_plugin_button_scrolled), NULL);
+
     g_object_set (G_OBJECT (xkb->btn), "has-tooltip", TRUE, NULL);
     g_signal_connect (xkb->btn, "query-tooltip",
             G_CALLBACK (xkb_plugin_set_tooltip), xkb);
diff --git a/panel-plugin/xkb-callbacks.c b/panel-plugin/xkb-callbacks.c
index e7eaeac..c2ae9d6 100644
--- a/panel-plugin/xkb-callbacks.c
+++ b/panel-plugin/xkb-callbacks.c
@@ -154,6 +154,28 @@ xkb_plugin_button_clicked (GtkButton *btn,
     }
 }
 
+gboolean
+xkb_plugin_button_scrolled (GtkWidget *btn,
+                            GdkEventScroll *event,
+                            gpointer data)
+{
+    switch (event->direction)
+    {
+      case GDK_SCROLL_UP:
+      case GDK_SCROLL_RIGHT:
+          xkb_config_next_group ();
+          return TRUE;
+      case GDK_SCROLL_DOWN:
+      case GDK_SCROLL_LEFT:
+          xkb_config_prev_group ();
+          return TRUE;
+      default:
+        return FALSE;
+    }
+
+    return FALSE;
+}
+
 void
 xkb_plugin_popup_menu (GtkButton *btn,
                        gpointer data)
diff --git a/panel-plugin/xkb-callbacks.h b/panel-plugin/xkb-callbacks.h
index e00b436..3cb5edf 100644
--- a/panel-plugin/xkb-callbacks.h
+++ b/panel-plugin/xkb-callbacks.h
@@ -4,7 +4,7 @@
  *
  * Parts of this program comes from the XfKC tool:
  * Copyright (C) 2006 Gauvain Pocentek <gauvainpocentek at gmail.com>
- * 
+ *
  * A part of this file comes from the gnome keyboard capplet (control-center):
  * Copyright (C) 2003 Sergey V. Oudaltsov <svu at users.sourceforge.net>
  *
@@ -66,6 +66,10 @@ void            xkb_plugin_popup_menu           (GtkButton *btn,
 void            xkb_plugin_button_clicked       (GtkButton *btn,
                                  gpointer data);
 
+gboolean        xkb_plugin_button_scrolled      (GtkWidget *btn,
+                                 GdkEventScroll *event,
+                                 gpointer data);
+
 gboolean        xkb_plugin_set_tooltip          (GtkWidget *widget,
                                  gint x,
                                  gint y,
diff --git a/panel-plugin/xkb-config.c b/panel-plugin/xkb-config.c
index d952a3c..6c751f3 100644
--- a/panel-plugin/xkb-config.c
+++ b/panel-plugin/xkb-config.c
@@ -278,6 +278,15 @@ xkb_config_next_group (void)
 }
 
 gboolean
+xkb_config_prev_group (void)
+{
+    xkl_engine_lock_group (config->engine,
+            xkl_engine_get_prev_group (config->engine));
+
+    return TRUE;
+}
+
+gboolean
 xkb_config_update_settings (t_xkb_settings *settings)
 {
     gboolean activate_settings = FALSE;
diff --git a/panel-plugin/xkb-config.h b/panel-plugin/xkb-config.h
index 3281471..c251e53 100644
--- a/panel-plugin/xkb-config.h
+++ b/panel-plugin/xkb-config.h
@@ -73,6 +73,7 @@ const gchar*      xkb_config_get_group_name               (gint group);
 const gchar*      xkb_config_get_variant                  (gint group);
 gboolean          xkb_config_set_group                    (gint group);
 gboolean          xkb_config_next_group                   (void);
+gboolean          xkb_config_prev_group                   (void);
 gint              xkb_config_variant_index_for_group      (gint group);
 
 void              xkb_config_window_changed               (guint new_window_id,



More information about the Xfce4-commits mailing list