[Xfce4-commits] <xfce4-settings:nick/settings-manager> Directly activate item if it's the only visible item.
Nick Schermer
noreply at xfce.org
Thu Jan 26 19:34:01 CET 2012
Updating branch refs/heads/nick/settings-manager
to d5c9b5022d12c0a647e0cc2fdd21a17526da618d (commit)
from 47894fafb5acf0116abd8bc02c61593dc8440af6 (commit)
commit d5c9b5022d12c0a647e0cc2fdd21a17526da618d
Author: Nick Schermer <nick at xfce.org>
Date: Thu Jan 26 19:32:57 2012 +0100
Directly activate item if it's the only visible item.
.../xfce-settings-manager-dialog.c | 35 +++++++++++++++++--
1 files changed, 31 insertions(+), 4 deletions(-)
diff --git a/xfce4-settings-manager/xfce-settings-manager-dialog.c b/xfce4-settings-manager/xfce-settings-manager-dialog.c
index 0f34ad8..ae0e507 100644
--- a/xfce4-settings-manager/xfce-settings-manager-dialog.c
+++ b/xfce4-settings-manager/xfce-settings-manager-dialog.c
@@ -653,6 +653,8 @@ xfce_settings_manager_dialog_entry_key_press (GtkWidget *entry,
GList *li;
DialogCategory *category;
GtkTreePath *path;
+ gint n_visible_items;
+ GtkTreeModel *model;
if (event->keyval == GDK_Escape)
{
@@ -662,6 +664,22 @@ xfce_settings_manager_dialog_entry_key_press (GtkWidget *entry,
}
else if (event->keyval == GDK_Return)
{
+ /* count visible children */
+ n_visible_items = 0;
+ for (li = dialog->categories; li != NULL; li = li->next)
+ {
+ category = li->data;
+ if (gtk_widget_get_visible (category->box))
+ {
+ model = exo_icon_view_get_model (EXO_ICON_VIEW (category->iconview));
+ n_visible_items += gtk_tree_model_iter_n_children (model, NULL);
+
+ /* stop searching if there are more then 1 items */
+ if (n_visible_items > 1)
+ break;
+ }
+ }
+
for (li = dialog->categories; li != NULL; li = li->next)
{
category = li->data;
@@ -670,12 +688,21 @@ xfce_settings_manager_dialog_entry_key_press (GtkWidget *entry,
if (!gtk_widget_get_visible (category->box))
continue;
- /* select first item */
+
path = gtk_tree_path_new_first ();
- exo_icon_view_set_cursor (EXO_ICON_VIEW (category->iconview), path, NULL, FALSE);
+ if (n_visible_items == 1)
+ {
+ /* activate this one item */
+ exo_icon_view_item_activated (EXO_ICON_VIEW (category->iconview), path);
+ }
+ else
+ {
+ /* select first item in view */
+ exo_icon_view_set_cursor (EXO_ICON_VIEW (category->iconview),
+ path, NULL, FALSE);
+ gtk_widget_grab_focus (category->iconview);
+ }
gtk_tree_path_free (path);
-
- gtk_widget_grab_focus (category->iconview);
break;
}
More information about the Xfce4-commits
mailing list