Skip to content

Commit

Permalink
Move legend from tooltip to hide-able statusbar (Bug #14131)
Browse files Browse the repository at this point in the history
  • Loading branch information
ochosi committed Apr 24, 2019
1 parent d2f914f commit a18b8bd
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 10 deletions.
59 changes: 58 additions & 1 deletion src/process-window-gtk3.ui
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.16.1 -->
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.0"/>
<object class="GtkWindow" id="process-window">
Expand All @@ -8,6 +8,9 @@
<property name="default_width">490</property>
<property name="default_height">465</property>
<property name="icon_name">utilities-system-monitor</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkBox" id="process-vbox">
<property name="visible">True</property>
Expand Down Expand Up @@ -206,6 +209,60 @@
<property name="position">0</property>
</packing>
</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>
<packing>
<property name="resize">True</property>
Expand Down
31 changes: 22 additions & 9 deletions src/process-window.c
Expand Up @@ -212,14 +212,25 @@ 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)
{
GtkWidget *button;
GtkWidget *icon;
GtkToolItem *xwininfo;
gint width, height;
gchar *markup;
gboolean show_legend;

window->settings = xtm_settings_get_default ();

Expand All @@ -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"));
Expand Down Expand Up @@ -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 (_("<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);

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
Expand All @@ -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;
}

/**
Expand Down
4 changes: 4 additions & 0 deletions src/settings-tool-button.c
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/settings.c
Expand Up @@ -33,6 +33,7 @@
enum
{
PROP_SHOW_ALL_PROCESSES = 1,
PROP_SHOW_LEGEND,
PROP_MORE_PRECISION,
PROP_FULL_COMMAND_LINE,
PROP_SHOW_STATUS_ICON,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit a18b8bd

Please sign in to comment.