Search
lxdream.org :: lxdream/src/gui/gtkui.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/gui/gtkui.c
changeset 530:28bdc62e642a
prev508:ccd2c10edfe6
author nkeynes
date Mon Nov 19 08:46:30 2007 +0000 (14 years ago)
permissions -rw-r--r--
last change Handle inability to connect the X server a little more cleanly
file annotate diff log raw
1.1 --- a/src/gui/gtkui.c Sat Nov 10 04:45:29 2007 +0000
1.2 +++ b/src/gui/gtkui.c Mon Nov 19 08:46:30 2007 +0000
1.3 @@ -57,6 +57,8 @@
1.4 static uint32_t gtk_gui_nanos = 0;
1.5 static struct timeval gtk_gui_lasttv;
1.6
1.7 +static gboolean gtk_gui_init_ok = FALSE;
1.8 +
1.9 #define ENABLE_ACTION(win,name) SET_ACTION_ENABLED(win,name,TRUE)
1.10 #define DISABLE_ACTION(win,name) SET_ACTION_ENABLED(win,name,FALSE)
1.11
1.12 @@ -184,46 +186,51 @@
1.13
1.14 gboolean gui_parse_cmdline( int *argc, char **argv[] )
1.15 {
1.16 - return gtk_init_check( argc, argv );
1.17 + gtk_gui_init_ok = gtk_init_check( argc, argv );
1.18 + return gtk_gui_init_ok;
1.19 }
1.20
1.21 gboolean gui_init( gboolean withDebug )
1.22 {
1.23 - GError *error = NULL;
1.24 - dreamcast_register_module( &gtk_gui_module );
1.25 - gtk_gui_alloc_resources();
1.26 -
1.27 - global_action_group = gtk_action_group_new("MenuActions");
1.28 - gtk_action_group_set_translation_domain( global_action_group, NULL );
1.29 - gtk_action_group_add_actions( global_action_group, ui_actions, G_N_ELEMENTS(ui_actions), NULL );
1.30 - gtk_action_group_add_toggle_actions( global_action_group, ui_toggle_actions, G_N_ELEMENTS(ui_toggle_actions), NULL );
1.31 - gtk_gui_enable_action("AudioSettings", FALSE);
1.32 - gtk_gui_enable_action("NetworkSettings", FALSE);
1.33 - gtk_gui_enable_action("VideoSettings", FALSE);
1.34 + if( gtk_gui_init_ok ) {
1.35 + GError *error = NULL;
1.36 + dreamcast_register_module( &gtk_gui_module );
1.37 + gtk_gui_alloc_resources();
1.38 +
1.39 + global_action_group = gtk_action_group_new("MenuActions");
1.40 + gtk_action_group_set_translation_domain( global_action_group, NULL );
1.41 + gtk_action_group_add_actions( global_action_group, ui_actions, G_N_ELEMENTS(ui_actions), NULL );
1.42 + gtk_action_group_add_toggle_actions( global_action_group, ui_toggle_actions, G_N_ELEMENTS(ui_toggle_actions), NULL );
1.43 + gtk_gui_enable_action("AudioSettings", FALSE);
1.44 + gtk_gui_enable_action("NetworkSettings", FALSE);
1.45 + gtk_gui_enable_action("VideoSettings", FALSE);
1.46 +
1.47 + global_ui_manager = gtk_ui_manager_new();
1.48 + gtk_ui_manager_set_add_tearoffs(global_ui_manager, TRUE);
1.49 + gtk_ui_manager_insert_action_group( global_ui_manager, global_action_group, 0 );
1.50 +
1.51 + if (!gtk_ui_manager_add_ui_from_string (global_ui_manager, ui_description, -1, &error)) {
1.52 + g_message ("building menus failed: %s", error->message);
1.53 + g_error_free (error);
1.54 + exit(1);
1.55 + }
1.56 + GtkAccelGroup *accel_group = gtk_ui_manager_get_accel_group (global_ui_manager);
1.57 + GtkWidget *menubar = gtk_ui_manager_get_widget(global_ui_manager, "/MainMenu");
1.58 + GtkWidget *toolbar = gtk_ui_manager_get_widget(global_ui_manager, "/MainToolbar");
1.59 +
1.60 + GtkWidget *gdrommenuitem = gtk_ui_manager_get_widget(global_ui_manager, "/MainMenu/FileMenu/GdromSettings");
1.61 + gdrom_menu_init();
1.62 + GtkWidget *gdrommenu = gdrom_menu_new();
1.63 + gtk_menu_item_set_submenu( GTK_MENU_ITEM(gdrommenuitem), gdrommenu );
1.64 + main_win = main_window_new( APP_NAME " " APP_VERSION, menubar, toolbar, accel_group );
1.65 + if( withDebug ) {
1.66 + gtk_gui_show_debugger();
1.67 + }
1.68
1.69 - global_ui_manager = gtk_ui_manager_new();
1.70 - gtk_ui_manager_set_add_tearoffs(global_ui_manager, TRUE);
1.71 - gtk_ui_manager_insert_action_group( global_ui_manager, global_action_group, 0 );
1.72 -
1.73 - if (!gtk_ui_manager_add_ui_from_string (global_ui_manager, ui_description, -1, &error)) {
1.74 - g_message ("building menus failed: %s", error->message);
1.75 - g_error_free (error);
1.76 - exit(1);
1.77 + return TRUE;
1.78 + } else {
1.79 + return FALSE;
1.80 }
1.81 - GtkAccelGroup *accel_group = gtk_ui_manager_get_accel_group (global_ui_manager);
1.82 - GtkWidget *menubar = gtk_ui_manager_get_widget(global_ui_manager, "/MainMenu");
1.83 - GtkWidget *toolbar = gtk_ui_manager_get_widget(global_ui_manager, "/MainToolbar");
1.84 -
1.85 - GtkWidget *gdrommenuitem = gtk_ui_manager_get_widget(global_ui_manager, "/MainMenu/FileMenu/GdromSettings");
1.86 - gdrom_menu_init();
1.87 - GtkWidget *gdrommenu = gdrom_menu_new();
1.88 - gtk_menu_item_set_submenu( GTK_MENU_ITEM(gdrommenuitem), gdrommenu );
1.89 - main_win = main_window_new( APP_NAME " " APP_VERSION, menubar, toolbar, accel_group );
1.90 - if( withDebug ) {
1.91 - gtk_gui_show_debugger();
1.92 - }
1.93 -
1.94 - return TRUE;
1.95 }
1.96
1.97 void gui_main_loop(void)
1.98 @@ -301,7 +308,11 @@
1.99
1.100 GtkWidget *gtk_gui_get_renderarea()
1.101 {
1.102 - return main_window_get_renderarea(main_win);
1.103 + if( main_win == NULL ) {
1.104 + return NULL;
1.105 + } else {
1.106 + return main_window_get_renderarea(main_win);
1.107 + }
1.108 }
1.109
1.110 /**
.