Search
lxdream.org :: lxdream/src/gui/main_win.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/gui/main_win.c
changeset 455:3080881d00d4
prev450:207461e79f21
next457:af605fd32c0b
author nkeynes
date Sun Oct 21 05:21:35 2007 +0000 (12 years ago)
permissions -rw-r--r--
last change More GUI WIP
file annotate diff log raw
1.1 --- a/src/gui/main_win.c Wed Oct 17 11:26:45 2007 +0000
1.2 +++ b/src/gui/main_win.c Sun Oct 21 05:21:35 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: main_win.c,v 1.5 2007-10-17 11:26:45 nkeynes Exp $
1.6 + * $Id: main_win.c,v 1.6 2007-10-21 05:21:35 nkeynes Exp $
1.7 *
1.8 * Define the main (emu) GTK window, along with its menubars,
1.9 * toolbars, etc.
1.10 @@ -30,119 +30,26 @@
1.11 #include "dream.h"
1.12 #include "gui/gtkui.h"
1.13
1.14 -#define SET_ACTION_ENABLED(win,name,b) gtk_action_set_sensitive( gtk_action_group_get_action( win->actions, name), b)
1.15 -#define ENABLE_ACTION(win,name) SET_ACTION_ENABLED(win,name,TRUE)
1.16 -#define DISABLE_ACTION(win,name) SET_ACTION_ENABLED(win,name,FALSE)
1.17 -
1.18 -static const GtkActionEntry ui_actions[] = {
1.19 - { "FileMenu", NULL, "_File" },
1.20 - { "SettingsMenu", NULL, "_Settings" },
1.21 - { "HelpMenu", NULL, "_Help" },
1.22 - { "Mount", GTK_STOCK_CDROM, "_Mount...", "<control>O", "Mount a cdrom disc", G_CALLBACK(mount_action_callback) },
1.23 - { "Reset", GTK_STOCK_REFRESH, "_Reset", "<control>R", "Reset dreamcast", G_CALLBACK(reset_action_callback) },
1.24 - { "Pause", GTK_STOCK_MEDIA_PAUSE, "_Pause", NULL, "Pause dreamcast", G_CALLBACK(pause_action_callback) },
1.25 - { "Run", GTK_STOCK_MEDIA_PLAY, "Resume", NULL, "Resume", G_CALLBACK(resume_action_callback) },
1.26 - { "LoadState", GTK_STOCK_REVERT_TO_SAVED, "_Load state...", "F4", "Load an lxdream save state", G_CALLBACK(load_state_action_callback) },
1.27 - { "SaveState", GTK_STOCK_SAVE_AS, "_Save state...", "F3", "Create an lxdream save state", G_CALLBACK(save_state_action_callback) },
1.28 - { "Debugger", NULL, "_Debugger", NULL, "Open debugger window", G_CALLBACK(debugger_action_callback) },
1.29 - { "Exit", GTK_STOCK_QUIT, "E_xit", NULL, "Exit lxdream", G_CALLBACK(exit_action_callback) },
1.30 - { "PathSettings", NULL, "_Paths...", NULL, "Configure files and paths", G_CALLBACK(path_settings_callback) },
1.31 - { "AudioSettings", NULL, "_Audio...", NULL, "Configure audio output", G_CALLBACK(audio_settings_callback) },
1.32 - { "ControllerSettings", NULL, "_Controllers...", NULL, "Configure controllers", G_CALLBACK(controller_settings_callback) },
1.33 - { "NetworkSettings", NULL, "_Network...", NULL, "Configure network settings", G_CALLBACK(network_settings_callback) },
1.34 - { "VideoSettings", NULL, "_Video...", NULL, "Configure video output", G_CALLBACK(video_settings_callback) },
1.35 - { "About", GTK_STOCK_ABOUT, "_About...", NULL, "About lxdream", G_CALLBACK(about_action_callback) }
1.36 -};
1.37 -static const GtkToggleActionEntry ui_toggle_actions[] = {
1.38 - { "FullScreen", NULL, "_Full Screen", "<alt>Return", "Toggle full screen video", G_CALLBACK(fullscreen_toggle_callback), 0 },
1.39 -};
1.40 -
1.41 -
1.42 -static const char *ui_description =
1.43 - "<ui>"
1.44 - " <menubar name='MainMenu'>"
1.45 - " <menu action='FileMenu'>"
1.46 - " <menuitem action='Mount'/>"
1.47 - " <separator/>"
1.48 - " <menuitem action='Reset'/>"
1.49 - " <menuitem action='Pause'/>"
1.50 - " <menuitem action='Run'/>"
1.51 - " <separator/>"
1.52 - " <menuitem action='LoadState'/>"
1.53 - " <menuitem action='SaveState'/>"
1.54 - " <separator/>"
1.55 - " <menuitem action='Exit'/>"
1.56 - " </menu>"
1.57 - " <menu action='SettingsMenu'>"
1.58 - " <menuitem action='PathSettings'/>"
1.59 - " <menuitem action='AudioSettings'/>"
1.60 - " <menuitem action='ControllerSettings'/>"
1.61 - " <menuitem action='NetworkSettings'/>"
1.62 - " <menuitem action='VideoSettings'/>"
1.63 - " <separator/>"
1.64 - " <menuitem action='FullScreen'/>"
1.65 - " </menu>"
1.66 - " <menu action='HelpMenu'>"
1.67 - " <menuitem action='About'/>"
1.68 - " </menu>"
1.69 - " </menubar>"
1.70 - " <toolbar name='MainToolbar'>"
1.71 - " <toolitem action='Mount'/>"
1.72 - " <toolitem action='Reset'/>"
1.73 - " <toolitem action='Pause'/>"
1.74 - " <toolitem action='Run'/>"
1.75 - " <separator/>"
1.76 - " <toolitem action='LoadState'/>"
1.77 - " <toolitem action='SaveState'/>"
1.78 - " </toolbar>"
1.79 - "</ui>";
1.80 -
1.81
1.82 struct main_window_info {
1.83 GtkWidget *window;
1.84 - GtkWidget *menubar;
1.85 - GtkWidget *toolbar;
1.86 GtkWidget *video;
1.87 GtkWidget *statusbar;
1.88 GtkActionGroup *actions;
1.89 };
1.90
1.91 -main_window_t main_window_new( const gchar *title )
1.92 +main_window_t main_window_new( const gchar *title, GtkWidget *menubar, GtkWidget *toolbar,
1.93 + GtkAccelGroup *accel_group )
1.94 {
1.95 GtkWidget *vbox;
1.96 - GtkUIManager *ui_manager;
1.97 - GtkAccelGroup *accel_group;
1.98 GtkWidget *frame;
1.99 - GError *error = NULL;
1.100 main_window_t win = g_malloc0( sizeof(struct main_window_info) );
1.101
1.102 win->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1.103 gtk_window_set_title( GTK_WINDOW(win->window), title );
1.104 -
1.105 - win->actions = gtk_action_group_new("MenuActions");
1.106 - gtk_action_group_add_actions( win->actions, ui_actions, G_N_ELEMENTS(ui_actions), win->window );
1.107 - gtk_action_group_add_toggle_actions( win->actions, ui_toggle_actions, G_N_ELEMENTS(ui_toggle_actions), win->window );
1.108 - DISABLE_ACTION(win, "AudioSettings");
1.109 - DISABLE_ACTION(win, "NetworkSettings");
1.110 - DISABLE_ACTION(win, "VideoSettings");
1.111 -
1.112 - ui_manager = gtk_ui_manager_new();
1.113 - gtk_ui_manager_set_add_tearoffs(ui_manager, TRUE);
1.114 - gtk_ui_manager_insert_action_group( ui_manager, win->actions, 0 );
1.115 -
1.116 - if (!gtk_ui_manager_add_ui_from_string (ui_manager, ui_description, -1, &error)) {
1.117 - g_message ("building menus failed: %s", error->message);
1.118 - g_error_free (error);
1.119 - exit(1);
1.120 - }
1.121 -
1.122 - accel_group = gtk_ui_manager_get_accel_group (ui_manager);
1.123 gtk_window_add_accel_group (GTK_WINDOW (win->window), accel_group);
1.124
1.125 - win->menubar = gtk_ui_manager_get_widget(ui_manager, "/MainMenu");
1.126 - win->toolbar = gtk_ui_manager_get_widget(ui_manager, "/MainToolbar");
1.127 -
1.128 - gtk_toolbar_set_style( GTK_TOOLBAR(win->toolbar), GTK_TOOLBAR_ICONS );
1.129 + gtk_toolbar_set_style( GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS );
1.130
1.131 win->video = gtk_drawing_area_new();
1.132 GTK_WIDGET_SET_FLAGS(win->video, GTK_CAN_FOCUS|GTK_CAN_DEFAULT);
1.133 @@ -155,8 +62,8 @@
1.134
1.135 vbox = gtk_vbox_new(FALSE, 0);
1.136 gtk_container_add( GTK_CONTAINER(win->window), vbox );
1.137 - gtk_box_pack_start( GTK_BOX(vbox), win->menubar, FALSE, FALSE, 0 );
1.138 - gtk_box_pack_start( GTK_BOX(vbox), win->toolbar, FALSE, FALSE, 0 );
1.139 + gtk_box_pack_start( GTK_BOX(vbox), menubar, FALSE, FALSE, 0 );
1.140 + gtk_box_pack_start( GTK_BOX(vbox), toolbar, FALSE, FALSE, 0 );
1.141 gtk_box_pack_start( GTK_BOX(vbox), frame, TRUE, TRUE, 0 );
1.142 gtk_box_pack_start( GTK_BOX(vbox), win->statusbar, FALSE, FALSE, 0 );
1.143 gtk_widget_show_all( win->window );
1.144 @@ -168,8 +75,8 @@
1.145
1.146 void main_window_set_running( main_window_t win, gboolean running )
1.147 {
1.148 - SET_ACTION_ENABLED( win, "Pause", running );
1.149 - SET_ACTION_ENABLED( win, "Run", !running );
1.150 + gtk_gui_enable_action( "Pause", running );
1.151 + gtk_gui_enable_action( "Run", !running );
1.152 gtk_statusbar_pop( GTK_STATUSBAR(win->statusbar), 1 );
1.153 gtk_statusbar_push( GTK_STATUSBAR(win->statusbar), 1, running ? "Running" : "Stopped" );
1.154 }
.