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