diff options
author | Ted Gould <ted@gould.cx> | 2010-08-10 15:22:29 -0500 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2010-08-10 15:22:29 -0500 |
commit | a34479eb97125446bfb5a8c6b86e2c6552319fa1 (patch) | |
tree | d2de51290fe0e362099528e8778f8d95799d895b /src/application-service-appstore.c | |
parent | d2c36a2dc643c8760556736067e1134aed674800 (diff) | |
parent | d7c7a2ae1656af559bfbdb2716fe381d313b5a53 (diff) | |
download | libayatana-appindicator-a34479eb97125446bfb5a8c6b86e2c6552319fa1.tar.gz libayatana-appindicator-a34479eb97125446bfb5a8c6b86e2c6552319fa1.tar.bz2 libayatana-appindicator-a34479eb97125446bfb5a8c6b86e2c6552319fa1.zip |
Updating to trunk
Diffstat (limited to 'src/application-service-appstore.c')
-rw-r--r-- | src/application-service-appstore.c | 124 |
1 files changed, 116 insertions, 8 deletions
diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 2aa418a..5fc4f9b 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -46,11 +46,14 @@ static gboolean _application_service_server_get_applications (ApplicationService #define NOTIFICATION_ITEM_PROP_AICON_NAME "AttentionIconName" #define NOTIFICATION_ITEM_PROP_ICON_THEME_PATH "IconThemePath" #define NOTIFICATION_ITEM_PROP_MENU "Menu" +#define NOTIFICATION_ITEM_PROP_LABEL "Label" +#define NOTIFICATION_ITEM_PROP_LABEL_GUIDE "LabelGuide" #define NOTIFICATION_ITEM_PROP_ORDERING_INDEX "OrderingIndex" #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" #define NOTIFICATION_ITEM_SIG_NEW_ICON_THEME_PATH "NewIconThemePath" /* Private Stuff */ @@ -80,6 +83,8 @@ struct _Application { gchar * aicon; gchar * menu; gchar * icon_theme_path; + gchar * label; + gchar * guide; gboolean currently_free; guint ordering_index; }; @@ -92,6 +97,7 @@ enum { APPLICATION_ADDED, APPLICATION_REMOVED, APPLICATION_ICON_CHANGED, + APPLICATION_LABEL_CHANGED, APPLICATION_ICON_THEME_PATH_CHANGED, LAST_SIGNAL }; @@ -126,8 +132,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, @@ -149,6 +155,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, 3, 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); @@ -269,6 +288,20 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err app->ordering_index = g_value_get_uint(ordering_index_data); } + 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); @@ -365,6 +398,12 @@ application_free (Application * app) if (app->icon_theme_path != NULL) { g_free(app->icon_theme_path); } + if (app->label != NULL) { + g_free(app->label); + } + if (app->guide != NULL) { + g_free(app->guide); + } g_free(app); return; @@ -460,6 +499,8 @@ apply_status (Application * app, AppIndicatorStatus status) app->dbus_name, app->menu, app->icon_theme_path, + app->label, + app->guide, TRUE); } } else { @@ -626,6 +667,48 @@ new_icon_theme_path (DBusGProxy * proxy, const gchar * icon_theme_path, gpointer 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) { + gint position = get_position(app); + if (position == -1) return; + + g_signal_emit(app->appstore, signals[APPLICATION_LABEL_CHANGED], 0, + position, + app->label != NULL ? app->label : "", + app->guide != NULL ? 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. */ @@ -653,6 +736,8 @@ application_service_appstore_application_add (ApplicationServiceAppstore * appst app->aicon = NULL; app->menu = NULL; app->icon_theme_path = NULL; + app->label = NULL; + app->guide = NULL; app->currently_free = FALSE; app->ordering_index = 0; @@ -704,7 +789,12 @@ application_service_appstore_application_add (ApplicationServiceAppstore * appst NOTIFICATION_ITEM_SIG_NEW_ICON_THEME_PATH, 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, G_CALLBACK(new_icon), @@ -725,7 +815,12 @@ application_service_appstore_application_add (ApplicationServiceAppstore * appst G_CALLBACK(new_icon_theme_path), 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, NOTIFICATION_ITEM_DBUS_IFACE, @@ -781,13 +876,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); @@ -799,19 +895,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_theme_path); + g_value_set_string(&value, app->icon_theme_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); |