[nautilus-actions] Define new BaseApplication properties
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Define new BaseApplication properties
- Date: Fri, 21 Jan 2011 18:47:58 +0000 (UTC)
commit a40249a8b6a76deba7703f348fbb05833be46f8a
Author: Pierre Wieser <pwieser trychlos org>
Date: Fri Jan 21 01:24:26 2011 +0100
Define new BaseApplication properties
+ application_name
+ icon_name
+ unique_app_name
ChangeLog | 3 +
src/nact/base-application.c | 143 ++++++++++++++++++++++++++++++++-----------
src/nact/base-application.h | 36 ++++++------
src/nact/nact-application.c | 6 +-
4 files changed, 131 insertions(+), 57 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 0796ff4..13fdc9e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2011-01-20 Pierre Wieser <pwieser trychlos org>
+ * src/nact/base-application.c:
+ * src/nact/base-application.h: Define new properties.
+
* src/nact/base-application-class.h: Removed file.
* src/nact/Makefile.am:
diff --git a/src/nact/base-application.c b/src/nact/base-application.c
index a77eb9a..da3b62c 100644
--- a/src/nact/base-application.c
+++ b/src/nact/base-application.c
@@ -51,9 +51,15 @@ struct _BaseApplicationClassPrivate {
*/
struct _BaseApplicationPrivate {
gboolean dispose_has_run;
+
+ /* properties
+ */
int argc;
- gpointer argv;
+ GStrv argv;
GOptionEntry *options;
+ gchar *application_name;
+ gchar *icon_name;
+ gchar *unique_app_name;
gboolean is_gtk_initialized;
UniqueApp *unique_app_handle;
@@ -68,16 +74,23 @@ struct _BaseApplicationPrivate {
/* instance properties
*/
enum {
- BASE_APPLICATION_PROP_ARGC_ID = 1,
- BASE_APPLICATION_PROP_ARGV_ID,
- BASE_APPLICATION_PROP_OPTIONS_ID,
+ BASE_PROP_0,
+
+ BASE_PROP_ARGC_ID,
+ BASE_PROP_ARGV_ID,
+ BASE_PROP_OPTIONS_ID,
+ BASE_PROP_APPLICATION_NAME_ID,
+ BASE_PROP_ICON_NAME_ID,
+ BASE_PROP_UNIQUE_APP_NAME_ID,
BASE_APPLICATION_PROP_IS_GTK_INITIALIZED_ID,
BASE_APPLICATION_PROP_UNIQUE_APP_HANDLE_ID,
BASE_APPLICATION_PROP_EXIT_CODE_ID,
BASE_APPLICATION_PROP_EXIT_MESSAGE1_ID,
BASE_APPLICATION_PROP_EXIT_MESSAGE2_ID,
BASE_APPLICATION_PROP_BUILDER_ID,
- BASE_APPLICATION_PROP_MAIN_WINDOW_ID
+ BASE_APPLICATION_PROP_MAIN_WINDOW_ID,
+
+ BASE_PROP_N_PROPERTIES
};
static GObjectClass *st_parent_class = NULL;
@@ -186,26 +199,52 @@ class_init( BaseApplicationClass *klass )
object_class->get_property = instance_get_property;
object_class->set_property = instance_set_property;
- spec = g_param_spec_int(
- BASE_APPLICATION_PROP_ARGC,
- "Command-line arguments count",
- "Command-line arguments count", 0, 65535, 0,
- G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
- g_object_class_install_property( object_class, BASE_APPLICATION_PROP_ARGC_ID, spec );
-
- spec = g_param_spec_pointer(
- BASE_APPLICATION_PROP_ARGV,
- "Command-line arguments",
- "A pointer to command-line arguments",
- G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
- g_object_class_install_property( object_class, BASE_APPLICATION_PROP_ARGV_ID, spec );
-
- spec = g_param_spec_pointer(
- BASE_APPLICATION_PROP_OPTIONS,
- "Command-line options",
- "A pointer to command-line options",
- G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
- g_object_class_install_property( object_class, BASE_APPLICATION_PROP_OPTIONS_ID, spec );
+ g_object_class_install_property( object_class, BASE_PROP_ARGC_ID,
+ g_param_spec_int(
+ BASE_PROP_ARGC,
+ _( "Arguments count" ),
+ _( "The count of command-line arguments" ),
+ 0, 65535, 0,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE ));
+
+ g_object_class_install_property( object_class, BASE_PROP_ARGV_ID,
+ g_param_spec_boxed(
+ BASE_PROP_ARGV,
+ _( "Arguments" ),
+ _( "The array of command-line arguments" ),
+ G_TYPE_STRV,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE ));
+
+ g_object_class_install_property( object_class, BASE_PROP_OPTIONS_ID,
+ g_param_spec_pointer(
+ BASE_PROP_OPTIONS,
+ _( "Option entries" ),
+ _( "The array of command-line option definitions" ),
+ G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE ));
+
+ g_object_class_install_property( object_class, BASE_PROP_APPLICATION_NAME_ID,
+ g_param_spec_string(
+ BASE_PROP_APPLICATION_NAME,
+ _( "Application name" ),
+ _( "The name of the application" ),
+ "",
+ G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE ));
+
+ g_object_class_install_property( object_class, BASE_PROP_ICON_NAME_ID,
+ g_param_spec_string(
+ BASE_PROP_ICON_NAME,
+ _( "Icon name" ),
+ _( "The name of the icon of the application" ),
+ "",
+ G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE ));
+
+ g_object_class_install_property( object_class, BASE_PROP_UNIQUE_APP_NAME_ID,
+ g_param_spec_string(
+ BASE_PROP_UNIQUE_APP_NAME,
+ _( "UniqueApp name" ),
+ _( "The Unique name of the application" ),
+ "",
+ G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE ));
spec = g_param_spec_boolean(
BASE_APPLICATION_PROP_IS_GTK_INITIALIZED,
@@ -308,18 +347,30 @@ instance_get_property( GObject *object, guint property_id, GValue *value, GParam
if( !self->private->dispose_has_run ){
switch( property_id ){
- case BASE_APPLICATION_PROP_ARGC_ID:
+ case BASE_PROP_ARGC_ID:
g_value_set_int( value, self->private->argc );
break;
- case BASE_APPLICATION_PROP_ARGV_ID:
- g_value_set_pointer( value, self->private->argv );
+ case BASE_PROP_ARGV_ID:
+ g_value_set_boxed( value, self->private->argv );
break;
- case BASE_APPLICATION_PROP_OPTIONS_ID:
+ case BASE_PROP_OPTIONS_ID:
g_value_set_pointer( value, self->private->options );
break;
+ case BASE_PROP_APPLICATION_NAME_ID:
+ g_value_set_string( value, self->private->application_name );
+ break;
+
+ case BASE_PROP_ICON_NAME_ID:
+ g_value_set_string( value, self->private->icon_name );
+ break;
+
+ case BASE_PROP_UNIQUE_APP_NAME_ID:
+ g_value_set_string( value, self->private->unique_app_name );
+ break;
+
case BASE_APPLICATION_PROP_IS_GTK_INITIALIZED_ID:
g_value_set_boolean( value, self->private->is_gtk_initialized );
break;
@@ -366,18 +417,34 @@ instance_set_property( GObject *object, guint property_id, const GValue *value,
if( !self->private->dispose_has_run ){
switch( property_id ){
- case BASE_APPLICATION_PROP_ARGC_ID:
+ case BASE_PROP_ARGC_ID:
self->private->argc = g_value_get_int( value );
break;
- case BASE_APPLICATION_PROP_ARGV_ID:
- self->private->argv = g_value_get_pointer( value );
+ case BASE_PROP_ARGV_ID:
+ g_boxed_free( G_TYPE_STRV, self->private->argv );
+ self->private->argv = g_value_dup_boxed( value );
break;
- case BASE_APPLICATION_PROP_OPTIONS_ID:
+ case BASE_PROP_OPTIONS_ID:
self->private->options = g_value_get_pointer( value );
break;
+ case BASE_PROP_APPLICATION_NAME_ID:
+ g_free( self->private->application_name );
+ self->private->application_name = g_value_dup_string( value );
+ break;
+
+ case BASE_PROP_ICON_NAME_ID:
+ g_free( self->private->icon_name );
+ self->private->icon_name = g_value_dup_string( value );
+ break;
+
+ case BASE_PROP_UNIQUE_APP_NAME_ID:
+ g_free( self->private->unique_app_name );
+ self->private->unique_app_name = g_value_dup_string( value );
+ break;
+
case BASE_APPLICATION_PROP_IS_GTK_INITIALIZED_ID:
self->private->is_gtk_initialized = g_value_get_boolean( value );
break;
@@ -462,6 +529,10 @@ instance_finalize( GObject *application )
self = BASE_APPLICATION( application );
+ g_free( self->private->application_name );
+ g_free( self->private->icon_name );
+ g_free( self->private->unique_app_name );
+
g_free( self->private->exit_message1 );
g_free( self->private->exit_message2 );
@@ -975,9 +1046,9 @@ application_do_initialize_gtk( BaseApplication *application )
g_debug( "%s: application=%p", thisfn, ( void * ) application );
g_object_get( G_OBJECT( application ),
- BASE_APPLICATION_PROP_ARGC, &argc,
- BASE_APPLICATION_PROP_ARGV, &argv,
- BASE_APPLICATION_PROP_OPTIONS, &options,
+ BASE_PROP_ARGC, &argc,
+ BASE_PROP_ARGV, &argv,
+ BASE_PROP_OPTIONS, &options,
NULL );
if( options ){
diff --git a/src/nact/base-application.h b/src/nact/base-application.h
index 14a004a..e0508da 100644
--- a/src/nact/base-application.h
+++ b/src/nact/base-application.h
@@ -405,6 +405,24 @@ typedef struct {
}
BaseApplicationClass;
+/**
+ * Properties defined by the BaseApplication class.
+ * They should be provided at object instantiation time.
+ *
+ * @BASE_PROP_ARGC: count of arguments in command-line.
+ * @BASE_PROP_ARGV: array of command-line arguments.
+ * @BASE_PROP_OPTIONS: array of command-line options descriptions.
+ * @BASE_PROP_APPLICATION_NAME: application name.
+ * @BASE_PROP_ICON_NAME: icon name.
+ * @BASE_PROP_UNIQUE_APP_NAME: unique name of the application (if apply)
+ */
+#define BASE_PROP_ARGC "base-application-argc"
+#define BASE_PROP_ARGV "base-application-argv"
+#define BASE_PROP_OPTIONS "base-application-options"
+#define BASE_PROP_APPLICATION_NAME "base-application-name"
+#define BASE_PROP_ICON_NAME "base-application-icon-name"
+#define BASE_PROP_UNIQUE_APP_NAME "base-application-unique-app-name"
+
enum {
BASE_APPLICATION_ERROR_I18N = 1, /* i18n initialization error */
BASE_APPLICATION_ERROR_GTK, /* gtk+ initialization error */
@@ -416,24 +434,6 @@ enum {
};
/**
- * @BASE_APPLICATION_PROP_ARGC: count of arguments in command-line.
- * @BASE_APPLICATION_PROP_ARGV: list of command-line arguments
- *
- * These two variables must be provided before running the
- * initialization process ; they are required in order to correctly
- * initialize the Gtk+ user interface.
- */
-#define BASE_APPLICATION_PROP_ARGC "base-application-argc"
-#define BASE_APPLICATION_PROP_ARGV "base-application-argv"
-
-/**
- * @BASE_APPLICATION_PROP_OPTIONS: command-line options.
- *
- * Can be provided at instanciation time only.
- */
-#define BASE_APPLICATION_PROP_OPTIONS "base-application-options"
-
-/**
* @BASE_APPLICATION_PROP_IS_GTK_INITIALIZED: set to %TRUE after
* successfully returning from the application_initialize_gtk() virtual
* function.
diff --git a/src/nact/nact-application.c b/src/nact/nact-application.c
index 027151e..bb1d54c 100644
--- a/src/nact/nact-application.c
+++ b/src/nact/nact-application.c
@@ -295,9 +295,9 @@ nact_application_new_with_args( int argc, char **argv )
return(
g_object_new(
NACT_APPLICATION_TYPE,
- BASE_APPLICATION_PROP_ARGC, argc,
- BASE_APPLICATION_PROP_ARGV, argv,
- BASE_APPLICATION_PROP_OPTIONS, st_entries,
+ BASE_PROP_ARGC, argc,
+ BASE_PROP_ARGV, argv,
+ BASE_PROP_OPTIONS, st_entries,
NULL )
);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]