← Back to team overview

ayatana-commits team mailing list archive

[Merge] lp:~themuso/indicator-application/a11y-desc into lp:indicator-application

 

Luke Yelavich has proposed merging lp:~themuso/indicator-application/a11y-desc into lp:indicator-application.

Requested reviews:
  Indicator Applet Developers (indicator-applet-developers)

For more details, see:
https://code.launchpad.net/~themuso/indicator-application/a11y-desc/+merge/49583
-- 
https://code.launchpad.net/~themuso/indicator-application/a11y-desc/+merge/49583
Your team ayatana-commits is subscribed to branch lp:indicator-application.
=== modified file 'src/application-service-appstore.c'
--- src/application-service-appstore.c	2011-02-07 18:01:11 +0000
+++ src/application-service-appstore.c	2011-02-14 02:51:10 +0000
@@ -49,12 +49,14 @@
 #define NOTIFICATION_ITEM_PROP_LABEL                 "XAyatanaLabel"
 #define NOTIFICATION_ITEM_PROP_LABEL_GUIDE           "XAyatanaLabelGuide"
 #define NOTIFICATION_ITEM_PROP_ORDERING_INDEX        "XAyatanaOrderingIndex"
+#define NOTIFICATION_ITEM_PROP_ACCESSIBLE_DESC       "AccessibleDesc"
 
 #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              "XAyatanaNewLabel"
 #define NOTIFICATION_ITEM_SIG_NEW_ICON_THEME_PATH    "NewIconThemePath"
+#define NOTIFICATION_ITEM_SIG_NEW_ACCESSIBLE_DESC    "NewAccessibleDesc"
 
 #define OVERRIDE_GROUP_NAME                          "Ordering Index Overrides"
 #define OVERRIDE_FILE_NAME                           "ordering-override.keyfile"
@@ -104,6 +106,7 @@
 	gchar * icon_theme_path;
 	gchar * label;
 	gchar * guide;
+	gchar * accessible_desc;
 	gboolean currently_free;
 	guint ordering_index;
 	GList * approved_by;
@@ -431,7 +434,7 @@
 	GVariant * menu = NULL, * id = NULL, * category = NULL,
 	         * status = NULL, * icon_name = NULL, * aicon_name = NULL,
 	         * icon_theme_path = NULL, * index = NULL, * label = NULL,
-	         * guide = NULL;
+	         * guide = NULL, * accessible_desc = NULL;
 
 	GVariant * properties = g_dbus_proxy_call_finish(app->props, res, &error);
 
@@ -474,6 +477,8 @@
 			label = g_variant_ref(value);
 		} else if (g_strcmp0(name, NOTIFICATION_ITEM_PROP_LABEL_GUIDE) == 0) {
 			guide = g_variant_ref(value);
+		} else if (g_strcmp0(name, NOTIFICATION_ITEM_PROP_ACCESSIBLE_DESC) == 0) {
+			accessible_desc = g_variant_ref(value);
 		} /* else ignore */
 	}
 	g_variant_iter_free (iter);
@@ -528,6 +533,12 @@
 			app->guide = g_strdup("");
 		}
 
+		if (accessible_desc != NULL) {
+			app->accessible_desc = g_variant_dup_string(accessible_desc, NULL);
+		} else {
+			app->accessible_desc = g_strdup("");
+		}
+
 		g_list_foreach(priv->approvers, check_with_old_approver, app);
 
 		apply_status(app);
@@ -548,6 +559,7 @@
 	if (index)           g_variant_unref (index);
 	if (label)           g_variant_unref (label);
 	if (guide)           g_variant_unref (guide);
+	if (accessible_desc) g_variant_unref (accessible_desc);
 
 	return;
 }
@@ -725,6 +737,9 @@
 	if (app->approved_by != NULL) {
 		g_list_free(app->approved_by);
 	}
+	if (app->accessible_desc != NULL) {
+		g_free(app->accessible_desc);
+	}
 
 	g_free(app);
 	return;
@@ -833,11 +848,12 @@
 		if (app->visible_state == VISIBLE_STATE_HIDDEN) {
 			/* Put on panel */
 			emit_signal (appstore, "ApplicationAdded",
-				     g_variant_new ("(sisosss)", newicon,
+				     g_variant_new ("(sisossss)", newicon,
 			                            get_position(app),
 			                            app->dbus_name, app->menu,
 			                            app->icon_theme_path,
-			                            app->label, app->guide));
+			                            app->label, app->guide,
+			                            app->accessible_desc));
 		} else {
 			/* Icon update */
 			gint position = get_position(app);
@@ -926,6 +942,32 @@
 	return;
 }
 
+static void
+new_accessible_desc (Application * app, const gchar * accessible_desc)
+{
+	gboolean changed = FALSE;
+
+	if (g_strcmp0(app->accessible_desc, accessible_desc) != 0) {
+		changed = TRUE;
+		if (app->accessible_desc != NULL) {
+			g_free(app->accessible_desc);
+			app->accessible_desc = NULL;
+		}
+		app->accessible_desc = g_strdup(accessible_desc);
+	}
+
+	if (changed) {
+		gint position = get_position(app);
+		if (position == -1) return;
+
+		emit_signal (app->appstore, "ApplicationAccessibleNameChanged",
+			     g_variant_new ("(is)", position,
+		             app->accessible_desc != NULL ? app->accessible_desc : ""));
+	}
+
+	return;
+}
+
 /* Adding a new NotificationItem object from DBus in to the
    appstore.  First, we need to get the information on it
    though. */
@@ -1124,6 +1166,11 @@
 		g_variant_get(parameters, "(&s&s)", &label, &guide);
 		new_label(app, label, guide);
 	}
+	else if (g_strcmp0(signal_name, NOTIFICATION_ITEM_SIG_NEW_ACCESSIBLE_DESC) == 0) {
+		const gchar * accessible_desc;
+		g_variant_get(parameters, "(&s)", &accessible_desc);
+		new_accessible_desc(app, accessible_desc);
+        }
 
 	return;
 }
@@ -1212,18 +1259,18 @@
 				continue;
 			}
 
-			g_variant_builder_add (&builder, "(sisosss)", app->icon,
+			g_variant_builder_add (&builder, "(sisossss)", app->icon,
 								   position++, app->dbus_name, app->menu,
 								   app->icon_theme_path, app->label,
-								   app->guide);
+								   app->guide, app->accessible_desc);
 		}
 
 		out = g_variant_builder_end(&builder);
 	} else {
 		GError * error = NULL;
-		out = g_variant_parse(g_variant_type_new("a(sisosss)"), "[]", NULL, NULL, &error);
+		out = g_variant_parse(g_variant_type_new("a(sisossss)"), "[]", NULL, NULL, &error);
 		if (error != NULL) {
-			g_warning("Unable to parse '[]' as a 'a(sisosss)': %s", error->message);
+			g_warning("Unable to parse '[]' as a 'a(sisossss)': %s", error->message);
 			out = NULL;
 			g_error_free(error);
 		}

=== modified file 'src/application-service.xml'
--- src/application-service.xml	2011-01-29 02:25:32 +0000
+++ src/application-service.xml	2011-02-14 02:51:10 +0000
@@ -26,7 +26,7 @@
 
 <!-- Methods -->
 		<method name="GetApplications">
-			<arg type="a(sisosss)" name="applications" direction="out" />
+			<arg type="a(sisossss)" name="applications" direction="out" />
 		</method>
 		<method name="ApplicationScrollEvent">
 			<arg type="s" name="dbusaddress" direction="in" />
@@ -44,6 +44,7 @@
 			<arg type="s" name="iconpath" direction="out" />
 			<arg type="s" name="label" direction="out" />
 			<arg type="s" name="labelguide" direction="out" />
+			<arg type="s" name="accessibledesc" direction="out" />
 		</signal>
 		<signal name="ApplicationRemoved">
 			<arg type="i" name="position" direction="out" />
@@ -61,5 +62,9 @@
 			<arg type="s" name="label" direction="out" />
 			<arg type="s" name="guide" direction="out" />
 		</signal>
+		<signal name="ApplicationAccessibleDescChanged">
+			<arg type="i" name="position" direction="out" />
+			<arg type="s" name="accessible_desc" direction="out" />
+		</signal>
 	</interface>
 </node>

=== modified file 'src/indicator-application.c'
--- src/indicator-application.c	2011-01-29 02:25:32 +0000
+++ src/indicator-application.c	2011-02-14 02:51:10 +0000
@@ -115,11 +115,12 @@
 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 (IndicatorApplication * application, const gchar * iconname, gint position, const gchar * dbusaddress, const gchar * dbusobject, const gchar * icon_theme_path, const gchar * label, const gchar * guide);
+static void application_added (IndicatorApplication * application, const gchar * iconname, gint position, const gchar * dbusaddress, const gchar * dbusobject, const gchar * icon_theme_path, const gchar * label, const gchar * guide, const gchar * accessible_desc);
 static void application_removed (IndicatorApplication * application, gint position);
 static void application_label_changed (IndicatorApplication * application, gint position, const gchar * label, const gchar * guide);
 static void application_icon_changed (IndicatorApplication * application, gint position, const gchar * iconname);
 static void application_icon_theme_path_changed (IndicatorApplication * application, gint position, const gchar * icon_theme_path);
+static void application_accessible_desc_changed (IndicatorApplication * application, gint position, const gchar * accessible_desc);
 static void get_applications (GObject * obj, GAsyncResult * res, gpointer user_data);
 static void get_applications_helper (IndicatorApplication * self, GVariant * variant);
 static void theme_dir_unref(IndicatorApplication * ia, const gchar * dir);
@@ -450,7 +451,7 @@
    ApplicationEntry and signaling the indicator host that
    we've got a new indicator. */
 static void
-application_added (IndicatorApplication * application, const gchar * iconname, gint position, const gchar * dbusaddress, const gchar * dbusobject, const gchar * icon_theme_path, const gchar * label, const gchar * guide)
+application_added (IndicatorApplication * application, const gchar * iconname, gint position, const gchar * dbusaddress, const gchar * dbusobject, const gchar * icon_theme_path, const gchar * label, const gchar * guide, const gchar * accessible_desc)
 {
 	g_return_if_fail(IS_INDICATOR_APPLICATION(application));
 	g_debug("Building new application entry: %s  with icon: %s at position %i", dbusaddress, iconname, position);
@@ -499,6 +500,12 @@
 		guess_label_size(app);
 	}
 
+	if (accessible_desc == NULL || accessible_desc[0] == '\0') {
+		app->entry.accessible_desc = NULL;
+	} else {
+		app->entry.accessible_desc = g_strdup(accessible_desc);
+	}
+
 	app->entry.menu = GTK_MENU(dbusmenu_gtkmenu_new((gchar *)dbusaddress, (gchar *)dbusobject));
 
 	/* Keep copies of these for ourself, just in case. */
@@ -700,6 +707,41 @@
 	return;
 }
 
+/* The callback for the signal that the accessible description for
+   an application has changed. */
+static void
+application_accessible_desc_changed (IndicatorApplication * application, gint position, const gchar * accessible_desc)
+{
+	IndicatorApplicationPrivate * priv = INDICATOR_APPLICATION_GET_PRIVATE(application);
+	ApplicationEntry * app = (ApplicationEntry *)g_list_nth_data(priv->applications, position);
+	gboolean signal_reload = FALSE;
+
+	if (app == NULL) {
+		g_warning("Unable to find application at position: %d", position);
+		return;
+	}
+
+	if (accessible_desc == NULL || accessible_desc[0] == '\0') {
+		/* No accessible_desc, let's see if we need to delete the old one */
+		if (app->entry.accessible_desc != NULL) {
+			app->entry.accessible_desc = NULL;
+			signal_reload = TRUE;
+		}
+	} else {
+		app->entry.accessible_desc = g_strdup(accessible_desc);
+
+		signal_reload = TRUE;
+	}
+
+	if (signal_reload) {
+		/* Unlike the label change, we don't need to remove and re-add
+		   the indicator to update the accessible description. */
+		g_signal_emit(G_OBJECT(application), INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE_ID, 0, &(app->entry), TRUE);
+
+	return;
+
+}
+
 /* Receives all signals from the service, routed to the appropriate functions */
 static void
 receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name,
@@ -715,11 +757,14 @@
 		const gchar * icon_theme_path;
 		const gchar * label;
 		const gchar * guide;
-		g_variant_get (parameters, "(&si&s&o&s&s&s)", &iconname,
+		const gchar * accessible_desc;
+		g_variant_get (parameters, "(&si&s&o&s&s&s&s)", &iconname,
 		               &position, &dbusaddress, &dbusobject,
-		               &icon_theme_path, &label, &guide);
+		               &icon_theme_path, &label, &guide,
+		               &accessible_desc);
 		application_added(self, iconname, position, dbusaddress,
-		                  dbusobject, icon_theme_path, label, guide);
+		                  dbusobject, icon_theme_path, label, guide,
+		                  accessible_desc);
 	}
 	else if (g_strcmp0(signal_name, "ApplicationRemoved") == 0) {
 		gint position;
@@ -745,6 +790,12 @@
 		g_variant_get (parameters, "(i&s&s)", &position, &label, &guide);
 		application_label_changed(self, position, label, guide);
 	}
+	else if (g_strcmp0(signal_name, "ApplicationAccessibleDescChanged") == 0) {
+		gint position;
+		const gchar * accessible_desc;
+		g_variant_get (parameters, "(i&s)", &position, &accessible_desc);
+		application_accessible_desc_changed(self, position, accessible_desc);
+	}
 
 	return;
 }
@@ -768,7 +819,7 @@
 		return;
 	}
 
-	g_variant_get(result, "(a(sisosss))", &iter);
+	g_variant_get(result, "(a(sisossss))", &iter);
 	while ((child = g_variant_iter_next_value (iter)))
 		get_applications_helper(self, child);
 	g_variant_iter_free (iter);
@@ -788,11 +839,12 @@
 	const gchar * icon_theme_path;
 	const gchar * label;
 	const gchar * guide;
-	g_variant_get(variant, "(sisosss)", &icon_name, &position,
+	const gchar * accessible_desc;
+	g_variant_get(variant, "(sisossss)", &icon_name, &position,
 	              &dbus_address, &dbus_object, &icon_theme_path, &label,
-	              &guide);
+	              &guide, &accessible_desc);
 
-	return application_added(self, icon_name, position, dbus_address, dbus_object, icon_theme_path, label, guide);
+	return application_added(self, icon_name, position, dbus_address, dbus_object, icon_theme_path, label, guide, accessible_desc);
 }
 
 /* Unrefs a theme directory.  This may involve removing it from


Follow ups