Loading...
Searching...
No Matches
gx_preset_window.h
Go to the documentation of this file.
/*
* Copyright (C) 2009, 2010 Hermann Meyer, James Warden, Andreas Degert
* Copyright (C) 2011 Pete Shorthose
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* ---------------------------------------------------------------------------
*
*
* ----------------------------------------------------------------------------
*/
/****************************************************************
** class PresetWindow
*/
class PresetStore: public Gtk::ListStore {
public:
class PresetModelColumns : public Gtk::TreeModel::ColumnRecord {
public:
Gtk::TreeModelColumn<Glib::ustring> name;
Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > edit_pb;
Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > del_pb;
PresetModelColumns() { add(name); add(edit_pb); add(del_pb); }
} col;
public:
PresetStore();
virtual bool row_draggable_vfunc(const TreeModel::Path& path) const;
};
class TargetModelColumns : public Gtk::TreeModel::ColumnRecord {
public:
Gtk::TreeModelColumn<Glib::ustring> name;
TargetModelColumns() { add(name); }
};
class BankModelColumns : public Gtk::TreeModel::ColumnRecord {
public:
Gtk::TreeModelColumn<Glib::ustring> name;
Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > type_pb;
Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > edit_pb;
Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > del_pb;
Gtk::TreeModelColumn<int> tp;
BankModelColumns() { add(name); add(type_pb); add(edit_pb); add(del_pb); add(tp); }
};
class MyTreeView: public Gtk::TreeView {
private:
MyTreeView(BaseObjectType* cobject): Gtk::TreeView(cobject) {}
sigc::signal<void()> m_signal_row_clicked;
virtual bool on_button_press_event(GdkEventButton* button_event);
public:
static MyTreeView *create_from_builder(BaseObjectType* cobject) { return new MyTreeView(cobject); }
//virtual bool on_drag_motion(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, guint timestamp);
using Gtk::TreeView::on_drag_motion;
sigc::signal<void()>& signal_row_clicked() { return m_signal_row_clicked; }
};
class GxActions;
class UIManager;
class PresetWindow: public sigc::trackable {
private:
enum {
TEXT_TARGETS = 0,
MODELROW_TARGET = 1,
URILIST_TARGET = 2,
};
gx_engine::GxMachineBase& machine;
GxActions& actions;
Glib::RefPtr<Gtk::AccelGroup> accelgroup;
CURL *curl;
bool in_edit;
Gtk::TreeModel::iterator edit_iter;
Glib::RefPtr<Gdk::Pixbuf> pb_edit;
Glib::RefPtr<Gdk::Pixbuf> pb_del;
Glib::RefPtr<Gdk::Pixbuf> pb_scratch;
Glib::RefPtr<Gdk::Pixbuf> pb_versiondiff;
Glib::RefPtr<Gdk::Pixbuf> pb_readonly;
Glib::RefPtr<Gdk::Pixbuf> pb_factory;
Glib::RefPtr<PresetStore> pstore;
TargetModelColumns target_col;
BankModelColumns bank_col;
int vpaned_pos;
int vpaned_step;
int vpaned_target;
const gx_system::CmdlineOptions& options;
bool in_current_preset;
bool load_in_progress;
sigc::connection on_map_conn;
// widget pointers (keep last)
Gtk::Button *save_preset;
Gtk::Button *new_preset_bank;
Gtk::ToggleButton *organize_presets;
Gtk::Button *online_preset;
MyTreeView *bank_treeview;
Gtk::CellRendererText *bank_cellrenderer;
MyTreeView *preset_treeview;
Gtk::CellRendererText *preset_cellrenderer;
Gtk::ComboBox *banks_combobox;
MyTreeView *presets_target_treeview;
Gtk::Label *preset_title;
Gtk::ScrolledWindow *presets_target_scrolledbox;
Gtk::TreeViewColumn* bank_column_flags;
Gtk::TreeViewColumn* bank_column_bank;
Gtk::TreeViewColumn* bank_column_edit;
Gtk::TreeViewColumn* bank_column_delete;
Gtk::TreeViewColumn* bank_column_spacer;
Gtk::TreeViewColumn* preset_column_preset;
Gtk::TreeViewColumn* preset_column_edit;
Gtk::TreeViewColumn* preset_column_delete;
Gtk::TreeViewColumn* preset_column_spacer;
Gtk::Paned *main_vpaned;
Gtk::ScrolledWindow *preset_scrolledbox;
private:
void load_widget_pointers(Glib::RefPtr<gx_gui::GxBuilder> bld);
void target_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& data, guint info, guint timestamp);
bool on_target_drag_motion(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, guint timestamp);
Glib::ustring get_combo_selection();
void reload_combo();
void on_preset_combo_changed();
bool select_func(const Glib::RefPtr<Gtk::TreeModel>& model, const Gtk::TreePath& path, bool path_currently_selected);
void set_cell_text(Gtk::Widget *widget, Gtk::CellRenderer *cell, const Glib::ustring& text, bool selected);
void highlight_current_bank(Gtk::CellRenderer *cell, const Gtk::TreeModel::iterator& iter);
void text_func(Gtk::CellRenderer *cell, const Gtk::TreeModel::iterator& iter);
void on_editing_started(const Gtk::CellEditable* edit, const Glib::ustring& path, Glib::RefPtr<Gtk::TreeModel>& model);
void reset_edit(Gtk::TreeViewColumn& col);
void on_edit_canceled(Gtk::TreeViewColumn *col);
void start_edit(const Gtk::TreeModel::Path& pt, Gtk::TreeViewColumn& col, Gtk::CellRenderer& cell);
Gtk::TreeIter get_current_bank_iter() { return bank_treeview->get_selection()->get_selected(); }
Glib::ustring get_current_bank();
bool run_message_dialog(Gtk::Widget& w, const Glib::ustring& msg);
bool on_bank_button_release(GdkEventButton *ev);
void on_bank_edited(const Glib::ustring& path, const Glib::ustring& newtext, Gtk::TreeView* w);
bool is_row_separator(const Glib::RefPtr<Gtk::TreeModel>& model, const Gtk::TreeModel::iterator& iter);
void on_new_bank();
void on_preset_save();
const std::string pdir() { return options.get_preset_dir();}
void on_online_preset();
void show_online_preset();
void popup_pos( int& x, int& y, bool& push_in );
void downloadPreset(Gtk::Menu *presetMenu,std::string uri);
bool download_file(Glib::ustring from_uri, Glib::ustring to_path);
Glib::ustring resolve_hostname();
void create_preset_menu();
void read_preset_menu();
std::vector< std::tuple<std::string,std::string,std::string> > olp;
bool on_bank_drag_motion(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, guint timestamp);
bool bank_drag_moveable(Gtk::TreePath pt);
bool bank_find_drop_position(int x, int y, Gtk::TreeModel::Path& pt, Gtk::TreeViewDropPosition& dst);
void on_bank_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& data, guint info, guint timestamp);
void on_bank_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& context, Gtk::SelectionData& selection, int info, int timestamp);
void on_bank_changed();
bool on_bank_query_tooltip(int x, int y, bool kb_tooltip, Glib::RefPtr<Gtk::Tooltip> tooltip);
void on_bank_reordered(const Gtk::TreeModel::Path& path);
bool on_preset_button_release(GdkEventButton *ev);
void on_preset_row_activated(const Gtk::TreePath& path, Gtk::TreeViewColumn* column);
void on_preset_edited(const Glib::ustring& path, const Glib::ustring& newtext);
void on_preset_changed();
bool on_preset_drag_motion(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, guint timestamp);
void on_preset_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& context, Gtk::SelectionData& selection, int info, int timestamp);
void on_preset_reordered(const Gtk::TreeModel::Path& path);
void autosize();
void on_organize();
bool animate_preset_show();
bool animate_preset_hide();
void set_row_for_presetfile(Gtk::TreeIter i, gx_system::PresetFileGui *f);
void display_paned(bool show_preset, int paned_child_height);
void on_selection_changed();
void on_presetlist_changed();
public:
PresetWindow(Glib::RefPtr<gx_gui::GxBuilder> bld, gx_engine::GxMachineBase& machine,
const gx_system::CmdlineOptions& options, GxActions& actions, UIManager& uimanager);
~PresetWindow();
void on_preset_select(bool v, bool animated, int preset_window_height);
};
BankModelColumns
Definition gx_preset_window.h:50
BankModelColumns::del_pb
Gtk::TreeModelColumn< Glib::RefPtr< Gdk::Pixbuf > > del_pb
Definition gx_preset_window.h:55
BankModelColumns::tp
Gtk::TreeModelColumn< int > tp
Definition gx_preset_window.h:56
BankModelColumns::BankModelColumns
BankModelColumns()
Definition gx_preset_window.h:57
BankModelColumns::name
Gtk::TreeModelColumn< Glib::ustring > name
Definition gx_preset_window.h:52
BankModelColumns::edit_pb
Gtk::TreeModelColumn< Glib::RefPtr< Gdk::Pixbuf > > edit_pb
Definition gx_preset_window.h:54
BankModelColumns::type_pb
Gtk::TreeModelColumn< Glib::RefPtr< Gdk::Pixbuf > > type_pb
Definition gx_preset_window.h:53
GxActions
Definition gx_main_window.h:709
MyTreeView
Definition gx_preset_window.h:60
MyTreeView::create_from_builder
static MyTreeView * create_from_builder(BaseObjectType *cobject)
Definition gx_preset_window.h:66
MyTreeView::on_button_press_event
virtual bool on_button_press_event(GdkEventButton *button_event)
MyTreeView::signal_row_clicked
sigc::signal< void()> & signal_row_clicked()
like Gtk::TreeSelection::signal_changed, but is also emitted when the selection didn't change
Definition gx_preset_window.h:70
MyTreeView::m_signal_row_clicked
sigc::signal< void()> m_signal_row_clicked
Definition gx_preset_window.h:63
MyTreeView::MyTreeView
MyTreeView(BaseObjectType *cobject)
Definition gx_preset_window.h:62
PresetStore::PresetModelColumns::name
Gtk::TreeModelColumn< Glib::ustring > name
Definition gx_preset_window.h:33
PresetStore::PresetModelColumns::del_pb
Gtk::TreeModelColumn< Glib::RefPtr< Gdk::Pixbuf > > del_pb
Definition gx_preset_window.h:35
PresetStore::PresetModelColumns::PresetModelColumns
PresetModelColumns()
Definition gx_preset_window.h:37
PresetStore::PresetModelColumns::edit_pb
Gtk::TreeModelColumn< Glib::RefPtr< Gdk::Pixbuf > > edit_pb
Definition gx_preset_window.h:34
PresetStore::col
PresetStore::PresetModelColumns col
PresetStore::PresetStore
PresetStore()
PresetStore::row_draggable_vfunc
virtual bool row_draggable_vfunc(const TreeModel::Path &path) const
PresetWindow::accelgroup
Glib::RefPtr< Gtk::AccelGroup > accelgroup
Definition gx_preset_window.h:85
PresetWindow::set_cell_text
void set_cell_text(Gtk::Widget *widget, Gtk::CellRenderer *cell, const Glib::ustring &text, bool selected)
PresetWindow::set_row_for_presetfile
void set_row_for_presetfile(Gtk::TreeIter i, gx_system::PresetFileGui *f)
PresetWindow::on_bank_edited
void on_bank_edited(const Glib::ustring &path, const Glib::ustring &newtext, Gtk::TreeView *w)
PresetWindow::pb_del
Glib::RefPtr< Gdk::Pixbuf > pb_del
Definition gx_preset_window.h:90
PresetWindow::presets_target_treeview
MyTreeView * presets_target_treeview
Definition gx_preset_window.h:116
PresetWindow::edit_iter
Gtk::TreeModel::iterator edit_iter
Definition gx_preset_window.h:88
PresetWindow::on_new_bank
void on_new_bank()
PresetWindow::PresetWindow
PresetWindow(Glib::RefPtr< gx_gui::GxBuilder > bld, gx_engine::GxMachineBase &machine, const gx_system::CmdlineOptions &options, GxActions &actions, UIManager &uimanager)
PresetWindow::options
const gx_system::CmdlineOptions & options
Definition gx_preset_window.h:101
PresetWindow::display_paned
void display_paned(bool show_preset, int paned_child_height)
PresetWindow::target_drag_data_received
void target_drag_data_received(const Glib::RefPtr< Gdk::DragContext > &context, int x, int y, const Gtk::SelectionData &data, guint info, guint timestamp)
PresetWindow::in_edit
bool in_edit
Definition gx_preset_window.h:87
PresetWindow::create_preset_menu
void create_preset_menu()
PresetWindow::on_bank_drag_data_received
void on_bank_drag_data_received(const Glib::RefPtr< Gdk::DragContext > &context, int x, int y, const Gtk::SelectionData &data, guint info, guint timestamp)
PresetWindow::show_online_preset
void show_online_preset()
PresetWindow::load_in_progress
bool load_in_progress
Definition gx_preset_window.h:103
PresetWindow::load_widget_pointers
void load_widget_pointers(Glib::RefPtr< gx_gui::GxBuilder > bld)
PresetWindow::save_preset
Gtk::Button * save_preset
Definition gx_preset_window.h:107
PresetWindow::preset_title
Gtk::Label * preset_title
Definition gx_preset_window.h:117
PresetWindow::read_preset_menu
void read_preset_menu()
PresetWindow::autosize
void autosize()
PresetWindow::vpaned_pos
int vpaned_pos
Definition gx_preset_window.h:98
PresetWindow::on_map_conn
sigc::connection on_map_conn
Definition gx_preset_window.h:104
PresetWindow::on_target_drag_motion
bool on_target_drag_motion(const Glib::RefPtr< Gdk::DragContext > &context, int x, int y, guint timestamp)
PresetWindow::preset_column_spacer
Gtk::TreeViewColumn * preset_column_spacer
Definition gx_preset_window.h:127
PresetWindow::on_preset_row_activated
void on_preset_row_activated(const Gtk::TreePath &path, Gtk::TreeViewColumn *column)
PresetWindow::get_current_bank
Glib::ustring get_current_bank()
PresetWindow::machine
gx_engine::GxMachineBase & machine
Definition gx_preset_window.h:83
PresetWindow::on_edit_canceled
void on_edit_canceled(Gtk::TreeViewColumn *col)
PresetWindow::reset_edit
void reset_edit(Gtk::TreeViewColumn &col)
PresetWindow::bank_column_spacer
Gtk::TreeViewColumn * bank_column_spacer
Definition gx_preset_window.h:123
PresetWindow::vpaned_step
int vpaned_step
Definition gx_preset_window.h:99
PresetWindow::pstore
Glib::RefPtr< PresetStore > pstore
Definition gx_preset_window.h:95
PresetWindow::resolve_hostname
Glib::ustring resolve_hostname()
PresetWindow::preset_column_delete
Gtk::TreeViewColumn * preset_column_delete
Definition gx_preset_window.h:126
PresetWindow::run_message_dialog
bool run_message_dialog(Gtk::Widget &w, const Glib::ustring &msg)
PresetWindow::reload_combo
void reload_combo()
PresetWindow::presets_target_scrolledbox
Gtk::ScrolledWindow * presets_target_scrolledbox
Definition gx_preset_window.h:118
PresetWindow::on_organize
void on_organize()
PresetWindow::highlight_current_bank
void highlight_current_bank(Gtk::CellRenderer *cell, const Gtk::TreeModel::iterator &iter)
PresetWindow::get_combo_selection
Glib::ustring get_combo_selection()
PresetWindow::select_func
bool select_func(const Glib::RefPtr< Gtk::TreeModel > &model, const Gtk::TreePath &path, bool path_currently_selected)
PresetWindow::is_row_separator
bool is_row_separator(const Glib::RefPtr< Gtk::TreeModel > &model, const Gtk::TreeModel::iterator &iter)
PresetWindow::text_func
void text_func(Gtk::CellRenderer *cell, const Gtk::TreeModel::iterator &iter)
PresetWindow::popup_pos
void popup_pos(int &x, int &y, bool &push_in)
PresetWindow::curl
CURL * curl
Definition gx_preset_window.h:86
PresetWindow::on_bank_drag_motion
bool on_bank_drag_motion(const Glib::RefPtr< Gdk::DragContext > &context, int x, int y, guint timestamp)
PresetWindow::on_bank_query_tooltip
bool on_bank_query_tooltip(int x, int y, bool kb_tooltip, Glib::RefPtr< Gtk::Tooltip > tooltip)
PresetWindow::bank_drag_moveable
bool bank_drag_moveable(Gtk::TreePath pt)
PresetWindow::actions
GxActions & actions
Definition gx_preset_window.h:84
PresetWindow::preset_scrolledbox
Gtk::ScrolledWindow * preset_scrolledbox
Definition gx_preset_window.h:129
PresetWindow::bank_cellrenderer
Gtk::CellRendererText * bank_cellrenderer
Definition gx_preset_window.h:112
PresetWindow::preset_column_preset
Gtk::TreeViewColumn * preset_column_preset
Definition gx_preset_window.h:124
PresetWindow::on_presetlist_changed
void on_presetlist_changed()
PresetWindow::start_edit
void start_edit(const Gtk::TreeModel::Path &pt, Gtk::TreeViewColumn &col, Gtk::CellRenderer &cell)
PresetWindow::bank_col
BankModelColumns bank_col
Definition gx_preset_window.h:97
PresetWindow::new_preset_bank
Gtk::Button * new_preset_bank
Definition gx_preset_window.h:108
PresetWindow::on_bank_reordered
void on_bank_reordered(const Gtk::TreeModel::Path &path)
PresetWindow::olp
std::vector< std::tuple< std::string, std::string, std::string > > olp
Definition gx_preset_window.h:162
PresetWindow::online_preset
Gtk::Button * online_preset
Definition gx_preset_window.h:110
PresetWindow::bank_column_flags
Gtk::TreeViewColumn * bank_column_flags
Definition gx_preset_window.h:119
PresetWindow::animate_preset_show
bool animate_preset_show()
PresetWindow::on_preset_reordered
void on_preset_reordered(const Gtk::TreeModel::Path &path)
PresetWindow::organize_presets
Gtk::ToggleButton * organize_presets
Definition gx_preset_window.h:109
PresetWindow::download_file
bool download_file(Glib::ustring from_uri, Glib::ustring to_path)
PresetWindow::on_bank_drag_data_get
void on_bank_drag_data_get(const Glib::RefPtr< Gdk::DragContext > &context, Gtk::SelectionData &selection, int info, int timestamp)
PresetWindow::downloadPreset
void downloadPreset(Gtk::Menu *presetMenu, std::string uri)
PresetWindow::TEXT_TARGETS
@ TEXT_TARGETS
Definition gx_preset_window.h:79
PresetWindow::MODELROW_TARGET
@ MODELROW_TARGET
Definition gx_preset_window.h:80
PresetWindow::URILIST_TARGET
@ URILIST_TARGET
Definition gx_preset_window.h:81
PresetWindow::on_preset_save
void on_preset_save()
PresetWindow::bank_column_edit
Gtk::TreeViewColumn * bank_column_edit
Definition gx_preset_window.h:121
PresetWindow::on_preset_drag_motion
bool on_preset_drag_motion(const Glib::RefPtr< Gdk::DragContext > &context, int x, int y, guint timestamp)
PresetWindow::~PresetWindow
~PresetWindow()
PresetWindow::on_online_preset
void on_online_preset()
PresetWindow::bank_column_delete
Gtk::TreeViewColumn * bank_column_delete
Definition gx_preset_window.h:122
PresetWindow::preset_column_edit
Gtk::TreeViewColumn * preset_column_edit
Definition gx_preset_window.h:125
PresetWindow::pb_versiondiff
Glib::RefPtr< Gdk::Pixbuf > pb_versiondiff
Definition gx_preset_window.h:92
PresetWindow::on_preset_combo_changed
void on_preset_combo_changed()
PresetWindow::pb_scratch
Glib::RefPtr< Gdk::Pixbuf > pb_scratch
Definition gx_preset_window.h:91
PresetWindow::in_current_preset
bool in_current_preset
Definition gx_preset_window.h:102
PresetWindow::on_preset_button_release
bool on_preset_button_release(GdkEventButton *ev)
PresetWindow::target_col
TargetModelColumns target_col
Definition gx_preset_window.h:96
PresetWindow::get_current_bank_iter
Gtk::TreeIter get_current_bank_iter()
Definition gx_preset_window.h:145
PresetWindow::animate_preset_hide
bool animate_preset_hide()
PresetWindow::on_bank_changed
void on_bank_changed()
PresetWindow::on_preset_drag_data_get
void on_preset_drag_data_get(const Glib::RefPtr< Gdk::DragContext > &context, Gtk::SelectionData &selection, int info, int timestamp)
PresetWindow::preset_cellrenderer
Gtk::CellRendererText * preset_cellrenderer
Definition gx_preset_window.h:114
PresetWindow::on_bank_button_release
bool on_bank_button_release(GdkEventButton *ev)
PresetWindow::bank_find_drop_position
bool bank_find_drop_position(int x, int y, Gtk::TreeModel::Path &pt, Gtk::TreeViewDropPosition &dst)
PresetWindow::bank_column_bank
Gtk::TreeViewColumn * bank_column_bank
Definition gx_preset_window.h:120
PresetWindow::pb_factory
Glib::RefPtr< Gdk::Pixbuf > pb_factory
Definition gx_preset_window.h:94
PresetWindow::pb_edit
Glib::RefPtr< Gdk::Pixbuf > pb_edit
Definition gx_preset_window.h:89
PresetWindow::pb_readonly
Glib::RefPtr< Gdk::Pixbuf > pb_readonly
Definition gx_preset_window.h:93
PresetWindow::bank_treeview
MyTreeView * bank_treeview
Definition gx_preset_window.h:111
PresetWindow::main_vpaned
Gtk::Paned * main_vpaned
Definition gx_preset_window.h:128
PresetWindow::preset_treeview
MyTreeView * preset_treeview
Definition gx_preset_window.h:113
PresetWindow::on_editing_started
void on_editing_started(const Gtk::CellEditable *edit, const Glib::ustring &path, Glib::RefPtr< Gtk::TreeModel > &model)
PresetWindow::vpaned_target
int vpaned_target
Definition gx_preset_window.h:100
PresetWindow::on_preset_select
void on_preset_select(bool v, bool animated, int preset_window_height)
PresetWindow::on_selection_changed
void on_selection_changed()
PresetWindow::on_preset_changed
void on_preset_changed()
PresetWindow::banks_combobox
Gtk::ComboBox * banks_combobox
Definition gx_preset_window.h:115
PresetWindow::pdir
const std::string pdir()
Definition gx_preset_window.h:153
PresetWindow::on_preset_edited
void on_preset_edited(const Glib::ustring &path, const Glib::ustring &newtext)
TargetModelColumns
Definition gx_preset_window.h:44
TargetModelColumns::TargetModelColumns
TargetModelColumns()
Definition gx_preset_window.h:47
TargetModelColumns::name
Gtk::TreeModelColumn< Glib::ustring > name
Definition gx_preset_window.h:46
UIManager
Definition gx_main_window.h:109
gx_engine::GxMachineBase
Definition machine.h:59
gx_system::CmdlineOptions
Definition gx_system.h:395
gx_system::PresetFileGui
Definition gx_json.h:373