Search
lxdream.org :: lxdream :: r530:28bdc62e642a
lxdream 0.9.1
released Jun 29
Download Now
changeset530:28bdc62e642a
parent529:06ffbecc7262
child531:f0fee3ba71d1
authornkeynes
dateMon Nov 19 08:46:30 2007 +0000 (12 years ago)
Handle inability to connect the X server a little more cleanly
src/drivers/video_gtk.c
src/gui/gtkui.c
1.1 --- a/src/drivers/video_gtk.c Mon Nov 19 08:45:00 2007 +0000
1.2 +++ b/src/drivers/video_gtk.c Mon Nov 19 08:46:30 2007 +0000
1.3 @@ -97,6 +97,9 @@
1.4 gboolean video_gtk_init()
1.5 {
1.6 video_win = gtk_gui_get_renderarea();
1.7 + if( video_win == NULL ) {
1.8 + return FALSE;
1.9 + }
1.10
1.11 g_signal_connect( video_win, "key_press_event",
1.12 G_CALLBACK(video_gtk_keydown_callback), NULL );
1.13 @@ -120,8 +123,10 @@
1.14
1.15 void video_gtk_shutdown()
1.16 {
1.17 - video_glx_shutdown();
1.18 - gtk_widget_destroy( GTK_WIDGET(video_win) );
1.19 + if( video_win != NULL ) {
1.20 + video_glx_shutdown();
1.21 + gtk_widget_destroy( GTK_WIDGET(video_win) );
1.22 + }
1.23
1.24 }
1.25
2.1 --- a/src/gui/gtkui.c Mon Nov 19 08:45:00 2007 +0000
2.2 +++ b/src/gui/gtkui.c Mon Nov 19 08:46:30 2007 +0000
2.3 @@ -57,6 +57,8 @@
2.4 static uint32_t gtk_gui_nanos = 0;
2.5 static struct timeval gtk_gui_lasttv;
2.6
2.7 +static gboolean gtk_gui_init_ok = FALSE;
2.8 +
2.9 #define ENABLE_ACTION(win,name) SET_ACTION_ENABLED(win,name,TRUE)
2.10 #define DISABLE_ACTION(win,name) SET_ACTION_ENABLED(win,name,FALSE)
2.11
2.12 @@ -184,46 +186,51 @@
2.13
2.14 gboolean gui_parse_cmdline( int *argc, char **argv[] )
2.15 {
2.16 - return gtk_init_check( argc, argv );
2.17 + gtk_gui_init_ok = gtk_init_check( argc, argv );
2.18 + return gtk_gui_init_ok;
2.19 }
2.20
2.21 gboolean gui_init( gboolean withDebug )
2.22 {
2.23 - GError *error = NULL;
2.24 - dreamcast_register_module( &gtk_gui_module );
2.25 - gtk_gui_alloc_resources();
2.26 -
2.27 - global_action_group = gtk_action_group_new("MenuActions");
2.28 - gtk_action_group_set_translation_domain( global_action_group, NULL );
2.29 - gtk_action_group_add_actions( global_action_group, ui_actions, G_N_ELEMENTS(ui_actions), NULL );
2.30 - gtk_action_group_add_toggle_actions( global_action_group, ui_toggle_actions, G_N_ELEMENTS(ui_toggle_actions), NULL );
2.31 - gtk_gui_enable_action("AudioSettings", FALSE);
2.32 - gtk_gui_enable_action("NetworkSettings", FALSE);
2.33 - gtk_gui_enable_action("VideoSettings", FALSE);
2.34 + if( gtk_gui_init_ok ) {
2.35 + GError *error = NULL;
2.36 + dreamcast_register_module( &gtk_gui_module );
2.37 + gtk_gui_alloc_resources();
2.38 +
2.39 + global_action_group = gtk_action_group_new("MenuActions");
2.40 + gtk_action_group_set_translation_domain( global_action_group, NULL );
2.41 + gtk_action_group_add_actions( global_action_group, ui_actions, G_N_ELEMENTS(ui_actions), NULL );
2.42 + gtk_action_group_add_toggle_actions( global_action_group, ui_toggle_actions, G_N_ELEMENTS(ui_toggle_actions), NULL );
2.43 + gtk_gui_enable_action("AudioSettings", FALSE);
2.44 + gtk_gui_enable_action("NetworkSettings", FALSE);
2.45 + gtk_gui_enable_action("VideoSettings", FALSE);
2.46 +
2.47 + global_ui_manager = gtk_ui_manager_new();
2.48 + gtk_ui_manager_set_add_tearoffs(global_ui_manager, TRUE);
2.49 + gtk_ui_manager_insert_action_group( global_ui_manager, global_action_group, 0 );
2.50 +
2.51 + if (!gtk_ui_manager_add_ui_from_string (global_ui_manager, ui_description, -1, &error)) {
2.52 + g_message ("building menus failed: %s", error->message);
2.53 + g_error_free (error);
2.54 + exit(1);
2.55 + }
2.56 + GtkAccelGroup *accel_group = gtk_ui_manager_get_accel_group (global_ui_manager);
2.57 + GtkWidget *menubar = gtk_ui_manager_get_widget(global_ui_manager, "/MainMenu");
2.58 + GtkWidget *toolbar = gtk_ui_manager_get_widget(global_ui_manager, "/MainToolbar");
2.59 +
2.60 + GtkWidget *gdrommenuitem = gtk_ui_manager_get_widget(global_ui_manager, "/MainMenu/FileMenu/GdromSettings");
2.61 + gdrom_menu_init();
2.62 + GtkWidget *gdrommenu = gdrom_menu_new();
2.63 + gtk_menu_item_set_submenu( GTK_MENU_ITEM(gdrommenuitem), gdrommenu );
2.64 + main_win = main_window_new( APP_NAME " " APP_VERSION, menubar, toolbar, accel_group );
2.65 + if( withDebug ) {
2.66 + gtk_gui_show_debugger();
2.67 + }
2.68
2.69 - global_ui_manager = gtk_ui_manager_new();
2.70 - gtk_ui_manager_set_add_tearoffs(global_ui_manager, TRUE);
2.71 - gtk_ui_manager_insert_action_group( global_ui_manager, global_action_group, 0 );
2.72 -
2.73 - if (!gtk_ui_manager_add_ui_from_string (global_ui_manager, ui_description, -1, &error)) {
2.74 - g_message ("building menus failed: %s", error->message);
2.75 - g_error_free (error);
2.76 - exit(1);
2.77 + return TRUE;
2.78 + } else {
2.79 + return FALSE;
2.80 }
2.81 - GtkAccelGroup *accel_group = gtk_ui_manager_get_accel_group (global_ui_manager);
2.82 - GtkWidget *menubar = gtk_ui_manager_get_widget(global_ui_manager, "/MainMenu");
2.83 - GtkWidget *toolbar = gtk_ui_manager_get_widget(global_ui_manager, "/MainToolbar");
2.84 -
2.85 - GtkWidget *gdrommenuitem = gtk_ui_manager_get_widget(global_ui_manager, "/MainMenu/FileMenu/GdromSettings");
2.86 - gdrom_menu_init();
2.87 - GtkWidget *gdrommenu = gdrom_menu_new();
2.88 - gtk_menu_item_set_submenu( GTK_MENU_ITEM(gdrommenuitem), gdrommenu );
2.89 - main_win = main_window_new( APP_NAME " " APP_VERSION, menubar, toolbar, accel_group );
2.90 - if( withDebug ) {
2.91 - gtk_gui_show_debugger();
2.92 - }
2.93 -
2.94 - return TRUE;
2.95 }
2.96
2.97 void gui_main_loop(void)
2.98 @@ -301,7 +308,11 @@
2.99
2.100 GtkWidget *gtk_gui_get_renderarea()
2.101 {
2.102 - return main_window_get_renderarea(main_win);
2.103 + if( main_win == NULL ) {
2.104 + return NULL;
2.105 + } else {
2.106 + return main_window_get_renderarea(main_win);
2.107 + }
2.108 }
2.109
2.110 /**
.