Guitarix
gx_main_window.cpp
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  * This is the gx_head GUI main class
21  *
22  * ----------------------------------------------------------------------------
23  */
24 
25 #include <guitarix.h>
26 #include <gxw/GxLevelSlider.h>
27 #include <gtkmm/accelmap.h>
28 #include "jsonrpc.h"
29 
30 /****************************************************************
31  ** class TextLoggingBox
32  */
33 
34 // color depending on msg type
35 TextLoggingBox::tab_table TextLoggingBox::tagdefs[] = {
36  {"colinfo", "#cccccc"},
37  {"colwarn", "#77994f"},
38  {"colerr", "#ff8800"},
39 };
40 
42  : box(),
43  ok_button(Gtk::Stock::OK),
44  buttonbox(),
45  scrollbox(),
46  tbox(),
47  highest_unseen_msg_level(-1),
48  msg_level_changed() {
49 
50  set_default_size(640, 320);
51  set_decorated(true);
52  set_resizable(true);
53  set_gravity(Gdk::GRAVITY_SOUTH);
54  set_keep_below(false);
55  set_title(_("Logging Window"));
56  set_type_hint(Gdk::WINDOW_TYPE_HINT_UTILITY);
57  set_border_width(4);
58 
59  box.set_border_width(0);
60  scrollbox.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
61 
62  add(box);
63 
64  tbox.set_wrap_mode(Gtk::WRAP_WORD_CHAR);
65  tbox.set_border_width(0);
66  tbox.set_editable(false);
67  tbox.set_cursor_visible(false);
68  tbox.set_pixels_above_lines(0);
69  tbox.set_pixels_below_lines(2);
70  tbox.set_justification(Gtk::JUSTIFY_LEFT);
71  tbox.set_left_margin(5);
72  tbox.set_indent(0);
73 
74  Glib::RefPtr<Gtk::TextBuffer> buffer = tbox.get_buffer();
75  for (int i = 0; i < GxLogger::kMessageTypeCount; i++) {
76  tags[i] = buffer->create_tag(tagdefs[i].tagname);
77  tags[i]->property_foreground() = tagdefs[i].tag_color;
78  }
79 
80  box.add(scrollbox);
81  box.pack_end(buttonbox, Gtk::PACK_SHRINK);
82  buttonbox.set_layout(Gtk::BUTTONBOX_END);
83  buttonbox.add(ok_button);
84  buttonbox.set_border_width(4);
85  ok_button.set_can_default();
86  ok_button.grab_default();
87  ok_button.signal_clicked().connect(sigc::mem_fun(this, &TextLoggingBox::hide));
88  //signal_activate().connect(sigc::mem_fun(this, &TextLoggingBox::hide));
89  scrollbox.add(tbox);
90  tbox.set_size_request(-1, 50);
91  box.show_all();
93  sigc::mem_fun(*this, &TextLoggingBox::show_msg));
95 }
96 
98 }
99 
100 bool TextLoggingBox::on_key_press_event(GdkEventKey *event) {
101  if (event->keyval == GDK_KEY_Escape && (event->state & Gtk::AccelGroup::get_default_mod_mask()) == 0) {
102  hide();
103  return true;
104  }
105  return Gtk::Window::on_key_press_event(event);
106 }
107 
108 void TextLoggingBox::on_show() {
109  highest_unseen_msg_level = GxLogger::kMessageTypeCount;
110  Gtk::Window::on_show();
111 }
112 
113 void TextLoggingBox::on_hide() {
114  highest_unseen_msg_level = -1;
115  Gtk::Window::on_hide();
116 }
117 
119  highest_unseen_msg_level = GxLogger::kMessageTypeCount;
120  msg_level_changed();
121  highest_unseen_msg_level = -1;
122 }
123 
124 void TextLoggingBox::show_msg(string msgbuf, GxLogger::MsgType msgtype, bool plugged) {
125  assert(0 <= msgtype && msgtype < GxLogger::kMessageTypeCount);
126 
127  // retrieve gtk text buffer
128  Glib::RefPtr<Gtk::TextBuffer> buffer = tbox.get_buffer();
129 
130  // how many lines to keep
131  const int nlines = 50;
132 
133  // delete first line when window filled up
134  int linecount = buffer->get_line_count(); // empty buffer == 1 line
135  if (linecount >= nlines) {
136  Gtk::TextIter iter1 = buffer->get_iter_at_line(0);
137  Gtk::TextIter iter2 = buffer->get_iter_at_line(1);
138  buffer->erase(iter1, iter2);
139  }
140 
141  Gtk::TextIter iter = buffer->end();
142  if (buffer->get_char_count() > 0) {
143  iter = buffer->insert(iter, "\n");
144  }
145 
146  buffer->insert_with_tag(iter, msgbuf, tags[msgtype]);
147  scrollbox.get_vadjustment()->set_value(10000);
148  // scroll to end (big value, gets clamped to max)
149 
150  // modify expander bg color is closed
151  if (msgtype > highest_unseen_msg_level) {
152  highest_unseen_msg_level = msgtype;
153  msg_level_changed();
154  }
155 }
156 
157 #if false // unused
158 /****************************************************************
159  ** KeyFinder
160  ** finds next unused Key in a GtkAccelGroup
161  */
162 
163 class KeyFinder {
164 private:
165  typedef list<GtkAccelKey> accel_list;
166  unsigned int next_key;
167  accel_list l;
168  static gboolean add_keys_to_list(GtkAccelKey *key, GClosure *cl, gpointer data);
169 public:
170  KeyFinder(Glib::RefPtr<Gtk::AccelGroup> group);
171  ~KeyFinder();
172  int operator()();
173 };
174 
175 KeyFinder::KeyFinder(Glib::RefPtr<Gtk::AccelGroup> group) {
176  next_key = GDK_a;
177  gtk_accel_group_find(group->gobj(), add_keys_to_list, static_cast<gpointer>(&l));
178 }
179 
180 KeyFinder::~KeyFinder() {
181 }
182 
183 gboolean KeyFinder::add_keys_to_list(GtkAccelKey *key, GClosure *cl, gpointer data) {
184  accel_list* l = (accel_list*)data;
185  if (key->accel_mods == GDK_SHIFT_MASK) {
186  l->push_back(*key);
187  }
188  return false;
189 }
190 
191 int KeyFinder::operator()() {
192  while (next_key <= GDK_z) {
193  bool found = false;
194  for (accel_list::iterator i = l.begin(); i != l.end(); ++i) {
195  if (next_key == i->accel_key) {
196  found = true;
197  break;
198  }
199  }
200  if (!found) {
201  return next_key++;
202  }
203  next_key++;
204  }
205  return -1;
206 }
207 #endif
208 
209 /****************************************************************
210  ** GxUiRadioMenu
211  ** adds the values of an EnumParameter as Gtk::RadioMenuItem's
212  ** to a Gtk::MenuShell
213  */
214 
215 class TubeKeys {
216 private:
217  static unsigned int keysep[];
218  unsigned int ks;
219 public:
220  TubeKeys(): ks(0) {};
221  int operator()();
222 };
223 
224 unsigned int TubeKeys::keysep[] = {
225  GDK_a, GDK_b, GDK_c, GDK_d, GDK_e, 0,
226  GDK_f, 0,
227  GDK_g, GDK_h, GDK_i, GDK_j, 0,
228  GDK_k, GDK_l, GDK_m, GDK_n, 0,
229  GDK_o, GDK_p, GDK_q, GDK_r
230 };
231 
232 inline int TubeKeys::operator()() {
233  if (ks < sizeof(keysep)/sizeof(keysep[0])) {
234  return keysep[ks++];
235  }
236  return -1;
237 }
238 
239 GxUiRadioMenu::GxUiRadioMenu(gx_engine::GxMachineBase& machine_, const std::string& id_)
240  : machine(machine_),
241  id(id_) {
242  machine.signal_parameter_value<int>(id).connect(
243  sigc::mem_fun(this, &GxUiRadioMenu::set_value));
244 }
245 
246 void GxUiRadioMenu::setup(const Glib::ustring& prefix, const Glib::ustring& postfix,
247  Glib::RefPtr<Gtk::UIManager>& uimanager, Glib::RefPtr<Gtk::ActionGroup>& actiongroup) {
248  int i, c;
249  const value_pair *p;
250  TubeKeys next_key;
251  Glib::ustring s = prefix;
252  Gtk::RadioButtonGroup group;
253  gx_engine::IntParameter& param = machine.get_parameter(id).getInt();
254  for (p = param.getValueNames(), i = 0; p->value_id; p++, i++) {
255  c = next_key();
256  if (c == 0) {
257  s += "<separator/>";
258  c = next_key();
259  }
260  Glib::ustring actname = Glib::ustring::compose("Enum_%1.%2", param.id(), p->value_id);
261  s += Glib::ustring::compose("<menuitem action=\"%1\"/>", actname);
262  Glib::RefPtr<Gtk::RadioAction> act = Gtk::RadioAction::create(group, actname, param.value_label(*p));
263  act->property_value().set_value(static_cast<int>(param.getLowerAsFloat())+i);
264  if (c > 0) {
265  actiongroup->add(act, Gtk::AccelKey(Glib::ustring::compose("<shift>%1", (char)c)));
266  } else {
267  actiongroup->add(act);
268  }
269  if (i == 0) {
270  act->signal_changed().connect(
271  sigc::mem_fun(*this, &GxUiRadioMenu::on_changed));
272  action = act;
273  }
274  //fprintf(stderr, "%s \n", p->value_id);
275  }
276  s.append(postfix);
277  uimanager->add_ui_from_string(s);
278 }
279 
280 void GxUiRadioMenu::set_value(unsigned int v) {
281  action->set_current_value(v);
282 }
283 
284 void GxUiRadioMenu::on_changed(Glib::RefPtr<Gtk::RadioAction> act) {
285  machine.set_parameter_value(id, act->get_current_value());
286 }
287 
288 
289 /****************************************************************
290  ** class Freezer
291  */
292 
294  : window(0), tag(), need_thaw(false), size_x(-1), size_y(-1) {
295 }
296 
298  thaw();
299 }
300 
301 void Freezer::freeze(Gtk::Window *w, int width, int height) {
302  if (window) {
303  thaw();
304  }
305  size_x = width;
306  size_y = height;
307  window = w;
308  Glib::RefPtr<Gdk::Window> win = window->get_window();
309  if (win) {
310  need_thaw = true;
311  win->freeze_updates();
312  }
313 }
314 
315 void Freezer::set_slot(sigc::slot<void> w) {
316  if (size_x == -1) {
317  w();
318  } else {
319  work = w;
320  }
321 }
322 
323 void Freezer::freeze_until_width_update(Gtk::Window *w, int width) {
324  int wd, ht;
325  w->get_size(wd, ht);
326  if (wd == width) {
327  return;
328  }
329  freeze(w, width, -1);
330 }
331 
332 void Freezer::freeze_and_size_request(Gtk::Window *w, int width, int height) {
333  int wd, ht;
334  w->get_size(wd, ht);
335  if (wd >= width && ht == height) {
336  return;
337  }
338  freeze(w, width, height);
339  w->set_size_request(width, height);
340 }
341 
342 bool Freezer::thaw_timeout() {
343 #ifndef NDEBUG
344  gx_print_error("freezer", "timeout");
345 #else
346  gx_print_warning("freezer", "timeout");
347 #endif
348  if (size_y != -1) {
349  window->set_size_request(-1,-1);
350  }
351  do_thaw();
352  return false;
353 }
354 
355 void Freezer::do_thaw() {
356  size_x = size_y = -1;
357  Glib::RefPtr<Gdk::Window> win = window->get_window();
358  window = 0;
359  if (!win) {
360  return;
361  }
362  if (!work.empty()) {
363  Glib::signal_idle().connect_once(work);
364  work.disconnect();
365  }
366  if (need_thaw) {
367  win->thaw_updates();
368  }
369 }
370 
371 void Freezer::thaw() {
372  if (size_x != -1) {
373  tag.disconnect();
374  do_thaw();
375  }
376 }
377 
378 bool Freezer::check_thaw(int width, int height) {
379  if (size_x == -1) {
380  return true;
381  }
382  Glib::RefPtr<Gdk::Window> win = window->get_window();
383  if (win && win->get_state()) {
384  thaw();
385  return true;
386  }
387  if (size_y == -1) {
388  if (size_x == width) {
389  window->set_size_request(-1,-1);
390  thaw();
391  return true;
392  }
393  }
394  if (size_x <= width && size_y == height) {
395  window->set_size_request(-1,-1);
396  thaw();
397  return true;
398  }
399  if (!tag.connected()) {
400  tag = Glib::signal_timeout().connect(sigc::mem_fun(*this, &Freezer::thaw_timeout), 500);
401  }
402  return false;
403 }
404 
405 
406 /****************************************************************
407  ** class MainWindow
408  */
409 
410 template <class T>
412  gx_engine::GxMachineBase& machine_, const std::string& id_, const Glib::ustring& name, const Glib::ustring& icon_name,
413  const Glib::ustring& label, const Glib::ustring& tooltip,
414  bool is_active)
415  : Gtk::ToggleAction(name, icon_name, label, tooltip, is_active),
416  machine(machine_),
417  id(id_) {
418  set_active(machine.get_parameter_value<T>(id));
419  machine.signal_parameter_value<T>(id).connect(
420  sigc::mem_fun(this, &UiToggleAction::set_active));
421 }
422 
423 template <class T>
425 }
426 
427 template <class T>
429  machine.set_parameter_value(id, get_active());
430 }
431 
432 void update_scrolled_window(Gtk::ScrolledWindow& w) {
433  Gtk::PolicyType hp, vp;
434  w.get_policy(hp, vp);
435  w.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
436  w.set_policy(hp, vp);
437 }
438 
439 /*
440 ** moving / hiding / showing parts of the UI
441 */
442 
443 void MainWindow::maybe_shrink_horizontally(bool preset_no_rack) {
444  Glib::RefPtr<Gdk::Window> w = window->get_window();
445  if (!w) {
446  return;
447  }
448  int state = w->get_state();
449  if (state & (Gdk::WINDOW_STATE_MAXIMIZED | Gdk::WINDOW_STATE_FULLSCREEN)) {
450  return;
451  }
452  Gtk::Requisition req;
453  window->size_request(req);
454  int x, y;
455  window->get_position(x, y);
456  Gdk::Geometry geom;
457  geom.min_width = req.width;
458  geom.min_height = req.height;
459  w->set_geometry_hints(geom, Gdk::HINT_MIN_SIZE);
460  if (preset_no_rack) {
461  req.height += options.preset_window_height - preset_scrolledbox->size_request().height;
462  } else {
463  req.height = std::max(req.height, options.window_height);
464  }
465  w->move_resize(x, y, req.width, req.height);
466  if (!state) {
467  freezer.freeze_until_width_update(window, req.width);
468  }
469 }
470 
471 void MainWindow::on_show_tuner() {
472  bool v = actions.tuner->get_active();
473  on_livetuner_toggled();
474  tunerbox->set_visible(v);
475  update_scrolled_window(*vrack_scrolledbox);
476 }
477 
478 void MainWindow::load_widget_pointers() {
479  bld->get_toplevel("MainWindow", window);
480  bld->find_widget("tunerbox", tunerbox);
481  bld->find_widget("vrack_scrolledbox", vrack_scrolledbox);
482  bld->find_widget("stereorackcontainerH", stereorackcontainerH);
483  bld->find_widget("stereorackcontainerV", stereorackcontainerV);
484  bld->find_widget("rackcontainer", rackcontainer);
485  bld->find_widget("stereorackbox", stereorackbox);
486  bld->find_widget("monorackcontainer", monocontainer);
487  bld->find_widget("monoampcontainer:ampdetails", monoampcontainer);
488  bld->find_widget("main_vpaned", main_vpaned);
489  bld->find_widget("amp_toplevel_box", amp_toplevel_box);
490  bld->find_widget("monobox", monobox);
491  bld->find_widget("upper_rackbox", upper_rackbox);
492  bld->find_widget("preset_scrolledbox", preset_scrolledbox);
493  bld->find_widget("preset_box_no_rack", preset_box_no_rack);
494  bld->find_widget("effects_frame_paintbox", effects_frame_paintbox);
495  bld->find_widget("insert_image", insert_image);
496  bld->find_widget("status_image", status_image);
497  bld->find_widget("jackd_image", jackd_image);
498  bld->find_widget("logstate_image", logstate_image);
499  bld->find_widget("menubox", menubox);
500  bld->find_widget("show_rack:barbutton", show_rack_button);
501  bld->find_widget("rack_order_h:barbutton", rack_order_h_button);
502  bld->find_widget("config_mode:barbutton", config_mode_button);
503  bld->find_widget("liveplay:barbutton", liveplay_button);
504  bld->find_widget("tuner:barbutton", tuner_button);
505  bld->find_widget("effects:barbutton", effects_button);
506  bld->find_widget("presets:barbutton", presets_button);
507  bld->find_widget("compress:barbutton", compress_button);
508  bld->find_widget("expand:barbutton", expand_button);
509  bld->find_widget("effects_toolpalette", effects_toolpalette);
510  bld->find_widget("amp_background:ampbox", amp_background);
511  bld->find_widget("tuner_on_off", tuner_on_off);
512  bld->find_widget("tuner_mode", tuner_mode);
513  bld->find_widget("tuner_reference_pitch", tuner_reference_pitch);
514  bld->find_widget("tuner_tuning", tuner_tuning);
515  bld->find_widget("tuner_temperament", tuner_temperament);
516  bld->find_widget("racktuner", racktuner);
517  bld->find_widget("ampdetail_compress:effect_reset", ampdetail_compress);
518  bld->find_widget("ampdetail_expand:effect_reset", ampdetail_expand);
519  bld->find_widget("ampdetail_mini", ampdetail_mini);
520  bld->find_widget("ampdetail_normal", ampdetail_normal);
521  bld->find_widget("fastmeterL", fastmeter[0]);
522  bld->find_widget("fastmeterR", fastmeter[1]);
523  bld->find_widget("preset_status", preset_status);
524  bld->find_widget("midi_out_box", midi_out_box);
525  bld->find_widget("midi_out_normal", midi_out_normal);
526  bld->find_widget("midi_out_mini", midi_out_mini);
527  bld->find_widget("midi_out_compress:effect_reset", midi_out_compress);
528  bld->find_widget("midi_out_expand:effect_reset", midi_out_expand);
529  bld->find_widget("midi_out_presets_mini", midi_out_presets_mini);
530  bld->find_widget("midi_out_presets_normal", midi_out_presets_normal);
531  bld->find_widget("channel1_button", channel1_button);
532  bld->find_widget("channel1_box", channel1_box);
533  bld->find_widget("channel2_button", channel2_button);
534  bld->find_widget("channel2_box", channel2_box);
535  bld->find_widget("channel3_button", channel3_button);
536  bld->find_widget("channel3_box", channel3_box);
537 }
538 
539 void MainWindow::on_select_preset(int idx) {
540  keyswitch.process_preset_key(idx);
541 }
542 
543 void MainWindow::on_next_preset() {
544  if (machine.setting_is_preset()) {
546  Glib::ustring t;
547  int idx = 0;
548  t = machine.get_current_name();
549  for (gx_system::PresetFile::iterator i = pf->begin(); i != pf->end(); ++i, ++idx) {
550  if (t.compare(i->name)==0) {
551  ++idx;
552  if (i == pf->end()-1) idx =0;
553  break;
554  }
555  }
556  keyswitch.process_preset_key(idx);
557  }
558 }
559 
560 void MainWindow::on_previus_preset() {
561  if (machine.setting_is_preset()) {
563  Glib::ustring t;
564  int idx = 0;
565  t = machine.get_current_name();
566  for (gx_system::PresetFile::iterator i = pf->begin(); i != pf->end(); ++i, ++idx) {
567  if (t.compare(i->name)==0) {
568  --idx;
569  if (i == pf->begin()) idx =pf->size()-1;
570  break;
571  }
572  }
573  keyswitch.process_preset_key(idx);
574  }
575 }
576 
577 void MainWindow::rebuild_preset_menu() {
578  if (preset_list_merge_id) {
579  uimanager->remove_ui(preset_list_merge_id);
580  uimanager->remove_action_group(preset_list_actiongroup);
581  preset_list_menu_bank.clear();
582  preset_list_merge_id = 0;
583  preset_list_actiongroup.reset();
584  uimanager->ensure_update();
585  }
586  if (!machine.setting_is_preset()) {
587  return;
588  }
590  if (!pf) {
591  return;
592  }
593  preset_list_actiongroup = Gtk::ActionGroup::create("PresetList");
594  preset_list_menu_bank = machine.get_current_bank();
595  Glib::ustring s = "<menubar><menu action=\"PresetsMenu\"><menu action=\"PresetListMenu\">";
596  int idx = 0;
597  for (gx_system::PresetFile::iterator i = pf->begin(); i != pf->end(); ++i, ++idx) {
598  Glib::ustring actname = "PresetList_" + i->name;
599  Glib::RefPtr<Gtk::Action> action = Gtk::Action::create(actname, i->name);
600  preset_list_actiongroup->add(
601  action, sigc::bind(sigc::mem_fun(*this, &MainWindow::on_select_preset), idx));
602  if (idx <= 9) {
603  char c = '0' + idx;
604  Gtk::AccelMap::change_entry(action->get_accel_path(), c, Gdk::ModifierType(0), true);
605  }
606  s += Glib::ustring::compose("<menuitem action=\"%1\"/>", actname);
607  }
608  s += "</menu></menu></menubar>";
609  uimanager->insert_action_group(preset_list_actiongroup);
610  preset_list_merge_id = uimanager->add_ui_from_string(s);
611  dynamic_cast<Gtk::MenuItem*>(uimanager->get_widget("/menubar/PresetsMenu/PresetListMenu"))->set_label(_("_Bank: ")+preset_list_menu_bank);
612 }
613 
614 void MainWindow::show_selected_preset() {
615  keyswitch.deactivate();
616  Glib::ustring t;
617  if (machine.setting_is_preset()) {
618  t = machine.get_current_bank() + " / " + machine.get_current_name();
619  if (preset_list_menu_bank != machine.get_current_bank()) {
620  rebuild_preset_menu();
621  }
622  }
623  preset_status->set_text(t);
624 }
625 
626 bool MainWindow::is_variable_size() {
627  return actions.presets->get_active() || actions.show_rack->get_active();
628 }
629 
630 void MainWindow::maybe_change_resizable() {
631  Glib::RefPtr<Gdk::Window> w = window->get_window();
632  if (w && w->get_state() != 0) {
633  return;
634  }
635  if (!is_variable_size() && window->get_resizable()) {
636  window->set_resizable(false);
637  } else if (!window->get_resizable()) {
638  window->set_resizable(true);
639  }
640 }
641 
642 void MainWindow::set_vpaned_handle() {
643  int w, h;
644  main_vpaned->get_handle_window()->get_size(w, h);
645  int pos = main_vpaned->get_allocation().get_height() - options.preset_window_height - h;
646  main_vpaned->set_position(pos);
647 }
648 
649 void MainWindow::on_show_rack() {
650  Gtk::Widget *w;
651  if (rackbox_stacked_vertical()) {
652  w = stereorackcontainerV;
653  } else {
654  w = stereorackbox;
655  }
656  bool v = options.system_show_rack = actions.show_rack->get_active();
657  actions.rackh->set_sensitive(v);
658  stereorackcontainer.set_visible(v);
659  rack_order_h_button->set_visible(v);
660  compress_button->set_visible(v);
661  expand_button->set_visible(v);
662  if (actions.presets->get_active() && preset_scrolledbox->get_mapped()) {
663  options.preset_window_height = preset_scrolledbox->get_allocation().get_height();
664  }
665  if (v) {
666  midi_out_box->set_visible(actions.midi_out->get_active());
667  options.window_height = max(options.window_height, window->size_request().height);
668  main_vpaned->set_position(oldpos);
669  w->show();
670  monoampcontainer->show();
671  monorackcontainer.show_entries();
672  vrack_scrolledbox->set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_ALWAYS);
673  vrack_scrolledbox->set_size_request(scrl_size_x, scrl_size_y);
674  if (preset_scrolledbox->get_parent() != main_vpaned) {
675  preset_box_no_rack->remove(*preset_scrolledbox);
676  main_vpaned->add(*preset_scrolledbox);
677  change_expand(*preset_box_no_rack, false);
678  change_expand(*main_vpaned, true);
679  }
680  Glib::RefPtr<Gdk::Window> win = window->get_window();
681  if (!win || win->get_state() == 0) {
682  Gtk::Requisition req;
683  window->size_request(req);
684  req.height = max(req.height, options.window_height);
685  freezer.freeze_and_size_request(window, req.width, req.height);
686  if (win && actions.presets->get_active()) {
687  freezer.set_slot(sigc::mem_fun(this, &MainWindow::set_vpaned_handle));
688  }
689  }
690  } else {
691  if (actions.midi_out->get_active()) {
692  midi_out_box->set_visible(false);
693  }
694  actions.show_plugin_bar->set_active(false);
695  oldpos = main_vpaned->get_position();
696  w->hide();
697  monoampcontainer->hide();
698  monorackcontainer.hide_entries();
699  if (preset_scrolledbox->get_parent() == main_vpaned) {
700  main_vpaned->remove(*preset_scrolledbox);
701  preset_box_no_rack->add(*preset_scrolledbox);
702  change_expand(*main_vpaned, false);
703  change_expand(*preset_box_no_rack, true);
704  }
705  preset_box_no_rack->set_visible(actions.presets->get_active());
706  vrack_scrolledbox->set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_NEVER);
707  vrack_scrolledbox->get_size_request(scrl_size_x, scrl_size_y);
708  vrack_scrolledbox->set_size_request(-1,-1);
709  if (actions.presets->get_active()) {
710  maybe_shrink_horizontally(true);
711  } else {
712  maybe_shrink_horizontally();
713  }
714  }
715  maybe_change_resizable();
716 }
717 
718 void MainWindow::on_compress_all() {
719  plugin_dict.compress(true);
720  on_ampdetail_switch(true, true);
721  actions.midi_out_plug->set_active(true);
722 }
723 
724 void MainWindow::on_expand_all() {
725  plugin_dict.compress(false);
726  on_ampdetail_switch(false, true);
727  actions.midi_out_plug->set_active(false);
728 }
729 
730 void MainWindow::on_rack_configuration() {
731  bool v = actions.rack_config->get_active();
732  actions.show_plugin_bar->set_sensitive(!v);
733  actions.show_rack->set_sensitive(!v);
734  actions.tuner->set_sensitive(!v);
735  actions.compress->set_sensitive(!v);
736  actions.expand->set_sensitive(!v);
737  actions.live_play->set_sensitive(!v);
738  Gtk::Requisition req;
739  monobox->size_request(req);
740  stereorackcontainer.set_config_mode(v);
741  monorackcontainer.set_config_mode(v);
742  szg_rack_units->set_ignore_hidden(v);
743  bool plugin_bar = actions.show_plugin_bar->get_active();
744  if (v) {
745  pre_act = actions.presets->get_active();
746  if (pre_act) {
747  actions.presets->set_active(false);
748  }
749  actions.show_rack->set_active(true);
750  effects_frame_paintbox->show();
751  upper_rackbox->hide();
752  Gtk::Requisition req2;
753  effects_frame_paintbox->size_request(req2);
754  int width = req.width;
755  if (!plugin_bar) {
756  if (rackbox_stacked_vertical()) {
757  width -= req2.width;
758  } else {
759  if (req2.width & 1) {
760  req2.width += 1;
761  }
762  width -= req2.width/2;
763  }
764  }
765  effects_frame_paintbox->set_size_request(req2.width, -1);
766  monobox->set_size_request(width,-1);
767  } else {
768  if (!plugin_bar) {
769  effects_frame_paintbox->hide();
770  }
771  upper_rackbox->show();
772  effects_frame_paintbox->set_size_request(-1,-1);
773  monobox->set_size_request(-1,-1);
774  if (pre_act) {
775  actions.presets->set_active(true);
776  }
777  }
778  if (!plugin_bar) {
779  update_width();
780  maybe_shrink_horizontally();
781  }
782 }
783 
784 void MainWindow::on_show_plugin_bar() {
785  bool v = options.system_show_toolbar = actions.show_plugin_bar->get_active();
786  if (v) {
787  actions.show_rack->set_active(true);
788  }
789  effects_frame_paintbox->set_visible(v);
790  if (!v) {
791  //update_scrolled_window(*vrack_scrolledbox);
792  //update_scrolled_window(*stereorackbox);
793  maybe_shrink_horizontally();
794  }
795 }
796 
797 void MainWindow::move_widget(Gtk::Widget& w, Gtk::Box& b1, Gtk::Box& b2) {
798  // reparent does not always work when child is hidden
799  // (sometimes wrong position when shown later),
800  // use remove / add
801  b1.remove(w);
802  b1.hide();
803  b2.pack_start(w);
804  b2.show();
805 }
806 
807 int MainWindow::rackbox_stacked_vertical() const {
808  return !actions.rackh->get_active();
809 }
810 
811 void MainWindow::change_expand(Gtk::Widget& w, bool value) {
812  Gtk::Box *p = dynamic_cast<Gtk::Box*>(w.get_parent());
813  int expand, fill;
814  unsigned int padding;
815  GtkPackType pack_type;
816  gtk_box_query_child_packing(p->gobj(), w.gobj(), &expand, &fill, &padding, &pack_type);
817  gtk_box_set_child_packing(p->gobj(), w.gobj(), value, value, padding, pack_type);
818 }
819 
820 double MainWindow::stop_at_stereo_bottom(double off, double step_size, double pagesize) {
821  Gtk::Allocation alloc = stereorackcontainer.get_allocation();
822  double lim = alloc.get_y() + alloc.get_height() - pagesize;
823  if (off >= lim) {
824  return off;
825  }
826  return min(off+step_size, lim);
827 }
828 
829 double MainWindow::stop_at_mono_top(double off, double step_size) {
830  Gtk::Allocation alloc = monorackcontainer.get_allocation();
831  if (off < alloc.get_y()) {
832  return off;
833  }
834  return max(off-step_size, double(alloc.get_y()));
835 }
836 
837 void MainWindow::on_dir_changed() {
838  bool v = options.system_order_rack_h = actions.rackh->get_active();
839  if (v) {
840  // horizontally
841  move_widget(stereorackcontainer, *stereorackcontainerV, *stereorackcontainerH);
842  change_expand(*monobox, true);
843  stereorackbox->show();
844  } else {
845  move_widget(stereorackcontainer, *stereorackcontainerH, *stereorackcontainerV);
846  change_expand(*monobox, false);
847  stereorackbox->hide();
848  maybe_shrink_horizontally();
849  }
850 }
851 
852 void MainWindow::on_configure_event(GdkEventConfigure *ev) {
853  if (freezer.check_thaw(ev->width, ev->height)) {
854  if (actions.show_rack->get_active()) {
855  options.window_height = ev->height;
856  }
857  }
858 }
859 
861 {
862  if (ch == &monorackcontainer && !actions.rackh->get_active()) {
863  stereorackcontainer.queue_draw();
864  }
865 }
866 
868  update_scrolled_window(*vrack_scrolledbox);
869  update_scrolled_window(*stereorackbox);
870 }
871 
872 RackBox *MainWindow::add_rackbox_internal(PluginUI& plugin, Gtk::Widget *mainwidget, Gtk::Widget *miniwidget,
873  bool mini, int pos, bool animate, Gtk::Widget *bare) {
874  RackBox *r = new RackBox(plugin, *this, bare);
875  if (mini) {
876  r->swtch(true);
877  }
878  r->pack(mainwidget, miniwidget, szg_rack_units);
879  update_width();
880  if (plugin.get_type() == PLUGIN_TYPE_MONO) {
881  monorackcontainer.add(*manage(r), pos);
882  } else {
883  stereorackcontainer.add(*manage(r), pos);
884  }
885  if (animate) {
886  r->animate_insert();
887  }
888  return r;
889 }
890 
891 RackBox *MainWindow::add_rackbox(PluginUI& pl, bool mini, int pos, bool animate) {
892  Gtk::Widget *mainwidget = 0;
893  Gtk::Widget *miniwidget = 0;
894  boxbuilder.get_box(pl.get_id(), mainwidget, miniwidget);
895  if (!mainwidget) {
896  gx_gui::UiBuilderImpl builder(this, &boxbuilder);
897 
898  if (machine.load_unit(builder, pl.plugin->get_pdef())) {
899  boxbuilder.fetch(mainwidget, miniwidget);
900  }
901  }
902  return add_rackbox_internal(pl, mainwidget, miniwidget, mini, pos, animate);
903 }
904 
905 void MainWindow::add_icon(const std::string& name) {
906  PluginUI *p = plugin_dict[name];
907  p->toolitem->show();
908 }
909 
910 void MainWindow::on_show_values() {
911  options.system_show_value = actions.show_values->get_active();
912  std::string s =
913  "style \"ShowValue\" {\n"
914  " GxRegler::show-value = " + gx_system::to_string(options.system_show_value) + "\n"
915  "}\n"
916  "class \"*GxRegler*\" style:highest \"ShowValue\"\n";
917  gtk_rc_parse_string(s.c_str());
918  gtk_rc_reset_styles(gtk_settings_get_default());
919 }
920 
921 void MainWindow::on_preset_action() {
922  bool v = options.system_show_presets = actions.presets->get_active();
923  if (!v && preset_scrolledbox->get_mapped()) {
924  options.preset_window_height = preset_scrolledbox->get_allocation().get_height();
925  }
926  maybe_change_resizable();
927  if (v && !actions.show_rack->get_active()) {
928  Glib::RefPtr<Gdk::Window> win = window->get_window();
929  if (!win || win->get_state() == 0) {
930  Gtk::Requisition req;
931  window->size_request(req);
932  freezer.freeze_and_size_request(window, req.width, req.height+options.preset_window_height);
933  }
934  }
935  preset_box_no_rack->set_visible(v);
936  preset_window->on_preset_select(v, use_animations() && actions.show_rack->get_active(), options.preset_window_height);
937 }
938 
939 /*
940 ** UI initialization
941 */
942 
943 bool MainWindow::on_my_leave_out(GdkEventCrossing *focus) {
944  Glib::RefPtr<Gdk::Window> wind = window->get_window();
945  wind->set_cursor();
946  return true;
947 }
948 
949 bool MainWindow::on_my_enter_in(GdkEventCrossing *focus) {
950  Glib::RefPtr<Gdk::Window> wind = window->get_window();
951  Gdk::Cursor cursor(Gdk::HAND1);
952  wind->set_cursor(cursor);
953  return true;
954 }
955 
956 void MainWindow::add_toolitem(PluginUI& pl, Gtk::ToolItemGroup *gw) {
957  Gtk::ToolItem *tb = new Gtk::ToolItem();
958  tb->set_use_drag_window(true);
959  tb->signal_drag_begin().connect(sigc::bind(sigc::mem_fun(*this, &MainWindow::on_ti_drag_begin), sigc::ref(pl)));
960  tb->signal_drag_end().connect(sigc::mem_fun(*this, &MainWindow::on_ti_drag_end));
961  tb->signal_drag_data_delete().connect(sigc::bind(sigc::mem_fun(*this, &MainWindow::on_ti_drag_data_delete), pl.get_id()));
962  tb->signal_button_press_event().connect(sigc::bind(sigc::mem_fun(*this, &MainWindow::on_ti_button_press), pl.get_id()));
963  tb->add_events(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK);
964  tb->signal_leave_notify_event().connect(sigc::mem_fun(*this, &MainWindow::on_my_leave_out));
965  tb->signal_enter_notify_event().connect(sigc::mem_fun(*this, &MainWindow::on_my_enter_in));
966  std::vector<Gtk::TargetEntry> listTargets;
967  if (pl.get_type() == PLUGIN_TYPE_MONO) {
968  listTargets.push_back(Gtk::TargetEntry("application/x-gtk-tool-palette-item-mono", Gtk::TARGET_SAME_APP, 0));
969  } else {
970  listTargets.push_back(Gtk::TargetEntry("application/x-gtk-tool-palette-item-stereo", Gtk::TARGET_SAME_APP, 0));
971  }
972  tb->drag_source_set(listTargets, Gdk::BUTTON1_MASK, Gdk::ACTION_MOVE);
973  tb->signal_drag_data_get().connect(sigc::bind(sigc::mem_fun(*this, &MainWindow::on_ti_drag_data_get), pl.get_id()));
974  Gtk::Image *img = new Gtk::Image(pl.icon);
975  if (!pl.tooltip.empty()) {
976  img->set_tooltip_text(pl.tooltip);
977  }
978  tb->add(*manage(img));
979  tb->show_all();
980  pl.toolitem = tb;
981  gw->add(*manage(tb));
982  pl.group = gw;
983 }
984 
985 bool MainWindow::on_visibility_notify(GdkEventVisibility *ev) {
986  bool v = ev->state != GDK_VISIBILITY_FULLY_OBSCURED;
987  if (v == is_visible) {
988  return false;
989  }
990  is_visible = v;
991  return false;
992 }
993 
994 void MainWindow::on_live_play() {
995  live_play->on_live_play(actions.live_play);
996 }
997 
998 void MainWindow::on_ti_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context, const PluginUI& plugin) {
999  drag_icon = new DragIcon(plugin, context, options);
1000 }
1001 
1002 void MainWindow::on_ti_drag_end(const Glib::RefPtr<Gdk::DragContext>& context) {
1003  if (drag_icon) {
1004  delete drag_icon;
1005  drag_icon = 0;
1006  }
1007 }
1008 
1009 void MainWindow::on_ti_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& context, Gtk::SelectionData& selection, int info, int timestamp, const char *effect_id) {
1010  selection.set(*context->get_targets().begin(), effect_id);
1011 }
1012 
1013 void MainWindow::hide_effect(const std::string& name) {
1014  Gtk::ToolItem *toolitem = plugin_dict[name]->toolitem;
1015  if (toolitem) {
1016  toolitem->hide();
1017  }
1018 }
1019 
1020 void MainWindow::on_ti_drag_data_delete(const Glib::RefPtr<Gdk::DragContext>& context, const char *effect_id) {
1021  hide_effect(effect_id);
1022 }
1023 
1024 bool MainWindow::on_ti_button_press(GdkEventButton *ev, const char *effect_id) {
1025  if (ev->type == GDK_2BUTTON_PRESS) {
1026  get_plugin(effect_id)->display_new();
1027  return true;
1028  }
1029  return false;
1030 }
1031 
1032 void MainWindow::on_tp_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& data, int info, int timestamp) {
1033  Glib::ustring id = data.get_data_as_string();
1034  PluginUI *p = get_plugin(id);
1035  p->display(false, false);
1036  add_icon(id);
1037  p->group->set_collapsed(false);
1038 }
1039 
1040 void MainWindow::jack_connection() {
1041  bool v = actions.jackserverconnection->get_active();
1042  if (!connect_jack(v)) {
1043  actions.jackserverconnection->set_active(!v);
1044  }
1045 }
1046 
1047 void MainWindow::on_portmap_response(int) {
1048  actions.jackports->set_active(false);
1049 }
1050 
1051 void MainWindow::on_portmap_activate() {
1052  gx_jack::GxJack *jack = machine.get_jack();
1053  if (!jack) {
1054  return;
1055  }
1056  if (actions.jackports->get_active()) {
1057  if (portmap_window) {
1058  return;
1059  }
1060  portmap_window = gx_portmap::PortMapWindow::create(machine, actions.accels);
1061  portmap_window->signal_response().connect(
1062  sigc::mem_fun(*this, &MainWindow::on_portmap_response));
1063  } else {
1064  if (!portmap_window) {
1065  return;
1066  }
1067  delete portmap_window;
1068  portmap_window = 0;
1069  }
1070 }
1071 
1072 void MainWindow::on_miditable_toggle() {
1073  gx_main_midi::MidiControllerTable::toggle(machine, actions.midicontroller);
1074 }
1075 
1076 void MainWindow::change_skin(Glib::RefPtr<Gtk::RadioAction> action) {
1077  set_new_skin(options.skin[action->get_current_value()]);
1078 }
1079 
1080 void MainWindow::set_new_skin(const Glib::ustring& skin_name) {
1081  if (!skin_name.empty()) {
1082  options.skin_name = skin_name;
1083  string rcfile = options.get_style_filepath(
1084  "gx_head_" + skin_name + ".rc");
1085  gtk_rc_parse(rcfile.c_str());
1086  gtk_rc_reset_styles(gtk_settings_get_default());
1087  make_icons();
1088  }
1089 }
1090 
1091 void MainWindow::add_skin_menu() {
1092  Glib::ustring s = "<menubar><menu action=\"OptionsMenu\"><menu action=\"SkinMenu\">";
1093  int idx = 0;
1094  Gtk::RadioButtonGroup sg;
1095  for (vector<Glib::ustring>::iterator i = options.skin.skin_list.begin();
1096  i != options.skin.skin_list.end();
1097  ++i) {
1098  Glib::ustring name = *i;
1099  Glib::ustring actname = Glib::ustring::compose("ChangeSkin_%1", name);
1100  s += Glib::ustring::compose("<menuitem action=\"%1\"/>", actname);
1101  Glib::RefPtr<Gtk::RadioAction> action = Gtk::RadioAction::create(sg, actname, name);
1102  if (name == options.skin_name) {
1103  action->set_active(true);
1104  }
1105  actions.group->add(action);
1106  if (idx == 0) {
1107  actions.skin = action;
1108  }
1109  action->property_value().set_value(idx++);
1110  }
1111  actions.skin->signal_changed().connect(
1112  sigc::mem_fun(*this, &MainWindow::change_skin));
1113  s.append("</menu></menu></menubar>");
1114  uimanager->add_ui_from_string(s);
1115 }
1116 
1120 };
1121 
1122 // check user's decision to turn off latency change warning
1123 void MainWindow::user_disable_latency_warn(Gtk::CheckButton* disable_warn) {
1124  options.no_warn_latency = disable_warn->get_active();
1125 }
1126 
1127 int MainWindow::gx_wait_latency_warn() {
1128  Gtk::Dialog warn_dialog;
1129  // no set_destroy_with_parent() ??
1130  warn_dialog.property_destroy_with_parent().set_value(true);
1131 
1132  Gtk::VBox box(0, 4);
1133  Gtk::Label labelt(_("\nWARNING\n"));
1134  Gtk::Label labelt1(
1135  _("CHANGING THE JACK_BUFFER_SIZE ON THE FLY \n"
1136  "MAY CAUSE UNPREDICTABLE EFFECTS \n"
1137  "TO OTHER RUNNING JACK APPLICATIONS. \n"
1138  "DO YOU WANT TO PROCEED ?"));
1139  Gdk::Color colorGreen("#969292");
1140  labelt1.modify_fg(Gtk::STATE_NORMAL, colorGreen);
1141  Pango::FontDescription font = labelt1.get_style()->get_font();
1142  font.set_size(10*Pango::SCALE);
1143  font.set_weight(Pango::WEIGHT_BOLD);
1144  labelt1.modify_font(font);
1145 
1146  Gdk::Color colorWhite("#ffffff");
1147  labelt.modify_fg(Gtk::STATE_NORMAL, colorWhite);
1148  font = labelt.get_style()->get_font();
1149  font.set_size(14*Pango::SCALE);
1150  font.set_weight(Pango::WEIGHT_BOLD);
1151  labelt.modify_font(font);
1152 
1153  warn_dialog.add_button(_("Yes"), kChangeLatency);
1154  warn_dialog.add_button(_("No"), kKeepLatency);
1155 
1156  Gtk::HBox box1(0, 4);
1157  Gtk::HBox box2(0, 4);
1158 
1159  Gtk::CheckButton disable_warn;
1160  disable_warn.signal_clicked().connect(
1161  sigc::bind(
1162  sigc::mem_fun(*this, &MainWindow::user_disable_latency_warn),
1163  &disable_warn));
1164 
1165  Gtk::Label labelt2(
1166  _("Don't bother me again with such a question, "
1167  "I know what I am doing"));
1168 
1169  box.add(labelt);
1170  box.add(labelt1);
1171  box.add(box2);
1172  box.add(box1);
1173  box1.add(disable_warn);
1174  box1.add(labelt2);
1175  warn_dialog.get_vbox()->add(box);
1176 
1177  labelt2.modify_fg(Gtk::STATE_NORMAL, colorWhite);
1178 
1179  font = labelt2.get_style()->get_font();
1180  font.set_size(8*Pango::SCALE);
1181  font.set_weight(Pango::WEIGHT_NORMAL);
1182  labelt2.modify_font(font);
1183 
1184  box.show_all();
1185 
1186  return warn_dialog.run();
1187 }
1188 
1189 void MainWindow::change_latency(Glib::RefPtr<Gtk::RadioAction> action) {
1190  // are we a proper jack gxjack.client ?
1191  gx_jack::GxJack *jack = machine.get_jack();
1192  if (!jack) {
1193  return;
1194  }
1195  if (!jack->client) {
1197  _("Jack Buffer Size setting"),
1198  _("we are not a jack gxjack.client, server may be down")
1199  );
1200  return;
1201  }
1202  jack_nframes_t buf_size = action->get_current_value();
1203  if (buf_size == jack->get_jack_bs()) {
1204  return;
1205  }
1206  if (!options.no_warn_latency && gx_wait_latency_warn() != kChangeLatency) {
1207  Glib::signal_idle().connect_once(
1208  sigc::bind(
1209  sigc::mem_fun(action.operator->(), &Gtk::RadioAction::set_current_value), jack->get_jack_bs()));
1210  } else {
1211  if (jack_set_buffer_size(jack->client, buf_size) != 0)
1212  gx_print_warning(_("Setting Jack Buffer Size"),
1213  _("Could not change latency"));
1214  }
1215  gx_print_info(
1216  _("Jack Buffer Size"),
1217  boost::format(_("latency is %1%")) % jack_get_buffer_size(jack->client));
1218 }
1219 
1220 void MainWindow::add_latency_menu() {
1221  Glib::ustring s = "<menubar><menu action=\"EngineMenu\"><menu action=\"JackLatency\">";
1222  Gtk::RadioButtonGroup group;
1223  const int min_pow = 4; // 2**4 = 16
1224  const int max_pow = 13; // 2**13 = 8192
1225  int jack_buffer_size = 16;
1226  for (int i = 0; i <= max_pow-min_pow; ++i) {
1227  Glib::ustring name = gx_system::to_string(jack_buffer_size);
1228  Glib::ustring actname = Glib::ustring::compose("Latency_%1", name);
1229  s += Glib::ustring::compose("<menuitem action=\"%1\"/>", actname);
1230  Glib::RefPtr<Gtk::RadioAction> action = Gtk::RadioAction::create(group, actname, name);
1231  actions.group->add(action);
1232  if (i == 0) {
1233  action->signal_changed().connect(
1234  sigc::mem_fun(*this, &MainWindow::change_latency));
1235  actions.latency = action;
1236  }
1237  action->property_value().set_value(jack_buffer_size);
1238  jack_buffer_size *= 2;
1239  }
1240  s.append("</menu></menu></menubar>");
1241  uimanager->add_ui_from_string(s);
1242 }
1243 
1244 void MainWindow::set_latency() {
1245  gx_jack::GxJack *jack = machine.get_jack();
1246  if (!jack) {
1247  return;
1248  }
1249  jack_nframes_t n = jack->get_jack_bs();
1250  if (n > 0) {
1251  actions.latency->set_current_value(n);
1252  }
1253  if (n > 1023) actions.osc_buffer_menu->set_sensitive(false);
1254  else actions.osc_buffer_menu->set_sensitive(true);
1255 }
1256 
1258  GError *error = NULL;
1259  gtk_show_uri(gdk_screen_get_default(), "http://guitarix.sourceforge.net/forum/",
1260  gtk_get_current_event_time(), &error);
1261  if (error)
1262  {
1263  gx_print_error("guitarix help",
1264  _("failed to load online help "));
1265  g_error_free(error);
1266  }
1267 }
1268 
1270  Glib::signal_idle().connect_once(sigc::ptr_fun( show_forum_help));
1271 }
1272 
1273 // ----menu funktion about
1275  static string about;
1276  if (about.empty()) {
1277  about +=_("<b>Guitarix:gx_head</b> (");
1278  about += GX_VERSION;
1279  about +=
1280  _(")\n\nThis Application is to a large extent provided"
1281  "\nwith the marvelous faust compiler.Yann Orlary"
1282  "\n(http://faust.grame.fr/)"
1283  "\n\nA large part is based on the work of Julius Orion Smith"
1284  "\n(htttp://ccrma.stanford.edu/realsimple/faust/)"
1285  "\nand Albert Graef\n(http://q-lang.sourceforge.net/examples.html#Faust)"
1286  "\n\n");
1287 
1288 
1289  about +=
1290  _("for impulse response it use zita-convolver"
1291  "\nby Fons Adriaensen"
1292  "\n(http://www.kokkinizita.net/linuxaudio/index.html)"
1293  "\n\nThe included IR-files are contributed by"
1294  "\nDavid Fau Casquel (BESTPLUGINS)"
1295  "\nhome: http://www.youtube.com/bestplugins"
1296  "\n\nauthors: Hermann Meyer &lt;brummer-@web.de&gt;"
1297  "\nauthors: James Warden &lt;warjamy@yahoo.com&gt;"
1298  "\nauthors: Andreas Degert &lt;andreas.degert@googlemail.com&gt;"
1299  "\nauthors: Pete Shorthose &lt;pshorthose@gmail.com&gt;"
1300  "\nauthors: Markus Schmidt &lt;schmidt@boomshop.net&gt;"
1301  "\n\nwebsite: http://guitarix.org/\n");
1302  }
1303 
1304  gx_gui::gx_message_popup(about.c_str());
1305 }
1306 
1307 void MainWindow::set_tooltips() {
1308  options.system_show_tooltips = actions.tooltips->get_active();
1309  gtk_settings_set_long_property(
1310  gtk_settings_get_default(), "gtk-enable-tooltips", options.system_show_tooltips,
1311  "gx_head menu-option");
1312 }
1313 
1314 void MainWindow::set_animations() {
1315  options.system_animations = actions.animations->get_active();
1316 }
1317 
1318 void MainWindow::on_select_jack_control() {
1319  if (select_jack_control) {
1320  select_jack_control->present();
1321  } else {
1322  select_jack_control = gx_gui::SelectJackControlPgm::create(options, machine);
1323  select_jack_control->signal_close().connect(
1324  sigc::mem_fun(*this, &MainWindow::delete_select_jack_control));
1325  select_jack_control->set_transient_for(*window);
1326  select_jack_control->show();
1327  }
1328 }
1329 
1330 void MainWindow::delete_select_jack_control() {
1331  delete select_jack_control;
1332  select_jack_control = 0;
1333 }
1334 
1335 // show loggingbox
1336 void MainWindow::on_log_activate() {
1337  if (actions.loggingbox->get_active()) {
1338  gint rxorg, ryorg;
1339  window->get_position(rxorg, ryorg);
1340  fLoggingWindow.move(rxorg+5, ryorg+272);
1341  fLoggingWindow.show_all();
1342  on_msg_level_changed();
1343  } else {
1344  fLoggingWindow.hide();
1345  }
1346 }
1347 // show loggingbox
1348 bool MainWindow::on_log_activated(GdkEventButton* ev) {
1349  if (ev->type == GDK_BUTTON_PRESS && ev->button == 1) {
1350  if (!actions.loggingbox->get_active()) {
1351  actions.loggingbox->set_active(true);
1352  gint rxorg, ryorg;
1353  window->get_position(rxorg, ryorg);
1354  fLoggingWindow.move(rxorg+5, ryorg+272);
1355  fLoggingWindow.show_all();
1356  on_msg_level_changed();
1357  } else {
1358  fLoggingWindow.hide();
1359  actions.loggingbox->set_active(false);
1360  }
1361  }else if (ev->type == GDK_BUTTON_PRESS && ev->button == 2) {
1362  fLoggingWindow.reset_msg_level();
1363  }
1364  return true;
1365 }
1366 
1367 bool MainWindow::on_log_scrolled(GdkEventScroll* ev) {
1368  if (!actions.loggingbox->get_active()) {
1369  actions.loggingbox->set_active(true);
1370  gint rxorg, ryorg;
1371  window->get_position(rxorg, ryorg);
1372  fLoggingWindow.move(rxorg+5, ryorg+272);
1373  fLoggingWindow.show_all();
1374  on_msg_level_changed();
1375  } else {
1376  fLoggingWindow.hide();
1377  actions.loggingbox->set_active(false);
1378  }
1379  return true;
1380 }
1381 
1382 void MainWindow::on_engine_toggled() {
1384  if (actions.engine_mute->get_active()) {
1386  } else if (actions.engine_bypass->get_active()) {
1388  } else {
1390  }
1391  machine.set_state(s);
1392 }
1393 
1394 void MainWindow::set_switcher_controller() {
1395  if (!machine.midi_get_config_mode()) {
1396  new gx_main_midi::MidiConnect(0, machine.get_parameter("ui.live_play_switcher"), machine);
1397  }
1398 }
1399 
1400 void MainWindow::set_bypass_controller() {
1401  if (!machine.midi_get_config_mode()) {
1402  new gx_main_midi::MidiConnect(0, machine.get_parameter("engine.bypass"), machine);
1403  }
1404 }
1405 
1406 void MainWindow::on_show_midi_out() {
1407 #ifdef USE_MIDI_OUT
1408  if (actions.midi_out->get_active()) {
1409  actions.show_rack->set_active(true);
1410  midi_out_box->set_visible(true);
1411  } else {
1412  midi_out_box->set_visible(false);
1413  machine.pluginlist_lookup_plugin("midi_out")->set_on_off(false);
1414  }
1415 #endif
1416 }
1417 
1418 void MainWindow::on_show_midi_out_plug() {
1419  if (actions.midi_out_plug->get_active()) {
1420  midi_out_normal->hide();
1421  midi_out_mini->show();
1422  } else {
1423  midi_out_mini->hide();
1424  midi_out_normal->show();
1425  }
1426 }
1427 
1428 void MainWindow::on_midi_out_channel_toggled(Gtk::RadioButton *rb, Gtk::Container *c) {
1429  c->set_visible(rb->get_active());
1430 }
1431 
1432 void MainWindow::on_livetuner_toggled() {
1433  if (actions.livetuner->get_active()) {
1434  if (actions.live_play->get_active()) {
1435  live_play->display_tuner(true);
1436  racktuner->set_sensitive(false);
1437  machine.tuner_used_for_display(true);
1438  } else {
1439  live_play->display_tuner(false);
1440  if (actions.tuner->get_active()) {
1441  racktuner->set_sensitive(true);
1442  machine.tuner_used_for_display(true);
1443  } else {
1444  machine.tuner_used_for_display(false);
1445  }
1446  }
1447  } else {
1448  live_play->display_tuner(false);
1449  racktuner->set_sensitive(false);
1450  machine.tuner_used_for_display(false);
1451  }
1452 }
1453 
1454 void MainWindow::create_actions() {
1455  gx_jack::GxJack *jack = machine.get_jack();
1456  actions.group = Gtk::ActionGroup::create("Main");
1457  /*
1458  ** Menu actions
1459  */
1460  actions.group->add(Gtk::Action::create("EngineMenu",_("_Engine")));
1461  actions.jack_latency_menu = Gtk::Action::create("JackLatency",_("_Latency"));
1462  actions.group->add(actions.jack_latency_menu);
1463  actions.osc_buffer_menu = Gtk::Action::create("OscBuffer",_("Osc. Buffer-size"));
1464  actions.group->add(actions.osc_buffer_menu);
1465 
1466  actions.group->add(Gtk::Action::create("PresetsMenu",_("_Presets")));
1467  actions.group->add(Gtk::Action::create("NextPreset",_("Next Preset")),
1468  sigc::mem_fun(*this, &MainWindow::on_next_preset));
1469  actions.group->add(Gtk::Action::create("PreviusPreset",_("Previus Preset")),
1470  sigc::mem_fun(*this, &MainWindow::on_previus_preset));
1471  actions.group->add(Gtk::Action::create("PresetListMenu","--"));
1472  actions.group->add(Gtk::Action::create("PluginsMenu",_("P_lugins")));
1473  actions.group->add(Gtk::Action::create("MonoPlugins",_("_Mono Plugins")));
1474  actions.group->add(Gtk::Action::create("StereoPlugins",_("_Stereo Plugins")));
1475  actions.group->add(Gtk::Action::create("TubeMenu",_("_Tube")));
1476  actions.group->add(Gtk::Action::create("OptionsMenu",_("_Options")));
1477  actions.group->add(Gtk::Action::create("SkinMenu", _("_Skin...")));
1478  actions.group->add(Gtk::Action::create("AboutMenu",_("_About")));
1479 
1480  /*
1481  ** engine actions
1482  */
1483  actions.jackserverconnection = Gtk::ToggleAction::create("JackServerConnection", _("Jack Server _Connection"));
1484  actions.group->add(
1485  actions.jackserverconnection,
1486  sigc::mem_fun(*this, &MainWindow::jack_connection));
1487 
1488  actions.jackports = Gtk::ToggleAction::create("JackPorts", _("Jack _Ports"));
1489  actions.group->add(
1490  actions.jackports,
1491  sigc::mem_fun(*this, &MainWindow::on_portmap_activate));
1492 
1493  actions.midicontroller = Gtk::ToggleAction::create("MidiController", _("M_idi Controller"));
1494  actions.group->add(
1495  actions.midicontroller,
1496  sigc::mem_fun(*this, &MainWindow::on_miditable_toggle));
1497 
1498  actions.engine_mute = Gtk::ToggleAction::create("EngineMute", _("Engine _Mute"));
1499  actions.group->add(actions.engine_mute);
1500  actions.engine_mute_conn = actions.engine_mute->signal_toggled().connect(
1501  sigc::mem_fun(*this, &MainWindow::on_engine_toggled));
1502 
1503  actions.engine_bypass = Gtk::ToggleAction::create("EngineBypass", _("Engine _Bypass"));
1504  actions.group->add(actions.engine_bypass);
1505  actions.engine_bypass_conn = actions.engine_bypass->signal_toggled().connect(
1506  sigc::mem_fun(*this, &MainWindow::on_engine_toggled));
1507 
1508  actions.quit = Gtk::Action::create("Quit",_("_Quit"));
1509  actions.group->add(
1510  actions.quit,
1511  sigc::hide_return(sigc::mem_fun(this, &MainWindow::on_quit)));
1512 
1513  /*
1514  ** actions to open other (sub)windows
1515  */
1516  actions.presets = Gtk::ToggleAction::create(
1517  "Presets",_("_Preset Selection"));
1518  actions.group->add(actions.presets,
1519  sigc::mem_fun(*this, &MainWindow::on_preset_action));
1520 
1521  actions.show_plugin_bar = Gtk::ToggleAction::create(
1522  "ShowPluginBar",_("Show Plugin _Bar"));
1523  actions.group->add(actions.show_plugin_bar,
1524  sigc::mem_fun(*this, &MainWindow::on_show_plugin_bar));
1525 
1526  actions.show_rack = Gtk::ToggleAction::create(
1527  "ShowRack",_("Show _Rack"), "", true);
1528  actions.group->add(actions.show_rack,
1529  sigc::mem_fun(*this, &MainWindow::on_show_rack));
1530 
1531  actions.loggingbox = Gtk::ToggleAction::create("LoggingBox", _("Show _Logging Box"));
1532  actions.group->add(
1533  actions.loggingbox,
1534  sigc::mem_fun(*this, &MainWindow::on_log_activate));
1535 
1536  actions.live_play = Gtk::ToggleAction::create("Liveplay",_("Live _Display"));
1537  actions.group->add(actions.live_play,
1538  sigc::mem_fun(*this, &MainWindow::on_live_play));
1539 
1540  actions.meterbridge = Gtk::ToggleAction::create("Meterbridge", _("_Meterbridge"));
1541  if (jack) {
1542  actions.group->add(
1543  actions.meterbridge,
1544  sigc::bind(sigc::ptr_fun(gx_child_process::Meterbridge::start_stop),
1545  sigc::ref(actions.meterbridge), sigc::ref(*jack)));
1546  } else {
1547  actions.group->add(actions.meterbridge);
1548  }
1549 
1550  actions.livetuner = UiBoolToggleAction::create(
1551  machine, "ui.racktuner", "LiveTuner", "??");
1552  actions.group->add(actions.livetuner);
1553  actions.livetuner->signal_toggled().connect(
1554  sigc::mem_fun(this, &MainWindow::on_livetuner_toggled));
1555 
1556  actions.midi_out = UiBoolToggleAction::create(
1557  machine, "ui.midi_out", "MidiOut", _("M_idi Out"));
1558  actions.group->add(
1559  actions.midi_out,
1560  sigc::mem_fun(this, &MainWindow::on_show_midi_out));
1561 
1562  actions.midi_out_plug = UiBoolToggleAction::create(
1563  machine, "midi_out.s_h", "MidiOutSH", "??");
1564  actions.group->add(
1565  actions.midi_out_plug,
1566  sigc::mem_fun(this, &MainWindow::on_show_midi_out_plug));
1567 
1568  /*
1569  ** rack actions
1570  */
1571  actions.tuner = UiBoolToggleAction::create(
1572  machine, "system.show_tuner", "Tuner",_("_Tuner"));
1573  actions.group->add(actions.tuner,
1574  sigc::mem_fun(*this, &MainWindow::on_show_tuner));
1575 
1576  actions.rack_config = Gtk::ToggleAction::create("RackConfig", _("R_ack Configuration"));
1577  actions.group->add(actions.rack_config,
1578  sigc::mem_fun(*this, &MainWindow::on_rack_configuration));
1579 
1580  actions.compress = Gtk::Action::create("Compress",_("C_ompress all"));
1581  actions.group->add(actions.compress,
1582  sigc::mem_fun(*this, &MainWindow::on_compress_all));
1583 
1584  actions.expand = Gtk::Action::create("Expand",_("E_xpand all"));
1585  actions.group->add(actions.expand,
1586  sigc::mem_fun(*this, &MainWindow::on_expand_all));
1587 
1588  actions.rackh = Gtk::ToggleAction::create(
1589  "RackH", _("Order Rack _Horizontally"));
1590  actions.group->add(actions.rackh,
1591  sigc::mem_fun(*this, &MainWindow::on_dir_changed));
1592 
1593  /*
1594  ** option actions
1595  */
1596  actions.show_values = Gtk::ToggleAction::create(
1597  "ShowValues",_("_Show _Values"), "", true);
1598  actions.group->add(actions.show_values,
1599  sigc::mem_fun(*this, &MainWindow::on_show_values));
1600 
1601  actions.tooltips = Gtk::ToggleAction::create(
1602  "ShowTooltips", _("Show _Tooltips"), "", true);
1603  actions.group->add(
1604  actions.tooltips,
1605  sigc::mem_fun(this, &MainWindow::set_tooltips));
1606 
1607  actions.midi_in_presets = UiSwitchToggleAction::create(
1608  machine, "system.midi_in_preset", "MidiInPresets", _("Include MIDI in _presets"));
1609  actions.group->add(actions.midi_in_presets);
1610 
1611  actions.jackstartup = Gtk::Action::create("JackStartup", _("_Jack Startup Control"));
1612  actions.group->add(
1613  actions.jackstartup,
1614  sigc::mem_fun(*this, &MainWindow::on_select_jack_control));
1615 
1616  actions.loadladspa = Gtk::Action::create("LoadLADSPA", _("LADSPA/LV2 Pl_ugins"));
1617  actions.group->add(
1618  actions.loadladspa,
1619  sigc::mem_fun(this, &MainWindow::on_load_ladspa));
1620 
1621  actions.group->add(Gtk::Action::create("ResetAll", _("Reset _All Parameters")),
1622  sigc::mem_fun(machine, &gx_engine::GxMachineBase::set_init_values));
1623 
1624  actions.animations = Gtk::ToggleAction::create(
1625  "Animations", _("_Use Animations"),"",true);
1626  actions.group->add(actions.animations,
1627  sigc::mem_fun(this, &MainWindow::set_animations));
1628 
1629  actions.group->add(Gtk::Action::create("SetPresetSwitcher", _("L_iveplay Midi Switch")),
1630  sigc::mem_fun(this, &MainWindow::set_switcher_controller));
1631 
1632  actions.group->add(Gtk::Action::create("SetBypassSwitcher", _("B_ypass Midi Switch")),
1633  sigc::mem_fun(this, &MainWindow::set_bypass_controller));
1634 
1635  /*
1636  ** Help and About
1637  */
1638  actions.group->add(Gtk::Action::create("Help", _("_Help")),
1639  sigc::ptr_fun(gx_show_help));
1640  actions.group->add(Gtk::Action::create("About", _("_About")),
1641  sigc::ptr_fun(gx_show_about));
1642 
1643  if (!jack) {
1644  actions.jack_latency_menu->set_visible(false);
1645  actions.jackserverconnection->set_visible(false);
1646  actions.jackports->set_visible(false);
1647  actions.meterbridge->set_visible(false);
1648  }
1649 }
1650 
1651 #if false // unused
1652 int get_current_workarea_height_from_desktop(GdkWindow *root) {
1653  // use "xprop -root" to view desktop properties
1654  GdkAtom actual_type, atom_cardinal;
1655  gint actual_format;
1656  gint num_items;
1657  int *ret_data_ptr;
1658  int idx;
1659  atom_cardinal = gdk_atom_intern("CARDINAL", false);
1660  if (!gdk_property_get(
1661  root, gdk_atom_intern("_NET_CURRENT_DESKTOP", false), atom_cardinal,
1662  0, 1, false, &actual_type, &actual_format, &num_items,
1663  (guchar**)&ret_data_ptr)) {
1664  return -1;
1665  }
1666  idx = *ret_data_ptr * 4 + 3; // [x, y, width, height] * desktop_count
1667  g_free(ret_data_ptr);
1668  if (!gdk_property_get(
1669  root, gdk_atom_intern("_NET_WORKAREA", false), atom_cardinal,
1670  idx, 1, false, &actual_type, &actual_format, &num_items,
1671  (guchar**)&ret_data_ptr)) {
1672  return -1;
1673  }
1674  if (idx >= num_items) {
1675  //??
1676  return -1;
1677  }
1678  int height = *ret_data_ptr;
1679  g_free(ret_data_ptr);
1680  return height;
1681 }
1682 
1683 int get_current_workarea_height() {
1684  // Helper fetching the current workarea (i.e. usable space) size
1685  GdkWindow *root = gdk_get_default_root_window();
1686  int height = get_current_workarea_height_from_desktop(root);
1687  if (height > 0) {
1688  return height;
1689  }
1690  int x, y, width, depth;
1691  gdk_window_get_geometry(root, &x, &y, &width, &height, &depth);
1692  return height;
1693 }
1694 #endif
1695 
1697  new PluginPresetPopup(pdef, machine);
1698 }
1699 
1700 void MainWindow::plugin_preset_popup(const PluginDef *pdef, const Glib::ustring& name) {
1701  new PluginPresetPopup(pdef, machine, name);
1702 }
1703 
1704 void MainWindow::clear_box(Gtk::Container& box) {
1705  std::vector<Gtk::Widget*> l = box.get_children();
1706  for (std::vector<Gtk::Widget*>::iterator p = l.begin(); p != l.end(); ++p) {
1707  box.remove(**p);
1708  }
1709 }
1710 
1711 void MainWindow::make_icons(bool force) {
1712  Gtk::OffscreenWindow w;
1713  w.set_type_hint(Gdk::WINDOW_TYPE_HINT_DOCK); // circumvent canberra-gtk-module bug on AV Linux
1714  Glib::RefPtr<Gdk::Screen> screen = w.get_screen();
1715  Glib::RefPtr<Gdk::Colormap> rgba = screen->get_rgba_colormap();
1716  if (rgba) {
1717  w.set_colormap(rgba);
1718  }
1719  Gtk::VBox vb;
1720  w.add(vb);
1721  Glib::RefPtr<Gtk::SizeGroup> sz = Gtk::SizeGroup::create(Gtk::SIZE_GROUP_BOTH);
1722  std::vector<std::pair<PluginUI*,Gtk::Widget*> > l;
1723  for (std::map<std::string, PluginUI*>::iterator i = plugin_dict.begin(); i != plugin_dict.end(); ++i) {
1724  if (!force && i->second->icon) {
1725  continue;
1726  }
1727  Gtk::Widget *r = RackBox::create_icon_widget(*i->second, options);
1728  r->hide();
1729  r->set_no_show_all(true);
1730  vb.add(*manage(r));
1731  sz->add_widget(*r);
1732  l.push_back(std::pair<PluginUI*,Gtk::Widget*>(i->second, r));
1733  }
1734  //FIXME hack to set a minimum size
1735  l.begin()->second->show();
1736  if (vb.size_request().width < 110) {
1737  vb.set_size_request(110, -1);
1738  }
1739  w.show_all();
1740  for (std::vector<std::pair<PluginUI*,Gtk::Widget*> >::iterator i = l.begin(); i != l.end(); ++i) {
1741  i->second->show();
1742  w.show();
1743  w.get_window()->process_updates(true);
1744  i->first->icon = w.get_pixbuf();
1745  if (i->first->toolitem) {
1746  dynamic_cast<Gtk::Image*>(i->first->toolitem->get_child())->set(i->first->icon);
1747  }
1748  w.hide();
1749  i->second->hide();
1750  }
1751 
1752  // Amp padding
1753  hanl = gtk_widget_render_icon(GTK_WIDGET(window->gobj()), "handle_left", (GtkIconSize)-1, NULL);
1754  hanr = gtk_widget_render_icon(GTK_WIDGET(window->gobj()), "handle_right", (GtkIconSize)-1, NULL);
1755  gint wl = gdk_pixbuf_get_width(hanl);
1756  gint wr = gdk_pixbuf_get_width(hanr);
1757  g_object_unref(hanl);
1758  g_object_unref(hanr);
1759  bld->find_widget("amp_padding", vbam);
1760  vbam->set_padding(0, 4, wl, wr);
1761  bld->find_widget("tuner_padding", vbam);
1762  vbam->set_padding(0, 4, wl, wr);
1763  bld->find_widget("details_padding", vbam);
1764  vbam->set_padding(0, 4, wl, wr);
1765 }
1766 
1767 class JConvPluginUI: public PluginUI {
1768 private:
1769  virtual void on_plugin_preset_popup();
1770 public:
1771  JConvPluginUI(MainWindow& main, const char* id,
1772  const Glib::ustring& tooltip="")
1773  : PluginUI(main, id, tooltip) {
1774  }
1775 };
1776 
1777 void JConvPluginUI::on_plugin_preset_popup() {
1779  &main.get_machine().get_parameter(std::string(get_id())+".convolver"));
1780  assert(jcp);
1781  Glib::ustring name = jcp->get_value().getIRFile();
1782  Glib::ustring::size_type n = name.find_last_of('.');
1783  if (n != Glib::ustring::npos) {
1784  name.erase(n);
1785  }
1786  main.plugin_preset_popup(plugin->get_pdef(), name);
1787 }
1788 
1789 void MainWindow::on_plugin_changed(gx_engine::Plugin *pl, gx_engine::PluginChange::pc c) {
1790  if (!pl) { // end of update sequence
1791  make_icons(true); // re-create all icons, width might have changed
1792  } else if (c == gx_engine::PluginChange::add) {
1793  register_plugin(new PluginUI(*this, pl->get_pdef()->id, ""));
1794  } else {
1795  PluginUI *pui = plugin_dict[pl->get_pdef()->id];
1797  plugin_dict.remove(pui);
1798  pui->unset_ui_merge_id(uimanager);
1799  uimanager->ensure_update();
1800  actions.group->remove(pui->get_action());
1801  machine.remove_rack_unit(pui->get_id(), pui->get_type());
1802  std::string group_id = pui->get_category();
1803  delete pui;
1804  Gtk::ToolItemGroup * group = groupmap[group_id];
1805  if (group->get_n_items() == 0) {
1806  Glib::ustring groupname = Glib::ustring::compose("PluginCategory_%1", group_id);
1807  Glib::RefPtr<Gtk::Action> act = actions.group->get_action(groupname);
1808  actions.group->remove(actions.group->get_action(groupname));
1809  groupmap.erase(group_id);
1810  delete group;
1811  }
1812  } else {
1814  //if (!pui->plugin->get_box_visible())
1815  bool state = pui->plugin->get_on_off();
1816  pui->update_rackbox();
1817  pui->plugin->set_on_off(state);
1819  pui->unset_ui_merge_id(uimanager);
1820  pui->group = add_plugin_category(pui->get_category());
1821  pui->toolitem->reparent(*pui->group);
1822  add_plugin_menu_entry(pui);
1823  }
1824  }
1825  }
1826 }
1827 
1828 void MainWindow::on_ladspa_finished(bool reload, bool quit) {
1829  if (reload) {
1830  machine.commit_ladspa_changes();
1831  }
1832  if (quit) {
1833  Glib::signal_idle().connect(sigc::mem_fun(this, &MainWindow::delete_ladspalist_window));
1834  }
1835 }
1836 
1837 bool MainWindow::delete_ladspalist_window() {
1838  if (ladspalist_window) {
1839  //ladspalist_window->hide();
1840  delete ladspalist_window;
1841  ladspalist_window = 0;
1842  }
1843  return false;
1844 }
1845 
1846 void MainWindow::on_load_ladspa() {
1847  if (ladspalist_window) {
1848  ladspalist_window->present();
1849  } else {
1850  ladspalist_window = new ladspa::PluginDisplay(machine, gx_head_icon, sigc::mem_fun(this, &MainWindow::on_ladspa_finished));
1851  }
1852 }
1853 
1854 void MainWindow::add_plugin(std::vector<PluginUI*>& p, const char *id, const Glib::ustring& tooltip) {
1855  if (PluginUI::is_registered(machine, id)) {
1856  return;
1857  }
1858  p.push_back(new PluginUI(*this, id, tooltip));
1859 }
1860 
1861 #ifdef accel_keys_for_plugins
1862 struct accel_search {
1863  unsigned int key;
1864  bool res;
1865 };
1866 
1867 static void accel_search_callback(gpointer data, const gchar *accel_path, guint accel_key, GdkModifierType accel_mods, gboolean changed) {
1868  accel_search *s = static_cast<accel_search*>(data);
1869  if (accel_key == s->key && accel_mods == 0) {
1870  s->res = true;
1871  }
1872 }
1873 
1874 static bool accel_map_has_key(unsigned int accel_key) {
1875  accel_search s;
1876  s.key = accel_key;
1877  s.res = false;
1878  gtk_accel_map_foreach_unfiltered(gpointer(&s), accel_search_callback);
1879  return s.res;
1880 }
1881 
1882 static bool accel_map_next_key(unsigned int *accel_key) {
1883  while (*accel_key <= GDK_z) {
1884  if (!accel_map_has_key(*accel_key)) {
1885  return true;
1886  }
1887  *accel_key += 1;
1888  }
1889  return false;
1890 }
1891 #endif
1892 
1893 struct PluginDesc {
1894  Glib::ustring group;
1895  std::vector<PluginUI*> *plugins;
1896  PluginDesc(const Glib::ustring& g, std::vector<PluginUI*> *p)
1897  : group(g), plugins(p) {}
1898 };
1899 
1900 Gtk::ToolItemGroup *MainWindow::add_plugin_category(const char *group, bool collapse) {
1901  std::map<Glib::ustring, Gtk::ToolItemGroup*>::iterator it = groupmap.find(group);
1902  if (it != groupmap.end()) {
1903  return it->second;
1904  }
1905  Glib::ustring ui_template =
1906  "<menubar><menu action=\"PluginsMenu\"><menu action=\"%1Plugins\"><menu action=\"%2\">"
1907  "</menu></menu></menu></menubar>";
1908  Glib::ustring groupname = Glib::ustring::compose("PluginCategory_%1", group);
1909  uimanager->add_ui_from_string(Glib::ustring::compose(ui_template, "Mono", groupname));
1910  uimanager->add_ui_from_string(Glib::ustring::compose(ui_template, "Stereo", groupname));
1911  actions.group->add(Gtk::Action::create(groupname, gettext(group)));
1912  Gtk::ToolItemGroup *gw = new Gtk::ToolItemGroup(gettext(group));
1913  groupmap[group] = gw;
1914  gw->set_collapsed(collapse);
1915  effects_toolpalette->add(*manage(gw));
1916  effects_toolpalette->set_exclusive(*gw, true);
1917  effects_toolpalette->set_expand(*gw, true);
1918  return gw;
1919 }
1920 
1921 Glib::ustring MainWindow::add_plugin_menu_entry(PluginUI *pui) {
1922  Glib::ustring ui_template =
1923  "<menubar><menu action=\"PluginsMenu\"><menu action=\"%1Plugins\"><menu action=\"%2\">"
1924  "<menuitem action=\"%3\"/>"
1925  "</menu></menu></menu></menubar>";
1926  const char *group = pui->get_category();
1927  Glib::ustring groupname = Glib::ustring::compose("PluginCategory_%1", group);
1928  Glib::ustring actionname = Glib::ustring::compose("Plugin_%1", pui->get_id());
1929  const char *tp = (pui->get_type() == PLUGIN_TYPE_MONO ? "Mono" : "Stereo");
1930  pui->set_ui_merge_id(uimanager->add_ui_from_string(Glib::ustring::compose(ui_template, tp, groupname, actionname)));
1931  //fprintf(stderr, "%s : %s : %s \n", tp, group, pui->get_name());
1932  return actionname;
1933 }
1934 
1935 void MainWindow::register_plugin(PluginUI *pui) {
1936  //FIXME UPDATE LV2 PLUGIN when needed
1937  //if (pui->plugin->get_pdef()->flags & gx_engine::PGNI_NEED_UPDATE)
1938  //fprintf(stderr,"UPDATE NEEDED for %s\n",pui->get_name());
1939  plugin_dict.add(pui);
1940  Gtk::ToolItemGroup *gw = add_plugin_category(pui->get_category());
1941  Glib::ustring actionname = add_plugin_menu_entry(pui);
1942  add_toolitem(*pui, gw);
1943  Glib::RefPtr<Gtk::ToggleAction> act = Gtk::ToggleAction::create(actionname, pui->get_name());
1944  actions.group->add(act);
1945 #ifdef accel_keys_for_plugins
1946  unsigned int key = GDK_a;
1947  if (accel_map_next_key(&key)) {
1948  Gtk::AccelMap::add_entry(act->get_accel_path(), key, Gdk::ModifierType(0));
1949  ++key;
1950  }
1951 #endif
1952  if (pui->rackbox && pui->rackbox->get_box_visible()) {
1953  act->set_active(true);
1954  }
1955  pui->set_action(act);
1956 }
1957 
1958 void MainWindow::fill_pluginlist() {
1959  // define order of categories by registering
1960  // them first
1961  add_plugin_category(N_("Tone Control"), false);
1962  add_plugin_category(N_("Distortion"));
1963  add_plugin_category(N_("Fuzz"));
1964  add_plugin_category(N_("Reverb"));
1965  add_plugin_category(N_("Echo / Delay"));
1966  add_plugin_category(N_("Modulation"));
1967  add_plugin_category(N_("Guitar Effects"));
1968  add_plugin_category(N_("Misc"));
1969 
1970  std::vector<PluginUI*> p;
1971  p.push_back(new JConvPluginUI(*this, "jconv"));
1972  p.push_back(new JConvPluginUI(*this, "jconv_mono"));
1973 
1974  gx_gui::UiBuilderImpl builder(this, &boxbuilder, &p);
1975  machine.pluginlist_append_rack(builder);
1976 
1977  std::sort(p.begin(), p.end(), plugins_by_name_less);
1978  for (std::vector<PluginUI*>::iterator v = p.begin(); v != p.end(); ++v) {
1979  register_plugin(*v);
1980  }
1981 }
1982 
1983 // start_jack() returns:
1984 // 1: success
1985 // 0: fail
1986 // -1: no start command configured
1987 int MainWindow::start_jack() {
1988  gx_jack::GxJack *jack = machine.get_jack();
1989  if (!jack) {
1990  return -1;
1991  }
1992  int wait_after_connect = 0;
1993  gx_engine::EnumParameter& jack_starter = machine.get_parameter("ui.jack_starter_idx").getEnum();
1994  string v_id = jack_starter.get_pair().value_id;
1995  if (v_id == "autostart") {
1996  return jack->gx_jack_connection(true, true, wait_after_connect, options) ? 1 : 0;
1997  }
1998  string cmd;
1999  if (v_id == "other") {
2000  cmd = machine.get_parameter("ui.jack_starter").getString().get_value();
2001  if (cmd.empty()) {
2002  return -1;
2003  }
2004  } else if (v_id == "qjackctl") {
2005  wait_after_connect = 500000;
2006  cmd = "qjackctl --start";
2007  } else {
2008  assert(false);
2009  }
2010  gx_system::gx_system_call(cmd, true, true);
2011  for (int i = 0; i < 10; i++) {
2012  if (jack->gx_jack_connection(true,false,wait_after_connect, options)) {
2013  return 1;
2014  }
2015  usleep(500000);
2016  }
2018  _("main"),
2019  string(_("I really tried to get jack up and running, sorry ... ")));
2020  return 0;
2021 }
2022 
2023 bool MainWindow::connect_jack(bool v, Gtk::Window *splash) {
2024  gx_jack::GxJack *jack = machine.get_jack();
2025  if (!jack) {
2026  return false;
2027  }
2028  if (jack->gx_jack_connection(v, false, 0, options)) {
2029  return true;
2030  }
2031  if (!v) {
2032  gx_print_error(_("main"), _("can't disconnect jack"));
2033  return false;
2034  }
2035  bool ask = machine.get_parameter_value<bool>("ui.ask_for_jack_starter");
2036  if (!ask) {
2037  switch (start_jack()) {
2038  case 1: return true; // connected
2039  case -1: return false; // no starter, do nothing
2040  default: break; // failed, ask user
2041  }
2042  }
2043  if (splash) {
2044  splash->hide();
2045  }
2046  if (!gx_gui::gx_start_jack_dialog(gx_head_icon)) {
2047  gx_print_warning(_("main"), string(_("Ignoring jackd ...")));
2048  return false;
2049  }
2050  return start_jack() == 1;
2051 }
2052 
2053 void MainWindow::on_jack_client_changed() {
2054  if (!window) {
2055  return;
2056  }
2057  gx_jack::GxJack *jack = machine.get_jack();
2058  if (!jack) {
2059  return;
2060  }
2061  bool v = (jack->client != 0);
2062  if (!v) {
2064  }
2065  actions.jackserverconnection->set_active(v);
2066  Glib::ustring s = "Guitarix: ";
2067  if (v) {
2068  s += jack->get_instancename();
2069  } else {
2070  s += "("+jack->get_instancename()+")";
2071  }
2072  window->set_title(s);
2073  actions.jack_latency_menu->set_sensitive(v);
2074  actions.engine_mute->set_sensitive(v);
2075  actions.engine_bypass->set_sensitive(v);
2076  status_image->set_sensitive(v);
2077  if (!v) {
2078  jackd_image->set(pixbuf_jack_disconnected);
2079  } else {
2080  jackd_image->set(pixbuf_jack_connected);
2081  }
2082 }
2083 
2084 void MainWindow::on_engine_state_change(gx_engine::GxEngineState state) {
2085  switch (state) {
2086  case gx_engine::kEngineOff:
2087  actions.engine_mute_conn.block();
2088  actions.engine_mute->set_active(true);
2089  actions.engine_mute_conn.unblock();
2090  status_image->set(pixbuf_off);
2091  machine.msend_midi_cc(0xB0,120,127,3);
2092  break;
2093  case gx_engine::kEngineOn:
2094  actions.engine_mute_conn.block();
2095  actions.engine_bypass_conn.block();
2096  actions.engine_mute->set_active(false);
2097  actions.engine_bypass->set_active(false);
2098  actions.engine_mute_conn.unblock();
2099  actions.engine_bypass_conn.unblock();
2100  status_image->set(pixbuf_on);
2101  machine.msend_midi_cc(0xB0,120,0,3);
2102  break;
2104  actions.engine_mute_conn.block();
2105  actions.engine_bypass_conn.block();
2106  actions.engine_mute->set_active(false);
2107  actions.engine_bypass->set_active(true);
2108  actions.engine_mute_conn.unblock();
2109  actions.engine_bypass_conn.unblock();
2110  status_image->set(pixbuf_bypass);
2111  break;
2112  }
2113 }
2114 
2115 void MainWindow::set_tuning(Gxw::RackTuner& tuner) {
2116  static struct TuningTab {
2117  const char *name;
2118  const char* key;
2119  bool flat;
2120  int notes[6];
2121  } tuning_tab[] = {
2122  { "Standard", "E", false, {40, 45, 50, 55, 59, 64}},
2123  { "Standard/Es", "Es", true, {39, 44, 49, 54, 58, 63}},
2124  { "Open E", "E", false, {40, 47, 52, 56, 59, 64}},
2125  { "Drop D", "D", false, {38, 45, 50, 55, 59, 64}},
2126  { "Half Step Down", "E", false, {39, 44, 49, 54, 58, 63}},
2127  { "Full Step Down", "D", false, {38, 43, 48, 53, 57, 62}},
2128  { "1 and 1/2 Steps Down", "E", false, {37, 42, 47, 52, 56, 61}},
2129  { "Double Drop D", "D", false, {38, 45, 50, 55, 59, 62}},
2130  { "Drop C", "C", false, {36, 43, 48, 53, 57, 62}},
2131  { "Drop C#", "C#", false, {37, 44, 49, 54, 58, 63}},
2132  { "Drop B", "B", false, {35, 42, 47, 52, 56, 61}},
2133  { "Drop A#", "A#", false, {34, 41, 46, 51, 55, 60}},
2134  { "Drop A", "A", false, {33, 40, 45, 50, 54, 59}},
2135  { "Open D", "D", false, {38, 45, 50, 54, 57, 62}},
2136  { "Open D Minor", "D", false, {38, 45, 50, 53, 57, 62}},
2137  { "Open G", "G", false, {38, 43, 50, 55, 59, 62}},
2138  { "Open G Minor", "G", false, {38, 43, 50, 55, 58, 62}},
2139  { "Open C", "C", false, {36, 43, 48, 55, 60, 64}},
2140  { "Open C#", "C#", false, {37, 42, 59, 52, 56, 61}},
2141  { "Open C Minor", "C", false, {36, 43, 48, 55, 60, 63}},
2142  { "Open E7", "E7", false, {40, 44, 50, 52, 59, 64}},
2143  { "Open E Minor7", "E", false, {40, 47, 50, 55, 59, 64}},
2144  { "Open G Major7", "G", false, {38, 43, 50, 54, 59, 62}},
2145  { "Open A Minor", "A", false, {40, 45, 52, 57, 60, 64}},
2146  { "Open A Minor7", "A", false, {40, 45, 52, 55, 60, 64}},
2147  { "Open A", "A", false, {40, 45, 49, 52, 57, 64}},
2148  { "C Tuning", "C", false, {36, 41, 46, 51, 55, 60}},
2149  { "C# Tuning", "C#", false, {37, 42, 47, 52, 56, 61}},
2150  { "Bb Tuning", "Bb", false, {34, 39, 44, 49, 53, 58}},
2151  { "A to A (Baritone)", "A", false, {33, 38, 43, 48, 52, 57}},
2152  { "Open Dsus2", "D", false, {38, 45, 50, 55, 57, 62}},
2153  { "Open Gsus2", "G", false, {38, 43, 50, 55, 60, 62}},
2154  { "G6", "G6", false, {38, 43, 50, 55, 59, 64}},
2155  { "Modal G", "G", false, {38, 43, 50, 55, 60, 62}},
2156  { "Overtone", "E", false, {48, 52, 55, 58, 60, 62}},
2157  { "Pentatonic", "E", false, {45, 48, 50, 52, 55, 69}},
2158  { "Minor Third", "E", false, {48, 51, 54, 57, 60, 63}},
2159  { "Major Third", "E", false, {48, 52, 56, 60, 64, 68}},
2160  { "All Fourths", "E", false, {40, 45, 50, 55, 60, 65}},
2161  { "Augmented Fourths", "E", false, {36, 42, 48, 54, 60, 66}},
2162  { "Slow Motion", "E", false, {38, 43, 50, 53, 60, 62}},
2163  { "Admiral", "E", false, {36, 43, 50, 55, 59, 60}},
2164  { "Buzzard", "E", false, {36, 41, 48, 55, 58, 65}},
2165  { "Face", "E", false, {36, 43, 50, 55, 57, 62}},
2166  { "Four and Twenty", "E", false, {38, 45, 50, 50, 57, 62}},
2167  { "Ostrich", "E", false, {38, 50, 50, 50, 62, 62}},
2168  { "Capo 200", "E", false, {36, 43, 50, 51, 62, 63}},
2169  { "Balalaika", "E", false, {40, 45, 50, 52, 52, 57}},
2170  { "Cittern One", "E", false, {36, 41, 48, 55, 60, 62}},
2171  { "Cittern Two", "E", false, {36, 43, 48, 55, 60, 67}},
2172  { "Dobro", "E", false, {43, 47, 50, 55, 59, 62}},
2173  { "Lefty", "E", false, {64, 59, 55, 50, 45, 40}},
2174  { "Mandoguitar", "E", false, {36, 43, 50, 57, 64, 71}},
2175  { "Rusty Cage", "E", false, {35, 45, 50, 55, 59, 64}},
2176  { "Hardcore", "C", false, {36, 43, 48, 53, 57, 58}},
2177  };
2178  int mode = tuner_tuning->get_value();
2179  tuner.clear_notes();
2180  if (mode > 0) {
2181  tuner.set_display_flat(tuning_tab[mode-1].flat);
2182  for (int i = 0; i < 6; ++i) {
2183  tuner.push_note(tuning_tab[mode-1].notes[i], 69, 12);
2184  }
2185  } else {
2186  tuner.set_display_flat(false);
2187  }
2188 }
2189 
2190 void MainWindow::set_tuner_tet(Gxw::RackTuner& tuner) {
2191  Glib::ustring tet = options.get_tuner_tet();
2192  int t = 0;
2193  if (tet.find("12") !=Glib::ustring::npos) t=0;
2194  else if (tet.find("19") !=Glib::ustring::npos) t=1;
2195  else if (tet.find("24") !=Glib::ustring::npos) t=2;
2196  else if (tet.find("31") !=Glib::ustring::npos) t=3;
2197  else if (tet.find("53") !=Glib::ustring::npos) t=4;
2198  else t = tuner_temperament->get_value();
2199  machine.set_parameter_value("racktuner.temperament", t);
2200  tuner.set_temperament(tuner_temperament->get_value());
2201  set_tuning(tuner);
2202 }
2203 
2204 void MainWindow::set_tuner_ref(Gxw::RackTuner& tuner) {
2205  Glib::ustring ref = options.get_tuner_ref();
2206  float t = atof(ref.c_str());
2207  machine.set_parameter_value("ui.tuner_reference_pitch", t);
2208  tuner.set_reference_pitch(tuner_reference_pitch->get_value());
2209  set_tuning(tuner);
2210 }
2211 
2212 void MainWindow::setup_tuner_temperament(Gxw::RackTuner& tuner) {
2213  tuner.set_temperament(tuner_temperament->get_value());
2214  set_tuning(tuner);
2215 }
2216 
2217 void MainWindow::setup_tuner(Gxw::RackTuner& tuner) {
2218  tuner.signal_frequency_poll().connect(
2219  sigc::compose(
2220  sigc::mem_fun(tuner, &Gxw::RackTuner::set_freq),
2221  sigc::mem_fun(machine, &gx_engine::GxMachineBase::get_tuner_freq)));
2222  tuner_mode->signal_value_changed().connect(
2223  sigc::compose(
2224  sigc::mem_fun(tuner, &Gxw::RackTuner::set_streaming),
2225  sigc::mem_fun(*tuner_mode, &Gxw::Selector::get_value)));
2226  tuner_reference_pitch->signal_value_changed().connect(
2227  sigc::compose(
2228  sigc::mem_fun(tuner, &Gxw::RackTuner::set_reference_pitch),
2229  sigc::mem_fun(*tuner_reference_pitch, &Gxw::ValueDisplay::get_value)));
2230  tuner_tuning->signal_value_changed().connect(
2231  sigc::bind(sigc::mem_fun(*this, &MainWindow::set_tuning), sigc::ref(tuner)));
2232  tuner_temperament->signal_value_changed().connect(
2233  sigc::bind(sigc::mem_fun(*this, &MainWindow::setup_tuner_temperament), sigc::ref(tuner)));
2234  tuner.set_temperament(tuner_temperament->get_value());
2235 }
2236 
2237 bool MainWindow::on_toggle_mute(GdkEventButton* ev) {
2238  if (ev->type == GDK_BUTTON_PRESS && ev->button == 1) {
2239  if (machine.get_state() == gx_engine::kEngineOff) {
2240  machine.set_state(gx_engine::kEngineOn);
2241  } else {
2242  machine.set_state(gx_engine::kEngineOff);
2243  }
2244  }
2245  return true;
2246 }
2247 
2248 bool MainWindow::on_scroll_toggle(GdkEventScroll* ev) {
2249  if (ev->direction == GDK_SCROLL_UP) {
2250  if (machine.get_state() == gx_engine::kEngineOff) {
2251  machine.set_state(gx_engine::kEngineOn);
2252  } else if (machine.get_state() == gx_engine::kEngineOn) {
2253  machine.set_state(gx_engine::kEngineBypass);
2254  } else {
2255  machine.set_state(gx_engine::kEngineOff);
2256  }
2257  } else if (ev->direction == GDK_SCROLL_DOWN) {
2258  if (machine.get_state() == gx_engine::kEngineOff) {
2259  machine.set_state(gx_engine::kEngineBypass);
2260  } else if (machine.get_state() == gx_engine::kEngineBypass) {
2261  machine.set_state(gx_engine::kEngineOn);
2262  } else {
2263  machine.set_state(gx_engine::kEngineOff);
2264  }
2265  }
2266 
2267  return true;
2268 }
2269 
2270 bool MainWindow::on_toggle_insert(GdkEventButton* ev) {
2271  if (ev->type == GDK_BUTTON_PRESS && ev->button == 1) {
2272  if (machine.get_parameter_value<bool>("engine.insert")) {
2273  machine.set_parameter_value("engine.insert",false);
2274  } else {
2275  machine.set_parameter_value("engine.insert",true);
2276  }
2277  }
2278  return true;
2279 }
2280 
2281 bool MainWindow::on_scroll_toggle_insert(GdkEventScroll* ev) {
2282  if (machine.get_parameter_value<bool>("engine.insert")) {
2283  machine.set_parameter_value("engine.insert",false);
2284  } else {
2285  machine.set_parameter_value("engine.insert",true);
2286  }
2287  return true;
2288 }
2289 
2290 void MainWindow::on_insert_jack_changed(bool s) {
2291  if (s) {
2292  insert_image->set(pixbuf_insert_off);
2293  } else {
2294  insert_image->set(pixbuf_insert_on);
2295  }
2296 }
2297 
2298 bool MainWindow::on_jackserverconnection(GdkEventButton* ev) {
2299  if (ev->type == GDK_BUTTON_PRESS && ev->button == 1) {
2300  bool v = actions.jackserverconnection->get_active();
2301  actions.jackserverconnection->set_active(!v);
2302  }
2303  return true;
2304 }
2305 
2306 bool MainWindow::on_jackserverconnection_scroll(GdkEventScroll* ev) {
2307  bool v = actions.jackserverconnection->get_active();
2308  actions.jackserverconnection->set_active(!v);
2309  return true;
2310 }
2311 
2312 void MainWindow::on_msg_level_changed() {
2313  switch (fLoggingWindow.get_unseen_msg_level()) {
2314  case GxLogger::kWarning: logstate_image->set(pixbuf_log_yellow); break;
2315  case GxLogger::kError: logstate_image->set(pixbuf_log_red); break;
2316  default: logstate_image->set(pixbuf_log_grey); break;
2317  }
2318 }
2319 
2320 //static void toggle_action(Glib::RefPtr<Gtk::ToggleAction> act) {
2321 // act->set_active(!act->get_active());
2322 //}
2323 
2324 void MainWindow::on_ampdetail_switch(bool compress, bool setparam) {
2325  if (compress) {
2326  ampdetail_normal->hide();
2327  ampdetail_mini->show();
2328  } else {
2329  ampdetail_mini->hide();
2330  ampdetail_normal->show();
2331  }
2332  if (setparam) {
2333  machine.set_parameter_value("ui.mp_s_h", compress);
2334  }
2335 }
2336 
2337 /****************************************************************
2338  ** oscilloscope handling
2339  */
2340 
2341 void MainWindow::set_osc_size() {
2342  //int osc_size = engine.oscilloscope.get_mul_buffer();
2343  if (options.mul_buffer > 0) {
2344  actions.osc_buffer_size->set_current_value(options.mul_buffer);
2345  }
2346 }
2347 
2348 void MainWindow::change_osc_buffer(Glib::RefPtr<Gtk::RadioAction> action) {
2349  gx_jack::GxJack *jack = machine.get_jack();
2350  if (!jack || jack->client) {
2351  options.mul_buffer = action->get_current_value();
2352  on_oscilloscope_activate(false);
2353  machine.set_oscilloscope_mul_buffer(options.mul_buffer);
2354  on_oscilloscope_activate(true);
2355  } else {
2356  set_osc_size();
2357  }
2358 }
2359 
2360 void MainWindow::add_osc_size_menu() {
2361  Glib::ustring s = "<menubar><menu action=\"OptionsMenu\"><menu action=\"OscBuffer\">";
2362  Gtk::RadioButtonGroup group;
2363  int osc_buffer_size = 1;
2364  for (int i = 1; i <= 6; ++i) {
2365  Glib::ustring name = "*" + gx_system::to_string(osc_buffer_size);
2366  Glib::ustring actname = Glib::ustring::compose("buffer size %1", name);
2367  s += Glib::ustring::compose("<menuitem action=\"%1\"/>", actname);
2368  Glib::RefPtr<Gtk::RadioAction> action = Gtk::RadioAction::create(group, actname, name);
2369  actions.group->add(action);
2370  if (i == 1) {
2371  action->signal_changed().connect(
2372  sigc::mem_fun(*this, &MainWindow::change_osc_buffer));
2373  actions.osc_buffer_size = action;
2374  }
2375  action->property_value().set_value(osc_buffer_size);
2376  osc_buffer_size++;
2377  }
2378  s.append("</menu></menu></menubar>");
2379  uimanager->add_ui_from_string(s);
2380 }
2381 
2382 void MainWindow::on_show_oscilloscope(bool v) {
2383  if (v) {
2384  // FIXME G_PRIORITY_DEFAULT_IDLE??
2385  Glib::signal_timeout().connect(
2386  sigc::mem_fun(*this, &MainWindow::on_refresh_oscilloscope), 60);
2387  }
2388 }
2389 
2390 void MainWindow::set_waveview_buffer(unsigned int size) {
2391  fWaveView.set_frame(machine.get_oscilloscope_buffer(), size);
2392 }
2393 
2394 void MainWindow::on_oscilloscope_post_pre(int post_pre) {
2395  // if (post_pre) {
2396  // fWaveView.set_multiplicator(150.,250.);
2397  // } else {
2398  fWaveView.set_multiplicator(20.,60.);
2399  // }
2400 }
2401 
2402 int MainWindow::on_oscilloscope_activate(bool start) {
2403  if (!start) {
2404  machine.clear_oscilloscope_buffer();
2405  fWaveView.queue_draw();
2406  }
2407  return 0;
2408 }
2409 
2410 bool MainWindow::on_refresh_oscilloscope() {
2411  int load, frames;
2412  bool is_rt;
2413  jack_nframes_t bsize;
2414  machine.get_oscilloscope_info(load, frames, is_rt, bsize);
2415  static struct {
2416  int load, frames;
2417  jack_nframes_t bsize;
2418  bool rt;
2419  } oc;
2420  if (!oc.bsize || oc.load != load) {
2421  oc.load = load;
2422  fWaveView.set_text(
2423  (boost::format(_("DSP Load %1% %%")) % oc.load).str().c_str(),
2424  Gtk::CORNER_TOP_LEFT);
2425  }
2426  if (!oc.bsize || oc.frames != frames) {
2427  oc.frames = frames;
2428  fWaveView.set_text(
2429  (boost::format(_("HT Frames %1%")) % oc.frames).str().c_str(),
2430  Gtk::CORNER_BOTTOM_LEFT);
2431  }
2432  if (!oc.bsize || oc.rt != is_rt) {
2433  oc.rt = is_rt;
2434  fWaveView.set_text(
2435  oc.rt ? _("RT Mode YES ") : _("RT mode <span color=\"#cc1a1a\">NO</span>"),
2436  Gtk::CORNER_BOTTOM_RIGHT);
2437  }
2438  if (!oc.bsize || oc.bsize != bsize) {
2439  oc.bsize = bsize;
2440  fWaveView.set_text(
2441  (boost::format(_("Latency %1%")) % oc.bsize).str().c_str(),
2442  Gtk::CORNER_TOP_RIGHT);
2443  }
2444  fWaveView.queue_draw();
2445  return machine.oscilloscope_plugin_box_visible();
2446 }
2447 
2448 /* --------- calculate power (percent) to decibel -------- */
2449 // Note: could use fast_log10 (see ardour code) to make it faster
2450 inline float power2db(float power) {
2451  return 20.*log10(power);
2452 }
2453 
2454 bool MainWindow::refresh_meter_level(float falloff) {
2455  const unsigned int channels = sizeof(fastmeter)/sizeof(fastmeter[0]);
2456  gx_jack::GxJack *jack = machine.get_jack();
2457  if (jack && !jack->client) {
2458  return true;
2459  }
2460 
2461  // Note: removed RMS calculation, we will only focus on max peaks
2462  static float old_peak_db[channels] = {-INFINITY, -INFINITY};
2463 
2464  // fill up from engine buffers
2465  float level[channels];
2466  machine.maxlevel_get(channels, level);
2467  for (unsigned int c = 0; c < channels; c++) {
2468  // update meters (consider falloff as well)
2469  // calculate peak dB and translate into meter
2470  float peak_db = -INFINITY;
2471  if (level[c] > 0) {
2472  peak_db = power2db(level[c]);
2473  }
2474  // retrieve old meter value and consider falloff
2475  if (peak_db < old_peak_db[c]) {
2476  peak_db = max(peak_db, old_peak_db[c] - falloff);
2477  }
2478  fastmeter[c]->set(log_meter(peak_db));
2479  old_peak_db[c] = peak_db;
2480  }
2481  return true;
2482 }
2483 
2484 bool MainWindow::survive_jack_shutdown() {
2485  gx_jack::GxJack *jack = machine.get_jack();
2486  if (!jack) {
2487  return false;
2488  }
2489  // return if jack is not down
2490  if (gx_system::gx_system_call("pgrep jackd", true) == SYSTEM_OK) {
2491  if (jack->is_jack_down()) {
2492  sleep(2);
2493  jack->set_jack_down(false);
2494  }
2495  // let's make sure we get out of here
2496  gx_print_warning("Jack Shutdown",
2497  _("jack has bumped us out!! "));
2498  actions.jackserverconnection->set_active(true);
2499  // run only one time whem jackd is running
2500  return false;
2501  } else if (!jack->is_jack_down()) {
2502  // refresh some stuff. Note that it can be executed
2503  // more than once, no harm here
2504  actions.jackserverconnection->set_active(false);
2505  jack->set_jack_down(true);
2506  gx_print_error("Jack Shutdown",
2507  _("jack has bumped us out!! "));
2508  }
2509  // run as long jackd is down
2510  return true;
2511 }
2512 
2513 void MainWindow::gx_jack_is_down() {
2514  actions.jackserverconnection->set_active(false);
2515  Glib::signal_timeout().connect(
2516  sigc::mem_fun(*this, &MainWindow::survive_jack_shutdown),
2517  200, Glib::PRIORITY_LOW);
2518 }
2519 
2520 #ifdef HAVE_JACK_SESSION
2521 void MainWindow::jack_session_event() {
2522  gx_jack::GxJack *jack = machine.get_jack();
2523  if (!jack) {
2524  return;
2525  }
2526  const char *statefile = "gx_head.state";
2527  jack_session_event_t *event = jack->get_last_session_event();
2528  set_in_session();
2529  machine.set_statefilename(string(event->session_dir) + statefile);
2530  machine.save_to_state();
2531 
2532 #ifndef NDEBUG
2533  string cmd(options.get_path_to_program());
2534 #else
2535  string cmd("guitarix");
2536 #endif
2537  cmd += " -U ";
2538  cmd += event->client_uuid;
2539  cmd += " -A ";
2540  cmd += jack->get_uuid_insert();
2541  cmd += " -f ${SESSION_DIR}";
2542  cmd += statefile; // no space after SESSION_DIR
2543  event->command_line = strdup(cmd.c_str());
2544 
2545  JackSessionEventType tp = event->type;
2546  if (jack->return_last_session_event() == 0) {
2547  if (tp == JackSessionSaveAndQuit) {
2548  GxExit::get_instance().exit_program("** session exit **");
2549  }
2550  }
2551 }
2552 
2553 void MainWindow::jack_session_event_ins() {
2554  gx_jack::GxJack *jack = machine.get_jack();
2555  if (!jack) {
2556  return;
2557  }
2558  jack_session_event_t *event = jack->get_last_session_event_ins();
2559  set_in_session();
2560  event->command_line = strdup("true ${SESSION_DIR}");
2561  JackSessionEventType tp = event->type;
2562  if (jack->return_last_session_event_ins() == 0) {
2563  if (tp == JackSessionSaveAndQuit) {
2564  GxExit::get_instance().exit_program("** session exit **");
2565  }
2566  }
2567 }
2568 #endif
2569 
2570 void MainWindow::set_in_session() {
2571  if (!in_session) {
2572  in_session = true;
2573  // it seems in a session we generally don't know
2574  // where to save and from where to recall data
2575  // it's all controlled by the session manager
2576  machine.disable_autosave(true);
2577  }
2578 }
2579 
2580 void MainWindow::systray_menu(guint button, guint32 activate_time) {
2581  Gtk::Menu *menu = dynamic_cast<Gtk::MenuItem*>(uimanager->get_widget("/menubar/EngineMenu"))->get_submenu();
2582  menu->popup(2, gtk_get_current_event_time());
2583 }
2584 
2585 void MainWindow::overload_status_changed(gx_engine::MidiAudioBuffer::Load l) {
2586  switch (l) {
2588  status_icon->set(gx_head_midi);
2589  break;
2592  status_icon->set(gx_head_icon);
2593  break;
2595  status_icon->set(gx_head_warn);
2596  break;
2597  default:
2598  assert(false);
2599  }
2600 }
2601 
2602 bool MainWindow::on_window_state_changed(GdkEventWindowState* event) {
2603  if (event->changed_mask & event->new_window_state & (Gdk::WINDOW_STATE_ICONIFIED|Gdk::WINDOW_STATE_WITHDRAWN)) {
2604  window->get_window()->get_root_origin(options.mainwin_x, options.mainwin_y);
2605  }
2606  return false;
2607 }
2608 
2609 void MainWindow::hide_extended_settings() {
2610  if (!is_visible ||
2611  (window->get_window()->get_state()
2612  & (Gdk::WINDOW_STATE_ICONIFIED|Gdk::WINDOW_STATE_WITHDRAWN))) {
2613  window->move(options.mainwin_x, options.mainwin_y);
2614  window->present();
2615  //window->deiconify();
2616  } else {
2617  window->hide();
2618  //window->iconify();
2619  }
2620 }
2621 
2622 //bool MainWindow::ui_sleep() {
2623 // usleep(1900);
2624  //cout<<"timeout"<<endl;
2625 // return true;
2626 //}
2627 
2629  int port = options.get_rpcport();
2630  if (machine.get_jack() && port != RPCPORT_DEFAULT && port != RPCPORT_NONE) {
2631  machine.start_socket(sigc::ptr_fun(Gtk::Main::quit), options.get_rpcaddress(), port);
2632  window->show();
2633  if (options.get_liveplaygui()) liveplay_button->set_active();
2634  Gtk::Main::run();
2635  } else {
2636  window->show();
2637  if (options.get_liveplaygui()) liveplay_button->set_active();
2638  // Glib::signal_timeout().connect (mem_fun (*this, &MainWindow::ui_sleep), 2);
2639  Gtk::Main::run();
2640  }
2641 }
2642 
2643 bool MainWindow::on_meter_button_release(GdkEventButton* ev) {
2644  if (ev->button == 1) {
2645  for (unsigned int i = 0; i < sizeof(fastmeter)/sizeof(fastmeter[0]); i++) {
2646  fastmeter[i]->clear();
2647  }
2648  return true;
2649  }
2650  return false;
2651 }
2652 
2653 void MainWindow::display_preset_msg(const Glib::ustring& bank, const Glib::ustring& preset) {
2654  preset_status->set_text(bank + " / " + preset);
2655 }
2656 
2657 bool MainWindow::on_key_press_event(GdkEventKey *event) {
2658  if ((event->state & Gtk::AccelGroup::get_default_mod_mask()) != 0) {
2659  return false;
2660  }
2661  if (event->keyval >= GDK_KEY_0 && event->keyval <= GDK_KEY_9) {
2662  keyswitch.process_preset_key(event->keyval - GDK_KEY_0);
2663  return true;
2664  }
2665  if (event->keyval >= GDK_KEY_KP_0 && event->keyval <= GDK_KEY_KP_9) {
2666  keyswitch.process_preset_key(event->keyval - GDK_KEY_KP_0);
2667  return true;
2668  }
2669  if (event->keyval >= GDK_KEY_a && event->keyval <= GDK_KEY_z) {
2670  keyswitch.process_bank_key(event->keyval - GDK_KEY_a);
2671  return true;
2672  }
2673  return false;
2674 }
2675 
2676 bool MainWindow::on_quit() {
2677  if (ladspalist_window && !ladspalist_window->check_exit()) {
2678  return true;
2679  }
2680  machine.stop_socket();
2681  Gtk::Main::quit();
2682  return false;
2683 }
2684 
2685 void MainWindow::amp_controls_visible(Gtk::Range *rr) {
2686  //FIXME
2687  bool v = std::abs(rr->get_value() - machine.get_parameter("tube.select").getUpperAsFloat()) < 0.5;
2688  const char *knobs1[] = {"gxmediumknobpregain","gxmediumknobdrive","gxmediumknobdist","gxmediumknobgain", "labelpregain:effekt_label", "labeldrive:effekt_label", "labeldist:effekt_label", "labelgain:effekt_label"};
2689  const char *knobs2[] = {"gxbigknobgain", "labelgain2:effekt_label"};
2690  for (unsigned int i = 0; i < sizeof(knobs1)/sizeof(knobs1[1]); ++i) {
2691  Gtk::Widget *w;
2692  bld->find_widget(knobs1[i], w);
2693  w->set_visible(!v);
2694  }
2695  for (unsigned int i = 0; i < sizeof(knobs2)/sizeof(knobs2[1]); ++i) {
2696  Gtk::Widget *w;
2697  bld->find_widget(knobs2[i], w);
2698  w->set_visible(v);
2699  }
2700 }
2701 
2703  Gtk::Window *splash, const Glib::ustring& title)
2704  : sigc::trackable(),
2705  options(options_),
2706  machine(machine_),
2707  bld(),
2708  freezer(),
2709  plugin_dict(),
2710  oldpos(0),
2711  scrl_size_x(-1),
2712  scrl_size_y(-1),
2713  monorackcontainer(PLUGIN_TYPE_MONO, *this),
2714  stereorackcontainer(PLUGIN_TYPE_STEREO, *this),
2715  pre_act(false),
2716  is_visible(false),
2717  drag_icon(0),
2718  preset_list_menu_bank(),
2719  preset_list_merge_id(0),
2720  preset_list_actiongroup(),
2721  uimanager(),
2722  live_play(),
2723  preset_window(),
2724  fWaveView(),
2725  convolver_filename_label(),
2726  convolver_mono_filename_label(),
2727  gx_head_icon(Gdk::Pixbuf::create_from_file(options.get_pixmap_filepath("gx_head.png"))),
2728  boxbuilder(machine_, fWaveView, convolver_filename_label, convolver_mono_filename_label, gx_head_icon),
2729  portmap_window(0),
2730  select_jack_control(0),
2731  fLoggingWindow(),
2732  amp_radio_menu(machine_, "tube.select"),
2733  pixbuf_insert_on(Gdk::Pixbuf::create_from_file(options.get_pixmap_filepath("insert_on.png"))),
2734  pixbuf_insert_off(Gdk::Pixbuf::create_from_file(options.get_pixmap_filepath("insert_off.png"))),
2735  pixbuf_on(Gdk::Pixbuf::create_from_file(options.get_pixmap_filepath("gx_on.png"))),
2736  pixbuf_off(Gdk::Pixbuf::create_from_file(options.get_pixmap_filepath("gx_off.png"))),
2737  pixbuf_bypass(Gdk::Pixbuf::create_from_file(options.get_pixmap_filepath("gx_bypass.png"))),
2738  pixbuf_jack_connected(Gdk::Pixbuf::create_from_file(options.get_pixmap_filepath("jackd_on.png"))),
2739  pixbuf_jack_disconnected(Gdk::Pixbuf::create_from_file(options.get_pixmap_filepath("jackd_off.png"))),
2740  pixbuf_log_grey(Gdk::Pixbuf::create_from_file(options.get_pixmap_filepath("gx_log_grey.png"))),
2741  pixbuf_log_yellow(Gdk::Pixbuf::create_from_file(options.get_pixmap_filepath("gx_log_yellow.png"))),
2742  pixbuf_log_red(Gdk::Pixbuf::create_from_file(options.get_pixmap_filepath("gx_log_red.png"))),
2743  in_session(false),
2744  status_icon(Gtk::StatusIcon::create(gx_head_icon)),
2745  gx_head_midi(Gdk::Pixbuf::create_from_file(options.get_pixmap_filepath("gx_head-midi.png"))),
2746  gx_head_warn(Gdk::Pixbuf::create_from_file(options.get_pixmap_filepath("gx_head-warn.png"))),
2747  actions(),
2748  keyswitch(machine, sigc::mem_fun(this, &MainWindow::display_preset_msg)),
2749  groupmap(),
2750  ladspalist_window(),
2751  szg_rack_units(Gtk::SizeGroup::create(Gtk::SIZE_GROUP_HORIZONTAL)) {
2752 
2753  convolver_filename_label.set_ellipsize(Pango::ELLIPSIZE_END);
2754  convolver_mono_filename_label.set_ellipsize(Pango::ELLIPSIZE_END);
2755 
2756  /*
2757  ** create actions and some parameters
2758  */
2759  create_actions();
2760 
2761  /*
2762  ** load key accelerator table and glade window definition
2763  **
2764  ** at this point all parameters that are used in the main window glade file must be defined
2765  */
2766  Gtk::AccelMap::load(options.get_builder_filepath("accels_rc"));
2767 
2768  const char *id_list[] = { "MainWindow", "amp_background:ampbox", "bank_liststore", "target_liststore",
2769  "bank_combo_liststore", 0 };
2770  bld = gx_gui::GxBuilder::create_from_file(options_.get_builder_filepath("mainpanel.glade"), &machine, id_list);
2771  load_widget_pointers();
2772  rackcontainer->set_homogeneous(true); // setting it in glade is awkward to use with glade tool
2773  szg_rack_units->add_widget(*ampdetail_mini);
2774  szg_rack_units->add_widget(*ampdetail_normal);
2775 
2776  // remove marker labels from boxes (used in glade to make display clearer)
2777  clear_box(*monocontainer);
2778  clear_box(*stereorackcontainerH);
2779  clear_box(*stereorackcontainerV);
2780  clear_box(*preset_box_no_rack);
2781 
2782  // create left column for equal width
2783  left_column = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
2784  Gtk::ScrolledWindow *swe;
2785  bld->find_widget("scrolledwindow_effects", swe);
2786  gtk_size_group_add_widget(left_column, GTK_WIDGET(swe->gobj()));
2787  Gtk::Button *pb;
2788  bld->find_widget("presets:barbutton", pb);
2789  gtk_size_group_add_widget(left_column, GTK_WIDGET(pb->gobj()));
2790 
2791  // preset window also creates some actions
2792  preset_window = new PresetWindow(bld, machine, options, actions, left_column);
2793 
2794  // create uimanager and load menu
2795  uimanager = Gtk::UIManager::create();
2796  uimanager->insert_action_group(actions.group);
2797  uimanager->add_ui_from_file(options.get_builder_filepath("menudef.xml"));
2798 
2799  // add dynamic submenus
2800  if (!options.get_clear_rc()) {
2801  add_skin_menu();
2802  }
2803  add_latency_menu();
2804  add_osc_size_menu();
2805  amp_radio_menu.setup("<menubar><menu action=\"TubeMenu\">","</menu></menubar>",uimanager,actions.group);
2806 
2807  // add menubar, accelgroup and icon to main window
2808  Gtk::Widget *menubar = uimanager->get_widget("/menubar");
2809  actions.accels = uimanager->get_accel_group();
2810  menubox->pack_start(*menubar);
2811  window->add_accel_group(actions.accels);
2812  window->set_icon(gx_head_icon);
2813  boxbuilder.set_accelgroup(actions.accels);
2814 
2815  /*
2816  ** connect main window signals
2817  */
2818  window->signal_window_state_event().connect(
2819  sigc::mem_fun(*this, &MainWindow::on_window_state_changed));
2820  window->signal_delete_event().connect(
2821  sigc::hide(sigc::mem_fun(this, &MainWindow::on_quit)));
2822  window->signal_configure_event().connect_notify(
2823  sigc::mem_fun(*this, &MainWindow::on_configure_event));
2824  window->signal_visibility_notify_event().connect(
2825  sigc::mem_fun(*this, &MainWindow::on_visibility_notify));
2826  window->signal_key_press_event().connect(
2827  sigc::mem_fun(*this, &MainWindow::on_key_press_event));
2828 
2829  /*
2830  ** status icon signal connections
2831  */
2832  status_icon->signal_activate().connect(
2833  sigc::mem_fun(*this, &MainWindow::hide_extended_settings));
2834  status_icon->signal_popup_menu().connect(
2835  sigc::mem_fun(*this, &MainWindow::systray_menu));
2836 
2837  // add rack container
2838  stereorackcontainerV->pack_start(stereorackcontainer, Gtk::PACK_EXPAND_WIDGET);
2839  monocontainer->pack_start(monorackcontainer, Gtk::PACK_EXPAND_WIDGET);
2840 
2841  /*
2842  ** jack, engine, and controller_map signal connections and related settings
2843  */
2845  gx_jack::GxJack *jack = machine.get_jack();
2846  if (jack) {
2847  jack->shutdown.connect(sigc::mem_fun(*this, &MainWindow::gx_jack_is_down));
2848  jack->signal_buffersize_change().connect(
2849  sigc::mem_fun(*this, &MainWindow::set_latency));
2850  jack->signal_client_change().connect(
2851  sigc::mem_fun(*this, &MainWindow::on_jack_client_changed));
2852 #ifdef HAVE_JACK_SESSION
2853  jack->session.connect(sigc::mem_fun(*this, &MainWindow::jack_session_event));
2854  jack->session_ins.connect(sigc::mem_fun(*this, &MainWindow::jack_session_event_ins));
2855  if (!options.get_jack_uuid().empty()) {
2856  set_in_session();
2857  }
2858 #endif
2859  }
2860 
2861  machine.signal_state_change().connect(
2862  sigc::mem_fun(*this, &MainWindow::on_engine_state_change));
2863  machine.signal_jack_load_change().connect(
2864  sigc::mem_fun(*this, &MainWindow::overload_status_changed));
2865  machine.signal_plugin_changed().connect(
2866  sigc::mem_fun(this, &MainWindow::on_plugin_changed));
2867  /*
2868  ** GxSettings signal connections
2869  */
2870  machine.signal_presetlist_changed().connect(
2871  sigc::mem_fun(*this, &MainWindow::rebuild_preset_menu));
2872  machine.signal_selection_changed().connect(
2873  sigc::mem_fun(*this, &MainWindow::show_selected_preset));
2874  machine.signal_selection_changed().connect(
2875  sigc::mem_fun(monorackcontainer, &RackContainer::check_order));
2876  machine.signal_selection_changed().connect(
2877  sigc::mem_fun(stereorackcontainer, &RackContainer::check_order));
2878 
2879  /*
2880  ** DnD setup for effects toolpalette
2881  */
2882  std::vector<Gtk::TargetEntry> listTargets;
2883  listTargets.push_back(Gtk::TargetEntry("application/x-guitarix-mono", Gtk::TARGET_SAME_APP, 1));
2884  listTargets.push_back(Gtk::TargetEntry("application/x-guitarix-stereo", Gtk::TARGET_SAME_APP, 2));
2885  effects_toolpalette->drag_dest_set(listTargets, Gtk::DEST_DEFAULT_ALL, Gdk::ACTION_MOVE);
2886  effects_toolpalette->signal_drag_data_received().connect(sigc::mem_fun(*this, &MainWindow::on_tp_drag_data_received));
2887 
2888  /*
2889  ** init jack connection image widget
2890  */
2891  if (jack) {
2892  jackd_image->set(pixbuf_jack_disconnected);
2893  jackd_image->get_parent()->add_events(Gdk::SCROLL_MASK);
2894  jackd_image->get_parent()->signal_button_press_event().connect(
2895  sigc::mem_fun(*this, &MainWindow::on_jackserverconnection));
2896  jackd_image->get_parent()->signal_scroll_event().connect(
2897  sigc::mem_fun(*this, &MainWindow::on_jackserverconnection_scroll));
2898  //jackd_image->get_parent()->signal_button_press_event().connect(
2899  // sigc::bind_return(
2900  // sigc::group(
2901  // sigc::ptr_fun(toggle_action),
2902  // actions.jackserverconnection),
2903  // true));
2904  } else {
2905  jackd_image->hide();
2906  }
2907 
2908  /*
2909  ** setup racktuner parameter and signals
2910  */
2911  setup_tuner(*racktuner);
2912  tuner_on_off->set_name("effect_on_off");
2913  tuner_on_off->signal_toggled().connect(
2914  sigc::compose(
2915  sigc::mem_fun(*racktuner, &Gxw::RackTuner::set_sensitive),
2916  sigc::mem_fun(*tuner_on_off, &Gxw::Switch::get_active)));
2917  racktuner->signal_poll_status_changed().connect(
2918  sigc::mem_fun(machine, &gx_engine::GxMachineBase::tuner_used_for_display));
2919 
2920  /*
2921  ** oscilloscope signal connections
2922  */
2923  machine.signal_oscilloscope_post_pre().connect(
2924  sigc::mem_fun(*this, &MainWindow::on_oscilloscope_post_pre));
2925  machine.signal_oscilloscope_visible().connect(
2926  sigc::mem_fun(*this, &MainWindow::on_show_oscilloscope));
2927  machine.signal_oscilloscope_activation().connect(
2928  sigc::mem_fun(*this, &MainWindow::on_oscilloscope_activate));
2929  machine.signal_oscilloscope_size_change().connect(
2930  sigc::mem_fun(*this, &MainWindow::set_waveview_buffer));
2931 
2932  /*
2933  ** fastmeter initialization and signal connections
2934  */
2935  for (unsigned int i = 0; i < sizeof(fastmeter)/sizeof(fastmeter[0]); ++i) {
2936  fastmeter[i]->signal_button_release_event().connect(
2937  sigc::mem_fun(*this, &MainWindow::on_meter_button_release));
2938  fastmeter[i]->set_tooltip_text(_("Overall Rack output"));
2939  }
2940  const float meter_falloff = 27; // in dB/sec.
2941  const float meter_display_timeout = 60; // in millisec
2942  const float falloff = meter_falloff * meter_display_timeout * 0.001;
2943  Glib::signal_timeout().connect(
2944  sigc::bind(sigc::mem_fun(this, &MainWindow::refresh_meter_level), falloff),
2945  meter_display_timeout);
2946 
2947  /*
2948  ** amp top box signal connections
2949  */
2950  ampdetail_compress->signal_clicked().connect(
2951  sigc::bind(sigc::mem_fun(*this, &MainWindow::on_ampdetail_switch), true, true));
2952  ampdetail_expand->signal_clicked().connect(
2953  sigc::bind(sigc::mem_fun(*this, &MainWindow::on_ampdetail_switch), false, true));
2954  machine.signal_parameter_value<bool>("ui.mp_s_h").connect(
2955  sigc::bind(sigc::mem_fun(*this, &MainWindow::on_ampdetail_switch), false));
2956 
2957  /*
2958  ** midi out signal connections
2959  */
2960  midi_out_compress->signal_clicked().connect(
2961  sigc::bind(
2962  sigc::mem_fun(actions.midi_out_plug.operator->(), &Gtk::ToggleAction::set_active),
2963  true));
2964  midi_out_expand->signal_clicked().connect(
2965  sigc::bind(
2966  sigc::mem_fun(actions.midi_out_plug.operator->(), &Gtk::ToggleAction::set_active),
2967  false));
2968  midi_out_presets_mini->signal_clicked().connect(
2969  sigc::bind(
2970  sigc::mem_fun1(this, &MainWindow::plugin_preset_popup),
2971  machine.pluginlist_lookup_plugin("midi_out")->get_pdef()));
2972  midi_out_presets_normal->signal_clicked().connect(
2973  sigc::bind(
2974  sigc::mem_fun1(this, &MainWindow::plugin_preset_popup),
2975  machine.pluginlist_lookup_plugin("midi_out")->get_pdef()));
2976  channel1_button->signal_toggled().connect(
2977  sigc::bind(
2978  sigc::mem_fun(this, &MainWindow::on_midi_out_channel_toggled),
2979  channel1_button, channel1_box));
2980  channel2_button->signal_toggled().connect(
2981  sigc::bind(
2982  sigc::mem_fun(this, &MainWindow::on_midi_out_channel_toggled),
2983  channel2_button, channel2_box));
2984  channel3_button->signal_toggled().connect(
2985  sigc::bind(
2986  sigc::mem_fun(this, &MainWindow::on_midi_out_channel_toggled),
2987  channel3_button, channel3_box));
2988 
2989  /*
2990  ** init status image widget
2991  */
2992  status_image->set(pixbuf_on);
2993  status_image->get_parent()->add_events(Gdk::SCROLL_MASK);
2994  gx_gui::connect_midi_controller(status_image->get_parent(), "engine.mute", machine);
2995  status_image->get_parent()->signal_button_press_event().connect(
2996  sigc::mem_fun(*this, &MainWindow::on_toggle_mute));
2997  status_image->get_parent()->signal_scroll_event().connect(
2998  sigc::mem_fun(*this, &MainWindow::on_scroll_toggle));
2999  on_engine_state_change(machine.get_state());
3000 
3001  /*
3002  ** init insert image widget
3003  */
3004  insert_image->set(pixbuf_insert_on);
3005  insert_image->get_parent()->add_events(Gdk::SCROLL_MASK);
3006  gx_gui::connect_midi_controller(insert_image->get_parent(), "engine.insert", machine);
3007  insert_image->get_parent()->signal_button_press_event().connect(
3008  sigc::mem_fun(*this, &MainWindow::on_toggle_insert));
3009  insert_image->get_parent()->signal_scroll_event().connect(
3010  sigc::mem_fun(*this, &MainWindow::on_scroll_toggle_insert));
3011  gx_engine::BoolParameter& ip = machine.get_parameter("engine.insert").getBool();
3012  ip.signal_changed().connect(sigc::mem_fun(*this, &MainWindow::on_insert_jack_changed));
3013 
3014  /*
3015  ** connect buttons with actions
3016  */
3017  gtk_activatable_set_related_action(GTK_ACTIVATABLE(show_rack_button->gobj()), GTK_ACTION(actions.show_rack->gobj()));
3018  gtk_activatable_set_related_action(GTK_ACTIVATABLE(rack_order_h_button->gobj()), GTK_ACTION(actions.rackh->gobj()));
3019  gtk_activatable_set_related_action(GTK_ACTIVATABLE(config_mode_button->gobj()), GTK_ACTION(actions.rack_config->gobj()));
3020  gtk_activatable_set_related_action(GTK_ACTIVATABLE(liveplay_button->gobj()),GTK_ACTION(actions.live_play->gobj()));
3021  gtk_activatable_set_related_action(GTK_ACTIVATABLE(tuner_button->gobj()),GTK_ACTION(actions.tuner->gobj()));
3022  gtk_activatable_set_related_action(GTK_ACTIVATABLE(effects_button->gobj()), GTK_ACTION(actions.show_plugin_bar->gobj()));
3023  gtk_activatable_set_related_action(GTK_ACTIVATABLE(presets_button->gobj()), GTK_ACTION(actions.presets->gobj()));
3024  gtk_activatable_set_related_action(GTK_ACTIVATABLE(compress_button->gobj()), GTK_ACTION(actions.compress->gobj()));
3025  gtk_activatable_set_related_action(GTK_ACTIVATABLE(expand_button->gobj()), GTK_ACTION(actions.expand->gobj()));
3026 
3027  /*
3028  ** setup window initial configuration
3029  */
3030  tunerbox->set_visible(machine.get_parameter_value<bool>("system.show_tuner"));
3031  racktuner->set_sensitive(machine.get_parameter_value<bool>("ui.racktuner"));
3032  actions.show_plugin_bar->set_active(false);
3033 
3034  /*
3035  ** create liveplay and setup liveplay racktuner
3036  */
3037  live_play = new Liveplay(options, machine, options.get_builder_filepath("mainpanel.glade"), actions);
3038  setup_tuner(live_play->get_tuner());
3039  live_play->get_tuner().signal_poll_status_changed().connect(
3040  sigc::mem_fun1(machine, &gx_engine::GxMachineBase::tuner_used_for_display));
3041 
3042  /*
3043  ** init logging window and logstate image widget
3044  */
3045  fLoggingWindow.set_transient_for(*window);
3046  fLoggingWindow.set_icon(gx_head_icon);
3047  fLoggingWindow.signal_msg_level_changed().connect(
3048  sigc::mem_fun(*this, &MainWindow::on_msg_level_changed));
3049  fLoggingWindow.signal_hide().connect(
3050  sigc::bind(
3051  sigc::mem_fun(actions.loggingbox.operator->(), &Gtk::ToggleAction::set_active),
3052  false));
3053  on_msg_level_changed();
3054  logstate_image->get_parent()->add_events(Gdk::SCROLL_MASK);
3055  logstate_image->get_parent()->signal_button_press_event().connect(
3056  sigc::mem_fun(*this, &MainWindow::on_log_activated));
3057  logstate_image->get_parent()->signal_scroll_event().connect(
3058  sigc::mem_fun(*this, &MainWindow::on_log_scrolled));
3059 
3060  //logstate_image->get_parent()->signal_button_press_event().connect(
3061  //sigc::bind_return(
3062  // sigc::group(
3063  // sigc::ptr_fun(toggle_action),
3064  // actions.loggingbox),
3065  // true));
3066 
3067  /*
3068  ** load plugin definitions into plugin_dict, add to effects_toolpalette
3069  **
3070  ** icons will be added after state loading when we know the skin
3071  ** UI definitions will be loaded on demand
3072  */
3073  fill_pluginlist();
3074  PluginUI *mainamp_plugin = new PluginUI(*this, "ampstack");
3075  plugin_dict.add(mainamp_plugin);
3076  mainamp_plugin->rackbox = add_rackbox_internal(*mainamp_plugin, 0, 0, false, -1, false, amp_background);
3077  //effects_toolpalette->set_name("effects_toolpalette");
3078  effects_toolpalette->show();
3079  if (!options.get_clear_rc()) {
3080  //g_object_set (gtk_settings_get_default (),"gtk-theme-name",NULL, NULL);
3081  set_new_skin(options.skin_name);
3082  } else {
3083  gtk_rc_parse(
3084  (options.get_style_filepath("clear.rc")).c_str());
3085  make_icons();
3086  }
3087 
3088  // call some action functions to sync state
3089  // with settings defined in create_actions()
3090  actions.rackh->set_active(options.system_order_rack_h);
3091  actions.presets->set_active(options.system_show_presets);
3092  actions.show_plugin_bar->set_active(options.system_show_toolbar);
3093  actions.show_rack->set_active(options.system_show_rack);
3094  actions.show_values->set_active(options.system_show_value);
3095  actions.tooltips->set_active(options.system_show_tooltips);
3096  actions.animations->set_active(options.system_animations);
3097 
3098  if (!title.empty()) {
3099  window->set_title(title);
3100  }
3101 
3102  /*
3103  ** Jack client connection and subsequent initalizations
3104  */
3105 
3106  // state must be loaded before starting jack because connect_jack() uses
3107  // some settings. If the jack client name changes (from the predefined value)
3108  // on connect the jack client-change signal will trigger the load of another
3109  // state file, which means that the jack starter options are read from the
3110  // standard state file (gx_head_rc or similar if -n is used)
3111  machine.loadstate();
3112  if (!in_session) {
3113  machine.disable_autosave(options.get_opt_save_on_exit());
3114  }
3115  if (!connect_jack(true, splash)) {
3116  // not connected, must synthesize signal for initialization
3117  if (jack) {
3118  jack->signal_client_change()();
3119  }
3120  }
3121  set_latency(); // make sure latency menu is updated
3122  set_osc_size();
3123 
3124  if (options.mainwin_height > 0) { // initially use the default set in mainpanel.glade
3125  window->set_default_size(-1, min(options.window_height, options.mainwin_height));
3126  }
3127 
3128  // set window position (make this optional??)
3129  if (options.mainwin_x > 0) {
3130  window->move(options.mainwin_x, options.mainwin_y);
3131  }
3132 
3133  Gtk::Range *rr;
3134  bld->find_widget("gxselector1:amp_selector", rr);
3135  rr->signal_value_changed().connect(
3136  sigc::bind(
3137  sigc::mem_fun(this, &MainWindow::amp_controls_visible),
3138  rr));
3139  amp_controls_visible(rr);
3140 
3141  // set insert_image state
3142  if (machine.get_parameter_value<bool>("engine.insert")) {
3143  insert_image->set(pixbuf_insert_off);
3144  machine.set_jack_insert(true);
3145  } else {
3146  insert_image->set(pixbuf_insert_on);
3147  machine.set_jack_insert(false);
3148  }
3149  if (!options.get_tuner_tet().empty()) set_tuner_tet(*racktuner);
3150 
3151  }
3152 
3154 #if false // set true to generate a new keyboard accel file
3155  gtk_accel_map_add_filter("<Actions>/Main/ChangeSkin_*");
3156  gtk_accel_map_add_filter("<Actions>/Main/Enum_tube.select.*");
3157  gtk_accel_map_add_filter("<Actions>/Main/Latency_*");
3158  gtk_accel_map_add_filter("<Actions>/Main/Plugin_*");
3159  gtk_accel_map_add_filter("<Actions>/PresetList/PresetList_*");
3160  Gtk::AccelMap::save(options.get_user_filepath("accels_rc"));
3161 #endif
3162 
3163  int mainwin_width;
3164  window->get_size(mainwin_width, options.mainwin_height);
3165  Glib::RefPtr<Gdk::Window> win = window->get_window();
3166  if (win) {
3167  win->get_root_origin(options.mainwin_x, options.mainwin_y);
3168  }
3169  if (actions.presets->get_active()) {
3170  options.preset_window_height = preset_scrolledbox->get_allocation().get_height();
3171  }
3172  plugin_dict.cleanup();
3173  delete live_play;
3174  delete preset_window;
3175  delete window;
3176  window = 0;
3177  //if (ladspalist_window) {
3178  //delete ladspalist_window;
3179  //ladspalist_window = 0;
3180  //}
3181 }
iterator end()
Definition: gx_json.h:366
virtual GxEngineState get_state()=0
virtual gx_system::PresetFileGui * get_current_bank_file()=0
void gx_print_info(const char *, const std::string &)
Definition: gx_logging.cpp:183
void check_order()
Definition: rack.cpp:1626
virtual float getLowerAsFloat() const
void cleanup()
Definition: rack.cpp:213
CmdConnection::msg_type start
Definition: jsonrpc.cpp:255
void set_jack_down(bool v)
Definition: gx_jack.h:188
double stop_at_mono_top(double off, double step_size)
#define GDK_KEY_Escape
Definition: guitarix.h:53
void set_streaming(bool p1)
Definition: racktuner.cc:290
Glib::RefPtr< Gtk::ToggleAction > get_action()
virtual sigc::signal< void, int > & signal_oscilloscope_post_pre()=0
PluginDef * get_pdef()
void set_display_flat(bool p1)
Definition: racktuner.cc:300
Glib::RefPtr< UiBoolToggleAction > midi_out_plug
void freeze_and_size_request(Gtk::Window *w, int width, int height)
void add_icon(const std::string &name)
#define RPCPORT_DEFAULT
Definition: gx_system.h:350
std::string get_builder_filepath(const std::string &basename) const
Definition: gx_system.h:373
virtual sigc::signal< void, GxEngineState > & signal_state_change()=0
static Glib::RefPtr< UiToggleAction > create(gx_engine::GxMachineBase &machine, const std::string &id, const Glib::ustring &name, const Glib::ustring &label=Glib::ustring(), const Glib::ustring &tooltip=Glib::ustring(), bool is_active=false)
virtual sigc::signal< void > & signal_presetlist_changed()=0
const char * get_name() const
virtual sigc::signal< void, bool > & signal_oscilloscope_visible()=0
void display(bool v, bool animate)
Definition: rack.cpp:137
int operator()()
#define GDK_KEY_9
Definition: guitarix.h:48
const char * value_id
Definition: gx_plugin.h:118
virtual Parameter & get_parameter(const std::string &id)=0
void set_temperament(int p1)
Definition: racktuner.cc:330
bool get_box_visible()
void set_ui_merge_id(Gtk::UIManager::ui_merge_id id)
Glib::ustring tooltip
#define N_(String)
GxJackLatencyChange
Glib::ustring skin_name
Definition: gx_system.h:445
virtual void set_state(GxEngineState state)=0
int gx_system_call(const std::string &, bool devnull=false, bool escape=false)
Definition: gx_system.cpp:950
static void rt_watchdog_set_limit(int limit)
Definition: gx_jack.cpp:146
bool get_on_off() const
static bool is_registered(gx_engine::GxMachineBase &m, const char *name)
Definition: rack.cpp:86
Glib::RefPtr< Gtk::ToggleAction > show_values
virtual sigc::signal< void, unsigned int > & signal_oscilloscope_size_change()=0
Glib::RefPtr< Gdk::Pixbuf > icon
void plugin_preset_popup(const PluginDef *pdef)
GxUiRadioMenu(gx_engine::GxMachineBase &machine, const std::string &id)
virtual void set_init_values()=0
bool check_thaw(int width, int height)
void set_reference_pitch(double p1)
Definition: tuner.cc:137
GtkSizeGroup * left_column
virtual void tuner_used_for_display(bool on)=0
Glib::RefPtr< Gtk::ToggleAction > tooltips
virtual gx_jack::GxJack * get_jack()=0
jack_nframes_t get_jack_bs()
Definition: gx_jack.h:179
std::vector< Position >::iterator iterator
Definition: gx_json.h:321
Glib::RefPtr< Gtk::ToggleAction > rackh
void set_freq(double p1)
Definition: racktuner.cc:265
void hide_effect(const std::string &name)
UiToggleAction(gx_engine::GxMachineBase &machine_, const std::string &id, const Glib::ustring &name, const Glib::ustring &icon_name, const Glib::ustring &label=Glib::ustring(), const Glib::ustring &tooltip=Glib::ustring(), bool is_active=false)
void pack(Gtk::Widget *mainbox, Gtk::Widget *minibox, const Glib::RefPtr< Gtk::SizeGroup > &szg)
Definition: rack.cpp:1215
virtual bool setting_is_preset()=0
std::string get_style_filepath(const std::string &basename) const
Definition: gx_system.h:461
double stop_at_stereo_bottom(double off, double step_size, double pagesize)
PluginDesc(const Glib::ustring &g, std::vector< PluginUI *> *p)
int get_idle_thread_timeout() const
Definition: gx_system.h:505
Glib::RefPtr< Gtk::ToggleAction > rack_config
Glib::RefPtr< Gtk::ToggleAction > show_rack
jack_client_t * client
Definition: gx_jack.h:171
static Gtk::Widget * create_icon_widget(const PluginUI &plugin, gx_system::CmdlineOptions &options)
Definition: rack.cpp:901
Glib::RefPtr< Gtk::ToggleAction > animations
void gx_print_error(const char *, const std::string &)
Definition: gx_logging.cpp:166
Gtk::ToolItemGroup * group
gx_engine::Plugin * plugin
#define RPCPORT_NONE
Definition: gx_system.h:351
Glib::RefPtr< Gtk::ActionGroup > group
static GxLogger & get_logger()
Definition: gx_logging.cpp:50
void update_width()
Glib::SignalProxy1< void, bool > signal_poll_status_changed()
Definition: racktuner.cc:357
Glib::RefPtr< Gtk::Action > expand
virtual bool load_unit(gx_gui::UiBuilderImpl &builder, PluginDef *pdef)=0
#define GDK_KEY_0
Definition: guitarix.h:46
void gx_show_about()
Glib::SignalProxy0< void > signal_frequency_poll()
Definition: racktuner.cc:351
float power2db(float power)
#define min(x, y)
bool is_jack_down()
Definition: gx_jack.h:208
void clear_notes()
Definition: racktuner.cc:340
T get_parameter_value(const std::string &id)
const char * id
Definition: gx_plugin.h:187
void animate_insert()
Definition: rack.cpp:1085
virtual const Glib::ustring & get_current_bank()=0
void show_forum_help()
#define max(x, y)
RackBox * add_rackbox(PluginUI &pl, bool mini=false, int pos=-1, bool animate=false)
sigc::signal< void > & signal_msg_level_changed()
sigc::signal< void, bool > & signal_changed()
Definition: gx_parameter.h:377
virtual float get_tuner_freq()=0
#define SYSTEM_OK
Definition: gx_system.h:81
MainWindow(gx_engine::GxMachineBase &machine, gx_system::CmdlineOptions &options, Gtk::Window *splash, const Glib::ustring &title)
static GxExit & get_instance()
Definition: gx_logging.cpp:205
PluginType get_type() const
static void toggle(gx_engine::GxMachineBase &machine, Glib::RefPtr< Gtk::ToggleAction > item)
const std::string & getIRFile() const
msg_signal & signal_message()
Definition: gx_logging.cpp:77
virtual sigc::signal< void, Plugin *, PluginChange::pc > & signal_plugin_changed()=0
JConvPluginUI(MainWindow &main, const char *id, const Glib::ustring &tooltip="")
virtual void set_parameter_value(const std::string &id, int value)=0
void set_action(Glib::RefPtr< Gtk::ToggleAction > &act)
Definition: rack.cpp:99
virtual sigc::signal< void > & signal_selection_changed()=0
std::string to_string(const T &t)
Definition: gx_system.h:525
std::vector< PluginUI * > * plugins
void add_plugin(std::vector< PluginUI *> &p, const char *id, const Glib::ustring &tooltip_="")
Glib::RefPtr< Gtk::ToggleAction > live_play
void connect_midi_controller(Gtk::Widget *w, const std::string &id, gx_engine::GxMachineBase &machine)
bool plugins_by_name_less(PluginUI *a, PluginUI *b)
Definition: rack.cpp:186
Glib::RefPtr< Gtk::AccelGroup > accels
Glib::ustring group
void set_slot(sigc::slot< void > w)
Gtk::ToolItem * toolitem
bool get_opt_save_on_exit() const
Definition: gx_system.h:502
void unset_ui_merge_id(Glib::RefPtr< Gtk::UIManager > uimanager)
Definition: rack.cpp:75
void gx_print_warning(const char *, const std::string &)
Definition: gx_logging.cpp:161
Glib::RefPtr< UiBoolToggleAction > tuner
const Glib::ustring & get_tuner_tet()
Definition: gx_system.h:488
virtual void disable_autosave(bool v)=0
bool gx_start_jack_dialog(Glib::RefPtr< Gdk::Pixbuf > gw_ib)
void update_rackbox()
Definition: rack.cpp:164
void exit_program(std::string msg="", int errcode=1)
Definition: gx_logging.cpp:196
const string & get_instancename()
Definition: gx_jack.h:202
const GxJConvSettings & get_value() const
int main(int argc, char *argv[])
Definition: gxw_demo.cc:62
#define GDK_KEY_z
Definition: guitarix.h:63
void swtch(bool mini)
Definition: rack.cpp:1134
void add(PluginUI *p)
Definition: rack.cpp:203
void setup(const Glib::ustring &prefix, const Glib::ustring &postfix, Glib::RefPtr< Gtk::UIManager > &uimanager, Glib::RefPtr< Gtk::ActionGroup > &actiongroup)
static void start_stop(Glib::RefPtr< Gtk::ToggleAction > &action, gx_jack::GxJack &jack)
std::string get_user_filepath(const std::string &basename) const
Definition: gx_system.h:371
Glib::Dispatcher shutdown
Definition: gx_jack.h:207
void gx_show_help()
const char * get_id() const
IntParameter & getInt()
Definition: gx_parameter.h:458
Glib::RefPtr< Gtk::ToggleAction > presets
const Glib::ustring & get_jack_uuid() const
Definition: gx_system.h:496
virtual Plugin * pluginlist_lookup_plugin(const std::string &id) const =0
EnumParameter & getEnum()
Definition: gx_parameter.h:463
bool gx_jack_connection(bool connect, bool startserver, int wait_after_connect, const gx_system::CmdlineOptions &opt)
Definition: gx_jack.cpp:437
#define GDK_KEY_KP_9
Definition: guitarix.h:56
Glib::RefPtr< Gtk::ToggleAction > show_plugin_bar
virtual void set_jack_insert(bool v)=0
void push_note(int p1, int p2, int p3)
Definition: racktuner.cc:345
virtual const Glib::ustring & get_current_name()=0
void set_on_off(bool v) const
Gxw::RackTuner & get_tuner()
bool get_clear_rc() const
Definition: gx_system.h:483
const char * get_category()
virtual sigc::signal< int, bool > & signal_oscilloscope_activation()=0
static const char * value_label(const value_pair &vp)
Definition: gx_parameter.h:199
virtual bool midi_get_config_mode(int *ctl=0)=0
sigc::signal< void, T > & signal_parameter_value(const std::string &id)
BoolParameter & getBool()
Definition: gx_parameter.h:469
void update_scrolled_window(Gtk::ScrolledWindow &w)
const string & id() const
Definition: gx_parameter.h:173
int gx_message_popup(const char *)
void resize_finished(RackContainer *ch)
const value_pair & get_pair()
Definition: gx_parameter.h:340
#define GDK_KEY_a
Definition: guitarix.h:49
RackBox * rackbox
void set_accelgroup(Glib::RefPtr< Gtk::AccelGroup > accels_)
virtual void loadstate()=0
#define GDK_KEY_KP_0
Definition: guitarix.h:54
void unplug_queue()
Definition: gx_logging.cpp:82
Glib::RefPtr< Gtk::Action > compress
Glib::RefPtr< Gtk::ToggleAction > loggingbox
static PortMapWindow * create(gx_engine::GxMachineBase &machine, Glib::RefPtr< Gtk::AccelGroup > ag)
Definition: gx_portmap.cpp:549
sigc::signal< void, MidiAudioBuffer::Load > & signal_jack_load_change()
Definition: machine.h:93
static SelectJackControlPgm * create(gx_system::CmdlineOptions &opt, gx_engine::GxMachineBase &machine)
void freeze_until_width_update(Gtk::Window *w, int width)
virtual const value_pair * getValueNames() const