From 456347aada2b1a3466efe6b27bb8ab3541b77f96 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 3 Aug 2010 11:47:45 -0500 Subject: Adding the label property and a signal for it changing. --- src/dbus-properties-client.h | 2 +- src/notification-item.xml | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/dbus-properties-client.h b/src/dbus-properties-client.h index dc9f299..6f08e78 100644 --- a/src/dbus-properties-client.h +++ b/src/dbus-properties-client.h @@ -39,7 +39,7 @@ org_freedesktop_DBus_Properties_get_async_callback (DBusGProxy *proxy, DBusGProx { DBusGAsyncData *data = (DBusGAsyncData*) user_data; GError *error = NULL; - GValue OUT_Value = {0}; + GValue OUT_Value = { 0, }; dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_VALUE, &OUT_Value, G_TYPE_INVALID); (*(org_freedesktop_DBus_Properties_get_reply)data->cb) (proxy, OUT_Value, error, data->userdata); return; diff --git a/src/notification-item.xml b/src/notification-item.xml index a0141c3..cacc6be 100644 --- a/src/notification-item.xml +++ b/src/notification-item.xml @@ -12,6 +12,7 @@ to find the icons specified above. --> + @@ -24,6 +25,9 @@ + + + -- cgit v1.2.3 From 9f0e3c6e81e5ee98551c928e846019e46760b6c0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 3 Aug 2010 11:48:27 -0500 Subject: This shouldn't be in Bazaar --- src/dbus-properties-client.h | 139 ------------------------------------------- 1 file changed, 139 deletions(-) delete mode 100644 src/dbus-properties-client.h diff --git a/src/dbus-properties-client.h b/src/dbus-properties-client.h deleted file mode 100644 index 6f08e78..0000000 --- a/src/dbus-properties-client.h +++ /dev/null @@ -1,139 +0,0 @@ -/* Generated by dbus-binding-tool; do not edit! */ - -#include -#include - -G_BEGIN_DECLS - -#ifndef _DBUS_GLIB_ASYNC_DATA_FREE -#define _DBUS_GLIB_ASYNC_DATA_FREE -static -#ifdef G_HAVE_INLINE -inline -#endif -void -_dbus_glib_async_data_free (gpointer stuff) -{ - g_slice_free (DBusGAsyncData, stuff); -} -#endif - -#ifndef DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_DBus_Properties -#define DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_DBus_Properties - -static -#ifdef G_HAVE_INLINE -inline -#endif -gboolean -org_freedesktop_DBus_Properties_get (DBusGProxy *proxy, const char * IN_Interface_Name, const char * IN_Property_Name, GValue* OUT_Value, GError **error) - -{ - return dbus_g_proxy_call (proxy, "Get", error, G_TYPE_STRING, IN_Interface_Name, G_TYPE_STRING, IN_Property_Name, G_TYPE_INVALID, G_TYPE_VALUE, OUT_Value, G_TYPE_INVALID); -} - -typedef void (*org_freedesktop_DBus_Properties_get_reply) (DBusGProxy *proxy, GValue OUT_Value, GError *error, gpointer userdata); - -static void -org_freedesktop_DBus_Properties_get_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) -{ - DBusGAsyncData *data = (DBusGAsyncData*) user_data; - GError *error = NULL; - GValue OUT_Value = { 0, }; - dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_VALUE, &OUT_Value, G_TYPE_INVALID); - (*(org_freedesktop_DBus_Properties_get_reply)data->cb) (proxy, OUT_Value, error, data->userdata); - return; -} - -static -#ifdef G_HAVE_INLINE -inline -#endif -DBusGProxyCall* -org_freedesktop_DBus_Properties_get_async (DBusGProxy *proxy, const char * IN_Interface_Name, const char * IN_Property_Name, org_freedesktop_DBus_Properties_get_reply callback, gpointer userdata) - -{ - DBusGAsyncData *stuff; - stuff = g_slice_new (DBusGAsyncData); - stuff->cb = G_CALLBACK (callback); - stuff->userdata = userdata; - return dbus_g_proxy_begin_call (proxy, "Get", org_freedesktop_DBus_Properties_get_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_STRING, IN_Interface_Name, G_TYPE_STRING, IN_Property_Name, G_TYPE_INVALID); -} -static -#ifdef G_HAVE_INLINE -inline -#endif -gboolean -org_freedesktop_DBus_Properties_set (DBusGProxy *proxy, const char * IN_Interface_Name, const char * IN_Property_Name, const GValue* IN_Value, GError **error) - -{ - return dbus_g_proxy_call (proxy, "Set", error, G_TYPE_STRING, IN_Interface_Name, G_TYPE_STRING, IN_Property_Name, G_TYPE_VALUE, IN_Value, G_TYPE_INVALID, G_TYPE_INVALID); -} - -typedef void (*org_freedesktop_DBus_Properties_set_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); - -static void -org_freedesktop_DBus_Properties_set_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) -{ - DBusGAsyncData *data = (DBusGAsyncData*) user_data; - GError *error = NULL; - dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); - (*(org_freedesktop_DBus_Properties_set_reply)data->cb) (proxy, error, data->userdata); - return; -} - -static -#ifdef G_HAVE_INLINE -inline -#endif -DBusGProxyCall* -org_freedesktop_DBus_Properties_set_async (DBusGProxy *proxy, const char * IN_Interface_Name, const char * IN_Property_Name, const GValue* IN_Value, org_freedesktop_DBus_Properties_set_reply callback, gpointer userdata) - -{ - DBusGAsyncData *stuff; - stuff = g_slice_new (DBusGAsyncData); - stuff->cb = G_CALLBACK (callback); - stuff->userdata = userdata; - return dbus_g_proxy_begin_call (proxy, "Set", org_freedesktop_DBus_Properties_set_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_STRING, IN_Interface_Name, G_TYPE_STRING, IN_Property_Name, G_TYPE_VALUE, IN_Value, G_TYPE_INVALID); -} -static -#ifdef G_HAVE_INLINE -inline -#endif -gboolean -org_freedesktop_DBus_Properties_get_all (DBusGProxy *proxy, const char * IN_Interface_Name, GHashTable** OUT_Properties, GError **error) - -{ - return dbus_g_proxy_call (proxy, "GetAll", error, G_TYPE_STRING, IN_Interface_Name, G_TYPE_INVALID, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), OUT_Properties, G_TYPE_INVALID); -} - -typedef void (*org_freedesktop_DBus_Properties_get_all_reply) (DBusGProxy *proxy, GHashTable *OUT_Properties, GError *error, gpointer userdata); - -static void -org_freedesktop_DBus_Properties_get_all_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) -{ - DBusGAsyncData *data = (DBusGAsyncData*) user_data; - GError *error = NULL; - GHashTable* OUT_Properties; - dbus_g_proxy_end_call (proxy, call, &error, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), &OUT_Properties, G_TYPE_INVALID); - (*(org_freedesktop_DBus_Properties_get_all_reply)data->cb) (proxy, OUT_Properties, error, data->userdata); - return; -} - -static -#ifdef G_HAVE_INLINE -inline -#endif -DBusGProxyCall* -org_freedesktop_DBus_Properties_get_all_async (DBusGProxy *proxy, const char * IN_Interface_Name, org_freedesktop_DBus_Properties_get_all_reply callback, gpointer userdata) - -{ - DBusGAsyncData *stuff; - stuff = g_slice_new (DBusGAsyncData); - stuff->cb = G_CALLBACK (callback); - stuff->userdata = userdata; - return dbus_g_proxy_begin_call (proxy, "GetAll", org_freedesktop_DBus_Properties_get_all_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_STRING, IN_Interface_Name, G_TYPE_INVALID); -} -#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_org_freedesktop_DBus_Properties */ - -G_END_DECLS -- cgit v1.2.3 From 6de3d6fb8e8551a3a5d39207d1dbaba519325d7a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 3 Aug 2010 13:15:49 -0500 Subject: These have needed to be ignored for a while. --- .bzrignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.bzrignore b/.bzrignore index cbf5964..94155ae 100644 --- a/.bzrignore +++ b/.bzrignore @@ -111,3 +111,5 @@ src/notification-approver-client.h src/notification-approver-server.h tests/test-approver tests/test-approver-tester +bindings/mono/policy.0.0.appindicator-sharp.config +bindings/mono/policy.0.0.appindicator-sharp.dll -- cgit v1.2.3 From 89a5ffef0d244b250c6cd1a809db68d64bf577ee Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 3 Aug 2010 14:10:45 -0500 Subject: Adding a property to guide the size of the label --- src/notification-item.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/notification-item.xml b/src/notification-item.xml index cacc6be..b339e7b 100644 --- a/src/notification-item.xml +++ b/src/notification-item.xml @@ -13,6 +13,7 @@ + @@ -27,6 +28,7 @@ + -- cgit v1.2.3 From 44e84ede3da7d4a7e45c8c5b674a21703811e15c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 3 Aug 2010 14:37:01 -0500 Subject: Setting up the label and lable guide properties. --- src/app-indicator.c | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/src/app-indicator.c b/src/app-indicator.c index 32f512f..98e90ae 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -104,7 +104,9 @@ enum { PROP_ATTENTION_ICON_NAME, PROP_ICON_THEME_PATH, PROP_MENU, - PROP_CONNECTED + PROP_CONNECTED, + PROP_LABEL, + PROP_LABEL_GUIDE }; /* The strings so that they can be slowly looked up. */ @@ -116,6 +118,8 @@ enum { #define PROP_ICON_THEME_PATH_S "icon-theme-path" #define PROP_MENU_S "menu" #define PROP_CONNECTED_S "connected" +#define PROP_LABEL_S "label" +#define PROP_LABEL_GUIDE_S "label-guide" /* Private macro, shhhh! */ #define APP_INDICATOR_GET_PRIVATE(o) \ @@ -284,6 +288,41 @@ app_indicator_class_init (AppIndicatorClass *klass) "Pretty simple, true if we have a reasonable expectation of being displayed through this object. You should hide your TrayIcon if so.", FALSE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + /** + AppIndicator:label: + + A label that can be shown next to the string in the application + indicator. The label will not be shown unless there is an icon + as well. The label is useful for numerical and other frequently + updated information. In general, it shouldn't be shown unless a + user requests it as it can take up a significant amount of space + on the user's panel. This may not be shown in all visualizations. + */ + g_object_class_install_property(object_class, + PROP_LABEL, + g_param_spec_string (PROP_LABEL_S, + "A label next to the icon", + "A label to provide dynamic information.", + NULL, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + /** + AppIndicator:label-guide: + + An optional string to provide guidance to the panel on how big + the #AppIndicator:label string could get. If this is set correctly + then the panel should never 'jiggle' as the string adjusts through + out the range of options. For instance, if you were providing a + percentage like "54% thrust" in #AppIndicator:label you'd want to + set this string to "100% thrust" to ensure space when Scotty can + get you enough power. + */ + g_object_class_install_property(object_class, + PROP_LABEL_GUIDE, + g_param_spec_string (PROP_LABEL_GUIDE_S, + "A string to size the space available for the label.", + "To ensure that the label does not cause the panel to 'jiggle' this string should provide information on how much space it could take.", + NULL, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); /* Signals */ -- cgit v1.2.3 From e541156e92220917a58ff8abce1cfa235dc343f1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 3 Aug 2010 14:47:42 -0500 Subject: Adding the label and guide fields to the private struct and tying that into the properties. --- src/app-indicator.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/src/app-indicator.c b/src/app-indicator.c index 98e90ae..29149ae 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -72,6 +72,8 @@ struct _AppIndicatorPrivate { gchar * icon_path; DbusmenuServer *menuservice; GtkWidget *menu; + gchar * label; + gchar * label_guide; GtkStatusIcon * status_icon; gint fallback_timer; @@ -407,6 +409,8 @@ app_indicator_init (AppIndicator *self) priv->icon_path = NULL; priv->menu = NULL; priv->menuservice = NULL; + priv->label = NULL; + priv->label_guide = NULL; priv->watcher_proxy = NULL; priv->connection = NULL; @@ -530,6 +534,16 @@ app_indicator_finalize (GObject *object) g_free(priv->icon_path); priv->icon_path = NULL; } + + if (priv->label != NULL) { + g_free(priv->label); + priv->label = NULL; + } + + if (priv->label_guide != NULL) { + g_free(priv->label_guide); + priv->label_guide = NULL; + } G_OBJECT_CLASS (app_indicator_parent_class)->finalize (object); return; @@ -602,6 +616,33 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu priv->icon_path = g_value_dup_string(value); break; + case PROP_LABEL: { + gchar * oldlabel = priv->label; + priv->label = g_value_dup_string(value); + + if (g_strcmp0(oldlabel, priv->label) != 0) { + // TODO: signal change + } + + if (oldlabel != NULL) { + g_free(oldlabel); + } + break; + } + case PROP_LABEL_GUIDE: { + gchar * oldguide = priv->label_guide; + priv->label_guide = g_value_dup_string(value); + + if (g_strcmp0(oldguide, priv->label_guide) != 0) { + // TODO: signal change + } + + if (oldguide != NULL) { + g_free(oldguide); + } + break; + } + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -659,6 +700,14 @@ app_indicator_get_property (GObject * object, guint prop_id, GValue * value, GPa g_value_set_boolean (value, priv->watcher_proxy != NULL ? TRUE : FALSE); break; + case PROP_LABEL: + g_value_set_string (value, priv->label); + break; + + case PROP_LABEL_GUIDE: + g_value_set_string (value, priv->label_guide); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; -- cgit v1.2.3 From 706a72b9b2a36c39ce274a2508031b4cc0f4bb2e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 3 Aug 2010 15:12:23 -0500 Subject: Adding in the convience wrappers --- src/app-indicator.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/app-indicator.h | 5 +++++ 2 files changed, 63 insertions(+) diff --git a/src/app-indicator.c b/src/app-indicator.c index 29149ae..ce79165 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -1222,6 +1222,31 @@ app_indicator_set_icon (AppIndicator *self, const gchar *icon_name) return; } +/** + app_indicator_set_label: + @self: The #AppIndicator object to use + @label: The label to show next to the icon. + @guide: A guide to size the label correctly. + + This is a wrapper function for the #AppIndicator:label and + #AppIndicator:guide properties. This function can take #NULL + as either @label or @guide and will clear the entries. +*/ +void +app_indicator_set_label (AppIndicator *self, const gchar * label, const gchar * guide) +{ + g_return_if_fail (IS_APP_INDICATOR (self)); + /* Note: The label can be NULL, it's okay */ + /* Note: The guide can be NULL, it's okay */ + + g_object_set(G_OBJECT(self), + PROP_LABEL_S, label == NULL ? "" : label, + PROP_LABEL_GUIDE_S, guide == NULL ? "" : guide, + NULL); + + return; +} + static void activate_menuitem (DbusmenuMenuitem *mi, guint timestamp, gpointer user_data) { @@ -1749,3 +1774,36 @@ app_indicator_get_menu (AppIndicator *self) return GTK_MENU(priv->menu); } + +/** + app_indicator_get_label: + @self: The #AppIndicator object to use + + Wrapper function for property #AppIndicator:label. + + Return value: The current label. +*/ +const gchar * +app_indicator_get_label (AppIndicator *self) +{ + g_return_val_if_fail (IS_APP_INDICATOR (self), NULL); + + return self->priv->label; +} + +/** + app_indicator_get_label_guide: + @self: The #AppIndicator object to use + + Wrapper function for property #AppIndicator:label-guide. + + Return value: The current label guide. +*/ +const gchar * +app_indicator_get_label_guide (AppIndicator *self) +{ + g_return_val_if_fail (IS_APP_INDICATOR (self), NULL); + + return self->priv->label_guide; +} + diff --git a/src/app-indicator.h b/src/app-indicator.h index e37abd4..767cf72 100644 --- a/src/app-indicator.h +++ b/src/app-indicator.h @@ -226,6 +226,9 @@ void app_indicator_set_menu (AppIndicator GtkMenu *menu); void app_indicator_set_icon (AppIndicator *self, const gchar *icon_name); +void app_indicator_set_label (AppIndicator *self, + const gchar *label, + const gchar *guide); /* Get properties */ const gchar * app_indicator_get_id (AppIndicator *self); @@ -234,6 +237,8 @@ AppIndicatorStatus app_indicator_get_status (AppIndicator * const gchar * app_indicator_get_icon (AppIndicator *self); const gchar * app_indicator_get_attention_icon (AppIndicator *self); GtkMenu * app_indicator_get_menu (AppIndicator *self); +const gchar * app_indicator_get_label (AppIndicator *self); +const gchar * app_indicator_get_label_guide (AppIndicator *self); G_END_DECLS -- cgit v1.2.3 From e0f472f173a2bb2931f7ddbb1c5bd3d25af5f462 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 3 Aug 2010 15:40:50 -0500 Subject: Adding the label funcs to the documentation. --- docs/reference/libappindicator-sections.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/reference/libappindicator-sections.txt b/docs/reference/libappindicator-sections.txt index 70df0b8..115e0d3 100644 --- a/docs/reference/libappindicator-sections.txt +++ b/docs/reference/libappindicator-sections.txt @@ -23,11 +23,14 @@ app_indicator_set_status app_indicator_set_attention_icon app_indicator_set_menu app_indicator_set_icon +app_indicator_set_label app_indicator_get_id app_indicator_get_category app_indicator_get_status app_indicator_get_icon app_indicator_get_attention_icon app_indicator_get_menu +app_indicator_get_label +app_indicator_get_label_guide -- cgit v1.2.3 From fc9d5d4f762493d0b8378b12ac6c8451e5b9683b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 3 Aug 2010 15:55:21 -0500 Subject: Adding in a signal to tell when the label is updated. --- src/app-indicator.c | 18 ++++++++++++++++++ src/app-indicator.h | 15 +++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/app-indicator.c b/src/app-indicator.c index ce79165..ec153c6 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -89,6 +89,7 @@ enum { NEW_ICON, NEW_ATTENTION_ICON, NEW_STATUS, + NEW_LABEL, CONNECTION_CHANGED, LAST_SIGNAL }; @@ -373,6 +374,23 @@ app_indicator_class_init (AppIndicatorClass *klass) G_TYPE_NONE, 1, G_TYPE_STRING); + /** + AppIndicator::new-label: + @arg0: The #AppIndicator object + @arg1: The string for the label + @arg1: The string for the guide + + Emitted when either #AppIndicator:label or #AppIndicator:label-guide are + changed. + */ + signals[NEW_LABEL] = g_signal_new (APP_INDICATOR_SIGNAL_NEW_LABEL, + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (AppIndicatorClass, new_label), + NULL, NULL, + g_cclosure_marshal_VOID__STRING_STRING, + G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING); + /** AppIndicator::connection-changed: @arg0: The #AppIndicator object diff --git a/src/app-indicator.h b/src/app-indicator.h index 767cf72..586d2dc 100644 --- a/src/app-indicator.h +++ b/src/app-indicator.h @@ -91,6 +91,11 @@ G_BEGIN_DECLS String identifier for the #AppIndicator::new-status signal. */ +/** + APP_INDICATOR_SIGNAL_NEW_LABEL: + + String identifier for the #AppIndicator::new-label signal. +*/ /** APP_INDICATOR_SIGNAL_CONNECTION_CHANGED: @@ -99,6 +104,7 @@ G_BEGIN_DECLS #define APP_INDICATOR_SIGNAL_NEW_ICON "new-icon" #define APP_INDICATOR_SIGNAL_NEW_ATTENTION_ICON "new-attention-icon" #define APP_INDICATOR_SIGNAL_NEW_STATUS "new-status" +#define APP_INDICATOR_SIGNAL_NEW_LABEL "new-label" #define APP_INDICATOR_SIGNAL_CONNECTION_CHANGED "connection-changed" /** @@ -152,8 +158,8 @@ typedef struct _AppIndicatorPrivate AppIndicatorPrivate; there is no Application Indicator area available. @unfallback: The function that gets called if an Application Indicator area appears after the fallback has been created. + @new_label: Slot for #AppIndicator::new-label. @app_indicator_reserved_1: Reserved for future use. - @app_indicator_reserved_2: Reserved for future use. The signals and external functions that make up the #AppIndicator class object. @@ -181,9 +187,14 @@ struct _AppIndicatorClass { void (*unfallback) (AppIndicator * indicator, GtkStatusIcon * status_icon); + /* Another DBus Signal */ + void (* new_label) (AppIndicator *indicator, + const gchar *label, + const gchar *guide, + gpointer user_data); + /* Reserved */ void (*app_indicator_reserved_1)(void); - void (*app_indicator_reserved_2)(void); }; /** -- cgit v1.2.3 From 84821ece8828fc87a45b9ba2ca75ef0a15d797ce Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 3 Aug 2010 16:18:42 -0500 Subject: Reusing the application service marshallers, not beautiful, but it works for now. --- src/Makefile.am | 3 ++- src/app-indicator.c | 3 ++- src/application-service-marshal.list | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 68be1c0..b704b5e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -94,7 +94,8 @@ BUILT_SOURCES += \ libappindicator_la_SOURCES = \ $(libappindicator_headers) \ app-indicator-enum-types.c \ - app-indicator.c + app-indicator.c \ + application-service-marshal.c libappindicator_la_LDFLAGS = \ -version-info 0:0:0 \ diff --git a/src/app-indicator.c b/src/app-indicator.c index ec153c6..e0ccec4 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -37,6 +37,7 @@ License version 3 and version 2.1 along with this program. If not, see #include "app-indicator.h" #include "app-indicator-enum-types.h" +#include "application-service-marshal.h" #include "notification-item-server.h" #include "notification-watcher-client.h" @@ -388,7 +389,7 @@ app_indicator_class_init (AppIndicatorClass *klass) G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (AppIndicatorClass, new_label), NULL, NULL, - g_cclosure_marshal_VOID__STRING_STRING, + _application_service_marshal_VOID__STRING_STRING, G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING); /** diff --git a/src/application-service-marshal.list b/src/application-service-marshal.list index 4ac8398..b49ff41 100644 --- a/src/application-service-marshal.list +++ b/src/application-service-marshal.list @@ -18,3 +18,4 @@ # with this program. If not, see . VOID: STRING, INT, STRING, STRING, STRING VOID: INT, STRING +VOID: STRING, STRING -- cgit v1.2.3 From 0422fcb1fd43d6ad34e5b763747aa6c0e904e321 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 3 Aug 2010 16:23:35 -0500 Subject: Putting the new define into the docs --- docs/reference/libappindicator-sections.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/reference/libappindicator-sections.txt b/docs/reference/libappindicator-sections.txt index 115e0d3..49a470d 100644 --- a/docs/reference/libappindicator-sections.txt +++ b/docs/reference/libappindicator-sections.txt @@ -9,6 +9,7 @@ APP_INDICATOR_GET_CLASS APP_INDICATOR_SIGNAL_NEW_ICON APP_INDICATOR_SIGNAL_NEW_ATTENTION_ICON APP_INDICATOR_SIGNAL_NEW_STATUS +APP_INDICATOR_SIGNAL_NEW_LABEL APP_INDICATOR_SIGNAL_CONNECTION_CHANGED AppIndicatorCategory AppIndicatorStatus -- cgit v1.2.3 From 52bfc9d4ba3d38ab07004b6fdb04173912329cf8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 3 Aug 2010 16:45:18 -0500 Subject: Signaling when the labels change in the idle loop --- src/app-indicator.c | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/src/app-indicator.c b/src/app-indicator.c index e0ccec4..0da0b01 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -75,6 +75,7 @@ struct _AppIndicatorPrivate { GtkWidget *menu; gchar * label; gchar * label_guide; + guint label_change_idle; GtkStatusIcon * status_icon; gint fallback_timer; @@ -144,6 +145,7 @@ static void app_indicator_finalize (GObject *object); static void app_indicator_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); static void app_indicator_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); /* Other stuff */ +static void signal_label_change (AppIndicator * self); static void check_connect (AppIndicator * self); static void register_service_cb (DBusGProxy * proxy, GError * error, gpointer data); static void start_fallback_timer (AppIndicator * self, gboolean disable_timeout); @@ -430,6 +432,7 @@ app_indicator_init (AppIndicator *self) priv->menuservice = NULL; priv->label = NULL; priv->label_guide = NULL; + priv->label_change_idle = 0; priv->watcher_proxy = NULL; priv->connection = NULL; @@ -481,6 +484,11 @@ app_indicator_dispose (GObject *object) priv->fallback_timer = 0; } + if (priv->label_change_idle != 0) { + g_source_remove(priv->label_change_idle); + priv->label_change_idle = 0; + } + if (priv->menu != NULL) { g_signal_handlers_disconnect_by_func (G_OBJECT (priv->menu), client_menu_changed, @@ -640,7 +648,7 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu priv->label = g_value_dup_string(value); if (g_strcmp0(oldlabel, priv->label) != 0) { - // TODO: signal change + signal_label_change(APP_INDICATOR(object)); } if (oldlabel != NULL) { @@ -653,7 +661,7 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu priv->label_guide = g_value_dup_string(value); if (g_strcmp0(oldguide, priv->label_guide) != 0) { - // TODO: signal change + signal_label_change(APP_INDICATOR(object)); } if (oldguide != NULL) { @@ -735,6 +743,39 @@ app_indicator_get_property (GObject * object, guint prop_id, GValue * value, GPa return; } +/* Sends the label changed signal and resets the source ID */ +static gboolean +signal_label_change_idle (gpointer user_data) +{ + AppIndicator * self = (AppIndicator *)user_data; + AppIndicatorPrivate *priv = self->priv; + + g_signal_emit(G_OBJECT(self), signals[NEW_LABEL], 0, + priv->label != NULL ? priv->label : "", + priv->label_guide != NULL ? priv->label_guide : "", + TRUE); + + priv->label_change_idle = 0; + + return FALSE; +} + +/* Sets up an idle function to send the label changed signal + so that we don't send it too many times. */ +static void +signal_label_change (AppIndicator * self) +{ + AppIndicatorPrivate *priv = self->priv; + + /* don't set it twice */ + if (priv->label_change_idle != 0) { + return; + } + + priv->label_change_idle = g_idle_add(signal_label_change_idle, self); + return; +} + /* This function is used to see if we have enough information to connect to things. If we do, and we're not connected, it connects for us. */ -- cgit v1.2.3 From a2e95f155e746d390a8e6b5253d527a655df96a2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 3 Aug 2010 17:07:29 -0500 Subject: Adding a test to set the label and guides a bunch. --- tests/test-libappindicator.c | 63 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/tests/test-libappindicator.c b/tests/test-libappindicator.c index 86879b3..6d06236 100644 --- a/tests/test-libappindicator.c +++ b/tests/test-libappindicator.c @@ -162,6 +162,68 @@ test_libappindicator_init (void) return; } +void +test_libappindicator_set_label (void) +{ + AppIndicator * ci = app_indicator_new ("my-id", + "my-name", + APP_INDICATOR_CATEGORY_APPLICATION_STATUS); + + g_assert(ci != NULL); + g_assert(app_indicator_get_label(ci) == NULL); + g_assert(app_indicator_get_label_guide(ci) == NULL); + + /* First check all the clearing modes, this is important as + we're going to use them later, we need them to work. */ + app_indicator_set_label(ci, NULL, NULL); + + g_assert(app_indicator_get_label(ci) == NULL); + g_assert(app_indicator_get_label_guide(ci) == NULL); + + app_indicator_set_label(ci, "", NULL); + + g_assert(app_indicator_get_label(ci) == NULL); + g_assert(app_indicator_get_label_guide(ci) == NULL); + + app_indicator_set_label(ci, NULL, ""); + + g_assert(app_indicator_get_label(ci) == NULL); + g_assert(app_indicator_get_label_guide(ci) == NULL); + + app_indicator_set_label(ci, "", ""); + + g_assert(app_indicator_get_label(ci) == NULL); + g_assert(app_indicator_get_label_guide(ci) == NULL); + + app_indicator_set_label(ci, "label", ""); + + g_assert(g_strcmp0(app_indicator_get_label(ci), "label")); + g_assert(app_indicator_get_label_guide(ci) == NULL); + + app_indicator_set_label(ci, NULL, NULL); + + g_assert(app_indicator_get_label(ci) == NULL); + g_assert(app_indicator_get_label_guide(ci) == NULL); + + app_indicator_set_label(ci, "label", "guide"); + + g_assert(g_strcmp0(app_indicator_get_label(ci), "label")); + g_assert(g_strcmp0(app_indicator_get_label_guide(ci), "guide")); + + app_indicator_set_label(ci, "label2", "guide"); + + g_assert(g_strcmp0(app_indicator_get_label(ci), "label2")); + g_assert(g_strcmp0(app_indicator_get_label_guide(ci), "guide")); + + app_indicator_set_label(ci, "trick-label", "trick-guide"); + + g_assert(g_strcmp0(app_indicator_get_label(ci), "trick-label")); + g_assert(g_strcmp0(app_indicator_get_label_guide(ci), "trick-guide")); + + g_object_unref(G_OBJECT(ci)); + return; +} + void test_libappindicator_props_suite (void) { @@ -169,6 +231,7 @@ test_libappindicator_props_suite (void) g_test_add_func ("/indicator-application/libappindicator/init_props", test_libappindicator_init_with_props); g_test_add_func ("/indicator-application/libappindicator/init_set_props", test_libappindicator_init_set_props); g_test_add_func ("/indicator-application/libappindicator/prop_signals", test_libappindicator_prop_signals); + g_test_add_func ("/indicator-application/libappindicator/set_label", test_libappindicator_set_label); return; } -- cgit v1.2.3 From f72116833d67c954ec69dfe8aced4e7e26c36c23 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 3 Aug 2010 17:09:57 -0500 Subject: Turning null strings into NULLs --- src/app-indicator.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/app-indicator.c b/src/app-indicator.c index 0da0b01..b3fa3e5 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -651,6 +651,11 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu signal_label_change(APP_INDICATOR(object)); } + if (priv->label != NULL && priv->label[0] == '\0') { + g_free(priv->label); + priv->label = NULL; + } + if (oldlabel != NULL) { g_free(oldlabel); } @@ -664,6 +669,11 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu signal_label_change(APP_INDICATOR(object)); } + if (priv->label_guide != NULL && priv->label_guide[0] == '\0') { + g_free(priv->label_guide); + priv->label_guide = NULL; + } + if (oldguide != NULL) { g_free(oldguide); } -- cgit v1.2.3 From 29253842cb7715e7f3d3ca94bf4082edb824bb9c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 3 Aug 2010 17:14:32 -0500 Subject: Stupid reverse logic in the string comparison. --- tests/test-libappindicator.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/test-libappindicator.c b/tests/test-libappindicator.c index 6d06236..2ac7326 100644 --- a/tests/test-libappindicator.c +++ b/tests/test-libappindicator.c @@ -197,7 +197,7 @@ test_libappindicator_set_label (void) app_indicator_set_label(ci, "label", ""); - g_assert(g_strcmp0(app_indicator_get_label(ci), "label")); + g_assert(g_strcmp0(app_indicator_get_label(ci), "label") == 0); g_assert(app_indicator_get_label_guide(ci) == NULL); app_indicator_set_label(ci, NULL, NULL); @@ -207,18 +207,18 @@ test_libappindicator_set_label (void) app_indicator_set_label(ci, "label", "guide"); - g_assert(g_strcmp0(app_indicator_get_label(ci), "label")); - g_assert(g_strcmp0(app_indicator_get_label_guide(ci), "guide")); + g_assert(g_strcmp0(app_indicator_get_label(ci), "label") == 0); + g_assert(g_strcmp0(app_indicator_get_label_guide(ci), "guide") == 0); app_indicator_set_label(ci, "label2", "guide"); - g_assert(g_strcmp0(app_indicator_get_label(ci), "label2")); - g_assert(g_strcmp0(app_indicator_get_label_guide(ci), "guide")); + g_assert(g_strcmp0(app_indicator_get_label(ci), "label2") == 0); + g_assert(g_strcmp0(app_indicator_get_label_guide(ci), "guide") == 0); app_indicator_set_label(ci, "trick-label", "trick-guide"); - g_assert(g_strcmp0(app_indicator_get_label(ci), "trick-label")); - g_assert(g_strcmp0(app_indicator_get_label_guide(ci), "trick-guide")); + g_assert(g_strcmp0(app_indicator_get_label(ci), "trick-label") == 0); + g_assert(g_strcmp0(app_indicator_get_label_guide(ci), "trick-guide") == 0); g_object_unref(G_OBJECT(ci)); return; -- cgit v1.2.3 From 6882b4cb557db5bc65f14d6b6e88f8f9667896b2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 3 Aug 2010 21:09:58 -0500 Subject: Setting up a basic signals test --- tests/test-libappindicator.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tests/test-libappindicator.c b/tests/test-libappindicator.c index 2ac7326..e6c8dcc 100644 --- a/tests/test-libappindicator.c +++ b/tests/test-libappindicator.c @@ -224,6 +224,47 @@ test_libappindicator_set_label (void) return; } +void +label_signals_cb (AppIndicator * appindicator, gchar * label, gchar * guide, gpointer user_data) +{ + gint * label_signals_count = (gint *)user_data; + (*label_signals_count)++; + return; +} + +void +label_signals_check (void) +{ + while (g_main_context_pending(NULL)) { + g_main_context_iteration(NULL, TRUE); + } + + return; +} + +void +test_libappindicator_label_signals (void) +{ + gint label_signals_count = 0; + AppIndicator * ci = app_indicator_new ("my-id", + "my-name", + APP_INDICATOR_CATEGORY_APPLICATION_STATUS); + + g_assert(ci != NULL); + g_assert(app_indicator_get_label(ci) == NULL); + g_assert(app_indicator_get_label_guide(ci) == NULL); + + g_signal_connect(G_OBJECT(ci), APP_INDICATOR_SIGNAL_NEW_LABEL, G_CALLBACK(label_signals_cb), &label_signals_count); + + app_indicator_set_label(ci, "label", "guide"); + g_assert(label_signals_count == 0); + + label_signals_check(); + g_assert(label_signals_count == 1); + + return; +} + void test_libappindicator_props_suite (void) { @@ -232,6 +273,7 @@ test_libappindicator_props_suite (void) g_test_add_func ("/indicator-application/libappindicator/init_set_props", test_libappindicator_init_set_props); g_test_add_func ("/indicator-application/libappindicator/prop_signals", test_libappindicator_prop_signals); g_test_add_func ("/indicator-application/libappindicator/set_label", test_libappindicator_set_label); + g_test_add_func ("/indicator-application/libappindicator/label_signals", test_libappindicator_label_signals); return; } -- cgit v1.2.3 From 43e185e0c4828a5eaa0422186198d08edefd12a1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 3 Aug 2010 21:13:34 -0500 Subject: More signalling tests. --- tests/test-libappindicator.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/test-libappindicator.c b/tests/test-libappindicator.c index e6c8dcc..8d12ac5 100644 --- a/tests/test-libappindicator.c +++ b/tests/test-libappindicator.c @@ -256,9 +256,37 @@ test_libappindicator_label_signals (void) g_signal_connect(G_OBJECT(ci), APP_INDICATOR_SIGNAL_NEW_LABEL, G_CALLBACK(label_signals_cb), &label_signals_count); + /* Shouldn't be a signal as it should be stuck in idle */ app_indicator_set_label(ci, "label", "guide"); g_assert(label_signals_count == 0); + /* Should show up after idle processing */ + label_signals_check(); + g_assert(label_signals_count == 1); + + /* Shouldn't signal with no change */ + label_signals_count = 0; + app_indicator_set_label(ci, "label", "guide"); + label_signals_check(); + g_assert(label_signals_count == 0); + + /* Change one, we should get one signal */ + app_indicator_set_label(ci, "label2", "guide"); + label_signals_check(); + g_assert(label_signals_count == 1); + + /* Change several times, one signal */ + label_signals_count = 0; + app_indicator_set_label(ci, "label1", "guide0"); + app_indicator_set_label(ci, "label1", "guide1"); + app_indicator_set_label(ci, "label2", "guide2"); + app_indicator_set_label(ci, "label3", "guide3"); + label_signals_check(); + g_assert(label_signals_count == 1); + + /* Clear should signal too */ + label_signals_count = 0; + app_indicator_set_label(ci, NULL, NULL); label_signals_check(); g_assert(label_signals_count == 1); -- cgit v1.2.3 From f2b808303f336aad4ee2663efb80a096dd61dcbd Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 4 Aug 2010 14:50:13 -0500 Subject: Setting the label in the simple client --- example/simple-client.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/example/simple-client.c b/example/simple-client.c index fbcaaaa..d756988 100644 --- a/example/simple-client.c +++ b/example/simple-client.c @@ -97,6 +97,18 @@ append_submenu (GtkWidget *item) gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), menu); } +guint percentage = 0; + +static gboolean +percent_change (gpointer user_data) +{ + percentage = (percentage + 1) % 100; + gchar * percentstr = g_strdup_printf("%d%%", percentage); + app_indicator_set_label (APP_INDICATOR(user_data), percentstr, "100%"); + g_free(percentstr); + return TRUE; +} + int main (int argc, char ** argv) { @@ -114,6 +126,9 @@ main (int argc, char ** argv) app_indicator_set_status (ci, APP_INDICATOR_STATUS_ACTIVE); app_indicator_set_attention_icon(ci, "indicator-messages-new"); + app_indicator_set_label (ci, "1%", "100%"); + + g_timeout_add_seconds(1, percent_change, ci); menu = gtk_menu_new (); GtkWidget *item = gtk_check_menu_item_new_with_label ("1"); -- cgit v1.2.3 From 1f04ea2f899a2922e9c625fd629463c4dd16aff5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 4 Aug 2010 20:19:29 -0500 Subject: Make sure we get to 100 --- example/simple-client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/simple-client.c b/example/simple-client.c index d756988..20cb281 100644 --- a/example/simple-client.c +++ b/example/simple-client.c @@ -103,7 +103,7 @@ static gboolean percent_change (gpointer user_data) { percentage = (percentage + 1) % 100; - gchar * percentstr = g_strdup_printf("%d%%", percentage); + gchar * percentstr = g_strdup_printf("%d%%", percentage + 1); app_indicator_set_label (APP_INDICATOR(user_data), percentstr, "100%"); g_free(percentstr); return TRUE; -- cgit v1.2.3 From 23e9b56c533e25febfa8c83c353492403cb1b4d5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 5 Aug 2010 14:45:50 -0500 Subject: Adding the ability to toggle the label on and off --- example/simple-client.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/example/simple-client.c b/example/simple-client.c index 20cb281..f2fac6f 100644 --- a/example/simple-client.c +++ b/example/simple-client.c @@ -26,6 +26,21 @@ with this program. If not, see . GMainLoop * mainloop = NULL; static gboolean active = TRUE; +static gboolean can_haz_label = TRUE; + +static void +label_toggle_cb (GtkWidget * widget, gpointer data) +{ + can_haz_label = !can_haz_label; + + if (can_haz_label) { + gtk_menu_item_set_label(GTK_MENU_ITEM(widget), "Hide label"); + } else { + gtk_menu_item_set_label(GTK_MENU_ITEM(widget), "Show label"); + } + + return; +} static void activate_clicked_cb (GtkWidget *widget, gpointer data) @@ -103,9 +118,13 @@ static gboolean percent_change (gpointer user_data) { percentage = (percentage + 1) % 100; - gchar * percentstr = g_strdup_printf("%d%%", percentage + 1); - app_indicator_set_label (APP_INDICATOR(user_data), percentstr, "100%"); - g_free(percentstr); + if (can_haz_label) { + gchar * percentstr = g_strdup_printf("%d%%", percentage + 1); + app_indicator_set_label (APP_INDICATOR(user_data), percentstr, "100%"); + g_free(percentstr); + } else { + app_indicator_set_label (APP_INDICATOR(user_data), NULL, NULL); + } return TRUE; } @@ -166,6 +185,13 @@ main (int argc, char ** argv) gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show(item); + item = gtk_menu_item_new_with_label ("Show label"); + label_toggle_cb(item, ci); + g_signal_connect (item, "activate", + G_CALLBACK (label_toggle_cb), ci); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + gtk_widget_show(item); + app_indicator_set_menu (ci, GTK_MENU (menu)); mainloop = g_main_loop_new(NULL, FALSE); -- cgit v1.2.3 From d377c945f1dcc36710313fdfa7e79b725fa8d42e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 5 Aug 2010 16:43:15 -0500 Subject: Fixing merge --- src/app-indicator.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app-indicator.c b/src/app-indicator.c index 3bfdf2f..22b9c03 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -1339,6 +1339,7 @@ app_indicator_set_label (AppIndicator *self, const gchar * label, const gchar * Sets the path to use when searching for icons. **/ +void app_indicator_set_icon_theme_path (AppIndicator *self, const gchar *icon_theme_path) { g_return_if_fail (IS_APP_INDICATOR (self)); -- cgit v1.2.3