gnome-system-monitor/gnome-system-monitor-sysinfo.patch

513 lines
14 KiB
Diff
Raw Normal View History

diff -urpN gnome-system-monitor-2.12.2-pristine/src/callbacks.c gnome-system-monitor-2.12.2/src/callbacks.c
--- gnome-system-monitor-2.12.2-pristine/src/callbacks.c 2005-08-11 10:50:26.000000000 -0400
+++ gnome-system-monitor-2.12.2/src/callbacks.c 2006-06-06 11:28:44.000000000 -0400
@@ -374,7 +374,7 @@ cb_change_current_page (GtkNotebook *nb,
procdata->config.current_tab = num;
- if (num == 0) {
+ if (num == 1) {
cb_timeout (procdata);
@@ -396,7 +396,7 @@ cb_change_current_page (GtkNotebook *nb,
}
- if (num == 1) {
+ if (num == 2) {
load_graph_start (procdata->cpu_graph);
load_graph_start (procdata->mem_graph);
load_graph_start (procdata->net_graph);
@@ -408,7 +408,7 @@ cb_change_current_page (GtkNotebook *nb,
}
- if (num == 2) {
+ if (num == 3) {
cb_update_disks (procdata);
diff -urpN gnome-system-monitor-2.12.2-pristine/src/interface.c gnome-system-monitor-2.12.2/src/interface.c
--- gnome-system-monitor-2.12.2-pristine/src/interface.c 2005-08-11 10:50:26.000000000 -0400
+++ gnome-system-monitor-2.12.2/src/interface.c 2006-06-06 15:52:31.000000000 -0400
@@ -29,6 +29,8 @@
#include <signal.h>
#include <gdk/gdkkeysyms.h>
#include <math.h>
+#include <glibtop/mountlist.h>
+#include <glibtop/fsusage.h>
#include "procman.h"
#include "callbacks.h"
@@ -155,6 +157,413 @@ static const char ui_info[] =
" <menuitem action=\"OpenFiles\" />"
" </popup>";
+typedef struct {
+ gchar *distro_name;
+ gchar *distro_version;
+ gchar *distro_release;
+
+ glong memory_bytes;
+ gint n_processors;
+ gchar **processor_models;
+
+ guint64 free_space_bytes;
+} SysInfoData;
+
+static SysInfoData *get_system_information (void);
+static void sys_info_data_free (SysInfoData *);
+
+static void load_distro_info (SysInfoData *);
+static void load_memory_info (SysInfoData *);
+static void load_processor_info (SysInfoData *);
+static void load_disk_space_info (SysInfoData *);
+
+static SysInfoData *
+get_system_information ()
+{
+ SysInfoData *data = g_new0 (SysInfoData, 1);
+
+ load_distro_info (data);
+ load_memory_info (data);
+ load_processor_info (data);
+ load_disk_space_info (data);
+
+ return data;
+}
+
+static void
+sys_info_data_free (SysInfoData *data)
+{
+ gint i;
+
+ g_return_if_fail (data);
+
+ g_free (data->distro_name);
+ g_free (data->distro_version);
+ g_free (data->distro_release);
+
+ for (i = 0; i < data->n_processors; ++i)
+ g_free (data->processor_models [i]);
+
+ g_free (data->processor_models);
+
+ g_free (data);
+}
+
+static void
+load_distro_info (SysInfoData *data)
+{
+ gchar *contents;
+ gchar **lines;
+
+ gchar *cursor;
+ gint i;
+
+ GError *error = NULL;
+
+
+ g_assert (data);
+
+ if (g_file_get_contents ("/etc/SuSE-release", & contents, NULL, & error)) {
+ lines = g_strsplit (contents, "\n", 0);
+
+ for (i = 0; lines [i]; ++i) {
+ if (strstr (lines [i], "VERSION")) {
+ cursor = strstr (lines [i], "=") + 1;
+ g_strstrip (cursor);
+
+ data->distro_version = g_strdup (cursor);
+ }
+ else if (strstr (lines [i], "RELEASE")) {
+ cursor = strstr (lines [i], "=") + 1;
+ g_strstrip (cursor);
+
+ data->distro_release = g_strdup (cursor);
+ }
+ else if (! data->distro_name) {
+ g_strstrip (lines [i]);
+
+ data->distro_name = g_strdup (lines [i]);
+ }
+ else
+ ;
+ }
+
+ g_strfreev (lines);
+ g_free (contents);
+ }
+ else {
+ g_error ("Error opening /etc/SuSE-release [%s]\n", error->message);
+
+ g_error_free (error);
+ }
+}
+
+static void
+load_memory_info (SysInfoData *data)
+{
+ gchar *contents;
+ gchar **lines;
+ gchar **tokens;
+
+ gint i, j;
+
+ GError *error = NULL;
+
+
+ g_assert (data);
+
+ if (g_file_get_contents ("/proc/meminfo", & contents, NULL, & error)) {
+ lines = g_strsplit (contents, "\n", 0);
+
+ for (i = 0; lines [i]; ++i) {
+ if (strstr (lines [i], "MemTotal: ")) {
+ tokens = g_strsplit (lines [i], " ", 0);
+
+ for (j = 1; tokens [j]; ++j)
+ if (strlen (tokens [j]) > 0 && g_ascii_isdigit (* tokens [j]))
+ data->memory_bytes = atol (tokens [j]) * 1024;
+
+ g_strfreev (tokens);
+ }
+ }
+
+ g_strfreev (lines);
+ g_free (contents);
+ }
+ else {
+ g_error ("Error opening /proc/meminfo [%s]\n", error->message);
+
+ g_error_free (error);
+ }
+}
+
+static void
+load_processor_info (SysInfoData *data)
+{
+ GList *processors;
+ gint n_processors;
+
+ gchar *contents;
+ gchar **lines;
+
+ gchar *cursor;
+ gint i;
+
+ GList *node;
+
+ GError *error = NULL;
+
+
+ g_assert (data);
+
+ if (! g_file_get_contents ("/proc/cpuinfo", & contents, NULL, & error)) {
+ g_error ("Couldn't open /proc/cpuinfo: %s", error->message);
+
+ g_error_free (error);
+
+ return;
+ }
+
+ lines = g_strsplit (contents, "\n", 0);
+
+ processors = NULL;
+ n_processors = 0;
+
+ for (i = 0; lines [i]; ++i) {
+ if (strstr (lines [i], "processor\t:")) {
+ n_processors ++;
+
+ cursor = strstr (lines [i], ":");
+
+ for (; lines [i]; ++i) {
+ if (strstr (lines [i], "model name\t:")) {
+ cursor = strstr (lines [i], ":");
+
+ if (strlen (cursor) > 1) {
+ g_strstrip (++ cursor);
+
+ processors = g_list_append (processors, cursor);
+ }
+
+ break;
+ }
+ }
+
+ if (! lines [i])
+ break;
+ }
+ }
+
+ data->n_processors = n_processors;
+ data->processor_models = g_new0 (gchar *, n_processors);
+
+ for (i = 0, node = processors; i < n_processors && node; ++i, node = node->next)
+ data->processor_models [i] = g_strdup ((gchar *) node->data);
+
+ g_strfreev (lines);
+ g_free (contents);
+}
+
+static void
+load_disk_space_info (SysInfoData *data)
+{
+ glibtop_mountentry *entries;
+ glibtop_mountlist mountlist;
+ glibtop_fsusage usage;
+
+ gint i;
+
+
+ g_assert (data);
+
+ entries = glibtop_get_mountlist (& mountlist, 0);
+
+ data->free_space_bytes = 0;
+
+ for (i = 0; i < mountlist.number; ++i) {
+ if (! strncmp (entries [i].devname, "/dev/", 5)) {
+ glibtop_get_fsusage (& usage, entries [i].mountdir);
+
+ data->free_space_bytes += usage.bfree * usage.block_size;
+ }
+ }
+
+ g_free (entries);
+}
+
+static GtkWidget *
+create_sysinfo_view (void)
+{
+ GtkWidget *hbox;
+ GtkWidget *vbox;
+
+ SysInfoData *data;
+
+ GtkWidget *novell_logo;
+
+ GtkWidget *distro_frame;
+
+ GtkWidget *hardware_frame;
+ GtkWidget *hardware_table;
+ GtkWidget *memory_label;
+ GtkWidget *processor_label;
+
+ GtkWidget *disk_space_frame;
+ GtkWidget *disk_space_table;
+ GtkWidget *disk_space_label;
+
+ GtkWidget *header;
+ GtkWidget *alignment;
+
+ gchar *markup;
+ gint i;
+
+
+ if (! (data = get_system_information ()))
+ return NULL;
+
+ hbox = gtk_hbox_new (FALSE, 12);
+ gtk_container_set_border_width (GTK_CONTAINER (hbox), 6);
+
+/* left-side logo */
+
+ novell_logo = gtk_image_new_from_file (DATADIR "/pixmaps/gnome-system-monitor/n-side.png");
+ gtk_misc_set_alignment (GTK_MISC (novell_logo), 0.5, 0.0);
+ gtk_misc_set_padding (GTK_MISC (novell_logo), 5, 12);
+ gtk_box_pack_start (GTK_BOX (hbox), novell_logo, FALSE, FALSE, 0);
+
+ vbox = gtk_vbox_new (FALSE, 12);
+ gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
+ gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
+
+/* distro section */
+
+ markup = g_strdup_printf ("<big><big><b>%s</b></big></big>", data->distro_name);
+ distro_frame = gtk_frame_new (markup);
+ gtk_frame_set_label_align (GTK_FRAME (distro_frame), 0.0, 0.5);
+ gtk_label_set_use_markup (
+ GTK_LABEL (gtk_frame_get_label_widget (GTK_FRAME (distro_frame))),
+ TRUE
+ );
+ gtk_frame_set_shadow_type (GTK_FRAME (distro_frame), GTK_SHADOW_NONE);
+ gtk_box_pack_start (GTK_BOX (vbox), distro_frame, FALSE, FALSE, 0);
+ g_free (markup);
+
+ alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 12, 0);
+ gtk_container_add (GTK_CONTAINER (distro_frame), alignment);
+
+/* hardware section */
+
+ markup = g_strdup_printf (_("<b>Hardware</b>"));
+ hardware_frame = gtk_frame_new (markup);
+ gtk_frame_set_label_align (GTK_FRAME (hardware_frame), 0.0, 0.5);
+ gtk_label_set_use_markup (
+ GTK_LABEL (gtk_frame_get_label_widget (GTK_FRAME (hardware_frame))),
+ TRUE
+ );
+ gtk_frame_set_shadow_type (GTK_FRAME (hardware_frame), GTK_SHADOW_NONE);
+ gtk_box_pack_start (GTK_BOX (vbox), hardware_frame, FALSE, FALSE, 0);
+ g_free (markup);
+
+ alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 12, 0);
+ gtk_container_add (GTK_CONTAINER (hardware_frame), alignment);
+
+ hardware_table = gtk_table_new (1 + data->n_processors, 2, FALSE);
+ gtk_table_set_row_spacings (GTK_TABLE (hardware_table), 6);
+ gtk_table_set_col_spacings (GTK_TABLE (hardware_table), 6);
+ gtk_container_set_border_width (GTK_CONTAINER (hardware_table), 6);
+ gtk_container_add (GTK_CONTAINER (alignment), hardware_table);
+
+ header = gtk_label_new (_("Memory:"));
+ gtk_misc_set_alignment (GTK_MISC (header), 0.0, 0.5);
+ gtk_table_attach (
+ GTK_TABLE (hardware_table), header,
+ 0, 1, 0, 1,
+ GTK_FILL, 0, 0, 0
+ );
+
+ markup = SI_gnome_vfs_format_file_size_for_display (data->memory_bytes);
+ memory_label = gtk_label_new (markup);
+ gtk_misc_set_alignment (GTK_MISC (memory_label), 0.0, 0.5);
+ gtk_table_attach (
+ GTK_TABLE (hardware_table), memory_label,
+ 1, 2, 0, 1,
+ GTK_FILL, 0, 0, 0
+ );
+ g_free (markup);
+
+ for (i = 0; i < data->n_processors; ++i) {
+ if (data->n_processors > 1) {
+ markup = g_strdup_printf (_("Processor %d:"), i);
+
+ header = gtk_label_new (markup);
+ }
+ else
+ header = gtk_label_new (_("Processor:"));
+
+ gtk_misc_set_alignment (GTK_MISC (header), 0.0, 0.5);
+ gtk_table_attach (
+ GTK_TABLE (hardware_table), header,
+ 0, 1, 1 + i, 2 + i,
+ GTK_FILL, 0, 0, 0
+ );
+
+ processor_label = gtk_label_new (data->processor_models [i]);
+ gtk_misc_set_alignment (GTK_MISC (processor_label), 0.0, 0.5);
+ gtk_table_attach (
+ GTK_TABLE (hardware_table), processor_label,
+ 1, 2, 1 + i, 2 + i,
+ GTK_FILL, 0, 0, 0
+ );
+ }
+
+/* disk space section */
+
+ markup = g_strdup_printf (_("<b>System Status</b>"));
+ disk_space_frame = gtk_frame_new (markup);
+ gtk_frame_set_label_align (GTK_FRAME (disk_space_frame), 0.0, 0.5);
+ gtk_label_set_use_markup (
+ GTK_LABEL (gtk_frame_get_label_widget (GTK_FRAME (disk_space_frame))),
+ TRUE
+ );
+ gtk_frame_set_shadow_type (GTK_FRAME (disk_space_frame), GTK_SHADOW_NONE);
+ gtk_box_pack_start (GTK_BOX (vbox), disk_space_frame, FALSE, FALSE, 0);
+ g_free (markup);
+
+ alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 12, 0);
+ gtk_container_add (GTK_CONTAINER (disk_space_frame), alignment);
+
+ disk_space_table = gtk_table_new (1, 2, FALSE);
+ gtk_table_set_row_spacings (GTK_TABLE (disk_space_table), 6);
+ gtk_table_set_col_spacings (GTK_TABLE (disk_space_table), 6);
+ gtk_container_set_border_width (GTK_CONTAINER (disk_space_table), 6);
+ gtk_container_add (GTK_CONTAINER (alignment), disk_space_table);
+
+ header = gtk_label_new (_("User Space Free:"));
+ gtk_misc_set_alignment (GTK_MISC (header), 0.0, 0.5);
+ gtk_table_attach (
+ GTK_TABLE (disk_space_table), header,
+ 0, 1, 0, 1,
+ GTK_FILL, 0, 0, 0
+ );
+
+ markup = SI_gnome_vfs_format_file_size_for_display (data->free_space_bytes);
+ disk_space_label = gtk_label_new (markup);
+ gtk_misc_set_alignment (GTK_MISC (disk_space_label), 0.0, 0.5);
+ gtk_table_attach (
+ GTK_TABLE (disk_space_table), disk_space_label,
+ 1, 2, 0, 1,
+ GTK_FILL, 0, 0, 0
+ );
+ g_free (markup);
+
+ sys_info_data_free (data);
+
+ return hbox;
+}
static GtkWidget *
create_proc_view (ProcData *procdata)
@@ -676,6 +1085,8 @@ create_main_window (ProcData *procdata)
GtkWidget *tab_label1, *tab_label2, *tab_label3;
GtkWidget *vbox1;
GtkWidget *sys_box, *devices_box;
+ GtkWidget *sysinfo_box;
+ GtkWidget *sysinfo_label;
app = gnome_app_new ("procman", _("System Monitor"));
@@ -742,6 +1153,12 @@ create_main_window (ProcData *procdata)
0);
gtk_widget_show (notebook);
+ sysinfo_box = create_sysinfo_view ();
+ gtk_widget_show_all (sysinfo_box);
+ sysinfo_label = gtk_label_new (_("System"));
+ gtk_widget_show (sysinfo_label);
+ gtk_notebook_append_page (GTK_NOTEBOOK (notebook), sysinfo_box, sysinfo_label);
+
vbox1 = create_proc_view (procdata);
gtk_widget_show (vbox1);
tab_label1 = gtk_label_new (_("Processes"));
Files gnome-system-monitor-2.12.2-pristine/src/.interface.c.swp and gnome-system-monitor-2.12.2/src/.interface.c.swp differ
diff -urpN gnome-system-monitor-2.12.2-pristine/src/procdialogs.c gnome-system-monitor-2.12.2/src/procdialogs.c
--- gnome-system-monitor-2.12.2-pristine/src/procdialogs.c 2005-07-07 19:41:25.000000000 -0400
+++ gnome-system-monitor-2.12.2/src/procdialogs.c 2006-06-06 11:28:44.000000000 -0400
@@ -799,7 +799,7 @@ procdialog_create_preferences_dialog (Pr
g_signal_connect (G_OBJECT (dialog), "response",
G_CALLBACK (prefs_dialog_button_pressed), procdata);
- if (procdata->config.current_tab == 0)
+ if (procdata->config.current_tab <= 1)
gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), 0);
else
gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), 1);
diff -urpN gnome-system-monitor-2.12.2-pristine/src/procman.c gnome-system-monitor-2.12.2/src/procman.c
--- gnome-system-monitor-2.12.2-pristine/src/procman.c 2005-10-01 03:47:21.000000000 -0400
+++ gnome-system-monitor-2.12.2/src/procman.c 2006-06-06 11:28:44.000000000 -0400
@@ -73,7 +73,7 @@ view_as_changed_cb (GConfClient *client,
GConfValue *value = gconf_entry_get_value (entry);
procdata->config.whose_process = gconf_value_get_int (value);
- procdata->config.whose_process = CLAMP (procdata->config.whose_process, 0, 2);
+ procdata->config.whose_process = CLAMP (procdata->config.whose_process, 0, 3);
proctable_clear_tree (procdata);
proctable_update_all (procdata);
@@ -385,7 +385,7 @@ procman_data_new (GConfClient *client)
pd->config.graph_update_interval = MAX (pd->config.graph_update_interval, 250);
pd->config.disks_update_interval = MAX (pd->config.disks_update_interval, 1000);
pd->config.whose_process = CLAMP (pd->config.whose_process, 0, 2);
- pd->config.current_tab = CLAMP (pd->config.current_tab, 0, 2);
+ pd->config.current_tab = CLAMP (pd->config.current_tab, 0, 3);
/* Determinie number of cpus since libgtop doesn't really tell you*/
pd->config.num_cpus = 0;