GTK: Move the main window into an .ui file
This commit is contained in:
parent
b568fbc5dc
commit
21276a5a07
|
@ -2,6 +2,6 @@
|
|||
<gresources>
|
||||
<gresource prefix="/org/desmume/DeSmuME">
|
||||
<file preprocess="xml-stripblanks" compressed="true">org.desmume.DeSmuME.svg</file>
|
||||
<file preprocess="xml-stripblanks" compressed="true">toolbar.ui</file>
|
||||
<file preprocess="xml-stripblanks" compressed="true">main.ui</file>
|
||||
</gresource>
|
||||
</gresources>
|
||||
|
|
|
@ -3862,8 +3862,6 @@ common_gtk_main(GApplication *app, gpointer user_data)
|
|||
|
||||
SDL_TimerID limiter_timer = 0;
|
||||
|
||||
GtkWidget *pBox;
|
||||
|
||||
/* use any language set on the command line */
|
||||
if ( my_config->firmware_language != -1) {
|
||||
CommonSettings.fwConfig.language = my_config->firmware_language;
|
||||
|
@ -4001,26 +3999,20 @@ common_gtk_main(GApplication *app, gpointer user_data)
|
|||
g_printerr("Using %d threads for video filter.\n", CommonSettings.num_cores);
|
||||
video = new VideoFilter(256, 384, VideoFilterTypeID_None, CommonSettings.num_cores);
|
||||
|
||||
/* Create the window */
|
||||
pWindow = gtk_application_window_new(GTK_APPLICATION(app));
|
||||
gtk_window_set_title(GTK_WINDOW(pWindow), "DeSmuME");
|
||||
gtk_window_set_resizable(GTK_WINDOW (pWindow), TRUE);
|
||||
gtk_window_set_icon_name(GTK_WINDOW (pWindow), "DeSmuME");
|
||||
/* Fetch the main elements from the window */
|
||||
GtkBuilder *builder = gtk_builder_new_from_resource("/org/desmume/DeSmuME/main.ui");
|
||||
pWindow = GTK_WIDGET(gtk_builder_get_object(builder, "window"));
|
||||
pToolBar = GTK_WIDGET(gtk_builder_get_object(builder, "toolbar"));
|
||||
pDrawingArea = GTK_WIDGET(gtk_builder_get_object(builder, "drawing-area"));
|
||||
pStatusBar = GTK_WIDGET(gtk_builder_get_object(builder, "status-bar"));
|
||||
g_object_unref(builder);
|
||||
|
||||
gtk_application_add_window(GTK_APPLICATION(app), GTK_WINDOW(pWindow));
|
||||
|
||||
g_signal_connect(G_OBJECT(pWindow), "destroy", G_CALLBACK(DoQuit), NULL);
|
||||
g_signal_connect(G_OBJECT(pWindow), "key_press_event", G_CALLBACK(Key_Press), NULL);
|
||||
g_signal_connect(G_OBJECT(pWindow), "key_release_event", G_CALLBACK(Key_Release), NULL);
|
||||
|
||||
/* Create the GtkBox */
|
||||
pBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_container_add(GTK_CONTAINER(pWindow), pBox);
|
||||
|
||||
/* Create the toolbar */
|
||||
GtkBuilder *builder = gtk_builder_new_from_resource("/org/desmume/DeSmuME/toolbar.ui");
|
||||
pToolBar = GTK_WIDGET(gtk_builder_get_object(builder, "toolbar"));
|
||||
gtk_container_add(GTK_CONTAINER(pBox), pToolBar);
|
||||
g_object_unref(builder);
|
||||
|
||||
/* Update audio toggle status */
|
||||
if (my_config->disable_sound || !config.audio_enabled) {
|
||||
g_simple_action_set_state(G_SIMPLE_ACTION(g_action_map_lookup_action(G_ACTION_MAP(app), "enableaudio")), g_variant_new_boolean(FALSE));
|
||||
|
@ -4336,15 +4328,9 @@ common_gtk_main(GApplication *app, gpointer user_data)
|
|||
}, open_recent_menu);
|
||||
g_list_free(items);
|
||||
|
||||
/* Creating the place for showing DS screens */
|
||||
pDrawingArea = gtk_drawing_area_new();
|
||||
gtk_widget_set_vexpand(pDrawingArea, TRUE);
|
||||
|
||||
/* This toggle action must not be set active before the pDrawingArea initialization to avoid a GTK warning */
|
||||
g_simple_action_set_state(G_SIMPLE_ACTION(g_action_map_lookup_action(G_ACTION_MAP(app), "gap")), g_variant_new_boolean(config.view_gap));
|
||||
|
||||
gtk_container_add (GTK_CONTAINER(pBox), pDrawingArea);
|
||||
|
||||
gtk_widget_set_events(pDrawingArea,
|
||||
GDK_EXPOSURE_MASK | GDK_LEAVE_NOTIFY_MASK |
|
||||
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
|
||||
|
@ -4362,9 +4348,7 @@ common_gtk_main(GApplication *app, gpointer user_data)
|
|||
G_CALLBACK(ConfigureDrawingArea), NULL ) ;
|
||||
|
||||
/* Status bar */
|
||||
pStatusBar = gtk_statusbar_new();
|
||||
UpdateStatusBar(EMU_DESMUME_NAME_AND_VERSION());
|
||||
gtk_box_pack_end(GTK_BOX(pBox), pStatusBar, FALSE, FALSE, 0);
|
||||
|
||||
gtk_widget_show_all(pWindow);
|
||||
|
||||
|
|
|
@ -0,0 +1,106 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.24"/>
|
||||
<object class="GtkApplicationWindow" id="window">
|
||||
<property name="can-focus">False</property>
|
||||
<property name="title">DeSmuME</property>
|
||||
<property name="resizable">True</property>
|
||||
<property name="show-menubar">True</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkBox" id="toolbar">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<object class="GtkToolButton">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="action-name">app.open</property>
|
||||
<property name="label" translatable="yes">_Open</property>
|
||||
<property name="icon-name">document-open</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToolButton">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="action-name">app.run</property>
|
||||
<property name="label" translatable="yes">_Run</property>
|
||||
<property name="icon-name">media-playback-start</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToolButton">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="action-name">app.pause</property>
|
||||
<property name="label" translatable="yes">_Pause</property>
|
||||
<property name="icon-name">media-playback-pause</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToolButton">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="action-name">app.quit</property>
|
||||
<property name="label" translatable="yes">_Quit</property>
|
||||
<property name="icon-name">application-exit</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkDrawingArea" id="drawing-area">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkStatusbar" id="status-bar">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
|
@ -1,34 +0,0 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<interface>
|
||||
<requires lib='gtk+' version='3.24'/>
|
||||
<object class='GtkBox' id='toolbar'>
|
||||
<child>
|
||||
<object class='GtkToolButton'>
|
||||
<property name='label' translatable='yes'>_Open</property>
|
||||
<property name='icon-name'>document-open</property>
|
||||
<property name='action-name'>app.open</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class='GtkToolButton'>
|
||||
<property name='label' translatable='yes'>_Run</property>
|
||||
<property name='icon-name'>media-playback-start</property>
|
||||
<property name='action-name'>app.run</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class='GtkToolButton'>
|
||||
<property name='label' translatable='yes'>_Pause</property>
|
||||
<property name='icon-name'>media-playback-pause</property>
|
||||
<property name='action-name'>app.pause</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class='GtkToolButton'>
|
||||
<property name='label' translatable='yes'>_Quit</property>
|
||||
<property name='icon-name'>application-exit</property>
|
||||
<property name='action-name'>app.quit</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
Loading…
Reference in New Issue