- Converted the "Directories" dialog to plain gtkmm
- Cleaned up the Joypad dialog
This commit is contained in:
bgk 2008-09-13 09:59:45 +00:00
parent 805315a8d1
commit c79612a379
4 changed files with 35 additions and 604 deletions

View File

@ -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();
}

View File

@ -22,7 +22,6 @@
#include <vector>
#include <libglademm.h>
#include <gtkmm.h>
#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<Gtk::Entry *> m_oEntries;
gint m_iCurrentEntry;

View File

@ -1543,571 +1543,6 @@
</widget>
</child>
</widget>
<widget class="GtkDialog" id="DirectoriesDialog">
<property name="title" translatable="yes">Directories</property>
<property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
<property name="destroy_with_parent">True</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox3">
<property name="visible">True</property>
<child>
<widget class="GtkTable" id="table1">
<property name="visible">True</property>
<property name="n_rows">5</property>
<property name="n_columns">2</property>
<child>
<widget class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">GBA roms : </property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkFileChooserButton" id="GBARomsDirEntry">
<property name="visible">True</property>
<property name="action">GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label7">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">GB roms : </property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label8">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Batteries : </property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkFileChooserButton" id="BatteriesDirEntry">
<property name="visible">True</property>
<property name="action">GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label9">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Saves : </property>
</widget>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkFileChooserButton" id="SavesDirEntry">
<property name="visible">True</property>
<property name="action">GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label10">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Captures : </property>
</widget>
<packing>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkFileChooserButton" id="CapturesDirEntry">
<property name="visible">True</property>
<property name="action">GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkFileChooserButton" id="GBRomsDirEntry">
<property name="visible">True</property>
<property name="action">GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
</widget>
<packing>
<property name="position">2</property>
</packing>
</child>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area3">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="closebutton2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="label">gtk-close</property>
<property name="use_stock">True</property>
<property name="response_id">-5</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
</widget>
</child>
</widget>
<widget class="GtkDialog" id="JoypadConfigDialog">
<property name="title" translatable="yes">Joypad config</property>
<property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
<property name="destroy_with_parent">True</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox4">
<property name="visible">True</property>
<child>
<widget class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
<property name="xscale">0</property>
<child>
<widget class="GtkTable" id="table2">
<property name="visible">True</property>
<property name="n_rows">12</property>
<property name="n_columns">2</property>
<property name="row_spacing">5</property>
<child>
<widget class="GtkEntry" id="JoypadUpEntry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="invisible_char">*</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label12">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Down : </property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label13">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Left : </property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label14">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Right : </property>
</widget>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label15">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Button A : </property>
</widget>
<packing>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label16">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Button B : </property>
</widget>
<packing>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label17">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Button L : </property>
</widget>
<packing>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label18">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Button R : </property>
</widget>
<packing>
<property name="top_attach">7</property>
<property name="bottom_attach">8</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label19">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Select : </property>
</widget>
<packing>
<property name="top_attach">8</property>
<property name="bottom_attach">9</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label20">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Start : </property>
</widget>
<packing>
<property name="top_attach">9</property>
<property name="bottom_attach">10</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label21">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Speed : </property>
</widget>
<packing>
<property name="top_attach">10</property>
<property name="bottom_attach">11</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label22">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Capture : </property>
</widget>
<packing>
<property name="top_attach">11</property>
<property name="bottom_attach">12</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="JoypadDownEntry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="invisible_char">*</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="JoypadLeftEntry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="invisible_char">*</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="JoypadRightEntry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="invisible_char">*</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="JoypadAEntry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="invisible_char">*</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="JoypadBEntry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="invisible_char">*</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="JoypadLEntry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="invisible_char">*</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="JoypadREntry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="invisible_char">*</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">7</property>
<property name="bottom_attach">8</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="JoypadSelectEntry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="invisible_char">*</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">8</property>
<property name="bottom_attach">9</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="JoypadStartEntry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="invisible_char">*</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">9</property>
<property name="bottom_attach">10</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="JoypadSpeedEntry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="invisible_char">*</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">10</property>
<property name="bottom_attach">11</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="JoypadCaptureEntry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="invisible_char">*</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">11</property>
<property name="bottom_attach">12</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label11">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Up : </property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
</widget>
</child>
</widget>
<packing>
<property name="position">2</property>
</packing>
</child>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area4">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="JoypadOkButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="label">gtk-close</property>
<property name="use_stock">True</property>
<property name="response_id">-5</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
</widget>
</child>
</widget>
<widget class="GtkDialog" id="TcpPortDialog">
<property name="title" translatable="yes">TCP port</property>
<property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>

View File

@ -617,46 +617,52 @@ void Window::vOnLayerToggled(Gtk::CheckMenuItem * _poCMI, int _iLayer)
void Window::vOnDirectories()
{
Glib::RefPtr<Xml> 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<Gtk::FileChooserButton *>(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<Gtk::Dialog *>(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<Gtk::FileChooserButton *>(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();
}