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(-) (limited to 'src') 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 (limited to 'src') 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 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(+) (limited to 'src') 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(-) (limited to 'src') 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(+) (limited to 'src') 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(+) (limited to 'src') 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 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(-) (limited to 'src') 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(-) (limited to 'src') 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 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(-) (limited to 'src') 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 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(+) (limited to 'src') 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 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(+) (limited to 'src') 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 From 18628e90b2a60b905569e62257f2b75a8bcb9335 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 5 Aug 2010 17:09:56 -0500 Subject: Incrementing the major version number --- src/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index b704b5e..0e84749 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -98,7 +98,7 @@ libappindicator_la_SOURCES = \ application-service-marshal.c libappindicator_la_LDFLAGS = \ - -version-info 0:0:0 \ + -version-info 1:0:0 \ -no-undefined \ -export-symbols-regex "^[^_d].*" -- cgit v1.2.3 From 89186858938bec991dfcbe931764b291edd24917 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 5 Aug 2010 17:14:38 -0500 Subject: Changing the size of the class structure, the reason for the break. --- src/app-indicator.h | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/app-indicator.h b/src/app-indicator.h index 8320a2f..a9e1c38 100644 --- a/src/app-indicator.h +++ b/src/app-indicator.h @@ -161,12 +161,20 @@ typedef struct _AppIndicatorPrivate AppIndicatorPrivate; @new_attention_icon: Slot for #AppIndicator::new-attention-icon. @new_status: Slot for #AppIndicator::new-status. @new_icon_theme_path: Slot for #AppIndicator::new-icon-theme-path + @new_label: Slot for #AppIndicator::new-label. @connection_changed: Slot for #AppIndicator::connection-changed. + @app_indicator_reserved_sw: Reserved for future use. + @app_indicator_reserved_ats: Reserved for future use. @fallback: Function that gets called to make a #GtkStatusIcon when 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. + @app_indicator_reserved_3: Reserved for future use. + @app_indicator_reserved_4: Reserved for future use. + @app_indicator_reserved_5: Reserved for future use. + @app_indicator_reserved_6: Reserved for future use. The signals and external functions that make up the #AppIndicator class object. @@ -183,27 +191,33 @@ struct _AppIndicatorClass { void (* new_status) (AppIndicator *indicator, const gchar *status, gpointer user_data); + void (* new_icon_theme_path) (AppIndicator *indicator, + const gchar *icon_theme_path, + gpointer user_data); + void (* new_label) (AppIndicator *indicator, + const gchar *label, + const gchar *guide, + gpointer user_data); /* Local Signals */ void (* connection_changed) (AppIndicator * indicator, gboolean connected, gpointer user_data); + void (*app_indicator_reserved_sw)(void); + void (*app_indicator_reserved_ats)(void); /* Overridable Functions */ GtkStatusIcon * (*fallback) (AppIndicator * indicator); void (*unfallback) (AppIndicator * indicator, GtkStatusIcon * status_icon); - /* Another DBus Signal */ - void (* new_label) (AppIndicator *indicator, - const gchar *label, - const gchar *guide, - gpointer user_data); - void (* new_icon_theme_path) (AppIndicator *indicator, - const gchar *icon_theme_path, - gpointer user_data); - /* Reserved */ + void (*app_indicator_reserved_1)(void); + void (*app_indicator_reserved_2)(void); + void (*app_indicator_reserved_3)(void); + void (*app_indicator_reserved_4)(void); + void (*app_indicator_reserved_5)(void); + void (*app_indicator_reserved_6)(void); }; /** -- cgit v1.2.3