Commits

jjacky committed 22f6f1a

single-click on systray icon will hide/show all opened windows (except kalu's updater)

Also fixed a memory leak when tried to show news but parsing failed.

Comments (0)

Files changed (5)

 void set_kalpm_nb (check_t type, gint nb);
 void set_kalpm_nb_syncdbs (gint nb);
 
+void add_open_window (gpointer window);
+void remove_open_window (gpointer window);
+
 #endif /* _KALU_H */
     gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, button, activate_time);
 }
 
+static GPtrArray *open_windows = NULL;
+
+void
+add_open_window (gpointer window)
+{
+    if (!open_windows)
+    {
+        open_windows = g_ptr_array_new ();
+    }
+    g_ptr_array_add (open_windows, window);
+}
+
+void
+remove_open_window (gpointer window)
+{
+    g_ptr_array_remove (open_windows, window);
+}
+
 static guint icon_press_timeout = 0;
 
 static gboolean
 {
     icon_press_timeout = 0;
     
-    /* do something... */
+    static gboolean is_minimized = FALSE;
+    g_ptr_array_foreach (open_windows,
+                         (GFunc) ((is_minimized) ? gtk_widget_show : gtk_widget_hide),
+                         NULL);
+    is_minimized = !is_minimized;
     
     return FALSE;
 }
     }
     notify_uninit ();
     free_config ();
+    if (open_windows)
+    {
+        g_ptr_array_free (open_windows, TRUE);
+    }
     return 0;
 }
 
     alpm_list_t **lists;
     int i;
     
-    /* will be present of this was a only_updates window */
+    /* will be present if this was a only_updates window */
     lists = g_object_get_data (G_OBJECT (window), "lists");
     if (lists)
     {
         /* this was holding the pointers, free it */
         free (lists);
     }
+    
+    /* remove from list of open windows */
+    remove_open_window (window);
 }
 
 static void
     gtk_window_set_has_resize_grip (GTK_WINDOW (*window), FALSE);
     g_signal_connect (G_OBJECT (*window), "destroy",
                       G_CALLBACK (window_destroy_cb), NULL);
+    /* add to list of open windows */
+    add_open_window (window);
     /* icon */
     GdkPixbuf *pixbuf;
     pixbuf = gtk_widget_render_icon_pixbuf (*window, "kalu-logo", GTK_ICON_SIZE_DIALOG);
             free (xml_news);
         }
         g_propagate_error (error, local_err);
+        gtk_widget_destroy (window);
         set_kalpm_busy (FALSE);
         return FALSE;
     }
     free (fallback_templates.tpl_aur->sep);
     free (fallback_templates.tpl_aur);
     
+    /* remove from list of open windows */
+    remove_open_window (window);
+    
     window = NULL;
 }
 
     gtk_window_set_title (GTK_WINDOW (window), "Preferences - kalu");
     gtk_container_set_border_width (GTK_CONTAINER (window), 2);
     gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
+    /* add to list of open windows */
+    add_open_window (window);
     /* icon */
     GdkPixbuf *pixbuf;
     pixbuf = gtk_widget_render_icon_pixbuf (window, "kalu-logo", GTK_ICON_SIZE_DIALOG);
     
     /* signals */
     g_signal_connect (G_OBJECT (window), "destroy",
-                     G_CALLBACK (destroy_cb), NULL);
+                      G_CALLBACK (destroy_cb), NULL);
     
     /* enforce (minimum) size */
     gint w, h;
 
 static struct _watched_t watched = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
 
-static GtkWidget * watched_new_window (w_type_t type);
+static GtkWidget *watched_new_window (w_type_t type);
 static void manage_load_watched (gboolean is_aur);
 
 
 }
 
 static void
-window_destroy_cb (GtkWidget *widget _UNUSED_, w_type_t type)
+window_destroy_cb (GtkWidget *window, w_type_t type)
 {
     GtkTreeModel *model;
     GtkTreeIter iter;
             watched.tree_manage_aur = NULL;
             break;
     }
+    
+    /* remove from list of open windows */
+    remove_open_window (window);
 }
 
 static void
     }
     gtk_container_set_border_width (GTK_CONTAINER (window), 0);
     gtk_window_set_has_resize_grip (GTK_WINDOW (window), FALSE);
+    /* add to list of open windows */
+    add_open_window (window);
     /* icon */
     GdkPixbuf *pixbuf;
     pixbuf = gtk_widget_render_icon_pixbuf (window, "kalu-logo", GTK_ICON_SIZE_DIALOG);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.