From 2f82dde7ca1c76ffd665120ea5576c46c353b6f1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sun, 20 Dec 2009 17:04:29 -0600 Subject: Adding the icon_path property to the code. --- src/libappindicator/app-indicator.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/libappindicator/app-indicator.c') diff --git a/src/libappindicator/app-indicator.c b/src/libappindicator/app-indicator.c index bb68cb2..536de59 100644 --- a/src/libappindicator/app-indicator.c +++ b/src/libappindicator/app-indicator.c @@ -63,6 +63,7 @@ struct _AppIndicatorPrivate { AppIndicatorStatus status; gchar *icon_name; gchar *attention_icon_name; + gchar * icon_path; DbusmenuServer *menuservice; GtkWidget *menu; @@ -91,6 +92,7 @@ enum { PROP_STATUS, PROP_ICON_NAME, PROP_ATTENTION_ICON_NAME, + PROP_ICON_PATH, PROP_MENU, PROP_CONNECTED }; @@ -101,6 +103,7 @@ enum { #define PROP_STATUS_S "status" #define PROP_ICON_NAME_S "icon-name" #define PROP_ATTENTION_ICON_NAME_S "attention-icon-name" +#define PROP_ICON_PATH_S "icon-path" #define PROP_MENU_S "menu" #define PROP_CONNECTED_S "connected" @@ -179,6 +182,14 @@ app_indicator_class_init (AppIndicatorClass *klass) NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property(object_class, + PROP_ICON_PATH, + g_param_spec_string (PROP_ICON_PATH_S, + "An additional path for custom icons.", + "An additional place to look for icon names that may be installed by the application.", + NULL, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property(object_class, PROP_MENU, g_param_spec_string (PROP_MENU_S, @@ -277,6 +288,7 @@ app_indicator_init (AppIndicator *self) priv->status = APP_INDICATOR_STATUS_PASSIVE; priv->icon_name = NULL; priv->attention_icon_name = NULL; + priv->icon_path = NULL; priv->menu = NULL; priv->menuservice = NULL; @@ -355,6 +367,11 @@ app_indicator_finalize (GObject *object) priv->attention_icon_name = NULL; } + if (priv->icon_path != NULL) { + g_free(priv->icon_path); + priv->icon_path = NULL; + } + G_OBJECT_CLASS (app_indicator_parent_class)->finalize (object); return; } @@ -423,6 +440,13 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu g_value_get_string (value)); break; + case PROP_ICON_PATH: + if (icon_path != NULL) { + g_free(icon_path); + } + priv->icon_path = g_value_dup_string(value); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -462,6 +486,10 @@ app_indicator_get_property (GObject * object, guint prop_id, GValue * value, GPa g_value_set_string (value, priv->attention_icon_name); break; + case PROP_ICON_PATH: + g_value_set_string (value, priv->icon_path); + break; + case PROP_MENU: if (G_VALUE_HOLDS_STRING(value)) { if (priv->menuservice != NULL) { -- cgit v1.2.3 From c44c00bdd91e0e5bf3010b0a7ac511b60c443370 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sun, 20 Dec 2009 17:11:23 -0600 Subject: Making the icon-path property construct only and making a constructor to set it. --- src/libappindicator/app-indicator.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'src/libappindicator/app-indicator.c') diff --git a/src/libappindicator/app-indicator.c b/src/libappindicator/app-indicator.c index 536de59..1756687 100644 --- a/src/libappindicator/app-indicator.c +++ b/src/libappindicator/app-indicator.c @@ -183,12 +183,12 @@ app_indicator_class_init (AppIndicatorClass *klass) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property(object_class, - PROP_ICON_PATH, + PROP_ICON_PATH, g_param_spec_string (PROP_ICON_PATH_S, "An additional path for custom icons.", "An additional place to look for icon names that may be installed by the application.", NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property(object_class, PROP_MENU, @@ -600,6 +600,36 @@ app_indicator_new (const gchar *id, return indicator; } +/** + app_indicator_new_with_path: + @id: The unique id of the indicator to create. + @icon_name: The icon name for this indicator + @category: The category of indicator. + @icon_path: A custom path for finding icons. + + Creates a new #AppIndicator setting the properties: + #AppIndicator::id with @id, #AppIndicator::category + with @category, #AppIndicator::icon-name with + @icon_name and #AppIndicator::icon-path with @icon_path. + + Return value: A pointer to a new #AppIndicator object. + */ +AppIndicator * +app_indicator_new_with_path (const gchar *id, + const gchar *icon_name, + AppIndicatorCategory category, + const gchar *icon_path) +{ + AppIndicator *indicator = g_object_new (APP_INDICATOR_TYPE, + "id", id, + "category", category_from_enum (category), + "icon-name", icon_name, + "icon-path", icon_path, + NULL); + + return indicator; +} + /** app_indicator_get_type: -- cgit v1.2.3 From b3542e0f35267b102155566710c4da5a025db975 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sun, 20 Dec 2009 17:13:23 -0600 Subject: Forgot to get these from the private struct. --- src/libappindicator/app-indicator.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/libappindicator/app-indicator.c') diff --git a/src/libappindicator/app-indicator.c b/src/libappindicator/app-indicator.c index 1756687..d22161c 100644 --- a/src/libappindicator/app-indicator.c +++ b/src/libappindicator/app-indicator.c @@ -441,8 +441,8 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu break; case PROP_ICON_PATH: - if (icon_path != NULL) { - g_free(icon_path); + if (priv->icon_path != NULL) { + g_free(priv->icon_path); } priv->icon_path = g_value_dup_string(value); break; -- cgit v1.2.3 From 83b4f68c5a188d3826beefbe2adddecc0f0a4668 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 8 Jan 2010 08:04:07 -0600 Subject: Changing the property to 'IconThemePath' to make it more clear about what it adjusts. --- src/libappindicator/app-indicator.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/libappindicator/app-indicator.c') diff --git a/src/libappindicator/app-indicator.c b/src/libappindicator/app-indicator.c index d22161c..f9a7c88 100644 --- a/src/libappindicator/app-indicator.c +++ b/src/libappindicator/app-indicator.c @@ -92,7 +92,7 @@ enum { PROP_STATUS, PROP_ICON_NAME, PROP_ATTENTION_ICON_NAME, - PROP_ICON_PATH, + PROP_ICON_THEME_PATH, PROP_MENU, PROP_CONNECTED }; @@ -103,7 +103,7 @@ enum { #define PROP_STATUS_S "status" #define PROP_ICON_NAME_S "icon-name" #define PROP_ATTENTION_ICON_NAME_S "attention-icon-name" -#define PROP_ICON_PATH_S "icon-path" +#define PROP_ICON_THEME_PATH_S "icon-theme-path" #define PROP_MENU_S "menu" #define PROP_CONNECTED_S "connected" @@ -183,8 +183,8 @@ app_indicator_class_init (AppIndicatorClass *klass) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property(object_class, - PROP_ICON_PATH, - g_param_spec_string (PROP_ICON_PATH_S, + PROP_ICON_THEME_PATH, + g_param_spec_string (PROP_ICON_THEME_PATH_S, "An additional path for custom icons.", "An additional place to look for icon names that may be installed by the application.", NULL, @@ -440,7 +440,7 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu g_value_get_string (value)); break; - case PROP_ICON_PATH: + case PROP_ICON_THEME_PATH: if (priv->icon_path != NULL) { g_free(priv->icon_path); } @@ -486,7 +486,7 @@ app_indicator_get_property (GObject * object, guint prop_id, GValue * value, GPa g_value_set_string (value, priv->attention_icon_name); break; - case PROP_ICON_PATH: + case PROP_ICON_THEME_PATH: g_value_set_string (value, priv->icon_path); break; @@ -610,7 +610,7 @@ app_indicator_new (const gchar *id, Creates a new #AppIndicator setting the properties: #AppIndicator::id with @id, #AppIndicator::category with @category, #AppIndicator::icon-name with - @icon_name and #AppIndicator::icon-path with @icon_path. + @icon_name and #AppIndicator::icon-theme-path with @icon_path. Return value: A pointer to a new #AppIndicator object. */ @@ -624,7 +624,7 @@ app_indicator_new_with_path (const gchar *id, "id", id, "category", category_from_enum (category), "icon-name", icon_name, - "icon-path", icon_path, + "icon-theme-path", icon_path, NULL); return indicator; -- cgit v1.2.3 From 8226d6c8f8870be9d2902fcd2137b242f2559da8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 8 Jan 2010 08:07:24 -0600 Subject: Using the #defines for the property names instead of strings. Define them once. --- src/libappindicator/app-indicator.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/libappindicator/app-indicator.c') diff --git a/src/libappindicator/app-indicator.c b/src/libappindicator/app-indicator.c index f9a7c88..739a7e6 100644 --- a/src/libappindicator/app-indicator.c +++ b/src/libappindicator/app-indicator.c @@ -592,9 +592,9 @@ app_indicator_new (const gchar *id, AppIndicatorCategory category) { AppIndicator *indicator = g_object_new (APP_INDICATOR_TYPE, - "id", id, - "category", category_from_enum (category), - "icon-name", icon_name, + PROP_ID_S, id, + PROP_CATEGORY_S, category_from_enum (category), + PROP_ICON_NAME_S, icon_name, NULL); return indicator; @@ -621,10 +621,10 @@ app_indicator_new_with_path (const gchar *id, const gchar *icon_path) { AppIndicator *indicator = g_object_new (APP_INDICATOR_TYPE, - "id", id, - "category", category_from_enum (category), - "icon-name", icon_name, - "icon-theme-path", icon_path, + PROP_ID_S, id, + PROP_CATEGORY_S, category_from_enum (category), + PROP_ICON_NAME_S, icon_name, + PROP_ICON_THEME_PATH_S, icon_path, NULL); return indicator; -- cgit v1.2.3