[file-roller] replace WindowList with gtk_application_get_windows



commit f4f31f1c9e897fe32114d2ef1b21e232231c3a3b
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Thu May 31 20:24:39 2012 +0200

    replace WindowList with gtk_application_get_windows

 src/fr-init.c   |    1 -
 src/fr-init.h   |    1 -
 src/fr-window.c |   10 +++-------
 src/main.c      |   52 +++++++++++++++++++++++++++++++---------------------
 4 files changed, 34 insertions(+), 30 deletions(-)
---
diff --git a/src/fr-init.c b/src/fr-init.c
index 9692759..7e02582 100644
--- a/src/fr-init.c
+++ b/src/fr-init.c
@@ -161,7 +161,6 @@ FrExtensionType file_ext_type[] = {
 };
 
 
-GList        *WindowList;
 GList        *CommandList;
 gint          ForceDirectoryCreation;
 GHashTable   *ProgramsCache;
diff --git a/src/fr-init.h b/src/fr-init.h
index 1e31d54..2639e70 100644
--- a/src/fr-init.h
+++ b/src/fr-init.h
@@ -43,7 +43,6 @@ typedef struct {
 	char      *temp_dir;
 } CommandData;
 
-extern GList                 *WindowList;
 extern GList                 *CommandList;
 extern gint                   ForceDirectoryCreation;
 extern GHashTable            *ProgramsCache;
diff --git a/src/fr-window.c b/src/fr-window.c
index 6f80b5b..c28482b 100644
--- a/src/fr-window.c
+++ b/src/fr-window.c
@@ -647,11 +647,7 @@ fr_window_finalize (GObject *object)
 		window->priv = NULL;
 	}
 
-	WindowList = g_list_remove (WindowList, window);
-
-	G_OBJECT_CLASS (parent_class)->finalize (object);
-
-	if (WindowList == NULL) {
+	if (gtk_application_get_windows (GTK_APPLICATION (g_application_get_default ())) == NULL) {
 		if (pixbuf_hash != NULL) {
 			g_hash_table_foreach (pixbuf_hash,
 					      gh_unref_pixbuf,
@@ -667,6 +663,8 @@ fr_window_finalize (GObject *object)
 			tree_pixbuf_hash = NULL;
 		}
 	}
+
+	G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
 
@@ -806,8 +804,6 @@ fr_window_init (FrWindow *window)
 			  "unrealize",
 			  G_CALLBACK (fr_window_unrealized),
 			  NULL);
-
-	WindowList = g_list_prepend (WindowList, window);
 }
 
 
diff --git a/src/main.c b/src/main.c
index b49b4d9..c5c4837 100644
--- a/src/main.c
+++ b/src/main.c
@@ -30,7 +30,6 @@
 #include "eggsmclient.h"
 #include "fr-init.h"
 
-GList        *WindowList = NULL;
 gint          ForceDirectoryCreation;
 
 static char **remaining_args;
@@ -241,9 +240,11 @@ activate_cb (GApplication *application)
 {
 	GList *link;
 
-	for (link = WindowList; link; link = link->next) {
-		FrWindow *window = link->data;
-		gtk_widget_show (GTK_WIDGET (window));
+	for (link = gtk_application_get_windows (GTK_APPLICATION (application));
+	     link != NULL;
+	     link = link->next)
+	{
+		gtk_widget_show (GTK_WIDGET (link->data));
 	}
 }
 
@@ -253,9 +254,9 @@ fr_save_state (EggSMClient *client, GKeyFile *state, gpointer user_data)
 {
 	/* discard command is automatically set by EggSMClient */
 
-	GList *window;
-	const char *argv[2] = { NULL };
-	guint i;
+	const char   *argv[2] = { NULL };
+	GApplication *application;
+	guint         i;
 
 	/* restart command */
 	argv[0] = program_argv0;
@@ -264,21 +265,30 @@ fr_save_state (EggSMClient *client, GKeyFile *state, gpointer user_data)
 	egg_sm_client_set_restart_command (client, 1, argv);
 
 	/* state */
-	for (window = WindowList, i = 0; window; window = window->next, i++) {
-		FrWindow *session = window->data;
-		gchar *key;
-
-		key = g_strdup_printf ("archive%d", i);
-		if ((session->archive == NULL) || (session->archive->file == NULL)) {
-			g_key_file_set_string (state, "Session", key, "");
-		} else {
-			gchar *uri;
-
-			uri = g_file_get_uri (session->archive->file);
-			g_key_file_set_string (state, "Session", key, uri);
-			g_free (uri);
+	application = g_application_get_default ();
+	if (application != NULL) {
+		GList *window;
+
+		for (window = gtk_application_get_windows (GTK_APPLICATION (application)), i = 0;
+		     window != NULL;
+		     window = window->next, i++)
+		{
+			FrWindow *session = window->data;
+			gchar *key;
+
+			key = g_strdup_printf ("archive%d", i);
+			if ((session->archive == NULL) || (session->archive->file == NULL)) {
+				g_key_file_set_string (state, "Session", key, "");
+			}
+			else {
+				gchar *uri;
+
+				uri = g_file_get_uri (session->archive->file);
+				g_key_file_set_string (state, "Session", key, uri);
+				g_free (uri);
+			}
+			g_free (key);
 		}
-		g_free (key);
 	}
 
 	g_key_file_set_integer (state, "Session", "archives", i);



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