Guitarix
gx_preset_window.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2009, 2010 Hermann Meyer, James Warden, Andreas Degert
3 * Copyright (C) 2011 Pete Shorthose
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 * ---------------------------------------------------------------------------
19 *
20 *
21 * ----------------------------------------------------------------------------
22 */
23
24/****************************************************************
25 ** class PresetWindow
26 */
27
28
29class PresetStore: public Gtk::ListStore {
30public:
31 class PresetModelColumns : public Gtk::TreeModel::ColumnRecord {
32 public:
33 Gtk::TreeModelColumn<Glib::ustring> name;
34 Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > edit_pb;
35 Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > del_pb;
36
37 PresetModelColumns() { add(name); add(edit_pb); add(del_pb); }
38 } col;
39public:
41 virtual bool row_draggable_vfunc(const TreeModel::Path& path) const;
42};
43
44class TargetModelColumns : public Gtk::TreeModel::ColumnRecord {
45public:
46 Gtk::TreeModelColumn<Glib::ustring> name;
48};
49
50class BankModelColumns : public Gtk::TreeModel::ColumnRecord {
51public:
52 Gtk::TreeModelColumn<Glib::ustring> name;
53 Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > type_pb;
54 Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > edit_pb;
55 Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > del_pb;
56 Gtk::TreeModelColumn<int> tp;
57 BankModelColumns() { add(name); add(type_pb); add(edit_pb); add(del_pb); add(tp); }
58};
59
60class MyTreeView: public Gtk::TreeView {
61private:
62 MyTreeView(BaseObjectType* cobject): Gtk::TreeView(cobject) {}
63 sigc::signal<void()> m_signal_row_clicked;
64 virtual bool on_button_press_event(GdkEventButton* button_event);
65public:
66 static MyTreeView *create_from_builder(BaseObjectType* cobject) { return new MyTreeView(cobject); }
67 //virtual bool on_drag_motion(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, guint timestamp);
68 using Gtk::TreeView::on_drag_motion;
70 sigc::signal<void()>& signal_row_clicked() { return m_signal_row_clicked; }
71};
72
73class GxActions;
74class UIManager;
75
76class PresetWindow: public sigc::trackable {
77private:
78 enum {
82 };
85 Glib::RefPtr<Gtk::AccelGroup> accelgroup;
86 CURL *curl;
87 bool in_edit;
88 Gtk::TreeModel::iterator edit_iter;
89 Glib::RefPtr<Gdk::Pixbuf> pb_edit;
90 Glib::RefPtr<Gdk::Pixbuf> pb_del;
91 Glib::RefPtr<Gdk::Pixbuf> pb_scratch;
92 Glib::RefPtr<Gdk::Pixbuf> pb_versiondiff;
93 Glib::RefPtr<Gdk::Pixbuf> pb_readonly;
94 Glib::RefPtr<Gdk::Pixbuf> pb_factory;
95 Glib::RefPtr<PresetStore> pstore;
104 sigc::connection on_map_conn;
105
106 // widget pointers (keep last)
107 Gtk::Button *save_preset;
108 Gtk::Button *new_preset_bank;
109 Gtk::ToggleButton *organize_presets;
110 Gtk::Button *online_preset;
112 Gtk::CellRendererText *bank_cellrenderer;
114 Gtk::CellRendererText *preset_cellrenderer;
115 Gtk::ComboBox *banks_combobox;
117 Gtk::Label *preset_title;
118 Gtk::ScrolledWindow *presets_target_scrolledbox;
119 Gtk::TreeViewColumn* bank_column_flags;
120 Gtk::TreeViewColumn* bank_column_bank;
121 Gtk::TreeViewColumn* bank_column_edit;
122 Gtk::TreeViewColumn* bank_column_delete;
123 Gtk::TreeViewColumn* bank_column_spacer;
124 Gtk::TreeViewColumn* preset_column_preset;
125 Gtk::TreeViewColumn* preset_column_edit;
126 Gtk::TreeViewColumn* preset_column_delete;
127 Gtk::TreeViewColumn* preset_column_spacer;
128 Gtk::Paned *main_vpaned;
129 Gtk::ScrolledWindow *preset_scrolledbox;
130private:
131 void load_widget_pointers(Glib::RefPtr<gx_gui::GxBuilder> bld);
132 void target_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& data, guint info, guint timestamp);
133 bool on_target_drag_motion(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, guint timestamp);
134 Glib::ustring get_combo_selection();
137 bool select_func(const Glib::RefPtr<Gtk::TreeModel>& model, const Gtk::TreePath& path, bool path_currently_selected);
138 void set_cell_text(Gtk::Widget *widget, Gtk::CellRenderer *cell, const Glib::ustring& text, bool selected);
139 void highlight_current_bank(Gtk::CellRenderer *cell, const Gtk::TreeModel::iterator& iter);
140 void text_func(Gtk::CellRenderer *cell, const Gtk::TreeModel::iterator& iter);
141 void on_editing_started(const Gtk::CellEditable* edit, const Glib::ustring& path, Glib::RefPtr<Gtk::TreeModel>& model);
142 void reset_edit(Gtk::TreeViewColumn& col);
143 void on_edit_canceled(Gtk::TreeViewColumn *col);
144 void start_edit(const Gtk::TreeModel::Path& pt, Gtk::TreeViewColumn& col, Gtk::CellRenderer& cell);
145 Gtk::TreeIter get_current_bank_iter() { return bank_treeview->get_selection()->get_selected(); }
146 Glib::ustring get_current_bank();
147 bool run_message_dialog(Gtk::Widget& w, const Glib::ustring& msg);
148 bool on_bank_button_release(GdkEventButton *ev);
149 void on_bank_edited(const Glib::ustring& path, const Glib::ustring& newtext, Gtk::TreeView* w);
150 bool is_row_separator(const Glib::RefPtr<Gtk::TreeModel>& model, const Gtk::TreeModel::iterator& iter);
153 const std::string pdir() { return options.get_preset_dir();}
156 void popup_pos( int& x, int& y, bool& push_in );
157 void downloadPreset(Gtk::Menu *presetMenu,std::string uri);
158 bool download_file(Glib::ustring from_uri, Glib::ustring to_path);
159 Glib::ustring resolve_hostname();
162 std::vector< std::tuple<std::string,std::string,std::string> > olp;
163 bool on_bank_drag_motion(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, guint timestamp);
164 bool bank_drag_moveable(Gtk::TreePath pt);
165 bool bank_find_drop_position(int x, int y, Gtk::TreeModel::Path& pt, Gtk::TreeViewDropPosition& dst);
166 void on_bank_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& data, guint info, guint timestamp);
167 void on_bank_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& context, Gtk::SelectionData& selection, int info, int timestamp);
169 bool on_bank_query_tooltip(int x, int y, bool kb_tooltip, Glib::RefPtr<Gtk::Tooltip> tooltip);
170 void on_bank_reordered(const Gtk::TreeModel::Path& path);
171 bool on_preset_button_release(GdkEventButton *ev);
172 void on_preset_row_activated(const Gtk::TreePath& path, Gtk::TreeViewColumn* column);
173 void on_preset_edited(const Glib::ustring& path, const Glib::ustring& newtext);
175 bool on_preset_drag_motion(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, guint timestamp);
176 void on_preset_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& context, Gtk::SelectionData& selection, int info, int timestamp);
177 void on_preset_reordered(const Gtk::TreeModel::Path& path);
178 void autosize();
183 void display_paned(bool show_preset, int paned_child_height);
186public:
187 PresetWindow(Glib::RefPtr<gx_gui::GxBuilder> bld, gx_engine::GxMachineBase& machine,
190 void on_preset_select(bool v, bool animated, int preset_window_height);
191};
Gtk::TreeModelColumn< Glib::RefPtr< Gdk::Pixbuf > > del_pb
Gtk::TreeModelColumn< int > tp
Gtk::TreeModelColumn< Glib::ustring > name
Gtk::TreeModelColumn< Glib::RefPtr< Gdk::Pixbuf > > edit_pb
Gtk::TreeModelColumn< Glib::RefPtr< Gdk::Pixbuf > > type_pb
static MyTreeView * create_from_builder(BaseObjectType *cobject)
virtual bool on_button_press_event(GdkEventButton *button_event)
sigc::signal< void()> & signal_row_clicked()
like Gtk::TreeSelection::signal_changed, but is also emitted when the selection didn't change
sigc::signal< void()> m_signal_row_clicked
MyTreeView(BaseObjectType *cobject)
Gtk::TreeModelColumn< Glib::ustring > name
Gtk::TreeModelColumn< Glib::RefPtr< Gdk::Pixbuf > > del_pb
Gtk::TreeModelColumn< Glib::RefPtr< Gdk::Pixbuf > > edit_pb
PresetStore::PresetModelColumns col
virtual bool row_draggable_vfunc(const TreeModel::Path &path) const
Glib::RefPtr< Gtk::AccelGroup > accelgroup
void set_cell_text(Gtk::Widget *widget, Gtk::CellRenderer *cell, const Glib::ustring &text, bool selected)
void set_row_for_presetfile(Gtk::TreeIter i, gx_system::PresetFileGui *f)
void on_bank_edited(const Glib::ustring &path, const Glib::ustring &newtext, Gtk::TreeView *w)
Glib::RefPtr< Gdk::Pixbuf > pb_del
MyTreeView * presets_target_treeview
Gtk::TreeModel::iterator edit_iter
void on_new_bank()
PresetWindow(Glib::RefPtr< gx_gui::GxBuilder > bld, gx_engine::GxMachineBase &machine, const gx_system::CmdlineOptions &options, GxActions &actions, UIManager &uimanager)
const gx_system::CmdlineOptions & options
void display_paned(bool show_preset, int paned_child_height)
void target_drag_data_received(const Glib::RefPtr< Gdk::DragContext > &context, int x, int y, const Gtk::SelectionData &data, guint info, guint timestamp)
void create_preset_menu()
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 show_online_preset()
void load_widget_pointers(Glib::RefPtr< gx_gui::GxBuilder > bld)
Gtk::Button * save_preset
Gtk::Label * preset_title
void read_preset_menu()
void autosize()
sigc::connection on_map_conn
bool on_target_drag_motion(const Glib::RefPtr< Gdk::DragContext > &context, int x, int y, guint timestamp)
Gtk::TreeViewColumn * preset_column_spacer
void on_preset_row_activated(const Gtk::TreePath &path, Gtk::TreeViewColumn *column)
Glib::ustring get_current_bank()
gx_engine::GxMachineBase & machine
void on_edit_canceled(Gtk::TreeViewColumn *col)
void reset_edit(Gtk::TreeViewColumn &col)
Gtk::TreeViewColumn * bank_column_spacer
Glib::RefPtr< PresetStore > pstore
Glib::ustring resolve_hostname()
Gtk::TreeViewColumn * preset_column_delete
bool run_message_dialog(Gtk::Widget &w, const Glib::ustring &msg)
void reload_combo()
Gtk::ScrolledWindow * presets_target_scrolledbox
void on_organize()
void highlight_current_bank(Gtk::CellRenderer *cell, const Gtk::TreeModel::iterator &iter)
Glib::ustring get_combo_selection()
bool select_func(const Glib::RefPtr< Gtk::TreeModel > &model, const Gtk::TreePath &path, bool path_currently_selected)
bool is_row_separator(const Glib::RefPtr< Gtk::TreeModel > &model, const Gtk::TreeModel::iterator &iter)
void text_func(Gtk::CellRenderer *cell, const Gtk::TreeModel::iterator &iter)
void popup_pos(int &x, int &y, bool &push_in)
bool on_bank_drag_motion(const Glib::RefPtr< Gdk::DragContext > &context, int x, int y, guint timestamp)
bool on_bank_query_tooltip(int x, int y, bool kb_tooltip, Glib::RefPtr< Gtk::Tooltip > tooltip)
bool bank_drag_moveable(Gtk::TreePath pt)
GxActions & actions
Gtk::ScrolledWindow * preset_scrolledbox
Gtk::CellRendererText * bank_cellrenderer
Gtk::TreeViewColumn * preset_column_preset
void on_presetlist_changed()
void start_edit(const Gtk::TreeModel::Path &pt, Gtk::TreeViewColumn &col, Gtk::CellRenderer &cell)
BankModelColumns bank_col
Gtk::Button * new_preset_bank
void on_bank_reordered(const Gtk::TreeModel::Path &path)
std::vector< std::tuple< std::string, std::string, std::string > > olp
Gtk::Button * online_preset
Gtk::TreeViewColumn * bank_column_flags
bool animate_preset_show()
void on_preset_reordered(const Gtk::TreeModel::Path &path)
Gtk::ToggleButton * organize_presets
bool download_file(Glib::ustring from_uri, Glib::ustring to_path)
void on_bank_drag_data_get(const Glib::RefPtr< Gdk::DragContext > &context, Gtk::SelectionData &selection, int info, int timestamp)
void downloadPreset(Gtk::Menu *presetMenu, std::string uri)
void on_preset_save()
Gtk::TreeViewColumn * bank_column_edit
bool on_preset_drag_motion(const Glib::RefPtr< Gdk::DragContext > &context, int x, int y, guint timestamp)
void on_online_preset()
Gtk::TreeViewColumn * bank_column_delete
Gtk::TreeViewColumn * preset_column_edit
Glib::RefPtr< Gdk::Pixbuf > pb_versiondiff
void on_preset_combo_changed()
Glib::RefPtr< Gdk::Pixbuf > pb_scratch
bool on_preset_button_release(GdkEventButton *ev)
TargetModelColumns target_col
Gtk::TreeIter get_current_bank_iter()
bool animate_preset_hide()
void on_bank_changed()
void on_preset_drag_data_get(const Glib::RefPtr< Gdk::DragContext > &context, Gtk::SelectionData &selection, int info, int timestamp)
Gtk::CellRendererText * preset_cellrenderer
bool on_bank_button_release(GdkEventButton *ev)
bool bank_find_drop_position(int x, int y, Gtk::TreeModel::Path &pt, Gtk::TreeViewDropPosition &dst)
Gtk::TreeViewColumn * bank_column_bank
Glib::RefPtr< Gdk::Pixbuf > pb_factory
Glib::RefPtr< Gdk::Pixbuf > pb_edit
Glib::RefPtr< Gdk::Pixbuf > pb_readonly
MyTreeView * bank_treeview
Gtk::Paned * main_vpaned
MyTreeView * preset_treeview
void on_editing_started(const Gtk::CellEditable *edit, const Glib::ustring &path, Glib::RefPtr< Gtk::TreeModel > &model)
void on_preset_select(bool v, bool animated, int preset_window_height)
void on_selection_changed()
void on_preset_changed()
Gtk::ComboBox * banks_combobox
const std::string pdir()
void on_preset_edited(const Glib::ustring &path, const Glib::ustring &newtext)
Gtk::TreeModelColumn< Glib::ustring > name
const std::string & get_preset_dir() const
Definition: gx_system.h:488