00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifdef HAVE_CONFIG_H
00029 # include <config.h>
00030 #endif
00031
00032 #include <gtk/gtk.h>
00033 #include <sys/types.h>
00034 #include <signal.h>
00035
00036 #include "interface.h"
00037 #include "support.h"
00038 #include "lininfo.h"
00039 #include "update.h"
00040 #include "lkmonitor.h"
00041
00042 #include <unistd.h>
00043 #include <stdio.h>
00044 #include <glib.h>
00045
00046
00047 GtkWidget *window1;
00048
00049
00050
00051
00052
00053 struct cpu_info cpu;
00054 struct mem_info mem;
00055 struct dev_info devs;
00056 struct settings_info settings;
00057 struct stats_info stats;
00058 struct acpi_info acpi;
00059
00060 pthread_t thread_id;
00061 GThread *gt_collector=NULL;
00062
00063 gboolean is_icon=FALSE;
00064 gboolean collector_exit=FALSE;
00065
00071 void
00072 refresh (void* nothing)
00073 {
00074 int page;
00075 GtkNotebook *nb;
00076
00077 nb = (GtkNotebook *) (lookup_widget (window1, "nb_main"));
00078
00079 while(!collector_exit){
00080 if(!is_icon){
00081 page = (int) gtk_notebook_get_current_page (nb);
00082 switch (page)
00083 {
00084 case 0:
00085 update_cpu_mhz();
00086 break;
00087 case 1:
00088 update_mem ();
00089 break;
00090 case 2:
00091
00092 break;
00093 case 3:
00094
00095 break;
00096 case 4:
00097 update_misc();
00098 }
00099 }
00100 sleep(1);
00101
00102 }
00103 }
00104
00110 int
00111 main (int argc, char *argv[])
00112 {
00113 gnome_program_init (PACKAGE, VERSION, LIBGNOMEUI_MODULE,
00114 argc, argv,
00115 GNOME_PARAM_APP_DATADIR, PACKAGE_DATA_DIR,
00116 NULL);
00117
00118 #ifdef ENABLE_NLS
00119 bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
00120 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
00121 textdomain (GETTEXT_PACKAGE);
00122 #endif
00123
00124
00125 gdk_threads_init ();
00126
00127
00128 gtk_set_locale ();
00129 gtk_init (&argc, &argv);
00130
00131
00132
00133
00134
00135
00136
00137 lkmonitor_create_tray_icon();
00138 window1 = create_window1 ();
00139
00140
00141 lkmonitor_init_widgets(window1);
00142
00143 gtk_widget_show (window1);
00144
00145
00146
00147
00148 update_cpu ();
00149 update_devs();
00150 update_settings();
00151
00152 if(get_battery_info(&acpi.battery,BATT_INFO)==-1)
00153 get_battery_info(&acpi.battery,BATT_INFO1);
00154
00155
00156 gdk_threads_enter ();
00157
00158
00159
00160 gt_collector=g_thread_create((GThreadFunc)refresh,NULL,TRUE,NULL);
00161 if(gt_collector!=NULL)
00162 g_message("Collector thread created");
00163 else
00164
00165 g_critical("Could not create thread!");
00166
00167
00168 gtk_main ();
00169
00170 gdk_threads_leave();
00171
00172 g_thread_join(gt_collector);
00173
00174 return 0;
00175 }