[Xfce4-commits] [xfce/xfce4-panel] 01/02: Set workspace wrapping behavior (bug 6401)

noreply at xfce.org noreply at xfce.org
Thu Feb 5 03:03:15 CET 2015


This is an automated email from the git hooks/post-receive script.

andrzejr pushed a commit to branch master
in repository xfce/xfce4-panel.

commit 440d8ea23babe6f6b81a4dceb268b72d8c8e35cf
Author: Andrzej <ndrwrdck at gmail.com>
Date:   Thu Feb 5 01:41:45 2015 +0000

    Set workspace wrapping behavior (bug 6401)
    
    Disabled workspace wrapping when scrolling over the pager plugin.
    Workspace wrapping can be enabled by setting a hidden boolean property:
    /plugins/plugin-#/wrap-workspaces            true
---
 plugins/pager/pager.c |   38 +++++++++++++++++++++++++++++++++-----
 1 file changed, 33 insertions(+), 5 deletions(-)

diff --git a/plugins/pager/pager.c b/plugins/pager/pager.c
index 3ff65a2..bea2fab 100644
--- a/plugins/pager/pager.c
+++ b/plugins/pager/pager.c
@@ -86,6 +86,7 @@ struct _PagerPlugin
 
   /* settings */
   guint          scrolling : 1;
+  guint          wrap_workspaces : 1;
   guint          miniature_view : 1;
   gint           rows;
   gfloat         ratio;
@@ -95,6 +96,7 @@ enum
 {
   PROP_0,
   PROP_WORKSPACE_SCROLLING,
+  PROP_WRAP_WORKSPACES,
   PROP_MINIATURE_VIEW,
   PROP_ROWS
 };
@@ -137,6 +139,13 @@ pager_plugin_class_init (PagerPluginClass *klass)
                                                          EXO_PARAM_READWRITE));
 
   g_object_class_install_property (gobject_class,
+                                   PROP_WRAP_WORKSPACES,
+                                   g_param_spec_boolean ("wrap-workspaces",
+                                                         NULL, NULL,
+                                                         FALSE,
+                                                         EXO_PARAM_READWRITE));
+
+  g_object_class_install_property (gobject_class,
                                    PROP_MINIATURE_VIEW,
                                    g_param_spec_boolean ("miniature-view",
                                                          NULL, NULL,
@@ -158,6 +167,7 @@ pager_plugin_init (PagerPlugin *plugin)
 {
   plugin->wnck_screen = NULL;
   plugin->scrolling = TRUE;
+  plugin->wrap_workspaces = FALSE;
   plugin->miniature_view = TRUE;
   plugin->rows = 1;
   plugin->ratio = 1.0;
@@ -180,6 +190,10 @@ pager_plugin_get_property (GObject    *object,
       g_value_set_boolean (value, plugin->scrolling);
       break;
 
+    case PROP_WRAP_WORKSPACES:
+      g_value_set_boolean (value, plugin->wrap_workspaces);
+      break;
+
     case PROP_MINIATURE_VIEW:
       g_value_set_boolean (value, plugin->miniature_view);
 
@@ -212,6 +226,10 @@ pager_plugin_set_property (GObject      *object,
       plugin->scrolling = g_value_get_boolean (value);
       break;
 
+    case PROP_WRAP_WORKSPACES:
+      plugin->wrap_workspaces = g_value_get_boolean (value);
+      break;
+
     case PROP_MINIATURE_VIEW:
       plugin->miniature_view = g_value_get_boolean (value);
       break;
@@ -265,12 +283,21 @@ pager_plugin_scroll_event (GtkWidget      *widget,
   else
     active_n++;
 
-  /* wrap around */
   n_workspaces = wnck_screen_get_workspace_count (plugin->wnck_screen) - 1;
-  if (active_n < 0)
-    active_n = n_workspaces;
-  else if (active_n > n_workspaces)
-    active_n = 0;
+
+  if (plugin->wrap_workspaces == TRUE)
+  {
+    /* wrap around */
+    if (active_n < 0)
+      active_n = n_workspaces;
+    else if (active_n > n_workspaces)
+      active_n = 0;
+  }
+  else if (active_n < 0 || active_n > n_workspaces )
+  {
+    /* we do not need to do anything */
+    return TRUE;
+  }
 
   new_ws = wnck_screen_get_workspace (plugin->wnck_screen, active_n);
   if (new_ws != NULL && active_ws != new_ws)
@@ -358,6 +385,7 @@ pager_plugin_construct (XfcePanelPlugin *panel_plugin)
   const PanelProperty  properties[] =
   {
     { "workspace-scrolling", G_TYPE_BOOLEAN },
+    { "wrap-workspaces", G_TYPE_BOOLEAN },
     { "miniature-view", G_TYPE_BOOLEAN },
     { "rows", G_TYPE_UINT },
     { NULL }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list