diff --git a/plugins/tasklist/tasklist-widget.c b/plugins/tasklist/tasklist-widget.c index 53174a99..27a9e3c7 100644 --- a/plugins/tasklist/tasklist-widget.c +++ b/plugins/tasklist/tasklist-widget.c @@ -81,6 +81,7 @@ enum PROP_0, PROP_GROUPING, PROP_INCLUDE_ALL_WORKSPACES, + PROP_USE_WORKSPACE, PROP_INCLUDE_ALL_MONITORS, PROP_FLAT_BUTTONS, PROP_SWITCH_WORKSPACE_ON_UNMINIMIZE, @@ -138,6 +139,10 @@ struct _XfceTasklist /* whether we show windows from all workspaces or * only the active workspace */ guint all_workspaces : 1; + + /* specify a workspace whose windows will be + * displayed regardless of actual workspace */ + gint use_workspace; /* whether we switch to another workspace when we try to * unminimize a window on another workspace */ @@ -339,6 +344,8 @@ static XfceTasklistChild *xfce_tasklist_group_button_new (WnckCl /* potential public functions */ static void xfce_tasklist_set_include_all_workspaces (XfceTasklist *tasklist, gboolean all_workspaces); +static void xfce_tasklist_set_use_workspace (XfceTasklist *tasklist, + gint use_workspace); static void xfce_tasklist_set_include_all_monitors (XfceTasklist *tasklist, gboolean all_monitors); static void xfce_tasklist_set_button_relief (XfceTasklist *tasklist, @@ -402,6 +409,13 @@ xfce_tasklist_class_init (XfceTasklistClass *klass) NULL, NULL, FALSE, EXO_PARAM_READWRITE)); + + g_object_class_install_property (gobject_class, + PROP_USE_WORKSPACE, + g_param_spec_int ("use-workspace", + NULL, NULL, + -1, 12, -1, + EXO_PARAM_READWRITE)); g_object_class_install_property (gobject_class, PROP_INCLUDE_ALL_MONITORS, @@ -559,6 +573,7 @@ xfce_tasklist_init (XfceTasklist *tasklist) tasklist->mode = XFCE_PANEL_PLUGIN_MODE_HORIZONTAL; tasklist->nrows = 1; tasklist->all_workspaces = FALSE; + tasklist->use_workspace = -1; tasklist->button_relief = GTK_RELIEF_NORMAL; tasklist->switch_workspace = TRUE; tasklist->only_minimized = FALSE; @@ -621,6 +636,10 @@ xfce_tasklist_get_property (GObject *object, case PROP_INCLUDE_ALL_WORKSPACES: g_value_set_boolean (value, tasklist->all_workspaces); break; + + case PROP_USE_WORKSPACE: + g_value_set_int (value, tasklist->use_workspace); + break; case PROP_INCLUDE_ALL_MONITORS: g_value_set_boolean (value, tasklist->all_monitors); @@ -696,6 +715,10 @@ xfce_tasklist_set_property (GObject *object, case PROP_INCLUDE_ALL_WORKSPACES: xfce_tasklist_set_include_all_workspaces (tasklist, g_value_get_boolean (value)); break; + + case PROP_USE_WORKSPACE: + xfce_tasklist_set_use_workspace (tasklist, g_value_get_int (value)); + break; case PROP_INCLUDE_ALL_MONITORS: xfce_tasklist_set_include_all_monitors (tasklist, g_value_get_boolean (value)); @@ -1617,7 +1640,11 @@ xfce_tasklist_active_workspace_changed (WnckScreen *screen, return; /* walk all the children and update their visibility */ - active_ws = wnck_screen_get_active_workspace (screen); + if (tasklist->use_workspace > -1) + active_ws = wnck_screen_get_workspace (screen, tasklist->use_workspace); + else + active_ws = wnck_screen_get_active_workspace (screen); + for (li = tasklist->windows; li != NULL; li = li->next) { child = li->data; @@ -1662,9 +1689,16 @@ xfce_tasklist_window_added (WnckScreen *screen, /* create new window button */ child = xfce_tasklist_button_new (window, tasklist); - /* initial visibility of the function */ - if (xfce_tasklist_button_visible (child, wnck_screen_get_active_workspace (screen))) - gtk_widget_show (child->button); + /* initial visibility of the function - dependent on use_workspace if used*/ + if (xfce_tasklist_button_visible (child, wnck_screen_get_active_workspace (screen))) { + if (tasklist->use_workspace > -1) { + if (wnck_screen_get_active_workspace (screen) == wnck_screen_get_workspace (screen, tasklist->use_workspace)) + gtk_widget_show (child->button); + } + else + gtk_widget_show (child->button); + } + if (G_LIKELY (child->class_group != NULL)) { @@ -1799,7 +1833,11 @@ xfce_tasklist_viewports_changed (WnckScreen *screen, /* pretend we changed workspace, this will update the * visibility of all the buttons */ - active_ws = wnck_screen_get_active_workspace (screen); + if (tasklist->use_workspace > -1) + active_ws = wnck_screen_get_workspace (screen, tasklist->use_workspace); + else + active_ws = wnck_screen_get_active_workspace (screen); + xfce_tasklist_active_workspace_changed (screen, active_ws, tasklist); } @@ -2575,7 +2613,11 @@ xfce_tasklist_button_state_changed (WnckWindow *window, { /* if we have all_blinking set make sure we toggle visibility of the button * in case the window is not in the current workspace */ - active_ws = wnck_screen_get_active_workspace (child->tasklist->screen); + if (tasklist->use_workspace > -1) + active_ws = wnck_screen_get_workspace (screen, tasklist->use_workspace); + else + active_ws = wnck_screen_get_active_workspace (child->tasklist->screen); + if (child->tasklist->all_blinking && blink && !xfce_tasklist_button_visible (child, active_ws)) { @@ -2628,6 +2670,7 @@ xfce_tasklist_button_geometry_changed2 (WnckWindow *window, { /* check if we need to change the visibility of the button */ active_ws = wnck_screen_get_active_workspace (child->tasklist->screen); + if (xfce_tasklist_button_visible (child, active_ws)) gtk_widget_show (child->button); else @@ -3159,6 +3202,7 @@ xfce_tasklist_button_new (WnckWindow *window, xfce_tasklist_button_icon_changed (window, child); xfce_tasklist_button_name_changed (NULL, child); + /* insert */ tasklist->windows = g_list_insert_sorted_with_data (tasklist->windows, child, xfce_tasklist_button_compare, @@ -3735,6 +3779,28 @@ xfce_tasklist_set_include_all_workspaces (XfceTasklist *tasklist, } } +static void +xfce_tasklist_set_use_workspace (XfceTasklist *tasklist, + gint use_workspace) +{ + panel_return_if_fail (XFCE_IS_TASKLIST (tasklist)); + + if (tasklist->use_workspace != use_workspace) + { + tasklist->use_workspace = use_workspace; + + if (tasklist->screen != NULL) + { + /* update visibility of buttons */ + xfce_tasklist_active_workspace_changed (tasklist->screen, + NULL, tasklist); + + /* make sure sorting is ok */ + xfce_tasklist_sort (tasklist); + } + } +} + static void diff --git a/plugins/tasklist/tasklist.c b/plugins/tasklist/tasklist.c index fdea3044..06007da8 100644 --- a/plugins/tasklist/tasklist.c +++ b/plugins/tasklist/tasklist.c @@ -132,6 +132,7 @@ tasklist_plugin_construct (XfcePanelPlugin *panel_plugin) { "show-labels", G_TYPE_BOOLEAN }, { "grouping", G_TYPE_UINT }, { "include-all-workspaces", G_TYPE_BOOLEAN }, + { "use-workspace", G_TYPE_INT }, { "include-all-monitors", G_TYPE_BOOLEAN }, { "flat-buttons", G_TYPE_BOOLEAN }, { "switch-workspace-on-unminimize", G_TYPE_BOOLEAN },