if (run)
return midori_run_script (uris ? *uris : NULL);
- if (config && !g_path_is_absolute (config))
- {
- g_critical (_("The specified configuration folder is invalid."));
- return 1;
- }
- sokoke_set_config_dir (config);
- g_free (config);
-
#if HAVE_HILDON
osso_context = osso_initialize (PACKAGE_NAME, PACKAGE_VERSION, FALSE, NULL);
}
#endif
- app = midori_app_new ();
+ if (config && !g_path_is_absolute (config))
+ {
+ g_critical (_("The specified configuration folder is invalid."));
+ return 1;
+ }
+ 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 ();
+ g_free (config);
+
/* FIXME: The app might be 'running' but actually showing a dialog
after a crash, so running a new window isn't a good idea. */
if (midori_app_instance_is_running (app))
MidoriBrowser* browser;
GtkAccelGroup* accel_group;
+ gchar* name;
MidoriWebSettings* settings;
KatzeArray* bookmarks;
KatzeArray* trash;
{
PROP_0,
+ PROP_NAME,
PROP_SETTINGS,
PROP_BOOKMARKS,
PROP_TRASH,
class->add_browser = _midori_app_add_browser;
class->quit = _midori_app_quit;
+ /**
+ * MidoriApp:name:
+ *
+ * The name of the instance.
+ *
+ * Since: 0.1.6
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_NAME,
+ g_param_spec_string (
+ "name",
+ "Name",
+ "The name of the instance",
+ "midori",
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
g_object_class_install_property (gobject_class,
PROP_SETTINGS,
g_param_spec_object (
}
#endif
-static void
-midori_app_init (MidoriApp* app)
+static gpointer
+midori_app_create_instance (MidoriApp* app,
+ const gchar* name)
{
#if HAVE_UNIQUE
+ gpointer instance;
GdkDisplay* display;
gchar* display_name;
gchar* instance_name;
guint i, n;
#endif
- app->accel_group = gtk_accel_group_new ();
-
- app->settings = NULL;
- app->bookmarks = NULL;
- app->trash = NULL;
- app->search_engines = NULL;
- app->history = NULL;
- app->extensions = NULL;
- app->browsers = katze_array_new (MIDORI_TYPE_BROWSER);
+ if (!name)
+ name = "midori";
#if HAVE_UNIQUE
if (!(display = gdk_display_get_default ()))
- {
- app->instance = NULL;
- return;
- }
+ return NULL;
display_name = g_strdup (gdk_display_get_name (display));
n = strlen (display_name);
for (i = 0; i < n; i++)
if (display_name[i] == ':' || display_name[i] == '.')
display_name[i] = '_';
- instance_name = g_strdup_printf ("de.twotoasts.midori_%s", display_name);
- app->instance = unique_app_new (instance_name, NULL);
+ instance_name = g_strdup_printf ("de.twotoasts.%s_%s", name, display_name);
+ instance = unique_app_new (instance_name, NULL);
g_free (instance_name);
g_free (display_name);
- g_signal_connect (app->instance, "message-received",
+ g_signal_connect (instance, "message-received",
G_CALLBACK (midori_browser_message_received_cb), app);
+ return instance;
#else
- app->instance = NULL;
+ return NULL;
#endif
}
+static void
+midori_app_init (MidoriApp* app)
+{
+ app->accel_group = gtk_accel_group_new ();
+
+ app->settings = NULL;
+ app->bookmarks = NULL;
+ app->trash = NULL;
+ app->search_engines = NULL;
+ app->history = NULL;
+ app->extensions = NULL;
+ app->browsers = katze_array_new (MIDORI_TYPE_BROWSER);
+
+ app->instance = NULL;
+}
+
static void
midori_app_finalize (GObject* object)
{
g_object_unref (app->accel_group);
+ katze_assign (app->name, NULL);
katze_object_assign (app->settings, NULL);
katze_object_assign (app->bookmarks, NULL);
katze_object_assign (app->trash, NULL);
switch (prop_id)
{
+ case PROP_NAME:
+ katze_assign (app->name, g_value_dup_string (value));
+ break;
case PROP_SETTINGS:
katze_object_assign (app->settings, g_value_dup_object (value));
/* FIXME: Propagate settings to all browsers */
switch (prop_id)
{
+ case PROP_NAME:
+ g_value_set_string (value, app->name);
+ break;
case PROP_SETTINGS:
g_value_set_object (value, app->settings);
break;
* Determines whether an instance of Midori is
* already running on the default display.
*
+ * Use the "name" property if you want to run more
+ * than one instance.
+ *
* If Midori was built without single instance support
* this function will always return %FALSE.
*
g_return_val_if_fail (MIDORI_IS_APP (app), FALSE);
#if HAVE_UNIQUE
+ if (!app->instance)
+ app->instance = midori_app_create_instance (app, app->name);
if (app->instance)
return unique_app_is_running (app->instance);
#endif