From 58066e7dcc021ee2962cb9b2d9a319ea7122b8ab Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Tue, 8 Nov 2011 22:09:49 +0100 Subject: [PATCH] Move naming logic into initialization of MidoriApp --- midori/main.c | 11 ----------- midori/midori-app.c | 22 +++++++++++++--------- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/midori/main.c b/midori/main.c index 90b8e9a7..8b722977 100644 --- a/midori/main.c +++ b/midori/main.c @@ -2308,17 +2308,6 @@ main (int argc, g_error ("--inactivity-reset is currently only supported with --app."); sokoke_set_config_dir (config); - if (config) - { - gchar* name_hash; - gchar* app_name; - name_hash = g_compute_checksum_for_string (G_CHECKSUM_MD5, config, -1); - app_name = g_strconcat ("midori", "_", name_hash, NULL); - g_free (name_hash); - app = g_object_new (MIDORI_TYPE_APP, "name", app_name, NULL); - g_free (app_name); - } - else app = midori_app_new (); katze_assign (config, (gchar*)sokoke_set_config_dir (NULL)); midori_startup_timer ("App created: \t%f"); diff --git a/midori/midori-app.c b/midori/midori-app.c index 772c13f1..483dda89 100644 --- a/midori/midori-app.c +++ b/midori/midori-app.c @@ -674,8 +674,7 @@ midori_app_io_channel_watch_cb (GIOChannel* channel, #endif static MidoriAppInstance -midori_app_create_instance (MidoriApp* app, - const gchar* name) +midori_app_create_instance (MidoriApp* app) { MidoriAppInstance instance; @@ -711,8 +710,15 @@ midori_app_create_instance (MidoriApp* app, GIOChannel* channel; #endif - if (!name) - name = "midori"; + if (!app->name) + { + const gchar* config = sokoke_set_config_dir (NULL); + gchar* name_hash; + name_hash = g_compute_checksum_for_string (G_CHECKSUM_MD5, config, -1); + app->name = g_strconcat ("midori", "_", name_hash, NULL); + g_free (name_hash); + g_object_notify (G_OBJECT (app), "name"); + } if (!(display = gdk_display_get_default ())) return MidoriAppInstanceNull; @@ -723,7 +729,7 @@ midori_app_create_instance (MidoriApp* app, if (display_name[i] == ':' || display_name[i] == '.' || display_name[i] == '\\') display_name[i] = '_'; - instance_name = g_strdup_printf ("de.twotoasts.%s_%s", name, display_name); + instance_name = g_strdup_printf ("de.twotoasts.%s_%s", app->name, display_name); #if HAVE_UNIQUE instance = unique_app_new (instance_name, NULL); @@ -900,8 +906,6 @@ midori_app_get_property (GObject* object, * * Instantiates a new #MidoriApp singleton. * - * Subsequent calls will ref the initial instance. - * * Return value: a new #MidoriApp **/ MidoriApp* @@ -931,7 +935,7 @@ midori_app_instance_is_running (MidoriApp* app) g_return_val_if_fail (MIDORI_IS_APP (app), FALSE); if (app->instance == MidoriAppInstanceNull) - app->instance = midori_app_create_instance (app, app->name); + app->instance = midori_app_create_instance (app); #if HAVE_HILDON /* FIXME: Determine if application is running already */ @@ -1284,7 +1288,7 @@ midori_app_send_notification (MidoriApp* app, } /** - * midori_app_init: + * midori_app_setup: * * Saves the argument vector, initializes threading and registers * several custom stock items and prepares localization. -- 2.39.5