aboutsummaryrefslogtreecommitdiff
path: root/src/fs/gnunet-fs-gtk.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs/gnunet-fs-gtk.c')
-rw-r--r--src/fs/gnunet-fs-gtk.c71
1 files changed, 34 insertions, 37 deletions
diff --git a/src/fs/gnunet-fs-gtk.c b/src/fs/gnunet-fs-gtk.c
index 8f4457a0..63eae452 100644
--- a/src/fs/gnunet-fs-gtk.c
+++ b/src/fs/gnunet-fs-gtk.c
@@ -61,7 +61,7 @@ GNUNET_FS_GTK_get_fs_handle ()
61 * @return configuration handle 61 * @return configuration handle
62 */ 62 */
63const struct GNUNET_CONFIGURATION_Handle * 63const struct GNUNET_CONFIGURATION_Handle *
64GNUNET_FS_GTK_get_configuration (void) 64GNUNET_FS_GTK_get_configuration ()
65{ 65{
66 return GNUNET_GTK_main_loop_get_configuration (ml); 66 return GNUNET_GTK_main_loop_get_configuration (ml);
67} 67}
@@ -102,18 +102,16 @@ static void
102main_window_save_position (GtkWidget *main_window) 102main_window_save_position (GtkWidget *main_window)
103{ 103{
104 GdkWindow *main_window_gdk; 104 GdkWindow *main_window_gdk;
105 105 gint window_x;
106 gint window_x, window_y, window_width, window_height, maximized; 106 gint window_y;
107 gint window_width;
108 gint window_height;
109 int maximized;
107 GdkWindowState window_state; 110 GdkWindowState window_state;
108 struct GNUNET_CONFIGURATION_Handle *cfg; 111 struct GNUNET_CONFIGURATION_Handle *cfg;
109 struct GNUNET_CONFIGURATION_Handle *cfgDefault; 112 struct GNUNET_CONFIGURATION_Handle *cfgDefault;
110 cfgDefault = GNUNET_CONFIGURATION_create ();
111 (void) GNUNET_CONFIGURATION_load (cfgDefault, NULL); /* load defaults only */
112
113 /* FIXME: is it safe to discard const qualifier? */
114 cfg = (struct GNUNET_CONFIGURATION_Handle *)
115 GNUNET_GTK_main_loop_get_configuration (ml);
116 113
114 cfg = (struct GNUNET_CONFIGURATION_Handle *) GNUNET_GTK_main_loop_get_configuration (ml);
117 main_window_gdk = gtk_widget_get_window (main_window); 115 main_window_gdk = gtk_widget_get_window (main_window);
118 maximized = GNUNET_YES; 116 maximized = GNUNET_YES;
119 if (NULL != main_window_gdk) 117 if (NULL != main_window_gdk)
@@ -127,20 +125,25 @@ main_window_save_position (GtkWidget *main_window)
127 gtk_window_get_size (GTK_WINDOW (main_window), &window_width, &window_height); 125 gtk_window_get_size (GTK_WINDOW (main_window), &window_width, &window_height);
128 126
129 GNUNET_CONFIGURATION_set_value_number (cfg, "gnunet-gtk", 127 GNUNET_CONFIGURATION_set_value_number (cfg, "gnunet-gtk",
130 "MAIN_WINDOW_X", window_x); 128 "MAIN_WINDOW_X", window_x);
131 GNUNET_CONFIGURATION_set_value_number (cfg, "gnunet-gtk", 129 GNUNET_CONFIGURATION_set_value_number (cfg, "gnunet-gtk",
132 "MAIN_WINDOW_Y", window_y); 130 "MAIN_WINDOW_Y", window_y);
133 GNUNET_CONFIGURATION_set_value_number (cfg, "gnunet-gtk", 131 GNUNET_CONFIGURATION_set_value_number (cfg, "gnunet-gtk",
134 "MAIN_WINDOW_WIDTH", window_width); 132 "MAIN_WINDOW_WIDTH", window_width);
135 GNUNET_CONFIGURATION_set_value_number (cfg, "gnunet-gtk", 133 GNUNET_CONFIGURATION_set_value_number (cfg, "gnunet-gtk",
136 "MAIN_WINDOW_HEIGHT", window_height); 134 "MAIN_WINDOW_HEIGHT", window_height);
137 GNUNET_CONFIGURATION_set_value_string (cfg, "gnunet-gtk", 135 GNUNET_CONFIGURATION_set_value_string (cfg, "gnunet-gtk",
138 "MAIN_WINDOW_MAXIMIZED", maximized == GNUNET_YES ? "YES" : "NO"); 136 "MAIN_WINDOW_MAXIMIZED",
137 (maximized == GNUNET_YES) ? "YES" : "NO");
139 138
140 GNUNET_CONFIGURATION_write_diffs (cfgDefault, cfg, "~/.gnunet/gnunet.conf"); 139 cfgDefault = GNUNET_CONFIGURATION_create ();
140 (void) GNUNET_CONFIGURATION_load (cfgDefault, NULL); /* load defaults only */
141 GNUNET_CONFIGURATION_write_diffs (cfgDefault, cfg,
142 GNUNET_GTK_main_loop_get_configuration_file (ml));
141 GNUNET_CONFIGURATION_destroy (cfgDefault); 143 GNUNET_CONFIGURATION_destroy (cfgDefault);
142} 144}
143 145
146
144/** 147/**
145 * Task run on shutdown. 148 * Task run on shutdown.
146 * FIXME-STYLE: does this need to be a separate task!? 149 * FIXME-STYLE: does this need to be a separate task!?
@@ -208,33 +211,27 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
208 211
209 cfg = GNUNET_GTK_main_loop_get_configuration (ml); 212 cfg = GNUNET_GTK_main_loop_get_configuration (ml);
210 213
211 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, "gnunet-gtk", 214 maximized = GNUNET_CONFIGURATION_get_value_yesno (cfg,
212 "MAIN_WINDOW_X", &window_x)) 215 "gnunet-gtk", "MAIN_WINDOW_MAXIMIZED");
213 window_x = ULONG_MAX; 216 if (GNUNET_SYSERR == maximized)
214 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, "gnunet-gtk",
215 "MAIN_WINDOW_Y", &window_y))
216 window_y = ULONG_MAX;
217 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, "gnunet-gtk",
218 "MAIN_WINDOW_WIDTH", &window_width))
219 window_width = ULONG_MAX;
220 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, "gnunet-gtk",
221 "MAIN_WINDOW_HEIGHT", &window_height))
222 window_height = ULONG_MAX;
223 if (GNUNET_SYSERR == (maximized = GNUNET_CONFIGURATION_get_value_yesno (cfg,
224 "gnunet-gtk", "MAIN_WINDOW_MAXIMIZED")))
225 maximized = GNUNET_YES; 217 maximized = GNUNET_YES;
226 218 if ( (GNUNET_NO == maximized) &&
227 if (window_x == ULONG_MAX || window_y == ULONG_MAX || 219 (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "gnunet-gtk",
228 window_width == ULONG_MAX || window_height == ULONG_MAX || 220 "MAIN_WINDOW_X", &window_x)) &&
229 maximized == GNUNET_YES) 221 (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "gnunet-gtk",
222 "MAIN_WINDOW_Y", &window_y)) &&
223 (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "gnunet-gtk",
224 "MAIN_WINDOW_WIDTH", &window_width)) &&
225 (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "gnunet-gtk",
226 "MAIN_WINDOW_HEIGHT", &window_height)) )
230 { 227 {
231 /* If anything is wrong - play safe and show it maximized */ 228 gtk_window_move (GTK_WINDOW (main_window), window_x, window_y);
232 gtk_window_maximize (GTK_WINDOW (main_window)); 229 gtk_window_resize (GTK_WINDOW (main_window), window_width, window_height);
233 } 230 }
234 else 231 else
235 { 232 {
236 gtk_window_move (GTK_WINDOW (main_window), window_x, window_y); 233 /* If anything is wrong - play safe and show it maximized */
237 gtk_window_resize (GTK_WINDOW (main_window), window_width, window_height); 234 gtk_window_maximize (GTK_WINDOW (main_window));
238 } 235 }
239 236
240 /* Allow multiple selection in metadata view; */ 237 /* Allow multiple selection in metadata view; */