[anjuta] devhelp: Port to webkitgtk2
- From: Carl-Anton Ingmarsson <carlantoni src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] devhelp: Port to webkitgtk2
- Date: Mon, 4 Feb 2013 22:15:53 +0000 (UTC)
commit 5da6255e76f860e186c1854ae07c5bd738b3ca54
Author: Carl-Anton Ingmarsson <ca ingmarsson gmail com>
Date: Thu Jan 24 20:34:47 2013 +0100
devhelp: Port to webkitgtk2
Conditionally build the plugin against the webkitgtk version that libdevhelp is
built against.
configure.ac | 7 ++++
plugins/devhelp/plugin.c | 69 ++++++++++++++++++++++++++++++++++++----------
plugins/devhelp/plugin.h | 7 +++-
3 files changed, 66 insertions(+), 17 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 7280dae..2d98d4c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -198,6 +198,13 @@ else
])
fi
+if test "x$devhelp_enabled" = "xyes"; then
+ case "$PLUGIN_DEVHELP_LIBS" in
+ *webkit2gtk-3.0*)
+ AC_DEFINE([HAVE_WEBKIT2], [1], [Defined if devhelp is built against webkitgtk2])
+ ;;
+ esac
+fi
AM_CONDITIONAL(HAVE_PLUGIN_DEVHELP, [test x$devhelp_enabled = xyes])
dnl Check for Glade3
diff --git a/plugins/devhelp/plugin.c b/plugins/devhelp/plugin.c
index 6df6b50..b3c46da 100644
--- a/plugins/devhelp/plugin.c
+++ b/plugins/devhelp/plugin.c
@@ -34,8 +34,11 @@
#ifndef DISABLE_EMBEDDED_DEVHELP
-#include <devhelp/devhelp.h>
+#ifdef HAVE_WEBKIT2
+#include <webkit2/webkit2.h>
+#else
#include <webkit/webkit.h>
+#endif
#define ONLINE_API_DOCS "http://library.gnome.org/devel"
@@ -84,10 +87,14 @@ devhelp_tree_link_selected_cb (GObject *ignored, DhLink *link,
gchar *uri;
anjuta_shell_present_widget (ANJUTA_PLUGIN (widget)->shell,
- widget->view_sw, NULL);
+ widget->present_widget, NULL);
uri = dh_link_get_uri (link);
+#ifdef HAVE_WEBKIT2
+ webkit_web_view_load_uri (WEBKIT_WEB_VIEW (widget->view), uri);
+#else
webkit_web_view_open (WEBKIT_WEB_VIEW (widget->view), uri);
+#endif
g_free (uri);
anjuta_devhelp_check_history (widget);
@@ -100,10 +107,14 @@ devhelp_search_link_selected_cb (GObject *ignored, DhLink *link,
gchar *uri;
anjuta_shell_present_widget (ANJUTA_PLUGIN (widget)->shell,
- widget->view_sw, NULL);
+ widget->present_widget, NULL);
uri = dh_link_get_uri (link);
+#ifdef HAVE_WEBKIT2
+ webkit_web_view_load_uri (WEBKIT_WEB_VIEW (widget->view), uri);
+#else
webkit_web_view_open (WEBKIT_WEB_VIEW (widget->view), uri);
+#endif
g_free (uri);
anjuta_devhelp_check_history (widget);
@@ -113,7 +124,7 @@ static void
on_go_back_clicked (GtkWidget *widget, AnjutaDevhelp *plugin)
{
anjuta_shell_present_widget (ANJUTA_PLUGIN (plugin)->shell,
- plugin->view_sw, NULL);
+ plugin->present_widget, NULL);
webkit_web_view_go_back (WEBKIT_WEB_VIEW (plugin->view));
@@ -124,7 +135,7 @@ static void
on_go_forward_clicked (GtkWidget *widget, AnjutaDevhelp *plugin)
{
anjuta_shell_present_widget (ANJUTA_PLUGIN (plugin)->shell,
- plugin->view_sw, NULL);
+ plugin->present_widget, NULL);
webkit_web_view_go_forward (WEBKIT_WEB_VIEW (plugin->view));
@@ -135,9 +146,14 @@ static void
on_online_clicked (GtkWidget* widget, AnjutaDevhelp* plugin)
{
anjuta_shell_present_widget (ANJUTA_PLUGIN (plugin)->shell,
- plugin->view_sw, NULL);
- webkit_web_view_open (WEBKIT_WEB_VIEW(plugin->view),
+ plugin->present_widget, NULL);
+#ifdef HAVE_WEBKIT2
+ webkit_web_view_load_uri (WEBKIT_WEB_VIEW (plugin->view),
+ ONLINE_API_DOCS);
+#else
+ webkit_web_view_open (WEBKIT_WEB_VIEW (plugin->view),
ONLINE_API_DOCS);
+#endif
anjuta_devhelp_check_history (plugin);
}
@@ -295,11 +311,23 @@ value_removed_current_editor (AnjutaPlugin *plugin,
}
#ifndef DISABLE_EMBEDDED_DEVHELP
+
+#ifdef HAVE_WEBKIT2
+static void on_load_changed (WebKitWebView* web_view,
+ WebKitLoadEvent load_event, gpointer user_data)
+{
+ AnjutaDevhelp* devhelp = ANJUTA_PLUGIN_DEVHELP(user_data);
+
+ if (load_event == WEBKIT_LOAD_FINISHED)
+ anjuta_devhelp_check_history(devhelp);
+}
+#else
static void on_load_finished (GObject* view, GObject* frame, gpointer user_data)
{
AnjutaDevhelp* devhelp = ANJUTA_PLUGIN_DEVHELP(user_data);
anjuta_devhelp_check_history(devhelp);
}
+#endif
#endif
@@ -449,10 +477,17 @@ devhelp_activate (AnjutaPlugin *plugin)
gtk_widget_show (devhelp->view);
// TODO: Show some good start page
+#ifdef HAVE_WEBKIT2
+ webkit_web_view_load_uri (WEBKIT_WEB_VIEW (devhelp->view), "about:blank");
+ g_signal_connect(G_OBJECT (devhelp->view), "load-changed",
+ G_CALLBACK (on_load_changed), devhelp);
+
+ devhelp->present_widget = devhelp->view;
+#else
webkit_web_view_open (WEBKIT_WEB_VIEW (devhelp->view), "about:blank");
g_signal_connect(G_OBJECT (devhelp->view), "load-finished",
G_CALLBACK (on_load_finished), devhelp);
-
+
devhelp->view_sw = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (devhelp->view_sw),
GTK_POLICY_AUTOMATIC,
@@ -461,16 +496,20 @@ devhelp_activate (AnjutaPlugin *plugin)
gtk_widget_show (devhelp->view_sw);
gtk_container_add (GTK_CONTAINER (devhelp->view_sw), devhelp->view);
- anjuta_shell_add_widget_custom (plugin->shell, devhelp->control_notebook,
- "AnjutaDevhelpIndex", _("API Browser"), ANJUTA_STOCK_DEVHELP_SEARCH,
- devhelp->tab_hbox,
- ANJUTA_SHELL_PLACEMENT_LEFT, NULL);
+ devhelp->present_widget = devhelp->view_sw;
+#endif
+
/* This is the window that show the html help text */
- anjuta_shell_add_widget_custom (plugin->shell, devhelp->view_sw,
+ anjuta_shell_add_widget_custom (plugin->shell, devhelp->present_widget,
"AnjutaDevhelpDisplay", _("API"),
ANJUTA_STOCK_DEVHELP_VIEW, devhelp->custom_label,
ANJUTA_SHELL_PLACEMENT_CENTER, NULL);
-
+
+ anjuta_shell_add_widget_custom (plugin->shell, devhelp->control_notebook,
+ "AnjutaDevhelpIndex", _("API Browser"), ANJUTA_STOCK_DEVHELP_SEARCH,
+ devhelp->tab_hbox,
+ ANJUTA_SHELL_PLACEMENT_LEFT, NULL);
+
#endif /* DISABLE_EMBEDDED_DEVHELP */
/* Add watches */
@@ -498,7 +537,7 @@ devhelp_deactivate (AnjutaPlugin *plugin)
#ifndef DISABLE_EMBEDDED_DEVHELP
/* Remove widgets */
- anjuta_shell_remove_widget(plugin->shell, devhelp->view_sw, NULL);
+ anjuta_shell_remove_widget(plugin->shell, devhelp->present_widget, NULL);
anjuta_shell_remove_widget(plugin->shell, devhelp->control_notebook, NULL);
#endif /* DISABLE_EMBEDDED_DEVHELP */
diff --git a/plugins/devhelp/plugin.h b/plugins/devhelp/plugin.h
index abaa039..1ffb6e1 100644
--- a/plugins/devhelp/plugin.h
+++ b/plugins/devhelp/plugin.h
@@ -48,9 +48,11 @@ struct _AnjutaDevhelp{
#ifndef DISABLE_EMBEDDED_DEVHELP
DhBookManager *book_manager;
-#endif /* DISABLE_EMBEDDED_DEVHELP */
GtkWidget *view;
+#ifndef HAVE_WEBKIT2
GtkWidget *view_sw;
+#endif /* HAVE_WEBKIT2 */
+ GtkWidget *present_widget;
GtkWidget *control_notebook;
GtkWidget *tab_hbox;
GtkWidget *custom_label;
@@ -61,7 +63,8 @@ struct _AnjutaDevhelp{
GtkWidget *online;
GtkWidget *tabber;
-
+#endif /* DISABLE_EMBEDDED_DEVHELP */
+
IAnjutaEditor *editor;
guint editor_watch_id;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]