[gnome-software] Add accessible descriptions to tiles



commit 9b8a719926d13643995640f7efebe855b61e2b99
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Sep 20 16:52:31 2013 -0400

    Add accessible descriptions to tiles
    
    We use the app summary as the accessible description for each
    tile. That way, all the information thats visible on the screen
    is also available in accessible form.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=708489

 src/gs-app-tile.c     |   29 ++++++++++++++++-------------
 src/gs-feature-tile.c |   36 ++++++++++++++++++++++++++++++++++++
 src/gs-popular-tile.c |   29 ++++++++++++++++-------------
 3 files changed, 68 insertions(+), 26 deletions(-)
---
diff --git a/src/gs-app-tile.c b/src/gs-app-tile.c
index 7d19d61..3defad6 100644
--- a/src/gs-app-tile.c
+++ b/src/gs-app-tile.c
@@ -61,6 +61,8 @@ app_state_changed (GsApp *app, GParamSpec *pspec, GsAppTile *tile)
 {
         GsAppTilePrivate *priv;
         AtkObject *accessible;
+       gchar *name;
+       gboolean installed;
 
         priv = gs_app_tile_get_instance_private (tile);
         accessible = gtk_widget_get_accessible (priv->button);
@@ -70,24 +72,25 @@ app_state_changed (GsApp *app, GParamSpec *pspec, GsAppTile *tile)
         case GS_APP_STATE_INSTALLING:
         case GS_APP_STATE_REMOVING:
         case GS_APP_STATE_UPDATABLE:
-                gtk_widget_show (priv->eventbox);
-                if (GTK_IS_ACCESSIBLE (accessible)) {
-                        gchar *name;
-                        name = g_strdup_printf ("%s (%s)",
-                                                gs_app_get_name (app),
-                                                _("Installed"));
-                        atk_object_set_name (accessible, name);
-                        g_free (name);
-                }
+               installed = TRUE;
+               name = g_strdup_printf ("%s (%s)",
+                                       gs_app_get_name (app),
+                                       _("Installed"));
                 break;
         case GS_APP_STATE_AVAILABLE:
         default:
-                gtk_widget_hide (priv->eventbox);
-                if (GTK_IS_ACCESSIBLE (accessible)) {
-                        atk_object_set_name (accessible, gs_app_get_name (app));
-                }
+               installed = FALSE;
+               name = g_strdup (gs_app_get_name (app));
                 break;
         }
+
+       gtk_widget_set_visible (priv->eventbox, installed);
+
+       if (GTK_IS_ACCESSIBLE (accessible)) {
+               atk_object_set_name (accessible, name);
+               atk_object_set_description (accessible, gs_app_get_summary (app));
+       }
+       g_free (name);
 }
 
 void
diff --git a/src/gs-feature-tile.c b/src/gs-feature-tile.c
index 7f6c214..90b5b7f 100644
--- a/src/gs-feature-tile.c
+++ b/src/gs-feature-tile.c
@@ -56,6 +56,38 @@ gs_feature_tile_get_app (GsFeatureTile *tile)
        return priv->app;
 }
 
+static void
+app_state_changed (GsApp *app, GParamSpec *pspec, GsFeatureTile *tile)
+{
+        GsFeatureTilePrivate *priv;
+        AtkObject *accessible;
+        gchar *name;
+
+        priv = gs_feature_tile_get_instance_private (tile);
+        accessible = gtk_widget_get_accessible (priv->button);
+
+        switch (gs_app_get_state (app)) {
+        case GS_APP_STATE_INSTALLED:
+        case GS_APP_STATE_INSTALLING:
+        case GS_APP_STATE_REMOVING:
+        case GS_APP_STATE_UPDATABLE:
+                name = g_strdup_printf ("%s (%s)",
+                                        gs_app_get_name (app),
+                                        _("Installed"));
+                break;
+        case GS_APP_STATE_AVAILABLE:
+        default:
+                name = g_strdup (gs_app_get_name (app));
+                break;
+        }
+
+        if (GTK_IS_ACCESSIBLE (accessible)) {
+                atk_object_set_name (accessible, name);
+                atk_object_set_description (accessible, gs_app_get_summary (app));
+        }
+        g_free (name);
+}
+
 void
 gs_feature_tile_set_app (GsFeatureTile *tile, GsApp *app)
 {
@@ -70,6 +102,10 @@ gs_feature_tile_set_app (GsFeatureTile *tile, GsApp *app)
        g_clear_object (&priv->app);
        priv->app = g_object_ref (app);
 
+        g_signal_connect (priv->app, "notify::state",
+                          G_CALLBACK (app_state_changed), tile);
+        app_state_changed (priv->app, NULL, tile);
+
        gtk_label_set_label (GTK_LABEL (priv->title), gs_app_get_name (app));
        gtk_label_set_label (GTK_LABEL (priv->subtitle), gs_app_get_summary (app));
        data = g_strdup_printf (
diff --git a/src/gs-popular-tile.c b/src/gs-popular-tile.c
index 512ab63..78c0ddf 100644
--- a/src/gs-popular-tile.c
+++ b/src/gs-popular-tile.c
@@ -60,6 +60,8 @@ app_state_changed (GsApp *app, GParamSpec *pspec, GsPopularTile *tile)
 {
        GsPopularTilePrivate *priv;
        AtkObject *accessible;
+       gchar *name;
+       gboolean installed;
 
        priv = gs_popular_tile_get_instance_private (tile);
        accessible = gtk_widget_get_accessible (priv->button);
@@ -69,24 +71,25 @@ app_state_changed (GsApp *app, GParamSpec *pspec, GsPopularTile *tile)
        case GS_APP_STATE_INSTALLING:
        case GS_APP_STATE_REMOVING:
        case GS_APP_STATE_UPDATABLE:
-               gtk_widget_show (priv->eventbox);
-               if (GTK_IS_ACCESSIBLE (accessible)) {
-                       gchar *name;
-                       name = g_strdup_printf ("%s (%s)",
-                                               gs_app_get_name (app),
-                                               _("Installed"));
-                       atk_object_set_name (accessible, name);
-                       g_free (name);
-               }
+               installed = TRUE;
+               name = g_strdup_printf ("%s (%s)",
+                                       gs_app_get_name (app),
+                                       _("Installed"));
                break;
        case GS_APP_STATE_AVAILABLE:
        default:
-               gtk_widget_hide (priv->eventbox);
-               if (GTK_IS_ACCESSIBLE (accessible)) {
-                       atk_object_set_name (accessible, gs_app_get_name (app));
-               }
+               installed = FALSE;
+               name = g_strdup (gs_app_get_name (app));
                break;
        }
+
+       gtk_widget_set_visible (priv->eventbox, installed);
+
+       if (GTK_IS_ACCESSIBLE (accessible)) {
+               atk_object_set_name (accessible, name);
+               atk_object_set_description (accessible, gs_app_get_summary (app));
+       }
+       g_free (name);
 }
 
 void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]