diff options
Diffstat (limited to 'src/fs/gnunet-fs-gtk.c')
-rw-r--r-- | src/fs/gnunet-fs-gtk.c | 66 |
1 files changed, 57 insertions, 9 deletions
diff --git a/src/fs/gnunet-fs-gtk.c b/src/fs/gnunet-fs-gtk.c index 415f142c..b44b970c 100644 --- a/src/fs/gnunet-fs-gtk.c +++ b/src/fs/gnunet-fs-gtk.c | |||
@@ -110,7 +110,7 @@ GNUNET_FS_GTK_get_anonymity_level_list_store () | |||
110 | * | 110 | * |
111 | * @param main_window main window widget | 111 | * @param main_window main window widget |
112 | */ | 112 | */ |
113 | static void | 113 | void |
114 | main_window_save_position (GtkWidget *main_window) | 114 | main_window_save_position (GtkWidget *main_window) |
115 | { | 115 | { |
116 | GdkWindow *main_window_gdk; | 116 | GdkWindow *main_window_gdk; |
@@ -157,6 +157,40 @@ main_window_save_position (GtkWidget *main_window) | |||
157 | 157 | ||
158 | 158 | ||
159 | /** | 159 | /** |
160 | * Obtains main window position and size before it's destroyed | ||
161 | * and saves these into user's config file. | ||
162 | * | ||
163 | * @param main_window main window widget | ||
164 | */ | ||
165 | void | ||
166 | GNUNET_FS_GTK_main_window_drag_end (GtkWidget *main_window, | ||
167 | GdkDragContext *drag_context, | ||
168 | gpointer user_data) | ||
169 | { | ||
170 | struct GNUNET_GTK_MainWindowContext *main_context = user_data; | ||
171 | |||
172 | main_window_save_position (main_context->main_window); | ||
173 | } | ||
174 | |||
175 | |||
176 | /** | ||
177 | * Obtains main window position and size before it's destroyed | ||
178 | * and saves these into user's config file. | ||
179 | * | ||
180 | * @param main_window main window widget | ||
181 | */ | ||
182 | void | ||
183 | GNUNET_FS_GTK_main_window_size_request (GtkWidget *main_window, | ||
184 | GtkRequisition *requisition, | ||
185 | gpointer user_data) | ||
186 | { | ||
187 | struct GNUNET_GTK_MainWindowContext *main_context = user_data; | ||
188 | |||
189 | main_window_save_position (main_context->main_window); | ||
190 | } | ||
191 | |||
192 | |||
193 | /** | ||
160 | * Task run on shutdown. | 194 | * Task run on shutdown. |
161 | * FIXME-STYLE: does this need to be a separate task!? | 195 | * FIXME-STYLE: does this need to be a separate task!? |
162 | * | 196 | * |
@@ -182,11 +216,30 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
182 | * @param user_data global builder instance, unused | 216 | * @param user_data global builder instance, unused |
183 | */ | 217 | */ |
184 | void | 218 | void |
185 | GNUNET_GTK_quit_cb (GObject * object, gpointer user_data) | 219 | GNUNET_FS_GTK_menu_quit_activate_cb (GtkMenuItem *object, |
220 | gpointer user_data) | ||
186 | { | 221 | { |
187 | struct GNUNET_GTK_MainWindowContext *main_context = user_data; | 222 | struct GNUNET_GTK_MainWindowContext *main_context = user_data; |
188 | 223 | ||
189 | main_window_save_position (main_context->main_window); | 224 | GNUNET_GTK_tray_icon_destroy (); |
225 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, | ||
226 | &shutdown_task, NULL); | ||
227 | GNUNET_free (main_context); | ||
228 | } | ||
229 | |||
230 | |||
231 | /** | ||
232 | * Callback invoked if the application is supposed to exit. | ||
233 | * | ||
234 | * @param object origin of the quit event, unused | ||
235 | * @param user_data global builder instance, unused | ||
236 | */ | ||
237 | void | ||
238 | GNUNET_FS_GTK_delete_event_cb (GtkWidget *object, | ||
239 | GdkEvent *event, | ||
240 | gpointer user_data) | ||
241 | { | ||
242 | struct GNUNET_GTK_MainWindowContext *main_context = user_data; | ||
190 | 243 | ||
191 | GNUNET_GTK_tray_icon_destroy (); | 244 | GNUNET_GTK_tray_icon_destroy (); |
192 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, | 245 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, |
@@ -208,20 +261,16 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
208 | unsigned long long dl_parallel, req_parallel, window_x, window_y, | 261 | unsigned long long dl_parallel, req_parallel, window_x, window_y, |
209 | window_width, window_height; | 262 | window_width, window_height; |
210 | int maximized; | 263 | int maximized; |
211 | |||
212 | struct GNUNET_GTK_MainWindowContext *main_context; | 264 | struct GNUNET_GTK_MainWindowContext *main_context; |
213 | 265 | ||
214 | main_context = GNUNET_malloc (sizeof (struct GNUNET_GTK_MainWindowContext)); | 266 | main_context = GNUNET_malloc (sizeof (struct GNUNET_GTK_MainWindowContext)); |
215 | |||
216 | ml = cls; | 267 | ml = cls; |
217 | |||
218 | /* setup main context */ | 268 | /* setup main context */ |
219 | if (GNUNET_OK != GNUNET_GTK_main_loop_build_window (cls, main_context)) | 269 | if (GNUNET_OK != GNUNET_GTK_main_loop_build_window (cls, main_context)) |
220 | { | 270 | { |
221 | GNUNET_free (main_context); | 271 | GNUNET_free (main_context); |
222 | return; | 272 | return; |
223 | } | 273 | } |
224 | |||
225 | main_context->builder = GNUNET_GTK_main_loop_get_builder (cls); | 274 | main_context->builder = GNUNET_GTK_main_loop_get_builder (cls); |
226 | main_context->cfg = GNUNET_GTK_main_loop_get_configuration (cls); | 275 | main_context->cfg = GNUNET_GTK_main_loop_get_configuration (cls); |
227 | main_context->search_ns_treestore = GTK_TREE_STORE (GNUNET_FS_GTK_get_main_window_object ("main_window_search_namespace_treestore")); | 276 | main_context->search_ns_treestore = GTK_TREE_STORE (GNUNET_FS_GTK_get_main_window_object ("main_window_search_namespace_treestore")); |
@@ -297,8 +346,7 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
297 | /* initialize file-sharing */ | 346 | /* initialize file-sharing */ |
298 | fs = GNUNET_FS_start (main_context->cfg, "gnunet-fs-gtk", | 347 | fs = GNUNET_FS_start (main_context->cfg, "gnunet-fs-gtk", |
299 | &GNUNET_GTK_fs_event_handler, NULL, | 348 | &GNUNET_GTK_fs_event_handler, NULL, |
300 | GNUNET_FS_FLAGS_NONE | GNUNET_FS_FLAGS_PERSISTENCE | 349 | GNUNET_FS_FLAGS_PERSISTENCE | GNUNET_FS_FLAGS_DO_PROBES, |
301 | /* | GNUNET_FS_FLAGS_DO_PROBES */ , | ||
302 | GNUNET_FS_OPTIONS_DOWNLOAD_PARALLELISM, | 350 | GNUNET_FS_OPTIONS_DOWNLOAD_PARALLELISM, |
303 | (unsigned int) dl_parallel, | 351 | (unsigned int) dl_parallel, |
304 | GNUNET_FS_OPTIONS_REQUEST_PARALLELISM, | 352 | GNUNET_FS_OPTIONS_REQUEST_PARALLELISM, |