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

noreply at xfce.org noreply at xfce.org
Sun Feb 26 16:34:15 CET 2017


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 60ebd2da6fee552708333785158bb2a7b00c5d9d
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 1e36b8c..4dfc1c3 100644
--- a/plugins/pager/pager.c
+++ b/plugins/pager/pager.c
@@ -97,6 +97,7 @@ struct _PagerPlugin
 
   /* settings */
   guint          scrolling : 1;
+  guint          wrap_workspaces : 1;
   guint          miniature_view : 1;
   gint           rows;
   gfloat         ratio;
@@ -106,6 +107,7 @@ enum
 {
   PROP_0,
   PROP_WORKSPACE_SCROLLING,
+  PROP_WRAP_WORKSPACES,
   PROP_MINIATURE_VIEW,
   PROP_ROWS
 };
@@ -151,6 +153,13 @@ pager_plugin_class_init (PagerPluginClass *klass)
                                                          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
   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,
@@ -172,6 +181,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;
@@ -194,6 +204,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);
 
@@ -226,6 +240,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;
@@ -279,12 +297,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)
@@ -372,6 +399,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