1 |
/* |
/* |
2 |
* Copyright (C) 2006-2014 Andreas Persson |
* Copyright (C) 2006-2017 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 <glibmmconfig.h> |
#include "compat.h" |
21 |
// threads.h must be included first to be able to build with |
// threads.h must be included first to be able to build with |
22 |
// G_DISABLE_DEPRECATED |
// G_DISABLE_DEPRECATED |
23 |
#if (GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION == 31 && GLIBMM_MICRO_VERSION >= 2) || \ |
#if (GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION == 31 && GLIBMM_MICRO_VERSION >= 2) || \ |
27 |
|
|
28 |
#include "dimensionmanager.h" |
#include "dimensionmanager.h" |
29 |
|
|
30 |
#include <gtkmm/stock.h> |
#if HAS_GTKMM_STOCK |
31 |
|
# include <gtkmm/stock.h> |
32 |
|
#endif |
33 |
#include <gtkmm/messagedialog.h> |
#include <gtkmm/messagedialog.h> |
34 |
#include <gtkmm/dialog.h> |
#include <gtkmm/dialog.h> |
35 |
#include <gtkmm/comboboxtext.h> |
#include <gtkmm/comboboxtext.h> |
36 |
#include <gtkmm/spinbutton.h> |
#include <gtkmm/spinbutton.h> |
37 |
#include <gtkmm/table.h> |
#include <gtkmm/label.h> |
38 |
|
#if USE_GTKMM_GRID |
39 |
|
# include <gtkmm/grid.h> |
40 |
|
#else |
41 |
|
# include <gtkmm/table.h> |
42 |
|
#endif |
43 |
|
|
44 |
#include "global.h" |
#include "global.h" |
45 |
#include "compat.h" |
#include "compat.h" |
251 |
} |
} |
252 |
|
|
253 |
DimensionManager::DimensionManager() : |
DimensionManager::DimensionManager() : |
254 |
|
#if HAS_GTKMM_STOCK |
255 |
addButton(Gtk::Stock::ADD), removeButton(Gtk::Stock::REMOVE), |
addButton(Gtk::Stock::ADD), removeButton(Gtk::Stock::REMOVE), |
256 |
|
#else |
257 |
|
addButton(_("_Add"), true), removeButton(_("_Remove"), true), |
258 |
|
#endif |
259 |
allRegionsCheckBox(_("All Regions")) |
allRegionsCheckBox(_("All Regions")) |
260 |
{ |
{ |
261 |
ignoreColumnClicked = true; |
ignoreColumnClicked = true; |
262 |
|
|
263 |
|
if (!Settings::singleton()->autoRestoreWindowDimension) { |
264 |
|
set_default_size(630, 250); |
265 |
|
set_position(Gtk::WIN_POS_MOUSE); |
266 |
|
} |
267 |
|
|
268 |
|
#if !HAS_GTKMM_STOCK |
269 |
|
// see : https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html |
270 |
|
addButton.set_icon_name("list-add"); |
271 |
|
removeButton.set_icon_name("list-remove"); |
272 |
|
#endif |
273 |
|
|
274 |
set_title(_("Dimensions of selected Region")); |
set_title(_("Dimensions of selected Region")); |
275 |
add(vbox); |
add(vbox); |
276 |
scrolledWindow.add(treeView); |
scrolledWindow.add(treeView); |
278 |
scrolledWindow.show(); |
scrolledWindow.show(); |
279 |
vbox.pack_start(buttonBox, Gtk::PACK_SHRINK); |
vbox.pack_start(buttonBox, Gtk::PACK_SHRINK); |
280 |
buttonBox.set_layout(Gtk::BUTTONBOX_END); |
buttonBox.set_layout(Gtk::BUTTONBOX_END); |
281 |
|
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) |
282 |
|
buttonBox.set_margin(5); |
283 |
|
#else |
284 |
buttonBox.set_border_width(5); |
buttonBox.set_border_width(5); |
285 |
|
#endif |
286 |
buttonBox.show(); |
buttonBox.show(); |
287 |
buttonBox.pack_start(allRegionsCheckBox, Gtk::PACK_EXPAND_PADDING); |
buttonBox.pack_start(allRegionsCheckBox, Gtk::PACK_EXPAND_PADDING); |
288 |
buttonBox.pack_start(addButton, Gtk::PACK_SHRINK); |
buttonBox.pack_start(addButton, Gtk::PACK_SHRINK); |
322 |
sigc::mem_fun(*this, &DimensionManager::onAllRegionsCheckBoxToggled) |
sigc::mem_fun(*this, &DimensionManager::onAllRegionsCheckBoxToggled) |
323 |
); |
); |
324 |
|
|
325 |
|
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
326 |
show_all_children(); |
show_all_children(); |
327 |
|
#endif |
328 |
resize(460,300); |
|
329 |
|
Settings::singleton()->showTooltips.get_proxy().signal_changed().connect( |
330 |
|
sigc::mem_fun(*this, &DimensionManager::on_show_tooltips_changed) |
331 |
|
); |
332 |
|
on_show_tooltips_changed(); |
333 |
|
} |
334 |
|
|
335 |
|
void DimensionManager::on_show_tooltips_changed() { |
336 |
|
const bool b = Settings::singleton()->showTooltips; |
337 |
|
|
338 |
|
treeView.set_has_tooltip(b); |
339 |
|
allRegionsCheckBox.set_has_tooltip(b); |
340 |
|
|
341 |
|
set_has_tooltip(b); |
342 |
} |
} |
343 |
|
|
344 |
bool DimensionManager::allRegions() const { |
bool DimensionManager::allRegions() const { |
367 |
}; |
}; |
368 |
typedef std::map<gig::dimension_t, _DimDef> _Dimensions; |
typedef std::map<gig::dimension_t, _DimDef> _Dimensions; |
369 |
|
|
370 |
// update all GUI elements according to current gig::Region informations |
// update all GUI elements according to current gig::Region information |
371 |
void DimensionManager::refreshManager() { |
void DimensionManager::refreshManager() { |
372 |
set_sensitive(false); |
set_sensitive(false); |
373 |
refTableModel->clear(); |
refTableModel->clear(); |
477 |
count++; |
count++; |
478 |
} |
} |
479 |
} |
} |
480 |
|
#if USE_GTKMM_GRID |
481 |
|
Gtk::Grid table; |
482 |
|
#else |
483 |
Gtk::Table table(1, 2); |
Gtk::Table table(1, 2); |
484 |
|
#endif |
485 |
Gtk::Label labelDimType(_("Dimension:"), Gtk::ALIGN_START); |
Gtk::Label labelDimType(_("Dimension:"), Gtk::ALIGN_START); |
486 |
Gtk::ComboBox comboDimType; |
Gtk::ComboBox comboDimType; |
487 |
comboDimType.set_model(refComboModel); |
comboDimType.set_model(refComboModel); |
489 |
comboDimType.pack_start(comboModel.m_type_name); |
comboDimType.pack_start(comboModel.m_type_name); |
490 |
table.attach(labelDimType, 0, 1, 0, 1); |
table.attach(labelDimType, 0, 1, 0, 1); |
491 |
table.attach(comboDimType, 1, 2, 0, 1); |
table.attach(comboDimType, 1, 2, 0, 1); |
492 |
|
#if USE_GTKMM_BOX |
493 |
|
dialog.get_content_area()->pack_start(table); |
494 |
|
#else |
495 |
dialog.get_vbox()->pack_start(table); |
dialog.get_vbox()->pack_start(table); |
496 |
|
#endif |
497 |
|
|
498 |
|
#if HAS_GTKMM_STOCK |
499 |
dialog.add_button(Gtk::Stock::OK, 0); |
dialog.add_button(Gtk::Stock::OK, 0); |
500 |
dialog.add_button(Gtk::Stock::CANCEL, 1); |
dialog.add_button(Gtk::Stock::CANCEL, 1); |
501 |
|
#else |
502 |
|
dialog.add_button(_("_OK"), 0); |
503 |
|
dialog.add_button(_("_Cancel"), 1); |
504 |
|
#endif |
505 |
|
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
506 |
dialog.show_all_children(); |
dialog.show_all_children(); |
507 |
|
#endif |
508 |
|
|
509 |
comboDimType.set_active(oldTypeIndex); |
comboDimType.set_active(oldTypeIndex); |
510 |
|
|
596 |
row[comboModel.m_type_name] = sType; |
row[comboModel.m_type_name] = sType; |
597 |
} |
} |
598 |
} |
} |
599 |
|
#if USE_GTKMM_GRID |
600 |
|
Gtk::Grid table; |
601 |
|
#else |
602 |
Gtk::Table table(2, 2); |
Gtk::Table table(2, 2); |
603 |
|
#endif |
604 |
Gtk::Label labelDimType(_("Dimension:"), Gtk::ALIGN_START); |
Gtk::Label labelDimType(_("Dimension:"), Gtk::ALIGN_START); |
605 |
Gtk::ComboBox comboDimType; |
Gtk::ComboBox comboDimType; |
606 |
comboDimType.set_model(refComboModel); |
comboDimType.set_model(refComboModel); |
607 |
comboDimType.pack_start(comboModel.m_type_id); |
comboDimType.pack_start(comboModel.m_type_id); |
608 |
comboDimType.pack_start(comboModel.m_type_name); |
comboDimType.pack_start(comboModel.m_type_name); |
609 |
Gtk::Label labelZones(_("Zones:"), Gtk::ALIGN_START); |
Gtk::Label labelZones(_("Zones:"), Gtk::ALIGN_START); |
610 |
|
#if USE_GTKMM_GRID |
611 |
|
table.attach(labelDimType, 0, 0); |
612 |
|
table.attach(comboDimType, 1, 0); |
613 |
|
table.attach(labelZones, 0, 1); |
614 |
|
#else |
615 |
table.attach(labelDimType, 0, 1, 0, 1); |
table.attach(labelDimType, 0, 1, 0, 1); |
616 |
table.attach(comboDimType, 1, 2, 0, 1); |
table.attach(comboDimType, 1, 2, 0, 1); |
617 |
table.attach(labelZones, 0, 1, 1, 2); |
table.attach(labelZones, 0, 1, 1, 2); |
618 |
|
#endif |
619 |
|
|
620 |
|
#if USE_GTKMM_BOX |
621 |
|
dialog.get_content_area()->pack_start(table); |
622 |
|
#else |
623 |
dialog.get_vbox()->pack_start(table); |
dialog.get_vbox()->pack_start(table); |
624 |
|
#endif |
625 |
|
|
626 |
// number of zones: use a combo box with fix values for gig |
// number of zones: use a combo box with fix values for gig |
627 |
// v2 and a spin button for v3 |
// v2 and a spin button for v3 |
651 |
table.attach(spinZones, 1, 2, 1, 2); |
table.attach(spinZones, 1, 2, 1, 2); |
652 |
} |
} |
653 |
|
|
654 |
|
#if HAS_GTKMM_STOCK |
655 |
dialog.add_button(Gtk::Stock::OK, 0); |
dialog.add_button(Gtk::Stock::OK, 0); |
656 |
dialog.add_button(Gtk::Stock::CANCEL, 1); |
dialog.add_button(Gtk::Stock::CANCEL, 1); |
657 |
|
#else |
658 |
|
dialog.add_button(_("_OK"), 0); |
659 |
|
dialog.add_button(_("_Cancel"), 1); |
660 |
|
#endif |
661 |
|
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
662 |
dialog.show_all_children(); |
dialog.show_all_children(); |
663 |
|
#endif |
664 |
|
|
665 |
if (!dialog.run()) { // OK selected ... |
if (!dialog.run()) { // OK selected ... |
666 |
Gtk::TreeModel::iterator iterType = comboDimType.get_active(); |
Gtk::TreeModel::iterator iterType = comboDimType.get_active(); |