1 |
/* |
/* |
2 |
* Copyright (C) 2006-2015 Andreas Persson |
* Copyright (C) 2006-2019 Andreas Persson |
3 |
* |
* |
4 |
* This program is free software; you can redistribute it and/or |
* This program is free software; you can redistribute it and/or |
5 |
* modify it under the terms of the GNU General Public License as |
* modify it under the terms of the GNU General Public License as |
17 |
* 02110-1301 USA. |
* 02110-1301 USA. |
18 |
*/ |
*/ |
19 |
|
|
20 |
|
#include "global.h" |
21 |
#include "paramedit.h" |
#include "paramedit.h" |
22 |
|
|
|
#include "global.h" |
|
23 |
#include "compat.h" |
#include "compat.h" |
24 |
#include "Settings.h" |
#include "Settings.h" |
25 |
|
|
26 |
|
#ifdef GLIBMM_HEADER_FILE |
27 |
|
# include GLIBMM_HEADER_FILE(glibmm.h) |
28 |
|
#else |
29 |
|
# include <glibmm.h> |
30 |
|
#endif |
31 |
|
|
32 |
#include <gtkmm/messagedialog.h> |
#include <gtkmm/messagedialog.h> |
33 |
|
|
34 |
namespace { |
namespace { |
145 |
label(Glib::ustring(labelText) + ":"), |
label(Glib::ustring(labelText) + ":"), |
146 |
widget(widget) |
widget(widget) |
147 |
{ |
{ |
148 |
|
#if HAS_GTKMM_ALIGNMENT |
149 |
label.set_alignment(Gtk::ALIGN_START); |
label.set_alignment(Gtk::ALIGN_START); |
150 |
|
#else |
151 |
|
label.set_halign(Gtk::Align::START); |
152 |
|
#endif |
153 |
|
Settings::singleton()->showTooltips.get_proxy().signal_changed().connect( |
154 |
|
sigc::mem_fun(this, &LabelWidget::on_show_tooltips_changed) |
155 |
|
); |
156 |
|
|
157 |
|
// workaround for a crash with certain gtkmm versions: postpone calling |
158 |
|
// on_show_tooltips_changed() because widget.gobj() might be uninitialized |
159 |
|
// at this point yet |
160 |
|
Glib::signal_idle().connect_once( // timeout starts given amount of ms after the main loop became idle again ... |
161 |
|
sigc::mem_fun(*this, &LabelWidget::on_show_tooltips_changed), |
162 |
|
300 |
163 |
|
); |
164 |
|
} |
165 |
|
|
166 |
|
void LabelWidget::on_show_tooltips_changed() { |
167 |
|
const bool b = Settings::singleton()->showTooltips; |
168 |
|
label.set_has_tooltip(b); |
169 |
|
widget.set_has_tooltip(b); |
170 |
} |
} |
171 |
|
|
172 |
void LabelWidget::set_sensitive(bool sensitive) |
void LabelWidget::set_sensitive(bool sensitive) |
178 |
ReadOnlyLabelWidget::ReadOnlyLabelWidget(const char* leftHandText) |
ReadOnlyLabelWidget::ReadOnlyLabelWidget(const char* leftHandText) |
179 |
: LabelWidget(leftHandText, text) |
: LabelWidget(leftHandText, text) |
180 |
{ |
{ |
181 |
|
#if HAS_GTKMM_ALIGNMENT |
182 |
text.set_alignment(Gtk::ALIGN_START, Gtk::ALIGN_START); |
text.set_alignment(Gtk::ALIGN_START, Gtk::ALIGN_START); |
183 |
|
#else |
184 |
|
label.set_halign(Gtk::Align::START); |
185 |
|
label.set_valign(Gtk::Align::START); |
186 |
|
#endif |
187 |
} |
} |
188 |
|
|
189 |
ReadOnlyLabelWidget::ReadOnlyLabelWidget(const char* leftHandText, const char* rightHandText) |
ReadOnlyLabelWidget::ReadOnlyLabelWidget(const char* leftHandText, const char* rightHandText) |
190 |
: LabelWidget(leftHandText, text) |
: LabelWidget(leftHandText, text) |
191 |
{ |
{ |
192 |
|
#if HAS_GTKMM_ALIGNMENT |
193 |
text.set_alignment(Gtk::ALIGN_START, Gtk::ALIGN_START); |
text.set_alignment(Gtk::ALIGN_START, Gtk::ALIGN_START); |
194 |
|
#else |
195 |
|
text.set_halign(Gtk::Align::START); |
196 |
|
text.set_valign(Gtk::Align::START); |
197 |
|
#endif |
198 |
text.set_text(rightHandText); |
text.set_text(rightHandText); |
199 |
} |
} |
200 |
|
|
218 |
box.add(scale); |
box.add(scale); |
219 |
} |
} |
220 |
|
|
221 |
|
void NumEntry::on_show_tooltips_changed() { |
222 |
|
LabelWidget::on_show_tooltips_changed(); |
223 |
|
|
224 |
|
const bool b = Settings::singleton()->showTooltips; |
225 |
|
spinbutton.set_has_tooltip(b); |
226 |
|
scale.set_has_tooltip(b); |
227 |
|
} |
228 |
|
|
229 |
NumEntryGain::NumEntryGain(const char* labelText, |
NumEntryGain::NumEntryGain(const char* labelText, |
230 |
double lower, double upper, |
double lower, double upper, |
231 |
int decimals, double coeff) : |
int decimals, double coeff) : |
276 |
sigc::mem_fun(*this, &BoolEntryPlus6::value_changed)); |
sigc::mem_fun(*this, &BoolEntryPlus6::value_changed)); |
277 |
} |
} |
278 |
|
|
279 |
|
void BoolEntryPlus6::on_show_tooltips_changed() { |
280 |
|
LabelWidget::on_show_tooltips_changed(); |
281 |
|
|
282 |
|
eGain.on_show_tooltips_changed(); |
283 |
|
} |
284 |
|
|
285 |
void BoolEntryPlus6::value_changed() |
void BoolEntryPlus6::value_changed() |
286 |
{ |
{ |
287 |
if (checkbutton.get_active()) eGain.set_value(plus6value); |
if (checkbutton.get_active()) eGain.set_value(plus6value); |
359 |
return true; |
return true; |
360 |
} |
} |
361 |
} |
} |
362 |
|
|
363 |
|
#if HAS_GTKMM_CPP11_ENUMS |
364 |
|
return Gtk::SpinButton::INPUT_ERROR; |
365 |
|
#else |
366 |
return Gtk::INPUT_ERROR; |
return Gtk::INPUT_ERROR; |
367 |
|
#endif |
368 |
} |
} |
369 |
} |
} |
370 |
|
|
384 |
|
|
385 |
namespace { |
namespace { |
386 |
// Convert the Entry text to a number |
// Convert the Entry text to a number |
387 |
|
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2 |
388 |
|
int on_input(double& new_value, Gtk::SpinButton* spinbutton) { |
389 |
|
return note_value(spinbutton->get_text(), &new_value); |
390 |
|
} |
391 |
|
#else |
392 |
int on_input(double* new_value, Gtk::SpinButton* spinbutton) { |
int on_input(double* new_value, Gtk::SpinButton* spinbutton) { |
393 |
return note_value(spinbutton->get_text(), new_value); |
return note_value(spinbutton->get_text(), new_value); |
394 |
} |
} |
395 |
|
#endif |
396 |
|
|
397 |
// Convert the Adjustment position to text |
// Convert the Adjustment position to text |
398 |
bool on_output(Gtk::SpinButton* spinbutton) { |
bool on_output(Gtk::SpinButton* spinbutton) { |
413 |
sigc::bind(sigc::ptr_fun(&on_output), &spin_button)); |
sigc::bind(sigc::ptr_fun(&on_output), &spin_button)); |
414 |
} |
} |
415 |
|
|
416 |
|
void ChoiceEntryBase::on_show_tooltips_changed() { |
417 |
|
LabelWidget::on_show_tooltips_changed(); |
418 |
|
|
419 |
|
const bool b = Settings::singleton()->showTooltips; |
420 |
|
combobox.set_has_tooltip(b); |
421 |
|
} |
422 |
|
|
423 |
ChoiceEntryLeverageCtrl::ChoiceEntryLeverageCtrl(const char* labelText) : |
ChoiceEntryLeverageCtrl::ChoiceEntryLeverageCtrl(const char* labelText) : |
424 |
|
#if HAS_GTKMM_ALIGNMENT |
425 |
LabelWidget(labelText, align), |
LabelWidget(labelText, align), |
426 |
align(0, 0, 0, 0) |
align(0, 0, 0, 0) |
427 |
|
#else |
428 |
|
LabelWidget(labelText, combobox) |
429 |
|
#endif |
430 |
{ |
{ |
431 |
for (int i = 0 ; i < controlChangeTextsSize ; i++) { |
for (int i = 0 ; i < controlChangeTextsSize ; i++) { |
432 |
if (controlChangeTexts[i].txt) { |
if (controlChangeTexts[i].txt) { |
441 |
#endif |
#endif |
442 |
} |
} |
443 |
} |
} |
444 |
|
combobox.set_wrap_width(4); |
445 |
combobox.signal_changed().connect( |
combobox.signal_changed().connect( |
446 |
sigc::mem_fun(*this, &ChoiceEntryLeverageCtrl::value_changed)); |
sigc::mem_fun(*this, &ChoiceEntryLeverageCtrl::value_changed)); |
447 |
|
#if HAS_GTKMM_ALIGNMENT |
448 |
align.add(combobox); |
align.add(combobox); |
449 |
|
#else |
450 |
|
combobox.set_halign(Gtk::Align::FILL); |
451 |
|
combobox.set_valign(Gtk::Align::FILL); |
452 |
|
#endif |
453 |
value.type = gig::leverage_ctrl_t::type_none; |
value.type = gig::leverage_ctrl_t::type_none; |
454 |
value.controller_number = 0; |
value.controller_number = 0; |
455 |
} |
} |
456 |
|
|
457 |
|
void ChoiceEntryLeverageCtrl::on_show_tooltips_changed() { |
458 |
|
LabelWidget::on_show_tooltips_changed(); |
459 |
|
|
460 |
|
const bool b = Settings::singleton()->showTooltips; |
461 |
|
combobox.set_has_tooltip(b); |
462 |
|
} |
463 |
|
|
464 |
void ChoiceEntryLeverageCtrl::value_changed() |
void ChoiceEntryLeverageCtrl::value_changed() |
465 |
{ |
{ |
466 |
int rowno = combobox.get_active_row_number(); |
int rowno = combobox.get_active_row_number(); |
539 |
} |
} |
540 |
|
|
541 |
|
|
542 |
|
BoolBox::BoolBox(const char* labelText) : Gtk::CheckButton(labelText) { |
543 |
|
signal_toggled().connect(sig_changed.make_slot()); |
544 |
|
Settings::singleton()->showTooltips.get_proxy().signal_changed().connect( |
545 |
|
sigc::mem_fun(this, &BoolBox::on_show_tooltips_changed) |
546 |
|
); |
547 |
|
on_show_tooltips_changed(); |
548 |
|
} |
549 |
|
|
550 |
|
void BoolBox::on_show_tooltips_changed() { |
551 |
|
const bool b = Settings::singleton()->showTooltips; |
552 |
|
set_has_tooltip(b); |
553 |
|
} |
554 |
|
|
555 |
|
|
556 |
BoolEntry::BoolEntry(const char* labelText) : |
BoolEntry::BoolEntry(const char* labelText) : |
557 |
LabelWidget(labelText, checkbutton), |
LabelWidget(labelText, checkbutton), |
558 |
checkbutton(labelText) |
checkbutton(labelText) |
602 |
text_buffer->set_text(text); |
text_buffer->set_text(text); |
603 |
} |
} |
604 |
|
|
605 |
|
void StringEntryMultiLine::on_show_tooltips_changed() { |
606 |
|
LabelWidget::on_show_tooltips_changed(); |
607 |
|
|
608 |
Table::Table(int x, int y) : Gtk::Table(x, y), rowno(0) { } |
const bool b = Settings::singleton()->showTooltips; |
609 |
|
text_view.set_has_tooltip(b); |
610 |
|
} |
611 |
|
|
612 |
|
|
613 |
|
Table::Table(int x, int y) : |
614 |
|
#if USE_GTKMM_GRID |
615 |
|
Gtk::Grid(), |
616 |
|
cols(x), |
617 |
|
#else |
618 |
|
Gtk::Table(x, y), |
619 |
|
#endif |
620 |
|
rowno(0) |
621 |
|
{ |
622 |
|
} |
623 |
|
|
624 |
void Table::add(BoolEntry& boolentry) |
void Table::add(BoolEntry& boolentry) |
625 |
{ |
{ |
626 |
|
#if USE_GTKMM_GRID |
627 |
|
attach(boolentry.widget, 0, rowno, 2); |
628 |
|
#else |
629 |
attach(boolentry.widget, 0, 2, rowno, rowno + 1, |
attach(boolentry.widget, 0, 2, rowno, rowno + 1, |
630 |
Gtk::FILL, Gtk::SHRINK); |
Gtk::FILL, Gtk::SHRINK); |
631 |
|
#endif |
632 |
rowno++; |
rowno++; |
633 |
} |
} |
634 |
|
|
635 |
void Table::add(BoolEntryPlus6& boolentry) |
void Table::add(BoolEntryPlus6& boolentry) |
636 |
{ |
{ |
637 |
|
#if USE_GTKMM_GRID |
638 |
|
attach(boolentry.widget, 0, rowno, 2); |
639 |
|
#else |
640 |
attach(boolentry.widget, 0, 2, rowno, rowno + 1, |
attach(boolentry.widget, 0, 2, rowno, rowno + 1, |
641 |
Gtk::FILL, Gtk::SHRINK); |
Gtk::FILL, Gtk::SHRINK); |
642 |
|
#endif |
643 |
rowno++; |
rowno++; |
644 |
} |
} |
645 |
|
|
646 |
void Table::add(LabelWidget& prop) |
void Table::add(LabelWidget& prop) |
647 |
{ |
{ |
648 |
|
#if USE_GTKMM_GRID |
649 |
|
attach(prop.label, 1, rowno); |
650 |
|
attach(prop.widget, 2, rowno); |
651 |
|
#else |
652 |
attach(prop.label, 1, 2, rowno, rowno + 1, |
attach(prop.label, 1, 2, rowno, rowno + 1, |
653 |
Gtk::FILL, Gtk::SHRINK); |
Gtk::FILL, Gtk::SHRINK); |
654 |
attach(prop.widget, 2, 3, rowno, rowno + 1, |
attach(prop.widget, 2, 3, rowno, rowno + 1, |
655 |
Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK); |
Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK); |
656 |
|
#endif |
657 |
rowno++; |
rowno++; |
658 |
} |
} |