info: add primary disk size info
This commit is contained in:
parent
42732d45fb
commit
b31b0e0f58
1 changed files with 27 additions and 3 deletions
|
@ -21,6 +21,8 @@
|
||||||
|
|
||||||
#include "cc-info-panel.h"
|
#include "cc-info-panel.h"
|
||||||
|
|
||||||
|
#include <sys/vfs.h>
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
|
|
||||||
|
@ -240,6 +242,23 @@ get_os_type (void)
|
||||||
return g_strdup_printf (_("%d-bit"), bits);
|
return g_strdup_printf (_("%d-bit"), bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 *
|
static char *
|
||||||
get_cpu_info (const glibtop_sysinfo *info)
|
get_cpu_info (const glibtop_sysinfo *info)
|
||||||
{
|
{
|
||||||
|
@ -333,19 +352,24 @@ cc_info_panel_init (CcInfoPanel *self)
|
||||||
glibtop_get_mem (&mem);
|
glibtop_get_mem (&mem);
|
||||||
text = g_format_size_for_display (mem.total);
|
text = g_format_size_for_display (mem.total);
|
||||||
widget = WID (self->priv->builder, "memory_label");
|
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);
|
g_free (text);
|
||||||
|
|
||||||
info = glibtop_get_sysinfo ();
|
info = glibtop_get_sysinfo ();
|
||||||
|
|
||||||
widget = WID (self->priv->builder, "processor_label");
|
widget = WID (self->priv->builder, "processor_label");
|
||||||
text = get_cpu_info (info);
|
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);
|
g_free (text);
|
||||||
|
|
||||||
widget = WID (self->priv->builder, "os_type_label");
|
widget = WID (self->priv->builder, "os_type_label");
|
||||||
text = get_os_type ();
|
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);
|
g_free (text);
|
||||||
|
|
||||||
widget = WID (self->priv->builder, "info_vbox");
|
widget = WID (self->priv->builder, "info_vbox");
|
||||||
|
|
Loading…
Add table
Reference in a new issue