From c79612a379122efcfaf8f167de7aabe94c561fa5 Mon Sep 17 00:00:00 2001 From: bgk Date: Sat, 13 Sep 2008 09:59:45 +0000 Subject: [PATCH] GTK : - Converted the "Directories" dialog to plain gtkmm - Cleaned up the Joypad dialog --- src/gtk/joypadconfig.cpp | 26 +- src/gtk/joypadconfig.h | 5 +- src/gtk/vba.glade | 565 ------------------------------------ src/gtk/windowcallbacks.cpp | 43 +-- 4 files changed, 35 insertions(+), 604 deletions(-) diff --git a/src/gtk/joypadconfig.cpp b/src/gtk/joypadconfig.cpp index 3e048f26..3a8d1b05 100644 --- a/src/gtk/joypadconfig.cpp +++ b/src/gtk/joypadconfig.cpp @@ -41,17 +41,21 @@ const JoypadConfigDialog::SJoypadKey JoypadConfigDialog::m_astKeys[] = { KEY_BUTTON_CAPTURE, "Capture :" } }; -JoypadConfigDialog::JoypadConfigDialog() : +JoypadConfigDialog::JoypadConfigDialog(EPad _eJoypad) : Gtk::Dialog("Joypad config", true, true), - m_oTable(G_N_ELEMENTS(m_astKeys), 2, false), - m_ePad(PAD_MAIN) + m_ePad(_eJoypad) { + Gtk::Table * poTable = Gtk::manage( new Gtk::Table(G_N_ELEMENTS(m_astKeys), 2, false) ); + poTable->set_border_width(5); + poTable->set_spacings(5); + get_vbox()->pack_start(* poTable); + for (guint i = 0; i < G_N_ELEMENTS(m_astKeys); i++) { Gtk::Label * poLabel = Gtk::manage( new Gtk::Label(m_astKeys[i].m_csKeyName, Gtk::ALIGN_RIGHT) ); Gtk::Entry * poEntry = Gtk::manage( new Gtk::Entry() ); - m_oTable.attach(* poLabel, 0, 1, i, i + 1); - m_oTable.attach(* poEntry, 1, 2, i, i + 1); + poTable->attach(* poLabel, 0, 1, i, i + 1); + poTable->attach(* poEntry, 1, 2, i, i + 1); m_oEntries.push_back(poEntry); poEntry->signal_focus_in_event().connect(sigc::bind( @@ -60,26 +64,16 @@ JoypadConfigDialog::JoypadConfigDialog() : poEntry->signal_focus_out_event().connect(sigc::mem_fun(*this, &JoypadConfigDialog::bOnEntryFocusOut)); } - Gtk::VBox* poVBox = get_vbox(); - poVBox->pack_start(m_oTable); - - m_oTable.set_border_width(5); - m_oTable.set_spacings(5); - m_poOkButton = add_button(Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE); - show_all(); + show_all_children(); vEmptyEventQueue(); memset(&m_oPreviousEvent, 0, sizeof(m_oPreviousEvent)); m_oConfigSig = Glib::signal_idle().connect(sigc::mem_fun(*this, &JoypadConfigDialog::bOnConfigIdle), Glib::PRIORITY_DEFAULT_IDLE); -} -void JoypadConfigDialog::vInitDialog(EPad _ePad) -{ - m_ePad = _ePad; vUpdateEntries(); } diff --git a/src/gtk/joypadconfig.h b/src/gtk/joypadconfig.h index d9911bab..76e6312b 100644 --- a/src/gtk/joypadconfig.h +++ b/src/gtk/joypadconfig.h @@ -22,7 +22,6 @@ #include -#include #include #include "../sdl/inputSDL.h" @@ -33,10 +32,9 @@ namespace VBA class JoypadConfigDialog : public Gtk::Dialog { public: - JoypadConfigDialog(); + JoypadConfigDialog(EPad _eJoypad); virtual ~JoypadConfigDialog(); - void vInitDialog(EPad _ePad); protected: bool bOnEntryFocusIn(GdkEventFocus * _pstEvent, guint _uiEntry); bool bOnEntryFocusOut(GdkEventFocus * _pstEvent); @@ -51,7 +49,6 @@ private: const char * m_csKeyName; }; - Gtk::Table m_oTable; Gtk::Button * m_poOkButton; std::vector m_oEntries; gint m_iCurrentEntry; diff --git a/src/gtk/vba.glade b/src/gtk/vba.glade index e265f427..b2eaa773 100644 --- a/src/gtk/vba.glade +++ b/src/gtk/vba.glade @@ -1543,571 +1543,6 @@ - - Directories - GTK_WIN_POS_CENTER_ON_PARENT - True - GDK_WINDOW_TYPE_HINT_DIALOG - - - True - - - True - 5 - 2 - - - True - 1 - GBA roms : - - - GTK_FILL - GTK_EXPAND - - - - - True - GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER - - - 1 - 2 - GTK_EXPAND - - - - - True - 1 - GB roms : - - - 1 - 2 - GTK_FILL - GTK_EXPAND - - - - - True - 1 - Batteries : - - - 2 - 3 - GTK_FILL - GTK_EXPAND - - - - - True - GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER - - - 1 - 2 - 2 - 3 - GTK_EXPAND - - - - - True - 1 - Saves : - - - 3 - 4 - GTK_FILL - GTK_EXPAND - - - - - True - GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER - - - 1 - 2 - 3 - 4 - GTK_EXPAND - - - - - True - 1 - Captures : - - - 4 - 5 - GTK_FILL - GTK_EXPAND - - - - - True - GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER - - - 1 - 2 - 4 - 5 - GTK_EXPAND - - - - - True - GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER - - - 1 - 2 - 1 - 2 - GTK_EXPAND - - - - - 2 - - - - - True - GTK_BUTTONBOX_END - - - True - True - True - gtk-close - True - -5 - - - 1 - - - - - False - GTK_PACK_END - - - - - - - Joypad config - GTK_WIN_POS_CENTER_ON_PARENT - True - GDK_WINDOW_TYPE_HINT_DIALOG - - - True - - - True - 0 - - - True - 12 - 2 - 5 - - - True - True - False - * - - - 1 - 2 - GTK_FILL - GTK_EXPAND - - - - - True - 1 - Down : - - - 1 - 2 - GTK_FILL - GTK_EXPAND - - - - - True - 1 - Left : - - - 2 - 3 - GTK_FILL - GTK_EXPAND - - - - - True - 1 - Right : - - - 3 - 4 - GTK_FILL - GTK_EXPAND - - - - - True - 1 - Button A : - - - 4 - 5 - GTK_FILL - GTK_EXPAND - - - - - True - 1 - Button B : - - - 5 - 6 - GTK_FILL - GTK_EXPAND - - - - - True - 1 - Button L : - - - 6 - 7 - GTK_FILL - GTK_EXPAND - - - - - True - 1 - Button R : - - - 7 - 8 - GTK_FILL - GTK_EXPAND - - - - - True - 1 - Select : - - - 8 - 9 - GTK_FILL - GTK_EXPAND - - - - - True - 1 - Start : - - - 9 - 10 - GTK_FILL - GTK_EXPAND - - - - - True - 1 - Speed : - - - 10 - 11 - GTK_FILL - GTK_EXPAND - - - - - True - 1 - Capture : - - - 11 - 12 - GTK_FILL - GTK_EXPAND - - - - - True - True - False - * - - - 1 - 2 - 1 - 2 - GTK_FILL - GTK_EXPAND - - - - - True - True - False - * - - - 1 - 2 - 2 - 3 - GTK_FILL - GTK_EXPAND - - - - - True - True - False - * - - - 1 - 2 - 3 - 4 - GTK_FILL - GTK_EXPAND - - - - - True - True - False - * - - - 1 - 2 - 4 - 5 - GTK_FILL - GTK_EXPAND - - - - - True - True - False - * - - - 1 - 2 - 5 - 6 - GTK_FILL - GTK_EXPAND - - - - - True - True - False - * - - - 1 - 2 - 6 - 7 - GTK_FILL - GTK_EXPAND - - - - - True - True - False - * - - - 1 - 2 - 7 - 8 - GTK_FILL - GTK_EXPAND - - - - - True - True - False - * - - - 1 - 2 - 8 - 9 - GTK_FILL - GTK_EXPAND - - - - - True - True - False - * - - - 1 - 2 - 9 - 10 - GTK_FILL - GTK_EXPAND - - - - - True - True - False - * - - - 1 - 2 - 10 - 11 - GTK_FILL - GTK_EXPAND - - - - - True - True - False - * - - - 1 - 2 - 11 - 12 - GTK_FILL - GTK_EXPAND - - - - - True - 1 - Up : - - - GTK_FILL - GTK_EXPAND - - - - - - - 2 - - - - - True - GTK_BUTTONBOX_END - - - True - True - True - gtk-close - True - -5 - - - 1 - - - - - False - GTK_PACK_END - - - - - TCP port GTK_WIN_POS_CENTER_ON_PARENT diff --git a/src/gtk/windowcallbacks.cpp b/src/gtk/windowcallbacks.cpp index 6a3ed853..c1453cdb 100644 --- a/src/gtk/windowcallbacks.cpp +++ b/src/gtk/windowcallbacks.cpp @@ -617,46 +617,52 @@ void Window::vOnLayerToggled(Gtk::CheckMenuItem * _poCMI, int _iLayer) void Window::vOnDirectories() { - Glib::RefPtr poXml; - poXml = Xml::create(PKGDATADIR "/vba.glade", "DirectoriesDialog"); - struct { const char * m_csKey; + const char * m_csLabel; const char * m_csFileChooserButton; + Gtk::FileChooserButton * m_poFileChooserButton; } astRow[] = { - { "gba_roms", "GBARomsDirEntry" }, - { "gb_roms", "GBRomsDirEntry" }, - { "batteries", "BatteriesDirEntry" }, - { "saves", "SavesDirEntry" }, - { "captures", "CapturesDirEntry" } + { "gba_roms", "GBA roms :", "GBARomsDirEntry", 0 }, + { "gb_roms", "GB roms :", "GBRomsDirEntry", 0 }, + { "batteries", "Batteries :", "BatteriesDirEntry", 0 }, + { "saves", "Saves :", "SavesDirEntry", 0 }, + { "captures", "Captures :", "CapturesDirEntry", 0 } }; + Gtk::Table oTable(G_N_ELEMENTS(astRow), 2, false); + oTable.set_border_width(5); + oTable.set_spacings(5); + for (guint i = 0; i < G_N_ELEMENTS(astRow); i++) { - Gtk::FileChooserButton * poFileChooserButton = dynamic_cast(poXml->get_widget(astRow[i].m_csFileChooserButton)); + Gtk::Label * poLabel = Gtk::manage( new Gtk::Label(astRow[i].m_csLabel, Gtk::ALIGN_RIGHT) ); + astRow[i].m_poFileChooserButton = Gtk::manage( new Gtk::FileChooserButton(Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER) ); + astRow[i].m_poFileChooserButton->set_current_folder(m_poDirConfig->sGetKey(astRow[i].m_csKey)); - poFileChooserButton->set_current_folder(m_poDirConfig->sGetKey(astRow[i].m_csKey)); + oTable.attach(* poLabel, 0, 1, i, i + 1); + oTable.attach(* astRow[i].m_poFileChooserButton, 1, 2, i, i + 1); } - Gtk::Dialog * poDialog = dynamic_cast(poXml->get_widget("DirectoriesDialog")); - poDialog->set_transient_for(*this); - poDialog->run(); + Gtk::Dialog oDialog("Directories", true, true); + oDialog.add_button(Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE); + oDialog.get_vbox()->pack_start(oTable); + oDialog.set_transient_for(*this); + oDialog.show_all_children(); + oDialog.run(); for (guint i = 0; i < G_N_ELEMENTS(astRow); i++) { - Gtk::FileChooserButton * poFileChooserButton = dynamic_cast(poXml->get_widget(astRow[i].m_csFileChooserButton)); - Glib::ustring sDir = poFileChooserButton->get_current_folder(); + Glib::ustring sDir = astRow[i].m_poFileChooserButton->get_current_folder(); m_poDirConfig->vSetKey(astRow[i].m_csKey, sDir); } // Needed if saves dir changed vUpdateGameSlots(); - - delete poDialog; } void Window::vOnPauseWhenInactiveToggled(Gtk::CheckMenuItem * _poCMI) @@ -863,9 +869,8 @@ void Window::vOnFilterIBToggled(Gtk::CheckMenuItem * _poCMI, int _iFilterIB) void Window::vOnJoypadConfigure(EPad _eJoypad) { - JoypadConfigDialog oDialog; + JoypadConfigDialog oDialog(_eJoypad); oDialog.set_transient_for(*this); - oDialog.vInitDialog(_eJoypad); oDialog.run(); }