From a89fe2cf130a13d8eebe14c0344071c0fd7641c5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sat, 28 Jan 2012 20:48:50 -0600 Subject: Adding get/set title functions --- src/app-indicator.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index f885cc7..17d6261 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -2126,6 +2126,30 @@ app_indicator_set_secondary_activate_target (AppIndicator *self, GtkWidget *menu g_signal_connect(menuitem, "parent-set", G_CALLBACK(sec_activate_target_parent_changed), self); } +/** + * app_indicator_set_title: + * @self: The #AppIndicator + * @title: (allow-none): Title of the app indicator + * + * Sets the title of the application indicator, or how it should be referred + * in a human readable form. This string should be UTF-8 and localized as it + * expected that users will set it. + * + * In the Unity desktop the most prominate place that this is show will be + * in the HUD. HUD listings for this application indicator will start with + * the title as the first part of the line for the menu items. + * + * Setting @title to %NULL removes the title. + */ +void +app_indicator_set_title (AppIndicator *self, const gchar * title) +{ + g_return_if_fail (IS_APP_INDICATOR (self)); + + + return; +} + /** * app_indicator_get_id: * @self: The #AppIndicator object to use @@ -2254,6 +2278,24 @@ app_indicator_get_attention_icon_desc (AppIndicator *self) return self->priv->att_accessible_desc; } +/** + * app_indicator_get_title: + * @self: The #AppIndicator object to use + * + * Gets the title of the application indicator. See the function + * app_indicator_set_title() for information on the title. + * + * Return value: The current title. + */ +const gchar * +app_indicator_get_title (AppIndicator *self) +{ + g_return_val_if_fail (IS_APP_INDICATOR (self), NULL); + + return NULL; +} + + /** * app_indicator_get_menu: * @self: The #AppIndicator object to use -- cgit v1.2.3 From fb6509958adc6b571ea7c067507a2d269cbae539 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sat, 28 Jan 2012 20:57:06 -0600 Subject: Adding a title entry to the private structure --- src/app-indicator.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index 17d6261..f1caf82 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -78,6 +78,7 @@ struct _AppIndicatorPrivate { GtkWidget *sec_activate_target; gboolean sec_activate_enabled; guint32 ordering_index; + gchar * title; gchar * label; gchar * label_guide; gchar * accessible_desc; @@ -575,6 +576,7 @@ app_indicator_init (AppIndicator *self) priv->menu = NULL; priv->menuservice = NULL; priv->ordering_index = 0; + priv->title = NULL; priv->label = NULL; priv->label_guide = NULL; priv->label_change_idle = 0; @@ -716,6 +718,11 @@ app_indicator_finalize (GObject *object) priv->icon_theme_path = NULL; } + if (priv->title != NULL) { + g_free(priv->title); + priv->title = NULL; + } + if (priv->label != NULL) { g_free(priv->label); priv->label = NULL; -- cgit v1.2.3 From 3c1556cb30938195c6646d203f949912d7af5c4e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sat, 28 Jan 2012 21:10:32 -0600 Subject: Adding the title property --- src/app-indicator.c | 47 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index f1caf82..f29d08e 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -128,7 +128,8 @@ enum { PROP_LABEL, PROP_LABEL_GUIDE, PROP_ORDERING_INDEX, - PROP_DBUS_MENU_SERVER + PROP_DBUS_MENU_SERVER, + PROP_TITLE }; /* The strings so that they can be slowly looked up. */ @@ -145,6 +146,7 @@ enum { #define PROP_LABEL_GUIDE_S "label-guide" #define PROP_ORDERING_INDEX_S "ordering-index" #define PROP_DBUS_MENU_SERVER_S "dbus-menu-server" +#define PROP_TITLE_S "title" /* Private macro, shhhh! */ #define APP_INDICATOR_GET_PRIVATE(o) \ @@ -252,7 +254,7 @@ app_indicator_class_init (AppIndicatorClass *klass) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY)); /** - * AppIndicator: + * AppIndicator:status: * * Whether the indicator is shown or requests attention. Defaults to * 'Passive'. @@ -411,6 +413,21 @@ app_indicator_class_init (AppIndicatorClass *klass) "DBusmenu server which is available for testing the application indicators.", DBUSMENU_TYPE_SERVER, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + /** + * AppIndicator:title: + * + * Provides a way to refer to this application indicator in a human + * readable form. This is used in the Unity desktop in the HUD as + * the first part of the menu entries to distinguish them from the + * focused application's entries. + */ + g_object_class_install_property(object_class, + PROP_TITLE, + g_param_spec_string (PROP_TITLE_S, + "Title of the application indicator", + "A human readable way to refer to this application indicator in the UI.", + NULL, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); /* Signals */ @@ -837,20 +854,38 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu gchar * oldlabel = priv->label; priv->label = g_value_dup_string(value); - if (g_strcmp0(oldlabel, priv->label) != 0) { - signal_label_change(APP_INDICATOR(object)); - } - if (priv->label != NULL && priv->label[0] == '\0') { g_free(priv->label); priv->label = NULL; } + if (g_strcmp0(oldlabel, priv->label) != 0) { + signal_label_change(APP_INDICATOR(object)); + } + if (oldlabel != NULL) { g_free(oldlabel); } break; } + case PROP_TITLE: { + gchar * oldtitle = priv->title; + priv->title = g_value_dup_string(value); + + if (priv->title != NULL && priv->title[0] == '\0') { + g_free(priv->title); + priv->title = NULL; + } + + if (g_strcmp0(oldtitle, priv->title) != 0) { + // signal_title_change(APP_INDICATOR(object)); + } + + if (oldtitle != NULL) { + g_free(oldtitle); + } + break; + } case PROP_LABEL_GUIDE: { gchar * oldguide = priv->label_guide; priv->label_guide = g_value_dup_string(value); -- cgit v1.2.3 From 3aa66a7c29f62a0d862ad04f9d61d61bee9a23ef Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sat, 28 Jan 2012 21:22:14 -0600 Subject: Support the title property over dbus and emitting the dbus signal when it changes --- src/app-indicator.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index f29d08e..bb44e50 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -878,7 +878,20 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu } if (g_strcmp0(oldtitle, priv->title) != 0) { - // signal_title_change(APP_INDICATOR(object)); + GError * error = NULL; + + g_dbus_connection_emit_signal(self->priv->connection, + NULL, + self->priv->path, + NOTIFICATION_ITEM_DBUS_IFACE, + "NewTitle", + NULL, + &error); + + if (error != NULL) { + g_warning("Unable to send signal for NewTitle: %s", error->message); + g_error_free(error); + } } if (oldtitle != NULL) { @@ -1104,6 +1117,8 @@ bus_get_prop (GDBusConnection * connection, const gchar * sender, const gchar * return g_variant_new_string(priv->icon_name ? priv->icon_name : ""); } else if (g_strcmp0(property, "AttentionIconName") == 0) { return g_variant_new_string(priv->attention_icon_name ? priv->attention_icon_name : ""); + } else if (g_strcmp0(property, "Title") == 0) { + return g_variant_new_string(priv->title ? priv->title : ""); } else if (g_strcmp0(property, "IconThemePath") == 0) { return g_variant_new_string(priv->icon_theme_path ? priv->icon_theme_path : ""); } else if (g_strcmp0(property, "Menu") == 0) { -- cgit v1.2.3 From f12cf320a0d665e2c304b4415aac3cedfaf559a1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sat, 28 Jan 2012 21:36:19 -0600 Subject: Make the set function call the property set function --- src/app-indicator.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index bb44e50..0d27cb2 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -2203,6 +2203,9 @@ app_indicator_set_title (AppIndicator *self, const gchar * title) { g_return_if_fail (IS_APP_INDICATOR (self)); + g_object_set(G_OBJECT(self), + PROP_TITLE_S, title == NULL ? "": title, + NULL); return; } -- cgit v1.2.3 From dcbd590c7c1a61560c9dfa2636a467e7e2332c6d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sat, 28 Jan 2012 21:45:02 -0600 Subject: Only signal to dbus if we're connected --- src/app-indicator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index 0d27cb2..54a2b6a 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -877,7 +877,7 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu priv->title = NULL; } - if (g_strcmp0(oldtitle, priv->title) != 0) { + if (g_strcmp0(oldtitle, priv->title) != 0 && self->priv->connection != NULL) { GError * error = NULL; g_dbus_connection_emit_signal(self->priv->connection, -- cgit v1.2.3 From 97d2b40745a0049fcf0be430ab9715c9e050bc3b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sat, 28 Jan 2012 21:45:34 -0600 Subject: Making get_title work --- src/app-indicator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index 54a2b6a..f3f8b9d 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -2352,7 +2352,7 @@ app_indicator_get_title (AppIndicator *self) { g_return_val_if_fail (IS_APP_INDICATOR (self), NULL); - return NULL; + return self->priv->title; } -- cgit v1.2.3 From 982de618938bc5f9bc1224492970ccb06bc3a00a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sat, 28 Jan 2012 21:46:45 -0600 Subject: Handling getting the title property --- src/app-indicator.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index f3f8b9d..6b4110c 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -1011,6 +1011,10 @@ app_indicator_get_property (GObject * object, guint prop_id, GValue * value, GPa g_value_set_object(value, priv->menuservice); break; + case PROP_TITLE: + g_value_set_string(value, priv->title); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; -- cgit v1.2.3 From f0e992803d3e05c69da1202f1c73cedcb50c8445 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 30 Jan 2012 22:51:10 -0600 Subject: Fix type in comment --- src/app-indicator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index 6b4110c..6c693e8 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -2196,7 +2196,7 @@ app_indicator_set_secondary_activate_target (AppIndicator *self, GtkWidget *menu * in a human readable form. This string should be UTF-8 and localized as it * expected that users will set it. * - * In the Unity desktop the most prominate place that this is show will be + * In the Unity desktop the most prominent place that this is show will be * in the HUD. HUD listings for this application indicator will start with * the title as the first part of the line for the menu items. * -- cgit v1.2.3