From 03313957df7968ac0e7bf724f4d8484378aabb68 Mon Sep 17 00:00:00 2001 From: Leandro Pereira Date: Sun, 2 Jul 2017 21:09:37 -0700 Subject: Select first item automatically when opening a dual pane I've seen a lot of people using HardInfo and never clicking in the top pane to get more information about a hardware item. By selecting the first item automatically, this gives a clue that more information can be obtained without being obnoxious with popups and other annoyances. --- shell/shell.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'shell') diff --git a/shell/shell.c b/shell/shell.c index bf866e84..10c87b3d 100644 --- a/shell/shell.c +++ b/shell/shell.c @@ -1299,6 +1299,17 @@ void shell_clear_field_updates(void) } } +static gboolean +select_first_item(gpointer data) +{ + GtkTreeIter first; + + if (gtk_tree_model_get_iter_first(shell->info->model, &first)) + gtk_tree_selection_select_iter(shell->info->selection, &first); + + return FALSE; +} + static void module_selected_show_info(ShellModuleEntry * entry, gboolean reload) { @@ -1384,6 +1395,13 @@ module_selected_show_info(ShellModuleEntry * entry, gboolean reload) g_strfreev(groups); g_key_file_free(key_file); g_free(key_data); + + switch (shell->view_type) { + case SHELL_VIEW_DUAL: + case SHELL_VIEW_LOAD_GRAPH: + case SHELL_VIEW_PROGRESS_DUAL: + g_idle_add(select_first_item, NULL); + } } static void info_selected_show_extra(gchar * data) -- cgit v1.2.3