From e6a59a7ef8e9f71ac89a1e84008e77f5ea71c905 Mon Sep 17 00:00:00 2001 From: Luke Yelavich Date: Mon, 7 Feb 2011 18:25:03 +1100 Subject: Add accessible name support --- src/indicator-application.c | 94 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 85 insertions(+), 9 deletions(-) (limited to 'src/indicator-application.c') diff --git a/src/indicator-application.c b/src/indicator-application.c index cd83bdf..098644b 100644 --- a/src/indicator-application.c +++ b/src/indicator-application.c @@ -115,11 +115,12 @@ 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 (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_name); 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_name_changed (IndicatorApplication * application, gint position, const gchar * accessible_name); 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 @@ guess_label_size (ApplicationEntry * app) 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_name) { 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 @@ application_added (IndicatorApplication * application, const gchar * iconname, g guess_label_size(app); } + if (accessible_name == NULL || accessible_name[0] == '\0') { + app->entry.accessible_name = NULL; + } else { + app->entry.accessible_name = g_strdup(accessible_name); + } + app->entry.menu = GTK_MENU(dbusmenu_gtkmenu_new((gchar *)dbusaddress, (gchar *)dbusobject)); /* Keep copies of these for ourself, just in case. */ @@ -700,6 +707,65 @@ application_icon_theme_path_changed (IndicatorApplication * application, gint po return; } +/* The callback for the signal that the accessible name for an application + has changed. */ +static void +application_accessible_name_changed (IndicatorApplication * application, gint position, const gchar * accessible_name) +{ + 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_name == NULL || accessible_name[0] == '\0') { + /* No accessible_name, let's see if we need to delete the old one */ + if (app->entry.accessible_name != NULL) { + app->entry.accessible_name = NULL; + signal_reload = TRUE; + } + } else { + app->entry.accessible_name = g_strdup(accessible_name); + + signal_reload = TRUE; + } + + if (signal_reload) { + /* Telling the listener that this has been removed, and then + readded to make it reparse the entry. */ + if (app->entry.label != NULL) { + gtk_widget_hide(GTK_WIDGET(app->entry.label)); + } + + if (app->entry.image != NULL) { + gtk_widget_hide(GTK_WIDGET(app->entry.image)); + } + + if (app->entry.menu != NULL) { + gtk_menu_detach(app->entry.menu); + } + + g_signal_emit(G_OBJECT(application), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED_ID, 0, &(app->entry), TRUE); + + if (app->entry.label != NULL) { + gtk_widget_show(GTK_WIDGET(app->entry.label)); + } + + if (app->entry.image != NULL) { + indicator_image_helper_update(app->entry.image, app->longname); + gtk_widget_show(GTK_WIDGET(app->entry.image)); + } + + g_signal_emit(G_OBJECT(application), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED_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 +781,14 @@ receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, 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_name; + 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_name); application_added(self, iconname, position, dbusaddress, - dbusobject, icon_theme_path, label, guide); + dbusobject, icon_theme_path, label, guide, + accessible_name); } else if (g_strcmp0(signal_name, "ApplicationRemoved") == 0) { gint position; @@ -745,6 +814,12 @@ receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, g_variant_get (parameters, "(i&s&s)", &position, &label, &guide); application_label_changed(self, position, label, guide); } + else if (g_strcmp0(signal_name, "ApplicationAccessibleNameChanged") == 0) { + gint position; + const gchar * accessible_name; + g_variant_get (parameters, "(i&s)", &position, &accessible_name); + application_accessible_name_changed(self, position, accessible_name); + } return; } @@ -768,7 +843,7 @@ get_applications (GObject * obj, GAsyncResult * res, gpointer user_data) 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 +863,12 @@ get_applications_helper (IndicatorApplication * self, GVariant * variant) const gchar * icon_theme_path; const gchar * label; const gchar * guide; - g_variant_get(variant, "(sisosss)", &icon_name, &position, + const gchar * accessible_name; + g_variant_get(variant, "(sisossss)", &icon_name, &position, &dbus_address, &dbus_object, &icon_theme_path, &label, - &guide); + &guide, &accessible_name); - 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_name); } /* Unrefs a theme directory. This may involve removing it from -- cgit v1.2.3 From a958e07de2cb9148a261187600b10598f60bbb69 Mon Sep 17 00:00:00 2001 From: Luke Yelavich Date: Tue, 8 Feb 2011 17:57:32 +1100 Subject: accessible_name -> accessible_desc --- src/indicator-application.c | 48 ++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'src/indicator-application.c') diff --git a/src/indicator-application.c b/src/indicator-application.c index 098644b..785f0b6 100644 --- a/src/indicator-application.c +++ b/src/indicator-application.c @@ -115,12 +115,12 @@ 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 (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_name); +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_name_changed (IndicatorApplication * application, gint position, const gchar * accessible_name); +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); @@ -451,7 +451,7 @@ guess_label_size (ApplicationEntry * app) 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, const gchar * accessible_name) +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); @@ -500,10 +500,10 @@ application_added (IndicatorApplication * application, const gchar * iconname, g guess_label_size(app); } - if (accessible_name == NULL || accessible_name[0] == '\0') { - app->entry.accessible_name = NULL; + if (accessible_desc == NULL || accessible_desc[0] == '\0') { + app->entry.accessible_desc = NULL; } else { - app->entry.accessible_name = g_strdup(accessible_name); + app->entry.accessible_desc = g_strdup(accessible_desc); } app->entry.menu = GTK_MENU(dbusmenu_gtkmenu_new((gchar *)dbusaddress, (gchar *)dbusobject)); @@ -707,10 +707,10 @@ application_icon_theme_path_changed (IndicatorApplication * application, gint po return; } -/* The callback for the signal that the accessible name for an application - has changed. */ +/* The callback for the signal that the accessible description for + an application has changed. */ static void -application_accessible_name_changed (IndicatorApplication * application, gint position, const gchar * accessible_name) +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); @@ -721,14 +721,14 @@ application_accessible_name_changed (IndicatorApplication * application, gint po return; } - if (accessible_name == NULL || accessible_name[0] == '\0') { - /* No accessible_name, let's see if we need to delete the old one */ - if (app->entry.accessible_name != NULL) { - app->entry.accessible_name = NULL; + 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_name = g_strdup(accessible_name); + app->entry.accessible_desc = g_strdup(accessible_desc); signal_reload = TRUE; } @@ -781,14 +781,14 @@ receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, const gchar * icon_theme_path; const gchar * label; const gchar * guide; - const gchar * accessible_name; + const gchar * accessible_desc; g_variant_get (parameters, "(&si&s&o&s&s&s&s)", &iconname, &position, &dbusaddress, &dbusobject, &icon_theme_path, &label, &guide, - &accessible_name); + &accessible_desc); application_added(self, iconname, position, dbusaddress, dbusobject, icon_theme_path, label, guide, - accessible_name); + accessible_desc); } else if (g_strcmp0(signal_name, "ApplicationRemoved") == 0) { gint position; @@ -814,11 +814,11 @@ receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, g_variant_get (parameters, "(i&s&s)", &position, &label, &guide); application_label_changed(self, position, label, guide); } - else if (g_strcmp0(signal_name, "ApplicationAccessibleNameChanged") == 0) { + else if (g_strcmp0(signal_name, "ApplicationAccessibleDescChanged") == 0) { gint position; - const gchar * accessible_name; - g_variant_get (parameters, "(i&s)", &position, &accessible_name); - application_accessible_name_changed(self, position, accessible_name); + const gchar * accessible_desc; + g_variant_get (parameters, "(i&s)", &position, &accessible_desc); + application_accessible_desc_changed(self, position, accessible_desc); } return; @@ -863,12 +863,12 @@ get_applications_helper (IndicatorApplication * self, GVariant * variant) const gchar * icon_theme_path; const gchar * label; const gchar * guide; - const gchar * accessible_name; + const gchar * accessible_desc; g_variant_get(variant, "(sisossss)", &icon_name, &position, &dbus_address, &dbus_object, &icon_theme_path, &label, - &guide, &accessible_name); + &guide, &accessible_desc); - return application_added(self, icon_name, position, dbus_address, dbus_object, icon_theme_path, label, guide, accessible_name); + 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 -- cgit v1.2.3 From 70d0a4d38b318a28abe7d6397c83c5b7ecb55c57 Mon Sep 17 00:00:00 2001 From: Luke Yelavich Date: Fri, 11 Feb 2011 07:53:12 +1100 Subject: Use the ACCESSIBLE_DESC_UPDATE signal to refresh the accessible description. --- src/indicator-application.c | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) (limited to 'src/indicator-application.c') diff --git a/src/indicator-application.c b/src/indicator-application.c index 785f0b6..086692e 100644 --- a/src/indicator-application.c +++ b/src/indicator-application.c @@ -734,33 +734,9 @@ application_accessible_desc_changed (IndicatorApplication * application, gint po } if (signal_reload) { - /* Telling the listener that this has been removed, and then - readded to make it reparse the entry. */ - if (app->entry.label != NULL) { - gtk_widget_hide(GTK_WIDGET(app->entry.label)); - } - - if (app->entry.image != NULL) { - gtk_widget_hide(GTK_WIDGET(app->entry.image)); - } - - if (app->entry.menu != NULL) { - gtk_menu_detach(app->entry.menu); - } - - g_signal_emit(G_OBJECT(application), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED_ID, 0, &(app->entry), TRUE); - - if (app->entry.label != NULL) { - gtk_widget_show(GTK_WIDGET(app->entry.label)); - } - - if (app->entry.image != NULL) { - indicator_image_helper_update(app->entry.image, app->longname); - gtk_widget_show(GTK_WIDGET(app->entry.image)); - } - - g_signal_emit(G_OBJECT(application), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED_ID, 0, &(app->entry), TRUE); - } + /* 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; -- cgit v1.2.3 From ab57d4162744d35bb08280d5922ce4044dec2042 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 23 Feb 2011 20:48:03 -0600 Subject: Adding a missing brace --- src/indicator-application.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/indicator-application.c') diff --git a/src/indicator-application.c b/src/indicator-application.c index 086692e..84864b8 100644 --- a/src/indicator-application.c +++ b/src/indicator-application.c @@ -737,6 +737,7 @@ application_accessible_desc_changed (IndicatorApplication * application, gint po /* 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; -- cgit v1.2.3 From 1cfc978dbf1df5ed02adc9a57f22d67d04621d06 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 24 Feb 2011 21:50:05 -0600 Subject: Switching things around so the icon switches with the description all the way up the stack --- src/indicator-application.c | 70 +++++++++++++++------------------------------ 1 file changed, 23 insertions(+), 47 deletions(-) (limited to 'src/indicator-application.c') diff --git a/src/indicator-application.c b/src/indicator-application.c index 84864b8..455abcb 100644 --- a/src/indicator-application.c +++ b/src/indicator-application.c @@ -118,9 +118,8 @@ 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, 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_changed (IndicatorApplication * application, gint position, const gchar * iconname, const gchar * icondesc); 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); @@ -651,7 +650,7 @@ application_label_changed (IndicatorApplication * application, gint position, co /* The callback for the signal that the icon for an application has changed. */ static void -application_icon_changed (IndicatorApplication * application, gint position, const gchar * iconname) +application_icon_changed (IndicatorApplication * application, gint position, const gchar * iconname, const gchar * icondesc) { IndicatorApplicationPrivate * priv = INDICATOR_APPLICATION_GET_PRIVATE(application); ApplicationEntry * app = (ApplicationEntry *)g_list_nth_data(priv->applications, position); @@ -661,6 +660,11 @@ application_icon_changed (IndicatorApplication * application, gint position, con return; } + if (iconname == NULL) { + g_warning("We can't have a NULL icon name on %d", position); + return; + } + /* We make a long name using the suffix, and if that icon is available we want to use it. Otherwise we'll just use the name we were given. */ @@ -675,6 +679,19 @@ application_icon_changed (IndicatorApplication * application, gint position, con } indicator_image_helper_update(app->entry.image, app->longname); + if (g_strcmp0(app->entry.accessible_desc, icondesc) != 0) { + if (app->entry.accessible_desc != NULL) { + g_free((gchar *)app->entry.accessible_desc); + app->entry.accessible_desc = NULL; + } + + if (icondesc != NULL && icondesc[0] != '\0') { + app->entry.accessible_desc = g_strdup(icondesc); + } + + g_signal_emit(G_OBJECT(application), INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE_ID, 0, &(app->entry), TRUE); + } + return; } @@ -707,42 +724,6 @@ application_icon_theme_path_changed (IndicatorApplication * application, gint po 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, @@ -775,8 +756,9 @@ receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, else if (g_strcmp0(signal_name, "ApplicationIconChanged") == 0) { gint position; const gchar * iconname; - g_variant_get (parameters, "(i&s)", &position, &iconname); - application_icon_changed(self, position, iconname); + const gchar * icondesc; + g_variant_get (parameters, "(i&s&s)", &position, &iconname, &icondesc); + application_icon_changed(self, position, iconname, icondesc); } else if (g_strcmp0(signal_name, "ApplicationIconThemePathChanged") == 0) { gint position; @@ -791,12 +773,6 @@ receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, 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; } -- cgit v1.2.3