From 72f6a5c8a2329ba0c1cd30b1686f4e25203c03b5 Mon Sep 17 00:00:00 2001 From: Victor , Steve Dodier-Lazaro Date: Wed, 4 Feb 2015 19:11:44 +0000 Subject: [PATCH] Updating the wrap-workspaces patch of bug 6401: Add an option to disable workspace wrapping in the pager panel plugin --- plugins/pager/pager-dialog.glade | 37 +++++++++++++++++++++++++++------- plugins/pager/pager.c | 43 +++++++++++++++++++++++++++++++++++----- 2 files changed, 68 insertions(+), 12 deletions(-) diff --git a/plugins/pager/pager-dialog.glade b/plugins/pager/pager-dialog.glade index 02fbcde..34e9ea4 100644 --- a/plugins/pager/pager-dialog.glade +++ b/plugins/pager/pager-dialog.glade @@ -135,14 +135,37 @@ 18 6 - - Switch workspaces using the mouse _wheel + True - True - False - True - True - + vertical + + + Switch workspaces using the mouse _wheel + True + True + False + True + True + + + 0 + + + + + Wrap workspaces when the _first or the last workspaces is reached + True + True + False + True + True + True + + + 1 + + + diff --git a/plugins/pager/pager.c b/plugins/pager/pager.c index 3ff65a2..8eef166 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, + TRUE, + 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 = TRUE; 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 } @@ -535,6 +563,11 @@ pager_plugin_configure_plugin (XfcePanelPlugin *panel_plugin) exo_mutual_binding_new (G_OBJECT (plugin), "workspace-scrolling", G_OBJECT (object), "active"); + object = gtk_builder_get_object (builder, "wrap-workspaces"); + panel_return_if_fail (GTK_IS_TOGGLE_BUTTON (object)); + exo_mutual_binding_new (G_OBJECT (plugin), "wrap-workspaces", + G_OBJECT (object), "active"); + object = gtk_builder_get_object (builder, "miniature-view"); panel_return_if_fail (GTK_IS_TOGGLE_BUTTON (object)); exo_mutual_binding_new (G_OBJECT (plugin), "miniature-view", -- 2.2.2