hello-world/src/dialog.c File Reference

#include <glib.h>
#include <gtk/gtk.h>
#include <signal.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
Include dependency graph for hello-world/src/dialog.c:

Go to the source code of this file.

Functions

static void usage (const char *argv_0)
void main_quit (void)
static gboolean run_error_dialog (gpointer data)
int main (int argc, char *argv[])

Variables

GtkWidget * g_main_window

Function Documentation

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

Definition at line 109 of file hello-world/src/dialog.c.

References g_main_window, msg, run_error_dialog(), and usage().

00110 {
00111     gchar *msg = NULL;
00112 
00113     // check command-line arguments
00114     if (argc < 2)
00115     {
00116         usage(argv[0]);
00117     }
00118 
00119     // init gtk, list the default rc files
00120     gtk_init(&argc, &argv);
00121 
00122     // create the top level window 
00123     g_main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
00124 
00125     if (argc > 0)
00126     {
00127         msg = g_strdup_printf("%s", argv[1]);
00128         g_idle_add(run_error_dialog, (gpointer) msg);
00129     }
00130     
00131     gtk_main();
00132     g_free(msg);
00133 
00134     return 0;
00135 }

Here is the call graph for this function:

void main_quit ( void   ) 

Definition at line 69 of file hello-world/src/dialog.c.

References g_main_window.

00070 {
00071     if (g_main_window)
00072     {
00073         gtk_widget_destroy(g_main_window);
00074         g_main_window = NULL;
00075     }    
00076     
00077     if (gtk_main_level() > 0)
00078     {
00079         gtk_main_quit();
00080     }
00081     else
00082     {
00083         _exit(0);
00084     }
00085 }

static gboolean run_error_dialog ( gpointer  data  )  [static]

Definition at line 88 of file hello-world/src/dialog.c.

References g_main_window, main_quit(), and msg.

00089 {
00090     GtkWidget   *dialog = NULL;
00091     gchar *msg = (gchar *) data;
00092 
00093     printf("Show dialog with message: [%s]\n", msg);
00094 
00095     dialog = gtk_message_dialog_new( GTK_WINDOW(g_main_window),
00096                                      GTK_DIALOG_DESTROY_WITH_PARENT,
00097                                      GTK_MESSAGE_INFO, //GTK_MESSAGE_ERROR,
00098                                      GTK_BUTTONS_OK,
00099                                      msg );
00100 
00101     gtk_dialog_run( GTK_DIALOG(dialog) );
00102     gtk_widget_destroy( dialog );
00103     main_quit();
00104     
00105     return FALSE;
00106 }

Here is the call graph for this function:

static void usage ( const char *  argv_0  )  [static]

Definition at line 57 of file hello-world/src/dialog.c.

00058 {
00059     static const char *usage_text = 
00060                         "\n"
00061                         "usage: %s <message>\n";
00062 
00063     printf(usage_text, argv_0);
00064 
00065     exit(1);
00066 }


Variable Documentation

GtkWidget* g_main_window

Copyright (C) 2009 iRex Technologies B.V. All rights reserved.

Definition at line 49 of file hello-world/src/dialog.c.

Generated by  doxygen 1.6.2-20100208