summaryrefslogtreecommitdiffstats
path: root/src/ui/dialog/input.cpp
diff options
context:
space:
mode:
authorMartin Owens <doctormo@gmail.com>2014-03-27 01:33:44 +0000
committerMartin Owens <doctormo@gmail.com>2014-03-27 01:33:44 +0000
commit5a4fb2325f60d292b47330f540b26a3279341c90 (patch)
treed2aa7967be25450b83e625025366c618101ae49f /src/ui/dialog/input.cpp
parentThe Polar Arrange Tab of the Arrange Dialog now hides the parametric (diff)
parentRemove Snap menu item and improve grid menu item text (diff)
downloadinkscape-5a4fb2325f60d292b47330f540b26a3279341c90.tar.gz
inkscape-5a4fb2325f60d292b47330f540b26a3279341c90.zip
Commit a merge to trunk, with probabal errors
(bzr r11073.1.36)
Diffstat (limited to 'src/ui/dialog/input.cpp')
-rw-r--r--src/ui/dialog/input.cpp710
1 files changed, 519 insertions, 191 deletions
diff --git a/src/ui/dialog/input.cpp b/src/ui/dialog/input.cpp
index eb2ddb88f..2d4755fd2 100644
--- a/src/ui/dialog/input.cpp
+++ b/src/ui/dialog/input.cpp
@@ -17,7 +17,9 @@
#include <glib/gprintf.h>
#include <glibmm/i18n.h>
+
#include <gtkmm/alignment.h>
+#include <gtkmm/buttonbox.h>
#include <gtkmm/cellrenderercombo.h>
#include <gtkmm/checkbutton.h>
#include <gtkmm/comboboxtext.h>
@@ -31,7 +33,13 @@
#include <gtkmm/paned.h>
#include <gtkmm/progressbar.h>
#include <gtkmm/scrolledwindow.h>
-#include <gtkmm/table.h>
+
+#if WITH_GTKMM_3_0
+# include <gtkmm/grid.h>
+#else
+# include <gtkmm/table.h>
+#endif
+
#include <gtkmm/treemodel.h>
#include <gtkmm/treemodelcolumn.h>
#include <gtkmm/treestore.h>
@@ -45,10 +53,10 @@
/* XPM */
static char const * core_xpm[] = {
"16 16 4 1",
-" c None",
-". c #808080",
-"+ c #000000",
-"@ c #FFFFFF",
+" c None",
+". c #808080",
+"+ c #000000",
+"@ c #FFFFFF",
" ",
" ",
" ",
@@ -283,9 +291,9 @@ static char const *button_on[] = {
/* XPM */
static char const * axis_none_xpm[] = {
"24 8 3 1",
-" c None",
-". c #000000",
-"+ c #808080",
+" c None",
+". c #000000",
+"+ c #808080",
" ",
" .++++++++++++++++++. ",
" .+ . .+. ",
@@ -297,10 +305,10 @@ static char const * axis_none_xpm[] = {
/* XPM */
static char const * axis_off_xpm[] = {
"24 8 4 1",
-" c None",
-". c #808080",
-"+ c #000000",
-"@ c #FFFFFF",
+" c None",
+". c #808080",
+"+ c #000000",
+"@ c #FFFFFF",
" ",
" .++++++++++++++++++. ",
" .+@@@@@@@@@@@@@@@@@@+. ",
@@ -312,9 +320,9 @@ static char const * axis_off_xpm[] = {
/* XPM */
static char const * axis_on_xpm[] = {
"24 8 3 1",
-" c None",
-". c #000000",
-"+ c #00FF00",
+" c None",
+". c #000000",
+"+ c #00FF00",
" ",
" .................... ",
" ..++++++++++++++++++.. ",
@@ -357,6 +365,15 @@ static std::map<Gdk::InputMode, Glib::ustring> &getModeToString()
return mapping;
}
+static int getModeId(Gdk::InputMode im)
+{
+ if (im == Gdk::MODE_DISABLED) return 0;
+ if (im == Gdk::MODE_SCREEN) return 1;
+ if (im == Gdk::MODE_WINDOW) return 2;
+
+ return 0;
+}
+
static std::map<Glib::ustring, Gdk::InputMode> &getStringToMode()
{
static std::map<Glib::ustring, Gdk::InputMode> mapping;
@@ -400,15 +417,64 @@ private:
static void setCellStateToggle(Gtk::CellRenderer *rndr, Gtk::TreeIter const &iter);
void saveSettings();
+ void onTreeSelect();
void useExtToggled();
- Glib::RefPtr<Gtk::TreeStore> store;
- Gtk::TreeIter tabletIter;
- Gtk::TreeView tree;
- Gtk::ScrolledWindow treeScroller;
+ void onModeChange();
+ void setKeys(gint count);
+ void setAxis(gint count);
+
+ Glib::RefPtr<Gtk::TreeStore> confDeviceStore;
+ Gtk::TreeIter confDeviceIter;
+ Gtk::TreeView confDeviceTree;
+ Gtk::ScrolledWindow confDeviceScroller;
Blink watcher;
Gtk::CheckButton useExt;
Gtk::Button save;
+
+#if WITH_GTKMM_3_0
+ Gtk::Paned pane;
+#else
+ Gtk::HPaned pane;
+#endif
+
+ Gtk::VBox detailsBox;
+ Gtk::HBox titleFrame;
+ Gtk::Label titleLabel;
+ Inkscape::UI::Widget::Frame axisFrame;
+ Inkscape::UI::Widget::Frame keysFrame;
+ Gtk::VBox axisVBox;
+ Gtk::ComboBoxText modeCombo;
+ Gtk::Label modeLabel;
+ Gtk::HBox modeBox;
+
+ class KeysColumns : public Gtk::TreeModel::ColumnRecord
+ {
+ public:
+ KeysColumns()
+ {
+ add(name);
+ add(value);
+ }
+ virtual ~KeysColumns() {}
+
+ Gtk::TreeModelColumn<Glib::ustring> name;
+ Gtk::TreeModelColumn<Glib::ustring> value;
+ };
+
+ KeysColumns keysColumns;
+ KeysColumns axisColumns;
+
+ Glib::RefPtr<Gtk::ListStore> axisStore;
+ Gtk::TreeView axisTree;
+ Gtk::ScrolledWindow axisScroll;
+
+ Glib::RefPtr<Gtk::ListStore> keysStore;
+ Gtk::TreeView keysTree;
+ Gtk::ScrolledWindow keysScroll;
+ Gtk::CellRendererAccel _kb_shortcut_renderer;
+
+
};
static DeviceModelColumns &getCols();
@@ -425,40 +491,60 @@ private:
GdkInputSource lastSourceSeen;
Glib::ustring lastDevnameSeen;
- Glib::RefPtr<Gtk::TreeStore> store;
- Gtk::TreeIter tabletIter;
- Gtk::TreeView tree;
- Inkscape::UI::Widget::Frame detailFrame;
+ Glib::RefPtr<Gtk::TreeStore> deviceStore;
+ Gtk::TreeIter deviceIter;
+ Gtk::TreeView deviceTree;
Inkscape::UI::Widget::Frame testFrame;
+ Inkscape::UI::Widget::Frame axisFrame;
Gtk::ScrolledWindow treeScroller;
Gtk::ScrolledWindow detailScroller;
+
+#if WITH_GTKMM_3_0
+ Gtk::Paned splitter;
+ Gtk::Paned split2;
+#else
Gtk::HPaned splitter;
Gtk::VPaned split2;
+#endif
+
Gtk::Label devName;
Gtk::Label devKeyCount;
Gtk::Label devAxesCount;
Gtk::ComboBoxText axesCombo;
Gtk::ProgressBar axesValues[6];
+
+#if WITH_GTKMM_3_0
+ Gtk::Grid axisTable;
+#else
+ Gtk::Table axisTable;
+#endif
+
Gtk::ComboBoxText buttonCombo;
Gtk::ComboBoxText linkCombo;
sigc::connection linkConnection;
Gtk::Label keyVal;
Gtk::Entry keyEntry;
- Gtk::Table devDetails;
Gtk::Notebook topHolder;
Gtk::Image testThumb;
Gtk::Image testButtons[24];
Gtk::Image testAxes[8];
+
+#if WITH_GTKMM_3_0
+ Gtk::Grid imageTable;
+#else
Gtk::Table imageTable;
+#endif
+
Gtk::EventBox testDetector;
ConfPanel cfgPanel;
+
static void setupTree( Glib::RefPtr<Gtk::TreeStore> store, Gtk::TreeIter &tablet );
void setupValueAndCombo( gint reported, gint actual, Gtk::Label& label, Gtk::ComboBoxText& combo );
void updateTestButtons( Glib::ustring const& key, gint hotButton );
void updateTestAxes( Glib::ustring const& key, GdkDevice* dev );
- void mapAxesValues( Glib::ustring const& key, guint numAxes, gdouble const * axes, GdkDevice* dev);
+ void mapAxesValues( Glib::ustring const& key, gdouble const * axes, GdkDevice* dev);
Glib::ustring getKeyFor( GdkDevice* device );
bool eventSnoop(GdkEvent* event);
void linkComboChanged();
@@ -526,19 +612,28 @@ InputDialogImpl::InputDialogImpl() :
lastSourceSeen((GdkInputSource)-1),
lastDevnameSeen(""),
- store(Gtk::TreeStore::create(getCols())),
- tabletIter(),
- tree(store),
- detailFrame(),
+ deviceStore(Gtk::TreeStore::create(getCols())),
+ deviceIter(),
+ deviceTree(deviceStore),
testFrame(_("Test Area")),
+ axisFrame(_("Axis")),
treeScroller(),
detailScroller(),
splitter(),
+#if WITH_GTKMM_3_0
+ split2(Gtk::ORIENTATION_VERTICAL),
+ axisTable(),
+#else
split2(),
+ axisTable(11, 2),
+#endif
linkCombo(),
- devDetails(12, 2),
topHolder(),
+#if WITH_GTKMM_3_0
+ imageTable(),
+#else
imageTable(8, 7),
+#endif
testDetector(),
cfgPanel()
{
@@ -547,10 +642,12 @@ InputDialogImpl::InputDialogImpl() :
treeScroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
treeScroller.set_shadow_type(Gtk::SHADOW_IN);
- treeScroller.add(tree);
+ treeScroller.add(deviceTree);
treeScroller.set_size_request(50, 0);
- split2.pack1(testFrame, false, false);
- split2.pack2(detailFrame, true, true);
+
+ split2.pack1(axisFrame, false, false);
+ split2.pack2(testFrame, true, true);
+
splitter.pack1(treeScroller);
splitter.pack2(split2);
@@ -558,13 +655,27 @@ InputDialogImpl::InputDialogImpl() :
testFrame.add(testDetector);
testThumb.set(getPix(PIX_TABLET));
testThumb.set_padding(24, 24);
+
+#if WITH_GTKMM_3_0
+ testThumb.set_hexpand();
+ testThumb.set_vexpand();
+ imageTable.attach(testThumb, 0, 0, 8, 1);
+#else
imageTable.attach(testThumb, 0, 8, 0, 1, ::Gtk::EXPAND, ::Gtk::EXPAND);
+#endif
+
{
guint col = 0;
guint row = 1;
for ( guint num = 0; num < G_N_ELEMENTS(testButtons); num++ ) {
testButtons[num].set(getPix(PIX_BUTTONS_NONE));
+
+#if WITH_GTKMM_3_0
+ imageTable.attach(testButtons[num], col, row, 1, 1);
+#else
imageTable.attach(testButtons[num], col, col + 1, row, row + 1, ::Gtk::FILL, ::Gtk::FILL);
+#endif
+
col++;
if (col > 7) {
col = 0;
@@ -575,7 +686,13 @@ InputDialogImpl::InputDialogImpl() :
col = 0;
for ( guint num = 0; num < G_N_ELEMENTS(testAxes); num++ ) {
testAxes[num].set(getPix(PIX_AXIS_NONE));
+
+#if WITH_GTKMM_3_0
+ imageTable.attach(testAxes[num], col * 2, row, 2, 1);
+#else
imageTable.attach(testAxes[num], col * 2, (col + 1) * 2, row, row + 1, ::Gtk::FILL, ::Gtk::FILL);
+#endif
+
col++;
if (col > 3) {
col = 0;
@@ -585,54 +702,76 @@ InputDialogImpl::InputDialogImpl() :
}
- topHolder.append_page(cfgPanel, _("Configuration"));
- topHolder.append_page(splitter, _("Hardware"));
- topHolder.show_all();
- topHolder.set_current_page(0);
+ // This is a hidden preference to enable the "hardware" details in a separate tab
+ // By default this is not available to users
+ if (Preferences::get()->getBool("/dialogs/inputdevices/test")) {
+ topHolder.append_page(cfgPanel, _("Configuration"));
+ topHolder.append_page(splitter, _("Hardware"));
+ topHolder.show_all();
+ topHolder.set_current_page(0);
+ contents->pack_start(topHolder);
+ } else {
+ contents->pack_start(cfgPanel);
+ }
- contents->pack_start(topHolder);
int rowNum = 0;
/* Gtk::Label* lbl = Gtk::manage(new Gtk::Label(_("Name:")));
- devDetails.attach(*lbl, 0, 1, rowNum, rowNum+ 1,
+ axisTable.attach(*lbl, 0, 1, rowNum, rowNum+ 1,
::Gtk::FILL,
::Gtk::SHRINK);
- devDetails.attach(devName, 1, 2, rowNum, rowNum + 1,
+ axisTable.attach(devName, 1, 2, rowNum, rowNum + 1,
::Gtk::SHRINK,
::Gtk::SHRINK);
rowNum++;*/
+ axisFrame.add(axisTable);
+
Gtk::Label *lbl = Gtk::manage(new Gtk::Label(_("Link:")));
- devDetails.attach(*lbl, 0, 1, rowNum, rowNum+ 1,
+
+#if WITH_GTKMM_3_0
+ axisTable.attach(*lbl, 0, rowNum, 1, 1);
+#else
+ axisTable.attach(*lbl, 0, 1, rowNum, rowNum+ 1,
::Gtk::FILL,
::Gtk::SHRINK);
+#endif
-#if WITH_GTKMM_2_24
linkCombo.append(_("None"));
-#else
- linkCombo.append_text(_("None"));
-#endif
linkCombo.set_active_text(_("None"));
linkCombo.set_sensitive(false);
linkConnection = linkCombo.signal_changed().connect(sigc::mem_fun(*this, &InputDialogImpl::linkComboChanged));
- devDetails.attach(linkCombo, 1, 2, rowNum, rowNum + 1,
+#if WITH_GTKMM_3_0
+ axisTable.attach(linkCombo, 1, rowNum, 1, 1);
+#else
+ axisTable.attach(linkCombo, 1, 2, rowNum, rowNum + 1,
::Gtk::FILL,
::Gtk::SHRINK);
+#endif
+
rowNum++;
+
lbl = Gtk::manage(new Gtk::Label(_("Axes count:")));
- devDetails.attach(*lbl, 0, 1, rowNum, rowNum+ 1,
+
+#if WITH_GTKMM_3_0
+ axisTable.attach(*lbl, 0, rowNum, 1, 1);
+ axisTable.attach(devAxesCount, 1, rowNum, 1, 1);
+#else
+ axisTable.attach(*lbl, 0, 1, rowNum, rowNum+ 1,
::Gtk::FILL,
::Gtk::SHRINK);
- devDetails.attach(devAxesCount, 1, 2, rowNum, rowNum + 1,
+ axisTable.attach(devAxesCount, 1, 2, rowNum, rowNum + 1,
::Gtk::SHRINK,
::Gtk::SHRINK);
+#endif
rowNum++;
+
/*
lbl = Gtk::manage(new Gtk::Label(_("Actual axes count:")));
devDetails.attach(*lbl, 0, 1, rowNum, rowNum+ 1,
@@ -647,24 +786,42 @@ InputDialogImpl::InputDialogImpl() :
for ( guint barNum = 0; barNum < static_cast<guint>(G_N_ELEMENTS(axesValues)); barNum++ ) {
lbl = Gtk::manage(new Gtk::Label(_("axis:")));
- devDetails.attach(*lbl, 0, 1, rowNum, rowNum+ 1,
- ::Gtk::FILL,
+
+#if WITH_GTKMM_3_0
+ lbl->set_hexpand();
+ axisTable.attach(*lbl, 0, rowNum, 1, 1);
+
+ axesValues[barNum].set_hexpand();
+ axisTable.attach(axesValues[barNum], 1, rowNum, 1, 1);
+#else
+ axisTable.attach(*lbl, 0, 1, rowNum, rowNum+ 1,
+ ::Gtk::EXPAND,
::Gtk::SHRINK);
- devDetails.attach(axesValues[barNum], 1, 2, rowNum, rowNum + 1,
+ axisTable.attach(axesValues[barNum], 1, 2, rowNum, rowNum + 1,
::Gtk::EXPAND,
::Gtk::SHRINK);
+#endif
+
axesValues[barNum].set_sensitive(false);
rowNum++;
+
+
}
lbl = Gtk::manage(new Gtk::Label(_("Button count:")));
- devDetails.attach(*lbl, 0, 1, rowNum, rowNum+ 1,
+
+#if WITH_GTKMM_3_0
+ axisTable.attach(*lbl, 0, rowNum, 1, 1);
+ axisTable.attach(devKeyCount, 1, rowNum, 1, 1);
+#else
+ axisTable.attach(*lbl, 0, 1, rowNum, rowNum+ 1,
::Gtk::FILL,
::Gtk::SHRINK);
- devDetails.attach(devKeyCount, 1, 2, rowNum, rowNum + 1,
+ axisTable.attach(devKeyCount, 1, 2, rowNum, rowNum + 1,
::Gtk::SHRINK,
::Gtk::SHRINK);
+#endif
rowNum++;
@@ -680,9 +837,14 @@ InputDialogImpl::InputDialogImpl() :
rowNum++;
*/
- devDetails.attach(keyVal, 0, 2, rowNum, rowNum + 1,
+#if WITH_GTKMM_3_0
+ axisTable.attach(keyVal, 0, rowNum, 2, 1);
+#else
+ axisTable.attach(keyVal, 0, 2, rowNum, rowNum + 1,
::Gtk::FILL,
::Gtk::SHRINK);
+#endif
+
rowNum++;
@@ -692,22 +854,31 @@ InputDialogImpl::InputDialogImpl() :
// gint mask,
// GdkExtensionMode mode);
+
+ // TODO: Extension event stuff has been removed from public API in GTK+ 3
+ // Need to check that this hasn't broken anything
+#if !GTK_CHECK_VERSION(3,0,0)
gtk_widget_set_extension_events( GTK_WIDGET(testDetector.gobj()), GDK_EXTENSION_EVENTS_ALL );
+#endif
testDetector.add_events(Gdk::POINTER_MOTION_MASK|Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK |Gdk::PROXIMITY_IN_MASK|Gdk::PROXIMITY_OUT_MASK|Gdk::SCROLL_MASK);
- devDetails.attach(keyEntry, 0, 2, rowNum, rowNum + 1,
+#if WITH_GTKMM_3_0
+ axisTable.attach(keyEntry, 0, rowNum, 2, 1);
+#else
+ axisTable.attach(keyEntry, 0, 2, rowNum, rowNum + 1,
::Gtk::FILL,
::Gtk::SHRINK);
+#endif
+
rowNum++;
- devDetails.set_sensitive(false);
- detailScroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
+ axisTable.set_sensitive(false);
+
+/* detailScroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
detailScroller.set_shadow_type(Gtk::SHADOW_NONE);
detailScroller.set_border_width (0);
- detailScroller.add(devDetails);
- detailFrame.add(detailScroller);
- detailFrame.set_size_request(0, 60);
+ detailScroller.add(devDetails);*/
//- 16x16/devices
// gnome-dev-mouse-optical
@@ -716,25 +887,24 @@ InputDialogImpl::InputDialogImpl() :
// mouse
-
//Add the TreeView's view columns:
- tree.append_column("I", getCols().thumbnail);
- tree.append_column("Bar", getCols().description);
+ deviceTree.append_column("I", getCols().thumbnail);
+ deviceTree.append_column("Bar", getCols().description);
- tree.set_enable_tree_lines();
- tree.set_headers_visible(false);
- tree.get_selection()->signal_changed().connect(sigc::mem_fun(*this, &InputDialogImpl::resyncToSelection));
+ deviceTree.set_enable_tree_lines();
+ deviceTree.set_headers_visible(false);
+ deviceTree.get_selection()->signal_changed().connect(sigc::mem_fun(*this, &InputDialogImpl::resyncToSelection));
- setupTree( store, tabletIter );
+ setupTree( deviceStore, deviceIter );
Inkscape::DeviceManager::getManager().signalDeviceChanged().connect(sigc::mem_fun(*this, &InputDialogImpl::handleDeviceChange));
Inkscape::DeviceManager::getManager().signalAxesChanged().connect(sigc::mem_fun(*this, &InputDialogImpl::updateDeviceAxes));
Inkscape::DeviceManager::getManager().signalButtonsChanged().connect(sigc::mem_fun(*this, &InputDialogImpl::updateDeviceButtons));
- Glib::RefPtr<Gtk::TreeView> treePtr(&tree);
- Inkscape::DeviceManager::getManager().signalLinkChanged().connect(sigc::bind(sigc::ptr_fun(&InputDialogImpl::updateDeviceLinks), tabletIter, treePtr));
+ Glib::RefPtr<Gtk::TreeView> treePtr(&deviceTree);
+ Inkscape::DeviceManager::getManager().signalLinkChanged().connect(sigc::bind(sigc::ptr_fun(&InputDialogImpl::updateDeviceLinks), deviceIter, treePtr));
- tree.expand_all();
+ deviceTree.expand_all();
show_all_children();
}
@@ -776,12 +946,30 @@ static Glib::ustring getCommon( std::list<Glib::ustring> const &names )
return result;
}
+
+void InputDialogImpl::ConfPanel::onModeChange()
+{
+ Glib::ustring newText = modeCombo.get_active_text();
+
+ Glib::RefPtr<Gtk::TreeSelection> sel = confDeviceTree.get_selection();
+ Gtk::TreeModel::iterator iter = sel->get_selected();
+ if (iter) {
+ Glib::RefPtr<InputDevice const> dev = (*iter)[getCols().device];
+ if (dev && (getStringToMode().find(newText) != getStringToMode().end())) {
+ Gdk::InputMode mode = getStringToMode()[newText];
+ Inkscape::DeviceManager::getManager().setMode( dev->getId(), mode );
+ }
+ }
+
+}
+
+
void InputDialogImpl::setupTree( Glib::RefPtr<Gtk::TreeStore> store, Gtk::TreeIter &tablet )
{
std::list<Glib::RefPtr<InputDevice const> > devList = Inkscape::DeviceManager::getManager().getDevices();
if ( !devList.empty() ) {
- Gtk::TreeModel::Row row = *(store->append());
- row[getCols().description] = _("Hardware");
+ //Gtk::TreeModel::Row row = *(store->append());
+ //row[getCols().description] = _("Hardware");
// Let's make some tablets!!!
std::list<TabletTmp> tablets;
@@ -806,7 +994,7 @@ void InputDialogImpl::setupTree( Glib::RefPtr<Gtk::TreeStore> store, Gtk::TreeIt
// Phase 2 - build a UI for the present devices
for ( std::list<TabletTmp>::iterator it = tablets.begin(); it != tablets.end(); ++it ) {
- tablet = store->append(row.children());
+ tablet = store->prepend(/*row.children()*/);
Gtk::TreeModel::Row childrow = *tablet;
if ( it->name.empty() ) {
// Check to see if we can derive one
@@ -869,13 +1057,14 @@ void InputDialogImpl::setupTree( Glib::RefPtr<Gtk::TreeStore> store, Gtk::TreeIt
for ( std::list<Glib::RefPtr<InputDevice const> >::iterator it = devList.begin(); it != devList.end(); ++it ) {
Glib::RefPtr<InputDevice const> dev = *it;
if ( dev && (consumed.find( dev->getId() ) == consumed.end()) ) {
- Gtk::TreeModel::Row deviceRow = *(store->append(row.children()));
+ Gtk::TreeModel::Row deviceRow = *(store->prepend(/*row.children()*/));
deviceRow[getCols().description] = dev->getName();
deviceRow[getCols().device] = dev;
deviceRow[getCols().mode] = dev->getMode();
deviceRow[getCols().thumbnail] = getPix(PIX_CORE);
}
}
+
} else {
g_warning("No devices found");
}
@@ -884,88 +1073,163 @@ void InputDialogImpl::setupTree( Glib::RefPtr<Gtk::TreeStore> store, Gtk::TreeIt
InputDialogImpl::ConfPanel::ConfPanel() :
Gtk::VBox(),
- store(Gtk::TreeStore::create(getCols())),
- tabletIter(),
- tree(store),
- treeScroller(),
+ confDeviceStore(Gtk::TreeStore::create(getCols())),
+ confDeviceIter(),
+ confDeviceTree(confDeviceStore),
+ confDeviceScroller(),
watcher(*this),
useExt(_("_Use pressure-sensitive tablet (requires restart)"), true),
- save(_("_Save"), true)
+ save(_("_Save"), true),
+ detailsBox(false, 4),
+ titleFrame(false, 4),
+ titleLabel(""),
+ axisFrame(_("Axes")),
+ keysFrame(_("Keys")),
+ modeLabel(_("Mode:")),
+ modeBox(false, 4)
+
{
- pack_start(treeScroller);
- treeScroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
- treeScroller.add(tree);
- class Foo : public Gtk::TreeModel::ColumnRecord {
+ confDeviceScroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
+ confDeviceScroller.set_shadow_type(Gtk::SHADOW_IN);
+ confDeviceScroller.add(confDeviceTree);
+ confDeviceScroller.set_size_request(120, 0);
+
+ /* class Foo : public Gtk::TreeModel::ColumnRecord {
public :
Gtk::TreeModelColumn<Glib::ustring> one;
Foo() {add(one);}
};
static Foo foo;
- Glib::RefPtr<Gtk::ListStore> poppers = Gtk::ListStore::create(foo);
- poppers->reference();
-
- Gtk::TreeModel::Row row = *(poppers->append());
- row[foo.one] = getModeToString()[Gdk::MODE_DISABLED];
- row = *(poppers->append());
- row[foo.one] = getModeToString()[Gdk::MODE_SCREEN];
- row = *(poppers->append());
- row[foo.one] = getModeToString()[Gdk::MODE_WINDOW];
//Add the TreeView's view columns:
{
Gtk::CellRendererToggle *rendr = new Gtk::CellRendererToggle();
Gtk::TreeViewColumn *col = new Gtk::TreeViewColumn("xx", *rendr);
if (col) {
- tree.append_column(*col);
+ confDeviceTree.append_column(*col);
col->set_cell_data_func(*rendr, sigc::ptr_fun(setCellStateToggle));
- rendr->signal_toggled().connect(sigc::bind(sigc::ptr_fun(commitCellStateChange), store));
+ rendr->signal_toggled().connect(sigc::bind(sigc::ptr_fun(commitCellStateChange), confDeviceStore));
}
- }
+ }*/
- int expPos = tree.append_column("", getCols().expander);
+ //int expPos = confDeviceTree.append_column("", getCols().expander);
- tree.append_column("I", getCols().thumbnail);
- tree.append_column("Bar", getCols().description);
+ confDeviceTree.append_column("I", getCols().thumbnail);
+ confDeviceTree.append_column("Bar", getCols().description);
- {
- Gtk::CellRendererCombo *rendr = new Gtk::CellRendererCombo();
- rendr->property_model().set_value(poppers);
- rendr->property_text_column().set_value(0);
- rendr->property_has_entry() = false;
+ //confDeviceTree.get_column(0)->set_fixed_width(100);
+ //confDeviceTree.get_column(1)->set_expand();
+
+/* {
Gtk::TreeViewColumn *col = new Gtk::TreeViewColumn("X", *rendr);
if (col) {
- tree.append_column(*col);
+ confDeviceTree.append_column(*col);
col->set_cell_data_func(*rendr, sigc::ptr_fun(setModeCellString));
- rendr->signal_edited().connect(sigc::bind(sigc::ptr_fun(commitCellModeChange), store));
+ rendr->signal_edited().connect(sigc::bind(sigc::ptr_fun(commitCellModeChange), confDeviceStore));
rendr->property_editable() = true;
}
- }
+ }*/
- tree.set_enable_tree_lines();
- tree.set_headers_visible(false);
- tree.set_expander_column( *tree.get_column(expPos - 1) );
+ //confDeviceTree.set_enable_tree_lines();
+ confDeviceTree.property_enable_tree_lines() = false;
+ confDeviceTree.property_enable_grid_lines() = false;
+ confDeviceTree.set_headers_visible(false);
+ //confDeviceTree.set_expander_column( *confDeviceTree.get_column(expPos - 1) );
- setupTree( store, tabletIter );
+ confDeviceTree.get_selection()->signal_changed().connect(sigc::mem_fun(*this, &InputDialogImpl::ConfPanel::onTreeSelect));
- Glib::RefPtr<Gtk::TreeView> treePtr(&tree);
- Inkscape::DeviceManager::getManager().signalLinkChanged().connect(sigc::bind(sigc::ptr_fun(&InputDialogImpl::updateDeviceLinks), tabletIter, treePtr));
+ setupTree( confDeviceStore, confDeviceIter );
- tree.expand_all();
+ Glib::RefPtr<Gtk::TreeView> treePtr(&confDeviceTree);
+ Inkscape::DeviceManager::getManager().signalLinkChanged().connect(sigc::bind(sigc::ptr_fun(&InputDialogImpl::updateDeviceLinks), confDeviceIter, treePtr));
+
+ confDeviceTree.expand_all();
useExt.set_active(Preferences::get()->getBool("/options/useextinput/value"));
useExt.signal_toggled().connect(sigc::mem_fun(*this, &InputDialogImpl::ConfPanel::useExtToggled));
- pack_start(useExt, Gtk::PACK_SHRINK);
- save.signal_clicked().connect(sigc::mem_fun(*this, &InputDialogImpl::ConfPanel::saveSettings));
-#if WITH_GTKMM_2_22
- Gtk::Alignment *align = new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_START, 0, 0);
+#if WITH_GTKMM_3_0
+ Gtk::ButtonBox *buttonBox = manage(new Gtk::ButtonBox);
#else
- Gtk::Alignment *align = new Gtk::Alignment(Gtk::ALIGN_RIGHT, Gtk::ALIGN_TOP, 0, 0);
+ Gtk::HButtonBox *buttonBox = manage (new Gtk::HButtonBox);
#endif
- align->add(save);
- pack_start(*Gtk::manage(align), Gtk::PACK_SHRINK);
+
+ buttonBox->set_layout (Gtk::BUTTONBOX_END);
+ //Gtk::Alignment *align = new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_START, 0, 0);
+ buttonBox->add(save);
+ save.signal_clicked().connect(sigc::mem_fun(*this, &InputDialogImpl::ConfPanel::saveSettings));
+
+ titleFrame.pack_start(titleLabel, true, true);
+ //titleFrame.set_shadow_type(Gtk::SHADOW_IN);
+
+ modeCombo.append(getModeToString()[Gdk::MODE_DISABLED]);
+ modeCombo.append(getModeToString()[Gdk::MODE_SCREEN]);
+ modeCombo.append(getModeToString()[Gdk::MODE_WINDOW]);
+ modeCombo.set_tooltip_text(_("A device can be 'Disabled', its co-ordinates mapped to the whole 'Screen', or to a single (usually focused) 'Window'"));
+ modeCombo.signal_changed().connect(sigc::mem_fun(*this, &InputDialogImpl::ConfPanel::onModeChange));
+
+ modeBox.pack_start(modeLabel, false, false);
+ modeBox.pack_start(modeCombo, true, true);
+
+ axisVBox.add(axisScroll);
+ axisFrame.add(axisVBox);
+
+ keysFrame.add(keysScroll);
+
+ /**
+ * Scrolled Window
+ */
+ keysScroll.add(keysTree);
+ keysScroll.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
+ keysScroll.set_shadow_type(Gtk::SHADOW_IN);
+ keysScroll.set_size_request(120, 80);
+
+ keysStore = Gtk::ListStore::create(keysColumns);
+
+ _kb_shortcut_renderer.property_editable() = true;
+
+ keysTree.set_model(keysStore);
+ keysTree.set_headers_visible(false);
+ keysTree.append_column("Name", keysColumns.name);
+ keysTree.append_column("Value", keysColumns.value);
+
+ //keysTree.append_column("Value", _kb_shortcut_renderer);
+ //keysTree.get_column(1)->add_attribute(_kb_shortcut_renderer.property_text(), keysColumns.value);
+ //_kb_shortcut_renderer.signal_accel_edited().connect( sigc::mem_fun(*this, &InputDialogImpl::onKBTreeEdited) );
+ //_kb_shortcut_renderer.signal_accel_cleared().connect( sigc::mem_fun(*this, &InputDialogImpl::onKBTreeCleared) );
+
+ axisStore = Gtk::ListStore::create(axisColumns);
+
+ axisTree.set_model(axisStore);
+ axisTree.set_headers_visible(false);
+ axisTree.append_column("Name", axisColumns.name);
+ axisTree.append_column("Value", axisColumns.value);
+
+ /**
+ * Scrolled Window
+ */
+ axisScroll.add(axisTree);
+ axisScroll.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
+ axisScroll.set_shadow_type(Gtk::SHADOW_IN);
+ axisScroll.set_size_request(0, 150);
+
+ pane.pack1(confDeviceScroller);
+ pane.pack2(detailsBox);
+
+ detailsBox.pack_start(titleFrame, false, false, 6);
+ detailsBox.pack_start(modeBox, false, false, 6);
+ detailsBox.pack_start(axisFrame, false, false);
+ detailsBox.pack_start(keysFrame, false, false);
+
+ pack_start(pane, true, true);
+ pack_start(useExt, Gtk::PACK_SHRINK);
+ pack_start(*buttonBox, false, false);
+
+ // Select the first device
+ confDeviceTree.get_selection()->select(confDeviceStore->get_iter("0"));
+
}
InputDialogImpl::ConfPanel::~ConfPanel()
@@ -998,6 +1262,8 @@ void InputDialogImpl::ConfPanel::commitCellModeChange(Glib::ustring const &path,
Inkscape::DeviceManager::getManager().setMode( dev->getId(), mode );
}
}
+
+
}
void InputDialogImpl::ConfPanel::setCellStateToggle(Gtk::CellRenderer *rndr, Gtk::TreeIter const &iter)
@@ -1032,6 +1298,25 @@ void InputDialogImpl::ConfPanel::commitCellStateChange(Glib::ustring const &path
}
}
+void InputDialogImpl::ConfPanel::onTreeSelect()
+{
+ Glib::RefPtr<Gtk::TreeSelection> treeSel = confDeviceTree.get_selection();
+ Gtk::TreeModel::iterator iter = treeSel->get_selected();
+ if (iter) {
+ Gtk::TreeModel::Row row = *iter;
+ Glib::ustring val = row[getCols().description];
+ Glib::RefPtr<InputDevice const> dev = row[getCols().device];
+ Gdk::InputMode mode = (*iter)[getCols().mode];
+ modeCombo.set_active(getModeId(mode));
+
+ titleLabel.set_markup("<b>" + row[getCols().description] + "</b>");
+
+ if (dev) {
+ setKeys(dev->getNumKeys());
+ setAxis(dev->getNumAxes());
+ }
+ }
+}
void InputDialogImpl::ConfPanel::saveSettings()
{
Inkscape::DeviceManager::getManager().saveConfig();
@@ -1073,8 +1358,8 @@ void InputDialogImpl::handleDeviceChange(Glib::RefPtr<InputDevice const> device)
{
// g_message("OUCH!!!! for %p hits %s", &device, device->getId().c_str());
std::vector<Glib::RefPtr<Gtk::TreeStore> > stores;
- stores.push_back(store);
- stores.push_back(cfgPanel.store);
+ stores.push_back(deviceStore);
+ stores.push_back(cfgPanel.confDeviceStore);
for (std::vector<Glib::RefPtr<Gtk::TreeStore> >::iterator it = stores.begin(); it != stores.end(); ++it) {
Gtk::TreeModel::iterator deviceIter;
@@ -1157,11 +1442,11 @@ bool InputDialogImpl::findDeviceByLink(const Gtk::TreeModel::iterator& iter,
void InputDialogImpl::updateDeviceLinks(Glib::RefPtr<InputDevice const> device, Gtk::TreeIter tabletIter, Glib::RefPtr<Gtk::TreeView> tree)
{
- Glib::RefPtr<Gtk::TreeStore> store = Glib::RefPtr<Gtk::TreeStore>::cast_dynamic(tree->get_model());
+ Glib::RefPtr<Gtk::TreeStore> deviceStore = Glib::RefPtr<Gtk::TreeStore>::cast_dynamic(tree->get_model());
// g_message("Links!!!! for %p hits [%s] with link of [%s]", &device, device->getId().c_str(), device->getLink().c_str());
Gtk::TreeModel::iterator deviceIter;
- store->foreach_iter( sigc::bind<Glib::ustring, Gtk::TreeModel::iterator*>(
+ deviceStore->foreach_iter( sigc::bind<Glib::ustring, Gtk::TreeModel::iterator*>(
sigc::ptr_fun(&InputDialogImpl::findDevice),
device->getId(),
&deviceIter) );
@@ -1179,16 +1464,16 @@ void InputDialogImpl::updateDeviceLinks(Glib::RefPtr<InputDevice const> device,
Glib::ustring descr = (*deviceIter)[getCols().description];
Glib::RefPtr<Gdk::Pixbuf> thumb = (*deviceIter)[getCols().thumbnail];
- Gtk::TreeModel::Row deviceRow = *store->append(tabletIter->children());
+ Gtk::TreeModel::Row deviceRow = *deviceStore->append(tabletIter->children());
deviceRow[getCols().description] = descr;
deviceRow[getCols().thumbnail] = thumb;
deviceRow[getCols().device] = dev;
deviceRow[getCols().mode] = dev->getMode();
Gtk::TreeModel::iterator oldParent = deviceIter->parent();
- store->erase(deviceIter);
+ deviceStore->erase(deviceIter);
if ( oldParent->children().empty() ) {
- store->erase(oldParent);
+ deviceStore->erase(oldParent);
}
}
} else {
@@ -1196,7 +1481,7 @@ void InputDialogImpl::updateDeviceLinks(Glib::RefPtr<InputDevice const> device,
if ( deviceIter->parent() == tabletIter ) {
// Simple case. Not already linked
- Gtk::TreeIter newGroup = store->append(tabletIter->children());
+ Gtk::TreeIter newGroup = deviceStore->append(tabletIter->children());
(*newGroup)[getCols().description] = _("Pen");
(*newGroup)[getCols().thumbnail] = getPix(PIX_PEN);
@@ -1204,7 +1489,7 @@ void InputDialogImpl::updateDeviceLinks(Glib::RefPtr<InputDevice const> device,
Glib::ustring descr = (*deviceIter)[getCols().description];
Glib::RefPtr<Gdk::Pixbuf> thumb = (*deviceIter)[getCols().thumbnail];
- Gtk::TreeModel::Row deviceRow = *store->append(newGroup->children());
+ Gtk::TreeModel::Row deviceRow = *deviceStore->append(newGroup->children());
deviceRow[getCols().description] = descr;
deviceRow[getCols().thumbnail] = thumb;
deviceRow[getCols().device] = dev;
@@ -1212,7 +1497,7 @@ void InputDialogImpl::updateDeviceLinks(Glib::RefPtr<InputDevice const> device,
Gtk::TreeModel::iterator linkIter;
- store->foreach_iter( sigc::bind<Glib::ustring, Gtk::TreeModel::iterator*>(
+ deviceStore->foreach_iter( sigc::bind<Glib::ustring, Gtk::TreeModel::iterator*>(
sigc::ptr_fun(&InputDialogImpl::findDeviceByLink),
device->getId(),
&linkIter) );
@@ -1221,22 +1506,22 @@ void InputDialogImpl::updateDeviceLinks(Glib::RefPtr<InputDevice const> device,
descr = (*linkIter)[getCols().description];
thumb = (*linkIter)[getCols().thumbnail];
- deviceRow = *store->append(newGroup->children());
+ deviceRow = *deviceStore->append(newGroup->children());
deviceRow[getCols().description] = descr;
deviceRow[getCols().thumbnail] = thumb;
deviceRow[getCols().device] = dev;
deviceRow[getCols().mode] = dev->getMode();
Gtk::TreeModel::iterator oldParent = linkIter->parent();
- store->erase(linkIter);
+ deviceStore->erase(linkIter);
if ( oldParent->children().empty() ) {
- store->erase(oldParent);
+ deviceStore->erase(oldParent);
}
}
Gtk::TreeModel::iterator oldParent = deviceIter->parent();
- store->erase(deviceIter);
+ deviceStore->erase(deviceIter);
if ( oldParent->children().empty() ) {
- store->erase(oldParent);
+ deviceStore->erase(oldParent);
}
tree->expand_row(Gtk::TreePath(newGroup), true);
}
@@ -1245,7 +1530,7 @@ void InputDialogImpl::updateDeviceLinks(Glib::RefPtr<InputDevice const> device,
}
void InputDialogImpl::linkComboChanged() {
- Glib::RefPtr<Gtk::TreeSelection> treeSel = tree.get_selection();
+ Glib::RefPtr<Gtk::TreeSelection> treeSel = deviceTree.get_selection();
Gtk::TreeModel::iterator iter = treeSel->get_selected();
if (iter) {
Gtk::TreeModel::Row row = *iter;
@@ -1271,34 +1556,26 @@ void InputDialogImpl::linkComboChanged() {
void InputDialogImpl::resyncToSelection() {
bool clear = true;
- Glib::RefPtr<Gtk::TreeSelection> treeSel = tree.get_selection();
+ Glib::RefPtr<Gtk::TreeSelection> treeSel = deviceTree.get_selection();
Gtk::TreeModel::iterator iter = treeSel->get_selected();
if (iter) {
Gtk::TreeModel::Row row = *iter;
Glib::ustring val = row[getCols().description];
Glib::RefPtr<InputDevice const> dev = row[getCols().device];
+
if ( dev ) {
- devDetails.set_sensitive(true);
+ axisTable.set_sensitive(true);
linkConnection.block();
-#if WITH_GTKMM_2_24
linkCombo.remove_all();
linkCombo.append(_("None"));
-#else
- linkCombo.clear_items();
- linkCombo.append_text(_("None"));
-#endif
linkCombo.set_active(0);
if ( dev->getSource() != Gdk::SOURCE_MOUSE ) {
Glib::ustring linked = dev->getLink();
std::list<Glib::RefPtr<InputDevice const> > devList = Inkscape::DeviceManager::getManager().getDevices();
for ( std::list<Glib::RefPtr<InputDevice const> >::const_iterator it = devList.begin(); it != devList.end(); ++it ) {
if ( ((*it)->getSource() != Gdk::SOURCE_MOUSE) && ((*it) != dev) ) {
-#if WITH_GTKMM_2_24
linkCombo.append((*it)->getName().c_str());
-#else
- linkCombo.append_text((*it)->getName().c_str());
-#endif
if ( (linked.length() > 0) && (linked == (*it)->getId()) ) {
linkCombo.set_active_text((*it)->getName().c_str());
}
@@ -1312,39 +1589,70 @@ void InputDialogImpl::resyncToSelection() {
clear = false;
devName.set_label(row[getCols().description]);
- detailFrame.set_label(row[getCols().description]);
+ axisFrame.set_label(row[getCols().description]);
setupValueAndCombo( dev->getNumAxes(), dev->getNumAxes(), devAxesCount, axesCombo);
setupValueAndCombo( dev->getNumKeys(), dev->getNumKeys(), devKeyCount, buttonCombo);
+
+
}
}
- devDetails.set_sensitive(!clear);
+ axisTable.set_sensitive(!clear);
if (clear) {
- detailFrame.set_label("");
+ axisFrame.set_label("");
devName.set_label("");
devAxesCount.set_label("");
devKeyCount.set_label("");
}
}
+void InputDialogImpl::ConfPanel::setAxis(gint count)
+{
+ /*
+ * TODO - Make each axis editable
+ */
+ axisStore->clear();
+
+ static Glib::ustring axesLabels[6] = {_("X"), _("Y"), _("Pressure"), _("X tilt"), _("Y tilt"), _("Wheel")};
+
+ for ( gint barNum = 0; barNum < static_cast<gint>(G_N_ELEMENTS(axesLabels)); barNum++ ) {
+
+ Gtk::TreeModel::Row row = *(axisStore->append());
+ row[axisColumns.name] = axesLabels[barNum];
+ if (barNum < count) {
+ row[axisColumns.value] = Glib::ustring::format(barNum+1);
+ } else {
+ row[axisColumns.value] = _("None");
+ }
+ }
+
+}
+void InputDialogImpl::ConfPanel::setKeys(gint count)
+{
+ /*
+ * TODO - Make each key assignable
+ */
+
+ keysStore->clear();
+
+ for (gint i = 0; i < count; i++) {
+ Gtk::TreeModel::Row row = *(keysStore->append());
+ row[keysColumns.name] = Glib::ustring::format(i+1);
+ row[keysColumns.value] = _("Disabled");
+ }
+
+
+}
void InputDialogImpl::setupValueAndCombo( gint reported, gint actual, Gtk::Label& label, Gtk::ComboBoxText& combo )
{
gchar *tmp = g_strdup_printf("%d", reported);
label.set_label(tmp);
g_free(tmp);
-#if WITH_GTKMM_2_24
combo.remove_all();
-#else
- combo.clear_items();
-#endif
for ( gint i = 1; i <= reported; ++i ) {
tmp = g_strdup_printf("%d", i);
-#if WITH_GTKMM_2_24
combo.append(tmp);
-#else
- combo.append_text(tmp);
-#endif
g_free(tmp);
}
@@ -1370,9 +1678,9 @@ void InputDialogImpl::updateTestButtons( Glib::ustring const& key, gint hotButto
void InputDialogImpl::updateTestAxes( Glib::ustring const& key, GdkDevice* dev )
{
- static gdouble epsilon = 0.0001;
+ //static gdouble epsilon = 0.0001;
{
- Glib::RefPtr<Gtk::TreeSelection> treeSel = tree.get_selection();
+ Glib::RefPtr<Gtk::TreeSelection> treeSel = deviceTree.get_selection();
Gtk::TreeModel::iterator iter = treeSel->get_selected();
if (iter) {
Gtk::TreeModel::Row row = *iter;
@@ -1384,7 +1692,6 @@ void InputDialogImpl::updateTestAxes( Glib::ustring const& key, GdkDevice* dev )
}
}
-
for ( gint i = 0; i < static_cast<gint>(G_N_ELEMENTS(testAxes)); i++ ) {
if ( axesMap[key].find(i) != axesMap[key].end() ) {
switch ( axesMap[key][i].first ) {
@@ -1399,10 +1706,15 @@ void InputDialogImpl::updateTestAxes( Glib::ustring const& key, GdkDevice* dev )
testAxes[i].set(getPix(PIX_AXIS_OFF));
axesValues[i].set_sensitive(true);
if ( dev && (i < static_cast<gint>(G_N_ELEMENTS(axesValues)) ) ) {
- if ( (dev->axes[i].max - dev->axes[i].min) > epsilon ) {
+ // FIXME: Device axis ranges are inaccessible in GTK+ 3 and
+ // are deprecated in GTK+ 2. Progress-bar ranges are disabled
+ // until we find an alternative solution
+
+ // if ( (dev->axes[i].max - dev->axes[i].min) > epsilon ) {
axesValues[i].set_sensitive(true);
- axesValues[i].set_fraction( (axesMap[key][i].second- dev->axes[i].min) / (dev->axes[i].max - dev->axes[i].min) );
- }
+ // axesValues[i].set_fraction( (axesMap[key][i].second- dev->axes[i].min) / (dev->axes[i].max - dev->axes[i].min) );
+ // }
+
gchar* str = g_strdup_printf("%f", axesMap[key][i].second);
axesValues[i].set_text(str);
g_free(str);
@@ -1412,10 +1724,16 @@ void InputDialogImpl::updateTestAxes( Glib::ustring const& key, GdkDevice* dev )
testAxes[i].set(getPix(PIX_AXIS_ON));
axesValues[i].set_sensitive(true);
if ( dev && (i < static_cast<gint>(G_N_ELEMENTS(axesValues)) ) ) {
- if ( (dev->axes[i].max - dev->axes[i].min) > epsilon ) {
+
+ // FIXME: Device axis ranges are inaccessible in GTK+ 3 and
+ // are deprecated in GTK+ 2. Progress-bar ranges are disabled
+ // until we find an alternative solution
+
+ // if ( (dev->axes[i].max - dev->axes[i].min) > epsilon ) {
axesValues[i].set_sensitive(true);
- axesValues[i].set_fraction( (axesMap[key][i].second- dev->axes[i].min) / (dev->axes[i].max - dev->axes[i].min) );
- }
+ // axesValues[i].set_fraction( (axesMap[key][i].second- dev->axes[i].min) / (dev->axes[i].max - dev->axes[i].min) );
+ // }
+
gchar* str = g_strdup_printf("%f", axesMap[key][i].second);
axesValues[i].set_text(str);
g_free(str);
@@ -1435,8 +1753,10 @@ void InputDialogImpl::updateTestAxes( Glib::ustring const& key, GdkDevice* dev )
}
}
-void InputDialogImpl::mapAxesValues( Glib::ustring const& key, guint numAxes, gdouble const * axes, GdkDevice* dev )
+void InputDialogImpl::mapAxesValues( Glib::ustring const& key, gdouble const * axes, GdkDevice* dev )
{
+ guint numAxes = gdk_device_get_n_axes(dev);
+
static gdouble epsilon = 0.0001;
if ( (numAxes > 0) && axes) {
for ( guint axisNum = 0; axisNum < numAxes; axisNum++ ) {
@@ -1487,7 +1807,11 @@ void InputDialogImpl::mapAxesValues( Glib::ustring const& key, guint numAxes, gd
Glib::ustring InputDialogImpl::getKeyFor( GdkDevice* device )
{
Glib::ustring key;
- switch ( device->source ) {
+
+ GdkInputSource source = gdk_device_get_source(device);
+ const gchar *name = gdk_device_get_name(device);
+
+ switch ( source ) {
case GDK_SOURCE_MOUSE:
key = "M:";
break;
@@ -1503,7 +1827,7 @@ Glib::ustring InputDialogImpl::getKeyFor( GdkDevice* device )
default:
key = "?:";
}
- key += device->name;
+ key += name;
return key;
}
@@ -1536,10 +1860,10 @@ bool InputDialogImpl::eventSnoop(GdkEvent* event)
GdkEventButton* btnEvt = reinterpret_cast<GdkEventButton*>(event);
if ( btnEvt->device ) {
key = getKeyFor(btnEvt->device);
- source = btnEvt->device->source;
- devName = btnEvt->device->name;
+ source = gdk_device_get_source(btnEvt->device);
+ devName = gdk_device_get_name(btnEvt->device);
+ mapAxesValues(key, btnEvt->axes, btnEvt->device);
- mapAxesValues(key, btnEvt->device->num_axes, btnEvt->axes, btnEvt->device);
if ( buttonMap[key].find(btnEvt->button) == buttonMap[key].end() ) {
// g_message("New button found for %s = %d", key.c_str(), btnEvt->button);
buttonMap[key].insert(btnEvt->button);
@@ -1565,9 +1889,9 @@ bool InputDialogImpl::eventSnoop(GdkEvent* event)
GdkEventMotion* btnMtn = reinterpret_cast<GdkEventMotion*>(event);
if ( btnMtn->device ) {
key = getKeyFor(btnMtn->device);
- source = btnMtn->device->source;
- devName = btnMtn->device->name;
- mapAxesValues(key, btnMtn->device->num_axes, btnMtn->axes, btnMtn->device);
+ source = gdk_device_get_source(btnMtn->device);
+ devName = gdk_device_get_name(btnMtn->device);
+ mapAxesValues(key, btnMtn->axes, btnMtn->device);
}
gchar* name = gtk_accelerator_name(0, static_cast<GdkModifierType>(btnMtn->state));
keyVal.set_label(name);
@@ -1591,19 +1915,16 @@ bool InputDialogImpl::eventSnoop(GdkEvent* event)
if ( (lastSourceSeen != source) || (lastDevnameSeen != devName) ) {
switch (source) {
- case GDK_SOURCE_MOUSE:
- {
+ case GDK_SOURCE_MOUSE: {
testThumb.set(getPix(PIX_CORE));
+ break;
}
- break;
- case GDK_SOURCE_CURSOR:
- {
-// g_message("flip to cursor");
+ case GDK_SOURCE_CURSOR: {
+// g_message("flip to cursor");
testThumb.set(getPix(PIX_MOUSE));
+ break;
}
- break;
- case GDK_SOURCE_PEN:
- {
+ case GDK_SOURCE_PEN: {
if (devName == _("pad")) {
// g_message("flip to pad");
testThumb.set(getPix(PIX_SIDEBUTTONS));
@@ -1611,17 +1932,24 @@ bool InputDialogImpl::eventSnoop(GdkEvent* event)
// g_message("flip to pen");
testThumb.set(getPix(PIX_TIP));
}
+ break;
}
- break;
- case GDK_SOURCE_ERASER:
- {
+ case GDK_SOURCE_ERASER: {
// g_message("flip to eraser");
testThumb.set(getPix(PIX_ERASER));
+ break;
}
- break;
-// default:
-// g_message("gurgle");
+#if WITH_GTKMM_3_0
+ /// \fixme GTK3 added new GDK_SOURCEs that should be handled here!
+ case GDK_SOURCE_KEYBOARD:
+ case GDK_SOURCE_TOUCHSCREEN:
+ case GDK_SOURCE_TOUCHPAD: {
+ g_warning("InputDialogImpl::eventSnoop : unhandled GDK_SOURCE type!");
+ break;
+ }
+#endif
}
+
updateTestButtons(key, hotButton);
lastSourceSeen = source;
lastDevnameSeen = devName;