#include <glib.h>#include <gtk/gtk.h>#include <signal.h>#include "lininfo.h"#include "support.h"#include <string.h>#include <stdio.h>#include <stdlib.h>Go to the source code of this file.
Functions | |
| void | update_mem () |
| Refresh data in window widgets for memory. | |
| void | update_cpu () |
| Refresh data in window widgets for cpu. | |
Variables | |
| GtkWidget * | window1 |
| mem_info | mem |
| cpu_info | cpu |
|
|
Refresh data in window widgets for cpu. Update gtk widgets for cpu panel This function updates labels to show recent values. Before, it calls to get_cpu_info to collect data Definition at line 145 of file update.c. References cpu_info::bogomips, cpu_info::cache, cpu, cpu_info::cpu_family, cpu_info::cpuid_level, cpu_info::flags, cpu_info::fpu, cpu_info::fpu_exception, get_cpu_info(), lookup_widget(), cpu_info::Mhz, cpu_info::model, cpu_info::model_name, cpu_info::processor, cpu_info::stepping, cpu_info::vendor_id, window1, and cpu_info::wp. Referenced by main(). 00146 {
00147
00148 get_cpu_info (&cpu);
00149
00150 GtkLabel *cosa;
00151
00152 /*This function is called only once, before collector thread is created.
00153 So, we don't need thread lock. Only one thread is accessing gtk widgets
00154 at a time.*/
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 }
|
|
|
Refresh data in window widgets for memory. Update gtk widgets for memory panel This function updates labels, progress bar and other widgets to show the most recent values. Before, it calls to get_mem_info to collect data Definition at line 47 of file update.c. References mem_info::active, mem_info::buffers, mem_info::cached, mem_info::dirty, mem_info::free, get_mem_info(), mem_info::high_free, mem_info::high_total, mem_info::hugepages_free, mem_info::hugepages_size, mem_info::hugepages_total, mem_info::inactive, lookup_widget(), mem_info::low_free, mem_info::low_total, mem, mem_info::swap_cached, mem_info::swap_free, mem_info::swap_total, mem_info::total, and window1. Referenced by refresh(). 00048 {
00049
00050 GtkLabel *cosa;
00051 GtkProgressBar *progreso;
00052 gfloat total, free;
00053
00054 get_mem_info (&mem);
00055
00056 //Get Gtk thread lock
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 //Compute percentage of memory use
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 //Compute percentage of swap use. Reuse variables.
00122
00123
00124 total = atoi (strtok (mem.swap_total, " "));
00125 free = atoi (strtok (mem.swap_free, " "));
00126
00127 //g_assert(total!=0);
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 }
|
|
|
Definition at line 50 of file main.c. Referenced by get_cpu_info(), and update_cpu(). |
|
|
Definition at line 51 of file main.c. Referenced by get_mem_info(), and update_mem(). |
|
|
Update data functions Show updated data to user Definition at line 47 of file main.c. Referenced by create_window1(), main(), refresh(), update_cpu(), and update_mem(). |
1.3.9.1