From 33e95d70eee4e5634d5400c3098857d2292dc63d Mon Sep 17 00:00:00 2001 From: bgk Date: Sun, 20 Feb 2011 08:28:48 +0000 Subject: [PATCH] =?UTF-8?q?GTK:=20Convert=20the=20remaining=20parts=20of?= =?UTF-8?q?=20the=20UI=20from=20Glade=20to=20GtkBuilder.=20Thanks=20to=20R?= =?UTF-8?q?afa=C5=82=20Mu=C5=BCy=C5=82o=20for=20the=20patch.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@977 a31d4220-a93d-0410-bf67-fe4944624d44 --- CMakeLists.txt | 8 +- src/gtk/main.cpp | 11 +- src/gtk/ui/vbam.glade | 590 ++++++++++++++++++++++++++---------------- src/gtk/window.cpp | 66 +++-- src/gtk/window.h | 8 +- 5 files changed, 417 insertions(+), 266 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7dbef242..1a77b35b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,7 +52,6 @@ IF(NOT NO_GTK) PKG_CHECK_MODULES ( GTKMM gtkmm-2.4 ) PKG_CHECK_MODULES ( GLIBMM glibmm-2.4 ) PKG_CHECK_MODULES ( GIOMM giomm-2.4 ) - PKG_CHECK_MODULES ( GLADEMM libglademm-2.4 ) PKG_CHECK_MODULES ( GTKGLMM gtkglextmm-x11-1.2 ) ENDIF(NOT NO_GTK) @@ -70,9 +69,9 @@ ENDIF( WITH_LIRC ) # Check that the dependencies are met to build the GTK frontend IF( NOT NO_GTK ) - IF( GLIBMM_FOUND AND GTKMM_FOUND AND GLADEMM_FOUND AND SDL_FOUND ) + IF( GLIBMM_FOUND AND GTKMM_FOUND AND SDL_FOUND ) SET( CAN_BUILD_GVBAM 1 ) - ENDIF( GLIBMM_FOUND AND GTKMM_FOUND AND GLADEMM_FOUND AND SDL_FOUND ) + ENDIF( GLIBMM_FOUND AND GTKMM_FOUND AND SDL_FOUND ) ENDIF( NOT NO_GTK ) # Set the default install dir @@ -286,7 +285,6 @@ IF( CAN_BUILD_GVBAM ) ${GIOMM_INCLUDE_DIRS} ${GTKMM_INCLUDE_DIRS} ${GTKGLMM_INCLUDE_DIRS} - ${GLADEMM_INCLUDE_DIRS} ) LINK_DIRECTORIES( @@ -294,7 +292,6 @@ IF( CAN_BUILD_GVBAM ) ${GIOMM_LIBRARY_DIRS} ${GTKMM_LIBRARY_DIRS} ${GTKGLMM_LIBRARY_DIRS} - ${GLADEMM_LIBRARY_DIRS} ) ENDIF( CAN_BUILD_GVBAM ) @@ -363,7 +360,6 @@ IF( CAN_BUILD_GVBAM ) vbamcore ${ZLIB_LIBRARY} ${PNG_LIBRARY} - ${GLADEMM_LIBRARIES} ${SDL_LIBRARY} ${GTKGLMM_LIBRARIES} ${SFML_LIBRARY} diff --git a/src/gtk/main.cpp b/src/gtk/main.cpp index d1f469db..a525541a 100644 --- a/src/gtk/main.cpp +++ b/src/gtk/main.cpp @@ -19,7 +19,6 @@ #include #include #include -#include #ifdef USE_OPENGL #include @@ -28,8 +27,6 @@ #include "window.h" #include "intl.h" -using Gnome::Glade::Xml; - int main(int argc, char * argv[]) { bool bShowVersion = false; @@ -90,12 +87,14 @@ int main(int argc, char * argv[]) std::string sGladeFile = VBA::Window::sGetUiFilePath("vbam.glade"); - Glib::RefPtr poXml; + Glib::RefPtr poXml; try { - poXml = Xml::create(sGladeFile, "MainWindow"); + poXml = Gtk::Builder::create(); + poXml->add_from_file(sGladeFile, "accelgroup1"); + poXml->add_from_file(sGladeFile, "MainWindow"); } - catch (const Xml::Error & e) + catch (const Gtk::BuilderError & e) { Gtk::MessageDialog oDialog(e.what(), false, diff --git a/src/gtk/ui/vbam.glade b/src/gtk/ui/vbam.glade index cbfee17e..0e27bb88 100644 --- a/src/gtk/ui/vbam.glade +++ b/src/gtk/ui/vbam.glade @@ -1,595 +1,753 @@ - - - - - + + + + + + False VBA + + + - + True + False - + True + False - + True + False + False _File True - - + + + False - + + gtk-open True - gtk-open + False + False True - True - + True + accelgroup1 + - + True + False + False Open rece_nt True - + - + True - + False + - + True + False + False Screen capt_ure... True - + - + True - + False + - + + gtk-close True - gtk-close - True + False + False True - + True + accelgroup1 + - + + gtk-quit True - gtk-quit - True + False + False True - - + True + accelgroup1 + + - + - + - + True + False + False _Emulation True - - + + + False - + True + False + False gtk-media-pause - True True - - + + - + True + False + False _Reset True - - + + - + + gtk-fullscreen True - gtk-fullscreen + False + False True True + accelgroup1 - + - + True - + False + - + True + False + False Loa_d state True - - + + + False - + True + False + False Most recent True - + - + True + False + False Auto load most recent True - + - + True - + False + - + True + False + False Slot1 True - - + + - + True + False + False Slot2 True - - + + - + True + False + False Slot3 True - - + + - + True + False + False Slot4 True - - + + - + True + False + False Slot5 True - - + + - + True + False + False Slot6 True - - + + - + True + False + False Slot7 True - - + + - + True + False + False Slot8 True - - + + - + True + False + False Slot9 True - - + + - + True + False + False Slot10 True - - + + - + True + False + False From _File ... True - - + + - + - + - + True + False + False S_ave state True - - + + + False - + True + False + False Oldest slot True - + - + True - + False + - + True + False + False Slot1 True - - + + - + True + False + False Slot2 True - - + + - + True + False + False Slot3 True - - + + - + True + False + False Slot4 True - - + + - + True + False + False Slot5 True - - + + - + True + False + False Slot6 True - - + + - + True + False + False Slot7 True - - + + - + True + False + False Slot8 True - - + + - + True + False + False Slot9 True - - + + - + True + False + False Slot10 True - - + + - + True - + False + - + True + False + False To _File ... True - - + + - + - + - + - + - + True + False + False _Options True - - + + + False - + True + False + False _Frameskip True - - + + + False - + True + False + False _Automatic True True - + - + True + False + False _0 True FrameskipAutomatic - + - + True + False + False _1 True FrameskipAutomatic - + - + True + False + False _2 True FrameskipAutomatic - + - + True + False + False _3 True FrameskipAutomatic - + - + True + False + False _4 True FrameskipAutomatic - + - + True + False + False _5 True FrameskipAutomatic - + - + True + False + False _6 True FrameskipAutomatic - + - + True + False + False _7 True FrameskipAutomatic - + - + True + False + False _8 True FrameskipAutomatic - + - + True + False + False _9 True FrameskipAutomatic - + - + - + - + True + False + False _Emulator True - - + + + False - + True + False + False Pause when inactive window True - + - + True + False + False Show speed True - - + + + False - + True + False + False None True True - + - + True + False + False Percentage True ShowSpeedNone - + - + True + False + False Detailed True ShowSpeedNone - + - + - + - + - + - + True + False + False _Game Boy ... True - + - + True + False + False Game Boy _Advance ... True - + - + True + False + False _Display ... True - + - + True + False + False _Sound ... True - + - + True + False + False D_irectories ... True - + - + True + False + False _Joypads ... True - + - + - + - + True - gtk-help + False + False + _Help True - True - - + + + False - + + gtk-about True - gtk-about + False + False True True - + accelgroup1 + - + - + - + False + True + 0 - + True + False 0 0 - + + True + True 1 - + - - + + + diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 38be11b5..38e8fe3e 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -49,8 +49,6 @@ extern int RGB_LOW_BITS_MASK; namespace VBA { -using Gnome::Glade::Xml; - Window * Window::m_poInstance = NULL; const Window::SJoypadKey Window::m_astJoypad[] = @@ -73,7 +71,7 @@ const Window::SJoypadKey Window::m_astJoypad[] = { "autoB", KEY_BUTTON_AUTO_B } }; -Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr & _poXml) : +Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr & _poXml) : Gtk::Window (_pstWindow), m_iGBScreenWidth (160), m_iGBScreenHeight (144), @@ -155,28 +153,28 @@ Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr & _poXml) : Gtk::CheckMenuItem * poCMI; // Menu bar - m_poMenuBar = dynamic_cast(_poXml->get_widget("MenuBar")); + _poXml->get_widget("MenuBar", m_poMenuBar); m_poMenuBar->signal_deactivate().connect(sigc::mem_fun(*this, &Window::vOnMenuExit)); - poMI = dynamic_cast(_poXml->get_widget("FileMenu")); + _poXml->get_widget("FileMenu", poMI); poMI->signal_activate().connect(sigc::mem_fun(*this, &Window::vOnMenuEnter)); - poMI = dynamic_cast(_poXml->get_widget("EmulationMenu")); + _poXml->get_widget("EmulationMenu", poMI); poMI->signal_activate().connect(sigc::mem_fun(*this, &Window::vOnMenuEnter)); - poMI = dynamic_cast(_poXml->get_widget("OptionsMenu")); + _poXml->get_widget("OptionsMenu", poMI); poMI->signal_activate().connect(sigc::mem_fun(*this, &Window::vOnMenuEnter)); - poMI = dynamic_cast(_poXml->get_widget("HelpMenu")); + _poXml->get_widget("HelpMenu", poMI); poMI->signal_activate().connect(sigc::mem_fun(*this, &Window::vOnMenuEnter)); // File menu // - poMI = dynamic_cast(_poXml->get_widget("FileOpen")); + _poXml->get_widget("FileOpen", poMI); poMI->signal_activate().connect(sigc::mem_fun(*this, &Window::vOnFileOpen)); - poMI = dynamic_cast(_poXml->get_widget("FileLoad")); + _poXml->get_widget("FileLoad", poMI); poMI->signal_activate().connect(sigc::mem_fun(*this, &Window::vOnFileLoad)); m_listSensitiveWhenPlaying.push_back(poMI); - poMI = dynamic_cast(_poXml->get_widget("FileSave")); + _poXml->get_widget("FileSave", poMI); poMI->signal_activate().connect(sigc::mem_fun(*this, &Window::vOnFileSave)); m_listSensitiveWhenPlaying.push_back(poMI); @@ -184,9 +182,9 @@ Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr & _poXml) : { char csName[20]; snprintf(csName, 20, "LoadGameSlot%d", i + 1); - m_apoLoadGameItem[i] = dynamic_cast(_poXml->get_widget(csName)); + _poXml->get_widget(csName, m_apoLoadGameItem[i]); snprintf(csName, 20, "SaveGameSlot%d", i + 1); - m_apoSaveGameItem[i] = dynamic_cast(_poXml->get_widget(csName)); + _poXml->get_widget(csName, m_apoSaveGameItem[i]); m_apoLoadGameItem[i]->signal_activate().connect(sigc::bind( sigc::mem_fun(*this, &Window::vOnLoadGame), @@ -197,22 +195,22 @@ Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr & _poXml) : } vUpdateGameSlots(); - poMI = dynamic_cast(_poXml->get_widget("LoadGameMostRecent")); + _poXml->get_widget("LoadGameMostRecent", poMI); poMI->signal_activate().connect(sigc::mem_fun(*this, &Window::vOnLoadGameMostRecent)); m_listSensitiveWhenPlaying.push_back(poMI); - poCMI = dynamic_cast(_poXml->get_widget("LoadGameAuto")); + _poXml->get_widget("LoadGameAuto", poCMI); poCMI->set_active(m_poCoreConfig->oGetKey("load_game_auto")); vOnLoadGameAutoToggled(poCMI); poCMI->signal_toggled().connect(sigc::bind( sigc::mem_fun(*this, &Window::vOnLoadGameAutoToggled), poCMI)); - poMI = dynamic_cast(_poXml->get_widget("SaveGameOldest")); + _poXml->get_widget("SaveGameOldest", poMI); poMI->signal_activate().connect(sigc::mem_fun(*this, &Window::vOnSaveGameOldest)); m_listSensitiveWhenPlaying.push_back(poMI); - m_poFilePauseItem = dynamic_cast(_poXml->get_widget("FilePause")); + _poXml->get_widget("FilePause", m_poFilePauseItem); m_poFilePauseItem->set_active(false); vOnFilePauseToggled(m_poFilePauseItem); m_poFilePauseItem->signal_toggled().connect(sigc::bind( @@ -220,19 +218,19 @@ Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr & _poXml) : m_poFilePauseItem)); m_listSensitiveWhenPlaying.push_back(m_poFilePauseItem); - poMI = dynamic_cast(_poXml->get_widget("FileReset")); + _poXml->get_widget("FileReset", poMI); poMI->signal_activate().connect(sigc::mem_fun(*this, &Window::vOnFileReset)); m_listSensitiveWhenPlaying.push_back(poMI); - poMI = dynamic_cast(_poXml->get_widget("FileScreenCapture")); + _poXml->get_widget("FileScreenCapture", poMI); poMI->signal_activate().connect(sigc::mem_fun(*this, &Window::vOnFileScreenCapture)); m_listSensitiveWhenPlaying.push_back(poMI); - poMI = dynamic_cast(_poXml->get_widget("FileClose")); + _poXml->get_widget("FileClose", poMI); poMI->signal_activate().connect(sigc::mem_fun(*this, &Window::vOnFileClose)); m_listSensitiveWhenPlaying.push_back(poMI); - poMI = dynamic_cast(_poXml->get_widget("FileExit")); + _poXml->get_widget("FileExit", poMI); poMI->signal_activate().connect(sigc::mem_fun(*this, &Window::vOnFileExit)); // Recent menu @@ -251,7 +249,7 @@ Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr & _poXml) : sigc::mem_fun(*this, &Window::vOnRecentFile)); - m_poRecentMenu = dynamic_cast(_poXml->get_widget("RecentMenu")); + _poXml->get_widget("RecentMenu", m_poRecentMenu); m_poRecentMenu->set_submenu(static_cast(*m_poRecentChooserMenu)); // Frameskip menu @@ -286,7 +284,7 @@ Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr & _poXml) : } for (guint i = 0; i < G_N_ELEMENTS(astFrameskip); i++) { - poCMI = dynamic_cast(_poXml->get_widget(astFrameskip[i].m_csName)); + _poXml->get_widget(astFrameskip[i].m_csName, poCMI); if (astFrameskip[i].m_iFrameskip == iDefaultFrameskip) { poCMI->set_active(); @@ -299,10 +297,10 @@ Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr & _poXml) : // Emulator menu // - poMI = dynamic_cast(_poXml->get_widget("DirectoriesConfigure")); + _poXml->get_widget("DirectoriesConfigure", poMI); poMI->signal_activate().connect(sigc::mem_fun(*this, &Window::vOnDirectories)); - poCMI = dynamic_cast(_poXml->get_widget("EmulatorPauseWhenInactive")); + _poXml->get_widget("EmulatorPauseWhenInactive", poCMI); poCMI->set_active(m_poDisplayConfig->oGetKey("pause_when_inactive")); vOnPauseWhenInactiveToggled(poCMI); poCMI->signal_toggled().connect(sigc::bind( @@ -325,7 +323,7 @@ Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr & _poXml) : EShowSpeed eDefaultShowSpeed = (EShowSpeed)m_poDisplayConfig->oGetKey("show_speed"); for (guint i = 0; i < G_N_ELEMENTS(astShowSpeed); i++) { - poCMI = dynamic_cast(_poXml->get_widget(astShowSpeed[i].m_csName)); + _poXml->get_widget(astShowSpeed[i].m_csName, poCMI); if (astShowSpeed[i].m_eShowSpeed == eDefaultShowSpeed) { poCMI->set_active(); @@ -337,24 +335,24 @@ Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr & _poXml) : } // Game Boy menu - poMI = dynamic_cast(_poXml->get_widget("GameBoyConfigure")); + _poXml->get_widget("GameBoyConfigure", poMI); poMI->signal_activate().connect(sigc::mem_fun(*this, &Window::vOnGameBoyConfigure)); // Game Boy Advance menu - poMI = dynamic_cast(_poXml->get_widget("GameBoyAdvanceConfigure")); + _poXml->get_widget("GameBoyAdvanceConfigure", poMI); poMI->signal_activate().connect(sigc::mem_fun(*this, &Window::vOnGameBoyAdvanceConfigure)); // Display menu - poMI = dynamic_cast(_poXml->get_widget("DisplayConfigure")); + _poXml->get_widget("DisplayConfigure", poMI); poMI->signal_activate().connect(sigc::mem_fun(*this, &Window::vOnDisplayConfigure)); // Sound menu - poMI = dynamic_cast(_poXml->get_widget("SoundConfigure")); + _poXml->get_widget("SoundConfigure", poMI); poMI->signal_activate().connect(sigc::mem_fun(*this, &Window::vOnSoundConfigure)); // Joypad menu // - poMI = dynamic_cast(_poXml->get_widget("JoypadConfigure")); + _poXml->get_widget("JoypadConfigure", poMI); poMI->signal_activate().connect(sigc::mem_fun(*this, &Window::vOnJoypadConfigure)); EPad eDefaultJoypad = (EPad)m_poInputConfig->oGetKey("active_joypad"); @@ -362,12 +360,12 @@ Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr & _poXml) : // Fullscreen menu // - poMI = dynamic_cast(_poXml->get_widget("VideoFullscreen")); + _poXml->get_widget("VideoFullscreen", poMI); poMI->signal_activate().connect(sigc::mem_fun(*this, &Window::vOnVideoFullscreen)); // Help menu // - poMI = dynamic_cast(_poXml->get_widget("HelpAbout")); + _poXml->get_widget("HelpAbout", poMI); poMI->signal_activate().connect(sigc::mem_fun(*this, &Window::vOnHelpAbout)); // Init widgets sensitivity @@ -459,7 +457,7 @@ void Window::vApplyConfigScreenArea() Gtk::Alignment * poC; - poC = dynamic_cast(m_poXml->get_widget("ScreenContainer")); + m_poXml->get_widget("ScreenContainer", poC); poC->remove(); poC->set(Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER, 1.0, 1.0); diff --git a/src/gtk/window.h b/src/gtk/window.h index d9344667..cfe33bdc 100644 --- a/src/gtk/window.h +++ b/src/gtk/window.h @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include "../System.h" #include "../sdl/inputSDL.h" @@ -39,7 +39,7 @@ namespace VBA class Window : public Gtk::Window { - friend class Gnome::Glade::Xml; + friend class Gtk::Builder; public: virtual ~Window(); @@ -113,7 +113,7 @@ public: protected: Window(GtkWindow * _pstWindow, - const Glib::RefPtr & _poXml); + const Glib::RefPtr & _poXml); enum EShowSpeed { @@ -197,7 +197,7 @@ private: static Window * m_poInstance; - Glib::RefPtr m_poXml; + Glib::RefPtr m_poXml; std::string m_sUserDataDir; std::string m_sConfigFile;