Hiroyuki Ikezoe
ikezo****@users*****
Tue Jan 23 20:50:34 JST 2007
Index: kazehakase/src/kz-app.c diff -u kazehakase/src/kz-app.c:1.24 kazehakase/src/kz-app.c:1.25 --- kazehakase/src/kz-app.c:1.24 Mon Jan 22 12:57:31 2007 +++ kazehakase/src/kz-app.c Tue Jan 23 20:50:33 2007 @@ -38,6 +38,7 @@ #include <fcntl.h> #endif /* HAVE_LIBSM */ +#include <glib/gi18n.h> #include "kazehakase.h" #include "kz-app.h" #include "kz-actions-tab.h" @@ -49,9 +50,17 @@ #include "glib-utils.h" #include "utils.h" +enum { + PROP_0, + PROP_ARGC, + PROP_ARGV +}; + typedef struct _KzAppPrivate KzAppPrivate; struct _KzAppPrivate { + gint argc; + gchar **argv; GList *window_list; KzFavicon *favicon; KzSearch *search; @@ -73,6 +82,14 @@ guint n_props, GObjectConstructParam *props); static void dispose (GObject *object); +static void set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static void get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); static void cb_destroy_window (GtkObject *object, gpointer data); @@ -92,9 +109,28 @@ kz_app_parent_class = g_type_class_peek_parent(klass); object_class = (GObjectClass *) klass; - object_class->constructor = constructor; - object_class->dispose = dispose; + object_class->constructor = constructor; + object_class->dispose = dispose; + object_class->set_property = set_property; + object_class->get_property = get_property; + g_object_class_install_property( + object_class, + PROP_ARGC, + g_param_spec_int( + "argc", + _("Argument number"), + _("The number of argument of program"), + 0, G_MAXINT, + 0, + G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY)); + g_object_class_install_property( + object_class, + PROP_ARGV, + g_param_spec_pointer ("argv", + _("Argument list"), + _("The argument list of program"), + G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY)); g_type_class_add_private(object_class, sizeof(KzAppPrivate)); } @@ -109,6 +145,12 @@ { GObjectClass *klass = G_OBJECT_CLASS(kz_app_parent_class); object = klass->constructor(type, n_props, props); + +#ifdef HAVE_LIBSM + /* session management */ + connect_sm(KZ_APP(object)); +#endif /* HAVE_LIBSM */ + the_kzapp = KZ_APP(object); } else @@ -119,6 +161,52 @@ } static void +set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + KzAppPrivate *priv = KZ_APP_GET_PRIVATE(object); + + switch (prop_id) + { + case PROP_ARGC: + priv->argc = g_value_get_int(value); + break; + case PROP_ARGV: + priv->argv = g_strdupv(g_value_get_pointer(value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + + +static void +get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + KzAppPrivate *priv = KZ_APP_GET_PRIVATE(object); + + switch (prop_id) + { + case PROP_ARGC: + g_value_set_int(value, priv->argc); + break; + case PROP_ARGV: + g_value_set_pointer(value, priv->argv); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + + +static void prepare_dir (void) { /* for thumbnails */ @@ -254,11 +342,6 @@ priv->migemo = kz_migemo_new(); #endif -#ifdef HAVE_LIBSM - /* session management */ - connect_sm(app); -#endif /* HAVE_LIBSM */ - g_free(sysconf_file); g_free(conf_file); g_free(bookmark_file); @@ -336,6 +419,9 @@ if (priv->favicon) g_object_unref(priv->favicon); + if (priv->argv) + g_strfreev(priv->argv); + #ifdef USE_SSL gnutls_global_deinit(); #endif @@ -352,11 +438,12 @@ SmcCloseConnection ((SmcConn) priv->smc_conn, 0, NULL); #endif /* HAVE_LIBSM */ - priv->profile = NULL; - priv->proxy = NULL; - priv->bookmarks = NULL; - priv->search = NULL; - priv->favicon = NULL; + priv->profile = NULL; + priv->proxy = NULL; + priv->bookmarks = NULL; + priv->search = NULL; + priv->favicon = NULL; + priv->argv = NULL; if (G_OBJECT_CLASS (kz_app_parent_class)->dispose) G_OBJECT_CLASS (kz_app_parent_class)->dispose(object); @@ -364,9 +451,12 @@ KzApp * -kz_app_new (void) +kz_app_new (gint argc, gchar **argv) { - KzApp *kzapp = g_object_new(KZ_TYPE_APP, NULL); + KzApp *kzapp = g_object_new(KZ_TYPE_APP, + "argc", argc, + "argv", argv, + NULL); return kzapp; } @@ -796,6 +886,26 @@ } static void +session_set_clone_command (KzApp *app) +{ + SmPropValue *vals; + gint i; + KzAppPrivate *priv = KZ_APP_GET_PRIVATE(app); + + vals = g_new(SmPropValue, priv->argc); + + for (i = 0; i < priv->argc; i++) + { + vals[i].length = strlen(priv->argv[i]); + vals[i].value = priv->argv[i]; + } + session_set_value(priv->smc_conn, SmCloneCommand, SmLISTofARRAY8, i, vals); + session_set_value(priv->smc_conn, SmRestartCommand, SmLISTofARRAY8, i, vals); + + g_free(vals); +} + +static void connect_sm (KzApp *app) { SmcCallbacks callbacks; @@ -854,33 +964,8 @@ session_set_gchar(priv->smc_conn, SmRestartStyleHint, (gchar) SmRestartIfRunning); session_set_string(priv->smc_conn, SmProgram, g_get_prgname()); -#if 0 -{ - GList *list; - gint argc; - gchar *ptr; - gint i = 0; - - SmPropValue *vals; - - ptr="/home/zoe/kazehakase/src/kazehakase"; - - if (!ptr) - return; - argc = 1; - - vals = g_new (SmPropValue, argc); - - ptr="/home/zoe/kazehakase/src/kazehakase"; - - vals[i].length = strlen(ptr); - vals[i++].value = ptr; - session_set_value(priv->smc_conn, SmCloneCommand, SmLISTofARRAY8, i, vals); - - g_free (vals); -} -#endif + session_set_clone_command(app); g_free(session_id); } } Index: kazehakase/src/kz-app.h diff -u kazehakase/src/kz-app.h:1.7 kazehakase/src/kz-app.h:1.8 --- kazehakase/src/kz-app.h:1.7 Thu Jan 4 11:47:51 2007 +++ kazehakase/src/kz-app.h Tue Jan 23 20:50:33 2007 @@ -53,7 +53,7 @@ GType kz_app_get_type (void) G_GNUC_CONST; -KzApp *kz_app_new (void); +KzApp *kz_app_new (gint argc, gchar **argv); GtkWidget *kz_app_create_new_window (KzApp *app, const gchar *uri); Index: kazehakase/src/main.c diff -u kazehakase/src/main.c:1.135 kazehakase/src/main.c:1.136 --- kazehakase/src/main.c:1.135 Mon Jan 15 09:16:36 2007 +++ kazehakase/src/main.c Tue Jan 23 20:50:33 2007 @@ -471,7 +471,7 @@ return 0; /* found kazehakase process */ } - kz_app = kz_app_new(); + kz_app = kz_app_new(argc, argv); #warning FIXME! Initializaton of mozilla should be called somewhere else. mozilla_init(KZ_GET_GLOBAL_PROFILE);