[virt-tools-list] [PATCH virt-viewer 1/3] Fix compilation with gtk 2.18

Marc-André Lureau marcandre.lureau at gmail.com
Wed Feb 29 16:03:07 UTC 2012


---
 src/Makefile.am          |    1 +
 src/virt-gtk-compat.h    |   62 ++++++++++++++++++++++++++++++++++++++++++++++
 src/virt-viewer-app.c    |    9 +++---
 src/virt-viewer-window.c |   21 +---------------
 4 files changed, 69 insertions(+), 24 deletions(-)
 create mode 100644 src/virt-gtk-compat.h

diff --git a/src/Makefile.am b/src/Makefile.am
index abb8c15..bbe6ecc 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -13,6 +13,7 @@ EXTRA_DIST = $(builderxml_DATA) \
 	gbinding.h
 
 COMMON_SOURCES =					\
+	gtk-compat.h					\
 	virt-viewer-util.h virt-viewer-util.c		\
 	virt-viewer-auth.h virt-viewer-auth.c		\
 	virt-viewer-app.h virt-viewer-app.c		\
diff --git a/src/virt-gtk-compat.h b/src/virt-gtk-compat.h
new file mode 100644
index 0000000..07217c9
--- /dev/null
+++ b/src/virt-gtk-compat.h
@@ -0,0 +1,62 @@
+/*
+ * Virt Viewer: A virtual machine console viewer
+ *
+ * Copyright (C) 2007-2012 Red Hat, Inc.
+ * Copyright (C) 2009-2012 Daniel P. Berrange
+ * Copyright (C) 2010 Marc-André Lureau
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Daniel P. Berrange <berrange at redhat.com>
+ */
+#ifndef _VIRT_GTK_COMPAT
+# define _VIRT_GTK_COMPAT
+
+#include <gdk/gdk.h>
+
+G_BEGIN_DECLS
+
+#if GTK_CHECK_VERSION(3, 0, 0)
+#define GDK_Control_L GDK_KEY_Control_L
+#define GDK_Alt_L GDK_KEY_Alt_L
+#define GDK_Delete GDK_KEY_Delete
+#define GDK_BackSpace GDK_KEY_BackSpace
+#define GDK_Print GDK_KEY_Print
+#define GDK_F1 GDK_KEY_F1
+#define GDK_F2 GDK_KEY_F2
+#define GDK_F3 GDK_KEY_F3
+#define GDK_F4 GDK_KEY_F4
+#define GDK_F5 GDK_KEY_F5
+#define GDK_F6 GDK_KEY_F6
+#define GDK_F7 GDK_KEY_F7
+#define GDK_F8 GDK_KEY_F8
+#define GDK_F9 GDK_KEY_F9
+#define GDK_F10 GDK_KEY_F10
+#define GDK_F11 GDK_KEY_F11
+#define GDK_F12 GDK_KEY_F12
+#endif
+
+G_END_DECLS
+
+#endif /* _VIRT_GTK_COMPAT */
+
+/*
+ * Local variables:
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  indent-tabs-mode: nil
+ * End:
+ */
+
diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index 97639a1..89a4ecf 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -50,6 +50,7 @@
 #include <windows.h>
 #endif
 
+#include "virt-gtk-compat.h"
 #include "virt-viewer-app.h"
 #include "virt-viewer-auth.h"
 #include "virt-viewer-window.h"
@@ -1261,10 +1262,10 @@ virt_viewer_app_constructor (GType gtype,
     priv->main_window = virt_viewer_app_window_new(self, priv->container, 0);
     priv->main_notebook = GTK_WIDGET(virt_viewer_window_get_notebook(priv->main_window));
 
-    gtk_accel_map_add_entry("<virt-viewer>/file/smartcard-insert", GDK_KEY_F8, GDK_SHIFT_MASK);
-    gtk_accel_map_add_entry("<virt-viewer>/file/smartcard-remove", GDK_KEY_F9, GDK_SHIFT_MASK);
-    gtk_accel_map_add_entry("<virt-viewer>/view/fullscreen", GDK_KEY_F11, 0);
-    gtk_accel_map_add_entry("<virt-viewer>/view/release-cursor", GDK_KEY_F12, GDK_SHIFT_MASK);
+    gtk_accel_map_add_entry("<virt-viewer>/file/smartcard-insert", GDK_F8, GDK_SHIFT_MASK);
+    gtk_accel_map_add_entry("<virt-viewer>/file/smartcard-remove", GDK_F9, GDK_SHIFT_MASK);
+    gtk_accel_map_add_entry("<virt-viewer>/view/fullscreen", GDK_F11, 0);
+    gtk_accel_map_add_entry("<virt-viewer>/view/release-cursor", GDK_F12, GDK_SHIFT_MASK);
 
     return obj;
 }
diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index 78adb74..708678a 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -35,6 +35,7 @@
 #include <glib/gprintf.h>
 #include <glib/gi18n.h>
 
+#include "virt-gtk-compat.h"
 #include "virt-viewer-window.h"
 #include "virt-viewer-session.h"
 #include "virt-viewer-app.h"
@@ -111,26 +112,6 @@ struct _VirtViewerWindowPrivate {
     gchar *subtitle;
 };
 
-#if GTK_CHECK_VERSION(3, 0, 0)
-#define GDK_Control_L GDK_KEY_Control_L
-#define GDK_Alt_L GDK_KEY_Alt_L
-#define GDK_Delete GDK_KEY_Delete
-#define GDK_BackSpace GDK_KEY_BackSpace
-#define GDK_Print GDK_KEY_Print
-#define GDK_F1 GDK_KEY_F1
-#define GDK_F2 GDK_KEY_F2
-#define GDK_F3 GDK_KEY_F3
-#define GDK_F4 GDK_KEY_F4
-#define GDK_F5 GDK_KEY_F5
-#define GDK_F6 GDK_KEY_F6
-#define GDK_F7 GDK_KEY_F7
-#define GDK_F8 GDK_KEY_F8
-#define GDK_F9 GDK_KEY_F9
-#define GDK_F10 GDK_KEY_F10
-#define GDK_F11 GDK_KEY_F11
-#define GDK_F12 GDK_KEY_F12
-#endif
-
 static void
 virt_viewer_window_get_property (GObject *object, guint property_id,
                                  GValue *value, GParamSpec *pspec)
-- 
1.7.7.6




More information about the virt-tools-list mailing list