From 334adaadda19ab8e8fa5dcde08272e4011eafae7 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Mon, 9 Jan 2012 19:27:58 -0800 Subject: Reduce GTK compatibility ifdef complexity. (bzr r10868) --- src/desktop-events.cpp | 71 ++++++++++++++++++++------------------------------ 1 file changed, 28 insertions(+), 43 deletions(-) (limited to 'src') diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp index 85ba08547..068e4aa9a 100644 --- a/src/desktop-events.cpp +++ b/src/desktop-events.cpp @@ -526,49 +526,34 @@ static void init_extended() if ( devices ) { for ( GList* curr = devices; curr; curr = g_list_next(curr) ) { GdkDevice* dev = reinterpret_cast(curr->data); -#if GTK_CHECK_VERSION (2, 22, 0) - if ( gdk_device_get_name (dev) - && (avoidName != gdk_device_get_name (dev)) - && (gdk_device_get_source (dev) != GDK_SOURCE_MOUSE) ) { -// g_message("Adding '%s' as [%d]", dev->name, dev->source); - - // Set the initial tool for the device - switch ( gdk_device_get_source (dev)) { +#if GTK_CHECK_VERSION(2, 22, 0) + gchar const *devName = gdk_device_get_name(dev); + GdkInputSource devSrc = gdk_device_get_source(dev); #else - if ( dev->name - && (avoidName != dev->name) - && (dev->source != GDK_SOURCE_MOUSE) ) { -// g_message("Adding '%s' as [%d]", dev->name, dev->source); + gchar const *devName = dev->name; + GdkInputSource devSrc = dev->source; +#endif + if ( devName + && (avoidName != devName) + && (devSrc != GDK_SOURCE_MOUSE) ) { +// g_message("Adding '%s' as [%d]", devName, devSrc); // Set the initial tool for the device - switch ( dev->source) { -#endif + switch ( devSrc ) { case GDK_SOURCE_PEN: -#if GTK_CHECK_VERSION (2, 22, 0) - toolToUse[gdk_device_get_name (dev)] = TOOLS_CALLIGRAPHIC; -#else - toolToUse[dev->name] = TOOLS_CALLIGRAPHIC; -#endif + toolToUse[devName] = TOOLS_CALLIGRAPHIC; break; case GDK_SOURCE_ERASER: -#if GTK_CHECK_VERSION (2, 22, 0) - toolToUse[gdk_device_get_name (dev)] = TOOLS_ERASER; -#else - toolToUse[dev->name] = TOOLS_ERASER; -#endif + toolToUse[devName] = TOOLS_ERASER; break; case GDK_SOURCE_CURSOR: -#if GTK_CHECK_VERSION (2, 22, 0) - toolToUse[gdk_device_get_name (dev)] = TOOLS_SELECT; -#else - toolToUse[dev->name] = TOOLS_SELECT; -#endif + toolToUse[devName] = TOOLS_SELECT; break; default: ; // do not add } -// } else if (dev->name) { -// g_message("Skippn '%s' as [%s]", dev->name, dev->source); +// } else if (devName) { +// g_message("Skippn '%s' as [%d]", devName, devSrc); } } } @@ -585,9 +570,9 @@ void snoop_extended(GdkEvent* event, SPDesktop *desktop) { GdkEventMotion* event2 = reinterpret_cast(event); if ( event2->device ) { -#if GTK_CHECK_VERSION (2, 22, 0) - source = gdk_device_get_source (event2->device); - name = gdk_device_get_name (event2->device); +#if GTK_CHECK_VERSION(2, 22, 0) + source = gdk_device_get_source(event2->device); + name = gdk_device_get_name(event2->device); #else source = event2->device->source; name = event2->device->name; @@ -603,9 +588,9 @@ void snoop_extended(GdkEvent* event, SPDesktop *desktop) { GdkEventButton* event2 = reinterpret_cast(event); if ( event2->device ) { -#if GTK_CHECK_VERSION (2, 22, 0) - source = gdk_device_get_source (event2->device); - name = gdk_device_get_name (event2->device); +#if GTK_CHECK_VERSION(2, 22, 0) + source = gdk_device_get_source(event2->device); + name = gdk_device_get_name(event2->device); #else source = event2->device->source; name = event2->device->name; @@ -618,9 +603,9 @@ void snoop_extended(GdkEvent* event, SPDesktop *desktop) { GdkEventScroll* event2 = reinterpret_cast(event); if ( event2->device ) { -#if GTK_CHECK_VERSION (2, 22, 0) - source = gdk_device_get_source (event2->device); - name = gdk_device_get_name (event2->device); +#if GTK_CHECK_VERSION(2, 22, 0) + source = gdk_device_get_source(event2->device); + name = gdk_device_get_name(event2->device); #else source = event2->device->source; name = event2->device->name; @@ -634,9 +619,9 @@ void snoop_extended(GdkEvent* event, SPDesktop *desktop) { GdkEventProximity* event2 = reinterpret_cast(event); if ( event2->device ) { -#if GTK_CHECK_VERSION (2, 22, 0) - source = gdk_device_get_source (event2->device); - name = gdk_device_get_name (event2->device); +#if GTK_CHECK_VERSION(2, 22, 0) + source = gdk_device_get_source(event2->device); + name = gdk_device_get_name(event2->device); #else source = event2->device->source; name = event2->device->source; -- cgit v1.2.3