Rearrange the UI to resemble top

Moved the graphs below the toolbar and made them taller, so that they
are more readable/usable. Converted the statusbar into a box, moved it
below the graphs and rearranged the content to match the graphs.
This commit is contained in:
Simon Steinbeiss
2014-12-17 22:50:41 +01:00
parent 12bf2c96b0
commit 3486d3fab1
4 changed files with 166 additions and 107 deletions

View File

@@ -35,7 +35,7 @@ struct _XtmProcessStatusbarClass
};
struct _XtmProcessStatusbar
{
GtkStatusbar parent;
GtkHBox parent;
/*<private>*/
XtmSettings * settings;
@@ -49,7 +49,7 @@ struct _XtmProcessStatusbar
gchar swap[64];
guint num_processes;
};
G_DEFINE_TYPE (XtmProcessStatusbar, xtm_process_statusbar, GTK_TYPE_STATUSBAR)
G_DEFINE_TYPE (XtmProcessStatusbar, xtm_process_statusbar, GTK_TYPE_BOX)
static void xtm_process_statusbar_finalize (GObject *object);
static void xtm_process_statusbar_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
@@ -78,46 +78,36 @@ xtm_process_statusbar_class_init (XtmProcessStatusbarClass *klass)
static void
xtm_process_statusbar_init (XtmProcessStatusbar *statusbar)
{
GtkWidget *area, *hbox;
GtkWidget *hbox, *hbox_cpu, *hbox_mem;
statusbar->settings = xtm_settings_get_default ();
#if GTK_CHECK_VERSION(2,20,0)
area = gtk_statusbar_get_message_area (GTK_STATUSBAR (statusbar));
#else
{
GtkShadowType shadow_type;
GtkWidget *frame;
gtk_widget_style_get (GTK_WIDGET (statusbar), "shadow-type", &shadow_type, NULL);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), shadow_type);
gtk_box_pack_start (GTK_BOX (statusbar), frame, TRUE, TRUE, 0);
area = gtk_hbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (frame), area);
gtk_widget_show_all (frame);
}
#endif
#ifdef HAVE_GTK3
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 16);
hbox_cpu = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 16);
hbox_mem = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 16);
#else
hbox = gtk_hbox_new (FALSE, 16);
hbox_cpu = gtk_hbox_new (FALSE, 16);
hbox_mem = gtk_hbox_new (FALSE, 16);
#endif
gtk_box_pack_start (GTK_BOX (area), hbox, TRUE, TRUE, 6);
statusbar->label_num_processes = gtk_label_new (NULL);
gtk_box_pack_start (GTK_BOX (hbox), statusbar->label_num_processes, FALSE, FALSE, 0);
statusbar->label_cpu = gtk_label_new (NULL);
gtk_box_pack_start (GTK_BOX (hbox), statusbar->label_cpu, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox_cpu), statusbar->label_cpu, TRUE, FALSE, 0);
statusbar->label_num_processes = gtk_label_new (NULL);
gtk_box_pack_start (GTK_BOX (hbox_cpu), statusbar->label_num_processes, TRUE, FALSE, 0);
statusbar->label_memory = gtk_label_new (NULL);
gtk_box_pack_start (GTK_BOX (hbox), statusbar->label_memory, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox_mem), statusbar->label_memory, TRUE, FALSE, 0);
statusbar->label_swap = gtk_label_new (NULL);
gtk_box_pack_start (GTK_BOX (hbox), statusbar->label_swap, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox_mem), statusbar->label_swap, TRUE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), hbox_cpu, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (hbox), hbox_mem, TRUE, TRUE, 0);
gtk_box_set_homogeneous (GTK_BOX (hbox), TRUE);
gtk_box_pack_start (GTK_BOX (statusbar), hbox, TRUE, TRUE, 0);
gtk_widget_show_all (hbox);
}

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<!-- Generated with glade 3.16.1 -->
<interface>
<requires lib="gtk+" version="3.0"/>
<object class="GtkWindow" id="process-window">
@@ -19,34 +19,6 @@
<property name="can_focus">False</property>
<property name="show_arrow">False</property>
<property name="icon_size">1</property>
<child>
<object class="GtkToolItem" id="cpu-toolitem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">2</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolItem" id="mem-toolitem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">2</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="toolbutton-about">
<property name="visible">True</property>
@@ -66,6 +38,78 @@
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="graph-vbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox" id="graph-hbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkFrame" id="cpu-toolitem">
<property name="height_request">100</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">False</property>
<property name="border_width">2</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<placeholder/>
</child>
<child type="label_item">
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="mem-toolitem">
<property name="height_request">100</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">False</property>
<property name="border_width">2</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<placeholder/>
</child>
<child type="label_item">
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox" id="root-warning-box">
<property name="can_focus">False</property>
@@ -105,7 +149,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
<property name="position">2</property>
</packing>
</child>
<child>
@@ -122,7 +166,7 @@
<property name="expand">False</property>
<property name="fill">False</property>
<property name="padding">2</property>
<property name="position">2</property>
<property name="position">3</property>
</packing>
</child>
<child>
@@ -149,12 +193,9 @@
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">3</property>
<property name="position">4</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
</object>

View File

@@ -140,6 +140,9 @@ 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);
button = GTK_WIDGET (gtk_builder_get_object (window->builder, "toolbutton-about"));
g_signal_connect_swapped (button, "clicked", G_CALLBACK (show_about_dialog), window);
{
GtkWidget *toolitem;
guint refresh_rate;
@@ -161,8 +164,9 @@ xtm_process_window_init (XtmProcessWindow *window)
g_signal_connect_swapped (window->settings, "notify::refresh-rate", G_CALLBACK (monitor_update_step_size), window);
}
button = GTK_WIDGET (gtk_builder_get_object (window->builder, "toolbutton-about"));
g_signal_connect_swapped (button, "clicked", G_CALLBACK (show_about_dialog), window);
window->statusbar = xtm_process_statusbar_new ();
gtk_widget_show (window->statusbar);
gtk_box_pack_start (GTK_BOX (gtk_builder_get_object (window->builder, "graph-vbox")), window->statusbar, FALSE, FALSE, 0);
if (geteuid () == 0)
{
@@ -181,10 +185,6 @@ xtm_process_window_init (XtmProcessWindow *window)
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);
window->statusbar = xtm_process_statusbar_new ();
gtk_widget_show (window->statusbar);
gtk_box_pack_start (GTK_BOX (gtk_builder_get_object (window->builder, "process-vbox")), window->statusbar, FALSE, FALSE, 0);
gtk_widget_grab_focus (GTK_WIDGET (window->treeview));
g_object_unref (window->builder);
@@ -212,7 +212,7 @@ xtm_process_window_finalize (GObject *object)
if (GTK_IS_TREE_VIEW (window->treeview))
gtk_widget_destroy (window->treeview);
if (GTK_IS_STATUSBAR (window->statusbar))
if (GTK_IS_BOX (window->statusbar))
gtk_widget_destroy (window->statusbar);
if (GTK_IS_TOOL_ITEM (window->exec_button))
@@ -412,7 +412,7 @@ xtm_process_window_set_system_info (XtmProcessWindow *window, guint num_processe
gchar value[4];
g_return_if_fail (XTM_IS_PROCESS_WINDOW (window));
g_return_if_fail (GTK_IS_STATUSBAR (window->statusbar));
g_return_if_fail (GTK_IS_BOX (window->statusbar));
g_object_set (window->statusbar, "num-processes", num_processes, "cpu", cpu, "memory", memory_str, "swap", swap_str, NULL);
@@ -430,6 +430,6 @@ void
xtm_process_window_show_swap_usage (XtmProcessWindow *window, gboolean show_swap_usage)
{
g_return_if_fail (XTM_IS_PROCESS_WINDOW (window));
g_return_if_fail (GTK_IS_STATUSBAR (window->statusbar));
g_return_if_fail (GTK_IS_BOX (window->statusbar));
g_object_set (window->statusbar, "show-swap", show_swap_usage, NULL);
}

View File

@@ -18,38 +18,11 @@
<property name="can_focus">False</property>
<property name="show_arrow">False</property>
<property name="icon_size">1</property>
<child>
<object class="GtkToolItem" id="cpu-toolitem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">2</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolItem" id="mem-toolitem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">2</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="toolbutton-about">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-about</property>
</object>
@@ -65,6 +38,64 @@
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkVBox" id="graph-vbox">
<property name="height_request">100</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkHBox" id="graph-hbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkToolItem" id="cpu-toolitem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">2</property>
<property name="use_action_appearance">False</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkToolItem" id="mem-toolitem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">2</property>
<property name="use_action_appearance">False</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">-1</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkVBox" id="root-warning-box">
<property name="can_focus">False</property>
@@ -103,7 +134,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
<property name="position">2</property>
</packing>
</child>
<child>
@@ -122,7 +153,7 @@
<property name="expand">False</property>
<property name="fill">False</property>
<property name="padding">2</property>
<property name="position">2</property>
<property name="position">3</property>
</packing>
</child>
<child>
@@ -150,12 +181,9 @@
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">3</property>
<property name="position">4</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
</object>