[gnome-control-center] wacom: Prevent failure when device's area cannot be retrieved



commit c74a65acb5739e5005de518c1fbe9a436ff286c5
Author: Joaquim Rocha <me joaquimrocha com>
Date:   Thu Apr 4 12:05:24 2013 +0200

    wacom: Prevent failure when device's area cannot be retrieved
    
    It also uses fake data from the screen's area. This functionality is
    dictated by the definition of FAKE_AREA in CPPFLAGS.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=689686

 panels/wacom/Makefile.am     |  4 ++--
 panels/wacom/cc-wacom-page.c | 23 +++++++++++++++++++++++
 2 files changed, 25 insertions(+), 2 deletions(-)
---
diff --git a/panels/wacom/Makefile.am b/panels/wacom/Makefile.am
index a37ecdb..3bb68b7 100644
--- a/panels/wacom/Makefile.am
+++ b/panels/wacom/Makefile.am
@@ -55,8 +55,8 @@ test_wacom_SOURCES =                  \
        gsd-input-helper.h              \
        gsd-enums.h
 
-test_wacom_CPPFLAGS = $(INCLUDES)
-test_wacom_LDADD = $(PANEL_LIBS) $(WACOM_PANEL_LIBS) $(builddir)/calibrator/libwacom-calibrator.la
+test_wacom_CPPFLAGS = $(INCLUDES) -DFAKE_AREA
+test_wacom_LDADD = $(PANEL_LIBS) $(WACOM_PANEL_LIBS) $(builddir)/calibrator/libwacom-calibrator-test.la
 
 resource_files = $(shell glib-compile-resources --sourcedir=$(srcdir) --generate-dependencies 
$(srcdir)/wacom.gresource.xml)
 cc-wacom-resources.c: wacom.gresource.xml $(resource_files)
diff --git a/panels/wacom/cc-wacom-page.c b/panels/wacom/cc-wacom-page.c
index 6214bdd..daa6372 100644
--- a/panels/wacom/cc-wacom-page.c
+++ b/panels/wacom/cc-wacom-page.c
@@ -22,6 +22,10 @@
 
 #include <config.h>
 
+#ifdef FAKE_AREA
+#include <gdk/gdk.h>
+#endif /* FAKE_AREA */
+
 #include <glib/gi18n-lib.h>
 #include <gtk/gtk.h>
 
@@ -267,7 +271,26 @@ calibrate_button_clicked_cb (GtkButton   *button,
            calibration[2] == -1 &&
            calibration[3] == -1) {
                gint *device_cal;
+
+#ifdef FAKE_AREA
+               GdkScreen *screen;
+               screen = gdk_screen_get_default ();
+
+               device_cal = g_new0 (int, 4);
+               device_cal[0] = 0;
+               device_cal[1] = gdk_screen_get_width (screen);
+               device_cal[2] = 0;
+               device_cal[3] = gdk_screen_get_height (screen);
+#else
                device_cal = gsd_wacom_device_get_area (page->priv->stylus);
+
+               if (device_cal == NULL) {
+                       g_warning ("Failed to get device's area. "
+                                  "Not running calibration.");
+                       return;
+               }
+#endif /* FAKE_AREA */
+
                for (i = 0; i < 4; i++)
                        calibration[i] = device_cal[i];
                g_free (device_cal);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]