17 |
* 02110-1301 USA. |
* 02110-1301 USA. |
18 |
*/ |
*/ |
19 |
|
|
20 |
|
#include <glibmmconfig.h> |
21 |
|
// threads.h must be included first to be able to build with |
22 |
|
// G_DISABLE_DEPRECATED |
23 |
|
#if (GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION == 31 && GLIBMM_MICRO_VERSION >= 2) || \ |
24 |
|
(GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION > 31) || GLIBMM_MAJOR_VERSION > 2 |
25 |
|
#include <glibmm/threads.h> |
26 |
|
#endif |
27 |
|
|
28 |
#include "dimensionmanager.h" |
#include "dimensionmanager.h" |
29 |
|
|
|
#include <gtkmm/stock.h> |
|
30 |
#include <gtkmm/messagedialog.h> |
#include <gtkmm/messagedialog.h> |
31 |
#include <gtkmm/dialog.h> |
#include <gtkmm/dialog.h> |
32 |
#include <gtkmm/comboboxtext.h> |
#include <gtkmm/comboboxtext.h> |
243 |
} |
} |
244 |
|
|
245 |
DimensionManager::DimensionManager() : |
DimensionManager::DimensionManager() : |
246 |
addButton(Gtk::Stock::ADD), removeButton(Gtk::Stock::REMOVE), |
addButton(_("_Add"), true), |
247 |
allRegionsCheckBox(_("All Regions")) |
removeButton(_("_Remove"), true), |
248 |
|
allRegionsCheckBox(_("All Regions")) |
249 |
{ |
{ |
250 |
ignoreColumnClicked = true; |
ignoreColumnClicked = true; |
251 |
|
|
392 |
} |
} |
393 |
|
|
394 |
void DimensionManager::onColumnClicked() { |
void DimensionManager::onColumnClicked() { |
395 |
|
printf("DimensionManager::onColumnClicked()\n"); |
396 |
|
|
397 |
|
//FIXME: BUG: this method is currently very unreliably called, it should actually be called when the user selects another column, it is ATM however also called when the table content changed programmatically causing the dialog below to popup at undesired times ! |
398 |
|
|
399 |
//HACK: Prevents that onColumnClicked() gets called multiple times or at times where it is not desired |
//HACK: Prevents that onColumnClicked() gets called multiple times or at times where it is not desired |
400 |
if (ignoreColumnClicked) { |
if (ignoreColumnClicked) { |
401 |
ignoreColumnClicked = false; |
ignoreColumnClicked = false; |
402 |
return; |
return; |
403 |
} |
} |
404 |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 18) || GTKMM_MAJOR_VERSION > 2 |
405 |
|
// prevents app to crash if this dialog is closed |
406 |
|
if (!get_visible()) |
407 |
|
return; |
408 |
|
#else |
409 |
|
# warning Your GTKMM version is too old; dimension manager dialog might crash when changing a dimension type ! |
410 |
|
#endif |
411 |
|
|
412 |
Gtk::TreeModel::Path path; |
Gtk::TreeModel::Path path; |
413 |
Gtk::TreeViewColumn* focus_column; |
Gtk::TreeViewColumn* focus_column; |
442 |
table.attach(comboDimType, 1, 2, 0, 1); |
table.attach(comboDimType, 1, 2, 0, 1); |
443 |
dialog.get_vbox()->pack_start(table); |
dialog.get_vbox()->pack_start(table); |
444 |
|
|
445 |
dialog.add_button(Gtk::Stock::OK, 0); |
dialog.add_button(_("_OK"), 0); |
446 |
dialog.add_button(Gtk::Stock::CANCEL, 1); |
dialog.add_button(_("_Cancel"), 1); |
447 |
dialog.show_all_children(); |
dialog.show_all_children(); |
448 |
|
|
449 |
comboDimType.set_active(oldTypeIndex); |
comboDimType.set_active(oldTypeIndex); |
450 |
|
|
451 |
if (!dialog.run()) { // OK selected ... |
if (!dialog.run()) { // OK selected ... |
452 |
|
ignoreColumnClicked = true; |
453 |
Gtk::TreeModel::iterator iterType = comboDimType.get_active(); |
Gtk::TreeModel::iterator iterType = comboDimType.get_active(); |
454 |
if (!iterType) return; |
if (!iterType) return; |
455 |
Gtk::TreeModel::Row rowType = *iterType; |
Gtk::TreeModel::Row rowType = *iterType; |
458 |
gig::dimension_t newType = static_cast<gig::dimension_t>(iTypeID); |
gig::dimension_t newType = static_cast<gig::dimension_t>(iTypeID); |
459 |
if (newType == oldType) return; |
if (newType == oldType) return; |
460 |
//printf("change 0x%x -> 0x%x\n", oldType, newType); |
//printf("change 0x%x -> 0x%x\n", oldType, newType); |
|
ignoreColumnClicked = true; |
|
461 |
|
|
462 |
// assemble the list of regions where the selected dimension type |
// assemble the list of regions where the selected dimension type |
463 |
// shall be changed |
// shall be changed |
572 |
table.attach(spinZones, 1, 2, 1, 2); |
table.attach(spinZones, 1, 2, 1, 2); |
573 |
} |
} |
574 |
|
|
575 |
dialog.add_button(Gtk::Stock::OK, 0); |
dialog.add_button(_("_OK"), 0); |
576 |
dialog.add_button(Gtk::Stock::CANCEL, 1); |
dialog.add_button(_("_Cancel"), 1); |
577 |
dialog.show_all_children(); |
dialog.show_all_children(); |
578 |
|
|
579 |
if (!dialog.run()) { // OK selected ... |
if (!dialog.run()) { // OK selected ... |