From d76982128319a00cb5fc30a119304865da55d8cf Mon Sep 17 00:00:00 2001 From: gballintijn Date: Thu, 7 May 2009 18:24:11 +0000 Subject: [PATCH] Remove a dependency (introduced r2360) of the (GUI independent) code in src/synfigapp on the (GUI dependent) code in src/gtkmm. git-svn-id: https://synfig.svn.sourceforge.net/svnroot/synfig@2374 1f10aa63-cdf2-0310-b900-c93c546f37ac --- synfig-studio/trunk/src/gtkmm/app.cpp | 2 + synfig-studio/trunk/src/gtkmm/devicetracker.cpp | 50 ++++++++--------------- synfig-studio/trunk/src/gtkmm/devicetracker.h | 7 +--- synfig-studio/trunk/src/synfigapp/inputdevice.cpp | 5 --- 4 files changed, 20 insertions(+), 44 deletions(-) diff --git a/synfig-studio/trunk/src/gtkmm/app.cpp b/synfig-studio/trunk/src/gtkmm/app.cpp index 58d6c61..ffca6fd 100644 --- a/synfig-studio/trunk/src/gtkmm/app.cpp +++ b/synfig-studio/trunk/src/gtkmm/app.cpp @@ -1280,6 +1280,8 @@ App::App(int *argc, char ***argv): studio_init_cb.amount_complete(9250,10000); studio_init_cb.task(_("Loading Settings...")); load_settings(); + device_tracker->load_preferences(); + studio_init_cb.task(_("Checking auto-recover...")); studio_init_cb.amount_complete(9900,10000); diff --git a/synfig-studio/trunk/src/gtkmm/devicetracker.cpp b/synfig-studio/trunk/src/gtkmm/devicetracker.cpp index 2f661dd..8bd9a46 100644 --- a/synfig-studio/trunk/src/gtkmm/devicetracker.cpp +++ b/synfig-studio/trunk/src/gtkmm/devicetracker.cpp @@ -116,42 +116,26 @@ DeviceTracker::save_preferences() } void -DeviceTracker::set_device_mode(const synfig::String & id, - InputDevice::Mode mode) +DeviceTracker::load_preferences() { - for (GList * itr = gdk_devices_list(); itr; itr = g_list_next(itr)) + GList * device_list = gdk_devices_list(); + for (GList * itr = device_list; itr; itr = g_list_next(itr)) { - GdkDevice * device = reinterpret_cast(itr->data); - if (id == device->name) - gdk_device_set_mode(device, GdkInputMode(mode)); - } -} + GdkDevice * gdk_device = reinterpret_cast(itr->data); -void -DeviceTracker::set_device_axes(const synfig::String & id, - const std::vector axes) -{ - for (GList * itr = gdk_devices_list(); itr; itr = g_list_next(itr)) - { - GdkDevice * device = reinterpret_cast(itr->data); - if (id == device->name) { - for (int axis = 0; axis < (int) axes.size(); axis++) - gdk_device_set_axis_use(device, axis, GdkAxisUse(axes[axis])); - } - } -} + InputDevice::Handle synfig_device = synfigapp::Main::find_input_device(gdk_device->name); + if (synfig_device == NULL) + continue; -void -DeviceTracker::set_device_keys(const synfig::String & id, - const std::vector keys) -{ - for (GList * itr = gdk_devices_list(); itr; itr = g_list_next(itr)) - { - GdkDevice * device = reinterpret_cast(itr->data); - if (id == device->name) { - for (int key = 0; key < (int) keys.size(); key++) - gdk_device_set_key(device, key, keys[key].keyval, - GdkModifierType(keys[key].modifiers)); - } + gdk_device_set_mode(gdk_device, GdkInputMode(synfig_device->get_mode())); + + const std::vector axes = synfig_device->get_axes(); + for (int axis = 0; axis < (int) axes.size(); axis++) + gdk_device_set_axis_use(gdk_device, axis, GdkAxisUse(axes[axis])); + + const std::vector keys = synfig_device->get_keys(); + for (int key = 0; key < (int) keys.size(); key++) + gdk_device_set_key(gdk_device, key, keys[key].keyval, + GdkModifierType(keys[key].modifiers)); } } diff --git a/synfig-studio/trunk/src/gtkmm/devicetracker.h b/synfig-studio/trunk/src/gtkmm/devicetracker.h index c3608de..14c0272 100644 --- a/synfig-studio/trunk/src/gtkmm/devicetracker.h +++ b/synfig-studio/trunk/src/gtkmm/devicetracker.h @@ -45,13 +45,8 @@ public: ~DeviceTracker(); void save_preferences(); + void load_preferences(); - static void set_device_mode(const synfig::String & id, - synfigapp::InputDevice::Mode mode); - static void set_device_axes(const synfig::String & id, - const std::vector axes); - static void set_device_keys(const synfig::String & id, - const std::vector keys); }; // END of class DeviceTracker }; // END of namespace studio diff --git a/synfig-studio/trunk/src/synfigapp/inputdevice.cpp b/synfig-studio/trunk/src/synfigapp/inputdevice.cpp index 02ad5ed..874fb19 100644 --- a/synfig-studio/trunk/src/synfigapp/inputdevice.cpp +++ b/synfig-studio/trunk/src/synfigapp/inputdevice.cpp @@ -34,7 +34,6 @@ #include #include #include "main.h" -#include #include "general.h" @@ -46,7 +45,6 @@ using namespace std; using namespace etl; using namespace synfig; using namespace synfigapp; -using namespace studio; /* === M A C R O S ========================================================= */ @@ -211,7 +209,6 @@ public: mode = InputDevice::MODE_DISABLED; input_device->set_mode(mode); - DeviceTracker::set_device_mode(input_device->get_id(), mode); } void set_axes_value(const synfig::String & value) @@ -231,7 +228,6 @@ public: } input_device->set_axes(axes); - DeviceTracker::set_device_axes(input_device->get_id(), axes); } void set_keys_value(const synfig::String & value) @@ -254,7 +250,6 @@ public: } input_device->set_keys(keys); - DeviceTracker::set_device_keys(input_device->get_id(), keys); } virtual KeyList get_key_list()const -- 2.7.4