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

main.c

Go to the documentation of this file.
00001 /*
00002 lkmonitor (Linux Kernel Monitor)
00003 
00004 Application for monitoring and tuning a Linux kernel.
00005 
00006 Copyright (C) 2005,2006  Fernando ApesteguĂ­a
00007 
00008 This program is free software; you can redistribute it and/or
00009 modify it under the terms of the GNU General Public License
00010 as published by the Free Software Foundation; either version 2
00011 of the License, or (at your option) any later version.
00012 
00013 This program is distributed in the hope that it will be useful,
00014 but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 GNU General Public License for more details.
00017 
00018 You should have received a copy of the GNU General Public License
00019 along with this program; if not, write to the Free Software
00020 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00021 */
00022 
00023 /*
00024  * Initial main.c file generated by Glade. Edit as required.
00025  * Glade will not overwrite this file.
00026  */
00027 
00028 #ifdef HAVE_CONFIG_H
00029 #  include <config.h>
00030 #endif
00031 
00032 #include <glib.h>
00033 
00034 #include <gtk/gtk.h>
00035 #include <sys/types.h>
00036 #include <signal.h>
00037 
00038 #include "interface.h"
00039 #include "support.h"
00040 #include "lininfo.h"
00041 #include <unistd.h>
00042 #include <stdio.h>
00043 
00044 #include <glib.h>
00045 #include <pthread.h>
00046 
00047 GtkWidget *window1;
00048 
00049 //Struct definitions
00050 struct cpu_info cpu;
00051 struct mem_info mem;
00052 
00053 pthread_t thread_id;
00054 
00055 
00061 void*
00062 refresh (void* nothing)
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 }
00085 
00091 int
00092 main (int argc, char *argv[])
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 }

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