diff options
author | Ted Gould <ted@gould.cx> | 2010-08-05 12:20:25 -0500 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2010-08-05 12:20:25 -0500 |
commit | 08a2c880e92c9ac143e83c862853c07068661fb9 (patch) | |
tree | f136c50e1bb091c50e800abac6b4cc434436fe8a /src/indicator-application.c | |
parent | a644617fdbc2257a9e6219532a5a6bfaf6decc90 (diff) | |
download | libayatana-appindicator-08a2c880e92c9ac143e83c862853c07068661fb9.tar.gz libayatana-appindicator-08a2c880e92c9ac143e83c862853c07068661fb9.tar.bz2 libayatana-appindicator-08a2c880e92c9ac143e83c862853c07068661fb9.zip |
Some slight refactoring and comments along with the ability to remove the entries and recreate them.
Diffstat (limited to 'src/indicator-application.c')
-rw-r--r-- | src/indicator-application.c | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/src/indicator-application.c b/src/indicator-application.c index 788c5e9..a4933ac 100644 --- a/src/indicator-application.c +++ b/src/indicator-application.c @@ -610,20 +610,34 @@ application_label_changed (DBusGProxy * proxy, gint position, const gchar * labe return; } - /* TODO: Be able to remove labels */ - - if (app->entry.label != NULL) { - gtk_label_set_text(app->entry.label, label); + if (label == NULL || label[0] == '\0') { + /* No label, let's see if we need to delete the old one */ + if (app->entry.label != NULL) { + g_object_unref(G_OBJECT(app->entry.label)); + app->entry.label = NULL; + + /* We tell listeners that it got removed and readded so + that we can get them to remove the old label. */ + g_signal_emit(G_OBJECT(application), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED_ID, 0, &(app->entry), TRUE); + g_signal_emit(G_OBJECT(application), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED_ID, 0, &(app->entry), TRUE); + } } else { - app->entry.label = GTK_LABEL(gtk_label_new(label)); - gtk_widget_show(GTK_WIDGET(app->entry.label)); + /* We've got a label, is this just an update or is + it a new thing. */ + if (app->entry.label != NULL) { + gtk_label_set_text(app->entry.label, label); + } else { + app->entry.label = GTK_LABEL(gtk_label_new(label)); + gtk_widget_show(GTK_WIDGET(app->entry.label)); - /* We tell listeners that it got removed and readded so - that we can get them to re-look at the new label. */ - g_signal_emit(G_OBJECT(application), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED_ID, 0, &(app->entry), TRUE); - g_signal_emit(G_OBJECT(application), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED_ID, 0, &(app->entry), TRUE); + /* We tell listeners that it got removed and readded so + that we can get them to re-look at the new label. */ + g_signal_emit(G_OBJECT(application), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED_ID, 0, &(app->entry), TRUE); + g_signal_emit(G_OBJECT(application), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED_ID, 0, &(app->entry), TRUE); + } } + /* Copy the guide if we have one */ if (app->guide != NULL) { g_free(app->guide); app->guide = NULL; @@ -633,6 +647,7 @@ application_label_changed (DBusGProxy * proxy, gint position, const gchar * labe app->guide = g_strdup(guide); } + /* Protected against not having a label */ guess_label_size(app); return; |