aboutsummaryrefslogtreecommitdiffstats
path: root/meta-xfce/recipes-xfce/xfce4-settings/xfce4-settings/0003-Remember-the-settings-manager-window-size-bug-9384.patch
blob: 8c1d1d9aa7ba9ab9bf3a1c0e68a1ca87d330345b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
From b3b1986327b9b42ac6f9442443ff103f6565a323 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Guelfucci?= <jeromeg@xfce.org>
Date: Wed, 19 Dec 2012 09:53:58 +0100
Subject: [PATCH] Remember the settings manager window size (bug #9384).

Handy with pluggable dialogs, allows the user to get rid of most of the
scrollbars.

Upstream-Status: applied
---
 xfce4-settings-manager/Makefile.am                 |    2 +
 xfce4-settings-manager/main.c                      |   13 +++++++
 .../xfce-settings-manager-dialog.c                 |   38 +++++++++++++++-----
 3 files changed, 44 insertions(+), 9 deletions(-)

diff --git a/xfce4-settings-manager/Makefile.am b/xfce4-settings-manager/Makefile.am
index c6bdc2d..99f9b3f 100644
--- a/xfce4-settings-manager/Makefile.am
+++ b/xfce4-settings-manager/Makefile.am
@@ -20,6 +20,7 @@ xfce4_settings_manager_CFLAGS = \
 	$(LIBXFCE4UTIL_CFLAGS) \
 	$(LIBXFCE4UI_CFLAGS) \
 	$(GARCON_CFLAGS) \
+	$(XFCONF_CFLAGS) \
 	$(EXO_CFLAGS) \
 	$(PLATFORM_CFLAGS)
 
@@ -31,6 +32,7 @@ xfce4_settings_manager_LDADD = \
 	$(GTK_LIBS) \
 	$(LIBXFCE4UTIL_LIBS) \
 	$(LIBXFCE4UI_LIBS) \
+	$(XFCONF_LIBS) \
 	$(EXO_LIBS) \
 	$(GARCON_LIBS)
 
diff --git a/xfce4-settings-manager/main.c b/xfce4-settings-manager/main.c
index 3a65879..42bec66 100644
--- a/xfce4-settings-manager/main.c
+++ b/xfce4-settings-manager/main.c
@@ -28,6 +28,7 @@
 #include <gtk/gtk.h>
 #include <libxfce4util/libxfce4util.h>
 #include <garcon/garcon.h>
+#include <xfconf/xfconf.h>
 
 #include "xfce-settings-manager-dialog.h"
 
@@ -79,6 +80,16 @@ main(int argc,
         return EXIT_SUCCESS;
     }
 
+    /* initialize xfconf */
+    if (G_UNLIKELY (!xfconf_init (&error)))
+    {
+        /* print error and leave */
+        g_critical ("Failed to connect to Xfconf daemon: %s", error->message);
+        g_error_free (error);
+
+        return EXIT_FAILURE;
+    }
+
     garcon_set_environment ("XFCE");
 
     dialog = xfce_settings_manager_dialog_new ();
@@ -95,5 +106,7 @@ main(int argc,
 
     gtk_main();
 
+    xfconf_shutdown ();
+
     return EXIT_SUCCESS;
 }
diff --git a/xfce4-settings-manager/xfce-settings-manager-dialog.c b/xfce4-settings-manager/xfce-settings-manager-dialog.c
index 043b143..39e33ff 100644
--- a/xfce4-settings-manager/xfce-settings-manager-dialog.c
+++ b/xfce4-settings-manager/xfce-settings-manager-dialog.c
@@ -35,6 +35,7 @@
 
 #include <libxfce4util/libxfce4util.h>
 #include <libxfce4ui/libxfce4ui.h>
+#include <xfconf/xfconf.h>
 #include <garcon/garcon.h>
 #include <exo/exo.h>
 
@@ -55,6 +56,7 @@ struct _XfceSettingsManagerDialog
 {
     XfceTitledDialog __parent__;
 
+    XfconfChannel  *channel;
     GarconMenu     *menu;
 
     GtkListStore   *store;
@@ -156,17 +158,19 @@ xfce_settings_manager_dialog_class_init (XfceSettingsManagerDialogClass *klass)
 static void
 xfce_settings_manager_dialog_init (XfceSettingsManagerDialog *dialog)
 {
-    GtkWidget *scroll;
+    GtkWidget *align;
+    GtkWidget *bbox;
     GtkWidget *dialog_vbox;
-    GtkWidget *viewport;
-    gchar     *path;
-    GtkWidget *hbox;
+    GtkWidget *ebox;
     GtkWidget *entry;
-    GtkWidget *align;
-    GList     *children;
+    GtkWidget *hbox;
     GtkWidget *header;
-    GtkWidget *ebox;
-    GtkWidget *bbox;
+    GtkWidget *scroll;
+    GtkWidget *viewport;
+    GList     *children;
+    gchar     *path;
+
+    dialog->channel = xfconf_channel_get ("xfce4-settings-manager");
 
     dialog->store = gtk_list_store_new (N_COLUMNS,
                                         G_TYPE_STRING,
@@ -180,7 +184,9 @@ xfce_settings_manager_dialog_init (XfceSettingsManagerDialog *dialog)
     dialog->menu = garcon_menu_new_for_path (path != NULL ? path : MENUFILE);
     g_free (path);
 
-    gtk_window_set_default_size (GTK_WINDOW (dialog), 640, 500);
+    gtk_window_set_default_size (GTK_WINDOW (dialog),
+      xfconf_channel_get_int (dialog->channel, "/last/window-width", 640),
+      xfconf_channel_get_int (dialog->channel, "/last/window-height", 500));
     xfce_settings_manager_dialog_set_title (dialog, NULL, NULL, NULL);
 
     dialog->button_back = xfce_gtk_button_new_mixed (GTK_STOCK_GO_BACK, _("All _Settings"));
@@ -334,6 +340,20 @@ xfce_settings_manager_dialog_response (GtkDialog *widget,
     }
     else
     {
+        GdkWindowState state;
+        gint           width, height;
+
+        /* Don't save the state for full-screen windows */
+        state = gdk_window_get_state (GTK_WIDGET (widget)->window);
+
+        if ((state & (GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN)) == 0)
+        {
+            /* Save window size */
+            gtk_window_get_size (GTK_WINDOW (widget), &width, &height);
+            xfconf_channel_set_int (dialog->channel, "/last/window-width", width),
+            xfconf_channel_set_int (dialog->channel, "/last/window-height", height);
+        }
+
         gtk_widget_destroy (GTK_WIDGET (widget));
         gtk_main_quit ();
     }
-- 
1.7.4.4