Main Page | Data Structures | File List | Data Fields | Globals

main.c File Reference

#include <glib.h>
#include <gtk/gtk.h>
#include <sys/types.h>
#include <signal.h>
#include "interface.h"
#include "support.h"
#include "lininfo.h"
#include <unistd.h>
#include <stdio.h>
#include <pthread.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
pthread_t thread_id


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 92 of file main.c.

References create_window1(), refresh(), thread_id, update_cpu(), and window1.

00093 {
00094         //Added manually by fernape.
00095         gnome_program_init (PACKAGE, VERSION, LIBGNOMEUI_MODULE,
00096                       argc, argv,
00097                       GNOME_PARAM_APP_DATADIR, PACKAGE_DATA_DIR,
00098                       NULL);
00099         
00100 #ifdef ENABLE_NLS
00101   bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
00102   bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
00103   textdomain (GETTEXT_PACKAGE);
00104 #endif
00105 
00106   
00107   gdk_threads_init ();
00108         
00109   gtk_set_locale ();
00110   gtk_init (&argc, &argv);
00111 
00112   /*
00113    * The following code was added by Glade to create one of each component
00114    * (except popup menus), just so that you see something after building
00115    * the project. Delete any crefresh);omponents that you don't want shown initially.
00116    */
00117   window1 = create_window1 ();
00118   gtk_widget_show (window1);
00119 
00120         //First calls to avoid 'cold start' effects.
00121   update_cpu ();
00122   
00123 
00124 gdk_threads_enter ();  //Begin of critial section
00125 
00126 //Launch thread
00127 if(pthread_create(&thread_id,NULL,&refresh,NULL)==0)
00128         g_message("Collector thread created");
00129 else
00130         //Error creating thread
00131         g_critical("Could not create thread!");
00132 
00133 
00134 
00135 gtk_main (); //Run inside event main loop
00136 
00137 
00138 gdk_threads_leave(); //Marks end of critical section
00139 
00140 
00141 return 0;
00142 }

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 62 of file main.c.

References lookup_widget(), update_mem(), and window1.

Referenced by main().

00063 {
00064   int page;
00065   GtkNotebook *nb;
00066   //Get current page from the notebook
00067  for(;;){
00068   nb = (GtkNotebook *) (lookup_widget (window1, "nb_main"));
00069   page = (int) gtk_notebook_get_current_page (nb);
00070 
00071   switch (page)
00072     {
00073     case 1:
00074       update_mem ();
00075       break;
00076     case 4:
00077       break;
00078     case 5:
00079                 break;
00080     }
00081 
00082         sleep(1);
00083 }
00084 }


Variable Documentation

struct cpu_info cpu
 

Definition at line 50 of file main.c.

Referenced by get_cpu_info(), and update_cpu().

struct mem_info mem
 

Definition at line 51 of file main.c.

Referenced by get_mem_info(), and update_mem().

pthread_t thread_id
 

Definition at line 53 of file main.c.

Referenced by lkmonitor_exit(), and main().

GtkWidget* window1
 

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().


Generated on Wed Feb 15 11:24:02 2006 for lkmonitor by  doxygen 1.3.9.1