keynav in the new shell



Hey,

the new control-center shell needs some keynav love. Here is a patch
that does 2 things:

- Make the view scroll if the focus moves to an offscreen category

- Arrange things so that only one item is selected in all categories.
Otherwise things become really confusing when using keynav in multiple
categories - you end up with a selected item in each category.

I also want to make arrow navigation work between categories, but that
needs GTK+ changes. I'll look into that.


Matthias
diff --git a/shell/gnome-control-center.c b/shell/gnome-control-center.c
index e859fa9..8e2bc0e 100644
--- a/shell/gnome-control-center.c
+++ b/shell/gnome-control-center.c
@@ -218,6 +218,30 @@ item_activated_cb (CcShellCategoryView *view,
 }
 
 static gboolean
+category_focus_out (GtkWidget          *view,
+                    GdkEventFocus      *event,
+                    GnomeControlCenter *shell)
+{
+  gtk_icon_view_unselect_all (GTK_ICON_VIEW (view));
+
+  return FALSE;
+}
+
+static void
+category_focus_in (GtkWidget          *view,
+                   GdkEventFocus      *event,
+                   GnomeControlCenter *shell)
+{
+  GtkTreePath *path;
+
+  path = gtk_tree_path_new_from_indices (0, -1);
+  gtk_icon_view_select_path (GTK_ICON_VIEW (view), path);
+  gtk_icon_view_set_cursor (GTK_ICON_VIEW (view), path, NULL, FALSE);
+  gtk_tree_path_free (path);
+  
+}
+
+static gboolean
 model_filter_func (GtkTreeModel              *model,
                    GtkTreeIter               *iter,
                    GnomeControlCenterPrivate *priv)
@@ -394,10 +418,14 @@ fill_model (GnomeControlCenter *shell)
   GMenuTreeDirectory *d;
   GMenuTree *tree;
   GtkWidget *vbox;
+  GtkWidget *sw;
 
   GnomeControlCenterPrivate *priv = shell->priv;
 
   vbox = W (priv->builder, "main-vbox");
+  sw = W (priv->builder, "scrolledwindow1");
+  gtk_container_set_focus_vadjustment (GTK_CONTAINER (vbox),
+                                       gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (sw)));
 
   tree = gmenu_tree_lookup (MENUDIR "/gnomecc.menu", 0);
 
@@ -441,6 +469,13 @@ fill_model (GnomeControlCenter *shell)
                             "desktop-item-activated",
                             G_CALLBACK (item_activated_cb), shell);
           gtk_widget_show (categoryview);
+          g_signal_connect (cc_shell_category_view_get_item_view (CC_SHELL_CATEGORY_VIEW (categoryview)),
+                           "focus-in-event",
+                           G_CALLBACK (category_focus_in), shell);
+          g_signal_connect (cc_shell_category_view_get_item_view (CC_SHELL_CATEGORY_VIEW (categoryview)),
+                           "focus-out-event",
+                           G_CALLBACK (category_focus_out), shell);
+
 
           /* add the items from this category to the model */
           for (f = contents; f; f = f->next)


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