diff options
Diffstat (limited to 'src/fs/gnunet-fs-gtk.c')
-rw-r--r-- | src/fs/gnunet-fs-gtk.c | 96 |
1 files changed, 48 insertions, 48 deletions
diff --git a/src/fs/gnunet-fs-gtk.c b/src/fs/gnunet-fs-gtk.c index 2f775e86..918611c7 100644 --- a/src/fs/gnunet-fs-gtk.c +++ b/src/fs/gnunet-fs-gtk.c | |||
@@ -193,7 +193,9 @@ GNUNET_GTK_main_window_configure_event_cb (GtkWidget *main_window, | |||
193 | static void | 193 | static void |
194 | shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 194 | shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
195 | { | 195 | { |
196 | GNUNET_GTK_tray_icon_destroy (); | ||
196 | GNUNET_GTK_main_loop_quit (ml); | 197 | GNUNET_GTK_main_loop_quit (ml); |
198 | ml = NULL; | ||
197 | if (fs != NULL) | 199 | if (fs != NULL) |
198 | { | 200 | { |
199 | GNUNET_FS_stop (fs); | 201 | GNUNET_FS_stop (fs); |
@@ -211,14 +213,11 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
211 | */ | 213 | */ |
212 | void | 214 | void |
213 | GNUNET_FS_GTK_menu_quit_activate_cb (GtkMenuItem *object, | 215 | GNUNET_FS_GTK_menu_quit_activate_cb (GtkMenuItem *object, |
214 | gpointer user_data) | 216 | gpointer user_data) |
215 | { | 217 | { |
216 | struct GNUNET_GTK_MainWindowContext *main_context = user_data; | 218 | struct GNUNET_GTK_MainWindowContext *main_context = user_data; |
217 | 219 | ||
218 | GNUNET_GTK_tray_icon_destroy (); | 220 | GNUNET_SCHEDULER_shutdown (); |
219 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, | ||
220 | &shutdown_task, NULL); | ||
221 | GNUNET_free (main_context); | ||
222 | } | 221 | } |
223 | 222 | ||
224 | 223 | ||
@@ -368,37 +367,37 @@ unique_app_message_cb (UniqueApp *app, | |||
368 | static void | 367 | static void |
369 | run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 368 | run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
370 | { | 369 | { |
371 | unsigned long long dl_parallel, req_parallel, window_x, window_y, | 370 | unsigned long long dl_parallel; |
372 | window_width, window_height; | 371 | unsigned long long req_parallel; |
372 | unsigned long long window_x; | ||
373 | unsigned long long window_y; | ||
374 | unsigned long long window_width; | ||
375 | unsigned long long window_height; | ||
373 | int maximized; | 376 | int maximized; |
374 | struct GNUNET_GTK_MainWindowContext *main_context; | 377 | static struct GNUNET_GTK_MainWindowContext main_context; |
375 | 378 | ||
376 | main_context = GNUNET_malloc (sizeof (struct GNUNET_GTK_MainWindowContext)); | ||
377 | ml = cls; | 379 | ml = cls; |
378 | /* setup main context */ | 380 | /* setup main context */ |
379 | if (GNUNET_OK != GNUNET_GTK_main_loop_build_window (cls, main_context)) | 381 | if (GNUNET_OK != GNUNET_GTK_main_loop_build_window (cls, &main_context)) |
380 | { | ||
381 | GNUNET_free (main_context); | ||
382 | return; | 382 | return; |
383 | } | 383 | main_context.builder = GNUNET_GTK_main_loop_get_builder (cls); |
384 | main_context->builder = GNUNET_GTK_main_loop_get_builder (cls); | 384 | main_context.cfg = GNUNET_GTK_main_loop_get_configuration (cls); |
385 | main_context->cfg = GNUNET_GTK_main_loop_get_configuration (cls); | 385 | main_context.search_ns_treestore = GTK_TREE_STORE (GNUNET_FS_GTK_get_main_window_object ("main_window_search_namespace_treestore")); |
386 | main_context->search_ns_treestore = GTK_TREE_STORE (GNUNET_FS_GTK_get_main_window_object ("main_window_search_namespace_treestore")); | 386 | main_context.main_window = GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_window")); |
387 | main_context->main_window = GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_window")); | 387 | main_context.ns_selector_treeview = GTK_TREE_VIEW (GNUNET_FS_GTK_get_main_window_object ("namespace_selector_treeview")); |
388 | main_context->ns_selector_treeview = GTK_TREE_VIEW (GNUNET_FS_GTK_get_main_window_object ("namespace_selector_treeview")); | 388 | main_context.ns_selector_window = GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object ("namespace_selector_window")); |
389 | main_context->ns_selector_window = GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object ("namespace_selector_window")); | 389 | main_context.ns_dropdown_button = GTK_TOGGLE_BUTTON (GNUNET_FS_GTK_get_main_window_object ("main_window_search_namespace_dropdown_button")); |
390 | main_context->ns_dropdown_button = GTK_TOGGLE_BUTTON (GNUNET_FS_GTK_get_main_window_object ("main_window_search_namespace_dropdown_button")); | 390 | main_context.search_ns_label = GTK_LABEL (GNUNET_FS_GTK_get_main_window_object ("main_window_search_selected_namespace_label")); |
391 | main_context->search_ns_label = GTK_LABEL (GNUNET_FS_GTK_get_main_window_object ("main_window_search_selected_namespace_label")); | ||
392 | 391 | ||
393 | main_context->search_entry = GTK_ENTRY (GNUNET_FS_GTK_get_main_window_object ("main_window_search_entry")); | 392 | main_context.search_entry = GTK_ENTRY (GNUNET_FS_GTK_get_main_window_object ("main_window_search_entry")); |
394 | 393 | ||
395 | main_context->anonymity_combo = GTK_COMBO_BOX (GNUNET_FS_GTK_get_main_window_object ("main_window_search_anonymity_combobox")); | 394 | main_context.anonymity_combo = GTK_COMBO_BOX (GNUNET_FS_GTK_get_main_window_object ("main_window_search_anonymity_combobox")); |
396 | main_context->anonymity_level_liststore = GTK_LIST_STORE (GNUNET_FS_GTK_get_main_window_object ("anonymity_level_liststore")); | 395 | main_context.anonymity_level_liststore = GTK_LIST_STORE (GNUNET_FS_GTK_get_main_window_object ("anonymity_level_liststore")); |
397 | 396 | ||
398 | main_context->preview_image = GTK_IMAGE (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_window_preview_image")); | 397 | main_context.preview_image = GTK_IMAGE (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_window_preview_image")); |
399 | main_context->md_liststore = GTK_LIST_STORE (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_meta_data_list_store")); | 398 | main_context.md_liststore = GTK_LIST_STORE (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_meta_data_list_store")); |
400 | main_context->md_treeview = GTK_TREE_VIEW (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_window_metadata_treeview")); | 399 | main_context.md_treeview = GTK_TREE_VIEW (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_window_metadata_treeview")); |
401 | main_context->ns_callback_registered = GNUNET_NO; | 400 | main_context.ns_callback_registered = GNUNET_NO; |
402 | 401 | ||
403 | GNUNET_GTK_set_icon_search_path (); | 402 | GNUNET_GTK_set_icon_search_path (); |
404 | GNUNET_GTK_setup_nls (); | 403 | GNUNET_GTK_setup_nls (); |
@@ -411,50 +410,51 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
411 | g_object_set (gtk_settings_get_default (), "gtk-button-images", TRUE, NULL); | 410 | g_object_set (gtk_settings_get_default (), "gtk-button-images", TRUE, NULL); |
412 | 411 | ||
413 | /* setup main window */ | 412 | /* setup main window */ |
414 | maximized = GNUNET_CONFIGURATION_get_value_yesno (main_context->cfg, | 413 | maximized = GNUNET_CONFIGURATION_get_value_yesno (main_context.cfg, |
415 | "gnunet-gtk", "MAIN_WINDOW_MAXIMIZED"); | 414 | "gnunet-gtk", "MAIN_WINDOW_MAXIMIZED"); |
416 | if (GNUNET_SYSERR == maximized) | 415 | if (GNUNET_SYSERR == maximized) |
417 | maximized = GNUNET_YES; | 416 | maximized = GNUNET_YES; |
418 | if ( (GNUNET_NO == maximized) && | 417 | if ( (GNUNET_NO == maximized) && |
419 | (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (main_context->cfg, "gnunet-gtk", | 418 | (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (main_context.cfg, "gnunet-gtk", |
420 | "MAIN_WINDOW_X", &window_x)) && | 419 | "MAIN_WINDOW_X", &window_x)) && |
421 | (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (main_context->cfg, "gnunet-gtk", | 420 | (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (main_context.cfg, "gnunet-gtk", |
422 | "MAIN_WINDOW_Y", &window_y)) && | 421 | "MAIN_WINDOW_Y", &window_y)) && |
423 | (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (main_context->cfg, "gnunet-gtk", | 422 | (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (main_context.cfg, "gnunet-gtk", |
424 | "MAIN_WINDOW_WIDTH", &window_width)) && | 423 | "MAIN_WINDOW_WIDTH", &window_width)) && |
425 | (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (main_context->cfg, "gnunet-gtk", | 424 | (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (main_context.cfg, "gnunet-gtk", |
426 | "MAIN_WINDOW_HEIGHT", &window_height)) ) | 425 | "MAIN_WINDOW_HEIGHT", &window_height)) ) |
427 | { | 426 | { |
428 | gtk_window_move (GTK_WINDOW (main_context->main_window), window_x, window_y); | 427 | gtk_window_move (GTK_WINDOW (main_context.main_window), window_x, window_y); |
429 | gtk_window_resize (GTK_WINDOW (main_context->main_window), window_width, window_height); | 428 | gtk_window_resize (GTK_WINDOW (main_context.main_window), window_width, window_height); |
430 | } | 429 | } |
431 | else | 430 | else |
432 | { | 431 | { |
433 | /* If anything is wrong - play safe and show it maximized */ | 432 | /* If anything is wrong - play safe and show it maximized */ |
434 | gtk_window_maximize (GTK_WINDOW (main_context->main_window)); | 433 | gtk_window_maximize (GTK_WINDOW (main_context.main_window)); |
435 | } | 434 | } |
436 | 435 | ||
437 | /* Allow multiple selection in metadata view; */ | 436 | /* Allow multiple selection in metadata view; */ |
438 | /* FIXME-GTK3: this can be done within (modern versions of) glade */ | 437 | /* FIXME-GTK3: this can be done within (modern versions of) glade */ |
439 | gtk_tree_selection_set_mode (gtk_tree_view_get_selection (main_context->md_treeview), | 438 | gtk_tree_selection_set_mode (gtk_tree_view_get_selection (main_context.md_treeview), |
440 | GTK_SELECTION_MULTIPLE); | 439 | GTK_SELECTION_MULTIPLE); |
441 | 440 | ||
442 | GNUNET_GTK_tray_icon_create (GTK_WINDOW (main_context->main_window), | 441 | GNUNET_GTK_tray_icon_create (ml, |
442 | GTK_WINDOW (main_context.main_window), | ||
443 | "gnunet-fs-gtk", | 443 | "gnunet-fs-gtk", |
444 | "gnunet-fs-gtk"); | 444 | "gnunet-fs-gtk"); |
445 | 445 | ||
446 | /* FIXME: should these '1's be here? Maybe better to put them into | 446 | /* FIXME: should these '1's be here? Maybe better to put them into |
447 | * default config files? | 447 | * default config files? |
448 | */ | 448 | */ |
449 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (main_context->cfg, "gnunet-fs-gtk", | 449 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (main_context.cfg, "gnunet-fs-gtk", |
450 | "MAX_PARALLEL_DOWNLOADS", &dl_parallel)) | 450 | "MAX_PARALLEL_DOWNLOADS", &dl_parallel)) |
451 | dl_parallel = DEFAULT_MAX_PARALLEL_DOWNLOADS; | 451 | dl_parallel = DEFAULT_MAX_PARALLEL_DOWNLOADS; |
452 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (main_context->cfg, "gnunet-fs-gtk", | 452 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (main_context.cfg, "gnunet-fs-gtk", |
453 | "MAX_PARALLEL_REQUESTS", &req_parallel)) | 453 | "MAX_PARALLEL_REQUESTS", &req_parallel)) |
454 | req_parallel = DEFAULT_MAX_PARALLEL_REQUESTS; | 454 | req_parallel = DEFAULT_MAX_PARALLEL_REQUESTS; |
455 | 455 | ||
456 | /* initialize file-sharing */ | 456 | /* initialize file-sharing */ |
457 | fs = GNUNET_FS_start (main_context->cfg, "gnunet-fs-gtk", | 457 | fs = GNUNET_FS_start (main_context.cfg, "gnunet-fs-gtk", |
458 | &GNUNET_GTK_fs_event_handler, NULL, | 458 | &GNUNET_GTK_fs_event_handler, NULL, |
459 | GNUNET_FS_FLAGS_PERSISTENCE | GNUNET_FS_FLAGS_DO_PROBES, | 459 | GNUNET_FS_FLAGS_PERSISTENCE | GNUNET_FS_FLAGS_DO_PROBES, |
460 | GNUNET_FS_OPTIONS_DOWNLOAD_PARALLELISM, | 460 | GNUNET_FS_OPTIONS_DOWNLOAD_PARALLELISM, |
@@ -465,23 +465,23 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
465 | if (NULL == fs) | 465 | if (NULL == fs) |
466 | { | 466 | { |
467 | GNUNET_GTK_main_loop_quit (cls); | 467 | GNUNET_GTK_main_loop_quit (cls); |
468 | GNUNET_free (main_context); | ||
469 | return; | 468 | return; |
470 | } | 469 | } |
471 | 470 | ||
472 | GNUNET_GTK_main_window_refresh_ns_list (main_context); | 471 | GNUNET_GTK_main_window_refresh_ns_list (&main_context); |
473 | #if HAVE_LIBUNIQUE | 472 | #if HAVE_LIBUNIQUE |
474 | unique_app_watch_window (unique_app, GTK_WINDOW (main_context->main_window)); | 473 | unique_app_watch_window (unique_app, GTK_WINDOW (main_context.main_window)); |
475 | g_signal_connect (unique_app, "message-received", | 474 | g_signal_connect (unique_app, "message-received", |
476 | G_CALLBACK (unique_app_message_cb), main_context); | 475 | G_CALLBACK (unique_app_message_cb), &main_context); |
477 | #endif | 476 | #endif |
478 | /* make GUI visible */ | 477 | /* make GUI visible */ |
479 | if (!tray_only) | 478 | if (!tray_only) |
480 | { | 479 | { |
481 | gtk_widget_show (main_context->main_window); | 480 | gtk_widget_show (main_context.main_window); |
482 | gtk_window_present (GTK_WINDOW (main_context->main_window)); | 481 | gtk_window_present (GTK_WINDOW (main_context.main_window)); |
483 | } | 482 | } |
484 | 483 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | |
484 | &shutdown_task, NULL); | ||
485 | } | 485 | } |
486 | 486 | ||
487 | 487 | ||