aboutsummaryrefslogtreecommitdiff
path: root/shell/shell.c
diff options
context:
space:
mode:
authorSimon Quigley <tsimonq2@ubuntu.com>2017-11-25 13:35:48 -0600
committerSimon Quigley <tsimonq2@ubuntu.com>2017-11-25 13:35:48 -0600
commit628a525ae2961f0461172613a0675dab6754c65e (patch)
tree9c16631a75cf703771196cabf274ee9eef9723d8 /shell/shell.c
parentab16195359ad146263dbd7b5ea2d94316caee627 (diff)
parent11e616945340e87a1f567ab92e6dfac3068875b1 (diff)
Update upstream source from tag 'upstream/0.5.1+git20171103'
Update to upstream version '0.5.1+git20171103' with Debian dir 12de6f1245697675c1d76dc1085c08844d715cb0
Diffstat (limited to 'shell/shell.c')
-rw-r--r--shell/shell.c67
1 files changed, 61 insertions, 6 deletions
diff --git a/shell/shell.c b/shell/shell.c
index b81e77b6..8688f9ac 100644
--- a/shell/shell.c
+++ b/shell/shell.c
@@ -447,7 +447,7 @@ static void create_window(void)
shell->status = gtk_label_new("");
#if GTK_CHECK_VERSION(3, 0, 0)
- gtk_widget_set_valign(GTK_MISC(shell->status), GTK_ALIGN_CENTER);
+ gtk_widget_set_valign(GTK_WIDGET(shell->status), GTK_ALIGN_CENTER);
#else
gtk_misc_set_alignment(GTK_MISC(shell->status), 0.0, 0.5);
#endif
@@ -512,7 +512,8 @@ static void menu_item_set_icon_always_visible(Shell *shell,
path = g_strdup_printf("%s/%s", parent_path, item_id);
menuitem = gtk_ui_manager_get_widget(shell->ui_manager, path);
-#if GTK_CHECK_VERSION(2, 18, 0)
+#if GTK_CHECK_VERSION(3, 0, 0)
+#else
gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(menuitem), TRUE);
#endif
g_free(path);
@@ -690,7 +691,7 @@ ShellSummary *summary_new(void)
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
#if GTK_CHECK_VERSION(3, 0, 0)
- gtk_container_add(GTK_SCROLLED_WINDOW(summary->scroll),
+ gtk_container_add(GTK_CONTAINER(summary->scroll),
summary->view);
#else
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(summary->scroll),
@@ -701,6 +702,17 @@ ShellSummary *summary_new(void)
return summary;
}
+static gboolean
+select_first_tree_item(gpointer data)
+{
+ GtkTreeIter first;
+
+ if (gtk_tree_model_get_iter_first(shell->tree->model, &first))
+ gtk_tree_selection_select_iter(shell->tree->selection, &first);
+
+ return FALSE;
+}
+
void shell_init(GSList * modules)
{
if (shell) {
@@ -770,6 +782,9 @@ void shell_init(GSList * modules)
#else
shell_action_set_enabled("SyncManagerAction", sync_manager_count_entries() > 0);
#endif
+
+ /* Should select Computer Summary (note: not Computer/Summary) */
+ g_idle_add(select_first_tree_item, NULL);
}
static gboolean update_field(gpointer data)
@@ -978,7 +993,10 @@ static void set_view_type(ShellViewType viewtype, gboolean reload)
}
/* turn off the rules hint */
+#if GTK_CHECK_VERSION(3, 0, 0)
+#else
gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(shell->info->view), FALSE);
+#endif
close_note(NULL, NULL);
@@ -1148,10 +1166,13 @@ group_handle_special(GKeyFile * key_file, ShellModuleEntry * entry,
g_free(file);
}
} else if (g_str_equal(key, "Zebra")) {
+#if GTK_CHECK_VERSION(3, 0, 0)
+#else
gtk_tree_view_set_rules_hint(GTK_TREE_VIEW
(shell->info->view),
g_key_file_get_boolean
(key_file, group, key, NULL));
+#endif
}
}
@@ -1389,6 +1410,30 @@ select_first_item(gpointer data)
return FALSE;
}
+static gboolean
+select_marked_or_first_item(gpointer data)
+{
+ GtkTreeIter first, it;
+ gboolean found_selection = FALSE;
+ gchar *datacol;
+
+ if ( gtk_tree_model_get_iter_first(shell->info->model, &first) ) {
+ it = first;
+ while ( gtk_tree_model_iter_next(shell->info->model, &it) ) {
+ gtk_tree_model_get(shell->info->model, &it, INFO_TREE_COL_DATA, &datacol, -1);
+ if (datacol != NULL && *datacol == '*') {
+ gtk_tree_selection_select_iter(shell->info->selection, &it);
+ found_selection = TRUE;
+ }
+ g_free(datacol);
+ }
+
+ if (!found_selection)
+ gtk_tree_selection_select_iter(shell->info->selection, &first);
+ }
+ return FALSE;
+}
+
static void
module_selected_show_info(ShellModuleEntry * entry, gboolean reload)
{
@@ -1491,7 +1536,7 @@ module_selected_show_info(ShellModuleEntry * entry, gboolean reload)
case SHELL_VIEW_DUAL:
case SHELL_VIEW_LOAD_GRAPH:
case SHELL_VIEW_PROGRESS_DUAL:
- g_idle_add(select_first_item, NULL);
+ g_idle_add(select_marked_or_first_item, NULL);
}
}
}
@@ -1507,6 +1552,9 @@ static void info_selected_show_extra(gchar * data)
return;
if (data) {
+ /* skip the select marker */
+ if (*data == '*')
+ data++;
GKeyFile *key_file = g_key_file_new();
gchar *key_data = shell->selected->morefunc(data);
gchar **groups;
@@ -1613,15 +1661,22 @@ static void shell_summary_add_item(ShellSummary *summary,
gtk_box_pack_start(GTK_BOX(frame_label_box), frame_image, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(frame_label_box), frame_label, FALSE, FALSE, 0);
+ content = gtk_label_new(temp);
/* TODO:GTK3 gtk_alignment_new(), etc is deprecated from 3.14 */
+#if GTK_CHECK_VERSION(3, 0, 0)
+ GtkWidget *frame_box;
+ frame_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
+ gtk_widget_set_margin_start(GTK_WIDGET(frame_box), 48);
+ gtk_box_pack_start(GTK_BOX(frame_box), content, FALSE, FALSE, 0);
+ gtk_container_add(GTK_CONTAINER(frame), frame_box);
+#else
alignment = gtk_alignment_new(0.5, 0.5, 1, 1);
gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 0, 0, 48, 0);
gtk_widget_show(alignment);
gtk_container_add(GTK_CONTAINER(frame), alignment);
-
- content = gtk_label_new(temp);
gtk_misc_set_alignment(GTK_MISC(content), 0.0, 0.5);
gtk_container_add(GTK_CONTAINER(alignment), content);
+#endif
gtk_widget_show_all(frame);
gtk_widget_show_all(frame_label_box);