[Xfce4-commits] <xfce4-screenshooter:master> Add a scroll feature for the panel plugin.

Jérôme Guelfucci jeromeg at xfce.org
Fri Aug 14 00:26:28 CEST 2009


Updating branch refs/heads/master
         to 9271cb32d3094754e82c2f39cfde5d0a4414e589 (commit)
       from 015b99d80d9f78fa1f21af707bc2bafdb02b7620 (commit)

commit 9271cb32d3094754e82c2f39cfde5d0a4414e589
Author: Jérôme Guelfucci <jeromeg at xfce.org>
Date:   Wed Aug 12 18:50:17 2009 +0200

    Add a scroll feature for the panel plugin.
    
    When scrolling the panel plugin button, the region to be
    screenshooted is changed. This is faster than opening the
    preferences dialog.

 ChangeLog                           |    8 ++++
 lib/screenshooter-global.h          |    4 +-
 panel-plugin/screenshooter-plugin.c |   70 ++++++++++++++++++++++++++---------
 3 files changed, 62 insertions(+), 20 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b1dd942..db867e0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2009-08-12 jeromeg
 
+Add a scroll feature for the panel plugin.
+
+When scrolling the panel plugin button, the region to be
+screenshooted is changed. This is faster than opening the
+preferences dialog.
+
+2009-08-12 jeromeg
+
 First implementation of a nice rubber banding.
 
 When the screen is composited, use a nicer area selection mecanism. Draw
diff --git a/lib/screenshooter-global.h b/lib/screenshooter-global.h
index 21bea82..8fb9996 100644
--- a/lib/screenshooter-global.h
+++ b/lib/screenshooter-global.h
@@ -58,9 +58,9 @@ ScreenshotData;
 
 
 
-/* Screenshot Modes */
+/* Screenshot regions */
 enum {
-  MODE_0,
+  REGION_0,
   FULLSCREEN,
   ACTIVE_WINDOW,
   SELECT,
diff --git a/panel-plugin/screenshooter-plugin.c b/panel-plugin/screenshooter-plugin.c
index b554906..076e16a 100644
--- a/panel-plugin/screenshooter-plugin.c
+++ b/panel-plugin/screenshooter-plugin.c
@@ -90,6 +90,11 @@ static void
 cb_button_clicked                    (GtkWidget            *button,
                                       PluginData           *pd);
 
+static gboolean
+cb_button_scrolled                   (GtkWidget            *widget,
+                                      GdkEventScroll       *event,
+                                      PluginData *pd);
+
 static void
 cb_style_set                         (XfcePanelPlugin      *plugin,
                                       gpointer              ignored,
@@ -171,6 +176,37 @@ cb_button_clicked (GtkWidget *button, PluginData *pd)
 
 
 
+static gboolean cb_button_scrolled (GtkWidget *widget,
+                                    GdkEventScroll *event,
+                                    PluginData *pd)
+{
+  switch (event->direction)
+    {
+      case GDK_SCROLL_UP:
+      case GDK_SCROLL_RIGHT:
+        pd->sd->region += 1;
+        if (pd->sd->region > SELECT)
+          pd->sd->region = FULLSCREEN;
+        set_panel_button_tooltip (pd);
+        gtk_widget_trigger_tooltip_query (pd->button);
+        return TRUE;
+      case GDK_SCROLL_DOWN:
+      case GDK_SCROLL_LEFT:
+        pd->sd->region -= 1;
+        if (pd->sd->region == REGION_0)
+          pd->sd->region = SELECT;
+        set_panel_button_tooltip (pd);
+        gtk_widget_trigger_tooltip_query (pd->button);
+        return TRUE;
+      default:
+        return FALSE;
+    }
+
+  return FALSE;
+}
+
+
+
 /* Set the style of the panel plugin.
 plugin: a XfcePanelPlugin (a screenshooter one).
 pd: the associated PluginData.
@@ -325,28 +361,26 @@ screenshooter_plugin_construct (XfcePanelPlugin *plugin)
   set_panel_button_tooltip (pd);
 
   TRACE ("Add the button to the panel");
-  gtk_widget_show_all (pd->button);
-
   gtk_container_add (GTK_CONTAINER (plugin), pd->button);
-
   xfce_panel_plugin_add_action_widget (plugin, pd->button);
+  gtk_widget_show_all (pd->button);
 
   /* Set the callbacks */
-  TRACE ("Set the clicked callback");
-  g_signal_connect (pd->button, "clicked", G_CALLBACK (cb_button_clicked), pd);
-
-  TRACE ("Set the free data callback");
-  g_signal_connect (plugin, "free-data", G_CALLBACK (cb_free_data), pd);
-
-  TRACE ("Set the size changed callback");
-  g_signal_connect (plugin, "size-changed", G_CALLBACK (cb_set_size), pd);
-
-  TRACE ("Set the style set callback");
-  pd->style_id = g_signal_connect (plugin, "style-set", G_CALLBACK (cb_style_set), pd);
-
-  TRACE ("Set the configuration menu");
+  g_signal_connect (pd->button, "clicked",
+                    (GCallback) cb_button_clicked, pd);
+  g_signal_connect (pd->button, "scroll-event",
+                    (GCallback) cb_button_scrolled, pd);
+  g_signal_connect (plugin, "free-data",
+                    (GCallback) cb_free_data, pd);
+  g_signal_connect (plugin, "size-changed",
+                    (GCallback) cb_set_size, pd);
+
+  pd->style_id = g_signal_connect (plugin, "style-set",
+                                   (GCallback) cb_style_set, pd);
+
+  /* Set the configuration menu */
   xfce_panel_plugin_menu_show_configure (plugin);
-
-  g_signal_connect (plugin, "configure-plugin", G_CALLBACK (cb_properties_dialog), pd);
+  g_signal_connect (plugin, "configure-plugin",
+                    (GCallback) cb_properties_dialog, pd);
 }
 XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL (screenshooter_plugin_construct);



More information about the Xfce4-commits mailing list