[gthumb] load the initial location only after calling the 'gth-browser-construct-idle-callback' hook



commit 180340f9ab5b880970f15ce11a62f8701ff6b560
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Tue Oct 25 15:40:50 2011 +0200

    load the initial location only after calling the 'gth-browser-construct-idle-callback' hook

 gthumb/gth-browser-actions-callbacks.c |    6 ++----
 gthumb/gth-browser.c                   |   28 ++++++++++++++++------------
 gthumb/gth-browser.h                   |    2 +-
 gthumb/main.c                          |    9 +++------
 4 files changed, 22 insertions(+), 23 deletions(-)
---
diff --git a/gthumb/gth-browser-actions-callbacks.c b/gthumb/gth-browser-actions-callbacks.c
index c126add..d216c65 100644
--- a/gthumb/gth-browser-actions-callbacks.c
+++ b/gthumb/gth-browser-actions-callbacks.c
@@ -103,8 +103,7 @@ gth_browser_activate_action_file_new_window (GtkAction  *action,
 {
 	GtkWidget *window;
 
-	window = gth_browser_new (NULL);
-	gth_browser_go_to (GTH_BROWSER (window), gth_browser_get_location (browser), NULL);
+	window = gth_browser_new (gth_browser_get_location (browser));
 	gtk_window_present (GTK_WINDOW (window));
 }
 
@@ -296,9 +295,8 @@ gth_browser_activate_action_folder_open_in_new_window (GtkAction  *action,
 	if (file_data == NULL)
 		return;
 
-	new_browser = gth_browser_new (NULL);
+	new_browser = gth_browser_new (file_data->file);
 	gtk_window_present (GTK_WINDOW (new_browser));
-	gth_browser_load_location (GTH_BROWSER (new_browser), file_data->file);
 
 	g_object_unref (file_data);
 }
diff --git a/gthumb/gth-browser.c b/gthumb/gth-browser.c
index e9c2ab9..3b615de 100644
--- a/gthumb/gth-browser.c
+++ b/gthumb/gth-browser.c
@@ -126,6 +126,7 @@ struct _GthBrowserPrivateData {
 
 	/* Browser data */
 
+	GFile             *first_location;
 	guint              help_message_cid;
 	gulong             folder_changed_id;
 	gulong             file_renamed_id;
@@ -2505,6 +2506,7 @@ gth_browser_finalize (GObject *object)
 	GthBrowser *browser = GTH_BROWSER (object);
 
 	if (browser->priv != NULL) {
+		_g_object_unref (browser->priv->first_location);
 		g_free (browser->priv->location_free_space);
 		_g_object_unref (browser->priv->location_source);
 		_g_object_unref (browser->priv->monitor_location);
@@ -3704,6 +3706,8 @@ _gth_browser_construct_step2 (gpointer data)
 	gth_hook_invoke ("gth-browser-construct-idle-callback", browser);
 	_gth_browser_monitor_entry_points (browser);
 	gtk_widget_grab_focus (gth_browser_get_file_list_view (browser));
+
+	gth_browser_go_to (browser, browser->priv->first_location, NULL);
 }
 
 
@@ -4092,7 +4096,8 @@ _gth_browser_unrealize (GtkWidget *browser,
 
 
 static void
-_gth_browser_construct (GthBrowser *browser)
+_gth_browser_construct (GthBrowser *browser,
+			GFile      *location)
 {
 	GError         *error = NULL;
 	GtkWidget      *vbox;
@@ -4103,6 +4108,11 @@ _gth_browser_construct (GthBrowser *browser)
 	char           *caption;
 	int             i;
 
+	if (location != NULL)
+		browser->priv->first_location = g_object_ref (location);
+	else
+		browser->priv->first_location = g_file_new_for_uri (gth_pref_get_startup_location ());
+
 	{
 		int width;
 		int height;
@@ -4591,22 +4601,16 @@ _gth_browser_construct (GthBrowser *browser)
 
 
 GtkWidget *
-gth_browser_new (const char *uri)
+gth_browser_new (GFile *location)
 {
 	GthBrowser *browser;
 
-	browser = (GthBrowser*) g_object_new (GTH_TYPE_BROWSER, "n-pages", GTH_BROWSER_N_PAGES, NULL);
-	_gth_browser_construct (browser);
+	browser = (GthBrowser*) g_object_new (GTH_TYPE_BROWSER,
+					      "n-pages", GTH_BROWSER_N_PAGES,
+					      NULL);
+	_gth_browser_construct (browser, location);
 	browser_list = g_list_prepend (browser_list, browser);
 
-	if (uri != NULL) {
-		GFile *location;
-
-		location = g_file_new_for_uri ((uri != NULL) ? uri : gth_pref_get_startup_location ());
-		gth_browser_go_to (browser, location, NULL);
-		g_object_unref (location);
-	}
-
 	return (GtkWidget*) browser;
 }
 
diff --git a/gthumb/gth-browser.h b/gthumb/gth-browser.h
index f1ad5e0..c937b4c 100644
--- a/gthumb/gth-browser.h
+++ b/gthumb/gth-browser.h
@@ -76,7 +76,7 @@ struct _GthBrowserClass
 };
 
 GType            gth_browser_get_type               (void);
-GtkWidget *      gth_browser_new                    (const char       *uri);
+GtkWidget *      gth_browser_new                    (GFile            *location);
 GFile *          gth_browser_get_location           (GthBrowser       *browser);
 GthFileData *    gth_browser_get_location_data      (GthBrowser       *browser);
 GthFileData *    gth_browser_get_current_file       (GthBrowser       *browser);
diff --git a/gthumb/main.c b/gthumb/main.c
index f843387..dcf7fe4 100644
--- a/gthumb/main.c
+++ b/gthumb/main.c
@@ -239,13 +239,11 @@ gth_restore_session (EggSMClient *client)
 
 		g_assert (location != NULL);
 
-		window = gth_browser_new (NULL);
+		file = g_file_new_for_uri (location);
+		window = gth_browser_new (file);
 		gtk_window_set_application (GTK_WINDOW (window), gthumb_application);
 		gtk_widget_show (window);
 
-		file = g_file_new_for_uri (location);
-		gth_browser_load_location (GTH_BROWSER (window), file);
-
 		g_object_unref (file);
 		g_free (location);
 	}
@@ -278,11 +276,10 @@ open_browser_window (GFile *location,
 {
 	GtkWidget *window;
 
-	window = gth_browser_new (NULL);
+	window = gth_browser_new (location);
 	gtk_window_set_application (GTK_WINDOW (window), gthumb_application);
 	if (! StartSlideshow)
 		gtk_window_present (GTK_WINDOW (window));
-	gth_browser_load_location (GTH_BROWSER (window), location);
 }
 
 



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