From aea57010adca9f26dd3abef66a3f7a5c169964ec Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sat, 7 May 2011 10:25:44 -0700 Subject: [PATCH] gui: Add wrapper with functions from GTK+ 2.18 and 2.20. Suggested by John Darrington. --- Smake | 1 + configure.ac | 2 + src/ui/gui/automake.mk | 17 +++- src/ui/gui/include/gtk/gtk.in.h | 166 ++++++++++++++++++++++++++++++++ src/ui/gui/psppire-buttonbox.c | 20 ---- 5 files changed, 185 insertions(+), 21 deletions(-) create mode 100644 src/ui/gui/include/gtk/gtk.in.h diff --git a/Smake b/Smake index 6ab0bd4b..83c583a3 100644 --- a/Smake +++ b/Smake @@ -34,6 +34,7 @@ GNULIB_MODULES = \ gettimeofday \ getopt-gnu \ gitlog-to-changelog \ + include_next \ isfinite \ isinf \ isnan \ diff --git a/configure.ac b/configure.ac index 7e66cfa8..d5609410 100644 --- a/configure.ac +++ b/configure.ac @@ -80,6 +80,8 @@ if test "$with_cairo" != no && test "$with_gui" != "no"; then if test "x$GLIB_GENMARSHAL" = x; then PSPP_REQUIRED_PREREQ([glib-genmarshal (or use --without-gui)]) fi + + gl_NEXT_HEADERS([gtk/gtk.h]) fi dnl Checks needed for psql reader diff --git a/src/ui/gui/automake.mk b/src/ui/gui/automake.mk index 8cefb9d9..a426cefd 100644 --- a/src/ui/gui/automake.mk +++ b/src/ui/gui/automake.mk @@ -256,7 +256,6 @@ nodist_src_ui_gui_psppire_SOURCES = \ src/ui/gui/psppire-marshal.c \ src/ui/gui/psppire-marshal.h - yelp-check: @if ! yelp --version > /dev/null 2>&1 ; then \ echo ; \ @@ -289,3 +288,19 @@ endif HAVE_GUI #ensure the installcheck passes even if there is no X server available installcheck-local: DISPLAY=/invalid/port $(MAKE) $(AM_MAKEFLAGS) installcheck-binPROGRAMS + +# wrapper +src_ui_gui_psppire_CPPFLAGS = $(AM_CPPFLAGS) -Isrc/ui/gui/include +BUILT_SOURCES += src/ui/gui/include/gtk/gtk.h +src/ui/gui/include/gtk/gtk.h: src/ui/gui/include/gtk/gtk.in.h + @$(MKDIR_P) src/ui/gui/include/gtk + $(AM_V_GEN)rm -f $@-t $@ && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ + sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ + -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ + -e 's|@''NEXT_GTK_GTK_H''@|$(NEXT_GTK_GTK_H)|g' \ + < $(srcdir)/src/ui/gui/include/gtk/gtk.in.h; \ + } > $@-t && \ + mv $@-t $@ +EXTRA_DIST += src/ui/gui/include/gtk/gtk.in.h diff --git a/src/ui/gui/include/gtk/gtk.in.h b/src/ui/gui/include/gtk/gtk.in.h new file mode 100644 index 00000000..83f0b646 --- /dev/null +++ b/src/ui/gui/include/gtk/gtk.in.h @@ -0,0 +1,166 @@ +/* Wrapper for . + Copyright (C) 2011 Free Software Foundation, Inc. + + 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 3 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, see . */ + +#ifndef PSPP_GTK_GTK_H +#define PSPP_GTK_GTK_H + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +#@INCLUDE_NEXT@ @NEXT_GTK_GTK_H@ + +#if !GTK_CHECK_VERSION(2,20,0) +/** + * gtk_widget_get_realized: + * @widget: a #GtkWidget + * + * Determines whether @widget is realized. + * + * Return value: %TRUE if @widget is realized, %FALSE otherwise + * + * Since: 2.20 + **/ +static inline gboolean +gtk_widget_get_realized (GtkWidget *widget) +{ + g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE); + + return (GTK_WIDGET_FLAGS (widget) & GTK_REALIZED) != 0; +} +#endif /* gtk < 2.20 */ + +#if !GTK_CHECK_VERSION(2,20,0) +/** + * gtk_widget_get_mapped: + * @widget: a #GtkWidget + * + * Whether the widget is mapped. + * + * Return value: %TRUE if the widget is mapped, %FALSE otherwise. + * + * Since: 2.20 + */ +static inline gboolean +gtk_widget_get_mapped (GtkWidget *widget) +{ + g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); + + return (GTK_WIDGET_FLAGS (widget) & GTK_MAPPED) != 0; +} +#endif /* gtk < 2.20 */ + +#if !GTK_CHECK_VERSION(2,18,0) +/** + * gtk_widget_get_visible: + * @widget: a #GtkWidget + * + * Determines whether the widget is visible. Note that this doesn't + * take into account whether the widget's parent is also visible + * or the widget is obscured in any way. + * + * See gtk_widget_set_visible(). + * + * Return value: %TRUE if the widget is visible + * + * Since: 2.18 + **/ +static inline gboolean +gtk_widget_get_visible (GtkWidget *widget) +{ + g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE); + + return (GTK_WIDGET_FLAGS (widget) & GTK_VISIBLE) != 0; +} +#endif /* gtk < 2.18 */ + +#if !GTK_CHECK_VERSION(2,18,0) +/** + * gtk_widget_is_drawable: + * @widget: a #GtkWidget + * + * Determines whether @widget can be drawn to. A widget can be drawn + * to if it is mapped and visible. + * + * Return value: %TRUE if @widget is drawable, %FALSE otherwise + * + * Since: 2.18 + **/ +static inline gboolean +gtk_widget_is_drawable (GtkWidget *widget) +{ + g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE); + + return ((GTK_WIDGET_FLAGS (wid) & GTK_VISIBLE) != 0 && + (GTK_WIDGET_FLAGS (wid) & GTK_MAPPED) != 0); +} +#endif /* gtk < 2.18 */ + +#if !GTK_CHECK_VERSION(2,18,0) +/** + * gtk_widget_has_focus: + * @widget: a #GtkWidget + * + * Determines if the widget has the global input focus. See + * gtk_widget_is_focus() for the difference between having the global + * input focus, and only having the focus within a toplevel. + * + * Return value: %TRUE if the widget has the global input focus. + * + * Since: 2.18 + **/ +static inline gboolean +gtk_widget_has_focus (GtkWidget *widget) +{ + g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE); + + return GTK_WIDGET_HAS_FOCUS (widget); +} +#endif /* gtk < 2.18 */ + +#if !GTK_CHECK_VERSION(2,18,0) +/** + * gtk_widget_set_can_focus: + * @widget: a #GtkWidget + * @can_focus: whether or not @widget can own the input focus. + * + * Specifies whether @widget can own the input focus. See + * gtk_widget_grab_focus() for actually setting the input focus on a + * widget. + * + * Since: 2.18 + **/ +static inline void +gtk_widget_set_can_focus (GtkWidget *widget, + gboolean can_focus) +{ + g_return_if_fail (GTK_IS_WIDGET (widget)); + + if (can_focus != GTK_WIDGET_CAN_FOCUS (widget)) + { + if (can_focus) + GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS); + else + GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_FOCUS); + + gtk_widget_queue_resize (widget); + g_object_notify (G_OBJECT (widget), "can-focus"); + } +} +#endif /* gtk < 2.18 */ + +#endif /* PSPP_GTK_GTK_H */ diff --git a/src/ui/gui/psppire-buttonbox.c b/src/ui/gui/psppire-buttonbox.c index 1c692d42..a6b00689 100644 --- a/src/ui/gui/psppire-buttonbox.c +++ b/src/ui/gui/psppire-buttonbox.c @@ -81,26 +81,6 @@ set_default (PsppireButtonBox *bb) } } -#if !GTK_CHECK_VERSION(2,20,0) -/** - * gtk_widget_get_realized: - * @widget: a #GtkWidget - * - * Determines whether @widget is realized. - * - * Return value: %TRUE if @widget is realized, %FALSE otherwise - * - * Since: 2.20 - **/ -static inline gboolean -gtk_widget_get_realized (GtkWidget *widget) -{ - g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE); - - return (GTK_WIDGET_FLAGS (widget) & GTK_REALIZED) != 0; -} -#endif /* gtk < 2.20 */ - static void psppire_buttonbox_set_property (GObject *object, guint prop_id, -- 2.30.2