summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2010-05-30 02:15:40 -0400
committerMatthias Clasen <mclasen@redhat.com>2010-05-30 02:19:50 -0400
commit5cededa0aaaa8f79f37623855e4918e317086e82 (patch)
treecf63350c8a3400c6cb98930ae559e54745ddb292 /gtk
parentcb8c0763215bd18219c2d32b56e4bfe8a576f6b3 (diff)
downloadgdk-pixbuf-5cededa0aaaa8f79f37623855e4918e317086e82.tar.gz
Improved icon view keynav
Use ::keynav-failed for arrow navigation in icon views, so that it is possible to override error handling. Also add API to get the row/col of an item. With this, it is possible to make arrow keynav span adjacent icon views, which is desired in the new control-center shell. testiconview-keynav demonstrates this.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtk.symbols2
-rw-r--r--gtk/gtkiconview.c91
-rw-r--r--gtk/gtkiconview.h4
3 files changed, 93 insertions, 4 deletions
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index e3ef990ff..f6d1aae50 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -2074,6 +2074,8 @@ gtk_icon_view_set_tooltip_cell
gtk_icon_view_get_tooltip_context
gtk_icon_view_set_tooltip_column
gtk_icon_view_get_tooltip_column
+gtk_icon_view_get_item_row
+gtk_icon_view_get_item_column
#endif
#endif
diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c
index ebb63a12b..1984122fe 100644
--- a/gtk/gtkiconview.c
+++ b/gtk/gtkiconview.c
@@ -4116,7 +4116,16 @@ gtk_icon_view_move_cursor_up_down (GtkIconView *icon_view,
if (!item)
{
- gtk_widget_error_bell (GTK_WIDGET (icon_view));
+ if (!gtk_widget_keynav_failed (GTK_WIDGET (icon_view), direction))
+ {
+ GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (icon_view));
+ if (toplevel)
+ gtk_widget_child_focus (toplevel,
+ direction == GTK_DIR_UP ?
+ GTK_DIR_TAB_BACKWARD :
+ GTK_DIR_TAB_FORWARD);
+ }
+
return;
}
@@ -4206,10 +4215,13 @@ gtk_icon_view_move_cursor_left_right (GtkIconView *icon_view,
gint cell = -1;
gboolean dirty = FALSE;
gint step;
-
+ GtkDirectionType direction;
+
if (!gtk_widget_has_focus (GTK_WIDGET (icon_view)))
return;
-
+
+ direction = count < 0 ? GTK_DIR_LEFT : GTK_DIR_RIGHT;
+
if (!icon_view->priv->cursor_item)
{
GList *list;
@@ -4241,7 +4253,16 @@ gtk_icon_view_move_cursor_left_right (GtkIconView *icon_view,
if (!item)
{
- gtk_widget_error_bell (GTK_WIDGET (icon_view));
+ if (!gtk_widget_keynav_failed (GTK_WIDGET (icon_view), direction))
+ {
+ GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (icon_view));
+ if (toplevel)
+ gtk_widget_child_focus (toplevel,
+ direction == GTK_DIR_LEFT ?
+ GTK_DIR_TAB_BACKWARD :
+ GTK_DIR_TAB_FORWARD);
+ }
+
return;
}
@@ -5918,6 +5939,68 @@ gtk_icon_view_path_is_selected (GtkIconView *icon_view,
}
/**
+ * gtk_icon_view_get_item_row:
+ * @icon_view: a #GtkIconView
+ * @path: the #GtkTreePath of the item
+ *
+ * Gets the row in which the item @path is currently
+ * displayed. Row numbers start at 0.
+ *
+ * Returns: The row in which the item is displayed
+ *
+ * Since: 2.22
+ */
+gint
+gtk_icon_view_get_item_row (GtkIconView *icon_view,
+ GtkTreePath *path)
+{
+ GtkIconViewItem *item;
+
+ g_return_val_if_fail (GTK_IS_ICON_VIEW (icon_view), FALSE);
+ g_return_val_if_fail (icon_view->priv->model != NULL, FALSE);
+ g_return_val_if_fail (path != NULL, FALSE);
+
+ item = g_list_nth_data (icon_view->priv->items,
+ gtk_tree_path_get_indices(path)[0]);
+
+ if (!item)
+ return -1;
+
+ return item->row;
+}
+
+/**
+ * gtk_icon_view_get_item_column:
+ * @icon_view: a #GtkIconView
+ * @path: the #GtkTreePath of the item
+ *
+ * Gets the column in which the item @path is currently
+ * displayed. Column numbers start at 0.
+ *
+ * Returns: The column in which the item is displayed
+ *
+ * Since: 2.22
+ */
+gint
+gtk_icon_view_get_item_column (GtkIconView *icon_view,
+ GtkTreePath *path)
+{
+ GtkIconViewItem *item;
+
+ g_return_val_if_fail (GTK_IS_ICON_VIEW (icon_view), FALSE);
+ g_return_val_if_fail (icon_view->priv->model != NULL, FALSE);
+ g_return_val_if_fail (path != NULL, FALSE);
+
+ item = g_list_nth_data (icon_view->priv->items,
+ gtk_tree_path_get_indices(path)[0]);
+
+ if (!item)
+ return -1;
+
+ return item->col;
+}
+
+/**
* gtk_icon_view_item_activated:
* @icon_view: A #GtkIconView
* @path: The #GtkTreePath to be activated
diff --git a/gtk/gtkiconview.h b/gtk/gtkiconview.h
index 7b9e51d22..ffb53b2b6 100644
--- a/gtk/gtkiconview.h
+++ b/gtk/gtkiconview.h
@@ -154,6 +154,10 @@ void gtk_icon_view_unselect_path (GtkIconView *icon_
GtkTreePath *path);
gboolean gtk_icon_view_path_is_selected (GtkIconView *icon_view,
GtkTreePath *path);
+gint gtk_icon_view_get_item_row (GtkIconView *icon_view,
+ GtkTreePath *path);
+gint gtk_icon_view_get_item_column (GtkIconView *icon_view,
+ GtkTreePath *path);
GList *gtk_icon_view_get_selected_items (GtkIconView *icon_view);
void gtk_icon_view_select_all (GtkIconView *icon_view);
void gtk_icon_view_unselect_all (GtkIconView *icon_view);