diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 9 | ||||
-rw-r--r-- | src/msm.gresource.xml | 6 | ||||
-rw-r--r-- | src/preferences.ui | 676 | ||||
-rw-r--r-- | src/procdialogs.cpp | 394 |
4 files changed, 734 insertions, 351 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index f684e7d..b001757 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -11,6 +11,8 @@ AM_CPPFLAGS = \ bin_PROGRAMS = mate-system-monitor +BUILT_SOURCES = msm-resources.c + mate_system_monitor_cpp_files = \ argv.cpp \ procman.cpp \ @@ -46,6 +48,7 @@ mate_system_monitor_h_files = \ defaulttable.h mate_system_monitor_SOURCES = \ + $(BUILT_SOURCES) \ $(mate_system_monitor_h_files) \ $(mate_system_monitor_cpp_files) \ $(mate_system_monitor_c_files) @@ -68,6 +71,9 @@ libbacon_la_CFLAGS = \ specdir = $(datadir)/procman +# Generate resources +msm-resources.c: msm.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies $(srcdir)/msm.gresource.xml) + $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate --c-name msm $< gsettings_ENUM_NAMESPACE = org.mate.system-monitor gsettings_ENUM_FILES = $(top_srcdir)/src/*.h @@ -81,9 +87,12 @@ dist_noinst_DATA = \ $(gsettings_in_file) CLEANFILES = \ + $(BUILT_SOURCES) \ $(gsettings_SCHEMAS) EXTRA_DIST = \ + msm.gresource.xml \ + preferences.ui \ $(gsettingsschema_in_files) MAINTAINERCLEANFILES = $(gsettings_SCHEMAS:.xml=.valid) diff --git a/src/msm.gresource.xml b/src/msm.gresource.xml new file mode 100644 index 0000000..f9e9c0f --- /dev/null +++ b/src/msm.gresource.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<gresources> + <gresource prefix="/org/mate/system-monitor"> + <file compressed="true" preprocess="xml-stripblanks">preferences.ui</file> + </gresource> +</gresources> diff --git a/src/preferences.ui b/src/preferences.ui new file mode 100644 index 0000000..7c49d86 --- /dev/null +++ b/src/preferences.ui @@ -0,0 +1,676 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.38.2 --> +<interface> + <requires lib="gtk+" version="3.24"/> + <object class="GtkImage" id="image1"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="icon-name">window-close</property> + </object> + <object class="GtkImage" id="image2"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="icon-name">help-browser</property> + </object> + <object class="GtkDialog" id="preferences_dialog"> + <property name="can-focus">False</property> + <property name="border-width">5</property> + <property name="title" translatable="yes">System Monitor Preferences</property> + <property name="default-width">400</property> + <property name="default-height">420</property> + <property name="destroy-with-parent">True</property> + <property name="type-hint">dialog</property> + <child internal-child="vbox"> + <object class="GtkBox" id="dialog_layout"> + <property name="can-focus">False</property> + <property name="margin-top">5</property> + <property name="margin-bottom">5</property> + <property name="orientation">vertical</property> + <property name="spacing">2</property> + <child internal-child="action_area"> + <object class="GtkButtonBox" id="dialog_action_area"> + <property name="can-focus">False</property> + <child> + <object class="GtkButton" id="help_button"> + <property name="label">Help</property> + <property name="use-action-appearance">False</property> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="receives-default">True</property> + <property name="image">image2</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="close_button"> + <property name="label">Close</property> + <property name="use-action-appearance">False</property> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="receives-default">True</property> + <property name="image">image1</property> + </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="pack-type">end</property> + <property name="position">0</property> + </packing> + </child> + <child> + <!-- n-columns=1 n-rows=1 --> + <object class="GtkGrid" id="content_grid"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="orientation">vertical</property> + <property name="column-spacing">2</property> + <child> + <object class="GtkNotebook" id="notebook"> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="border-width">5</property> + <child> + <!-- n-columns=1 n-rows=2 --> + <object class="GtkGrid" id="processes_tab_content"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="border-width">12</property> + <property name="orientation">vertical</property> + <property name="row-spacing">18</property> + <child> + <!-- n-columns=1 n-rows=2 --> + <object class="GtkGrid" id="processes_behavior"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="row-spacing">6</property> + <child> + <object class="GtkLabel" id="processes_behavior_label"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="halign">start</property> + <property name="label" translatable="yes">Behavior</property> + <property name="single-line-mode">True</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">0</property> + </packing> + </child> + <child> + <!-- n-columns=1 n-rows=4 --> + <object class="GtkGrid" id="processes_behavior_section"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="margin-start">12</property> + <property name="row-spacing">6</property> + <child> + <!-- n-columns=2 n-rows=1 --> + <object class="GtkGrid" id="update_interval_grid"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="hexpand">True</property> + <property name="column-spacing">12</property> + <child> + <object class="GtkLabel" id="processes_interval_label"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes">_Update interval in seconds:</property> + <property name="use-underline">True</property> + <property name="mnemonic-widget">processes_interval_spinner</property> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">0</property> + </packing> + </child> + <child> + <object class="GtkSpinButton" id="processes_interval_spinner"> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="invisible-char">•</property> + <property name="climb-rate">1</property> + <property name="digits">2</property> + </object> + <packing> + <property name="left-attach">1</property> + <property name="top-attach">0</property> + </packing> + </child> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="smooth_button"> + <property name="label" translatable="yes">Enable _smooth refresh</property> + <property name="use-action-appearance">False</property> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="receives-default">False</property> + <property name="use-underline">True</property> + <property name="draw-indicator">True</property> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">1</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="check_button"> + <property name="label" translatable="yes">Alert before ending or _killing processes</property> + <property name="use-action-appearance">False</property> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="receives-default">False</property> + <property name="use-underline">True</property> + <property name="draw-indicator">True</property> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">2</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="solaris_button"> + <property name="label" translatable="yes">_Divide CPU usage by CPU count</property> + <property name="use-action-appearance">False</property> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="receives-default">False</property> + <property name="use-underline">True</property> + <property name="draw-indicator">True</property> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">3</property> + </packing> + </child> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">1</property> + </packing> + </child> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">0</property> + </packing> + </child> + <child> + <!-- n-columns=1 n-rows=2 --> + <object class="GtkGrid" id="processes_fields"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="row-spacing">6</property> + <child> + <object class="GtkLabel" id="processes_fields_label"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes">Information Fields</property> + <property name="justify">fill</property> + <property name="ellipsize">end</property> + <property name="single-line-mode">True</property> + <property name="xalign">0</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">0</property> + </packing> + </child> + <child> + <!-- n-columns=1 n-rows=2 --> + <object class="GtkGrid" id="processes_fields_grid"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkLabel" id="processes_fields_table_label"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes">Process i_nformation shown in list:</property> + <property name="use-underline">True</property> + <property name="mnemonic-widget">proctree_columns</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">0</property> + </packing> + </child> + <child> + <object class="GtkScrolledWindow" id="processes_scrolled"> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="shadow-type">in</property> + <child> + <object class="GtkTreeView" id="proctree_columns"> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="headers-visible">False</property> + <property name="enable-search">False</property> + <child internal-child="selection"> + <object class="GtkTreeSelection" id="processes-columns-selection"/> + </child> + </object> + </child> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">1</property> + </packing> + </child> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">1</property> + </packing> + </child> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">1</property> + </packing> + </child> + </object> + </child> + <child type="tab"> + <object class="GtkLabel" id="processes_tab_label"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes">Processes</property> + </object> + <packing> + <property name="tab-fill">False</property> + </packing> + </child> + <child> + <!-- n-columns=1 n-rows=1 --> + <object class="GtkGrid" id="resources_tab_content"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="border-width">12</property> + <property name="orientation">vertical</property> + <property name="row-spacing">18</property> + <child> + <!-- n-columns=1 n-rows=2 --> + <object class="GtkGrid" id="resources_graphs"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="hexpand">True</property> + <property name="row-spacing">6</property> + <child> + <object class="GtkLabel" id="resources_graphs_label"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="hexpand">True</property> + <property name="label" translatable="yes">Graphs</property> + <property name="justify">fill</property> + <property name="ellipsize">end</property> + <property name="single-line-mode">True</property> + <property name="xalign">0</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">0</property> + </packing> + </child> + <child> + <!-- n-columns=1 n-rows=2 --> + <object class="GtkGrid" id="resources_graphs_section"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="margin-start">12</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="row-spacing">6</property> + <child> + <!-- n-columns=2 n-rows=1 --> + <object class="GtkGrid" id="resources_update_interval"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="hexpand">True</property> + <property name="column-spacing">12</property> + <child> + <object class="GtkLabel" id="resources_interval_label"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes">_Update interval in seconds:</property> + <property name="use-underline">True</property> + <property name="mnemonic-widget">resources_interval_spinner</property> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">0</property> + </packing> + </child> + <child> + <object class="GtkSpinButton" id="resources_interval_spinner"> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="invisible-char">•</property> + <property name="climb-rate">1</property> + <property name="digits">2</property> + </object> + <packing> + <property name="left-attach">1</property> + <property name="top-attach">0</property> + </packing> + </child> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="bits_button"> + <property name="label" translatable="yes">_Show network speed in bits</property> + <property name="use-action-appearance">False</property> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="receives-default">False</property> + <property name="hexpand">True</property> + <property name="use-underline">True</property> + <property name="draw-indicator">True</property> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">1</property> + </packing> + </child> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">1</property> + </packing> + </child> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">0</property> + </packing> + </child> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + <child type="tab"> + <object class="GtkLabel" id="resources_tab_label"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes">Resources</property> + </object> + <packing> + <property name="position">1</property> + <property name="tab-fill">False</property> + </packing> + </child> + <child> + <!-- n-columns=1 n-rows=2 --> + <object class="GtkGrid" id="devices_tab_content"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="border-width">12</property> + <property name="orientation">vertical</property> + <property name="row-spacing">18</property> + <child> + <!-- n-columns=1 n-rows=2 --> + <object class="GtkGrid" id="devices_behavior"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="row-spacing">6</property> + <child> + <object class="GtkLabel" id="devices_behavior_label"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="hexpand">True</property> + <property name="label" translatable="yes">Behavior</property> + <property name="justify">fill</property> + <property name="ellipsize">end</property> + <property name="single-line-mode">True</property> + <property name="xalign">0</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">0</property> + </packing> + </child> + <child> + <!-- n-columns=1 n-rows=2 --> + <object class="GtkGrid" id="devices_behavior_section"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="margin-start">12</property> + <property name="hexpand">True</property> + <property name="row-spacing">6</property> + <child> + <!-- n-columns=2 n-rows=1 --> + <object class="GtkGrid" id="devices_interval_grid"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="hexpand">True</property> + <property name="column-spacing">12</property> + <child> + <object class="GtkLabel" id="devices_interval_label"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes">_Update interval in seconds:</property> + <property name="use-underline">True</property> + <property name="mnemonic-widget">devices_interval_spinner</property> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">0</property> + </packing> + </child> + <child> + <object class="GtkSpinButton" id="devices_interval_spinner"> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="invisible-char">•</property> + <property name="climb-rate">1</property> + <property name="digits">2</property> + </object> + <packing> + <property name="left-attach">1</property> + <property name="top-attach">0</property> + </packing> + </child> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="all_devices_check"> + <property name="label" translatable="yes">Show _all file systems</property> + <property name="use-action-appearance">False</property> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="receives-default">False</property> + <property name="hexpand">True</property> + <property name="use-underline">True</property> + <property name="draw-indicator">True</property> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">1</property> + </packing> + </child> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">1</property> + </packing> + </child> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">0</property> + </packing> + </child> + <child> + <!-- n-columns=1 n-rows=2 --> + <object class="GtkGrid" id="devices_fields"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="row-spacing">6</property> + <child> + <object class="GtkLabel" id="devices_fields_label"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="hexpand">True</property> + <property name="label" translatable="yes">Information Fields</property> + <property name="justify">fill</property> + <property name="ellipsize">end</property> + <property name="single-line-mode">True</property> + <property name="xalign">0</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">0</property> + </packing> + </child> + <child> + <!-- n-columns=1 n-rows=2 --> + <object class="GtkGrid" id="devices_fields_grid"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="orientation">vertical</property> + <property name="row-spacing">6</property> + <child> + <object class="GtkLabel" id="devices_fields_table_label"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes">File system i_nformation shown in list:</property> + <property name="use-underline">True</property> + <property name="mnemonic-widget">disktreenew_columns</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">0</property> + </packing> + </child> + <child> + <object class="GtkScrolledWindow" id="devices_scrolled"> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="shadow-type">in</property> + <child> + <object class="GtkTreeView" id="disktreenew_columns"> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="headers-visible">False</property> + <property name="enable-search">False</property> + <child internal-child="selection"> + <object class="GtkTreeSelection" id="devices-treeview-selection"/> + </child> + </object> + </child> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">1</property> + </packing> + </child> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">1</property> + </packing> + </child> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">1</property> + </packing> + </child> + </object> + <packing> + <property name="position">2</property> + </packing> + </child> + <child type="tab"> + <object class="GtkLabel" id="file_systems_tab_label"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes">File Systems</property> + </object> + <packing> + <property name="position">2</property> + <property name="tab-fill">False</property> + </packing> + </child> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">0</property> + </packing> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + <action-widgets> + <action-widget response="-11">help_button</action-widget> + <action-widget response="-7">close_button</action-widget> + </action-widgets> + </object> +</interface> diff --git a/src/procdialogs.cpp b/src/procdialogs.cpp index e3d1208..a3b60c6 100644 --- a/src/procdialogs.cpp +++ b/src/procdialogs.cpp @@ -37,6 +37,7 @@ #include "procman_pkexec.h" #include "cgroups.h" +#define GET_WIDGET(x) GTK_WIDGET(gtk_builder_get_object(builder, x)) static GtkWidget *renice_dialog = NULL; static GtkWidget *prefs_dialog = NULL; @@ -286,74 +287,6 @@ prefs_dialog_button_pressed (GtkDialog *dialog, gint id, gpointer data) } -static void -show_kill_dialog_toggled (GtkToggleButton *button, gpointer data) -{ - ProcData *procdata = static_cast<ProcData*>(data); - GSettings *settings = procdata->settings; - - gboolean toggled; - - toggled = gtk_toggle_button_get_active (button); - - g_settings_set_boolean (settings, "kill-dialog", toggled); - -} - - - -static void -solaris_mode_toggled(GtkToggleButton *button, gpointer data) -{ - ProcData *procdata = static_cast<ProcData*>(data); - GSettings *settings = procdata->settings; - gboolean toggled; - toggled = gtk_toggle_button_get_active(button); - g_settings_set_boolean(settings, procman::settings::solaris_mode.c_str(), toggled); -} - - -static void -network_in_bits_toggled(GtkToggleButton *button, gpointer data) -{ - ProcData *procdata = static_cast<ProcData*>(data); - GSettings *settings = procdata->settings; - gboolean toggled; - toggled = gtk_toggle_button_get_active(button); - g_settings_set_boolean(settings, procman::settings::network_in_bits.c_str(), toggled); -} - - - -static void -smooth_refresh_toggled(GtkToggleButton *button, gpointer data) -{ - ProcData *procdata = static_cast<ProcData*>(data); - GSettings *settings = procdata->settings; - - gboolean toggled; - - toggled = gtk_toggle_button_get_active(button); - - g_settings_set_boolean(settings, SmoothRefresh::KEY.c_str(), toggled); -} - - - -static void -show_all_fs_toggled (GtkToggleButton *button, gpointer data) -{ - ProcData *procdata = static_cast<ProcData*>(data); - GSettings *settings = procdata->settings; - - gboolean toggled; - - toggled = gtk_toggle_button_get_active (button); - - g_settings_set_boolean (settings, "show-all-fs", toggled); -} - - class SpinButtonUpdater { public: @@ -428,37 +361,24 @@ disk_field_toggled (GtkCellRendererToggle *cell, gchar *path_str, gpointer data) field_toggled ("disktreenew", cell, path_str, data); } -static GtkWidget * -create_field_page(GtkWidget *tree, const gchar *child_schema, const gchar *text) +static void +create_field_page(GtkBuilder* builder, GtkWidget *tree, const gchar *widgetname) { - GtkWidget *vbox; - GtkWidget *scrolled; - GtkWidget *label; - GtkWidget *treeview; + GtkTreeView *treeview; GList *it, *columns; GtkListStore *model; GtkTreeViewColumn *column; GtkCellRenderer *cell; + gchar *full_widgetname; - vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); - - label = gtk_label_new_with_mnemonic (text); - gtk_label_set_xalign (GTK_LABEL (label), 0.0); - gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0); - - scrolled = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled), GTK_SHADOW_IN); - gtk_box_pack_start (GTK_BOX (vbox), scrolled, TRUE, TRUE, 0); + full_widgetname = g_strdup_printf ("%s_columns", widgetname); + treeview = GTK_TREE_VIEW (gtk_builder_get_object (builder, full_widgetname)); + g_free (full_widgetname); model = gtk_list_store_new (3, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_POINTER); - treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model)); - gtk_container_add (GTK_CONTAINER (scrolled), treeview); + gtk_tree_view_set_model (GTK_TREE_VIEW(treeview), GTK_TREE_MODEL(model)); g_object_unref (G_OBJECT (model)); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), treeview); column = gtk_tree_view_column_new (); @@ -467,9 +387,10 @@ create_field_page(GtkWidget *tree, const gchar *child_schema, const gchar *text) gtk_tree_view_column_set_attributes (column, cell, "active", 0, NULL); - if (g_strcmp0 (child_schema, "proctree") == 0) + + if (g_strcmp0 (widgetname, "proctree") == 0) g_signal_connect (G_OBJECT (cell), "toggled", G_CALLBACK (proc_field_toggled), model); - else if (g_strcmp0 (child_schema, "disktreenew") == 0) + else if (g_strcmp0 (widgetname, "disktreenew") == 0) g_signal_connect (G_OBJECT (cell), "toggled", G_CALLBACK (disk_field_toggled), model); gtk_tree_view_column_set_clickable (column, TRUE); @@ -485,7 +406,6 @@ create_field_page(GtkWidget *tree, const gchar *child_schema, const gchar *text) gtk_tree_view_column_set_title (column, "Not Shown"); gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column); - gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE); columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (tree)); @@ -522,15 +442,11 @@ create_field_page(GtkWidget *tree, const gchar *child_schema, const gchar *text) } g_list_free(columns); - - return vbox; } void procdialog_create_preferences_dialog (ProcData *procdata) { - static GtkWidget *dialog = NULL; - typedef SpinButtonUpdater SBU; static SBU interval_updater("update-interval"); @@ -538,81 +454,21 @@ procdialog_create_preferences_dialog (ProcData *procdata) static SBU disks_interval_updater("disks-interval"); GtkWidget *notebook; - GtkWidget *proc_box; - GtkWidget *sys_box; - GtkWidget *main_vbox; - GtkWidget *vbox, *vbox2, *vbox3; - GtkWidget *hbox, *hbox2, *hbox3; - GtkWidget *label; GtkAdjustment *adjustment; GtkWidget *spin_button; GtkWidget *check_button; - GtkWidget *tab_label; GtkWidget *smooth_button; - GtkSizeGroup *size; + GtkBuilder *builder; gfloat update; - gchar *tmp; if (prefs_dialog) return; - size = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); - - dialog = gtk_dialog_new_with_buttons (_("System Monitor Preferences"), - GTK_WINDOW (procdata->app), - GTK_DIALOG_DESTROY_WITH_PARENT, - "gtk-help", GTK_RESPONSE_HELP, - "gtk-close", GTK_RESPONSE_CLOSE, - NULL); - /* FIXME: we should not declare the window size, but let it's */ - /* driven by window childs. The problem is that the fields list */ - /* have to show at least 4 items to respect HIG. I don't know */ - /* any function to set list height by contents/items inside it. */ - gtk_window_set_default_size (GTK_WINDOW (dialog), 400, 500); - gtk_container_set_border_width (GTK_CONTAINER (dialog), 5); - prefs_dialog = dialog; - - main_vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); - gtk_box_set_spacing (GTK_BOX (main_vbox), 2); - - notebook = gtk_notebook_new (); - gtk_container_set_border_width (GTK_CONTAINER (notebook), 5); - gtk_box_pack_start (GTK_BOX (main_vbox), notebook, TRUE, TRUE, 0); - - proc_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 18); - gtk_container_set_border_width (GTK_CONTAINER (proc_box), 12); - tab_label = gtk_label_new (_("Processes")); - gtk_widget_show (tab_label); - gtk_notebook_append_page (GTK_NOTEBOOK (notebook), proc_box, tab_label); - - vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); - gtk_box_pack_start (GTK_BOX (proc_box), vbox, FALSE, FALSE, 0); - - tmp = g_strdup_printf ("<b>%s</b>", _("Behavior")); - label = gtk_label_new (NULL); - gtk_label_set_xalign (GTK_LABEL (label), 0.0); - gtk_label_set_markup (GTK_LABEL (label), tmp); - g_free (tmp); - gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); - - hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - - label = gtk_label_new (" "); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - - vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); - gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, TRUE, 0); - - hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); - gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, FALSE, 0); + builder = gtk_builder_new_from_resource("/org/mate/system-monitor/preferences.ui"); - label = gtk_label_new_with_mnemonic (_("_Update interval in seconds:")); - gtk_label_set_xalign (GTK_LABEL (label), 0.0); - gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, FALSE, 0); - - hbox3 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); - gtk_box_pack_start (GTK_BOX (hbox2), hbox3, TRUE, TRUE, 0); + prefs_dialog = GET_WIDGET("preferences_dialog"); + notebook = GET_WIDGET("notebook"); + spin_button = GET_WIDGET("processes_interval_spinner"); update = (gfloat) procdata->config.update_interval; adjustment = (GtkAdjustment *) gtk_adjustment_new(update / 1000.0, @@ -622,219 +478,54 @@ procdialog_create_preferences_dialog (ProcData *procdata) 1.0, 0); - spin_button = gtk_spin_button_new (adjustment, 1.0, 2); - gtk_box_pack_start (GTK_BOX (hbox3), spin_button, FALSE, FALSE, 0); + gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON(spin_button), adjustment); g_signal_connect (G_OBJECT (spin_button), "focus_out_event", G_CALLBACK (SBU::callback), &interval_updater); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), spin_button); - - - hbox2 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6); - gtk_box_pack_start(GTK_BOX(vbox2), hbox2, FALSE, FALSE, 0); - - smooth_button = gtk_check_button_new_with_mnemonic(_("Enable _smooth refresh")); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(smooth_button), - g_settings_get_boolean(procdata->settings, - SmoothRefresh::KEY.c_str())); - g_signal_connect(G_OBJECT(smooth_button), "toggled", - G_CALLBACK(smooth_refresh_toggled), procdata); - gtk_box_pack_start(GTK_BOX(hbox2), smooth_button, TRUE, TRUE, 0); - - - - hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); - gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, FALSE, 0); - - check_button = gtk_check_button_new_with_mnemonic (_("Alert before ending or _killing processes")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button), - procdata->config.show_kill_warning); - g_signal_connect (G_OBJECT (check_button), "toggled", - G_CALLBACK (show_kill_dialog_toggled), procdata); - gtk_box_pack_start (GTK_BOX (hbox2), check_button, FALSE, FALSE, 0); - - - - - hbox2 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6); - gtk_box_pack_start(GTK_BOX(vbox2), hbox2, FALSE, FALSE, 0); - - GtkWidget *solaris_button = gtk_check_button_new_with_mnemonic(_("Divide CPU usage by CPU count")); - gtk_widget_set_tooltip_text(solaris_button, _("Solaris mode")); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(solaris_button), - g_settings_get_boolean(procdata->settings, - procman::settings::solaris_mode.c_str())); - g_signal_connect(G_OBJECT(solaris_button), "toggled", - G_CALLBACK(solaris_mode_toggled), procdata); - gtk_box_pack_start(GTK_BOX(hbox2), solaris_button, TRUE, TRUE, 0); - - - - - hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); - gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, FALSE, 0); - - vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); - gtk_box_pack_start (GTK_BOX (proc_box), vbox, TRUE, TRUE, 0); - - tmp = g_strdup_printf ("<b>%s</b>", _("Information Fields")); - label = gtk_label_new (NULL); - gtk_label_set_xalign (GTK_LABEL (label), 0.0); - gtk_label_set_markup (GTK_LABEL (label), tmp); - g_free (tmp); - gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); - - hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); - gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0); - - label = gtk_label_new (" "); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - - vbox2 = create_field_page (procdata->tree, "proctree", _("Process i_nformation shown in list:")); - gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, TRUE, 0); - - sys_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); - gtk_container_set_border_width (GTK_CONTAINER (sys_box), 12); - tab_label = gtk_label_new (_("Resources")); - gtk_widget_show (tab_label); - gtk_notebook_append_page (GTK_NOTEBOOK (notebook), sys_box, tab_label); - - vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); - gtk_box_pack_start (GTK_BOX (sys_box), vbox, FALSE, FALSE, 0); - - tmp = g_strdup_printf ("<b>%s</b>", _("Graphs")); - label = gtk_label_new (NULL); - gtk_label_set_xalign (GTK_LABEL (label), 0.0); - gtk_label_set_markup (GTK_LABEL (label), tmp); - g_free (tmp); - gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, FALSE, 0); - - hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - label = gtk_label_new (" "); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + smooth_button = GET_WIDGET("smooth_button"); + g_settings_bind(procdata->settings, SmoothRefresh::KEY.c_str(), smooth_button, "active", G_SETTINGS_BIND_DEFAULT); - vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); - gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, TRUE, 0); + check_button = GET_WIDGET("check_button"); + g_settings_bind(procdata->settings, "kill-dialog", check_button, "active", G_SETTINGS_BIND_DEFAULT); - hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); - gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, FALSE, 0); + GtkWidget *solaris_button = GET_WIDGET("solaris_button"); + g_settings_bind(procdata->settings, procman::settings::solaris_mode.c_str(), solaris_button, "active", G_SETTINGS_BIND_DEFAULT); - label = gtk_label_new_with_mnemonic (_("_Update interval in 1/10 sec:")); - gtk_label_set_xalign (GTK_LABEL (label), 0.0); - gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, FALSE, 0); - gtk_size_group_add_widget (size, label); - - hbox3 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); - gtk_box_pack_start (GTK_BOX (hbox2), hbox3, TRUE, TRUE, 0); + create_field_page (builder, procdata->tree, "proctree"); update = (gfloat) procdata->config.graph_update_interval; adjustment = (GtkAdjustment *) gtk_adjustment_new(update / 1000.0, 0.25, 100.0, 0.25, 1.0, 0); - spin_button = gtk_spin_button_new (adjustment, 1.0, 2); + + spin_button = GET_WIDGET("resources_interval_spinner"); + gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON(spin_button), adjustment); + g_signal_connect (G_OBJECT (spin_button), "focus_out_event", G_CALLBACK(SBU::callback), &graph_interval_updater); - gtk_box_pack_start (GTK_BOX (hbox3), spin_button, FALSE, FALSE, 0); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), spin_button); - - - GtkWidget *bits_button; - bits_button = gtk_check_button_new_with_mnemonic(_("Show network speed in bits")); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(bits_button), - g_settings_get_boolean(procdata->settings, - procman::settings::network_in_bits.c_str())); - - g_signal_connect(G_OBJECT(bits_button), "toggled", - G_CALLBACK(network_in_bits_toggled), procdata); - gtk_box_pack_start(GTK_BOX(vbox2), bits_button, TRUE, TRUE, 0); - - - - hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); - gtk_box_pack_start (GTK_BOX (vbox2), hbox2, TRUE, TRUE, 0); - - /* - * Devices - */ - vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 12); - tab_label = gtk_label_new (_("File Systems")); - gtk_widget_show (tab_label); - gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox, tab_label); - - tmp = g_strdup_printf ("<b>%s</b>", _("File Systems")); - label = gtk_label_new (NULL); - gtk_label_set_xalign (GTK_LABEL (label), 0.0); - gtk_label_set_markup (GTK_LABEL (label), tmp); - g_free (tmp); - gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); - - hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - - label = gtk_label_new (" "); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - - vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); - gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, TRUE, 0); - hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); - gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, FALSE, 0); + GtkWidget *bits_button = GET_WIDGET("bits_button"); + g_settings_bind(procdata->settings, procman::settings::network_in_bits.c_str(), bits_button, "active", G_SETTINGS_BIND_DEFAULT); - label = gtk_label_new_with_mnemonic (_("_Update interval in seconds:")); - gtk_label_set_xalign (GTK_LABEL (label), 0.0); - gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, FALSE, 0); - - hbox3 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); - gtk_box_pack_start (GTK_BOX (hbox2), hbox3, TRUE, TRUE, 0); update = (gfloat) procdata->config.disks_update_interval; adjustment = (GtkAdjustment *) gtk_adjustment_new (update / 1000.0, 1.0, 100.0, 1.0, 1.0, 0); - spin_button = gtk_spin_button_new (adjustment, 1.0, 0); - gtk_box_pack_start (GTK_BOX (hbox3), spin_button, FALSE, FALSE, 0); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), spin_button); + + spin_button = GET_WIDGET("devices_interval_spinner"); + gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON(spin_button), adjustment); g_signal_connect (G_OBJECT (spin_button), "focus_out_event", G_CALLBACK(SBU::callback), &disks_interval_updater); + check_button = GET_WIDGET("all_devices_check"); + g_settings_bind(procdata->settings, "show-all-fs", check_button, "active", G_SETTINGS_BIND_DEFAULT); - hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); - gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, FALSE, 0); - check_button = gtk_check_button_new_with_mnemonic (_("Show _all file systems")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button), - procdata->config.show_all_fs); - g_signal_connect (G_OBJECT (check_button), "toggled", - G_CALLBACK (show_all_fs_toggled), procdata); - gtk_box_pack_start (GTK_BOX (hbox2), check_button, FALSE, FALSE, 0); - - - vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); - gtk_box_pack_start (GTK_BOX (vbox), vbox2, FALSE, FALSE, 0); - - label = gtk_label_new (" "); - gtk_box_pack_start (GTK_BOX (vbox2), label, FALSE, FALSE, 0); - - tmp = g_strdup_printf ("<b>%s</b>", _("Information Fields")); - label = gtk_label_new (NULL); - gtk_label_set_xalign (GTK_LABEL (label), 0.0); - gtk_label_set_markup (GTK_LABEL (label), tmp); - g_free (tmp); - gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); - - hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); - gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0); + create_field_page (builder, procdata->disk_list, "disktreenew"); - label = gtk_label_new (" "); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - - vbox3 = create_field_page (procdata->disk_list, "disktreenew", _("File system i_nformation shown in list:")); - gtk_box_pack_start (GTK_BOX (hbox), vbox3, TRUE, TRUE, 0); - - gtk_widget_show_all (dialog); - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (prefs_dialog_button_pressed), procdata); + gtk_widget_show_all (prefs_dialog); + g_signal_connect (G_OBJECT (prefs_dialog), "response", + G_CALLBACK (prefs_dialog_button_pressed), procdata); switch (procdata->config.current_tab) { case PROCMAN_TAB_SYSINFO: @@ -847,10 +538,11 @@ procdialog_create_preferences_dialog (ProcData *procdata) case PROCMAN_TAB_DISKS: gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 2); break; - } -} + gtk_builder_connect_signals (builder, NULL); + g_object_unref (G_OBJECT (builder)); +} static char * |