main.c File Reference

#include <gtk/gtk.h>
#include <sys/types.h>
#include <signal.h>
#include "interface.h"
#include "support.h"
#include "lininfo.h"
#include "update.h"
#include "lkmonitor.h"
#include <unistd.h>
#include <stdio.h>
#include <glib.h>

Go to the source code of this file.

Functions

void refresh (void *nothing)
int main (int argc, char *argv[])

Variables

GtkWidget * window1
cpu_info cpu
mem_info mem
dev_info devs
settings_info settings
stats_info stats
acpi_info acpi
pthread_t thread_id
GThread * gt_collector = NULL
gboolean is_icon = FALSE
gboolean collector_exit = FALSE


Function Documentation

int main ( int  argc,
char *  argv[] 
)

Program entry point

Parameters:
argc Number of arguments
argv string array (for arguments)
Returns:
0 if normal program exit

Definition at line 111 of file main.c.

References acpi, BATT_INFO, BATT_INFO1, acpi_info::battery, create_window1(), get_battery_info(), gt_collector, lkmonitor_create_tray_icon(), lkmonitor_init_widgets(), refresh(), update_cpu(), update_devs(), update_settings(), and window1.

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    * The following code was added by Glade to create one of each component
00134    * (except popup menus), just so that you see something after building
00135    * the project. Delete any crefresh);omponents that you don't want shown initially.
00136    */
00137   lkmonitor_create_tray_icon();
00138   window1 = create_window1 ();
00139   /*Set some widget properties*/
00140   
00141   lkmonitor_init_widgets(window1);
00142   
00143   gtk_widget_show (window1);
00144   
00145   
00146 
00147   /*First calls for static information*/
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 ();  //Begin of critial section
00157 
00158 /*Launch thread*/
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         /*Error creating thread*/
00165         g_critical("Could not create thread!");
00166 
00167 
00168 gtk_main ();
00169 
00170 gdk_threads_leave(); //Marks end of critical section
00171 
00172 g_thread_join(gt_collector); /*Wait for collector thread to finish*/
00173 
00174 return 0;
00175 }

void refresh ( void *  nothing  ) 

Function that represent the collector thread behaviour Collector thread runs into an infinite loop, scanning window and refreshing information if required.

Parameters:
nothing Required for POSIX compatibility. Not used

Definition at line 72 of file main.c.

References collector_exit, is_icon, lookup_widget(), update_cpu_mhz(), update_mem(), update_misc(), and window1.

Referenced by main().

00073 {
00074   int page;
00075   GtkNotebook *nb;
00076 
00077  nb = (GtkNotebook *) (lookup_widget (window1, "nb_main"));
00078   //Get current page from the notebook
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          // update_devs();
00092       break;
00093     case 3:
00094         //      update_settings();
00095                 break;
00096         case 4:
00097           update_misc();
00098     }
00099  }
00100         sleep(1);
00101 
00102 }
00103 }


Variable Documentation

struct acpi_info acpi

Definition at line 58 of file main.c.

Referenced by get_acpi_info(), main(), and update_misc().

gboolean collector_exit = FALSE

Definition at line 64 of file main.c.

Referenced by lkmonitor_exit(), and refresh().

struct cpu_info cpu

Definition at line 53 of file main.c.

Referenced by get_cpu_info(), and update_cpu().

struct dev_info devs

Definition at line 55 of file main.c.

Referenced by get_devs_info(), and update_devs().

GThread* gt_collector = NULL

Definition at line 61 of file main.c.

Referenced by main().

gboolean is_icon = FALSE

Definition at line 63 of file main.c.

Referenced by docklet_onclick(), on_window1_delete_event(), and refresh().

struct mem_info mem

Definition at line 54 of file main.c.

Referenced by get_mem_info(), and update_mem().

struct settings_info settings

Definition at line 56 of file main.c.

Referenced by get_settings_info(), and update_settings().

struct stats_info stats

Definition at line 57 of file main.c.

Referenced by get_stats_info(), and update_misc().

pthread_t thread_id

Definition at line 60 of file main.c.

GtkWidget* window1

Update data functions Show updated data to user

Definition at line 47 of file main.c.


Generated on Sat Dec 2 11:27:53 2006 for lkmonitor by  doxygen 1.5.1