cleaned up gtk2 code quite a bit
until direct sdl rendering on gtk2 can occur, the file menu will be in a seperate window however this will allow direct interfacing with the emulator rather than just command line options like gfceux
This commit is contained in:
parent
98096d5b52
commit
4b6d0c4b3f
|
@ -12,7 +12,7 @@ opts.AddVariables(
|
||||||
BoolVariable('NEWPPU', 'Enable new PPU core', 0),
|
BoolVariable('NEWPPU', 'Enable new PPU core', 0),
|
||||||
BoolVariable('CREATE_AVI', 'Enable avi creation support (SDL only)', 0),
|
BoolVariable('CREATE_AVI', 'Enable avi creation support (SDL only)', 0),
|
||||||
BoolVariable('LOGO', 'Enable a logoscreen when creating avis (SDL only)', '1'),
|
BoolVariable('LOGO', 'Enable a logoscreen when creating avis (SDL only)', '1'),
|
||||||
BoolVariable('GTK2', 'Enable experimental integrated GTK2 GUI (BROKEN, SDL Devs only!)', 0)
|
BoolVariable('GTK2', 'Enable GTK2 GUI (SDL only) (EXPERIMENTAL!)', 0)
|
||||||
)
|
)
|
||||||
|
|
||||||
env = Environment(options = opts)
|
env = Environment(options = opts)
|
||||||
|
|
|
@ -36,6 +36,13 @@ gint mainLoop(gpointer data)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void quit ()
|
||||||
|
{
|
||||||
|
SDL_Quit();
|
||||||
|
gtk_main_quit();
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
// this is not used currently; it is used in rendering sdl in
|
// this is not used currently; it is used in rendering sdl in
|
||||||
// the gtk window which is broken
|
// the gtk window which is broken
|
||||||
gint configureEvent (GtkWidget* widget, GdkEventConfigure* event)
|
gint configureEvent (GtkWidget* widget, GdkEventConfigure* event)
|
||||||
|
@ -46,20 +53,73 @@ gint configureEvent (GtkWidget* widget, GdkEventConfigure* event)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Our menu, an array of GtkItemFactoryEntry structures that defines each menu item */
|
||||||
|
static GtkItemFactoryEntry menu_items[] = {
|
||||||
|
{ "/_File", NULL, NULL, 0, "<Branch>" },
|
||||||
|
{ "/File/_New", "<control>N", NULL, 0, "<StockItem>", GTK_STOCK_NEW },
|
||||||
|
{ "/File/_Open", "<control>O", NULL, 0, "<StockItem>", GTK_STOCK_OPEN },
|
||||||
|
{ "/File/_Save", "<control>S", NULL, 0, "<StockItem>", GTK_STOCK_SAVE },
|
||||||
|
{ "/File/Save _As", NULL, NULL, 0, "<Item>" },
|
||||||
|
{ "/File/sep1", NULL, NULL, 0, "<Separator>" },
|
||||||
|
{ "/File/_Quit", "<CTRL>Q", quit, 0, "<StockItem>", GTK_STOCK_QUIT },
|
||||||
|
{ "/_Options", NULL, NULL, 0, "<Branch>" },
|
||||||
|
{ "/Options/tear", NULL, NULL, 0, "<Tearoff>" },
|
||||||
|
{ "/Options/Check", NULL, NULL, 1, "<CheckItem>" },
|
||||||
|
{ "/Options/sep", NULL, NULL, 0, "<Separator>" },
|
||||||
|
{ "/Options/Rad1", NULL, NULL, 1, "<RadioItem>" },
|
||||||
|
{ "/Options/Rad2", NULL, NULL, 2, "/Options/Rad1" },
|
||||||
|
{ "/Options/Rad3", NULL, NULL, 3, "/Options/Rad1" },
|
||||||
|
{ "/_Help", NULL, NULL, 0, "<LastBranch>" },
|
||||||
|
{ "/_Help/About", NULL, NULL, 0, "<Item>" },
|
||||||
|
};
|
||||||
|
|
||||||
|
static gint nmenu_items = sizeof (menu_items) / sizeof (menu_items[0]);
|
||||||
|
|
||||||
|
static GtkWidget* CreateMenubar( GtkWidget* window)
|
||||||
|
{
|
||||||
|
GtkItemFactory *item_factory;
|
||||||
|
GtkAccelGroup *accel_group;
|
||||||
|
|
||||||
|
/* Make an accelerator group (shortcut keys) */
|
||||||
|
accel_group = gtk_accel_group_new ();
|
||||||
|
|
||||||
|
/* Make an ItemFactory (that makes a menubar) */
|
||||||
|
item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", accel_group);
|
||||||
|
|
||||||
|
/* This function generates the menu items. Pass the item factory,
|
||||||
|
the number of items in the array, the array itself, and any
|
||||||
|
callback data for the the menu items. */
|
||||||
|
gtk_item_factory_create_items (item_factory, nmenu_items, menu_items, NULL);
|
||||||
|
|
||||||
|
/* Attach the new accelerator group to the window. */
|
||||||
|
gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
|
||||||
|
|
||||||
|
/* Finally, return the actual menu bar created by the item factory. */
|
||||||
|
return gtk_item_factory_get_widget (item_factory, "<main>");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int InitGTKSubsystem(int argc, char** argv)
|
int InitGTKSubsystem(int argc, char** argv)
|
||||||
{
|
{
|
||||||
GtkWidget* MainWindow;
|
GtkWidget* MainWindow;
|
||||||
|
GtkWidget* Menubar;
|
||||||
int xres, yres;
|
int xres, yres;
|
||||||
|
|
||||||
g_config->getOption("SDL.XResolution", &xres);
|
g_config->getOption("SDL.XResolution", &xres);
|
||||||
g_config->getOption("SDL.YResolution", &yres);
|
g_config->getOption("SDL.YResolution", &yres);
|
||||||
|
|
||||||
gtk_init(&argc, &argv);
|
gtk_init(&argc, &argv);
|
||||||
|
|
||||||
MainWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
MainWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||||
gtk_window_set_title(GTK_WINDOW(MainWindow), "fceuX GTK GUI - WIP");
|
gtk_window_set_title(GTK_WINDOW(MainWindow), "fceuX GTK GUI - WIP");
|
||||||
gtk_widget_set_usize(MainWindow, xres, yres);
|
|
||||||
gtk_widget_realize(MainWindow);
|
Menubar = CreateMenubar(MainWindow);
|
||||||
|
|
||||||
|
gtk_container_add(GTK_CONTAINER(MainWindow), Menubar);
|
||||||
|
|
||||||
|
// broken SDL embedding code
|
||||||
|
//gtk_widget_set_usize(MainWindow, xres, yres);
|
||||||
|
//gtk_widget_realize(MainWindow);
|
||||||
|
|
||||||
// event handlers
|
// event handlers
|
||||||
gtk_widget_add_events(MainWindow, GDK_BUTTON_PRESS_MASK);
|
gtk_widget_add_events(MainWindow, GDK_BUTTON_PRESS_MASK);
|
||||||
|
@ -68,7 +128,7 @@ int InitGTKSubsystem(int argc, char** argv)
|
||||||
|
|
||||||
|
|
||||||
// PRG: this code here is the the windowID "hack" to render SDL
|
// PRG: this code here is the the windowID "hack" to render SDL
|
||||||
// in a GTK window. however, I can't get it to work right now
|
// in a GTK window. however, I can't get it to work right now
|
||||||
// so i'm commenting it out and haivng a seperate GTK2 window with
|
// so i'm commenting it out and haivng a seperate GTK2 window with
|
||||||
// controls
|
// controls
|
||||||
// 12/21/09
|
// 12/21/09
|
||||||
|
@ -99,7 +159,7 @@ int InitGTKSubsystem(int argc, char** argv)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// signal handlers
|
// signal handlers
|
||||||
g_signal_connect(G_OBJECT(MainWindow), "delete-event", gtk_main_quit, NULL);
|
g_signal_connect(G_OBJECT(MainWindow), "delete-event", quit, NULL);
|
||||||
//gtk_idle_add(mainLoop, MainWindow);
|
//gtk_idle_add(mainLoop, MainWindow);
|
||||||
|
|
||||||
gtk_widget_show_all(MainWindow);
|
gtk_widget_show_all(MainWindow);
|
||||||
|
|
Loading…
Reference in New Issue