Move legend from tooltip to hide-able statusbar (Bug #14131)

This commit is contained in:
Simon Steinbeiss
2019-04-24 22:22:13 +02:00
parent d2f914f532
commit a18b8bd3c3
4 changed files with 87 additions and 10 deletions

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.16.1 --> <!-- Generated with glade 3.22.1 -->
<interface> <interface>
<requires lib="gtk+" version="3.0"/> <requires lib="gtk+" version="3.0"/>
<object class="GtkWindow" id="process-window"> <object class="GtkWindow" id="process-window">
@@ -8,6 +8,9 @@
<property name="default_width">490</property> <property name="default_width">490</property>
<property name="default_height">465</property> <property name="default_height">465</property>
<property name="icon_name">utilities-system-monitor</property> <property name="icon_name">utilities-system-monitor</property>
<child>
<placeholder/>
</child>
<child> <child>
<object class="GtkBox" id="process-vbox"> <object class="GtkBox" id="process-vbox">
<property name="visible">True</property> <property name="visible">True</property>
@@ -206,6 +209,60 @@
<property name="position">0</property> <property name="position">0</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkBox" id="legend">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="margin_right">6</property>
<property name="margin_bottom">6</property>
<property name="spacing">18</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">&lt;span foreground='#000000' background='#aed581'&gt; &lt;/span&gt; Starting task</property>
<property name="use_markup">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">&lt;span foreground='#000000' background='#fff176'&gt; &lt;/span&gt; Changing task</property>
<property name="use_markup">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">&lt;span foreground='#000000' background='#e57373'&gt; &lt;/span&gt; Terminating task</property>
<property name="use_markup">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object> </object>
<packing> <packing>
<property name="resize">True</property> <property name="resize">True</property>

View File

@@ -212,6 +212,17 @@ xtm_process_window_class_init (XtmProcessWindowClass *klass)
widget_class->hide = xtm_process_window_hide; 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 static void
xtm_process_window_init (XtmProcessWindow *window) xtm_process_window_init (XtmProcessWindow *window)
{ {
@@ -219,7 +230,7 @@ xtm_process_window_init (XtmProcessWindow *window)
GtkWidget *icon; GtkWidget *icon;
GtkToolItem *xwininfo; GtkToolItem *xwininfo;
gint width, height; gint width, height;
gchar *markup; gboolean show_legend;
window->settings = xtm_settings_get_default (); window->settings = xtm_settings_get_default ();
@@ -243,6 +254,8 @@ xtm_process_window_init (XtmProcessWindow *window)
window->settings_button = xtm_settings_tool_button_new (); window->settings_button = xtm_settings_tool_button_new ();
gtk_toolbar_insert (GTK_TOOLBAR (window->toolbar), GTK_TOOL_ITEM (window->settings_button), 1); 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); icon = gtk_image_new_from_icon_name ("xc_crosshair", GTK_ICON_SIZE_LARGE_TOOLBAR);
xwininfo = gtk_tool_button_new (icon, _("Identify Window")); 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 (); window->treeview = xtm_process_tree_view_new ();
gtk_widget_show (window->treeview); gtk_widget_show (window->treeview);
markup = g_strdup_printf (_("<span foreground='#000000' background='#aed581'> </span> Starting task\n"
"<span foreground='#000000' background='#fff176'> </span> Changing task\n"
"<span foreground='#000000' background='#e57373'> </span> 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); 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")); 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), "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); 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_set_tooltip_text (window->filter_entry, _("Filter on process name"));
gtk_widget_grab_focus (GTK_WIDGET (window->filter_entry)); gtk_widget_grab_focus (GTK_WIDGET (window->filter_entry));
g_object_unref (window->builder);
window->builder = NULL;
} }
static void static void
@@ -349,6 +359,9 @@ xtm_process_window_finalize (GObject *object)
if (XTM_IS_SETTINGS (window->settings)) if (XTM_IS_SETTINGS (window->settings))
g_object_unref (window->settings); g_object_unref (window->settings);
g_object_unref (window->builder);
window->builder = NULL;
} }
/** /**

View File

@@ -181,6 +181,10 @@ construct_menu (void)
menu_append_item (GTK_MENU (menu), _("CPU"), "column-cpu", settings); menu_append_item (GTK_MENU (menu), _("CPU"), "column-cpu", settings);
menu_append_item (GTK_MENU (menu), _("Priority"), "column-priority", 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); gtk_widget_show_all (menu);
return menu; return menu;

View File

@@ -33,6 +33,7 @@
enum enum
{ {
PROP_SHOW_ALL_PROCESSES = 1, PROP_SHOW_ALL_PROCESSES = 1,
PROP_SHOW_LEGEND,
PROP_MORE_PRECISION, PROP_MORE_PRECISION,
PROP_FULL_COMMAND_LINE, PROP_FULL_COMMAND_LINE,
PROP_SHOW_STATUS_ICON, PROP_SHOW_STATUS_ICON,
@@ -89,6 +90,8 @@ xtm_settings_class_init (XtmSettingsClass *klass)
class->set_property = xtm_settings_set_property; class->set_property = xtm_settings_set_property;
g_object_class_install_property (class, PROP_SHOW_ALL_PROCESSES, 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_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_object_class_install_property (class, PROP_MORE_PRECISION,
g_param_spec_boolean ("more-precision", "MorePrecision", "More precision", FALSE, G_PARAM_READWRITE)); g_param_spec_boolean ("more-precision", "MorePrecision", "More precision", FALSE, G_PARAM_READWRITE));
g_object_class_install_property (class, PROP_FULL_COMMAND_LINE, g_object_class_install_property (class, PROP_FULL_COMMAND_LINE,