GTK: Cleanup includes. Don't instanciate global objects.
git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@987 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
parent
6f0b4f3048
commit
0be270ad00
|
@ -23,23 +23,6 @@
|
|||
namespace VBA
|
||||
{
|
||||
|
||||
class CheatCodeColumns : public Gtk::TreeModel::ColumnRecord
|
||||
{
|
||||
public:
|
||||
CheatCodeColumns()
|
||||
{
|
||||
add(uText);
|
||||
add(iType);
|
||||
}
|
||||
|
||||
~CheatCodeColumns() {}
|
||||
|
||||
Gtk::TreeModelColumn<Glib::ustring> uText;
|
||||
Gtk::TreeModelColumn<ECheatType> iType;
|
||||
};
|
||||
|
||||
CheatCodeColumns cTypeModel;
|
||||
|
||||
/**
|
||||
* GameBoyAdvanceCheatEditDialog
|
||||
*
|
||||
|
@ -55,24 +38,24 @@ CheatEditDialog::CheatEditDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::
|
|||
refBuilder->get_widget("CheatCancelButton", m_poCheatCancelButton);
|
||||
|
||||
// Tree View model
|
||||
m_poCheatTypeStore = Gtk::ListStore::create(cTypeModel);
|
||||
m_poCheatTypeStore = Gtk::ListStore::create(m_oTypeModel);
|
||||
|
||||
m_poCheatTypeComboBox->set_model(m_poCheatTypeStore);
|
||||
|
||||
Gtk::TreeModel::Row row = *(m_poCheatTypeStore->append());
|
||||
|
||||
row[cTypeModel.iType] = CheatGeneric;
|
||||
row[cTypeModel.uText] = "Generic Code";
|
||||
row[m_oTypeModel.iType] = CheatGeneric;
|
||||
row[m_oTypeModel.uText] = "Generic Code";
|
||||
|
||||
row = *(m_poCheatTypeStore->append());
|
||||
|
||||
row[cTypeModel.iType] = CheatGSA;
|
||||
row[cTypeModel.uText] = "Gameshark Advance";
|
||||
row[m_oTypeModel.iType] = CheatGSA;
|
||||
row[m_oTypeModel.uText] = "Gameshark Advance";
|
||||
|
||||
row = *(m_poCheatTypeStore->append());
|
||||
|
||||
row[cTypeModel.iType] = CheatCBA;
|
||||
row[cTypeModel.uText] = "CodeBreaker Advance";
|
||||
row[m_oTypeModel.iType] = CheatCBA;
|
||||
row[m_oTypeModel.uText] = "CodeBreaker Advance";
|
||||
|
||||
m_poCheatTypeComboBox->set_active(CheatGeneric);
|
||||
|
||||
|
@ -98,7 +81,7 @@ ECheatType CheatEditDialog::vGetType()
|
|||
{
|
||||
Gtk::TreeModel::Row row = *iter;
|
||||
|
||||
return row[cTypeModel.iType];
|
||||
return row[m_oTypeModel.iType];
|
||||
}
|
||||
|
||||
return CheatGeneric;
|
||||
|
|
|
@ -19,7 +19,11 @@
|
|||
#ifndef __VBA_CHEATEDIT_H__
|
||||
#define __VBA_CHEATEDIT_H__
|
||||
|
||||
#include <gtkmm.h>
|
||||
#include <gtkmm/combobox.h>
|
||||
#include <gtkmm/entry.h>
|
||||
#include <gtkmm/liststore.h>
|
||||
#include <gtkmm/textview.h>
|
||||
#include <gtkmm/treemodel.h>
|
||||
|
||||
#include "window.h"
|
||||
|
||||
|
@ -33,6 +37,21 @@ enum ECheatType
|
|||
CheatCBA
|
||||
};
|
||||
|
||||
class EditCheatCodeColumns : public Gtk::TreeModel::ColumnRecord
|
||||
{
|
||||
public:
|
||||
EditCheatCodeColumns()
|
||||
{
|
||||
add(uText);
|
||||
add(iType);
|
||||
}
|
||||
|
||||
~EditCheatCodeColumns() {}
|
||||
|
||||
Gtk::TreeModelColumn<Glib::ustring> uText;
|
||||
Gtk::TreeModelColumn<ECheatType> iType;
|
||||
};
|
||||
|
||||
class CheatEditDialog : public Gtk::Dialog
|
||||
{
|
||||
public:
|
||||
|
@ -54,6 +73,7 @@ private:
|
|||
Gtk::Button * m_poCheatCancelButton;
|
||||
Glib::RefPtr<Gtk::TextBuffer> m_poCheatInputBuffer;
|
||||
Glib::RefPtr<Gtk::ListStore> m_poCheatTypeStore;
|
||||
EditCheatCodeColumns m_oTypeModel;
|
||||
};
|
||||
|
||||
} // namespace VBA
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
#include "cheatlist.h"
|
||||
|
||||
#include <gtkmm/stock.h>
|
||||
|
||||
#include "intl.h"
|
||||
#include "stringtokenizer.h"
|
||||
#include <vector>
|
||||
|
@ -25,25 +27,6 @@
|
|||
namespace VBA
|
||||
{
|
||||
|
||||
class CheatCodeColumns : public Gtk::TreeModel::ColumnRecord
|
||||
{
|
||||
public:
|
||||
CheatCodeColumns()
|
||||
{
|
||||
add(iIndex);
|
||||
add(bEnabled);
|
||||
add(uDesc);
|
||||
}
|
||||
|
||||
~CheatCodeColumns() {}
|
||||
|
||||
Gtk::TreeModelColumn<int> iIndex;
|
||||
Gtk::TreeModelColumn<bool> bEnabled;
|
||||
Gtk::TreeModelColumn<Glib::ustring> uDesc;
|
||||
};
|
||||
|
||||
CheatCodeColumns cRecordModel;
|
||||
|
||||
CheatListDialog::CheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::Builder>& refBuilder) :
|
||||
Gtk::Dialog(_pstDialog)
|
||||
{
|
||||
|
@ -56,7 +39,7 @@ CheatListDialog::CheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::
|
|||
refBuilder->get_widget("CheatTreeView", m_poCheatTreeView);
|
||||
|
||||
// Tree View model
|
||||
m_poCheatListStore = Gtk::ListStore::create(cRecordModel);
|
||||
m_poCheatListStore = Gtk::ListStore::create(m_oRecordModel);
|
||||
|
||||
m_poCheatTreeView->set_model(m_poCheatListStore);
|
||||
|
||||
|
@ -69,9 +52,9 @@ CheatListDialog::CheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr<Gtk::
|
|||
Gtk::TreeViewColumn* pColumn = m_poCheatTreeView->get_column(cols_count - 1);
|
||||
|
||||
if (pColumn)
|
||||
pColumn->add_attribute(pRenderer->property_active(), cRecordModel.bEnabled);
|
||||
pColumn->add_attribute(pRenderer->property_active(), m_oRecordModel.bEnabled);
|
||||
|
||||
m_poCheatTreeView->append_column("Description", cRecordModel.uDesc);
|
||||
m_poCheatTreeView->append_column("Description", m_oRecordModel.uDesc);
|
||||
|
||||
m_poCheatOpenButton->signal_clicked().connect(sigc::mem_fun(*this, &CheatListDialog::vOnCheatOpen));
|
||||
m_poCheatSaveButton->signal_clicked().connect(sigc::mem_fun(*this, &CheatListDialog::vOnCheatSave));
|
||||
|
@ -230,7 +213,7 @@ void CheatListDialog::vOnCheatRemove()
|
|||
{
|
||||
Gtk::TreeModel::Row row = *iter;
|
||||
|
||||
cheatsDelete(row[cRecordModel.iIndex], false);
|
||||
cheatsDelete(row[m_oRecordModel.iIndex], false);
|
||||
|
||||
m_poCheatListStore->erase(iter);
|
||||
}
|
||||
|
@ -251,9 +234,9 @@ void CheatListDialog::vOnCheatMarkAll()
|
|||
{
|
||||
Gtk::TreeModel::Row row = *iter;
|
||||
|
||||
row[cRecordModel.bEnabled] = bMark;
|
||||
row[m_oRecordModel.bEnabled] = bMark;
|
||||
|
||||
vToggleCheat(row[cRecordModel.iIndex], row[cRecordModel.bEnabled]);
|
||||
vToggleCheat(row[m_oRecordModel.iIndex], row[m_oRecordModel.bEnabled]);
|
||||
}
|
||||
|
||||
bMark = !bMark;
|
||||
|
@ -265,9 +248,9 @@ void CheatListDialog::vOnCheatToggled(Glib::ustring const& string_path)
|
|||
|
||||
Gtk::TreeModel::Row row = *iter;
|
||||
|
||||
row[cRecordModel.bEnabled] = !row[cRecordModel.bEnabled];
|
||||
row[m_oRecordModel.bEnabled] = !row[m_oRecordModel.bEnabled];
|
||||
|
||||
vToggleCheat(row[cRecordModel.iIndex], row[cRecordModel.bEnabled]);
|
||||
vToggleCheat(row[m_oRecordModel.iIndex], row[m_oRecordModel.bEnabled]);
|
||||
}
|
||||
|
||||
void CheatListDialog::vToggleCheat(int index, bool enable) {
|
||||
|
@ -284,9 +267,9 @@ void CheatListDialog::vUpdateList(int previous)
|
|||
// Add row for each newly added cheat
|
||||
Gtk::TreeModel::Row row = *(m_poCheatListStore->append());
|
||||
|
||||
row[cRecordModel.iIndex] = i;
|
||||
row[cRecordModel.bEnabled] = cheatsList[i].enabled;
|
||||
row[cRecordModel.uDesc] = cheatsList[i].desc;
|
||||
row[m_oRecordModel.iIndex] = i;
|
||||
row[m_oRecordModel.bEnabled] = cheatsList[i].enabled;
|
||||
row[m_oRecordModel.uDesc] = cheatsList[i].desc;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#ifndef __VBA_CHEATLIST_H__
|
||||
#define __VBA_CHEATLIST_H__
|
||||
|
||||
#include <gtkmm.h>
|
||||
#include <gtkmm/toolbutton.h>
|
||||
|
||||
#include "../System.h"
|
||||
#include "../gba/Cheats.h"
|
||||
|
@ -32,6 +32,23 @@
|
|||
namespace VBA
|
||||
{
|
||||
|
||||
class ListCheatCodeColumns : public Gtk::TreeModel::ColumnRecord
|
||||
{
|
||||
public:
|
||||
ListCheatCodeColumns()
|
||||
{
|
||||
add(iIndex);
|
||||
add(bEnabled);
|
||||
add(uDesc);
|
||||
}
|
||||
|
||||
~ListCheatCodeColumns() {}
|
||||
|
||||
Gtk::TreeModelColumn<int> iIndex;
|
||||
Gtk::TreeModelColumn<bool> bEnabled;
|
||||
Gtk::TreeModelColumn<Glib::ustring> uDesc;
|
||||
};
|
||||
|
||||
class CheatListDialog : public Gtk::Dialog
|
||||
{
|
||||
public:
|
||||
|
@ -59,6 +76,7 @@ private:
|
|||
Gtk::ToolButton * m_poCheatMarkAllButton;
|
||||
Gtk::TreeView * m_poCheatTreeView;
|
||||
Glib::RefPtr<Gtk::ListStore> m_poCheatListStore;
|
||||
ListCheatCodeColumns m_oRecordModel;
|
||||
|
||||
bool bMark;
|
||||
};
|
||||
|
|
|
@ -19,7 +19,8 @@
|
|||
#ifndef __VBA_GAMEBOYADVANCECONFIG_H__
|
||||
#define __VBA_GAMEBOYADVANCECONFIG_H__
|
||||
|
||||
#include <gtkmm.h>
|
||||
#include <gtkmm/combobox.h>
|
||||
#include <gtkmm/filechooserbutton.h>
|
||||
|
||||
#include "configfile.h"
|
||||
#include "window.h"
|
||||
|
|
|
@ -19,7 +19,8 @@
|
|||
#ifndef __VBA_GAMEBOYCONFIG_H__
|
||||
#define __VBA_GAMEBOYCONFIG_H__
|
||||
|
||||
#include <gtkmm.h>
|
||||
#include <gtkmm/combobox.h>
|
||||
#include <gtkmm/filechooserbutton.h>
|
||||
|
||||
#include "configfile.h"
|
||||
#include "window.h"
|
||||
|
|
|
@ -23,6 +23,8 @@ namespace VBA
|
|||
|
||||
void StringTokenizer::tokenize(Glib::ustring source, std::vector<Glib::ustring>& tokens)
|
||||
{
|
||||
Glib::ustring delimiters = " \t\n\r";
|
||||
|
||||
// Skip delimiters at beginning.
|
||||
Glib::ustring::size_type lastPos = source.find_first_not_of(delimiters, 0);
|
||||
// Find first "non-delimiter".
|
||||
|
|
|
@ -20,8 +20,7 @@
|
|||
#ifndef __VBA_STRINGTOKENIZER_H__
|
||||
#define __VBA_STRINGTOKENIZER_H__
|
||||
|
||||
#include <gtkmm.h>
|
||||
#include <string>
|
||||
#include <glibmm/ustring.h>
|
||||
#include <vector>
|
||||
|
||||
namespace VBA
|
||||
|
@ -33,8 +32,6 @@ public:
|
|||
static void tokenize(Glib::ustring source, std::vector<Glib::ustring>& tokens);
|
||||
};
|
||||
|
||||
static const Glib::ustring delimiters = " \t\n\r";
|
||||
|
||||
} // VBA namespace
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue