gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r24889 - in gnunet-gtk: contrib src/fs src/include src/lib


From: gnunet
Subject: [GNUnet-SVN] r24889 - in gnunet-gtk: contrib src/fs src/include src/lib src/peerinfo src/setup src/statistics
Date: Sat, 10 Nov 2012 21:07:04 +0100

Author: grothoff
Date: 2012-11-10 21:07:04 +0100 (Sat, 10 Nov 2012)
New Revision: 24889

Modified:
   gnunet-gtk/contrib/gnunet_gtk_status_bar_menu.glade
   gnunet-gtk/src/fs/gnunet-fs-gtk.c
   gnunet-gtk/src/include/gnunet_gtk.h
   gnunet-gtk/src/lib/eventloop.c
   gnunet-gtk/src/lib/trayicon.c
   gnunet-gtk/src/peerinfo/gnunet-peerinfo-gtk.c
   gnunet-gtk/src/setup/gnunet-setup.c
   gnunet-gtk/src/statistics/gnunet-statistics-gtk.c
Log:
fix #2626 -- existing and window hiding via tray icon

Modified: gnunet-gtk/contrib/gnunet_gtk_status_bar_menu.glade
===================================================================
--- gnunet-gtk/contrib/gnunet_gtk_status_bar_menu.glade 2012-11-10 19:13:54 UTC 
(rev 24888)
+++ gnunet-gtk/contrib/gnunet_gtk_status_bar_menu.glade 2012-11-10 20:07:04 UTC 
(rev 24889)
@@ -13,7 +13,7 @@
         <property name="use_underline">True</property>
         <property name="use_stock">True</property>
         <property name="always_show_image">True</property>
-        <signal name="activate" handler="GNUNET_GTK_quit_cb" swapped="no"/>
+        <signal name="activate" handler="GNUNET_GTK_tray_icon_quit" 
swapped="no"/>
       </object>
     </child>
   </object>

Modified: gnunet-gtk/src/fs/gnunet-fs-gtk.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk.c   2012-11-10 19:13:54 UTC (rev 24888)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk.c   2012-11-10 20:07:04 UTC (rev 24889)
@@ -193,7 +193,9 @@
 static void
 shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {  
+  GNUNET_GTK_tray_icon_destroy ();
   GNUNET_GTK_main_loop_quit (ml);
+  ml = NULL;
   if (fs != NULL)
   {
     GNUNET_FS_stop (fs);
@@ -211,14 +213,11 @@
  */
 void
 GNUNET_FS_GTK_menu_quit_activate_cb (GtkMenuItem *object,
-                                 gpointer user_data)
+                                    gpointer user_data)
 {
   struct GNUNET_GTK_MainWindowContext *main_context = user_data;
 
-  GNUNET_GTK_tray_icon_destroy ();
-  GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                      &shutdown_task, NULL);
-  GNUNET_free (main_context);
+  GNUNET_SCHEDULER_shutdown ();
 }
 
 
@@ -368,37 +367,37 @@
 static void
 run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
-  unsigned long long dl_parallel, req_parallel, window_x, window_y,
-      window_width, window_height;
+  unsigned long long dl_parallel;
+  unsigned long long req_parallel;
+  unsigned long long window_x;
+  unsigned long long window_y;
+  unsigned long long window_width;
+  unsigned long long window_height;
   int maximized;
-  struct GNUNET_GTK_MainWindowContext *main_context;
+  static struct GNUNET_GTK_MainWindowContext main_context;
 
-  main_context = GNUNET_malloc (sizeof (struct GNUNET_GTK_MainWindowContext));
   ml = cls;
   /* setup main context */
-  if (GNUNET_OK != GNUNET_GTK_main_loop_build_window (cls, main_context))
-  {
-    GNUNET_free (main_context);
+  if (GNUNET_OK != GNUNET_GTK_main_loop_build_window (cls, &main_context))
     return;
-  }
-  main_context->builder = GNUNET_GTK_main_loop_get_builder (cls);
-  main_context->cfg = GNUNET_GTK_main_loop_get_configuration (cls);
-  main_context->search_ns_treestore = GTK_TREE_STORE 
(GNUNET_FS_GTK_get_main_window_object 
("main_window_search_namespace_treestore"));
-  main_context->main_window = GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object 
("GNUNET_GTK_main_window"));
-  main_context->ns_selector_treeview = GTK_TREE_VIEW 
(GNUNET_FS_GTK_get_main_window_object ("namespace_selector_treeview"));
-  main_context->ns_selector_window = GTK_WIDGET 
(GNUNET_FS_GTK_get_main_window_object ("namespace_selector_window"));
-  main_context->ns_dropdown_button = GTK_TOGGLE_BUTTON 
(GNUNET_FS_GTK_get_main_window_object 
("main_window_search_namespace_dropdown_button"));
-  main_context->search_ns_label = GTK_LABEL 
(GNUNET_FS_GTK_get_main_window_object 
("main_window_search_selected_namespace_label"));
+  main_context.builder = GNUNET_GTK_main_loop_get_builder (cls);
+  main_context.cfg = GNUNET_GTK_main_loop_get_configuration (cls);
+  main_context.search_ns_treestore = GTK_TREE_STORE 
(GNUNET_FS_GTK_get_main_window_object 
("main_window_search_namespace_treestore"));
+  main_context.main_window = GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object 
("GNUNET_GTK_main_window"));
+  main_context.ns_selector_treeview = GTK_TREE_VIEW 
(GNUNET_FS_GTK_get_main_window_object ("namespace_selector_treeview"));
+  main_context.ns_selector_window = GTK_WIDGET 
(GNUNET_FS_GTK_get_main_window_object ("namespace_selector_window"));
+  main_context.ns_dropdown_button = GTK_TOGGLE_BUTTON 
(GNUNET_FS_GTK_get_main_window_object 
("main_window_search_namespace_dropdown_button"));
+  main_context.search_ns_label = GTK_LABEL 
(GNUNET_FS_GTK_get_main_window_object 
("main_window_search_selected_namespace_label"));
 
-  main_context->search_entry = GTK_ENTRY (GNUNET_FS_GTK_get_main_window_object 
("main_window_search_entry"));
+  main_context.search_entry = GTK_ENTRY (GNUNET_FS_GTK_get_main_window_object 
("main_window_search_entry"));
 
-  main_context->anonymity_combo = GTK_COMBO_BOX 
(GNUNET_FS_GTK_get_main_window_object 
("main_window_search_anonymity_combobox"));
-  main_context->anonymity_level_liststore = GTK_LIST_STORE 
(GNUNET_FS_GTK_get_main_window_object ("anonymity_level_liststore"));
+  main_context.anonymity_combo = GTK_COMBO_BOX 
(GNUNET_FS_GTK_get_main_window_object 
("main_window_search_anonymity_combobox"));
+  main_context.anonymity_level_liststore = GTK_LIST_STORE 
(GNUNET_FS_GTK_get_main_window_object ("anonymity_level_liststore"));
 
-  main_context->preview_image = GTK_IMAGE 
(GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_window_preview_image"));
-  main_context->md_liststore = GTK_LIST_STORE 
(GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_meta_data_list_store"));
-  main_context->md_treeview = GTK_TREE_VIEW 
(GNUNET_FS_GTK_get_main_window_object 
("GNUNET_GTK_main_window_metadata_treeview"));
-  main_context->ns_callback_registered = GNUNET_NO;
+  main_context.preview_image = GTK_IMAGE (GNUNET_FS_GTK_get_main_window_object 
("GNUNET_GTK_main_window_preview_image"));
+  main_context.md_liststore = GTK_LIST_STORE 
(GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_meta_data_list_store"));
+  main_context.md_treeview = GTK_TREE_VIEW 
(GNUNET_FS_GTK_get_main_window_object 
("GNUNET_GTK_main_window_metadata_treeview"));
+  main_context.ns_callback_registered = GNUNET_NO;
 
   GNUNET_GTK_set_icon_search_path ();
   GNUNET_GTK_setup_nls ();
@@ -411,50 +410,51 @@
   g_object_set (gtk_settings_get_default (), "gtk-button-images", TRUE, NULL);
 
   /* setup main window */
-  maximized = GNUNET_CONFIGURATION_get_value_yesno (main_context->cfg,
+  maximized = GNUNET_CONFIGURATION_get_value_yesno (main_context.cfg,
                                                    "gnunet-gtk", 
"MAIN_WINDOW_MAXIMIZED");
   if (GNUNET_SYSERR == maximized)
     maximized = GNUNET_YES;
   if ( (GNUNET_NO == maximized) &&
-       (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (main_context->cfg, 
"gnunet-gtk",
+       (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (main_context.cfg, 
"gnunet-gtk",
                                                            "MAIN_WINDOW_X", 
&window_x)) &&
-       (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (main_context->cfg, 
"gnunet-gtk",
+       (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (main_context.cfg, 
"gnunet-gtk",
                                                            "MAIN_WINDOW_Y", 
&window_y)) &&
-       (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (main_context->cfg, 
"gnunet-gtk",
+       (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (main_context.cfg, 
"gnunet-gtk",
                                                            
"MAIN_WINDOW_WIDTH", &window_width)) &&
-       (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (main_context->cfg, 
"gnunet-gtk",
+       (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (main_context.cfg, 
"gnunet-gtk",
                                                            
"MAIN_WINDOW_HEIGHT", &window_height)) )
   {
-    gtk_window_move (GTK_WINDOW (main_context->main_window), window_x, 
window_y);
-    gtk_window_resize (GTK_WINDOW (main_context->main_window), window_width, 
window_height);
+    gtk_window_move (GTK_WINDOW (main_context.main_window), window_x, 
window_y);
+    gtk_window_resize (GTK_WINDOW (main_context.main_window), window_width, 
window_height);
   }
   else
   {
     /* If anything is wrong - play safe and show it maximized */
-    gtk_window_maximize (GTK_WINDOW (main_context->main_window));
+    gtk_window_maximize (GTK_WINDOW (main_context.main_window));
   }
   
   /* Allow multiple selection in metadata view; */
   /* FIXME-GTK3: this can be done within (modern versions of) glade */
-  gtk_tree_selection_set_mode (gtk_tree_view_get_selection 
(main_context->md_treeview),
+  gtk_tree_selection_set_mode (gtk_tree_view_get_selection 
(main_context.md_treeview),
                                GTK_SELECTION_MULTIPLE);
 
-  GNUNET_GTK_tray_icon_create (GTK_WINDOW (main_context->main_window),
+  GNUNET_GTK_tray_icon_create (ml,
+                              GTK_WINDOW (main_context.main_window),
                                "gnunet-fs-gtk",
                                "gnunet-fs-gtk");
 
   /* FIXME: should these '1's be here? Maybe better to put them into
    * default config files?
    */
-  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (main_context->cfg, 
"gnunet-fs-gtk",
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (main_context.cfg, 
"gnunet-fs-gtk",
       "MAX_PARALLEL_DOWNLOADS", &dl_parallel))
     dl_parallel = DEFAULT_MAX_PARALLEL_DOWNLOADS;
-  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (main_context->cfg, 
"gnunet-fs-gtk",
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (main_context.cfg, 
"gnunet-fs-gtk",
       "MAX_PARALLEL_REQUESTS", &req_parallel))
     req_parallel = DEFAULT_MAX_PARALLEL_REQUESTS;
 
   /* initialize file-sharing */
-  fs = GNUNET_FS_start (main_context->cfg, "gnunet-fs-gtk",
+  fs = GNUNET_FS_start (main_context.cfg, "gnunet-fs-gtk",
                        &GNUNET_GTK_fs_event_handler, NULL, 
                        GNUNET_FS_FLAGS_PERSISTENCE | GNUNET_FS_FLAGS_DO_PROBES,
                         GNUNET_FS_OPTIONS_DOWNLOAD_PARALLELISM,
@@ -465,23 +465,23 @@
   if (NULL == fs)
   {
     GNUNET_GTK_main_loop_quit (cls);
-    GNUNET_free (main_context);
     return;
   }
 
-  GNUNET_GTK_main_window_refresh_ns_list (main_context);
+  GNUNET_GTK_main_window_refresh_ns_list (&main_context);
 #if HAVE_LIBUNIQUE
-  unique_app_watch_window (unique_app, GTK_WINDOW (main_context->main_window));
+  unique_app_watch_window (unique_app, GTK_WINDOW (main_context.main_window));
   g_signal_connect (unique_app, "message-received",
-                   G_CALLBACK (unique_app_message_cb), main_context);
+                   G_CALLBACK (unique_app_message_cb), &main_context);
 #endif
   /* make GUI visible */
   if (!tray_only)
   {
-    gtk_widget_show (main_context->main_window);
-    gtk_window_present (GTK_WINDOW (main_context->main_window));
+    gtk_widget_show (main_context.main_window);
+    gtk_window_present (GTK_WINDOW (main_context.main_window));
   }
-
+  GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
+                               &shutdown_task, NULL);
 }
 
 

Modified: gnunet-gtk/src/include/gnunet_gtk.h
===================================================================
--- gnunet-gtk/src/include/gnunet_gtk.h 2012-11-10 19:13:54 UTC (rev 24888)
+++ gnunet-gtk/src/include/gnunet_gtk.h 2012-11-10 20:07:04 UTC (rev 24889)
@@ -47,6 +47,13 @@
 #define GDK_KEY_Delete GDK_Delete
 #endif
 
+/**
+ * Handle for our main loop.
+ */
+struct GNUNET_GTK_MainLoop;
+
+
+
 /* ****************** Initialization *************** */
 
 /**
@@ -122,15 +129,18 @@
                            GtkTreePath *treepath,
                             guint column, gchar ** value);
 
+
 /**
  * Create our tray icon.
  *
+ * @param ml main loop
  * @param main handle to the main window (show or hide)
  * @param icon_name name of the tray icon file
  * @param tooltip tooltip for the tray icon
  */
 void
-GNUNET_GTK_tray_icon_create (GtkWindow * main, const char *icon_name,
+GNUNET_GTK_tray_icon_create (struct GNUNET_GTK_MainLoop *ml,
+                            GtkWindow * main, const char *icon_name,
                              const char *tooltip);
 
 
@@ -174,12 +184,7 @@
 
 /* ******************* main loop ***************** */
 
-/**
- * Handle for our main loop.
- */
-struct GNUNET_GTK_MainLoop;
 
-
 /**
  * Initialize the main loop.
  *

Modified: gnunet-gtk/src/lib/eventloop.c
===================================================================
--- gnunet-gtk/src/lib/eventloop.c      2012-11-10 19:13:54 UTC (rev 24888)
+++ gnunet-gtk/src/lib/eventloop.c      2012-11-10 20:07:04 UTC (rev 24889)
@@ -190,6 +190,7 @@
   }
 }
 
+
 /**
  * Get the builder from the main window.
  *

Modified: gnunet-gtk/src/lib/trayicon.c
===================================================================
--- gnunet-gtk/src/lib/trayicon.c       2012-11-10 19:13:54 UTC (rev 24888)
+++ gnunet-gtk/src/lib/trayicon.c       2012-11-10 20:07:04 UTC (rev 24889)
@@ -45,20 +45,48 @@
 static void
 tray_icon_on_click (GtkStatusIcon * status_icon, gpointer user_data)
 {
-  if (gtk_window_is_active (main_window))
+  gboolean tlf;
+
+  g_object_get (main_window,
+               "visible", &tlf,
+               NULL);
+  if (tlf)
+  {
     gtk_widget_hide (GTK_WIDGET (main_window));
+  }
   else
-    gtk_window_present (main_window);
+  {
+    gtk_widget_show (GTK_WIDGET (main_window));
+    gtk_window_deiconify (main_window);
+    gtk_widget_grab_focus (GTK_WIDGET (main_window));
+  }
 }
 
 
 /**
+ * Function called from trayicon "quit" context menu
+ * to trigger shutdown.
+ *
+ * @param menuitem quit item
+ * @param user_data the main loop context
+ */
+void
+GNUNET_GTK_tray_icon_quit (GtkMenuItem *menuitem,
+                          gpointer user_data)
+{
+  /* struct GNUNET_GTK_MainLoop *ml = user_data; */
+  GNUNET_SCHEDULER_shutdown ();
+}
+
+
+/**
  * We got a right-click on the tray icon. Display the context
  * menu (which should have a 'quit' button).
  */
 static int
 tray_icon_on_menu (GtkWidget * widget, GdkEvent * event, gpointer user_data)
 {
+  struct GNUNET_GTK_MainLoop *ml = user_data;
   GtkMenu *tray_menu;
   GdkEventButton *event_button;
   GtkBuilder *builder;
@@ -68,10 +96,11 @@
     event_button = (GdkEventButton *) event;
     if (event_button->button == 3)
     {
-      builder = GNUNET_GTK_get_new_builder 
("gnunet_gtk_status_bar_menu.glade", NULL);
+      builder = GNUNET_GTK_get_new_builder 
("gnunet_gtk_status_bar_menu.glade", ml);
       tray_menu =
           GTK_MENU (gtk_builder_get_object
                     (builder, "GNUNET_GTK_status_bar_popup_menu"));
+      g_object_ref (tray_menu);
       gtk_menu_popup (tray_menu, NULL, NULL, NULL, NULL, event_button->button,
                       event_button->time);
       g_object_unref (builder);
@@ -84,12 +113,14 @@
 /**
  * Create our tray icon.
  *
+ * @param ml main loop
  * @param main handle to the main window (show or hide)
  * @param icon_name name of the tray icon file
  * @param tooltip tooltip for the tray icon
  */
 void
-GNUNET_GTK_tray_icon_create (GtkWindow * main, const char *icon_name,
+GNUNET_GTK_tray_icon_create (struct GNUNET_GTK_MainLoop *ml,
+                            GtkWindow * main, const char *icon_name,
                              const char *tooltip)
 {
   if (NULL != tray_icon)
@@ -100,9 +131,9 @@
   main_window = main;
   tray_icon = gtk_status_icon_new ();
   g_signal_connect (G_OBJECT (tray_icon), "activate",
-                    G_CALLBACK (tray_icon_on_click), NULL);
+                    G_CALLBACK (tray_icon_on_click), ml);
   g_signal_connect (G_OBJECT (tray_icon), "button_press_event",
-                    G_CALLBACK (tray_icon_on_menu), tray_icon);
+                    G_CALLBACK (tray_icon_on_menu), ml);
   gtk_status_icon_set_from_icon_name (tray_icon, icon_name);
   gtk_status_icon_set_tooltip_text (tray_icon, tooltip);
   gtk_status_icon_set_visible (tray_icon, TRUE);

Modified: gnunet-gtk/src/peerinfo/gnunet-peerinfo-gtk.c
===================================================================
--- gnunet-gtk/src/peerinfo/gnunet-peerinfo-gtk.c       2012-11-10 19:13:54 UTC 
(rev 24888)
+++ gnunet-gtk/src/peerinfo/gnunet-peerinfo-gtk.c       2012-11-10 20:07:04 UTC 
(rev 24889)
@@ -213,6 +213,9 @@
 static void
 shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
+  GNUNET_GTK_tray_icon_destroy ();
+  GNUNET_GTK_main_loop_quit (ml);
+  ml = NULL;
   if (NULL != pnc)
   {
     GNUNET_PEERINFO_notify_cancel (pnc);
@@ -436,9 +439,7 @@
 void
 GNUNET_PEERINFO_GTK_quit_cb (GObject * object, gpointer user_data)
 {
-  GNUNET_GTK_tray_icon_destroy ();
-  GNUNET_GTK_main_loop_quit (ml);
-  GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
+  GNUNET_SCHEDULER_shutdown ();
 }
 
 
@@ -503,7 +504,8 @@
   ls = GTK_LIST_STORE (get_object ("GNUNET_PEERINFO_GTK_list_store"));
   GNUNET_assert (NULL != ls);
   gtk_window_maximize (GTK_WINDOW (main_window));
-  GNUNET_GTK_tray_icon_create (GTK_WINDOW (main_window),
+  GNUNET_GTK_tray_icon_create (ml,
+                              GTK_WINDOW (main_window),
                                "gnunet-gtk" /* FIXME: different icon? */ ,
                                "gnunet-peerinfo-gtk");
 
@@ -513,6 +515,8 @@
     gtk_widget_show (main_window);
     gtk_window_present (GTK_WINDOW (main_window));
   }
+  GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
+                               &shutdown_task, NULL);
 }
 
 

Modified: gnunet-gtk/src/setup/gnunet-setup.c
===================================================================
--- gnunet-gtk/src/setup/gnunet-setup.c 2012-11-10 19:13:54 UTC (rev 24888)
+++ gnunet-gtk/src/setup/gnunet-setup.c 2012-11-10 20:07:04 UTC (rev 24889)
@@ -396,8 +396,7 @@
 void
 GNUNET_SETUP_quit_cb (GObject * object, gpointer user_data)
 {
-  GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                      &cleanup_task, NULL);
+  GNUNET_SCHEDULER_shutdown ();
 }
 
 
@@ -491,8 +490,7 @@
 static void
 autoconfig_finished_cb (void *cls)
 {
-  GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                     &cleanup_task, NULL);    
+  GNUNET_SCHEDULER_shutdown ();
 }
 
 
@@ -598,6 +596,8 @@
     gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object 
("GNUNET_setup_namestore_vbox")));
   }
 #endif
+  GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
+                               &cleanup_task, NULL);
   if (do_autoconfig)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,

Modified: gnunet-gtk/src/statistics/gnunet-statistics-gtk.c
===================================================================
--- gnunet-gtk/src/statistics/gnunet-statistics-gtk.c   2012-11-10 19:13:54 UTC 
(rev 24888)
+++ gnunet-gtk/src/statistics/gnunet-statistics-gtk.c   2012-11-10 20:07:04 UTC 
(rev 24889)
@@ -208,34 +208,26 @@
 static void
 shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
+  GNUNET_GTK_tray_icon_destroy ();
+  GNUNET_GTK_main_loop_quit (ml);
+  ml = NULL;
   GNUNET_STATISTICS_destroy (statistics, GNUNET_NO);
   statistics = NULL;
-}
-
-
-/**
- * Callback invoked if the application is supposed to exit.
- */
-void
-GNUNET_STATISTICS_GTK_quit_cb (GObject * object, gpointer user_data)
-{
-  GNUNET_GTK_tray_icon_destroy ();
-  GNUNET_GTK_main_loop_quit (ml);
   if (connection_task != GNUNET_SCHEDULER_NO_TASK)
   {
     GNUNET_SCHEDULER_cancel (connection_task);
     connection_task = GNUNET_SCHEDULER_NO_TASK;
   }
-  GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
 }
 
+
 /**
- * Callback invoked if the application is supposed to exit from the tray.
+ * Callback invoked if the application is supposed to exit.
  */
 void
-GNUNET_GTK_quit_cb (GObject * object, gpointer user_data)
+GNUNET_STATISTICS_GTK_quit_cb (GObject * object, gpointer user_data)
 {
-  GNUNET_STATISTICS_GTK_quit_cb (object, user_data);
+  GNUNET_SCHEDULER_shutdown ();
 }
 
 
@@ -270,7 +262,8 @@
   /* setup main window */
   main_window = GTK_WIDGET (get_object ("GNUNET_STATISTICS_GTK_main_window"));
   gtk_window_maximize (GTK_WINDOW (main_window));
-  GNUNET_GTK_tray_icon_create (GTK_WINDOW (main_window),
+  GNUNET_GTK_tray_icon_create (ml,
+                              GTK_WINDOW (main_window),
                                "gnunet-gtk" /* FIXME: different icon? */ ,
                                "gnunet-statistics-gtk");
 
@@ -284,6 +277,8 @@
     gtk_widget_show (main_window);
     gtk_window_present (GTK_WINDOW (main_window));
   }
+  GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
+                               &shutdown_task, NULL);
 }
 
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]