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