Skip to content

Commit

Permalink
Initial pass at remove GTK+2
Browse files Browse the repository at this point in the history
Updating the build system and some of the conditional code.
More to come.
  • Loading branch information
codebrainz committed Oct 4, 2020
1 parent 8184f91 commit d065c50
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 127 deletions.
3 changes: 0 additions & 3 deletions HACKING
Original file line number Diff line number Diff line change
Expand Up @@ -791,9 +791,6 @@ Building Plugins
The geany-plugins autotools script automatically detects the
installed system Geany and builds the plugins against that.

Plugins will build with either GTK2 or GTK3, whichever the detected
Geany was built with.

To use plugins with a development version of Geany built with
a different prefix, the plugins will need to be compiled against
that version if the ABI has changed.
Expand Down
8 changes: 4 additions & 4 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ Installation from sources

Requirements
++++++++++++
For compiling Geany yourself, you will need the GTK2 (>= 2.24) or
GTK3 libraries and header files. You will also need its dependency libraries
and header files, such as Pango, Glib and ATK. All these files are
available at https://www.gtk.org.
For compiling Geany yourself, you will need the GTK3 libraries and
header files. You will also need its dependency libraries and header
files, such as Pango, Glib and ATK. All these files are available at
https://www.gtk.org.

Furthermore you need, of course, a C compiler and the Make tool; a C++
compiler is also needed for the required Scintilla library included. The
Expand Down
29 changes: 4 additions & 25 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -71,38 +71,17 @@ AC_CHECK_DECLS([_NSGetEnviron],,,[[#include <crt_externs.h>]])
GEANY_CHECK_REVISION([dnl force debug mode for a VCS working copy
CFLAGS="-g -DGEANY_DEBUG $CFLAGS"])

# GTK version check
AC_ARG_ENABLE([gtk2],
[AS_HELP_STRING([--enable-gtk2],
[compile against deprecated GTK2 [default=no]])],
[enable_gtk2=$enableval],
[enable_gtk2=no])

gtk2_package=gtk+-2.0
gtk2_min_version=2.24
gtk3_package=gtk+-3.0
gtk3_min_version=3.0

AS_IF([test "x$enable_gtk2" = "xyes"],
[gtk_package=$gtk2_package
gtk_min_version=$gtk2_min_version],
[gtk_package=$gtk3_package
gtk_min_version=$gtk3_min_version])

AM_CONDITIONAL([GTK3], [test "x$gtk_package" = "x$gtk3_package"])

# GTK/GLib/GIO checks
gtk_modules="$gtk_package >= $gtk_min_version glib-2.0 >= 2.32"
gtk_modules="gtk+-3.0 >= 3.0 glib-2.0 >= 2.32"
gtk_modules_private="gio-2.0 >= 2.32 gmodule-no-export-2.0"
PKG_CHECK_MODULES([GTK], [$gtk_modules $gtk_modules_private])
AC_SUBST([DEPENDENCIES], [$gtk_modules])
AS_VAR_APPEND([GTK_CFLAGS], [" -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_32"])
dnl Disable all GTK deprecations on 3.x so long as we want to keep 2.x support and only require 3.0.
dnl No need on 2.x as we target the latest version.
AM_COND_IF([GTK3], [AS_VAR_APPEND([GTK_CFLAGS], [" -DGDK_DISABLE_DEPRECATION_WARNINGS"])])
dnl Disable all GTK deprecations
AS_VAR_APPEND([GTK_CFLAGS], [" -DGDK_DISABLE_DEPRECATION_WARNINGS"])
AC_SUBST([GTK_CFLAGS])
AC_SUBST([GTK_LIBS])
GTK_VERSION=`$PKG_CONFIG --modversion $gtk_package`
GTK_VERSION=`$PKG_CONFIG --modversion gtk+-3.0`
AC_SUBST([GTK_VERSION])
GEANY_STATUS_ADD([Using GTK version], [${GTK_VERSION}])
# GTHREAD checks
Expand Down
5 changes: 0 additions & 5 deletions data/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,7 @@ nobase_dist_pkgdata_DATA = \
ui_toolbar.xml \
geany.glade

if GTK3
nobase_dist_pkgdata_DATA += \
geany-3.0.css \
geany-3.20.css \
geany.css
else
nobase_dist_pkgdata_DATA += geany.gtkrc
endif

81 changes: 5 additions & 76 deletions src/gtkcompat.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,86 +18,15 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

/* Compatibility macros to support older GTK+ versions */
/* Compatibility macros to support older GTK+ versions
*
* TODO: This file can be removed once the code is updated to use GTK3 keysyms.
*/

#ifndef GTK_COMPAT_H
#define GTK_COMPAT_H 1

#include <gtk/gtk.h>
#if GTK_CHECK_VERSION(3, 0, 0)
# include <gdk/gdkkeysyms-compat.h>
#endif

G_BEGIN_DECLS


/* GtkComboBoxText */
/* This is actually available in GTK 2.24, but we expose GtkComboBoxText in the
* API so we don't want the type to change for no good reason (although this
* should probably be harmless since it's only a derivated type). However, since
* a plugin needs to be rebuilt and tuned to work with GTK3 we don't mind that
* a type changes between the GTK2 and GTK3 version */
#if ! GTK_CHECK_VERSION(3, 0, 0)
/* undef those not to get warnings about redefinitions under GTK 2.24 */
# undef GTK_COMBO_BOX_TEXT
# undef GTK_COMBO_BOX_TEXT_CLASS
# undef GTK_COMBO_BOX_TEXT_GET_CLASS
# undef GTK_IS_COMBO_BOX_TEXT
# undef GTK_IS_COMBO_BOX_TEXT_CLASS
# undef GTK_TYPE_COMBO_BOX_TEXT

# define GTK_COMBO_BOX_TEXT GTK_COMBO_BOX
# define GTK_COMBO_BOX_TEXT_CLASS GTK_COMBO_BOX_CLASS
# define GTK_COMBO_BOX_TEXT_GET_CLASS GTK_COMBO_BOX_GET_CLASS
# define GTK_IS_COMBO_BOX_TEXT GTK_IS_COMBO_BOX
# define GTK_IS_COMBO_BOX_TEXT_CLASS GTK_IS_COMBO_BOX_CLASS
# define GTK_TYPE_COMBO_BOX_TEXT GTK_TYPE_COMBO_BOX
# define GtkComboBoxText GtkComboBox
# define gtk_combo_box_text_new gtk_combo_box_new_text
# define gtk_combo_box_text_new_with_entry gtk_combo_box_entry_new_text
# define gtk_combo_box_text_append_text gtk_combo_box_append_text
# define gtk_combo_box_text_insert_text gtk_combo_box_insert_text
# define gtk_combo_box_text_prepend_text gtk_combo_box_prepend_text
# define gtk_combo_box_text_remove gtk_combo_box_remove_text
# define gtk_combo_box_text_get_active_text gtk_combo_box_get_active_text
#endif

/* GtkWidget */
#if ! GTK_CHECK_VERSION(3, 0, 0)
# define gtk_widget_get_allocated_height(widget) (((GtkWidget *) (widget))->allocation.height)
# define gtk_widget_get_allocated_width(widget) (((GtkWidget *) (widget))->allocation.width)
#endif


/* Mappings below only prevent some deprecation warnings on GTK3 for things
* that didn't exist on GTK2. That's not future-proof. */
#if GTK_CHECK_VERSION(3, 0, 0)
/* Gtk[VH]Box */
# define compat_gtk_box_new(orientation, homogeneous, spacing) \
((GtkWidget *)g_object_new(GTK_TYPE_BOX, \
"orientation", (orientation), \
"homogeneous", (homogeneous), \
"spacing", (spacing), \
NULL))
# define gtk_vbox_new(homogeneous, spacing) \
compat_gtk_box_new(GTK_ORIENTATION_VERTICAL, (homogeneous), (spacing))
# define gtk_hbox_new(homogeneous, spacing) \
compat_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, (homogeneous), (spacing))
/* Gtk[VH]ButtonBox */
# define gtk_vbutton_box_new() gtk_button_box_new(GTK_ORIENTATION_VERTICAL)
# define gtk_hbutton_box_new() gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL)
/* Gtk[VH]Separator */
# define gtk_vseparator_new() gtk_separator_new(GTK_ORIENTATION_VERTICAL)
# define gtk_hseparator_new() gtk_separator_new(GTK_ORIENTATION_HORIZONTAL)
/* Gtk[VH]Paned */
# define gtk_vpaned_new() gtk_paned_new(GTK_ORIENTATION_VERTICAL)
# define gtk_hpaned_new() gtk_paned_new(GTK_ORIENTATION_HORIZONTAL)
/* Gtk[VH]Scrollbar */
# define gtk_vscrollbar_new(adj) gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL, (adj))
# define gtk_hscrollbar_new(adj) gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL, (adj))
#endif


G_END_DECLS
#include <gdk/gdkkeysyms-compat.h>

#endif /* GTK_COMPAT_H */
11 changes: 4 additions & 7 deletions src/plugindata.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,10 @@ G_BEGIN_DECLS
*/
#define GEANY_API_VERSION 239

/* hack to have a different ABI when built with GTK3 because loading GTK2-linked plugins
* with GTK3-linked Geany leads to crash */
#if GTK_CHECK_VERSION(3, 0, 0)
# define GEANY_ABI_SHIFT 8
#else
# define GEANY_ABI_SHIFT 0
#endif

/* when gtk2 and gtk3 were both supported at the same time this was used
* to prevent loading gtk2 plugins with gtk3 Geany or vice versa. */
#define GEANY_ABI_SHIFT 8
/** The Application Binary Interface (ABI) version, incremented whenever
* existing fields in the plugin data types have to be changed or reordered.
* Changing this forces all plugins to be recompiled before Geany can load them. */
Expand Down
10 changes: 3 additions & 7 deletions src/stash.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,9 @@
#include <stdlib.h> /* only for atoi() */


/* GTK3 removed ComboBoxEntry, but we need a value to differentiate combo box with and
* without entries, and it must not collide with other GTypes */
#ifdef GTK_TYPE_COMBO_BOX_ENTRY
# define TYPE_COMBO_BOX_ENTRY GTK_TYPE_COMBO_BOX_ENTRY
#else /* !GTK_TYPE_COMBO_BOX_ENTRY */
# define TYPE_COMBO_BOX_ENTRY get_combo_box_entry_type()
#define TYPE_COMBO_BOX_ENTRY get_combo_box_entry_type()


static GType get_combo_box_entry_type(void)
{
static volatile gsize type = 0;
Expand All @@ -100,7 +97,6 @@ static GType get_combo_box_entry_type(void)
}
return type;
}
#endif /* !GTK_TYPE_COMBO_BOX_ENTRY */


struct StashPref
Expand Down

0 comments on commit d065c50

Please sign in to comment.