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 #ifdef HAVE_WEBKIT
29 #include <webkit/webkit.h>
30 #endif
31 
32 class PresetStore: public Gtk::ListStore {
33 public:
34  class PresetModelColumns : public Gtk::TreeModel::ColumnRecord {
35  public:
36  Gtk::TreeModelColumn<Glib::ustring> name;
37  Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > edit_pb;
38  Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > del_pb;
39 
40  PresetModelColumns() { add(name); add(edit_pb); add(del_pb); }
41  } col;
42 public:
43  PresetStore();
44  virtual bool row_draggable_vfunc(const TreeModel::Path& path) const;
45 };
46 
47 class TargetModelColumns : public Gtk::TreeModel::ColumnRecord {
48 public:
49  Gtk::TreeModelColumn<Glib::ustring> name;
50  TargetModelColumns() { add(name); }
51 };
52 
53 class BankModelColumns : public Gtk::TreeModel::ColumnRecord {
54 public:
55  Gtk::TreeModelColumn<Glib::ustring> name;
56  Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > type_pb;
57  Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > edit_pb;
58  Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > del_pb;
59  Gtk::TreeModelColumn<int> tp;
60  BankModelColumns() { add(name); add(type_pb); add(edit_pb); add(del_pb); add(tp); }
61 };
62 
63 class MyTreeView: public Gtk::TreeView {
64 private:
65  MyTreeView(BaseObjectType* cobject): Gtk::TreeView(cobject) {}
66 public:
67  static MyTreeView *create_from_builder(BaseObjectType* cobject) { return new MyTreeView(cobject); }
68  //virtual bool on_drag_motion(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, guint timestamp);
69  using Gtk::TreeView::on_drag_motion;
70 };
71 
72 struct GxActions;
73 
74 class PresetWindow: public sigc::trackable {
75 private:
76  enum {
77  TEXT_TARGETS = 0,
78  MODELROW_TARGET = 1,
79  URILIST_TARGET = 2,
80  };
81  gx_engine::GxMachineBase& machine;
82  GxActions& actions;
83  bool in_edit;
84  Gtk::TreeModel::iterator edit_iter;
85  Glib::RefPtr<Gdk::Pixbuf> pb_edit;
86  Glib::RefPtr<Gdk::Pixbuf> pb_del;
87  Glib::RefPtr<Gdk::Pixbuf> pb_scratch;
88  Glib::RefPtr<Gdk::Pixbuf> pb_versiondiff;
89  Glib::RefPtr<Gdk::Pixbuf> pb_readonly;
90  Glib::RefPtr<Gdk::Pixbuf> pb_factory;
91  Glib::RefPtr<PresetStore> pstore;
92  TargetModelColumns target_col;
93  BankModelColumns bank_col;
94  sigc::connection bank_row_del_conn;
95  sigc::connection preset_row_del_conn;
96  int vpaned_pos;
97  int vpaned_step;
98  int vpaned_target;
99  const gx_system::CmdlineOptions& options;
100  bool in_current_preset;
101  sigc::connection on_map_conn;
102 
103  // widget pointers (keep last)
104  Gtk::Button *close_preset;
105  Gtk::Button *save_preset;
106  Gtk::Button *new_preset_bank;
107  Gtk::ToggleButton *organize_presets;
108  Gtk::Button *online_preset;
109  MyTreeView *bank_treeview;
110  Gtk::CellRendererText *bank_cellrenderer;
111  MyTreeView *preset_treeview;
112  Gtk::CellRendererText *preset_cellrenderer;
113  Gtk::ComboBox *banks_combobox;
114  MyTreeView *presets_target_treeview;
115  Gtk::Label *preset_title;
116  Gtk::ScrolledWindow *presets_target_scrolledbox;
117  Gtk::TreeViewColumn *bank_column_edit;
118  Gtk::TreeViewColumn *bank_column_delete;
119  Gtk::TreeViewColumn *preset_column_edit;
120  Gtk::TreeViewColumn *preset_column_delete;
121  Gtk::VPaned *main_vpaned;
122  Gtk::ScrolledWindow *preset_scrolledbox;
123  GtkSizeGroup *left_column;
124 private:
125  void load_widget_pointers(Glib::RefPtr<gx_gui::GxBuilder> bld);
126  void target_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& data, guint info, guint timestamp);
127  bool on_target_drag_motion(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, guint timestamp);
128  Glib::ustring get_combo_selection();
129  void reload_combo();
130  void on_preset_combo_changed();
131  void reload_target();
132  bool select_func(const Glib::RefPtr<Gtk::TreeModel>& model, const Gtk::TreePath& path, bool path_currently_selected);
133  void highlight_current_bank(Gtk::CellRenderer *cell, const Gtk::TreeModel::iterator& iter);
134  void text_func(Gtk::CellRenderer *cell, const Gtk::TreeModel::iterator& iter);
135  void on_editing_started(const Gtk::CellEditable* edit, const Glib::ustring& path, Glib::RefPtr<Gtk::TreeModel>& model);
136  bool edit_cell(Gtk::TreeModel::Path pt, Gtk::TreeViewColumn& col, Gtk::CellRenderer& cell);
137  void reset_edit(Gtk::TreeViewColumn& col);
138  void on_edit_canceled(Gtk::TreeViewColumn *col);
139  void start_edit(const Gtk::TreeModel::Path& pt, Gtk::TreeViewColumn& col, Gtk::CellRenderer& cell);
140  Gtk::TreeIter get_current_bank_iter() { return bank_treeview->get_selection()->get_selected(); }
141  Glib::ustring get_current_bank();
142  bool run_message_dialog(Gtk::Widget& w, const Glib::ustring& msg);
143  bool on_bank_button_release(GdkEventButton *ev);
144  void on_bank_edited(const Glib::ustring& path, const Glib::ustring& newtext, Gtk::TreeView* w);
145  bool is_row_separator(const Glib::RefPtr<Gtk::TreeModel>& model, const Gtk::TreeModel::iterator& iter);
146  void on_new_bank();
147  void on_preset_save();
148  const std::string pdir() { return options.get_preset_dir();}
149 #ifdef HAVE_WEBKIT
150  void on_online_preset();
151  void show_online_preset();
152  static bool downloadRequested(WebKitWebView* webView, WebKitDownload *download,gpointer data );
153  static bool uploadRequested(WebKitWebView* webView, WebKitFileChooserRequest *request,gpointer data );
154  static bool insertRequested(const char* uri, gpointer data );
155  static void download_status(GObject* object, GParamSpec* pspec, gpointer data);
156 #endif
157  bool on_bank_drag_motion(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, guint timestamp);
158  void on_bank_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& data, guint info, guint timestamp);
159  void on_bank_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& context, Gtk::SelectionData& selection, int info, int timestamp);
160  void on_bank_changed();
161  bool on_bank_query_tooltip(int x, int y, bool kb_tooltip, Glib::RefPtr<Gtk::Tooltip> tooltip);
162  void reload_banks(const Glib::ustring& sel_bank);
163  void set_presets();
164  void on_bank_reordered(const Gtk::TreeModel::Path& path);
165  bool on_preset_button_release(GdkEventButton *ev);
166  bool on_preset_button_press(GdkEventButton *ev);
167  void on_preset_row_activated(const Gtk::TreePath& path, Gtk::TreeViewColumn* column);
168  void on_preset_edited(const Glib::ustring& path, const Glib::ustring& newtext);
169  void on_cursor_changed();
170  void on_preset_changed();
171  bool on_preset_drag_motion(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, guint timestamp);
172  void on_preset_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& context, Gtk::SelectionData& selection, int info, int timestamp);
173  void on_preset_reordered(const Gtk::TreeModel::Path& path);
174  void autosize();
175  void on_organize();
176  void on_presets_close();
177  bool animate_preset_show();
178  bool animate_preset_hide();
179  void set_row_for_presetfile(Gtk::TreeIter i, gx_system::PresetFileGui *f);
180  void display_paned(bool show_preset, int paned_child_height);
181  void on_selection_changed();
182 public:
183  PresetWindow(Glib::RefPtr<gx_gui::GxBuilder> bld, gx_engine::GxMachineBase& machine,
184  const gx_system::CmdlineOptions& options, GxActions& actions, GtkSizeGroup *lc);
185  ~PresetWindow();
186  void on_preset_select(bool v, bool animated, int preset_window_height);
187 };
Gtk::TreeModelColumn< Glib::RefPtr< Gdk::Pixbuf > > type_pb
const std::string & get_preset_dir() const
Definition: gx_system.h:473
Gtk::TreeModelColumn< Glib::RefPtr< Gdk::Pixbuf > > edit_pb
static MyTreeView * create_from_builder(BaseObjectType *cobject)
Gtk::TreeModelColumn< Glib::RefPtr< Gdk::Pixbuf > > del_pb
Gtk::TreeModelColumn< Glib::RefPtr< Gdk::Pixbuf > > edit_pb
virtual bool row_draggable_vfunc(const TreeModel::Path &path) const
PresetStore::PresetModelColumns col
Gtk::TreeModelColumn< Glib::RefPtr< Gdk::Pixbuf > > del_pb
Gtk::TreeModelColumn< Glib::ustring > name
Gtk::TreeModelColumn< int > tp
Gtk::TreeModelColumn< Glib::ustring > name
Gtk::TreeModelColumn< Glib::ustring > name