Show app instance name in about:version

This commit is contained in:
Christian Dywan 2012-03-18 14:14:09 +01:00
parent 7e64370a8e
commit 5aa526d106
3 changed files with 26 additions and 19 deletions

View file

@ -68,9 +68,6 @@ struct _MidoriApp
{
GObject parent_instance;
MidoriBrowser* browser;
gchar* name;
MidoriWebSettings* settings;
KatzeArray* bookmarks;
KatzeArray* trash;
@ -80,6 +77,7 @@ struct _MidoriApp
KatzeArray* extensions;
KatzeArray* browsers;
MidoriBrowser* browser;
MidoriAppInstance instance;
#if !HAVE_HILDON || !HAVE_LIBNOTIFY
@ -87,6 +85,8 @@ struct _MidoriApp
#endif
};
static gchar* app_name = NULL;
struct _MidoriAppClass
{
GObjectClass parent_class;
@ -718,29 +718,30 @@ midori_app_create_instance (MidoriApp* app)
GIOChannel* channel;
#endif
if (!app->name)
if (!(display = gdk_display_get_default ()))
return MidoriAppInstanceNull;
{
#if HAVE_UNIQUE
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);
katze_assign (app_name, g_strconcat ("midori", "_", name_hash, NULL));
g_free (name_hash);
g_object_notify (G_OBJECT (app), "name");
#else
app->name = g_strdup (PACKAGE_NAME);
katze_assign (app_name, g_strdup (PACKAGE_NAME));
#endif
}
if (!(display = gdk_display_get_default ()))
return MidoriAppInstanceNull;
display_name = g_strdup (gdk_display_get_name (display));
n = strlen (display_name);
for (i = 0; i < n; i++)
if (strchr (":.\\/", display_name[i]))
display_name[i] = '_';
instance_name = g_strdup_printf ("de.twotoasts.%s_%s", app->name, display_name);
instance_name = g_strdup_printf ("de.twotoasts.%s_%s", app_name, display_name);
g_free (display_name);
katze_assign (app_name, instance_name);
#if HAVE_UNIQUE
instance = unique_app_new (instance_name, NULL);
@ -758,14 +759,16 @@ midori_app_create_instance (MidoriApp* app)
(GIOFunc)midori_app_io_channel_watch_cb, app);
}
#endif
g_free (instance_name);
g_free (display_name);
#endif
return instance;
}
const gchar*
midori_app_get_name (MidoriApp* app)
{
return app_name;
}
static void
midori_app_init (MidoriApp* app)
{
@ -793,7 +796,7 @@ midori_app_finalize (GObject* object)
{
MidoriApp* app = MIDORI_APP (object);
katze_assign (app->name, NULL);
katze_assign (app_name, NULL);
katze_object_assign (app->settings, NULL);
katze_object_assign (app->bookmarks, NULL);
katze_object_assign (app->trash, NULL);
@ -833,7 +836,7 @@ midori_app_set_property (GObject* object,
switch (prop_id)
{
case PROP_NAME:
katze_assign (app->name, g_value_dup_string (value));
katze_assign (app_name, g_value_dup_string (value));
break;
case PROP_SETTINGS:
katze_object_assign (app->settings, g_value_dup_object (value));
@ -873,7 +876,7 @@ midori_app_get_property (GObject* object,
switch (prop_id)
{
case PROP_NAME:
g_value_set_string (value, app->name);
g_value_set_string (value, app_name);
break;
case PROP_SETTINGS:
g_value_set_object (value, app->settings);

View file

@ -41,6 +41,9 @@ midori_app_get_type (void) G_GNUC_CONST;
MidoriApp*
midori_app_new (void);
const gchar*
midori_app_get_name (MidoriApp* app);
gboolean
midori_app_instance_is_running (MidoriApp* app);

View file

@ -13,6 +13,7 @@
#include "midori-view.h"
#include "midori-browser.h"
#include "midori-searchaction.h"
#include "midori-app.h"
#include "midori-platform.h"
#include "midori-core.h"
#include "midori-findbar.h"
@ -4142,7 +4143,7 @@ midori_view_set_uri (MidoriView* view,
"style=\"position: absolute; right: 15px; bottom: 15px; z-index: -9;\">"
"<table>"
"<tr><td>Command&nbsp;line</td><td>%s</td></tr>"
"<tr><td>Midori</td><td>%s</td></tr>"
"<tr><td>Midori</td><td>%s (%s)</td></tr>"
"<tr><td>WebKitGTK+</td><td>%d.%d.%d (%d.%d.%d)</td></tr>"
"<tr><td>GTK+</td><td>%d.%d.%d (%d.%d.%d)</td></tr>"
"<tr><td>Glib</td><td>%d.%d.%d (%d.%d.%d)</td></tr>"
@ -4159,7 +4160,7 @@ midori_view_set_uri (MidoriView* view,
"</body></html>",
_("Version numbers in brackets show the version used at runtime."),
command_line,
PACKAGE_VERSION,
PACKAGE_VERSION, midori_app_get_name (NULL),
WEBKIT_MAJOR_VERSION, WEBKIT_MINOR_VERSION, WEBKIT_MICRO_VERSION,
webkit_major_version (),
webkit_minor_version (),