From a18b8bd3c357af82fd68e1e11a046d7727b02c51 Mon Sep 17 00:00:00 2001 From: Simon Steinbeiss Date: Wed, 24 Apr 2019 22:22:13 +0200 Subject: [PATCH] Move legend from tooltip to hide-able statusbar (Bug #14131) --- src/process-window-gtk3.ui | 59 +++++++++++++++++++++++++++++++++++++- src/process-window.c | 31 ++++++++++++++------ src/settings-tool-button.c | 4 +++ src/settings.c | 3 ++ 4 files changed, 87 insertions(+), 10 deletions(-) diff --git a/src/process-window-gtk3.ui b/src/process-window-gtk3.ui index 2ecaf82..ca99cf5 100644 --- a/src/process-window-gtk3.ui +++ b/src/process-window-gtk3.ui @@ -1,5 +1,5 @@ - + @@ -8,6 +8,9 @@ 490 465 utilities-system-monitor + + + True @@ -206,6 +209,60 @@ 0 + + + True + False + end + 6 + 6 + 18 + + + True + False + <span foreground='#000000' background='#aed581'> </span> Starting task + True + + + False + True + 0 + + + + + True + False + <span foreground='#000000' background='#fff176'> </span> Changing task + True + + + False + True + 1 + + + + + True + False + <span foreground='#000000' background='#e57373'> </span> Terminating task + True + + + False + True + 2 + + + + + False + True + 1 + + True diff --git a/src/process-window.c b/src/process-window.c index c93ac3d..2dd7ca5 100644 --- a/src/process-window.c +++ b/src/process-window.c @@ -212,6 +212,17 @@ xtm_process_window_class_init (XtmProcessWindowClass *klass) widget_class->hide = xtm_process_window_hide; } +static void +xtm_show_legend (XtmProcessWindow *window) +{ + gboolean show_legend; + + g_object_get (window->settings, + "show-legend", &show_legend, + NULL); + gtk_widget_set_visible (GTK_WIDGET (gtk_builder_get_object (window->builder, "legend")), show_legend); +} + static void xtm_process_window_init (XtmProcessWindow *window) { @@ -219,7 +230,7 @@ xtm_process_window_init (XtmProcessWindow *window) GtkWidget *icon; GtkToolItem *xwininfo; gint width, height; - gchar *markup; + gboolean show_legend; window->settings = xtm_settings_get_default (); @@ -243,6 +254,8 @@ xtm_process_window_init (XtmProcessWindow *window) window->settings_button = xtm_settings_tool_button_new (); gtk_toolbar_insert (GTK_TOOLBAR (window->toolbar), GTK_TOOL_ITEM (window->settings_button), 1); + g_signal_connect_swapped (window->settings, "notify::show-legend", G_CALLBACK (xtm_show_legend), window); + g_object_notify (G_OBJECT (window->settings), "show-legend"); icon = gtk_image_new_from_icon_name ("xc_crosshair", GTK_ICON_SIZE_LARGE_TOOLBAR); xwininfo = gtk_tool_button_new (icon, _("Identify Window")); @@ -312,22 +325,19 @@ xtm_process_window_init (XtmProcessWindow *window) window->treeview = xtm_process_tree_view_new (); gtk_widget_show (window->treeview); - markup = g_strdup_printf (_(" Starting task\n" - " Changing task\n" - " Terminating task")); - gtk_widget_set_tooltip_markup (GTK_WIDGET (gtk_builder_get_object (window->builder, "scrolledwindow")), markup); - g_free (markup); gtk_container_add (GTK_CONTAINER (gtk_builder_get_object (window->builder, "scrolledwindow")), window->treeview); + g_object_get (window->settings, + "show-legend", &show_legend, + NULL); + gtk_widget_set_visible (GTK_WIDGET (gtk_builder_get_object (window->builder, "legend")), show_legend); + window->filter_entry = GTK_WIDGET(gtk_builder_get_object (window->builder, "filter-entry")); g_signal_connect (G_OBJECT(window->filter_entry), "icon-press", G_CALLBACK(filter_entry_icon_pressed_cb), NULL); g_signal_connect (G_OBJECT(window->filter_entry), "changed", G_CALLBACK(filter_entry_keyrelease_handler), window->treeview); gtk_widget_set_tooltip_text (window->filter_entry, _("Filter on process name")); gtk_widget_grab_focus (GTK_WIDGET (window->filter_entry)); - - g_object_unref (window->builder); - window->builder = NULL; } static void @@ -349,6 +359,9 @@ xtm_process_window_finalize (GObject *object) if (XTM_IS_SETTINGS (window->settings)) g_object_unref (window->settings); + + g_object_unref (window->builder); + window->builder = NULL; } /** diff --git a/src/settings-tool-button.c b/src/settings-tool-button.c index 274029a..e5e265c 100644 --- a/src/settings-tool-button.c +++ b/src/settings-tool-button.c @@ -181,6 +181,10 @@ construct_menu (void) menu_append_item (GTK_MENU (menu), _("CPU"), "column-cpu", settings); menu_append_item (GTK_MENU (menu), _("Priority"), "column-priority", settings); + mi = gtk_separator_menu_item_new (); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); + menu_append_item (GTK_MENU (menu), _("Show Legend"), "show-legend", settings); + gtk_widget_show_all (menu); return menu; diff --git a/src/settings.c b/src/settings.c index 4fbf99e..8a01ff6 100644 --- a/src/settings.c +++ b/src/settings.c @@ -33,6 +33,7 @@ enum { PROP_SHOW_ALL_PROCESSES = 1, + PROP_SHOW_LEGEND, PROP_MORE_PRECISION, PROP_FULL_COMMAND_LINE, PROP_SHOW_STATUS_ICON, @@ -89,6 +90,8 @@ xtm_settings_class_init (XtmSettingsClass *klass) class->set_property = xtm_settings_set_property; g_object_class_install_property (class, PROP_SHOW_ALL_PROCESSES, g_param_spec_boolean ("show-all-processes", "ShowAllProcesses", "Show all processes", FALSE, G_PARAM_READWRITE)); + g_object_class_install_property (class, PROP_SHOW_LEGEND, + g_param_spec_boolean ("show-legend", "ShowLegend", "Show legend", TRUE, G_PARAM_READWRITE)); g_object_class_install_property (class, PROP_MORE_PRECISION, g_param_spec_boolean ("more-precision", "MorePrecision", "More precision", FALSE, G_PARAM_READWRITE)); g_object_class_install_property (class, PROP_FULL_COMMAND_LINE,