Remove a dependency (introduced r2360) of the (GUI independent) code in
authorgballintijn <gballintijn@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Thu, 7 May 2009 18:24:11 +0000 (18:24 +0000)
committerCarlos Lopez <carlos@pcnuevo.(none)>
Fri, 12 Jun 2009 14:31:18 +0000 (16:31 +0200)
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
synfig-studio/trunk/src/gtkmm/devicetracker.cpp
synfig-studio/trunk/src/gtkmm/devicetracker.h
synfig-studio/trunk/src/synfigapp/inputdevice.cpp

index 58d6c61..ffca6fd 100644 (file)
@@ -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);
index 2f661dd..8bd9a46 100644 (file)
@@ -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<GdkDevice*>(itr->data);
-               if (id == device->name)
-                       gdk_device_set_mode(device, GdkInputMode(mode));
-       }
-}
+               GdkDevice * gdk_device = reinterpret_cast<GdkDevice*>(itr->data);
 
-void
-DeviceTracker::set_device_axes(const synfig::String & id,
-               const std::vector<synfigapp::InputDevice::AxisUse> axes)
-{
-       for (GList * itr = gdk_devices_list(); itr; itr = g_list_next(itr))
-       {
-               GdkDevice * device = reinterpret_cast<GdkDevice*>(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<synfigapp::InputDevice::DeviceKey> keys)
-{
-       for (GList * itr = gdk_devices_list(); itr; itr = g_list_next(itr))
-       {
-               GdkDevice * device = reinterpret_cast<GdkDevice*>(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<synfigapp::InputDevice::AxisUse> 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<synfigapp::InputDevice::DeviceKey> 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));
        }
 }
index c3608de..14c0272 100644 (file)
@@ -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<synfigapp::InputDevice::AxisUse> axes);
-       static void set_device_keys(const synfig::String & id,
-                       const std::vector<synfigapp::InputDevice::DeviceKey> keys);
 }; // END of class DeviceTracker
 
 }; // END of namespace studio
index 02ad5ed..874fb19 100644 (file)
@@ -34,7 +34,6 @@
 #include <cstdio>
 #include <ETL/stringf>
 #include "main.h"
-#include <gtkmm/devicetracker.h>
 
 #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