[gthumb/ext] create the main catalog directory at start up time



commit 98c8193bbcbb82a9b62314b14583ff2aad1a29af
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sat Aug 29 13:18:04 2009 +0200

    create the main catalog directory at start up time

 extensions/catalogs/callbacks.c   |    7 +++++++
 extensions/catalogs/callbacks.h   |    1 +
 extensions/catalogs/gth-catalog.c |    1 -
 extensions/catalogs/main.c        |    1 +
 gthumb/gth-main-default-hooks.c   |    7 +++++++
 gthumb/main.c                     |   31 ++++++++++++++++---------------
 6 files changed, 32 insertions(+), 16 deletions(-)
---
diff --git a/extensions/catalogs/callbacks.c b/extensions/catalogs/callbacks.c
index e65e01a..2daec52 100644
--- a/extensions/catalogs/callbacks.c
+++ b/extensions/catalogs/callbacks.c
@@ -126,6 +126,13 @@ browser_data_free (BrowserData *data)
 
 
 void
+catalogs__initialize_cb (void)
+{
+	gth_user_dir_make_dir_for_file (GTH_DIR_DATA, GTHUMB_DIR, "catalogs", "dummy", NULL);
+}
+
+
+void
 catalogs__gth_browser_construct_cb (GthBrowser *browser)
 {
 	BrowserData *data;
diff --git a/extensions/catalogs/callbacks.h b/extensions/catalogs/callbacks.h
index 14bacdf..76a44a4 100644
--- a/extensions/catalogs/callbacks.h
+++ b/extensions/catalogs/callbacks.h
@@ -26,6 +26,7 @@
 #include <gthumb.h>
 #include "gth-catalog.h"
 
+void catalogs__initialize_cb                           (void);
 void catalogs__gth_browser_construct_cb                (GthBrowser    *browser);
 void catalogs__gth_browser_update_sensitivity_cb       (GthBrowser    *browser);
 void catalogs__gth_browser_folder_tree_popup_before_cb (GthBrowser    *browser,
diff --git a/extensions/catalogs/gth-catalog.c b/extensions/catalogs/gth-catalog.c
index 7996745..9610ecf 100644
--- a/extensions/catalogs/gth-catalog.c
+++ b/extensions/catalogs/gth-catalog.c
@@ -542,7 +542,6 @@ gth_catalog_get_base (void)
 	GFile *base;
 
 	catalogs_dir = gth_user_dir_get_file (GTH_DIR_DATA, GTHUMB_DIR, "catalogs", NULL);
-	/*catalogs_dir = g_strdup ("/home/paolo/.gnome2/gthumb/collections");*/
 	base = g_file_new_for_path (catalogs_dir);
 
 	g_free (catalogs_dir);
diff --git a/extensions/catalogs/main.c b/extensions/catalogs/main.c
index 76ca553..af11b1f 100644
--- a/extensions/catalogs/main.c
+++ b/extensions/catalogs/main.c
@@ -43,6 +43,7 @@ gthumb_extension_activate (void)
 	gth_hook_add_callback ("gth-catalog-load-from-data", 10, G_CALLBACK (catalogs__gth_catalog_load_from_data_cb), NULL);
 
 	gth_main_register_file_source (GTH_TYPE_FILE_SOURCE_CATALOGS);
+	gth_hook_add_callback ("initialize", 10, G_CALLBACK (catalogs__initialize_cb), NULL);
 	gth_hook_add_callback ("gth-browser-construct", 10, G_CALLBACK (catalogs__gth_browser_construct_cb), NULL);
 	gth_hook_add_callback ("gth-browser-update-sensitivity", 10, G_CALLBACK (catalogs__gth_browser_update_sensitivity_cb), NULL);
 	gth_hook_add_callback ("gth-browser-folder-tree-popup-before", 10, G_CALLBACK (catalogs__gth_browser_folder_tree_popup_before_cb), NULL);
diff --git a/gthumb/gth-main-default-hooks.c b/gthumb/gth-main-default-hooks.c
index 7d3a73c..b1b8a9a 100644
--- a/gthumb/gth-main-default-hooks.c
+++ b/gthumb/gth-main-default-hooks.c
@@ -33,6 +33,13 @@ gth_main_register_default_hooks (void)
 	gth_hooks_initialize ();
 
 	/**
+	 * Called at start up time to do basic initialization.
+	 *
+	 * no arguments.
+	 **/
+	gth_hook_register ("initialize", 0);
+
+	/**
 	 * Called after the window has been initialized.  Can be used by
 	 * an extension to create and attach specific data to the window.
 	 *
diff --git a/gthumb/main.c b/gthumb/main.c
index d6eb9bc..492245f 100644
--- a/gthumb/main.c
+++ b/gthumb/main.c
@@ -243,21 +243,30 @@ prepare_application (void)
 	const char  *arg;
 	int          i;
 
-	client = egg_sm_client_get ();
-	if (egg_sm_client_is_resumed (client)) {
-		gth_restore_session (client);
-		return;
-	}
-
 	gthumb_app = unique_app_new_with_commands ("org.gnome.gthumb", NULL,
 						   "import-photos", COMMAND_IMPORT_PHOTOS,
 						   NULL);
 
-	if (! unique_app_is_running (gthumb_app))
+	if (! unique_app_is_running (gthumb_app)) {
+		gth_main_register_default_hooks ();
+		gth_main_register_file_source (GTH_TYPE_FILE_SOURCE_VFS);
+		gth_main_register_default_sort_types ();
+		gth_main_register_default_tests ();
+		gth_main_register_default_types ();
+		gth_main_register_default_metadata ();
+		gth_main_activate_extensions ();
+		gth_hook_invoke ("initialize", NULL);
 		g_signal_connect (gthumb_app,
 				  "message-received",
 				  G_CALLBACK (unique_app_message_received_cb),
 				  NULL);
+	}
+
+	client = egg_sm_client_get ();
+	if (egg_sm_client_is_resumed (client)) {
+		gth_restore_session (client);
+		return;
+	}
 
 	if (remaining_args == NULL) { /* No location specified. */
 		GFile *location;
@@ -327,14 +336,6 @@ main (int argc, char *argv[])
 	gth_session_manager_init ();
 	gth_pref_initialize ();
 	gth_main_initialize ();
-	gth_main_register_default_hooks ();
-	gth_main_register_file_source (GTH_TYPE_FILE_SOURCE_VFS);
-	gth_main_register_default_sort_types ();
-	gth_main_register_default_tests ();
-	gth_main_register_default_types ();
-	gth_main_register_default_metadata ();
-	gth_main_activate_extensions ();
-
 	prepare_application ();
 
 	if (! unique_app_is_running (gthumb_app)) {



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