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
00029 #ifdef HAVE_CONFIG_H
00030 # include <config.h>
00031 #endif
00032
00033 #include <gtk/gtk.h>
00034 #include <sys/types.h>
00035 #include <signal.h>
00036
00037 #include "interface.h"
00038 #include "support.h"
00039 #include "lininfo.h"
00040 #include "update.h"
00041 #include "lkmonitor.h"
00042
00043 #include <unistd.h>
00044 #include <stdio.h>
00045 #include <glib.h>
00046
00047
00048 GtkWidget *window1;
00049
00050
00051
00052
00053
00054 struct cpu_info cpu;
00055 struct mem_info mem;
00056 struct dev_info devs;
00057 struct settings_info settings;
00058 struct stats_info stats;
00059 struct acpi_info acpi;
00060 struct cmd_ver cmdversion;
00061 struct channels_info cn_info;
00062 struct net_dev_info netinfo;
00063 struct fs_info fsinfo;
00064 struct modules_info modinfo;
00065
00066 pthread_t thread_id;
00067 GThread *gt_collector=NULL;
00068
00069 gboolean is_icon=FALSE;
00070 gboolean collector_exit=FALSE;
00071
00077 void
00078 refresh (void* nothing)
00079 {
00080 int page;
00081 GtkNotebook *nb;
00082
00083 nb = (GtkNotebook *) (lookup_widget (window1, "nb_main"));
00084
00085 while(!collector_exit){
00086 if(!is_icon){
00087 page = (int) gtk_notebook_get_current_page (nb);
00088 switch (page)
00089 {
00090 case 0:
00091 update_cpu_mhz();
00092 break;
00093 case 1:
00094 update_mem ();
00095 break;
00096 case 2:
00097
00098 break;
00099 case 3:
00100
00101 break;
00102 case 4:
00103 update_misc();
00104 break;
00105 case 5:
00106 update_process();
00107 break;
00108 case 6:
00109 break;
00110 case 7:
00111 update_net_info();
00112 break;
00113 case 8:
00114 update_fs_info();
00115 break;
00116 }
00117 }
00118 sleep(1);
00119
00120 }
00121 }
00122
00128 int
00129 main (int argc, char *argv[])
00130 {
00131 gnome_program_init (PACKAGE, VERSION, LIBGNOMEUI_MODULE,
00132 argc, argv,
00133 GNOME_PARAM_APP_DATADIR, PACKAGE_DATA_DIR,
00134 NULL);
00135
00136 #ifdef ENABLE_NLS
00137 bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
00138 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
00139 textdomain (GETTEXT_PACKAGE);
00140 #endif
00141
00142
00143 gdk_threads_init ();
00144
00145
00146 gtk_set_locale ();
00147 gtk_init (&argc, &argv);
00148
00149
00150
00151
00152
00153
00154
00155 lkmonitor_create_tray_icon();
00156 window1 = create_window1 ();
00157
00158
00159 lkmonitor_init_widgets(window1);
00160
00161 gtk_widget_show (window1);
00162
00163
00164
00165
00166
00167 update_cpu ();
00168 update_devs();
00169 update_settings();
00170 update_cmd_ver();
00171 update_channels();
00172 update_net_info();
00173 update_modules_info();
00174
00175 if(get_battery_info(&acpi.battery,BATT_INFO)==-1)
00176 get_battery_info(&acpi.battery,BATT_INFO1);
00177
00178
00179 gdk_threads_enter ();
00180
00181
00182
00183 gt_collector=g_thread_create((GThreadFunc)refresh,NULL,TRUE,NULL);
00184 if(gt_collector!=NULL)
00185 g_message("Collector thread created");
00186 else
00187
00188 g_critical("Could not create thread!");
00189
00190
00191 gtk_main ();
00192
00193 gdk_threads_leave();
00194
00195 g_thread_join(gt_collector);
00196
00197 return 0;
00198 }