diff options
author | Dan Nicholson <dbn.lists@gmail.com> | 2012-03-18 18:53:51 -0700 |
---|---|---|
committer | Dan Nicholson <dbn.lists@gmail.com> | 2012-06-06 21:59:26 -0700 |
commit | e764289af5c0c764f10414d2ff32c3dff72ad1fd (patch) | |
tree | 307b8ca0daf518f02692ed820bcee58831618619 | |
parent | c527cff025300224867cb61cb6f46508d6157381 (diff) |
Optionally build against gtk3 and evince3
The current not ideal situation for NPAPI plugins is that only gtk2 is
supported on mozilla browsers and only gtk3 is supported on epiphany.
Thus, a choice needs to be made whether to link in one gtk version or
the other depending on the intended usage.
The viewer code is entirely compatible with gtk3 and evince3, but
GtkPlug needs a little adjustment. However, the plugin immediately
crashes on firefox since it's still running gtk2 and our plugin is in
the same address space. To use gtk3 unconditionally we'll either need to
run the plugin in a separate process like totem or just wait patiently
for gtk3 to be supported by firefox. I choose the latter for now and
default to gtk2 since firefox is by far the more popular browser.
-rw-r--r-- | configure.ac | 37 | ||||
-rw-r--r-- | src/evbp.c | 9 |
2 files changed, 37 insertions, 9 deletions
diff --git a/configure.ac b/configure.ac index 7e310d8..8333a23 100644 --- a/configure.ac +++ b/configure.ac @@ -12,15 +12,40 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) dnl We want C99 features AC_PROG_CC_C99 -dnl Check for dependencies. Mozilla packages are split out because we -dnl only want their headers. -GTK_REQUIRED=2.14.0 +dnl Required versions of dependencies. +GTK2_REQUIRED=2.14.0 +GTK3_REQUIRED=3.0 GLIB_REQUIRED=2.18.0 -EVINCE_API=2.32 +EVINCE2_API=2.32 +EVINCE3_API=3.0 + +dnl Check for NPAPI. Mozilla packages are split out because we only +dnl want their headers from MOZILLA_CFLAGS. mozilla_pkgs="mozilla-plugin nspr" -evince_pkgs="gtk+-2.0 >= $GTK_REQUIRED gio-2.0 >= $GLIB_REQUIRED \ - evince-view-$EVINCE_API evince-document-$EVINCE_API" PKG_CHECK_MODULES([MOZILLA], [$mozilla_pkgs]) + +dnl See if we want gtk2/evince2 or gtk3/evince3. This is important +dnl because mozilla currently only support gtk2 plugins and epiphany +dnl only supports gtk3 plugins. Default to gtk2 for now since firefox is +dnl the more likely browser. +AC_MSG_CHECKING([which GTK+ version to use]) +AC_ARG_ENABLE([gtk3], + [AC_HELP_STRING([--enable-gtk3], + [use GTK+ version 3 (default: no, gtk2)])], + [], + [enable_gtk3=no]) +if test "x$enable_gtk3" = xno; then + gtk=gtk+-2.0 + gtk_required=$GTK2_REQUIRED + evince_api=$EVINCE2_API +else + gtk=gtk+-3.0 + gtk_required=$GTK3_REQUIRED + evince_api=$EVINCE3_API +fi +AC_MSG_RESULT([$gtk]) +evince_pkgs="$gtk >= $gtk_required gio-2.0 >= $GLIB_REQUIRED \ + evince-view-$evince_api evince-document-$evince_api" PKG_CHECK_MODULES([EVINCE], [$evince_pkgs]) GETTEXT_PACKAGE="$PACKAGE" @@ -29,6 +29,9 @@ #include <prtypes.h> #include <glib.h> #include <gtk/gtk.h> +#if GTK_MAJOR_VERSION > 2 +#include <gtk/gtkx.h> +#endif #include <gdk/gdkx.h> #include <evince-document.h> #include <evince-view.h> @@ -165,7 +168,7 @@ static NPError evbp_set_window(NPP instance, NPWindow *window) { evbp_priv_t *priv = instance->pdata; - GdkNativeWindow id; + Window id; GtkWidget *plug; g_debug("%s", __func__); @@ -179,8 +182,8 @@ evbp_set_window(NPP instance, NPWindow *window) priv->window = window; /* Create a plug from the window id we were told about */ - id = (GdkNativeWindow)(unsigned long)window->window; - g_debug("plugging into window id %u", id); + id = (Window)window->window; + g_debug("plugging into window id %lu", (unsigned long)id); plug = gtk_plug_new(id); gtk_container_add(GTK_CONTAINER(plug), priv->viewer); gtk_widget_show_all(plug); |