summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeandro Pereira <leandro@hardinfo.org>2017-07-02 21:09:37 -0700
committerLeandro Pereira <leandro@hardinfo.org>2017-07-02 21:09:37 -0700
commit03313957df7968ac0e7bf724f4d8484378aabb68 (patch)
tree7acd7180afeff39d468ea027a52972663374d046
parent62d230e4188528d2d71206ec2ae2f75e26000649 (diff)
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.
-rw-r--r--shell/shell.c18
1 files changed, 18 insertions, 0 deletions
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)