[gnome-control-center] info: add primary disk size info
- From: William Jon McCann <mccann src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] info: add primary disk size info
- Date: Tue, 11 Jan 2011 00:46:06 +0000 (UTC)
commit b31b0e0f58dd5d38808b8b7eb843b95a0d0dfdd6
Author: William Jon McCann <jmccann redhat com>
Date: Mon Jan 10 19:42:19 2011 -0500
info: add primary disk size info
panels/info/cc-info-panel.c | 30 +++++++++++++++++++++++++++---
1 files changed, 27 insertions(+), 3 deletions(-)
---
diff --git a/panels/info/cc-info-panel.c b/panels/info/cc-info-panel.c
index 5eee2ce..aa32682 100644
--- a/panels/info/cc-info-panel.c
+++ b/panels/info/cc-info-panel.c
@@ -21,6 +21,8 @@
#include "cc-info-panel.h"
+#include <sys/vfs.h>
+
#include <glib.h>
#include <glib/gi18n.h>
@@ -241,6 +243,23 @@ get_os_type (void)
}
static char *
+get_primary_disc_info (void)
+{
+ guint64 total_bytes;
+ struct statfs buf;
+
+ if (statfs ("/", &buf) < 0)
+ {
+ g_warning ("Unable to stat / filesystem: %s", g_strerror (errno));
+ return NULL;
+ }
+ else
+ total_bytes = (guint64) buf.f_blocks * buf.f_bsize;
+
+ return g_format_size_for_display (total_bytes);
+}
+
+static char *
get_cpu_info (const glibtop_sysinfo *info)
{
GHashTable *counts;
@@ -333,19 +352,24 @@ cc_info_panel_init (CcInfoPanel *self)
glibtop_get_mem (&mem);
text = g_format_size_for_display (mem.total);
widget = WID (self->priv->builder, "memory_label");
- gtk_label_set_text (GTK_LABEL (widget), text);
+ gtk_label_set_text (GTK_LABEL (widget), text ? text : "");
g_free (text);
info = glibtop_get_sysinfo ();
widget = WID (self->priv->builder, "processor_label");
text = get_cpu_info (info);
- gtk_label_set_text (GTK_LABEL (widget), text);
+ gtk_label_set_text (GTK_LABEL (widget), text ? text : "");
g_free (text);
widget = WID (self->priv->builder, "os_type_label");
text = get_os_type ();
- gtk_label_set_text (GTK_LABEL (widget), text);
+ gtk_label_set_text (GTK_LABEL (widget), text ? text : "");
+ g_free (text);
+
+ widget = WID (self->priv->builder, "disk_label");
+ text = get_primary_disc_info ();
+ gtk_label_set_text (GTK_LABEL (widget), text ? text : "");
g_free (text);
widget = WID (self->priv->builder, "info_vbox");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]