00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00025
00026 #include <glib.h>
00027
00028 #include <gtk/gtk.h>
00029 #include <signal.h>
00030 #include "lininfo.h"
00031 #include "support.h"
00032 #include <string.h>
00033 #include <stdio.h>
00034 #include <stdlib.h>
00035
00036
00037 extern GtkWidget *window1;
00038 extern struct mem_info mem;
00039 extern struct cpu_info cpu;
00040
00046 void
00047 update_mem ()
00048 {
00049
00050 GtkLabel *cosa;
00051 GtkProgressBar *progreso;
00052 gfloat total, free;
00053
00054 get_mem_info (&mem);
00055
00056
00057 gdk_threads_enter();
00058
00059 cosa = (GtkLabel *) lookup_widget (window1, "lbl_total");
00060 gtk_label_set_text (cosa, (gchar *) mem.total);
00061
00062 cosa = (GtkLabel *) lookup_widget (window1, "lbl_free");
00063 gtk_label_set_text (cosa, (gchar *) mem.free);
00064
00065 cosa = (GtkLabel *) lookup_widget (window1, "lbl_buffers");
00066 gtk_label_set_text (cosa, (gchar *) mem.buffers);
00067
00068 cosa = (GtkLabel *) lookup_widget (window1, "lbl_cached");
00069 gtk_label_set_text (cosa, (gchar *) mem.cached);
00070
00071 cosa = (GtkLabel *) lookup_widget (window1, "lbl_swap_cached");
00072 gtk_label_set_text (cosa, (gchar *) mem.swap_cached);
00073
00074 cosa = (GtkLabel *) lookup_widget (window1, "lbl_active");
00075 gtk_label_set_text (cosa, (gchar *) mem.active);
00076
00077 cosa = (GtkLabel *) lookup_widget (window1, "lbl_inactive");
00078 gtk_label_set_text (cosa, (gchar *) mem.inactive);
00079
00080 cosa = (GtkLabel *) lookup_widget (window1, "lbl_dirty");
00081 gtk_label_set_text (cosa, (gchar *) mem.dirty);
00082
00083 cosa = (GtkLabel *) lookup_widget (window1, "lbl_hp_total");
00084 gtk_label_set_text (cosa, (gchar *) mem.hugepages_total);
00085
00086 cosa = (GtkLabel *) lookup_widget (window1, "lbl_hp_free");
00087 gtk_label_set_text (cosa, (gchar *) mem.hugepages_free);
00088
00089 cosa = (GtkLabel *) lookup_widget (window1, "lbl_hp_size");
00090 gtk_label_set_text (cosa, (gchar *) mem.hugepages_size);
00091
00092 cosa = (GtkLabel *) lookup_widget (window1, "lbl_high_total");
00093 gtk_label_set_text (cosa, (gchar *) mem.high_total);
00094
00095 cosa = (GtkLabel *) lookup_widget (window1, "lbl_high_free");
00096 gtk_label_set_text (cosa, (gchar *) mem.high_free);
00097
00098 cosa = (GtkLabel *) lookup_widget (window1, "lbl_low_total");
00099 gtk_label_set_text (cosa, (gchar *) mem.low_total);
00100
00101
00102 cosa = (GtkLabel *) lookup_widget (window1, "lbl_low_free");
00103 gtk_label_set_text (cosa, (gchar *) mem.low_free);
00104
00105 cosa = (GtkLabel *) lookup_widget (window1, "lbl_swap_total");
00106 gtk_label_set_text (cosa, (gchar *) mem.swap_total);
00107
00108 cosa = (GtkLabel *) lookup_widget (window1, "lbl_swap_free");
00109 gtk_label_set_text (cosa, (gchar *) mem.swap_free);
00110
00111
00112 total = atoi (strtok (mem.total, " "));
00113 free = atoi (strtok (mem.free, " "));
00114
00115 g_assert(total!=0);
00116
00117 progreso = (GtkProgressBar *) (lookup_widget (window1, "pb_mem"));
00118 gtk_progress_bar_set_fraction (progreso, (gfloat) ((total - free) / total));
00119
00120
00121
00122
00123
00124 total = atoi (strtok (mem.swap_total, " "));
00125 free = atoi (strtok (mem.swap_free, " "));
00126
00127
00128
00129 progreso = (GtkProgressBar *) (lookup_widget (window1, "pb_swap"));
00130
00131 if(total!=0)
00132 gtk_progress_bar_set_fraction (progreso, (gfloat) ((total - free) / total));
00133 else
00134 gtk_progress_bar_set_text(progreso, (gchar *)"Not present");
00135
00136 gdk_threads_leave();
00137 }
00138
00139
00144 void
00145 update_cpu ()
00146 {
00147
00148 get_cpu_info (&cpu);
00149
00150 GtkLabel *cosa;
00151
00152
00153
00154
00155
00156 cosa = (GtkLabel *) lookup_widget (window1, "lbl_processor");
00157 gtk_label_set_text (cosa, (gchar *) cpu.processor);
00158
00159 cosa = (GtkLabel *) lookup_widget (window1, "lbl_vendor");
00160 gtk_label_set_text (cosa, (gchar *) cpu.vendor_id);
00161
00162 cosa = (GtkLabel *) lookup_widget (window1, "lbl_family");
00163 gtk_label_set_text (cosa, (gchar *) cpu.cpu_family);
00164
00165
00166 cosa = (GtkLabel *) lookup_widget (window1, "lbl_model");
00167 gtk_label_set_text (cosa, (gchar *) cpu.model);
00168
00169 cosa = (GtkLabel *) lookup_widget (window1, "lbl_model_name");
00170 gtk_label_set_text (cosa, (gchar *) cpu.model_name);
00171
00172 cosa = (GtkLabel *) lookup_widget (window1, "lbl_stepping");
00173 gtk_label_set_text (cosa, (gchar *) cpu.stepping);
00174
00175 cosa = (GtkLabel *) lookup_widget (window1, "lbl_Mhz");
00176 gtk_label_set_text (cosa, (gchar *) cpu.Mhz);
00177
00178 cosa = (GtkLabel *) lookup_widget (window1, "lbl_cache");
00179 gtk_label_set_text (cosa, (gchar *) cpu.cache);
00180
00181 cosa = (GtkLabel *) lookup_widget (window1, "lbl_fpu");
00182 gtk_label_set_text (cosa, (gchar *) cpu.fpu);
00183
00184 cosa = (GtkLabel *) lookup_widget (window1, "lbl_fpu_exception");
00185 gtk_label_set_text (cosa, (gchar *) cpu.fpu_exception);
00186
00187 cosa = (GtkLabel *) lookup_widget (window1, "lbl_cpu_id_level");
00188 gtk_label_set_text (cosa, (gchar *) cpu.cpuid_level);
00189
00190 cosa = (GtkLabel *) lookup_widget (window1, "lbl_wp");
00191 gtk_label_set_text (cosa, (gchar *) cpu.wp);
00192
00193 cosa = (GtkLabel *) lookup_widget (window1, "lbl_bogomips");
00194 gtk_label_set_text (cosa, (gchar *) cpu.bogomips);
00195
00196 cosa = (GtkLabel *) lookup_widget (window1, "lbl_flags");
00197 gtk_label_set_text (cosa, (gchar *) cpu.flags);
00198
00199
00200 }