[Xfce4-commits] <xfdesktop:master> Fix for invalid single workspace number in settings app

Eric Koegel noreply at xfce.org
Sun Aug 4 10:36:13 CEST 2013


Updating branch refs/heads/master
         to be0719f7c9e686ee52dc8a9a37f27e15f18203d1 (commit)
       from 02c53a331c02300134d66da376bcb6a85d90be63 (commit)

commit be0719f7c9e686ee52dc8a9a37f27e15f18203d1
Author: Eric Koegel <eric.koegel at gmail.com>
Date:   Sun Mar 24 15:07:29 2013 +0300

    Fix for invalid single workspace number in settings app
    
    Xfdesktop-settings app now repsonds to workspaces being created
    and destroyed because it can impact how the single workspace mode
    operates. If the single workspace number is set to a workspace that
    is destroyed it reverts back to per workspace wallpapers and toogles
    the checkbox so that the user knows what is going on.

 settings/main.c |   52 +++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 39 insertions(+), 13 deletions(-)

diff --git a/settings/main.c b/settings/main.c
index f33f543..d10dec2 100644
--- a/settings/main.c
+++ b/settings/main.c
@@ -101,6 +101,7 @@ typedef struct
     GtkWidget *frame_image_list;
     GtkWidget *image_iconview;
     GtkWidget *btn_folder;
+    GtkWidget *chk_apply_to_all;
     GtkWidget *image_style_combo;
     GtkWidget *color_style_combo;
     GtkWidget *color1_btn;
@@ -141,6 +142,9 @@ enum
     N_ICON_COLS,
 };
 
+static void cb_xfdesktop_chk_apply_to_all(GtkCheckButton *button,
+                                          gpointer user_data);
+
 
 /* assumes gdk lock is held on function enter, and should be held
  * on function exit */
@@ -683,7 +687,7 @@ xfdesktop_settings_get_active_workspace(AppearancePanel *panel,
 {
     WnckWorkspace *wnck_workspace;
     gboolean single_workspace;
-    gint workspace_num, active_workspace;
+    gint workspace_num, single_workspace_num;
 
     wnck_workspace = wnck_window_get_workspace(wnck_window);
 
@@ -694,16 +698,22 @@ xfdesktop_settings_get_active_workspace(AppearancePanel *panel,
                                                TRUE);
 
     /* If we're in single_workspace mode we need to return the workspace that
-     * it was set to, otherwise return the current workspace */
+     * it was set to, if that workspace exists, otherwise return the current
+     * workspace and turn off the single workspace mode */
     if(single_workspace) {
-        active_workspace = xfconf_channel_get_int(panel->channel,
-                                                  SINGLE_WORKSPACE_NUMBER,
-                                                  0);
-    } else {
-        active_workspace = workspace_num;
+        WnckScreen *wnck_screen = wnck_window_get_screen(wnck_window);
+        single_workspace_num = xfconf_channel_get_int(panel->channel,
+                                                      SINGLE_WORKSPACE_NUMBER,
+                                                      0);
+        if(single_workspace_num < wnck_screen_get_workspace_count(wnck_screen)) {
+            return single_workspace_num;
+        } else {
+            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(panel->chk_apply_to_all),
+                                         FALSE);
+        }
     }
 
-    return active_workspace;
+    return workspace_num;
 }
 
 static void
@@ -1097,6 +1107,18 @@ cb_update_background_tab(WnckWindow *wnck_window,
 }
 
 static void
+cb_workspace_changed(WnckScreen *screen,
+                               WnckWorkspace *workspace,
+                               gpointer user_data)
+{
+    AppearancePanel *panel = user_data;
+
+    /* Call update background because the single workspace mode may have
+     * changed due to the addition/removal of a workspace */
+    cb_update_background_tab(panel->wnck_window, user_data);
+}
+
+static void
 cb_xfdesktop_chk_apply_to_all(GtkCheckButton *button,
                               gpointer user_data)
 {
@@ -1153,7 +1175,7 @@ xfdesktop_settings_dialog_setup_tabs(GtkBuilder *main_gxml,
     GtkWidget *appearance_container, *chk_custom_font_size,
               *spin_font_size, *w, *box, *spin_icon_size,
               *chk_show_thumbnails, *chk_single_click, *appearance_settings,
-              *bnt_exit, *chk_apply_to_all;
+              *bnt_exit;
     GtkBuilder *appearance_gxml;
     AppearancePanel *panel = g_new0(AppearancePanel, 1);
     GError *error = NULL;
@@ -1226,6 +1248,10 @@ xfdesktop_settings_dialog_setup_tabs(GtkBuilder *main_gxml,
                      G_CALLBACK(cb_update_background_tab), panel);
     g_signal_connect(panel->wnck_window, "workspace-changed",
                      G_CALLBACK(cb_update_background_tab), panel);
+    g_signal_connect(wnck_screen, "workspace-created",
+                     G_CALLBACK(cb_workspace_changed), panel);
+    g_signal_connect(wnck_screen, "workspace-destroyed",
+                     G_CALLBACK(cb_workspace_changed), panel);
 
     /* send invalid numbers so that the update_background_tab will update everything */
     panel->monitor = -1;
@@ -1296,14 +1322,14 @@ xfdesktop_settings_dialog_setup_tabs(GtkBuilder *main_gxml,
     gtk_combo_box_set_active(GTK_COMBO_BOX(panel->color_style_combo), 0);
 
     /* Use these settings for all workspaces checkbox */
-    chk_apply_to_all =  GTK_WIDGET(gtk_builder_get_object(appearance_gxml,
-                                                          "chk_apply_to_all"));
+    panel->chk_apply_to_all =  GTK_WIDGET(gtk_builder_get_object(appearance_gxml,
+                                                                 "chk_apply_to_all"));
 
     if(xfconf_channel_get_bool(channel, SINGLE_WORKSPACE_MODE, TRUE)) {
-        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chk_apply_to_all), TRUE);
+        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(panel->chk_apply_to_all), TRUE);
     }
 
-    g_signal_connect(G_OBJECT(chk_apply_to_all), "toggled",
+    g_signal_connect(G_OBJECT(panel->chk_apply_to_all), "toggled",
                     G_CALLBACK(cb_xfdesktop_chk_apply_to_all),
                     panel);
 


More information about the Xfce4-commits mailing list