[virt-tools-list] [virt-viewer v4] Drop support to gtk2

Jonathon Jongsma jjongsma at redhat.com
Mon Feb 15 20:38:38 UTC 2016


Looks good, thanks!

Acked-by: Jonathon Jongsma <jjongsma at redhat.com>



On Mon, 2016-02-15 at 21:33 +0100, Fabiano Fidêncio wrote:
> The 3.0 release was the last one that still supports GTK2. For the
> Windows builds the support to GTK2 was dropped in the previous release.
> Let's do the same for the entire project now.
> 
> Signed-off-by: Eduardo Lima (Etrunko) <etrunko at redhat.com>
> 
> --
> Changes since v3:
>  - Addressed Jonathon's comments. Please, take a look on diff between v4
>    and v3 here: http://ur1.ca/oiw9a
> --
> 
> ---
>  configure.ac                    |  57 ++++-----------------
>  src/Makefile.am                 |   1 -
>  src/view/autoDrawer.c           |  10 ----
>  src/view/ovBox.c                |  45 -----------------
>  src/virt-gtk-compat.h           |  78 -----------------------------
>  src/virt-viewer-app.c           |  17 +++----
>  src/virt-viewer-display-spice.c |   2 +-
>  src/virt-viewer-display.c       | 107 +--------------------------------------
> -
>  src/virt-viewer-display.h       |   1 -
>  src/virt-viewer-window.c        |  59 +++++++++-------------
>  virt-viewer.spec.in             |  23 ---------
>  11 files changed, 43 insertions(+), 357 deletions(-)
>  delete mode 100644 src/virt-gtk-compat.h
> 
> diff --git a/configure.ac b/configure.ac
> index 8aa80ca..2b979f4 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -15,10 +15,8 @@ AM_SILENT_RULES([yes])
>  GLIB2_REQUIRED=2.22.0
>  LIBXML2_REQUIRED="2.6.0"
>  LIBVIRT_REQUIRED="0.10.0"
> -GTK2_REQUIRED="2.18.0"
> -GTK3_REQUIRED="3.0"
> -GTK_VNC1_REQUIRED="0.3.8"
> -GTK_VNC2_REQUIRED="0.4.0"
> +GTK_REQUIRED="3.0"
> +GTK_VNC_REQUIRED="0.4.0"
>  SPICE_GTK_REQUIRED="0.30"
>  SPICE_PROTOCOL_REQUIRED="0.12.7"
>  GOVIRT_REQUIRED="0.3.2"
> @@ -26,10 +24,8 @@ GOVIRT_REQUIRED="0.3.2"
>  AC_SUBST([GLIB2_REQUIRED])
>  AC_SUBST([LIBXML2_REQUIRED])
>  AC_SUBST([LIBVIRT_REQUIRED])
> -AC_SUBST([GTK2_REQUIRED])
> -AC_SUBST([GTK3_REQUIRED])
> -AC_SUBST([GTK_VNC1_REQUIRED])
> -AC_SUBST([GTK_VNC2_REQUIRED])
> +AC_SUBST([GTK_REQUIRED])
> +AC_SUBST([GTK_VNC_REQUIRED])
>  AC_SUBST([SPICE_GTK_REQUIRED])
>  AC_SUBST([SPICE_PROTOCOL_REQUIRED])
>  AC_SUBST([GOVIRT_REQUIRED])
> @@ -121,48 +117,17 @@ AC_CHECK_LIB([virt],
>               [AC_DEFINE([HAVE_VIR_DOMAIN_OPEN_GRAPHICS_FD], 1, [Have
> virDomainOpenGraphicsFD?])])
>  LIBS=$old_LIBS
>  
> -AC_MSG_CHECKING([which gtk+ version to compile against])
> -AC_ARG_WITH([gtk],
> -  [AS_HELP_STRING([--with-gtk=2.0|3.0],[which gtk+ version to compile against
> (default: 3.0)])],
> -  [case "$with_gtk" in
> -     2.0|3.0) ;;
> -     *) AC_MSG_ERROR([invalid gtk version specified]) ;;
> -   esac],
> -  [with_gtk=3.0])
> -AC_MSG_RESULT([$with_gtk])
> -
> -case "$with_gtk" in
> -  2.0) GTK_API_VERSION=2.0
> -       GTK_REQUIRED=$GTK2_REQUIRED
> -       GTK_VNC_REQUIRED=$GTK_VNC1_REQUIRED
> -       GTK_VNC_API_VERSION=1.0
> -       SPICE_GTK_API_VERSION=2.0
> -       ;;
> -  3.0) GTK_API_VERSION=3.0
> -       GTK_REQUIRED=$GTK3_REQUIRED
> -       GTK_VNC_REQUIRED=$GTK_VNC2_REQUIRED
> -       GTK_VNC_API_VERSION=2.0
> -       SPICE_GTK_API_VERSION=3.0
> -       ;;
> -esac
> -
> -AC_SUBST([GTK_API_VERSION])
> -AC_SUBST([GTK_REQUIRED])
> -AC_SUBST([GTK_VNC_API_VERSION])
> -AM_CONDITIONAL([HAVE_GTK_2],[test "$with_gtk" = "2.0"])
> -AM_CONDITIONAL([HAVE_GTK_3],[test "$with_gtk" = "3.0"])
> -
> -PKG_CHECK_MODULES(GTK, gtk+-$GTK_API_VERSION >= $GTK_REQUIRED)
> +PKG_CHECK_MODULES(GTK, gtk+-3.0 >= $GTK_REQUIRED)
>  
>  AC_ARG_WITH([gtk-vnc],
>      AS_HELP_STRING([--without-gtk-vnc], [Ignore presence of gtk-vnc and
> disable it]))
>  
>  AS_IF([test "x$with_gtk_vnc" != "xno" && test "x$with_gtk_vnc" != "xyes"],
> -      [PKG_CHECK_EXISTS([gtk-vnc-$GTK_VNC_API_VERSION >= $GTK_VNC_REQUIRED],
> +      [PKG_CHECK_EXISTS([gtk-vnc-2.0 >= $GTK_VNC_REQUIRED],
>                          [with_gtk_vnc=yes], [with_gtk_vnc=no])])
>  
>  AS_IF([test "x$with_gtk_vnc" = "xyes"],
> -      [PKG_CHECK_MODULES(GTK_VNC, [gtk-vnc-$GTK_VNC_API_VERSION >=
> $GTK_VNC_REQUIRED])]
> +      [PKG_CHECK_MODULES(GTK_VNC, [gtk-vnc-2.0 >= $GTK_VNC_REQUIRED])]
>        [AC_DEFINE([HAVE_GTK_VNC], 1, [Have gtk-vnc?])]
>  )
>  AM_CONDITIONAL([HAVE_GTK_VNC], [test "x$with_gtk_vnc" = "xyes"])
> @@ -171,12 +136,12 @@ AC_ARG_WITH([spice-gtk],
>      AS_HELP_STRING([--without-spice-gtk], [Ignore presence of spice-gtk and
> disable it]))
>  
>  AS_IF([test "x$with_spice_gtk" != "xno" && test "x$with_spice_gtk" !=
> "xyes"],
> -      [PKG_CHECK_EXISTS([spice-client-gtk-$SPICE_GTK_API_VERSION >=
> $SPICE_GTK_REQUIRED
> +      [PKG_CHECK_EXISTS([spice-client-gtk-3.0 >= $SPICE_GTK_REQUIRED
>                           spice-controller spice-protocol >=
> $SPICE_PROTOCOL_REQUIRED],
>                          [with_spice_gtk=yes], [with_spice_gtk=no])])
>  
>  AS_IF([test "x$with_spice_gtk" = "xyes"],
> -      [PKG_CHECK_MODULES(SPICE_GTK, [spice-client-gtk-$SPICE_GTK_API_VERSION
> >= $SPICE_GTK_REQUIRED])]
> +      [PKG_CHECK_MODULES(SPICE_GTK, [spice-client-gtk-3.0 >=
> $SPICE_GTK_REQUIRED])]
>        [PKG_CHECK_MODULES(SPICE_CONTROLLER, [spice-controller])]
>        [PKG_CHECK_MODULES(SPICE_PROTOCOL, [spice-protocol >=
> $SPICE_PROTOCOL_REQUIRED])]
>        [AC_DEFINE([HAVE_SPICE_GTK], 1, [Have spice-gtk?])]
> @@ -275,10 +240,6 @@ AC_MSG_NOTICE([])
>  AC_MSG_NOTICE([Configuration summary])
>  AC_MSG_NOTICE([=====================])
>  AC_MSG_NOTICE([])
> -AC_MSG_NOTICE([ Features:])
> -AC_MSG_NOTICE([])
> -AC_MSG_NOTICE([      Gtk: $with_gtk])
> -AC_MSG_NOTICE([])
>  AC_MSG_NOTICE([ Libraries:])
>  AC_MSG_NOTICE([])
>  AC_MSG_NOTICE([       GLIB2: $GLIB2_CFLAGS $GLIB2_LIBS])
> diff --git a/src/Makefile.am b/src/Makefile.am
> index 1ebc24e..42d30fd 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -42,7 +42,6 @@ libvirt_viewer_la_SOURCES =					
> \
>  	$(BUILT_SOURCES)				\
>  	virt-glib-compat.h				\
>  	virt-glib-compat.c				\
> -	virt-gtk-compat.h				\
>  	virt-viewer-util.h				\
>  	virt-viewer-util.c				\
>  	virt-viewer-auth.h				\
> diff --git a/src/view/autoDrawer.c b/src/view/autoDrawer.c
> index cbf92de..2ae106c 100644
> --- a/src/view/autoDrawer.c
> +++ b/src/view/autoDrawer.c
> @@ -218,7 +218,6 @@ ViewAutoDrawerUpdate(ViewAutoDrawer *that, // IN
>     if (gtk_widget_get_window(priv->evBox)) {
>        int x;
>        int y;
> -#if GTK_CHECK_VERSION(3, 0, 0)
>        GdkDevice *dev;
>        GdkDeviceManager *devmgr;
>  
> @@ -227,9 +226,6 @@ ViewAutoDrawerUpdate(ViewAutoDrawer *that, // IN
>  
>        gdk_window_get_device_position(gtk_widget_get_window(priv->evBox),
>                                       dev, &x, &y, NULL);
> -#else
> -      gtk_widget_get_pointer(priv->evBox, &x, &y);
> -#endif
>  
>        gtk_widget_get_allocation(priv->evBox, &allocation);
>        g_assert(gtk_container_get_border_width(   GTK_CONTAINER(priv->evBox))
> @@ -262,16 +258,10 @@ ViewAutoDrawerUpdate(ViewAutoDrawer *that, // IN
>     if (!priv->inputUngrabbed) {
>        GtkWidget *grabbed = NULL;
>  
> -#if GTK_CHECK_VERSION(3, 0, 0)
>        if (gtk_window_has_group (window)) {
>          GtkWindowGroup *group = gtk_window_get_group (window);
>          grabbed = gtk_window_group_get_current_grab (group);
>        }
> -#else
> -      if (window->group && window->group->grabs) {
> -        grabbed = GTK_WIDGET(window->group->grabs->data);
> -      }
> -#endif
>        if (!grabbed) {
>           grabbed = gtk_grab_get_current();
>        }
> diff --git a/src/view/ovBox.c b/src/view/ovBox.c
> index 185b0b7..fa56fd5 100644
> --- a/src/view/ovBox.c
> +++ b/src/view/ovBox.c
> @@ -76,13 +76,6 @@
>  
>  #include "ovBox.h"
>  
> -#if ! GTK_CHECK_VERSION(3, 0, 0)
> -#define gtk_widget_set_realized(widget, val)        \
> -  GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED)
> -#define gtk_widget_get_realized(widget)                \
> -  GTK_WIDGET_REALIZED(widget)
> -#endif
> -
>  struct _ViewOvBoxPrivate
>  {
>     GdkWindow *underWin;
> @@ -338,22 +331,12 @@ static void
>  ViewOvBoxSetBackground(ViewOvBox *that) // IN
>  {
>     GtkWidget *widget = GTK_WIDGET(that);
> -
> -#if GTK_CHECK_VERSION(3, 0, 0)
>     GtkStyleContext *stylecontext;
>  
>     stylecontext = gtk_widget_get_style_context(widget);
>     gtk_style_context_set_background(stylecontext,
> gtk_widget_get_window(widget));
>     gtk_style_context_set_background(stylecontext, that->priv->underWin);
>     gtk_style_context_set_background(stylecontext, that->priv->overWin);
> -#else
> -   GtkStyle *style;
> -
> -   style = gtk_widget_get_style (widget);
> -   gtk_style_set_background(style, gtk_widget_get_window(widget),
> GTK_STATE_NORMAL);
> -   gtk_style_set_background(style, that->priv->underWin, GTK_STATE_NORMAL);
> -   gtk_style_set_background(style, that->priv->overWin, GTK_STATE_NORMAL);
> -#endif
>  }
>  
>  
> @@ -403,9 +386,6 @@ ViewOvBoxRealize(GtkWidget *widget) // IN
>                             &attributes, mask);
>     gtk_widget_set_window(widget, window);
>     gdk_window_set_user_data(window, that);
> -#if !GTK_CHECK_VERSION(3, 0, 0)
> -   gtk_widget_set_style(widget,
> gtk_style_attach(gtk_widget_get_style(widget), window));
> -#endif
>  
>     /*
>      * The order in which we create the children X window matters: the child
> @@ -508,11 +488,7 @@ ViewOvBoxRealSizeRequest(GtkWidget *widget,           //
> IN
>     that = VIEW_OV_BOX(widget);
>     priv = that->priv;
>  
> -#if GTK_CHECK_VERSION(3, 0, 0)
>     gtk_widget_get_preferred_size(priv->over, NULL, &priv->overR);
> -#else
> -   gtk_widget_size_request(priv->over, &priv->overR);
> -#endif
>  
>     gtk_container_child_get(GTK_CONTAINER(that), priv->over,
>                             "expand", &expand,
> @@ -534,7 +510,6 @@ ViewOvBoxRealSizeRequest(GtkWidget *widget,           //
> IN
>     }
>  }
>  
> -#if GTK_CHECK_VERSION(3, 0, 0)
>  static void
>  ViewOvBox_get_preferred_width (GtkWidget *widget,
>                                 gint      *minimal_width,
> @@ -567,22 +542,6 @@ ViewOvBox_get_preferred_height (GtkWidget *widget,
>     *natural_height = nat_out.height;
>  }
>  
> -#else
> -
> -static void
> -ViewOvBoxSizeRequest(GtkWidget *widget,           // IN
> -                     GtkRequisition *requisition) // OUT
> -{
> -   ViewOvBoxPrivate *priv = VIEW_OV_BOX(widget)->priv;
> -   GtkRequisition min;
> -
> -   gtk_widget_size_request(priv->under, &min);
> -
> -   ViewOvBoxRealSizeRequest(widget, &min, NULL, requisition, NULL);
> -}
> -#endif
> -
> -
>  /*
>   *---------------------------------------------------------------------------
> --
>   *
> @@ -760,12 +719,8 @@ ViewOvBoxClassInit(ViewOvBoxClass *klass) // IN
>     widgetClass->unmap = ViewOvBoxUnmap;
>     widgetClass->realize = ViewOvBoxRealize;
>     widgetClass->unrealize = ViewOvBoxUnrealize;
> -#if GTK_CHECK_VERSION(3, 0, 0)
>     widgetClass->get_preferred_width = ViewOvBox_get_preferred_width;
>     widgetClass->get_preferred_height = ViewOvBox_get_preferred_height;
> -#else
> -   widgetClass->size_request = ViewOvBoxSizeRequest;
> -#endif
>     widgetClass->size_allocate = ViewOvBoxSizeAllocate;
>     widgetClass->style_set = ViewOvBoxStyleSet;
>  
> diff --git a/src/virt-gtk-compat.h b/src/virt-gtk-compat.h
> deleted file mode 100644
> index 110c17a..0000000
> --- a/src/virt-gtk-compat.h
> +++ /dev/null
> @@ -1,78 +0,0 @@
> -/*
> - * 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 <gtk/gtk.h>
> -#include <gdk/gdk.h>
> -
> -G_BEGIN_DECLS
> -
> -#if !GTK_CHECK_VERSION(2, 20, 0)
> -#define gtk_widget_get_mapped(w) GTK_WIDGET_MAPPED(w)
> -#endif
> -
> -#if GTK_CHECK_VERSION(3, 0, 0)
> -#define GDK_Shift_L GDK_KEY_Shift_L
> -#define GDK_VoidSymbol GDK_KEY_VoidSymbol
> -#define GDK_Control_L GDK_KEY_Control_L
> -#define GDK_Alt_L GDK_KEY_Alt_L
> -#define GDK_Delete GDK_KEY_Delete
> -#define GDK_End GDK_KEY_End
> -#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
> -#define GDK_0 GDK_KEY_0
> -#define GDK_plus GDK_KEY_plus
> -#define GDK_minus GDK_KEY_minus
> -#endif
> -
> -#if !GTK_CHECK_VERSION(3, 0, 0)
> -#define gtk_widget_get_realized(widget)         \
> -  GTK_WIDGET_REALIZED(widget)
> -#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 60157e9..7f7fed3 100644
> --- a/src/virt-viewer-app.c
> +++ b/src/virt-viewer-app.c
> @@ -50,7 +50,6 @@
>  #include <windows.h>
>  #endif
>  
> -#include "virt-gtk-compat.h"
>  #include "virt-viewer-app.h"
>  #include "virt-viewer-auth.h"
>  #include "virt-viewer-window.h"
> @@ -1883,14 +1882,14 @@ virt_viewer_app_constructed(GObject *object)
>      virt_viewer_app_set_hotkeys(self, opt_hotkeys);
>      virt_viewer_window_set_zoom_level(self->priv->main_window, opt_zoom);
>  
> -    virt_viewer_set_insert_smartcard_accel(self, GDK_F8, GDK_SHIFT_MASK);
> -    virt_viewer_set_remove_smartcard_accel(self, GDK_F9, GDK_SHIFT_MASK);
> -    gtk_accel_map_add_entry("<virt-viewer>/view/toggle-fullscreen", GDK_F11,
> 0);
> -    gtk_accel_map_add_entry("<virt-viewer>/view/release-cursor", GDK_F12,
> GDK_SHIFT_MASK);
> -    gtk_accel_map_add_entry("<virt-viewer>/view/zoom-reset", GDK_0,
> GDK_CONTROL_MASK);
> -    gtk_accel_map_add_entry("<virt-viewer>/view/zoom-out", GDK_minus,
> GDK_CONTROL_MASK);
> -    gtk_accel_map_add_entry("<virt-viewer>/view/zoom-in", GDK_plus,
> GDK_CONTROL_MASK);
> -    gtk_accel_map_add_entry("<virt-viewer>/send/secure-attention", GDK_End,
> GDK_CONTROL_MASK | GDK_MOD1_MASK);
> +    virt_viewer_set_insert_smartcard_accel(self, GDK_KEY_F8, GDK_SHIFT_MASK);
> +    virt_viewer_set_remove_smartcard_accel(self, GDK_KEY_F9, GDK_SHIFT_MASK);
> +    gtk_accel_map_add_entry("<virt-viewer>/view/toggle-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>/view/zoom-reset", GDK_KEY_0,
> GDK_CONTROL_MASK);
> +    gtk_accel_map_add_entry("<virt-viewer>/view/zoom-out", GDK_KEY_minus,
> GDK_CONTROL_MASK);
> +    gtk_accel_map_add_entry("<virt-viewer>/view/zoom-in", GDK_KEY_plus,
> GDK_CONTROL_MASK);
> +    gtk_accel_map_add_entry("<virt-viewer>/send/secure-attention",
> GDK_KEY_End, GDK_CONTROL_MASK | GDK_MOD1_MASK);
>  }
>  
>  static void
> diff --git a/src/virt-viewer-display-spice.c b/src/virt-viewer-display-spice.c
> index c3dbd75..5114833 100644
> --- a/src/virt-viewer-display-spice.c
> +++ b/src/virt-viewer-display-spice.c
> @@ -214,7 +214,7 @@
> virt_viewer_display_spice_size_allocate(VirtViewerDisplaySpice *self,
>       * resizes the window to the size it already wants to be (based on
> desktop
>       * size and zoom level), just return early
>       */
> -    virt_viewer_display_get_preferred_size(VIRT_VIEWER_DISPLAY(self),
> &preferred);
> +    gtk_widget_get_preferred_size(GTK_WIDGET(self), NULL, &preferred);
>      if (preferred.width == allocation->width
>          && preferred.height == allocation->height) {
>          return;
> diff --git a/src/virt-viewer-display.c b/src/virt-viewer-display.c
> index e3f86a3..16fb930 100644
> --- a/src/virt-viewer-display.c
> +++ b/src/virt-viewer-display.c
> @@ -27,7 +27,6 @@
>  #include <locale.h>
>  #include <math.h>
>  
> -#include "virt-gtk-compat.h"
>  #include "virt-viewer-session.h"
>  #include "virt-viewer-display.h"
>  #include "virt-viewer-util.h"
> @@ -36,10 +35,6 @@
>  
>  struct _VirtViewerDisplayPrivate
>  {
> -#if !GTK_CHECK_VERSION(3, 0, 0)
> -    gboolean dirty;
> -    gboolean size_request_once;
> -#endif
>      guint desktopWidth;
>      guint desktopHeight;
>      guint zoom_level;
> @@ -50,17 +45,12 @@ struct _VirtViewerDisplayPrivate
>      gboolean fullscreen;
>  };
>  
> -#if !GTK_CHECK_VERSION(3, 0, 0)
> -static void virt_viewer_display_size_request(GtkWidget *widget,
> -                                             GtkRequisition *requisition);
> -#else
>  static void virt_viewer_display_get_preferred_width(GtkWidget *widget,
>                                                      int *minwidth,
>                                                      int *defwidth);
>  static void virt_viewer_display_get_preferred_height(GtkWidget *widget,
>                                                       int *minheight,
>                                                       int *defheight);
> -#endif
>  static void virt_viewer_display_size_allocate(GtkWidget *widget,
>                                                GtkAllocation *allocation);
>  static void virt_viewer_display_set_property(GObject *object,
> @@ -99,12 +89,8 @@ virt_viewer_display_class_init(VirtViewerDisplayClass
> *class)
>      object_class->set_property = virt_viewer_display_set_property;
>      object_class->get_property = virt_viewer_display_get_property;
>  
> -#if GTK_CHECK_VERSION(3, 0, 0)
>      widget_class->get_preferred_width =
> virt_viewer_display_get_preferred_width;
>      widget_class->get_preferred_height =
> virt_viewer_display_get_preferred_height;
> -#else
> -    widget_class->size_request = virt_viewer_display_size_request;
> -#endif
>      widget_class->size_allocate = virt_viewer_display_size_allocate;
>      widget_class->grab_focus = virt_viewer_display_grab_focus;
>  
> @@ -268,10 +254,6 @@ virt_viewer_display_init(VirtViewerDisplay *display)
>      display->priv->desktopWidth = MIN_DISPLAY_WIDTH;
>      display->priv->desktopHeight = MIN_DISPLAY_HEIGHT;
>      display->priv->zoom_level = NORMAL_ZOOM_LEVEL;
> -#if !GTK_CHECK_VERSION(3, 0, 0)
> -    display->priv->dirty = TRUE;
> -    display->priv->size_request_once = FALSE;
> -#endif
>  }
>  
>  GtkWidget*
> @@ -363,81 +345,6 @@ virt_viewer_display_grab_focus(GtkWidget *widget)
>      gtk_widget_grab_focus(gtk_bin_get_child(bin));
>  }
>  
> -/* Compatibility function to allow gtk2 to emulate gtk3 behavior. We can't
> use
> - * the size request since it simply returns the minimum size whenever dirty
> is
> - * false */
> -void virt_viewer_display_get_preferred_size(VirtViewerDisplay *self,
> -                                            GtkRequisition *requisition)
> -{
> -#if GTK_CHECK_VERSION(3, 0, 0)
> -    gtk_widget_get_preferred_size(GTK_WIDGET(self), NULL, requisition);
> -#else
> -    VirtViewerDisplayPrivate *priv = self->priv;
> -    int border_width = gtk_container_get_border_width(GTK_CONTAINER(self));
> -
> -    requisition->width = border_width * 2;
> -    requisition->height = border_width * 2;
> -
> -    if (virt_viewer_display_get_zoom(self)) {
> -        requisition->width += round(priv->desktopWidth * priv->zoom_level /
> (double) NORMAL_ZOOM_LEVEL);
> -        requisition->height += round(priv->desktopHeight * priv->zoom_level /
> (double) NORMAL_ZOOM_LEVEL);
> -    } else {
> -        requisition->width += priv->desktopWidth;
> -        requisition->height += priv->desktopHeight;
> -    }
> -#endif
> -}
> -
> -
> -#if !GTK_CHECK_VERSION(3, 0, 0)
> -static gboolean
> -virt_viewer_display_idle(gpointer opaque)
> -{
> -    VirtViewerDisplay *display = opaque;
> -    VirtViewerDisplayPrivate *priv = display->priv;
> -    if (!priv->dirty)
> -        gtk_widget_queue_resize_no_redraw(GTK_WIDGET(display));
> -    return FALSE;
> -}
> -
> -
> -static void
> -virt_viewer_display_size_request(GtkWidget *widget,
> -                                 GtkRequisition *requisition)
> -{
> -    VirtViewerDisplay *display = VIRT_VIEWER_DISPLAY(widget);
> -    VirtViewerDisplayPrivate *priv = display->priv;
> -
> -    if (priv->dirty || !priv->size_request_once) {
> -        virt_viewer_display_get_preferred_size(display, requisition);
> -    } else {
> -        requisition->width = MIN_DISPLAY_WIDTH * priv->zoom_level / (double)
> NORMAL_ZOOM_LEVEL;
> -        requisition->height = MIN_DISPLAY_HEIGHT * priv->zoom_level /
> (double) NORMAL_ZOOM_LEVEL;
> -    }
> -
> -    priv->size_request_once = TRUE;
> -    g_debug("Display size request %dx%d (desktop %dx%d)",
> -              requisition->width, requisition->height,
> -              priv->desktopWidth, priv->desktopHeight);
> -}
> -
> -static void
> -virt_viewer_display_make_resizable(VirtViewerDisplay *self)
> -{
> -    VirtViewerDisplayPrivate *priv = self->priv;
> -
> -    /* This unsets the size request, so that the user can
> -     * manually resize the window smaller again
> -     */
> -    if (priv->dirty) {
> -        g_idle_add(virt_viewer_display_idle, GTK_WIDGET(self));
> -        if (gtk_widget_get_mapped(GTK_WIDGET(self)))
> -            priv->dirty = FALSE;
> -    }
> -}
> -
> -#else
> -
>  static void
> virt_viewer_display_get_preferred_dimension_from_desktop(VirtViewerDisplay
> *display,
>                                                                       const
> int minimal_size,
>                                                                       const
> int desktop_dim,
> @@ -487,7 +394,6 @@ static void
> virt_viewer_display_get_preferred_height(GtkWidget *widget,
>                                                               minheight,
>                                                               defheight);
>  }
> -#endif
>  
>  
>  static void
> @@ -509,11 +415,8 @@ virt_viewer_display_size_allocate(GtkWidget *widget,
>  
>      if (priv->desktopWidth == 0 || priv->desktopHeight == 0 ||
>          child == NULL || !gtk_widget_get_visible(child))
> -#if !GTK_CHECK_VERSION(3, 0, 0)
> -        goto end;
> -#else
>          return;
> -#endif
> +
>      border_width = gtk_container_get_border_width(GTK_CONTAINER(display));
>  
>      width  = MAX(1, allocation->width - 2 * border_width);
> @@ -535,11 +438,6 @@ virt_viewer_display_size_allocate(GtkWidget *widget,
>  
>      g_debug("Child allocate %dx%d", child_allocation.width,
> child_allocation.height);
>      gtk_widget_size_allocate(child, &child_allocation);
> -
> -#if !GTK_CHECK_VERSION(3, 0, 0)
> -end:
> -    virt_viewer_display_make_resizable(display);
> -#endif
>  }
>  
>  
> @@ -577,9 +475,6 @@ void virt_viewer_display_queue_resize(VirtViewerDisplay
> *display)
>      GtkWidget *child = gtk_bin_get_child(GTK_BIN(display));
>  
>      if (child && gtk_widget_get_visible(child)) {
> -#if !GTK_CHECK_VERSION(3, 0, 0)
> -        display->priv->dirty = TRUE;
> -#endif
>          gtk_widget_queue_resize(GTK_WIDGET(display));
>      }
>  }
> diff --git a/src/virt-viewer-display.h b/src/virt-viewer-display.h
> index a279697..7b55ca5 100644
> --- a/src/virt-viewer-display.h
> +++ b/src/virt-viewer-display.h
> @@ -133,7 +133,6 @@ gboolean virt_viewer_display_get_enabled(VirtViewerDisplay
> *display);
>  gboolean virt_viewer_display_get_selectable(VirtViewerDisplay *display);
>  void virt_viewer_display_queue_resize(VirtViewerDisplay *display);
>  void virt_viewer_display_get_preferred_monitor_geometry(VirtViewerDisplay
> *self, GdkRectangle* preferred);
> -void virt_viewer_display_get_preferred_size(VirtViewerDisplay *self,
> GtkRequisition* requisistion);
>  gint virt_viewer_display_get_nth(VirtViewerDisplay *self);
>  
>  G_END_DECLS
> diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
> index a1b9940..0624952 100644
> --- a/src/virt-viewer-window.c
> +++ b/src/virt-viewer-window.c
> @@ -36,7 +36,6 @@
>  #include <glib/gi18n.h>
>  #include <math.h>
>  
> -#include "virt-gtk-compat.h"
>  #include "virt-viewer-window.h"
>  #include "virt-viewer-display.h"
>  #include "virt-viewer-session.h"
> @@ -343,9 +342,7 @@ virt_viewer_window_init (VirtViewerWindow *self)
>  
>      virt_viewer_window_update_title(self);
>      gtk_window_set_resizable(GTK_WINDOW(priv->window), TRUE);
> -#if GTK_CHECK_VERSION(3, 0, 0)
>      gtk_window_set_has_resize_grip(GTK_WINDOW(priv->window), FALSE);
> -#endif
>      priv->accel_enabled = TRUE;
>  
>      accels = gtk_accel_groups_from_object(G_OBJECT(priv->window));
> @@ -408,15 +405,11 @@ static void
>  virt_viewer_window_queue_resize(VirtViewerWindow *self)
>  {
>      VirtViewerWindowPrivate *priv = self->priv;
> -#if GTK_CHECK_VERSION(3, 0, 0)
>      GtkRequisition nat;
>  
>      gtk_window_set_default_size(GTK_WINDOW(priv->window), -1, -1);
>      gtk_widget_get_preferred_size(GTK_WIDGET(priv->window), NULL, &nat);
>      gtk_window_resize(GTK_WINDOW(priv->window), nat.width, nat.height);
> -#else
> -    gtk_window_resize(GTK_WINDOW(priv->window), 1, 1);
> -#endif
>  }
>  
>  static void
> @@ -534,23 +527,23 @@ struct keyComboDef {
>  };
>  
>  static const struct keyComboDef keyCombos[] = {
> -    { { GDK_Control_L, GDK_Alt_L, GDK_Delete, GDK_VoidSymbol },
> N_("Ctrl+Alt+_Del"), "<virt-viewer>/send/secure-attention"},
> -    { { GDK_Control_L, GDK_Alt_L, GDK_BackSpace, GDK_VoidSymbol },
> N_("Ctrl+Alt+_Backspace"), NULL},
> -    { { GDK_VoidSymbol }, "" , NULL},
> -    { { GDK_Control_L, GDK_Alt_L, GDK_F1, GDK_VoidSymbol },
> N_("Ctrl+Alt+F_1"), NULL},
> -    { { GDK_Control_L, GDK_Alt_L, GDK_F2, GDK_VoidSymbol },
> N_("Ctrl+Alt+F_2"), NULL},
> -    { { GDK_Control_L, GDK_Alt_L, GDK_F3, GDK_VoidSymbol },
> N_("Ctrl+Alt+F_3"), NULL},
> -    { { GDK_Control_L, GDK_Alt_L, GDK_F4, GDK_VoidSymbol },
> N_("Ctrl+Alt+F_4"), NULL},
> -    { { GDK_Control_L, GDK_Alt_L, GDK_F5, GDK_VoidSymbol },
> N_("Ctrl+Alt+F_5"), NULL},
> -    { { GDK_Control_L, GDK_Alt_L, GDK_F6, GDK_VoidSymbol },
> N_("Ctrl+Alt+F_6"), NULL},
> -    { { GDK_Control_L, GDK_Alt_L, GDK_F7, GDK_VoidSymbol },
> N_("Ctrl+Alt+F_7"), NULL},
> -    { { GDK_Control_L, GDK_Alt_L, GDK_F8, GDK_VoidSymbol },
> N_("Ctrl+Alt+F_8"), NULL},
> -    { { GDK_Control_L, GDK_Alt_L, GDK_F9, GDK_VoidSymbol },
> N_("Ctrl+Alt+F_9"), NULL},
> -    { { GDK_Control_L, GDK_Alt_L, GDK_F10, GDK_VoidSymbol },
> N_("Ctrl+Alt+F1_0"), NULL},
> -    { { GDK_Control_L, GDK_Alt_L, GDK_F11, GDK_VoidSymbol },
> N_("Ctrl+Alt+F11"), NULL},
> -    { { GDK_Control_L, GDK_Alt_L, GDK_F12, GDK_VoidSymbol },
> N_("Ctrl+Alt+F12"), NULL},
> -    { { GDK_VoidSymbol }, "" , NULL},
> -    { { GDK_Print, GDK_VoidSymbol }, "_PrintScreen", NULL},
> +    { { GDK_KEY_Control_L, GDK_KEY_Alt_L, GDK_KEY_Delete, GDK_KEY_VoidSymbol
> }, N_("Ctrl+Alt+_Del"), "<virt-viewer>/send/secure-attention"},
> +    { { GDK_KEY_Control_L, GDK_KEY_Alt_L, GDK_KEY_BackSpace,
> GDK_KEY_VoidSymbol }, N_("Ctrl+Alt+_Backspace"), NULL},
> +    { { GDK_KEY_VoidSymbol }, "" , NULL},
> +    { { GDK_KEY_Control_L, GDK_KEY_Alt_L, GDK_KEY_F1, GDK_KEY_VoidSymbol },
> N_("Ctrl+Alt+F_1"), NULL},
> +    { { GDK_KEY_Control_L, GDK_KEY_Alt_L, GDK_KEY_F2, GDK_KEY_VoidSymbol },
> N_("Ctrl+Alt+F_2"), NULL},
> +    { { GDK_KEY_Control_L, GDK_KEY_Alt_L, GDK_KEY_F3, GDK_KEY_VoidSymbol },
> N_("Ctrl+Alt+F_3"), NULL},
> +    { { GDK_KEY_Control_L, GDK_KEY_Alt_L, GDK_KEY_F4, GDK_KEY_VoidSymbol },
> N_("Ctrl+Alt+F_4"), NULL},
> +    { { GDK_KEY_Control_L, GDK_KEY_Alt_L, GDK_KEY_F5, GDK_KEY_VoidSymbol },
> N_("Ctrl+Alt+F_5"), NULL},
> +    { { GDK_KEY_Control_L, GDK_KEY_Alt_L, GDK_KEY_F6, GDK_KEY_VoidSymbol },
> N_("Ctrl+Alt+F_6"), NULL},
> +    { { GDK_KEY_Control_L, GDK_KEY_Alt_L, GDK_KEY_F7, GDK_KEY_VoidSymbol },
> N_("Ctrl+Alt+F_7"), NULL},
> +    { { GDK_KEY_Control_L, GDK_KEY_Alt_L, GDK_KEY_F8, GDK_KEY_VoidSymbol },
> N_("Ctrl+Alt+F_8"), NULL},
> +    { { GDK_KEY_Control_L, GDK_KEY_Alt_L, GDK_KEY_F9, GDK_KEY_VoidSymbol },
> N_("Ctrl+Alt+F_9"), NULL},
> +    { { GDK_KEY_Control_L, GDK_KEY_Alt_L, GDK_KEY_F10, GDK_KEY_VoidSymbol },
> N_("Ctrl+Alt+F1_0"), NULL},
> +    { { GDK_KEY_Control_L, GDK_KEY_Alt_L, GDK_KEY_F11, GDK_KEY_VoidSymbol },
> N_("Ctrl+Alt+F11"), NULL},
> +    { { GDK_KEY_Control_L, GDK_KEY_Alt_L, GDK_KEY_F12, GDK_KEY_VoidSymbol },
> N_("Ctrl+Alt+F12"), NULL},
> +    { { GDK_KEY_VoidSymbol }, "" , NULL},
> +    { { GDK_KEY_Print, GDK_KEY_VoidSymbol }, "_PrintScreen", NULL},
>  };
>  
>  static guint
> @@ -558,7 +551,7 @@ get_nkeys(const guint *keys)
>  {
>      guint i;
>  
> -    for (i = 0; keys[i] != GDK_VoidSymbol; )
> +    for (i = 0; keys[i] != GDK_KEY_VoidSymbol; )
>          i++;
>  
>      return i;
> @@ -584,7 +577,7 @@ virt_viewer_menu_add_combo(VirtViewerWindow *self, GtkMenu
> *menu,
>  {
>      GtkWidget *item;
>  
> -    if (keys == NULL || keys[0] == GDK_VoidSymbol) {
> +    if (keys == NULL || keys[0] == GDK_KEY_VoidSymbol) {
>          item = gtk_separator_menu_item_new();
>      } else {
>          item = gtk_menu_item_new_with_mnemonic(label);
> @@ -612,17 +605,17 @@ accel_key_to_keys(const GtkAccelKey *key)
>  
>      /* first, send the modifiers */
>      if (key->accel_mods & GDK_SHIFT_MASK) {
> -        val = GDK_Shift_L;
> +        val = GDK_KEY_Shift_L;
>          g_array_append_val(a, val);
>      }
>  
>      if (key->accel_mods & GDK_CONTROL_MASK) {
> -        val = GDK_Control_L;
> +        val = GDK_KEY_Control_L;
>          g_array_append_val(a, val);
>      }
>  
>      if (key->accel_mods & GDK_MOD1_MASK) {
> -        val = GDK_Alt_L;
> +        val = GDK_KEY_Alt_L;
>          g_array_append_val(a, val);
>      }
>  
> @@ -630,7 +623,7 @@ accel_key_to_keys(const GtkAccelKey *key)
>      val = key->accel_key;
>      g_array_append_val(a, val);
>  
> -    val = GDK_VoidSymbol;
> +    val = GDK_KEY_VoidSymbol;
>      g_array_append_val(a, val);
>  
>      return (guint*)g_array_free(a, FALSE);
> @@ -657,7 +650,7 @@ accel_map_item_cb(gpointer data,
>  
>      if (!g_str_has_prefix(accel_path, "<virt-viewer>"))
>          return;
> -    if (accel_key == GDK_VoidSymbol || accel_key == 0)
> +    if (accel_key == GDK_KEY_VoidSymbol || accel_key == 0)
>          return;
>  
>      guint *keys = accel_key_to_keys(&key);
> @@ -1477,11 +1470,7 @@
> virt_viewer_window_get_minimal_dimensions(VirtViewerWindow *self,
>      GtkWidget *top_menu;
>  
>      top_menu =
> GTK_WIDGET(gtk_builder_get_object(virt_viewer_window_get_builder(self), "top
> -menu"));
> -#if !GTK_CHECK_VERSION(3, 0, 0)
> -    gtk_widget_get_child_requisition(top_menu, &req);
> -#else
>      gtk_widget_get_preferred_size(top_menu, &req, NULL);
> -#endif
>      /* minimal dimensions of the window are the maximum of dimensions of the
> top-menu
>       * and minimal dimension of the display
>       */
> diff --git a/virt-viewer.spec.in b/virt-viewer.spec.in
> index e79692b..194c8b2 100644
> --- a/virt-viewer.spec.in
> +++ b/virt-viewer.spec.in
> @@ -5,11 +5,6 @@
>  # touch configure.ac or Makefile.am.
>  %{!?enable_autotools:%define enable_autotools 0}
>  
> -%define with_gtk3 0
> -%if 0%{?fedora} >= 15 || 0%{?rhel} >= 7
> -%define with_gtk3 1
> -%endif
> -
>  %define with_spice 0
>  %if 0%{?fedora} >= 17 || 0%{?rhel} >= 6
>  %define with_spice 1
> @@ -43,24 +38,12 @@ BuildRequires: libtool
>  %endif
>  
>  BuildRequires: glib2-devel >= @GLIB2_REQUIRED@
> -%if %{with_gtk3}
>  BuildRequires: gtk3-devel >= @GTK3_REQUIRED@
> -%else
> -BuildRequires: gtk2-devel >= @GTK2_REQUIRED@
> -%endif
>  BuildRequires: libvirt-devel >= @LIBVIRT_REQUIRED@
>  BuildRequires: libxml2-devel >= @LIBXML2_REQUIRED@
> -%if %{with_gtk3}
>  BuildRequires: gtk-vnc2-devel >= @GTK_VNC2_REQUIRED@
> -%else
> -BuildRequires: gtk-vnc-devel >= @GTK_VNC1_REQUIRED@
> -%endif
>  %if %{with_spice}
> -%if %{with_gtk3}
>  BuildRequires: spice-gtk3-devel >= @SPICE_GTK_REQUIRED@
> -%else
> -BuildRequires: spice-gtk-devel >= @SPICE_GTK_REQUIRED@
> -%endif
>  BuildRequires: spice-protocol >= @SPICE_PROTOCOL_REQUIRED@
>  %endif
>  BuildRequires: /usr/bin/pod2man
> @@ -94,12 +77,6 @@ autoreconf -if
>  %define spice_arg --without-spice-gtk
>  %endif
>  
> -%if %{with_gtk3}
> -%define gtk_arg --with-gtk=3.0
> -%else
> -%define gtk_arg --with-gtk=2.0
> -%endif
> -
>  %if %{with_govirt}
>  %define govirt_arg --with-ovirt
>  %endif




More information about the virt-tools-list mailing list