aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-08-04 14:56:10 -0500
committerTed Gould <ted@gould.cx>2010-08-04 14:56:10 -0500
commitbe5cab0001457de5835ef1dedffb44fc83a1588e (patch)
tree6ae4db93b1504fc43c6fb105ae39425306a30d22
parent6eeaa491a8749fc13b7fc5a63fc8e62134d5c803 (diff)
parentc25bb3c4bd3bf3b5c2d79db028d6db016eaa2c5b (diff)
downloadlibayatana-appindicator-be5cab0001457de5835ef1dedffb44fc83a1588e.tar.gz
libayatana-appindicator-be5cab0001457de5835ef1dedffb44fc83a1588e.tar.bz2
libayatana-appindicator-be5cab0001457de5835ef1dedffb44fc83a1588e.zip
Adding label support into the indicator
-rw-r--r--debian/changelog3
-rw-r--r--src/application-service-appstore.c135
-rw-r--r--src/application-service-appstore.h1
-rw-r--r--src/application-service-marshal.list3
-rw-r--r--src/application-service.xml9
-rw-r--r--src/indicator-application.c62
6 files changed, 188 insertions, 25 deletions
diff --git a/debian/changelog b/debian/changelog
index 39f3545..b166db2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,8 +2,9 @@ indicator-application (0.2.3-0ubuntu2~ppa1~label1) UNRELEASED; urgency=low
* Upstream Merge
* Adding label support into the library
+ * Adding label support into the indicator
- -- Ted Gould <ted@ubuntu.com> Wed, 04 Aug 2010 14:54:30 -0500
+ -- Ted Gould <ted@ubuntu.com> Wed, 04 Aug 2010 14:55:57 -0500
indicator-application (0.2.3-0ubuntu1) maverick; urgency=low
diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c
index 311fcb1..8d9206f 100644
--- a/src/application-service-appstore.c
+++ b/src/application-service-appstore.c
@@ -38,17 +38,20 @@ static gboolean _application_service_server_get_applications (ApplicationService
#include "application-service-server.h"
-#define NOTIFICATION_ITEM_PROP_ID "Id"
-#define NOTIFICATION_ITEM_PROP_CATEGORY "Category"
-#define NOTIFICATION_ITEM_PROP_STATUS "Status"
-#define NOTIFICATION_ITEM_PROP_ICON_NAME "IconName"
-#define NOTIFICATION_ITEM_PROP_AICON_NAME "AttentionIconName"
-#define NOTIFICATION_ITEM_PROP_ICON_PATH "IconThemePath"
-#define NOTIFICATION_ITEM_PROP_MENU "Menu"
-
-#define NOTIFICATION_ITEM_SIG_NEW_ICON "NewIcon"
-#define NOTIFICATION_ITEM_SIG_NEW_AICON "NewAttentionIcon"
-#define NOTIFICATION_ITEM_SIG_NEW_STATUS "NewStatus"
+#define NOTIFICATION_ITEM_PROP_ID "Id"
+#define NOTIFICATION_ITEM_PROP_CATEGORY "Category"
+#define NOTIFICATION_ITEM_PROP_STATUS "Status"
+#define NOTIFICATION_ITEM_PROP_ICON_NAME "IconName"
+#define NOTIFICATION_ITEM_PROP_AICON_NAME "AttentionIconName"
+#define NOTIFICATION_ITEM_PROP_ICON_PATH "IconThemePath"
+#define NOTIFICATION_ITEM_PROP_MENU "Menu"
+#define NOTIFICATION_ITEM_PROP_LABEL "Label"
+#define NOTIFICATION_ITEM_PROP_LABEL_GUIDE "LabelGuide"
+
+#define NOTIFICATION_ITEM_SIG_NEW_ICON "NewIcon"
+#define NOTIFICATION_ITEM_SIG_NEW_AICON "NewAttentionIcon"
+#define NOTIFICATION_ITEM_SIG_NEW_STATUS "NewStatus"
+#define NOTIFICATION_ITEM_SIG_NEW_LABEL "NewLabel"
/* Private Stuff */
struct _ApplicationServiceAppstorePrivate {
@@ -78,6 +81,8 @@ struct _Application {
gchar * aicon;
gchar * menu;
gchar * icon_path;
+ gchar * label;
+ gchar * guide;
gboolean currently_free;
};
@@ -89,6 +94,7 @@ enum {
APPLICATION_ADDED,
APPLICATION_REMOVED,
APPLICATION_ICON_CHANGED,
+ APPLICATION_LABEL_CHANGED,
LAST_SIGNAL
};
@@ -122,8 +128,8 @@ application_service_appstore_class_init (ApplicationServiceAppstoreClass *klass)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (ApplicationServiceAppstoreClass, application_added),
NULL, NULL,
- _application_service_marshal_VOID__STRING_INT_STRING_STRING_STRING,
- G_TYPE_NONE, 5, G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_NONE);
+ _application_service_marshal_VOID__STRING_INT_STRING_STRING_STRING_STRING_STRING,
+ G_TYPE_NONE, 7, G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_NONE);
signals[APPLICATION_REMOVED] = g_signal_new ("application-removed",
G_TYPE_FROM_CLASS(klass),
G_SIGNAL_RUN_LAST,
@@ -138,6 +144,19 @@ application_service_appstore_class_init (ApplicationServiceAppstoreClass *klass)
NULL, NULL,
_application_service_marshal_VOID__INT_STRING,
G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_STRING, G_TYPE_NONE);
+ signals[APPLICATION_LABEL_CHANGED] = g_signal_new ("application-label-changed",
+ G_TYPE_FROM_CLASS(klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (ApplicationServiceAppstoreClass, application_label_changed),
+ NULL, NULL,
+ _application_service_marshal_VOID__INT_STRING_STRING,
+ G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_NONE);
+
+ dbus_g_object_register_marshaller(_application_service_marshal_VOID__STRING_STRING,
+ G_TYPE_NONE,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_INVALID);
dbus_g_object_type_install_info(APPLICATION_SERVICE_APPSTORE_TYPE,
&dbus_glib__application_service_server_object_info);
@@ -253,6 +272,20 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err
app->icon_path = g_strdup("");
}
+ gpointer label_data = g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_LABEL);
+ if (label_data != NULL) {
+ app->label = g_value_dup_string((GValue *)label_data);
+ } else {
+ app->label = g_strdup("");
+ }
+
+ gpointer guide_data = g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_LABEL_GUIDE);
+ if (guide_data != NULL) {
+ app->guide = g_value_dup_string((GValue *)guide_data);
+ } else {
+ app->guide = g_strdup("");
+ }
+
/* TODO: Calling approvers, but we're ignoring the results. So, eh. */
g_list_foreach(priv->approvers, check_with_old_approver, app);
@@ -349,6 +382,12 @@ application_free (Application * app)
if (app->icon_path != NULL) {
g_free(app->icon_path);
}
+ if (app->label != NULL) {
+ g_free(app->label);
+ }
+ if (app->guide != NULL) {
+ g_free(app->guide);
+ }
g_free(app);
return;
@@ -446,6 +485,8 @@ apply_status (Application * app, AppIndicatorStatus status)
app->dbus_name,
app->menu,
app->icon_path,
+ app->label,
+ app->guide,
TRUE);
}
} else {
@@ -586,6 +627,41 @@ new_status (DBusGProxy * proxy, const gchar * status, gpointer data)
return;
}
+/* Called when the Notification Item signals that it
+ has a new label. */
+static void
+new_label (DBusGProxy * proxy, const gchar * label, const gchar * guide, gpointer data)
+{
+ Application * app = (Application *)data;
+ if (!app->validated) return;
+
+ gboolean changed = FALSE;
+
+ if (g_strcmp0(app->label, label) != 0) {
+ changed = TRUE;
+ if (app->label != NULL) {
+ g_free(app->label);
+ app->label = NULL;
+ }
+ app->label = g_strdup(label);
+ }
+
+ if (g_strcmp0(app->guide, guide) != 0) {
+ changed = TRUE;
+ if (app->guide != NULL) {
+ g_free(app->guide);
+ app->guide = NULL;
+ }
+ app->guide = g_strdup(guide);
+ }
+
+ if (changed) {
+ g_signal_emit(app->appstore, signals[APPLICATION_LABEL_CHANGED], 0, app->label, app->guide, TRUE);
+ }
+
+ return;
+}
+
/* Adding a new NotificationItem object from DBus in to the
appstore. First, we need to get the information on it
though. */
@@ -613,6 +689,8 @@ application_service_appstore_application_add (ApplicationServiceAppstore * appst
app->aicon = NULL;
app->menu = NULL;
app->icon_path = NULL;
+ app->label = NULL;
+ app->guide = NULL;
app->currently_free = FALSE;
/* Get the DBus proxy for the NotificationItem interface */
@@ -659,6 +737,11 @@ application_service_appstore_application_add (ApplicationServiceAppstore * appst
NOTIFICATION_ITEM_SIG_NEW_STATUS,
G_TYPE_STRING,
G_TYPE_INVALID);
+ dbus_g_proxy_add_signal(app->dbus_proxy,
+ NOTIFICATION_ITEM_SIG_NEW_LABEL,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_INVALID);
dbus_g_proxy_connect_signal(app->dbus_proxy,
NOTIFICATION_ITEM_SIG_NEW_ICON,
@@ -675,6 +758,11 @@ application_service_appstore_application_add (ApplicationServiceAppstore * appst
G_CALLBACK(new_status),
app,
NULL);
+ dbus_g_proxy_connect_signal(app->dbus_proxy,
+ NOTIFICATION_ITEM_SIG_NEW_LABEL,
+ G_CALLBACK(new_label),
+ app,
+ NULL);
/* Get all the propertiees */
org_freedesktop_DBus_Properties_get_all_async(app->prop_proxy,
@@ -734,13 +822,14 @@ _application_service_server_get_applications (ApplicationServiceAppstore * appst
gint position = 0;
for (listpntr = priv->applications; listpntr != NULL; listpntr = g_list_next(listpntr)) {
+ Application * app = (Application *)listpntr->data;
GValueArray * values = g_value_array_new(5);
GValue value = {0};
/* Icon name */
g_value_init(&value, G_TYPE_STRING);
- g_value_set_string(&value, ((Application *)listpntr->data)->icon);
+ g_value_set_string(&value, app->icon);
g_value_array_append(values, &value);
g_value_unset(&value);
@@ -752,19 +841,31 @@ _application_service_server_get_applications (ApplicationServiceAppstore * appst
/* DBus Address */
g_value_init(&value, G_TYPE_STRING);
- g_value_set_string(&value, ((Application *)listpntr->data)->dbus_name);
+ g_value_set_string(&value, app->dbus_name);
g_value_array_append(values, &value);
g_value_unset(&value);
/* DBus Object */
g_value_init(&value, DBUS_TYPE_G_OBJECT_PATH);
- g_value_set_static_boxed(&value, ((Application *)listpntr->data)->menu);
+ g_value_set_static_boxed(&value, app->menu);
g_value_array_append(values, &value);
g_value_unset(&value);
/* Icon path */
g_value_init(&value, G_TYPE_STRING);
- g_value_set_string(&value, ((Application *)listpntr->data)->icon_path);
+ g_value_set_string(&value, app->icon_path);
+ g_value_array_append(values, &value);
+ g_value_unset(&value);
+
+ /* Label */
+ g_value_init(&value, G_TYPE_STRING);
+ g_value_set_string(&value, app->label);
+ g_value_array_append(values, &value);
+ g_value_unset(&value);
+
+ /* Guide */
+ g_value_init(&value, G_TYPE_STRING);
+ g_value_set_string(&value, app->guide);
g_value_array_append(values, &value);
g_value_unset(&value);
diff --git a/src/application-service-appstore.h b/src/application-service-appstore.h
index e8ba8c1..34c7b1c 100644
--- a/src/application-service-appstore.h
+++ b/src/application-service-appstore.h
@@ -46,6 +46,7 @@ struct _ApplicationServiceAppstoreClass {
void (*application_added) (ApplicationServiceAppstore * appstore, gchar *, gint, gchar *, gchar *, gpointer);
void (*application_removed) (ApplicationServiceAppstore * appstore, gint, gpointer);
void (*application_icon_changed)(ApplicationServiceAppstore * appstore, gint, const gchar *, gpointer);
+ void (*application_label_changed)(ApplicationServiceAppstore * appstore, gint, const gchar *, const gchar *, gpointer);
};
struct _ApplicationServiceAppstore {
diff --git a/src/application-service-marshal.list b/src/application-service-marshal.list
index b49ff41..f432028 100644
--- a/src/application-service-marshal.list
+++ b/src/application-service-marshal.list
@@ -16,6 +16,7 @@
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
-VOID: STRING, INT, STRING, STRING, STRING
+VOID: STRING, INT, STRING, STRING, STRING, STRING, STRING
+VOID: INT, STRING, STRING
VOID: INT, STRING
VOID: STRING, STRING
diff --git a/src/application-service.xml b/src/application-service.xml
index 0b2e959..df49516 100644
--- a/src/application-service.xml
+++ b/src/application-service.xml
@@ -26,7 +26,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
<!-- Methods -->
<method name="GetApplications">
- <arg type="a(sisos)" name="applications" direction="out" />
+ <arg type="a(sisosss)" name="applications" direction="out" />
</method>
<!-- Signals -->
@@ -36,6 +36,8 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
<arg type="s" name="dbusaddress" direction="out" />
<arg type="o" name="dbusobject" direction="out" />
<arg type="s" name="iconpath" direction="out" />
+ <arg type="s" name="label" direction="out" />
+ <arg type="s" name="labelguide" direction="out" />
</signal>
<signal name="ApplicationRemoved">
<arg type="i" name="position" direction="out" />
@@ -44,6 +46,11 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
<arg type="i" name="position" direction="out" />
<arg type="s" name="icon_name" direction="out" />
</signal>
+ <signal name="ApplicationLabelChanged">
+ <arg type="i" name="position" direction="out" />
+ <arg type="s" name="label" direction="out" />
+ <arg type="s" name="guide" direction="out" />
+ </signal>
</interface>
</node>
diff --git a/src/indicator-application.c b/src/indicator-application.c
index 16c3a9f..9c12474 100644
--- a/src/indicator-application.c
+++ b/src/indicator-application.c
@@ -105,8 +105,9 @@ static void disconnected (IndicatorApplication * application);
static void disconnected_helper (gpointer data, gpointer user_data);
static gboolean disconnected_kill (gpointer user_data);
static void disconnected_kill_helper (gpointer data, gpointer user_data);
-static void application_added (DBusGProxy * proxy, const gchar * iconname, gint position, const gchar * dbusaddress, const gchar * dbusobject, const gchar * icon_path, IndicatorApplication * application);
+static void application_added (DBusGProxy * proxy, const gchar * iconname, gint position, const gchar * dbusaddress, const gchar * dbusobject, const gchar * icon_path, const gchar * label, const gchar * guide, IndicatorApplication * application);
static void application_removed (DBusGProxy * proxy, gint position , IndicatorApplication * application);
+static void application_label_changed (DBusGProxy * proxy, gint position, const gchar * label, const gchar * guide, IndicatorApplication * application);
static void application_icon_changed (DBusGProxy * proxy, gint position, const gchar * iconname, IndicatorApplication * application);
static void get_applications (DBusGProxy *proxy, GPtrArray *OUT_applications, GError *error, gpointer userdata);
static void get_applications_helper (gpointer data, gpointer user_data);
@@ -130,19 +131,27 @@ indicator_application_class_init (IndicatorApplicationClass *klass)
io_class->get_entries = get_entries;
io_class->get_location = get_location;
- dbus_g_object_register_marshaller(_application_service_marshal_VOID__STRING_INT_STRING_STRING_STRING,
+ dbus_g_object_register_marshaller(_application_service_marshal_VOID__STRING_INT_STRING_STRING_STRING_STRING_STRING,
G_TYPE_NONE,
G_TYPE_STRING,
G_TYPE_INT,
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
G_TYPE_INVALID);
dbus_g_object_register_marshaller(_application_service_marshal_VOID__INT_STRING,
G_TYPE_NONE,
G_TYPE_INT,
G_TYPE_STRING,
G_TYPE_INVALID);
+ dbus_g_object_register_marshaller(_application_service_marshal_VOID__INT_STRING_STRING,
+ G_TYPE_NONE,
+ G_TYPE_INT,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_INVALID);
return;
}
@@ -280,6 +289,12 @@ connected (IndicatorApplication * application)
G_TYPE_INT,
G_TYPE_STRING,
G_TYPE_INVALID);
+ dbus_g_proxy_add_signal(priv->service_proxy,
+ "ApplicationLabelChanged",
+ G_TYPE_INT,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_INVALID);
/* Connect to them */
g_debug("Connect to them.");
@@ -298,6 +313,11 @@ connected (IndicatorApplication * application)
G_CALLBACK(application_icon_changed),
application,
NULL /* Disconnection Signal */);
+ dbus_g_proxy_connect_signal(priv->service_proxy,
+ "ApplicationLabelChanged",
+ G_CALLBACK(application_label_changed),
+ application,
+ NULL /* Disconnection Signal */);
}
/* Query it for existing applications */
@@ -413,7 +433,7 @@ application_added_search (gconstpointer a, gconstpointer b)
ApplicationEntry and signaling the indicator host that
we've got a new indicator. */
static void
-application_added (DBusGProxy * proxy, const gchar * iconname, gint position, const gchar * dbusaddress, const gchar * dbusobject, const gchar * icon_path, IndicatorApplication * application)
+application_added (DBusGProxy * proxy, const gchar * iconname, gint position, const gchar * dbusaddress, const gchar * dbusobject, const gchar * icon_path, const gchar * label, const gchar * guide, IndicatorApplication * application)
{
g_return_if_fail(IS_INDICATOR_APPLICATION(application));
g_debug("Building new application entry: %s with icon: %s", dbusaddress, iconname);
@@ -456,7 +476,15 @@ application_added (DBusGProxy * proxy, const gchar * iconname, gint position, co
app->entry.image = indicator_image_helper(longname);
g_free(longname);
- app->entry.label = NULL;
+ if (label == NULL || label[0] == '\0') {
+ app->entry.label = NULL;
+ } else {
+ app->entry.label = GTK_LABEL(gtk_label_new(label));
+ gtk_widget_show(GTK_WIDGET(app->entry.label));
+
+ /* TODO: Use guide to size the label better */
+ }
+
app->entry.menu = GTK_MENU(dbusmenu_gtkmenu_new((gchar *)dbusaddress, (gchar *)dbusobject));
/* Keep copies of these for ourself, just in case. */
@@ -514,6 +542,28 @@ application_removed (DBusGProxy * proxy, gint position, IndicatorApplication * a
return;
}
+/* The callback for the signal that the label for an application
+ has changed. */
+static void
+application_label_changed (DBusGProxy * proxy, gint position, const gchar * label, const gchar * guide, IndicatorApplication * application)
+{
+ IndicatorApplicationPrivate * priv = INDICATOR_APPLICATION_GET_PRIVATE(application);
+ ApplicationEntry * app = (ApplicationEntry *)g_list_nth_data(priv->applications, position);
+
+ if (app == NULL) {
+ g_warning("Unable to find application at position: %d", position);
+ return;
+ }
+
+ if (app->entry.label != NULL) {
+ gtk_label_set_text(app->entry.label, label);
+ } else {
+ /* TODO: Handle the case where we didn't have a label */
+ }
+
+ return;
+}
+
/* The callback for the signal that the icon for an application
has changed. */
static void
@@ -565,8 +615,10 @@ get_applications_helper (gpointer data, gpointer user_data)
const gchar * dbus_address = g_value_get_string(g_value_array_get_nth(array, 2));
const gchar * dbus_object = g_value_get_boxed(g_value_array_get_nth(array, 3));
const gchar * icon_path = g_value_get_string(g_value_array_get_nth(array, 4));
+ const gchar * label = g_value_get_string(g_value_array_get_nth(array, 5));
+ const gchar * guide = g_value_get_string(g_value_array_get_nth(array, 6));
- return application_added(NULL, icon_name, position, dbus_address, dbus_object, icon_path, user_data);
+ return application_added(NULL, icon_name, position, dbus_address, dbus_object, icon_path, label, guide, user_data);
}
/* Refs a theme directory, and it may add it to the search