Move naming logic into initialization of MidoriApp

This commit is contained in:
Christian Dywan 2011-11-08 22:09:49 +01:00
parent 4e30586f4c
commit 58066e7dcc
2 changed files with 13 additions and 20 deletions

View file

@ -2308,17 +2308,6 @@ main (int argc,
g_error ("--inactivity-reset is currently only supported with --app."); g_error ("--inactivity-reset is currently only supported with --app.");
sokoke_set_config_dir (config); 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 (); app = midori_app_new ();
katze_assign (config, (gchar*)sokoke_set_config_dir (NULL)); katze_assign (config, (gchar*)sokoke_set_config_dir (NULL));
midori_startup_timer ("App created: \t%f"); midori_startup_timer ("App created: \t%f");

View file

@ -674,8 +674,7 @@ midori_app_io_channel_watch_cb (GIOChannel* channel,
#endif #endif
static MidoriAppInstance static MidoriAppInstance
midori_app_create_instance (MidoriApp* app, midori_app_create_instance (MidoriApp* app)
const gchar* name)
{ {
MidoriAppInstance instance; MidoriAppInstance instance;
@ -711,8 +710,15 @@ midori_app_create_instance (MidoriApp* app,
GIOChannel* channel; GIOChannel* channel;
#endif #endif
if (!name) if (!app->name)
name = "midori"; {
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 ())) if (!(display = gdk_display_get_default ()))
return MidoriAppInstanceNull; return MidoriAppInstanceNull;
@ -723,7 +729,7 @@ midori_app_create_instance (MidoriApp* app,
if (display_name[i] == ':' || display_name[i] == '.' if (display_name[i] == ':' || display_name[i] == '.'
|| 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 #if HAVE_UNIQUE
instance = unique_app_new (instance_name, NULL); instance = unique_app_new (instance_name, NULL);
@ -900,8 +906,6 @@ midori_app_get_property (GObject* object,
* *
* Instantiates a new #MidoriApp singleton. * Instantiates a new #MidoriApp singleton.
* *
* Subsequent calls will ref the initial instance.
*
* Return value: a new #MidoriApp * Return value: a new #MidoriApp
**/ **/
MidoriApp* MidoriApp*
@ -931,7 +935,7 @@ midori_app_instance_is_running (MidoriApp* app)
g_return_val_if_fail (MIDORI_IS_APP (app), FALSE); g_return_val_if_fail (MIDORI_IS_APP (app), FALSE);
if (app->instance == MidoriAppInstanceNull) if (app->instance == MidoriAppInstanceNull)
app->instance = midori_app_create_instance (app, app->name); app->instance = midori_app_create_instance (app);
#if HAVE_HILDON #if HAVE_HILDON
/* FIXME: Determine if application is running already */ /* 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 * Saves the argument vector, initializes threading and registers
* several custom stock items and prepares localization. * several custom stock items and prepares localization.