aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-08-03 16:45:18 -0500
committerTed Gould <ted@gould.cx>2010-08-03 16:45:18 -0500
commit52bfc9d4ba3d38ab07004b6fdb04173912329cf8 (patch)
tree40a7bc0e9e0fb56110fc99c185ccb0b8773e4a94
parent0422fcb1fd43d6ad34e5b763747aa6c0e904e321 (diff)
downloadayatana-indicator-application-52bfc9d4ba3d38ab07004b6fdb04173912329cf8.tar.gz
ayatana-indicator-application-52bfc9d4ba3d38ab07004b6fdb04173912329cf8.tar.bz2
ayatana-indicator-application-52bfc9d4ba3d38ab07004b6fdb04173912329cf8.zip
Signaling when the labels change in the idle loop
-rw-r--r--src/app-indicator.c45
1 files 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. */