[input-pad] Added input-pad-xx-gtk3.patch for GTK3

Takao Fujiwara fujiwara at fedoraproject.org
Tue Nov 9 09:34:27 UTC 2010


commit 459968cd572a2e9c7e00ff738a80351c07418b22
Author: Takao Fujiwara <tfujiwar at redhat.com>
Date:   Tue Nov 9 18:33:53 2010 +0900

    Added input-pad-xx-gtk3.patch for GTK3

 input-pad-xx-gtk3.patch |  624 +++++++++++++++++++++++++++++++++++++++++++++++
 input-pad.spec          |   24 ++-
 2 files changed, 647 insertions(+), 1 deletions(-)
---
diff --git a/input-pad-xx-gtk3.patch b/input-pad-xx-gtk3.patch
new file mode 100644
index 0000000..2236e87
--- /dev/null
+++ b/input-pad-xx-gtk3.patch
@@ -0,0 +1,624 @@
+From a2c88142005f18359e0571933287edb8ef3d3299 Mon Sep 17 00:00:00 2001
+From: fujiwarat <takao.fujiwara1 at gmail.com>
+Date: Tue, 9 Nov 2010 17:44:47 +0900
+Subject: [PATCH] Supported GTK3.
+
+---
+ configure.ac             |   38 +++++++++++++-
+ input-pad.pc.in          |    2 +-
+ input-pad/Makefile.am    |   21 ++++++--
+ input-pad/button-gtk.c   |   32 +++++++++--
+ input-pad/geometry-gdk.c |   10 ++--
+ input-pad/window-gtk.c   |  127 ++++++++++++++++++++++++++++------------------
+ input-pad/xtest-gdk.c    |    6 +-
+ pyinput-pad/Makefile.am  |   20 ++++++--
+ 8 files changed, 181 insertions(+), 75 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index eda90b5..fab3dbe 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -78,9 +78,29 @@ PKG_CHECK_MODULES(GLIB2, [
+     glib-2.0 >= 2.8
+ ])
+ 
+-PKG_CHECK_MODULES(GTK2, [
+-    gtk+-2.0
+-])
++dnl - check gtk
++AC_ARG_WITH(gtk-version,
++    AS_HELP_STRING([--with-gtk-version[=VERSION]],
++                   [Select GTK+ version. The default is 2]),,
++    with_gtk_version=2
++)
++
++if test "x$with_gtk_version" = x3 ; then
++    PKG_CHECK_MODULES(GTK3, [
++        gtk+-3.0
++    ])
++    AM_CONDITIONAL(HAVE_GTK3, true)
++    AM_CONDITIONAL(HAVE_GTK2, false)
++    WITH_GTK_VERSION=3.0
++else
++    PKG_CHECK_MODULES(GTK2, [
++        gtk+-2.0
++    ])
++    AM_CONDITIONAL(HAVE_GTK3, false)
++    AM_CONDITIONAL(HAVE_GTK2, true)
++    WITH_GTK_VERSION=2.0
++fi
++AC_SUBST(WITH_GTK_VERSION)
+ 
+ PKG_CHECK_MODULES(LIBXML2, [
+     libxml-2.0 >= 2.0
+@@ -203,3 +223,15 @@ pyinput-pad/pyinput_pad.pth
+ ])
+ 
+ AC_OUTPUT
++echo "
++                input-pad version pad_version
++
++
++libinput_pad version:    $libinput_pad_VERSION
++GTK+ version:            $WITH_GTK_VERSION
++Have libxklavier:        $have_libxklavier
++Enable EEK               $enable_eek
++Enable Python            $enable_python
++Enable XTEST             $enable_xtest
++lt version info          $LT_VERSION_INFO
++"
+diff --git a/input-pad.pc.in b/input-pad.pc.in
+index f439e8c..6b92673 100644
+--- a/input-pad.pc.in
++++ b/input-pad.pc.in
+@@ -8,6 +8,6 @@ xkeysenddir=@libdir@/input-pad- at libinput_pad_VERSION@/modules/xkeysend
+ Name: input-pad
+ Description: Input Pad
+ Version: @VERSION@
+-Requires: glib-2.0 gtk+-2.0
++Requires: glib-2.0 gtk+- at WITH_GTK_VERSION@
+ Cflags: -I${includedir}
+ Libs: -L${libdir} -linput-pad
+diff --git a/input-pad/Makefile.am b/input-pad/Makefile.am
+index a3a1aaa..d1c0431 100644
+--- a/input-pad/Makefile.am
++++ b/input-pad/Makefile.am
+@@ -70,7 +70,6 @@ libinput_pad_la_SOURCES = \
+ 	$(NULL)
+ 
+ libinput_pad_la_CFLAGS = \
+-	$(GTK2_CFLAGS)                                          \
+ 	$(LIBXML2_CFLAGS)                                       \
+ 	$(X11_CFLAGS)                                           \
+ 	$(XKB_CFLAGS)                                           \
+@@ -78,7 +77,6 @@ libinput_pad_la_CFLAGS = \
+ 	$(NULL)
+ 
+ libinput_pad_la_LIBADD = \
+-	$(GTK2_LIBS)                                            \
+ 	$(LIBXML2_LIBS)                                         \
+ 	$(X11_LIBS)                                             \
+ 	$(XKB_LIBS)                                             \
+@@ -91,6 +89,14 @@ libinput_pad_la_LDFLAGS = \
+ 	$(no_undefined)                                         \
+ 	$(NULL)
+ 
++if HAVE_GTK3
++    libinput_pad_la_CFLAGS += $(GTK3_CFLAGS)
++    libinput_pad_la_LIBADD += $(GTK3_LIBS)
++else
++    libinput_pad_la_CFLAGS += $(GTK2_CFLAGS)
++    libinput_pad_la_LIBADD += $(GTK2_LIBS)
++endif
++
+ input-pad-marshal.h: input-pad-marshal.list
+ 	@$(GLIB_GENMARSHAL) $< --prefix=INPUT_PAD --header > $@ \
+ 	$(NULL)
+@@ -116,13 +122,11 @@ libinput_pad_xtest_gdk_la_SOURCES = \
+ 	$(NULL)
+ 
+ libinput_pad_xtest_gdk_la_CFLAGS = \
+-	$(GTK2_CFLAGS)                                          \
+ 	$(X11_CFLAGS)                                           \
+ 	$(NULL)
+ 
+ libinput_pad_xtest_gdk_la_LIBADD = \
+ 	$(builddir)/libinput-pad.la                             \
+-	$(GTK2_LIBS)                                            \
+ 	$(X11_LIBS)                                             \
+ 	$(XTEST_LIBS)                                           \
+ 	$(NULL)
+@@ -132,6 +136,15 @@ libinput_pad_xtest_gdk_la_LDFLAGS = \
+ 	-avoid-version                                          \
+ 	$(no_undefined)                                         \
+ 	$(NULL)
++
++if HAVE_GTK3
++    libinput_pad_xtest_gdk_la_CFLAGS += $(GTK3_CFLAGS)
++    libinput_pad_xtest_gdk_la_LIBADD += $(GTK3_LIBS)
++else
++    libinput_pad_xtest_gdk_la_CFLAGS += $(GTK2_CFLAGS)
++    libinput_pad_xtest_gdk_la_LIBADD += $(GTK2_LIBS)
++endif
++
+ endif
+ 
+ if HAVE_EEK
+diff --git a/input-pad/button-gtk.c b/input-pad/button-gtk.c
+index a5cd080..55ed3a0 100644
+--- a/input-pad/button-gtk.c
++++ b/input-pad/button-gtk.c
+@@ -53,7 +53,13 @@ static guint                    signals[LAST_SIGNAL] = { 0 };
+ static GtkBuildableIface       *parent_buildable_iface;
+ 
+ static void input_pad_gtk_button_buildable_interface_init (GtkBuildableIface *iface);
+-static void input_pad_gtk_button_destroy_real (GtkObject *object);
++
++#if GTK_CHECK_VERSION (2, 90, 0)
++static void input_pad_gtk_button_destroy_real (GtkWidget *widget);
++#else
++static void input_pad_gtk_button_destroy_real (GtkObject *widget);
++#endif
++
+ static gint input_pad_gtk_button_press_real (GtkWidget *widget, GdkEventButton *event);
+ static gint input_pad_gtk_button_release_real (GtkWidget *widget, GdkEventButton *event);
+ 
+@@ -80,10 +86,16 @@ static void
+ input_pad_gtk_button_class_init (InputPadGtkButtonClass *klass)
+ {
+     GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+-    GtkObjectClass *object_class = (GtkObjectClass *) klass;
++#if !GTK_CHECK_VERSION (2, 90, 0)
++    GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
++#endif
+     GtkWidgetClass *widget_class = (GtkWidgetClass *) klass;
+ 
++#if GTK_CHECK_VERSION (2, 90, 0)
++    widget_class->destroy = input_pad_gtk_button_destroy_real;
++#else
+     object_class->destroy = input_pad_gtk_button_destroy_real;
++#endif
+     widget_class->button_press_event = input_pad_gtk_button_press_real;
+     widget_class->button_release_event = input_pad_gtk_button_release_real;
+ 
+@@ -162,11 +174,15 @@ end_timer (InputPadGtkButton *button)
+ }
+ 
+ static void
+-input_pad_gtk_button_destroy_real (GtkObject *object)
++#if GTK_CHECK_VERSION (2, 90, 0)
++input_pad_gtk_button_destroy_real (GtkWidget *widget)
++#else
++input_pad_gtk_button_destroy_real (GtkObject *widget)
++#endif
+ {
+     InputPadGtkButton *ibutton;
+-    if (INPUT_PAD_IS_GTK_BUTTON (object)) {
+-        ibutton = INPUT_PAD_GTK_BUTTON (object);
++    if (INPUT_PAD_IS_GTK_BUTTON (widget)) {
++        ibutton = INPUT_PAD_GTK_BUTTON (widget);
+         if (ibutton->priv) {
+             end_timer (ibutton);
+             g_free (ibutton->priv->rawtext);
+@@ -174,7 +190,11 @@ input_pad_gtk_button_destroy_real (GtkObject *object)
+             ibutton->priv = NULL;
+         }
+     }
+-    GTK_OBJECT_CLASS (input_pad_gtk_button_parent_class)->destroy (object);
++#if GTK_CHECK_VERSION (2, 90, 0)
++    GTK_WIDGET_CLASS (input_pad_gtk_button_parent_class)->destroy (widget);
++#else
++    GTK_OBJECT_CLASS (input_pad_gtk_button_parent_class)->destroy (widget);
++#endif
+ }
+ 
+ static gint
+diff --git a/input-pad/geometry-gdk.c b/input-pad/geometry-gdk.c
+index 252aacf..367f664 100644
+--- a/input-pad/geometry-gdk.c
++++ b/input-pad/geometry-gdk.c
+@@ -84,7 +84,7 @@ static gboolean
+ input_pad_xkb_init (InputPadGtkWindow *window)
+ {
+     static gboolean retval = FALSE;
+-    Display *xdisplay = GDK_WINDOW_XDISPLAY (GTK_WIDGET(window)->window);
++    Display *xdisplay = GDK_WINDOW_XDISPLAY (gtk_widget_get_window (GTK_WIDGET (window)));
+ 
+     if (retval) {
+         return retval;
+@@ -103,7 +103,7 @@ input_pad_xkb_init (InputPadGtkWindow *window)
+ static XkbFileInfo *
+ input_pad_xkb_get_file_info (InputPadGtkWindow *window)
+ {
+-    Display *xdisplay = GDK_WINDOW_XDISPLAY (GTK_WIDGET(window)->window);
++    Display *xdisplay = GDK_WINDOW_XDISPLAY (gtk_widget_get_window (GTK_WIDGET (window)));
+     XkbFileInfo *xkb_info;
+ 
+     xkb_info = g_new0 (XkbFileInfo, 1);
+@@ -353,7 +353,7 @@ add_xkb_key (InputPadXKBKeyList        *xkb_key_list,
+ static XklEngine *
+ init_xkl_engine (InputPadGtkWindow *window, XklConfigRec **initial_xkl_recp)
+ {
+-    Display *xdisplay = GDK_WINDOW_XDISPLAY (GTK_WIDGET(window)->window);
++    Display *xdisplay = GDK_WINDOW_XDISPLAY (gtk_widget_get_window (GTK_WIDGET (window)));
+     XklConfigRec *xklrec;
+ 
+     if (xklengine) {
+@@ -494,7 +494,7 @@ xkl_setup_events (XklEngine            *xklengine,
+ static guint
+ xkb_get_current_group (InputPadGtkWindow *window)
+ {
+-    Display *xdisplay = GDK_WINDOW_XDISPLAY (GTK_WIDGET(window)->window);
++    Display *xdisplay = GDK_WINDOW_XDISPLAY (gtk_widget_get_window (GTK_WIDGET (window)));
+     XkbStateRec state;
+ 
+     if (XkbGetState (xdisplay, XkbUseCoreKbd, &state) != Success) {
+@@ -989,7 +989,7 @@ input_pad_gdk_xkb_get_group_layouts (InputPadGtkWindow   *window,
+     g_return_val_if_fail (window != NULL && INPUT_PAD_IS_GTK_WINDOW (window),
+                           NULL);
+ 
+-    xdisplay = GDK_WINDOW_XDISPLAY (GTK_WIDGET(window)->window);
++    xdisplay = GDK_WINDOW_XDISPLAY (gtk_widget_get_window (GTK_WIDGET (window)));
+     xkb_rules_name = XInternAtom (xdisplay, "_XKB_RULES_NAMES", TRUE);
+     if (xkb_rules_name == None) {
+         g_warning ("Could not get XKB rules atom");
+diff --git a/input-pad/window-gtk.c b/input-pad/window-gtk.c
+index 7c2dc19..372c611 100644
+--- a/input-pad/window-gtk.c
++++ b/input-pad/window-gtk.c
+@@ -24,7 +24,7 @@
+ #endif
+ 
+ #include <gtk/gtk.h>
+-#include <gdk/gdkkeys.h>
++#include <gdk/gdk.h>
+ #include <gdk/gdkx.h>
+ #include <X11/Xlib.h>
+ #include <X11/keysym.h>
+@@ -253,8 +253,15 @@ static void             append_all_char_view_table
+ static void             destroy_all_char_view_table
+                                                 (GtkWidget         *viewport,
+                                                  InputPadGtkWindow *window);
++
++#if GTK_CHECK_VERSION (2, 90, 0)
++static void             input_pad_gtk_window_real_destroy
++                                                (GtkWidget         *widget);
++#else
+ static void             input_pad_gtk_window_real_destroy
+-                                                (GtkObject         *object);
++                                                (GtkObject         *widget);
++#endif
++
+ static void             input_pad_gtk_window_buildable_interface_init
+                                                 (GtkBuildableIface *iface);
+ 
+@@ -1005,7 +1012,11 @@ on_button_layout_arrow_pressed (GtkButton *button, gpointer data)
+             gtk_button_set_label (button, "->");
+             gtk_widget_set_tooltip_text (GTK_WIDGET (button),
+                                          _("Extend layout"));
++#if GTK_CHECK_VERSION (2, 90, 0)
++            reduced_width += gtk_widget_get_allocated_width (table_data[i].table);
++#else
+             reduced_width += table_data[i].table->allocation.width;
++#endif
+         }
+     }
+ 
+@@ -1201,14 +1212,16 @@ static void
+ resize_toplevel_window_with_hide_widget (GtkWidget *widget)
+ {
+     GtkWidget *toplevel;
++    GtkAllocation allocation;
+     int width, height;
+ 
+     toplevel = gtk_widget_get_toplevel (widget);
+     g_return_if_fail (GTK_IS_WINDOW (toplevel));
+     gtk_window_get_size (GTK_WINDOW (toplevel), &width, &height);
+-    if (height > widget->allocation.height &&
+-        widget->allocation.x >= 0) {
+-        height -= widget->allocation.height;
++    gtk_widget_get_allocation (widget, &allocation);
++    if (height > allocation.height &&
++        allocation.x >= 0) {
++        height -= allocation.height;
+         gtk_window_resize (GTK_WINDOW (toplevel), width, height);
+         gtk_widget_queue_resize (toplevel);
+     }
+@@ -1472,7 +1485,7 @@ digit_model_renew (GtkTreeModel *model, int prev_base, int new_base)
+ static gint
+ _spin_button_get_arrow_size (GtkSpinButton *spin_button)
+ {
+-    gint size = pango_font_description_get_size (GTK_WIDGET (spin_button)->style->font_desc);
++    gint size = pango_font_description_get_size (gtk_widget_get_style (GTK_WIDGET (spin_button))->font_desc);
+     gint arrow_size;
+     const gint MIN_ARROW_WIDTH = 6;
+ 
+@@ -1481,52 +1494,41 @@ _spin_button_get_arrow_size (GtkSpinButton *spin_button)
+     return arrow_size - arrow_size % 2; /* force even */
+ }
+ 
+-/* Modified GtkSpinButton->size_allocate() not to show text */
++/* Modified GtkSpinButton->size_allocate() not to show text
++ * gtk_spin_button_size_allocate() calls _gtk_spin_button_get_panel()
++ * internally in GTK3 and _gtk_spin_button_get_panel() is a private API now
++ * so hack gtk_spin_button_size_allocate() in this way. */
+ static void
+ _gtk_spin_button_size_allocate (GtkWidget     *widget,
+                                 GtkAllocation *allocation)
+ {
+-    GtkSpinButton *spin = GTK_SPIN_BUTTON (widget);
+-    GtkAllocation panel_allocation;
++    void (* size_allocate)       (GtkWidget        *widget,
++                                  GtkAllocation    *allocation);
++    gint width;
+     gint arrow_size;
+     gint panel_width;
+-    static gpointer parent_class = NULL;
+ 
+-    arrow_size = _spin_button_get_arrow_size (spin);
+-    panel_width = arrow_size + 2 * widget->style->xthickness;
+- 
+-    widget->allocation = *allocation;
++    size_allocate = g_object_get_data (G_OBJECT (widget), "size_allocate_orig");
+ 
+-    /* resize to show arrow only. */
+-    allocation->width = panel_width;
+-
+-    if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) {
+-      panel_allocation.x = 0;
+-    } else {
+-      panel_allocation.x = allocation->width - panel_width;
++    if (size_allocate == NULL) {
++        return;
+     }
+-    panel_allocation.width = panel_width;
+-    panel_allocation.height = MIN (widget->requisition.height, allocation->height);
+-
+-    panel_allocation.y = 0;
+ 
+-    if (parent_class == NULL) {
+-        parent_class = g_type_class_peek_parent (GTK_SPIN_BUTTON_GET_CLASS (widget));
+-    }
++    width = allocation->width;
++    arrow_size = _spin_button_get_arrow_size (GTK_SPIN_BUTTON (widget));
++    panel_width = arrow_size + 2 * gtk_widget_get_style (widget)->xthickness;
++    allocation->width = panel_width;
+ 
+-    if (parent_class != NULL) {
+-        GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
+-    }
++    /* The original gtk_spin_button_size_allocate() moves the position of
++     * widget->priv->panel to the right edge of widget.
++     * I'd like to hide spin's text area since it's not used in this GUI.
++     * The hide technique is to set spin's width with panel's width and then
++     * panel's x and spin's x are same value and spin's text area is hidden
++     * because allocation->width - panel_width == 0. */
+ 
+-    if (GTK_WIDGET_REALIZED (widget)) {
+-        gdk_window_move_resize (GTK_SPIN_BUTTON (widget)->panel,
+-                                panel_allocation.x,
+-                                panel_allocation.y,
+-                                panel_allocation.width,
+-                                panel_allocation.height);
+-    }
++    size_allocate (widget, allocation);
+ 
+-    gtk_widget_queue_draw (GTK_WIDGET (spin));
++    allocation->width = width;
+ }
+ 
+ static void
+@@ -1547,8 +1549,10 @@ init_spin_button (GtkWidget *spin_button, CodePointData *cp_data)
+ 
+     arrow_size = _spin_button_get_arrow_size (GTK_SPIN_BUTTON (spin_button));
+     gtk_widget_set_size_request (spin_button,
+-                                 arrow_size + 2 * spin_button->style->xthickness,
++                                 arrow_size + 2 * gtk_widget_get_style (spin_button)->xthickness,
+                                  -1);
++    g_object_set_data (G_OBJECT (spin_button), "size_allocate_orig",
++                       GTK_WIDGET_GET_CLASS (spin_button)->size_allocate);
+     GTK_WIDGET_GET_CLASS (spin_button)->size_allocate = _gtk_spin_button_size_allocate;
+     adjustment = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spin_button));
+     gtk_adjustment_set_upper (adjustment, (gdouble) MAX_UCODE);
+@@ -1601,6 +1605,8 @@ set_code_point_base (CodePointData *cp_data, int n_encoding)
+     GtkTreeModel *model;
+     GtkTreeIter iter;
+     GtkCellRenderer *renderer;
++    GtkAllocation combobox_allocation;
++    GtkAllocation toplevel_allocation;
+ 
+     g_return_if_fail (cp_data != NULL);
+     g_return_if_fail (GTK_IS_CONTAINER (cp_data->digit_hbox));
+@@ -1687,10 +1693,13 @@ end_configure_combobox:
+     list = gtk_container_get_children (GTK_CONTAINER (digit_hbox));
+     combobox = GTK_WIDGET (g_list_nth (list, n_digit - 1)->data);
+     toplevel = gtk_widget_get_toplevel (digit_hbox);
++    gtk_widget_get_allocation (combobox, &combobox_allocation);
++    gtk_widget_get_allocation (toplevel, &toplevel_allocation);
+     if (do_resize &&
+-        combobox->allocation.x >= 0 && combobox->allocation.width > 10) {
+-        toplevel->allocation.width = combobox->allocation.x +
+-                                     combobox->allocation.width + 10;
++        combobox_allocation.x >= 0 && combobox_allocation.width > 10) {
++        toplevel_allocation.width = combobox_allocation.x +
++                                    combobox_allocation.width + 10;
++        gtk_widget_set_allocation (toplevel, &toplevel_allocation);
+         gtk_widget_queue_resize (toplevel);
+     }
+     digit_hbox_set_code_point (digit_hbox, code);
+@@ -3979,7 +3988,9 @@ input_pad_gtk_window_set_priv (InputPadGtkWindow *window)
+     if (!gdk_color_parse ("gray", &color)) {
+         color.red = color.green = color.blue = 0xffff;
+     }
++#if !GTK_CHECK_VERSION(2, 90, 0)
+     gdk_colormap_alloc_color (gdk_colormap_get_system(), &color, FALSE, TRUE);
++#endif
+     priv->color_gray = gdk_color_copy (&color);
+     if (kbdui_name) {
+         priv->kbdui_name = g_strdup (kbdui_name);
+@@ -4026,9 +4037,13 @@ input_pad_gtk_window_buildable_interface_init (GtkBuildableIface *iface)
+ }
+ 
+ static void
+-input_pad_gtk_window_real_destroy (GtkObject *object)
++#if GTK_CHECK_VERSION (2, 90, 0)
++input_pad_gtk_window_real_destroy (GtkWidget *widget)
++#else
++input_pad_gtk_window_real_destroy (GtkObject *widget)
++#endif
+ {
+-    InputPadGtkWindow *window = INPUT_PAD_GTK_WINDOW (object);
++    InputPadGtkWindow *window = INPUT_PAD_GTK_WINDOW (widget);
+ 
+     if (window->priv) {
+         if (window->priv->group) {
+@@ -4051,7 +4066,11 @@ input_pad_gtk_window_real_destroy (GtkObject *object)
+         window->priv->kbdui_name = NULL;
+         window->priv = NULL;
+     }
+-    GTK_OBJECT_CLASS (input_pad_gtk_window_parent_class)->destroy (object);
++#if GTK_CHECK_VERSION (2, 90, 0)
++    GTK_WIDGET_CLASS (input_pad_gtk_window_parent_class)->destroy (widget);
++#else
++    GTK_OBJECT_CLASS (input_pad_gtk_window_parent_class)->destroy (widget);
++#endif
+ }
+ 
+ static void
+@@ -4077,12 +4096,14 @@ input_pad_gtk_window_real_button_pressed (InputPadGtkWindow *window,
+ {
+     if (type == INPUT_PAD_TABLE_TYPE_CHARS) {
+         if (keysym > 0) {
+-            send_key_event (GTK_WIDGET(window)->window, keysym, keycode, state);
++            send_key_event (gtk_widget_get_window (GTK_WIDGET (window)),
++                            keysym, keycode, state);
+         } else {
+             g_print ("%s", str ? str : "");
+         }
+     } else if (type == INPUT_PAD_TABLE_TYPE_KEYSYMS) {
+-        send_key_event (GTK_WIDGET(window)->window, keysym, keycode, state);
++        send_key_event (gtk_widget_get_window (GTK_WIDGET (window)),
++                        keysym, keycode, state);
+     } else if (type == INPUT_PAD_TABLE_TYPE_STRINGS) {
+             g_print ("%s", str ? str : "");
+     } else if (type == INPUT_PAD_TABLE_TYPE_COMMANDS) {
+@@ -4097,10 +4118,16 @@ static void
+ input_pad_gtk_window_class_init (InputPadGtkWindowClass *klass)
+ {
+     GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
++#if !GTK_CHECK_VERSION (2, 90, 0)
+     GtkObjectClass *object_class = (GtkObjectClass *) klass;
++#endif
+     GtkWidgetClass *widget_class = (GtkWidgetClass *) klass;
+ 
++#if GTK_CHECK_VERSION (2, 90, 0)
++    widget_class->destroy = input_pad_gtk_window_real_destroy;
++#else
+     object_class->destroy = input_pad_gtk_window_real_destroy;
++#endif
+     widget_class->realize = input_pad_gtk_window_real_realize;
+ 
+     klass->button_pressed = input_pad_gtk_window_real_button_pressed;
+@@ -4189,7 +4216,9 @@ _input_pad_gtk_window_new_with_gtype (GtkWindowType type,
+     }
+ 
+     window = create_ui (child);
+-    INPUT_PAD_GTK_WINDOW (window)->parent.type = type;
++
++    /* setting GtkWindowType is no longer supported with gtkbuilder because
++     * the constructor property is done here. */
+ 
+     return window; 
+ }
+diff --git a/input-pad/xtest-gdk.c b/input-pad/xtest-gdk.c
+index 348b431..ac8b6ae 100644
+--- a/input-pad/xtest-gdk.c
++++ b/input-pad/xtest-gdk.c
+@@ -75,7 +75,7 @@ have_extension (InputPadGtkWindow *window)
+     g_return_val_if_fail (window != NULL &&
+                           INPUT_PAD_IS_GTK_WINDOW (window), FALSE);
+ 
+-    if (!XQueryExtension (GDK_WINDOW_XDISPLAY (GTK_WIDGET(window)->window),
++    if (!XQueryExtension (GDK_WINDOW_XDISPLAY (gtk_widget_get_window (GTK_WIDGET (window))),
+                          "XTEST", &opcode, &event, &error)) {
+         g_warning ("Could not find XTEST module. Maybe you did not install "
+                    "libXtst library.\n"
+@@ -99,13 +99,13 @@ on_window_button_pressed (InputPadGtkWindow    *window,
+     }
+     if (type == INPUT_PAD_TABLE_TYPE_CHARS) {
+         if (keysym > 0) {
+-            send_key_event (GTK_WIDGET(window)->window, keysym, keycode, state);
++            send_key_event (gtk_widget_get_window (GTK_WIDGET (window)), keysym, keycode, state);
+             return TRUE;
+         } else {
+             return FALSE;
+         }
+     } else if (type == INPUT_PAD_TABLE_TYPE_KEYSYMS) {
+-        send_key_event (GTK_WIDGET(window)->window, keysym, keycode, state);
++        send_key_event (gtk_widget_get_window (GTK_WIDGET (window)), keysym, keycode, state);
+         return TRUE;
+     }
+     return FALSE;
+diff --git a/pyinput-pad/Makefile.am b/pyinput-pad/Makefile.am
+index b215923..478f00d 100644
+--- a/pyinput-pad/Makefile.am
++++ b/pyinput-pad/Makefile.am
+@@ -55,12 +55,10 @@ nodist__input_pad_la_SOURCES = \
+ 
+ _input_pad_la_CFLAGS = \
+ 	$(PYTHON_CFLAGS)                                        \
+-	$(GTK2_CFLAGS)                                          \
+ 	$(NULL)
+ 
+ _input_pad_la_LDFLAGS = \
+ 	$(PYTHON_LIBS)                                          \
+-	$(GTK2_LIBS)                                            \
+ 	-avoid-version                                          \
+ 	-module                                                 \
+ 	$(NULL)
+@@ -69,6 +67,14 @@ _input_pad_la_LIBADD = \
+ 	$(top_builddir)/input-pad/libinput-pad.la               \
+ 	$(NULL)
+ 
++if HAVE_GTK3
++    _input_pad_la_CFLAGS += $(GTK3_CFLAGS)
++    _input_pad_la_LDFLAGS += $(GTK3_LIBS)
++else
++    _input_pad_la_CFLAGS += $(GTK2_CFLAGS)
++    _input_pad_la_LDFLAGS += $(GTK2_LIBS)
++endif
++
+ _input_pad_group_la_SOURCES = \
+ 	$(NULL)
+ 
+@@ -99,12 +105,10 @@ nodist__input_pad_window_gtk_la_SOURCES = \
+ 
+ _input_pad_window_gtk_la_CFLAGS = \
+ 	$(PYTHON_CFLAGS)                                        \
+-	$(GTK2_CFLAGS)                                          \
+ 	$(NULL)
+ 
+ _input_pad_window_gtk_la_LDFLAGS = \
+ 	$(PYTHON_LIBS)                                          \
+-	$(GTK2_LIBS)                                            \
+ 	-avoid-version                                          \
+ 	-module                                                 \
+ 	$(NULL)
+@@ -113,6 +117,14 @@ _input_pad_window_gtk_la_LIBADD = \
+ 	$(top_builddir)/input-pad/libinput-pad.la               \
+ 	$(NULL)
+ 
++if HAVE_GTK3
++    _input_pad_window_gtk_la_CFLAGS += $(GTK3_CFLAGS)
++    _input_pad_window_gtk_la_LDFLAGS += $(GTK3_LIBS)
++else
++    _input_pad_window_gtk_la_CFLAGS += $(GTK2_CFLAGS)
++    _input_pad_window_gtk_la_LDFLAGS += $(GTK2_LIBS)
++endif
++
+ %.py %_wrap.c: %.i
+ 	@f=`basename "$<"`;                                     \
+ 	if [ x"$$f" = xinput_pad_window_gtk.i ] ; then          \
+-- 
+1.7.2.1
+
diff --git a/input-pad.spec b/input-pad.spec
index 8c12908..3338b00 100644
--- a/input-pad.spec
+++ b/input-pad.spec
@@ -1,6 +1,7 @@
 %define have_python_devel 1
 %define have_xtest_devel  1
 %define have_eek_devel    1
+%define use_gtk3          1
 
 %if %have_python_devel
   %if ! (0%{?fedora} > 12 || 0%{?rhel} > 5)
@@ -20,17 +21,22 @@
 
 Name:       input-pad
 Version:    0.1.2
-Release:    1%{?dist}
+Release:    2%{?dist}
 Summary:    On-screen Input Pad to Send Characters with Mouse
 License:    LGPLv2+
 Group:      System Environment/Libraries
 URL:        http://code.google.com/p/input-pad/
 Source0:    http://input-pad.googlecode.com/files/%{name}-%{version}.tar.gz
+Patch1:     input-pad-xx-gtk3.patch
 
 BuildRoot:  %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
 BuildRequires:  gettext-devel
+%if %use_gtk3
+BuildRequires:  gtk3-devel
+%else
 BuildRequires:  gtk2-devel
+%endif
 BuildRequires:  libtool
 BuildRequires:  libxkbfile-devel
 BuildRequires:  libxklavier-devel       >= %libxklavier_version
@@ -91,8 +97,18 @@ The input-pad-eek package contains eekboard extension module
 
 %prep
 %setup -q
+%if %use_gtk3
+%patch1 -p1
+%endif
 
 %build
+%if %use_gtk3
+libtoolize -c -f
+aclocal
+autoconf
+autoheader
+automake -a -c -f
+%endif
 %configure \
 %if ! %have_python_devel
     --disable-python            \
@@ -103,6 +119,9 @@ The input-pad-eek package contains eekboard extension module
 %if %have_xtest_devel
     --enable-xtest              \
 %endif
+%if %use_gtk3
+    --with-gtk-version=3        \
+%endif
     --disable-static
 make %{?_smp_mflags}
 
@@ -179,6 +198,9 @@ rm -rf $RPM_BUILD_ROOT
 %endif
 
 %changelog
+* Tue Nov 09 2010 Takao Fujiwara <tfujiwar at redhat.com> - 0.1.2-2
+- Added input-pad-xx-gtk3.patch for GTK3
+
 * Tue Sep 07 2010 Takao Fujiwara <tfujiwar at redhat.com> - 0.1.2-1
 - Bumped to 0.1.2
 


More information about the scm-commits mailing list