[virt-tools-list] [PATCH 1/4] Drop support to gtk2
Eduardo Lima (Etrunko)
etrunko at redhat.com
Fri Nov 27 19:23:58 UTC 2015
From: Fabiano Fidêncio <fidencio at redhat.com>
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.
---
configure.ac | 39 +++----------------
src/view/autoDrawer.c | 10 -----
src/view/ovBox.c | 45 ----------------------
src/virt-gtk-compat.h | 12 ------
src/virt-viewer-display.c | 96 -----------------------------------------------
src/virt-viewer-window.c | 10 -----
virt-viewer.spec.in | 23 ------------
7 files changed, 5 insertions(+), 230 deletions(-)
diff --git a/configure.ac b/configure.ac
index cf75f0e..54d39c1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -15,9 +15,7 @@ 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"
SPICE_GTK_REQUIRED="0.29.35"
SPICE_PROTOCOL_REQUIRED="0.12.7"
@@ -26,9 +24,7 @@ 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([SPICE_GTK_REQUIRED])
AC_SUBST([SPICE_PROTOCOL_REQUIRED])
@@ -121,36 +117,15 @@ 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
+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
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)
@@ -275,10 +250,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/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
index 110c17a..ea31bda 100644
--- a/src/virt-gtk-compat.h
+++ b/src/virt-gtk-compat.h
@@ -29,11 +29,6 @@
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
@@ -57,13 +52,6 @@ G_BEGIN_DECLS
#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
diff --git a/src/virt-viewer-display.c b/src/virt-viewer-display.c
index d8b3312..d7ef3c3 100644
--- a/src/virt-viewer-display.c
+++ b/src/virt-viewer-display.c
@@ -36,10 +36,6 @@
struct _VirtViewerDisplayPrivate
{
-#if !GTK_CHECK_VERSION(3, 0, 0)
- gboolean dirty;
- gboolean size_request_once;
-#endif
guint desktopWidth;
guint desktopHeight;
guint zoom_level;
@@ -51,17 +47,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,
@@ -100,12 +91,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;
@@ -278,10 +265,6 @@ virt_viewer_display_init(VirtViewerDisplay *display)
display->priv->desktopHeight = 100;
display->priv->zoom_level = NORMAL_ZOOM_LEVEL;
display->priv->zoom = TRUE;
-#if !GTK_CHECK_VERSION(3, 0, 0)
- display->priv->dirty = TRUE;
- display->priv->size_request_once = FALSE;
-#endif
}
GtkWidget*
@@ -383,75 +366,10 @@ virt_viewer_display_grab_focus(GtkWidget *widget)
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 (priv->zoom) {
- 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;
- requisition->height = MIN_DISPLAY_HEIGHT;
- }
-
- 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_width(GtkWidget *widget,
int *minwidth,
int *defwidth)
@@ -488,8 +406,6 @@ static void virt_viewer_display_get_preferred_height(GtkWidget *widget,
*defheight = priv->desktopHeight + 2 * border_height;
}
}
-#endif
-
static void
virt_viewer_display_size_allocate(GtkWidget *widget,
@@ -510,11 +426,7 @@ virt_viewer_display_size_allocate(GtkWidget *widget,
if (priv->desktopWidth == 0 ||
priv->desktopHeight == 0)
-#if !GTK_CHECK_VERSION(3, 0, 0)
- goto end;
-#else
return;
-#endif
desktopAspect = (double)priv->desktopWidth / (double)priv->desktopHeight;
@@ -539,11 +451,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(VIRT_VIEWER_DISPLAY(widget));
-#endif
}
@@ -581,9 +488,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-window.c b/src/virt-viewer-window.c
index a1b9940..3a958f0 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -343,9 +343,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 +406,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
@@ -1477,11 +1471,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 dfc819c..a68bf71 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
--
2.5.0
More information about the virt-tools-list
mailing list