summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Nicholson <dbn.lists@gmail.com>2013-02-23 10:57:50 -0800
committerDan Nicholson <dbn.lists@gmail.com>2013-02-23 21:55:45 -0800
commit0199c621862e5037129cbe634e2920c90c04a55a (patch)
tree606b2395e067077bfd7d74401997e8f2bf0c0bc4
parentfe4d2d43436d2562b9cebe02d68246aa4449f93c (diff)
plug: Begin custom EvbpPlug class
There are a few bugs in the usage of GtkPlug that cause critical warnings and crashes. Using our own class to override methods might give a chance to workaround these issues.
-rw-r--r--src/Makefile.am1
-rw-r--r--src/evbp-plug.c50
-rw-r--r--src/evbp-plug.h61
-rw-r--r--src/evbp.c3
-rw-r--r--test/previewer.c3
5 files changed, 116 insertions, 2 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 1364eaf..b64b825 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,6 +1,7 @@
libevbp2_viewer_la_CFLAGS = $(E_CFLAGS) $(MOZILLA_CFLAGS) $(EVINCE2_CFLAGS)
libevbp2_viewer_la_LIBADD = $(EVINCE2_LIBS)
libevbp2_viewer_la_SOURCES = \
+ evbp-plug.h evbp-plug.c \
evbp-viewer.h evbp-viewer.c \
evbp-mime.h evbp-mime.c \
ev-page-action.h ev-page-action.c \
diff --git a/src/evbp-plug.c b/src/evbp-plug.c
new file mode 100644
index 0000000..6e74f9a
--- /dev/null
+++ b/src/evbp-plug.c
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2013 Dan Nicholson <dbn.lists@gmail.com>
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+#include <config.h>
+#include "evbp-plug.h"
+#include <gtk/gtk.h>
+#if GTK_MAJOR_VERSION > 2
+#include <gtk/gtkx.h>
+#endif
+#include <gdk/gdkx.h>
+
+G_DEFINE_TYPE(EvbpPlug, evbp_plug, GTK_TYPE_PLUG)
+
+static void
+evbp_plug_class_init(EvbpPlugClass *class)
+{
+}
+
+static void
+evbp_plug_init(EvbpPlug *plug)
+{
+}
+
+GtkWidget *
+evbp_plug_new(Window socket_id)
+{
+ EvbpPlug *plug;
+
+ plug = g_object_new(EVBP_TYPE_PLUG, NULL);
+ gtk_plug_construct_for_display(GTK_PLUG(plug),
+ gdk_display_get_default(),
+ socket_id);
+ return GTK_WIDGET(plug);
+}
diff --git a/src/evbp-plug.h b/src/evbp-plug.h
new file mode 100644
index 0000000..69f78de
--- /dev/null
+++ b/src/evbp-plug.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2013 Dan Nicholson <dbn.lists@gmail.com>
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+#ifndef _EVBP_PLUG_H_
+#define _EVBP_PLUG_H_
+
+#include <glib-object.h>
+#include <gtk/gtk.h>
+#if GTK_MAJOR_VERSION > 2
+#include <gtk/gtkx.h>
+#endif
+#include <gdk/gdkx.h>
+
+G_BEGIN_DECLS
+
+#define EVBP_TYPE_PLUG \
+ (evbp_plug_get_type())
+#define EVBP_PLUG(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), EVBP_TYPE_PLUG, EvbpPlug))
+#define EVBP_PLUG_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), EVBP_TYPE_PLUG, EvbpPlugClass))
+#define EVBP_IS_PLUG(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), EVBP_TYPE_PLUG))
+#define EVBP_IS_PLUG_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), EVBP_TYPE_PLUG))
+#define EVBP_GET_PLUG_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS((obj), EVBP_TYPE_PLUG, EvbpPlugClass))
+
+typedef struct _EvbpPlug EvbpPlug;
+typedef struct _EvbpPlugClass EvbpPlugClass;
+
+struct _EvbpPlug {
+ GtkPlug plug;
+};
+
+struct _EvbpPlugClass {
+ GtkPlugClass parent_class;
+};
+
+GType evbp_plug_get_type(void) G_GNUC_CONST;
+GtkWidget *evbp_plug_new(Window socket_id);
+
+G_END_DECLS
+
+#endif /* _EVBP_PLUG_H_ */
diff --git a/src/evbp.c b/src/evbp.c
index 8971021..5fcee76 100644
--- a/src/evbp.c
+++ b/src/evbp.c
@@ -18,6 +18,7 @@
*/
#include <config.h>
+#include "evbp-plug.h"
#include "evbp-viewer.h"
#include "evbp-mime.h"
@@ -209,7 +210,7 @@ evbp_set_window(NPP instance, NPWindow *window)
Window id = (Window)window->window;
g_debug("plugging into window id %lu", (unsigned long)id);
- priv->plug = gtk_plug_new(id);
+ priv->plug = evbp_plug_new(id);
gtk_widget_set_size_request(priv->plug, window->width,
window->height);
gtk_container_add(GTK_CONTAINER(priv->plug), priv->viewer);
diff --git a/test/previewer.c b/test/previewer.c
index 100f81e..3690357 100644
--- a/test/previewer.c
+++ b/test/previewer.c
@@ -25,6 +25,7 @@
#include <gtk/gtkx.h>
#endif
#include <gdk/gdkx.h>
+#include "evbp-plug.h"
#include "evbp-viewer.h"
enum run_mode {
@@ -171,7 +172,7 @@ main(int argc, char *argv[])
if (mode != MODE_SOCKET) {
/* create a plug to for the socket */
g_debug("Creating plug from window %lu", (unsigned long)sockwin);
- plug = gtk_plug_new(sockwin);
+ plug = evbp_plug_new(sockwin);
viewer = evbp_viewer_new();
gtk_container_add(GTK_CONTAINER(plug), viewer);
gtk_widget_show_all(plug);