Back to index

lshw  02.16
gtk-lshw.c
Go to the documentation of this file.
00001 #include <stdbool.h>
00002 #include <unistd.h>
00003 #include <gtk/gtk.h>
00004 
00005 #include "support.h"
00006 #include "config.h"
00007 #include "stock.h"
00008 #include "engine.h"
00009 
00010 static char *id = "@(#) $Id: gtk-lshw.c 2433 2012-01-10 22:01:30Z lyonel $";
00011 
00012 extern GtkWidget *mainwindow;
00013 
00014 int
00015 main (int argc, char *argv[])
00016 {
00017 #ifndef NONLS
00018   bindtextdomain (PACKAGE, LOCALEDIR);
00019   bind_textdomain_codeset (PACKAGE, "UTF-8");
00020   textdomain (PACKAGE);
00021 #endif
00022 
00023   gtk_init (&argc, &argv);
00024 
00025   if(geteuid() != 0)
00026   {
00027     bool proceed = false;
00028     GtkWidget *dialog = gtk_message_dialog_new (NULL,
00029                             GTK_DIALOG_MODAL,
00030                             GTK_MESSAGE_WARNING,
00031                             GTK_BUTTONS_NONE,
00032                             "Executing this program as a normal user will give incomplete and maybe erroneous information.");
00033     gtk_dialog_add_buttons(GTK_DIALOG(dialog),
00034                                   GTK_STOCK_QUIT, GTK_RESPONSE_CANCEL,
00035                                   GTK_STOCK_EXECUTE, GTK_RESPONSE_ACCEPT,
00036                                   NULL);
00037 
00038     proceed = (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT);
00039     gtk_widget_destroy (dialog);
00040 
00041     if(!proceed)
00042       return -1;
00043   }
00044 
00045   lshw_gtk_stock_init();
00046   lshw_ui_init();
00047 
00048   if(!mainwindow)
00049     return(1);
00050 
00051   gtk_widget_show(mainwindow);
00052   gtk_main ();
00053 
00054   (void) &id;                                     // avoid warning "id defined but not used"
00055 
00056   return 0;
00057 }