lists.geany.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
List overview
Plugins-Commits
May 2018
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
plugins-commits@lists.geany.org
1 participants
29 discussions
Start a n
N
ew thread
[geany/geany-plugins] 4cff84: webhelper: Port context menu to WebKitContextMenu
by Chow Loong Jin
30 May '18
30 May '18
Branch: refs/heads/master Author: Chow Loong Jin <hyperair(a)debian.org> Committer: Chow Loong Jin <hyperair(a)debian.org> Date: Tue, 16 Jan 2018 18:11:33 UTC Commit: 4cff84632ca8f314e4438d6df5a88a24204784d4
https://github.com/geany/geany-plugins/commit/4cff84632ca8f314e4438d6df5a88…
Log Message: ----------- webhelper: Port context menu to WebKitContextMenu Modified Paths: -------------- webhelper/src/gwh-browser.c webhelper/src/gwh-browser.h webhelper/src/gwh-plugin.c Modified: webhelper/src/gwh-browser.c 152 lines changed, 89 insertions(+), 63 deletions(-) =================================================================== @@ -27,6 +27,7 @@ #include <string.h> #include <glib.h> #include <glib/gi18n-lib.h> +#include <gio/gio.h> #include <gtk/gtk.h> #include <webkit2/webkit2.h> @@ -597,8 +598,9 @@ on_web_view_progress_notify (GObject *object, static void -on_item_flip_orientation_activate (GtkMenuItem *item, - GwhBrowser *self) +on_item_flip_orientation_activate (GSimpleAction *action, + GVariant *parameter, + GwhBrowser *self) { gtk_orientable_set_orientation (GTK_ORIENTABLE (self), gtk_orientable_get_orientation (GTK_ORIENTABLE (self)) == GTK_ORIENTATION_VERTICAL @@ -607,20 +609,24 @@ on_item_flip_orientation_activate (GtkMenuItem *item, } static void -on_item_zoom_100_activate (GtkMenuItem *item, - GwhBrowser *self) +on_item_zoom_100_activate (WebKitWebView *view) { - webkit_web_view_set_zoom_level (WEBKIT_WEB_VIEW (self->priv->web_view), 1.0); + webkit_web_view_set_zoom_level (view, 1.0); } static void -on_item_full_content_zoom_activate (GtkCheckMenuItem *item, - GwhBrowser *self) +on_item_full_content_zoom_activate (GSimpleAction *action, + GVariant *dummy_parameter, + GwhBrowser *self) { WebKitSettings *settings; + gboolean zoom_text_only; + settings = webkit_web_view_get_settings (WEBKIT_WEB_VIEW (self->priv->web_view)); - webkit_settings_set_zoom_text_only (settings, !gtk_check_menu_item_get_active (item)); + zoom_text_only = !webkit_settings_get_zoom_text_only (settings); + webkit_settings_set_zoom_text_only (settings, zoom_text_only); + g_simple_action_set_state (action, g_variant_new_boolean (!zoom_text_only)); } static void web_view_zoom (WebKitWebView *view, gdouble factor) @@ -639,68 +645,88 @@ static void web_view_zoom_out (WebKitWebView *view) web_view_zoom (view, zoom_out_factor); } -static void -on_web_view_populate_popup (WebKitWebView *view, - GtkMenu *menu, - GwhBrowser *self) +static gboolean +on_web_view_context_menu (WebKitWebView *view, + WebKitContextMenu *context_menu, + GdkEvent *event, + WebKitHitTestResult *hit_test_result, + GwhBrowser *self) { - GtkWidget *item; - GtkWidget *submenu; - - #define ADD_SEPARATOR(menu) \ - item = gtk_separator_menu_item_new (); \ - gtk_widget_show (item); \ - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item) - - ADD_SEPARATOR (menu); - + WebKitContextMenuItem *item; + WebKitContextMenu *submenu; + GAction *action; + GVariant *action_state; + + webkit_context_menu_append (context_menu, + webkit_context_menu_item_new_separator ()); + /* Zoom menu */ - submenu = gtk_menu_new (); - item = gtk_menu_item_new_with_mnemonic (_("_Zoom")); - gtk_widget_show (item); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + submenu = webkit_context_menu_new (); + item = webkit_context_menu_item_new_with_submenu (_("_Zoom"), submenu); + webkit_context_menu_append (context_menu, item); + /* zoom in */ - item = gtk_image_menu_item_new_from_stock (GTK_STOCK_ZOOM_IN, NULL); - g_signal_connect_swapped (item, "activate", + action = g_simple_action_new ("zoom-in", NULL); + g_signal_connect_swapped (action, "activate", G_CALLBACK (web_view_zoom_in), view); - gtk_menu_shell_append (GTK_MENU_SHELL (submenu), item); + item = webkit_context_menu_item_new_from_gaction (action, _("Zoom _In"), + NULL); + webkit_context_menu_append (submenu, item); + /* zoom out */ - item = gtk_image_menu_item_new_from_stock (GTK_STOCK_ZOOM_OUT, NULL); - g_signal_connect_swapped (item, "activate", + action = g_simple_action_new ("zoom-out", NULL); + g_signal_connect_swapped (action, "activate", G_CALLBACK (web_view_zoom_out), view); - gtk_menu_shell_append (GTK_MENU_SHELL (submenu), item); + item = webkit_context_menu_item_new_from_gaction (action, _("Zoom _Out"), + NULL); + webkit_context_menu_append (submenu, item); + /* zoom 1:1 */ - ADD_SEPARATOR (submenu); - item = gtk_image_menu_item_new_from_stock (GTK_STOCK_ZOOM_100, NULL); - g_signal_connect (item, "activate", - G_CALLBACK (on_item_zoom_100_activate), self); - gtk_menu_shell_append (GTK_MENU_SHELL (submenu), item); + webkit_context_menu_append (submenu, + webkit_context_menu_item_new_separator ()); + action = g_simple_action_new ("zoom-reset", NULL); + g_signal_connect_swapped (action, "activate", + G_CALLBACK (on_item_zoom_100_activate), view); + item = webkit_context_menu_item_new_from_gaction (action, _("_Reset Zoom"), + NULL); + webkit_context_menu_append (submenu, item); + /* full content zoom */ - ADD_SEPARATOR (submenu); - item = gtk_check_menu_item_new_with_mnemonic (_("Full-_content zoom")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), - !webkit_settings_get_zoom_text_only (webkit_web_view_get_settings(view))); - g_signal_connect (item, "activate", - G_CALLBACK (on_item_full_content_zoom_activate), self); - gtk_menu_shell_append (GTK_MENU_SHELL (submenu), item); - /* show zoom sumbenu */ - gtk_widget_show_all (submenu); - - ADD_SEPARATOR (menu); - - item = gtk_menu_item_new_with_label (_("Flip panes orientation")); - g_signal_connect (item, "activate", - G_CALLBACK (on_item_flip_orientation_activate), self); - gtk_widget_show (item); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + webkit_context_menu_append (submenu, + webkit_context_menu_item_new_separator ()); + action_state = g_variant_new_boolean ( + webkit_settings_get_zoom_text_only (webkit_web_view_get_settings (view))); + + action = g_simple_action_new_stateful ( + "full-content-zoom", + NULL, + action_state + ); + item = webkit_context_menu_item_new_from_gaction (action, + _("Full-_content zoom"), + NULL); + g_simple_action_set_enabled (action, TRUE); + webkit_context_menu_append (submenu, item); + g_signal_connect (action, "activate", + on_item_full_content_zoom_activate, self); + + /* flip panes orientation */ + webkit_context_menu_append (context_menu, + webkit_context_menu_item_new_separator ()); + action = g_simple_action_new ("flip-panes", NULL); + g_signal_connect_swapped (action, "activate", + G_CALLBACK (on_item_flip_orientation_activate), + view); + item = webkit_context_menu_item_new_from_gaction ( + action, _("_Flip panes orientation"), NULL); + webkit_context_menu_append (context_menu, item); if (! INSPECTOR_VISIBLE (self) || INSPECTOR_DETACHED (self)) { - gtk_widget_set_sensitive (item, FALSE); + g_simple_action_set_enabled (action, FALSE); } - - #undef ADD_SEPARATOR - - g_signal_emit (self, signals[POPULATE_POPUP], 0, menu); + + g_signal_emit (self, signals[POPULATE_POPUP], 0, context_menu); + + return FALSE; } static gboolean @@ -905,7 +931,7 @@ gwh_browser_class_init (GwhBrowserClass *klass) G_STRUCT_OFFSET (GwhBrowserClass, populate_popup), NULL, NULL, g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, GTK_TYPE_MENU); + G_TYPE_NONE, 1, WEBKIT_TYPE_CONTEXT_MENU); g_object_class_override_property (object_class, PROP_ORIENTATION, @@ -1221,8 +1247,8 @@ gwh_browser_init (GwhBrowser *self) G_CALLBACK (on_web_view_load_failed), self); g_signal_connect (G_OBJECT (self->priv->web_view), "notify::favicon", G_CALLBACK (on_web_view_favicon_notify), self); - g_signal_connect (G_OBJECT (self->priv->web_view), "populate-popup", - G_CALLBACK (on_web_view_populate_popup), self); + g_signal_connect (G_OBJECT (self->priv->web_view), "context-menu", + G_CALLBACK (on_web_view_context_menu), self); g_signal_connect (G_OBJECT (self->priv->web_view), "scroll-event", G_CALLBACK (on_web_view_scroll_event), self); g_signal_connect (G_OBJECT (self->priv->web_view), "hovering-over-link", Modified: webhelper/src/gwh-browser.h 4 lines changed, 2 insertions(+), 2 deletions(-) =================================================================== @@ -56,8 +56,8 @@ struct _GwhBrowserClass { GtkVBoxClass parent_class; - void (*populate_popup) (GwhBrowser *browser, - GtkMenu *menu); + void (*populate_popup) (GwhBrowser *browser, + WebKitContextMenu *menu); }; Modified: webhelper/src/gwh-plugin.c 50 lines changed, 31 insertions(+), 19 deletions(-) =================================================================== @@ -240,33 +240,45 @@ on_document_save (GObject *obj, } static void -on_item_auto_reload_toggled (GtkCheckMenuItem *item, - gpointer dummy) +on_item_auto_reload_toggled (GAction *action, + GVariant *parameter, + gpointer dummy) { + gboolean browser_auto_reload; + + g_object_get (G_OBJECT (G_settings), + "browser-auto-reload", &browser_auto_reload, NULL); g_object_set (G_OBJECT (G_settings), "browser-auto-reload", - gtk_check_menu_item_get_active (item), NULL); + !browser_auto_reload, NULL); + g_simple_action_set_state (action, g_variant_new_boolean (browser_auto_reload)); } static void -on_browser_populate_popup (GwhBrowser *browser, - GtkMenu *menu, - gpointer dummy) +on_browser_populate_popup (GwhBrowser *browser, + WebKitContextMenu *menu, + gpointer dummy) { - GtkWidget *item; - gboolean auto_reload = FALSE; - - item = gtk_separator_menu_item_new (); - gtk_widget_show (item); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - + GAction *action; + gboolean auto_reload = FALSE; + GVariant *action_state; + WebKitContextMenuItem *item; + + webkit_context_menu_append (menu, + webkit_context_menu_item_new_separator ()); + g_object_get (G_OBJECT (G_settings), "browser-auto-reload", &auto_reload, NULL); - item = gtk_check_menu_item_new_with_mnemonic (_("Reload upon document saving")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), auto_reload); - gtk_widget_show (item); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - g_signal_connect (item, "toggled", G_CALLBACK (on_item_auto_reload_toggled), - NULL); + action_state = g_variant_new_boolean (auto_reload); + action = g_simple_action_new_stateful ( + "browser-auto-reload", + NULL, + action_state + ); + item = webkit_context_menu_item_new_from_gaction ( + action, _("Reload upon document saving"), NULL); + webkit_context_menu_append (menu, item); + g_signal_connect (action, "activate", + on_item_auto_reload_toggled, NULL); } static void -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany-plugins] ba6142: webhelper: Initialize webkit favicon database
by Chow Loong Jin
30 May '18
30 May '18
Branch: refs/heads/master Author: Chow Loong Jin <hyperair(a)debian.org> Committer: Chow Loong Jin <hyperair(a)debian.org> Date: Sat, 13 Jan 2018 05:18:16 UTC Commit: ba6142e6ad784d182bda184d7bc12420e1f0563c
https://github.com/geany/geany-plugins/commit/ba6142e6ad784d182bda184d7bc12…
Log Message: ----------- webhelper: Initialize webkit favicon database This fixes missing favicons in webhelper. Modified Paths: -------------- webhelper/src/gwh-browser.c Modified: webhelper/src/gwh-browser.c 4 lines changed, 4 insertions(+), 0 deletions(-) =================================================================== @@ -1124,6 +1124,7 @@ gwh_browser_init (GwhBrowser *self) { GtkWidget *scrolled; WebKitSettings *wkws; + WebKitWebContext *wkcontext; gboolean inspector_detached; self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GWH_TYPE_BROWSER, @@ -1134,6 +1135,9 @@ gwh_browser_init (GwhBrowser *self) self->priv->web_view = webkit_web_view_new (); wkws = webkit_web_view_get_settings (WEBKIT_WEB_VIEW (self->priv->web_view)); g_object_set (wkws, "enable-developer-extras", TRUE, NULL); + + wkcontext = webkit_web_view_get_context (WEBKIT_WEB_VIEW (self->priv->web_view)); + webkit_web_context_set_favicon_database_directory (wkcontext, NULL); self->priv->settings = gwh_settings_get_default (); g_object_get (self->priv->settings, -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany-plugins] 1fd266: webhelper: Initial port to webkit2gtk
by Chow Loong Jin
30 May '18
30 May '18
Branch: refs/heads/master Author: Chow Loong Jin <hyperair(a)debian.org> Committer: Chow Loong Jin <hyperair(a)debian.org> Date: Wed, 10 Jan 2018 18:02:27 UTC Commit: 1fd266a97b9fedb0ae463a2cf9a409af27bb0ae6
https://github.com/geany/geany-plugins/commit/1fd266a97b9fedb0ae463a2cf9a40…
Log Message: ----------- webhelper: Initial port to webkit2gtk Modified Paths: -------------- build/webhelper.m4 webhelper/src/gwh-browser.c webhelper/src/gwh-browser.h Modified: build/webhelper.m4 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -19,7 +19,7 @@ AC_DEFUN([GP_CHECK_WEBHELPER], fi fi - GP_CHECK_GTK3([webkit_package=webkitgtk-3.0], + GP_CHECK_GTK3([webkit_package=webkit2gtk-4.0], [webkit_package=webkit-1.0]) GP_CHECK_PLUGIN_DEPS([WebHelper], [WEBHELPER], [$GP_GTK_PACKAGE >= ${GTK_VERSION} Modified: webhelper/src/gwh-browser.c 123 lines changed, 66 insertions(+), 57 deletions(-) =================================================================== @@ -27,7 +27,7 @@ #include <glib.h> #include <glib/gi18n-lib.h> #include <gtk/gtk.h> -#include <webkit/webkit.h> +#include <webkit2/webkit2.h> #include "gwh-utils.h" #include "gwh-settings.h" @@ -136,21 +136,25 @@ static void inspector_set_detached (GwhBrowser *self, static void set_location_icon (GwhBrowser *self, - const gchar *icon_uri) + const cairo_surface_t *icon_surface) { gboolean success = FALSE; - - if (icon_uri) { + + if (icon_surface) { GdkPixbuf *icon; - - icon = gwh_pixbuf_new_from_uri (icon_uri, NULL); - if (icon) { - gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (self->priv->url_entry), - GTK_ENTRY_ICON_PRIMARY, icon); - g_object_unref (icon); - success = TRUE; - } + + icon = gdk_pixbuf_get_from_surface ( + icon_surface, 0, 0, + cairo_image_surface_get_width (icon_surface), + cairo_image_surface_get_height (icon_surface) + ); + + gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (self->priv->url_entry), + GTK_ENTRY_ICON_PRIMARY, icon); + g_object_unref (icon); + success = TRUE; } + if (! success) { if (G_UNLIKELY (self->priv->default_icon == NULL)) { gchar *ctype; @@ -519,20 +523,9 @@ update_load_status (GwhBrowser *self) { gboolean loading = FALSE; WebKitWebView *web_view = WEBKIT_WEB_VIEW (self->priv->web_view); - - switch (webkit_web_view_get_load_status (web_view)) { - case WEBKIT_LOAD_PROVISIONAL: - case WEBKIT_LOAD_COMMITTED: - case WEBKIT_LOAD_FIRST_VISUALLY_NON_EMPTY_LAYOUT: - loading = TRUE; - break; - - case WEBKIT_LOAD_FINISHED: - case WEBKIT_LOAD_FAILED: - loading = FALSE; - break; - } - + + loading = webkit_web_view_is_loading (web_view); + gtk_widget_set_sensitive (GTK_WIDGET (self->priv->item_reload), ! loading); gtk_widget_set_visible (GTK_WIDGET (self->priv->item_reload), ! loading); gtk_widget_set_sensitive (GTK_WIDGET (self->priv->item_cancel), loading); @@ -542,23 +535,23 @@ update_load_status (GwhBrowser *self) } static void -on_web_view_load_status_notify (GObject *object, - GParamSpec *pspec, - GwhBrowser *self) +on_web_view_load_changed (WebKitWebView *object, + WebKitLoadEvent load_event, + GwhBrowser *self) { update_load_status (self); } static gboolean -on_web_view_load_error (WebKitWebView *web_view, - WebKitWebFrame *web_frame, - gchar *uri, - gpointer web_error, - GwhBrowser *self) +on_web_view_load_failed (WebKitWebView *web_view, + WebKitLoadEvent load_event, + gchar *failing_uri, + GError *error, + GwhBrowser *self) { update_load_status (self); - return FALSE; /* we didn't really handled the error, so return %FALSE */ + return FALSE; /* we didn't really handle the error, so return %FALSE */ } static void @@ -575,14 +568,14 @@ on_web_view_uri_notify (GObject *object, } static void -on_web_view_icon_uri_notify (GObject *object, - GParamSpec *pspec, - GwhBrowser *self) +on_web_view_favicon_notify (GObject *object, + GParamSpec *pspec, + GwhBrowser *self) { - const gchar *icon_uri; + const cairo_surface_t *icon_surface; - icon_uri = webkit_web_view_get_icon_uri (WEBKIT_WEB_VIEW (self->priv->web_view)); - set_location_icon (self, icon_uri); + icon_surface = webkit_web_view_get_favicon (WEBKIT_WEB_VIEW (self->priv->web_view)); + set_location_icon (self, icon_surface); } static void @@ -592,7 +585,7 @@ on_web_view_progress_notify (GObject *object, { gdouble value; - value = webkit_web_view_get_progress (WEBKIT_WEB_VIEW (self->priv->web_view)); + value = webkit_web_view_get_estimated_load_progress (WEBKIT_WEB_VIEW (self->priv->web_view)); if (value >= 1.0) { value = 0.0; } @@ -621,8 +614,24 @@ static void on_item_full_content_zoom_activate (GtkCheckMenuItem *item, GwhBrowser *self) { - webkit_web_view_set_full_content_zoom (WEBKIT_WEB_VIEW (self->priv->web_view), - gtk_check_menu_item_get_active (item)); + WebKitSettings *settings; + settings = webkit_web_view_get_settings (WEBKIT_WEB_VIEW (self->priv->web_view)); + + webkit_settings_set_zoom_text_only (settings, !gtk_check_menu_item_get_active (item)); +} + +static void web_view_zoom_in (WebKitWebView *view) +{ + gdouble target_zoom_level = webkit_web_view_get_zoom_level (view) + 0.05; + webkit_web_view_set_zoom_level (view, target_zoom_level); +} + +static void web_view_zoom_out (WebKitWebView *view) +{ + gdouble target_zoom_level = webkit_web_view_get_zoom_level (view) - 0.05; + target_zoom_level = MIN(target_zoom_level, 0.05); + + webkit_web_view_set_zoom_level (view, target_zoom_level); } static void @@ -649,12 +658,12 @@ on_web_view_populate_popup (WebKitWebView *view, /* zoom in */ item = gtk_image_menu_item_new_from_stock (GTK_STOCK_ZOOM_IN, NULL); g_signal_connect_swapped (item, "activate", - G_CALLBACK (webkit_web_view_zoom_in), view); + G_CALLBACK (web_view_zoom_in), view); gtk_menu_shell_append (GTK_MENU_SHELL (submenu), item); /* zoom out */ item = gtk_image_menu_item_new_from_stock (GTK_STOCK_ZOOM_OUT, NULL); g_signal_connect_swapped (item, "activate", - G_CALLBACK (webkit_web_view_zoom_out), view); + G_CALLBACK (web_view_zoom_out), view); gtk_menu_shell_append (GTK_MENU_SHELL (submenu), item); /* zoom 1:1 */ ADD_SEPARATOR (submenu); @@ -666,7 +675,7 @@ on_web_view_populate_popup (WebKitWebView *view, ADD_SEPARATOR (submenu); item = gtk_check_menu_item_new_with_mnemonic (_("Full-_content zoom")); gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), - webkit_web_view_get_full_content_zoom (view)); + !webkit_settings_get_zoom_text_only (webkit_web_view_get_settings(view))); g_signal_connect (item, "activate", G_CALLBACK (on_item_full_content_zoom_activate), self); gtk_menu_shell_append (GTK_MENU_SHELL (submenu), item); @@ -701,11 +710,11 @@ on_web_view_scroll_event (GtkWidget *widget, handled = TRUE; switch (event->direction) { case GDK_SCROLL_DOWN: - webkit_web_view_zoom_out (WEBKIT_WEB_VIEW (self->priv->web_view)); + web_view_zoom_out (WEBKIT_WEB_VIEW (self->priv->web_view)); break; case GDK_SCROLL_UP: - webkit_web_view_zoom_in (WEBKIT_WEB_VIEW (self->priv->web_view)); + web_view_zoom_in (WEBKIT_WEB_VIEW (self->priv->web_view)); break; default: @@ -1114,7 +1123,7 @@ static void gwh_browser_init (GwhBrowser *self) { GtkWidget *scrolled; - WebKitWebSettings *wkws; + WebKitSettings *wkws; gboolean inspector_detached; self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GWH_TYPE_BROWSER, @@ -1183,12 +1192,12 @@ gwh_browser_init (GwhBrowser *self) G_CALLBACK (on_web_view_progress_notify), self); g_signal_connect (G_OBJECT (self->priv->web_view), "notify::uri", G_CALLBACK (on_web_view_uri_notify), self); - g_signal_connect (G_OBJECT (self->priv->web_view), "notify::load-status", - G_CALLBACK (on_web_view_load_status_notify), self); - g_signal_connect (G_OBJECT (self->priv->web_view), "notify::load-error", - G_CALLBACK (on_web_view_load_error), self); - g_signal_connect (G_OBJECT (self->priv->web_view), "notify::icon-uri", - G_CALLBACK (on_web_view_icon_uri_notify), self); + g_signal_connect (G_OBJECT (self->priv->web_view), "load-changed", + G_CALLBACK (on_web_view_load_changed), self); + g_signal_connect (G_OBJECT (self->priv->web_view), "load-failed", + G_CALLBACK (on_web_view_load_failed), self); + g_signal_connect (G_OBJECT (self->priv->web_view), "notify::favicon", + G_CALLBACK (on_web_view_favicon_notify), self); g_signal_connect (G_OBJECT (self->priv->web_view), "populate-popup", G_CALLBACK (on_web_view_populate_popup), self); g_signal_connect (G_OBJECT (self->priv->web_view), "scroll-event", @@ -1251,7 +1260,7 @@ gwh_browser_set_uri (GwhBrowser *self, } g_free (scheme); if (g_strcmp0 (real_uri, gwh_browser_get_uri (self)) != 0) { - webkit_web_view_open (WEBKIT_WEB_VIEW (self->priv->web_view), real_uri); + webkit_web_view_load_uri (WEBKIT_WEB_VIEW (self->priv->web_view), real_uri); g_object_notify (G_OBJECT (self), "uri"); } g_free (real_uri); Modified: webhelper/src/gwh-browser.h 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -22,7 +22,7 @@ #include <glib.h> #include <gtk/gtk.h> -#include <webkit/webkit.h> +#include <webkit2/webkit2.h> G_BEGIN_DECLS -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany-plugins] c5f410: [markdown] Use webkit2gtk3 (webkit2 API)
by Sérgio M. Basto
30 May '18
30 May '18
Branch: refs/heads/master Author: Sérgio M. Basto <sergio(a)serjux.com> Committer: Sérgio M. Basto <sergio(a)serjux.com> Date: Sat, 09 Dec 2017 02:57:45 UTC Commit: c5f410a5040751f8ef5348a55084b60cb09990cb
https://github.com/geany/geany-plugins/commit/c5f410a5040751f8ef5348a55084b…
Log Message: ----------- [markdown] Use webkit2gtk3 (webkit2 API) To build, in Fedora linux, with package webkitgtk4-devel Modified Paths: -------------- build/markdown.m4 markdown/src/viewer.c markdown/src/viewer.h Modified: build/markdown.m4 4 lines changed, 2 insertions(+), 2 deletions(-) =================================================================== @@ -49,8 +49,8 @@ AC_DEFUN([GP_CHECK_MARKDOWN], GTK_VERSION=2.16 WEBKIT_VERSION=1.1.13 - GP_CHECK_GTK3([webkit_package=webkitgtk-3.0], - [webkit_package=webkit-1.0]) + GP_CHECK_GTK3([webkit_package=webkit2gtk-4.0], + [webkit_package=webkit2gtk-4.0]) GP_CHECK_PLUGIN_DEPS([markdown], [MARKDOWN], [$GP_GTK_PACKAGE >= ${GTK_VERSION} Modified: markdown/src/viewer.c 7 lines changed, 3 insertions(+), 4 deletions(-) =================================================================== @@ -22,7 +22,7 @@ #include "config.h" #include <string.h> #include <gtk/gtk.h> -#include <webkit/webkitwebview.h> +#include <webkit2/webkit2.h> #include <geanyplugin.h> #ifndef FULL_PRICE # include <mkdio.h> @@ -300,7 +300,7 @@ static void on_webview_load_status_notify(WebKitWebView *view, GParamSpec *pspec, MarkdownViewer *self) { - WebKitLoadStatus load_status; + WebKitLoadEvent load_status; g_object_get(view, "load-status", &load_status, NULL); @@ -393,8 +393,7 @@ markdown_viewer_update_view(MarkdownViewer *self) G_CALLBACK(on_webview_load_status_notify), self); } - webkit_web_view_load_string(WEBKIT_WEB_VIEW(self), html, "text/html", - self->priv->enc, base_uri); + webkit_web_view_load_html(WEBKIT_WEB_VIEW(self), html, base_uri); g_free(base_uri); g_free(html); Modified: markdown/src/viewer.h 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -23,7 +23,7 @@ #define MARKDOWN_VIEWER_H 1 #include <gtk/gtk.h> -#include <webkit/webkitwebview.h> +#include <webkit2/webkit2.h> G_BEGIN_DECLS -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany-plugins] 1d5665: [webhelper] Use webkit2gtk3 (webkit2 API)
by Sérgio M. Basto
30 May '18
30 May '18
Branch: refs/heads/master Author: Sérgio M. Basto <sergio(a)serjux.com> Committer: Sérgio M. Basto <sergio(a)serjux.com> Date: Sat, 09 Dec 2017 03:00:52 UTC Commit: 1d5665ed777ea8d0a1963a8a6775142218fd16b5
https://github.com/geany/geany-plugins/commit/1d5665ed777ea8d0a1963a8a67751…
Log Message: ----------- [webhelper] Use webkit2gtk3 (webkit2 API) To build, in Fedora linux, with package webkitgtk4-devel Still need rework at least zoom functionalities that was comment out. Modified Paths: -------------- build/webhelper.m4 webhelper/src/gwh-browser.c webhelper/src/gwh-browser.h Modified: build/webhelper.m4 4 lines changed, 2 insertions(+), 2 deletions(-) =================================================================== @@ -19,8 +19,8 @@ AC_DEFUN([GP_CHECK_WEBHELPER], fi fi - GP_CHECK_GTK3([webkit_package=webkitgtk-3.0], - [webkit_package=webkit-1.0]) + GP_CHECK_GTK3([webkit_package=webkit2gtk-4.0], + [webkit_package=webkit2gtk-4.0]) GP_CHECK_PLUGIN_DEPS([WebHelper], [WEBHELPER], [$GP_GTK_PACKAGE >= ${GTK_VERSION} glib-2.0 >= ${GLIB_VERSION} Modified: webhelper/src/gwh-browser.c 74 lines changed, 32 insertions(+), 42 deletions(-) =================================================================== @@ -27,7 +27,7 @@ #include <glib.h> #include <glib/gi18n-lib.h> #include <gtk/gtk.h> -#include <webkit/webkit.h> +#include <webkit2/webkit2.h> #include "gwh-utils.h" #include "gwh-settings.h" @@ -136,14 +136,15 @@ static void inspector_set_detached (GwhBrowser *self, static void set_location_icon (GwhBrowser *self, - const gchar *icon_uri) + cairo_surface_t *favicon) { gboolean success = FALSE; - if (icon_uri) { + if (favicon) { GdkPixbuf *icon; - - icon = gwh_pixbuf_new_from_uri (icon_uri, NULL); + GtkImage *image; + gtk_image_set_from_surface (image, favicon); + icon = gtk_image_get_pixbuf(image); if (icon) { gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (self->priv->url_entry), GTK_ENTRY_ICON_PRIMARY, icon); @@ -520,19 +521,7 @@ update_load_status (GwhBrowser *self) gboolean loading = FALSE; WebKitWebView *web_view = WEBKIT_WEB_VIEW (self->priv->web_view); - switch (webkit_web_view_get_load_status (web_view)) { - case WEBKIT_LOAD_PROVISIONAL: - case WEBKIT_LOAD_COMMITTED: - case WEBKIT_LOAD_FIRST_VISUALLY_NON_EMPTY_LAYOUT: - loading = TRUE; - break; - - case WEBKIT_LOAD_FINISHED: - case WEBKIT_LOAD_FAILED: - loading = FALSE; - break; - } - + loading = webkit_web_view_is_loading(web_view); gtk_widget_set_sensitive (GTK_WIDGET (self->priv->item_reload), ! loading); gtk_widget_set_visible (GTK_WIDGET (self->priv->item_reload), ! loading); gtk_widget_set_sensitive (GTK_WIDGET (self->priv->item_cancel), loading); @@ -549,17 +538,17 @@ on_web_view_load_status_notify (GObject *object, update_load_status (self); } -static gboolean +/*static gboolean on_web_view_load_error (WebKitWebView *web_view, - WebKitWebFrame *web_frame, + WebKitFrame *web_frame, gchar *uri, gpointer web_error, GwhBrowser *self) { update_load_status (self); - return FALSE; /* we didn't really handled the error, so return %FALSE */ -} + return FALSE; we didn't really handled the error, so return %FALSE +} */ static void on_web_view_uri_notify (GObject *object, @@ -579,10 +568,10 @@ on_web_view_icon_uri_notify (GObject *object, GParamSpec *pspec, GwhBrowser *self) { - const gchar *icon_uri; + cairo_surface_t *favicon; - icon_uri = webkit_web_view_get_icon_uri (WEBKIT_WEB_VIEW (self->priv->web_view)); - set_location_icon (self, icon_uri); + favicon = webkit_web_view_get_favicon (WEBKIT_WEB_VIEW (self->priv->web_view)); + set_location_icon (self, favicon); } static void @@ -592,11 +581,12 @@ on_web_view_progress_notify (GObject *object, { gdouble value; - value = webkit_web_view_get_progress (WEBKIT_WEB_VIEW (self->priv->web_view)); +/* value = webkit_web_view_get_progress (WEBKIT_WEB_VIEW (self->priv->web_view)); if (value >= 1.0) { value = 0.0; } gtk_entry_set_progress_fraction (GTK_ENTRY (self->priv->url_entry), value); + */ } @@ -617,13 +607,13 @@ on_item_zoom_100_activate (GtkMenuItem *item, webkit_web_view_set_zoom_level (WEBKIT_WEB_VIEW (self->priv->web_view), 1.0); } -static void +/* static void on_item_full_content_zoom_activate (GtkCheckMenuItem *item, GwhBrowser *self) { webkit_web_view_set_full_content_zoom (WEBKIT_WEB_VIEW (self->priv->web_view), gtk_check_menu_item_get_active (item)); -} +} */ static void on_web_view_populate_popup (WebKitWebView *view, @@ -648,13 +638,13 @@ on_web_view_populate_popup (WebKitWebView *view, gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); /* zoom in */ item = gtk_image_menu_item_new_from_stock (GTK_STOCK_ZOOM_IN, NULL); - g_signal_connect_swapped (item, "activate", - G_CALLBACK (webkit_web_view_zoom_in), view); +// g_signal_connect_swapped (item, "activate", +// G_CALLBACK (webkit_web_view_zoom_in), view); gtk_menu_shell_append (GTK_MENU_SHELL (submenu), item); /* zoom out */ item = gtk_image_menu_item_new_from_stock (GTK_STOCK_ZOOM_OUT, NULL); - g_signal_connect_swapped (item, "activate", - G_CALLBACK (webkit_web_view_zoom_out), view); +// g_signal_connect_swapped (item, "activate", +// G_CALLBACK (webkit_web_view_zoom_out), view); gtk_menu_shell_append (GTK_MENU_SHELL (submenu), item); /* zoom 1:1 */ ADD_SEPARATOR (submenu); @@ -665,10 +655,10 @@ on_web_view_populate_popup (WebKitWebView *view, /* full content zoom */ ADD_SEPARATOR (submenu); item = gtk_check_menu_item_new_with_mnemonic (_("Full-_content zoom")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), - webkit_web_view_get_full_content_zoom (view)); - g_signal_connect (item, "activate", - G_CALLBACK (on_item_full_content_zoom_activate), self); +// gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), +// webkit_web_view_get_full_content_zoom (view)); +// g_signal_connect (item, "activate", +// G_CALLBACK (on_item_full_content_zoom_activate), self); gtk_menu_shell_append (GTK_MENU_SHELL (submenu), item); /* show zoom sumbenu */ gtk_widget_show_all (submenu); @@ -701,11 +691,11 @@ on_web_view_scroll_event (GtkWidget *widget, handled = TRUE; switch (event->direction) { case GDK_SCROLL_DOWN: - webkit_web_view_zoom_out (WEBKIT_WEB_VIEW (self->priv->web_view)); + webkit_web_view_set_zoom_level (WEBKIT_WEB_VIEW (self->priv->web_view), 1.0); break; case GDK_SCROLL_UP: - webkit_web_view_zoom_in (WEBKIT_WEB_VIEW (self->priv->web_view)); + webkit_web_view_set_zoom_level (WEBKIT_WEB_VIEW (self->priv->web_view), 1.0); break; default: @@ -1114,7 +1104,7 @@ static void gwh_browser_init (GwhBrowser *self) { GtkWidget *scrolled; - WebKitWebSettings *wkws; + WebKitSettings *wkws; gboolean inspector_detached; self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GWH_TYPE_BROWSER, @@ -1185,8 +1175,8 @@ gwh_browser_init (GwhBrowser *self) G_CALLBACK (on_web_view_uri_notify), self); g_signal_connect (G_OBJECT (self->priv->web_view), "notify::load-status", G_CALLBACK (on_web_view_load_status_notify), self); - g_signal_connect (G_OBJECT (self->priv->web_view), "notify::load-error", - G_CALLBACK (on_web_view_load_error), self); +// g_signal_connect (G_OBJECT (self->priv->web_view), "notify::load-error", +// G_CALLBACK (on_web_view_load_error), self); g_signal_connect (G_OBJECT (self->priv->web_view), "notify::icon-uri", G_CALLBACK (on_web_view_icon_uri_notify), self); g_signal_connect (G_OBJECT (self->priv->web_view), "populate-popup", @@ -1251,7 +1241,7 @@ gwh_browser_set_uri (GwhBrowser *self, } g_free (scheme); if (g_strcmp0 (real_uri, gwh_browser_get_uri (self)) != 0) { - webkit_web_view_open (WEBKIT_WEB_VIEW (self->priv->web_view), real_uri); + webkit_web_view_load_uri (WEBKIT_WEB_VIEW (self->priv->web_view), real_uri); g_object_notify (G_OBJECT (self), "uri"); } g_free (real_uri); Modified: webhelper/src/gwh-browser.h 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -22,7 +22,7 @@ #include <glib.h> #include <gtk/gtk.h> -#include <webkit/webkit.h> +#include <webkit2/webkit2.h> G_BEGIN_DECLS -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany-plugins] 341cab: Merge pull request #677 from hyperair/webkit2gtk
by Frank Lanitz
30 May '18
30 May '18
Branch: refs/heads/master Author: Frank Lanitz <frank(a)frank.uvena.de> Committer: GitHub <noreply(a)github.com> Date: Wed, 30 May 2018 05:21:02 UTC Commit: 341cab4e13c122b2b74e6f31a43be9adc653f8af
https://github.com/geany/geany-plugins/commit/341cab4e13c122b2b74e6f31a43be…
Log Message: ----------- Merge pull request #677 from hyperair/webkit2gtk Port both webhelper and markdown to webkit2gtk Modified Paths: -------------- build/markdown.m4 build/webhelper.m4 markdown/src/Makefile.am markdown/src/viewer.c markdown/src/viewer.h webhelper/src/Makefile.am webhelper/src/gwh-browser.c webhelper/src/gwh-browser.h webhelper/src/gwh-plugin.c Modified: build/markdown.m4 4 lines changed, 2 insertions(+), 2 deletions(-) =================================================================== @@ -49,13 +49,13 @@ AC_DEFUN([GP_CHECK_MARKDOWN], GTK_VERSION=2.16 WEBKIT_VERSION=1.1.13 - GP_CHECK_GTK3([webkit_package=webkitgtk-3.0], + GP_CHECK_GTK3([webkit_package=webkit2gtk-4.0], [webkit_package=webkit-1.0]) - GP_CHECK_PLUGIN_DEPS([markdown], [MARKDOWN], [$GP_GTK_PACKAGE >= ${GTK_VERSION} $webkit_package >= ${WEBKIT_VERSION} gthread-2.0]) + AM_CONDITIONAL([MARKDOWN_WEBKIT2], [test "$webkit_package" = webkit2gtk-4.0]) GP_COMMIT_PLUGIN_STATUS([Markdown]) Modified: build/webhelper.m4 5 lines changed, 2 insertions(+), 3 deletions(-) =================================================================== @@ -19,14 +19,13 @@ AC_DEFUN([GP_CHECK_WEBHELPER], fi fi - GP_CHECK_GTK3([webkit_package=webkitgtk-3.0], - [webkit_package=webkit-1.0]) + GP_CHECK_PLUGIN_GTK3_ONLY([webhelper]) GP_CHECK_PLUGIN_DEPS([WebHelper], [WEBHELPER], [$GP_GTK_PACKAGE >= ${GTK_VERSION} glib-2.0 >= ${GLIB_VERSION} gio-2.0 >= ${GIO_VERSION} gdk-pixbuf-2.0 >= ${GDK_PIXBUF_VERSION} - $webkit_package >= ${WEBKIT_VERSION} + webkit2gtk-4.0 >= ${WEBKIT_VERSION} gthread-2.0]) Modified: markdown/src/Makefile.am 4 lines changed, 4 insertions(+), 0 deletions(-) =================================================================== @@ -35,4 +35,8 @@ markdown_la_CFLAGS += $(LIBMARKDOWN_CFLAGS) markdown_la_LIBADD += $(LIBMARKDOWN_LIBS) endif +if MARKDOWN_WEBKIT2 +markdown_la_CFLAGS += -DMARKDOWN_WEBKIT2 +endif + include $(top_srcdir)/build/cppcheck.mk Modified: markdown/src/viewer.c 29 lines changed, 28 insertions(+), 1 deletions(-) =================================================================== @@ -22,7 +22,11 @@ #include "config.h" #include <string.h> #include <gtk/gtk.h> -#include <webkit/webkitwebview.h> +#ifdef MARKDOWN_WEBKIT2 +# include <webkit2/webkit2.h> +#else +# include <webkit/webkitwebview.h> +#endif #include <geanyplugin.h> #ifndef FULL_PRICE # include <mkdio.h> @@ -296,6 +300,18 @@ pop_scroll_pos(MarkdownViewer *self) return popped; } +#ifdef MARKDOWN_WEBKIT2 +static void +on_webview_load_changed(MarkdownViewer *self, + WebKitLoadEvent load_event, + WebKitWebView *web_view) +{ + /* When the webkit is done loading, reset the scroll position. */ + if (load_event == WEBKIT_LOAD_FINISHED) { + pop_scroll_pos(self); + } +} +#else static void on_webview_load_status_notify(WebKitWebView *view, GParamSpec *pspec, MarkdownViewer *self) @@ -309,6 +325,7 @@ on_webview_load_status_notify(WebKitWebView *view, GParamSpec *pspec, pop_scroll_pos(self); } } +#endif gchar * markdown_viewer_get_html(MarkdownViewer *self) @@ -388,13 +405,23 @@ markdown_viewer_update_view(MarkdownViewer *self) /* Connect a signal handler (only needed once) to restore the scroll * position once the webview is reloaded. */ if (self->priv->load_handle == 0) { +#ifdef MARKDOWN_WEBKIT2 + self->priv->load_handle = + g_signal_connect_swapped(WEBKIT_WEB_VIEW(self), "load-changed", + G_CALLBACK(on_webview_load_changed), self); +#else self->priv->load_handle = g_signal_connect_swapped(WEBKIT_WEB_VIEW(self), "notify::load-status", G_CALLBACK(on_webview_load_status_notify), self); +#endif } +#ifdef MARKDOWN_WEBKIT2 + webkit_web_view_load_html(WEBKIT_WEB_VIEW(self), html, base_uri); +#else webkit_web_view_load_string(WEBKIT_WEB_VIEW(self), html, "text/html", self->priv->enc, base_uri); +#endif g_free(base_uri); g_free(html); Modified: markdown/src/viewer.h 6 lines changed, 5 insertions(+), 1 deletions(-) =================================================================== @@ -23,7 +23,11 @@ #define MARKDOWN_VIEWER_H 1 #include <gtk/gtk.h> -#include <webkit/webkitwebview.h> +#ifdef MARKDOWN_WEBKIT2 +# include <webkit2/webkit2.h> +#else +# include <webkit/webkitwebview.h> +#endif G_BEGIN_DECLS Modified: webhelper/src/Makefile.am 3 lines changed, 2 insertions(+), 1 deletions(-) =================================================================== @@ -34,7 +34,8 @@ webhelper_la_CPPFLAGS = $(AM_CPPFLAGS) \ webhelper_la_CFLAGS = $(AM_CFLAGS) \ $(WEBHELPER_CFLAGS) webhelper_la_LIBADD = $(COMMONLIBS) \ - $(WEBHELPER_LIBS) + $(WEBHELPER_LIBS) \ + -lm # These are generated in $(srcdir) because they are part of the distribution, # and should anyway only be regenerated if the .tpl changes, which is a Modified: webhelper/src/gwh-browser.c 490 lines changed, 204 insertions(+), 286 deletions(-) =================================================================== @@ -21,13 +21,15 @@ #include "config.h" +#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <glib.h> #include <glib/gi18n-lib.h> +#include <gio/gio.h> #include <gtk/gtk.h> -#include <webkit/webkit.h> +#include <webkit2/webkit2.h> #include "gwh-utils.h" #include "gwh-settings.h" @@ -124,33 +126,35 @@ enum { }; static guint signals[LAST_SIGNAL] = {0}; +static const gdouble zoom_in_factor = 1.2; +static const gdouble zoom_out_factor = 1.0 / 1.2; G_DEFINE_TYPE_WITH_CODE (GwhBrowser, gwh_browser, GTK_TYPE_VBOX, G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL)) -static void inspector_set_detached (GwhBrowser *self, - gboolean detached); - - static void set_location_icon (GwhBrowser *self, - const gchar *icon_uri) + const cairo_surface_t *icon_surface) { gboolean success = FALSE; - - if (icon_uri) { + + if (icon_surface) { GdkPixbuf *icon; - - icon = gwh_pixbuf_new_from_uri (icon_uri, NULL); - if (icon) { - gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (self->priv->url_entry), - GTK_ENTRY_ICON_PRIMARY, icon); - g_object_unref (icon); - success = TRUE; - } + + icon = gdk_pixbuf_get_from_surface ( + icon_surface, 0, 0, + cairo_image_surface_get_width (icon_surface), + cairo_image_surface_get_height (icon_surface) + ); + + gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (self->priv->url_entry), + GTK_ENTRY_ICON_PRIMARY, icon); + g_object_unref (icon); + success = TRUE; } + if (! success) { if (G_UNLIKELY (self->priv->default_icon == NULL)) { gchar *ctype; @@ -243,17 +247,6 @@ on_settings_inspector_window_geometry_notify (GObject *object, g_free (geometry); } -static void -on_settings_inspector_detached_notify (GObject *object, - GParamSpec *pspec, - GwhBrowser *self) -{ - gboolean detached; - - g_object_get (object, pspec->name, &detached, NULL); - inspector_set_detached (self, detached); -} - static void on_settings_wm_windows_skip_taskbar_notify (GObject *object, GParamSpec *pspec, @@ -290,10 +283,10 @@ on_settings_wm_windows_type_notify (GObject *object, /* web inspector events handling */ #define INSPECTOR_DETACHED(self) \ - (gtk_bin_get_child (GTK_BIN ((self)->priv->inspector_window)) != NULL) + (webkit_web_inspector_is_attached ((self)->priv->inspector)) #define INSPECTOR_VISIBLE(self) \ - (gtk_widget_get_visible ((self)->priv->inspector_view)) + (webkit_web_inspector_get_web_view ((self)->priv->inspector) != NULL) static void inspector_set_visible (GwhBrowser *self, @@ -308,117 +301,22 @@ inspector_set_visible (GwhBrowser *self, } } -static void -inspector_hide_window (GwhBrowser *self) -{ - if (gtk_widget_get_visible (self->priv->inspector_window)) { - gtk_window_get_position (GTK_WINDOW (self->priv->inspector_window), - &self->priv->inspector_window_x, - &self->priv->inspector_window_y); - gtk_widget_hide (self->priv->inspector_window); - } -} - -static void -inspector_show_window (GwhBrowser *self) -{ - if (! gtk_widget_get_visible (self->priv->inspector_window)) { - gtk_widget_show (self->priv->inspector_window); - gtk_window_move (GTK_WINDOW (self->priv->inspector_window), - self->priv->inspector_window_x, - self->priv->inspector_window_y); - } -} - -static void -inspector_set_detached (GwhBrowser *self, - gboolean detached) -{ - if (detached != INSPECTOR_DETACHED (self)) { - if (detached) { - gtk_widget_reparent (self->priv->inspector_view, - self->priv->inspector_window); - if (INSPECTOR_VISIBLE (self)) { - inspector_show_window (self); - } - } else { - gtk_widget_reparent (self->priv->inspector_view, self->priv->paned); - inspector_hide_window (self); - } - g_object_set (self->priv->settings, "inspector-detached", detached, NULL); - } -} - -static WebKitWebView * -on_inspector_inspect_web_view (WebKitWebInspector *inspector, - WebKitWebView *view, - GwhBrowser *self) -{ - if (self->priv->inspector_web_view) { - gtk_widget_destroy (self->priv->inspector_web_view); - } - - self->priv->inspector_web_view = webkit_web_view_new (); - gtk_widget_show (self->priv->inspector_web_view); - gtk_container_add (GTK_CONTAINER (self->priv->inspector_view), - self->priv->inspector_web_view); - - return WEBKIT_WEB_VIEW (self->priv->inspector_web_view); -} - -static gboolean -on_inspector_show_window (WebKitWebInspector *inspector, - GwhBrowser *self) -{ - gtk_widget_show (self->priv->inspector_view); - if (INSPECTOR_DETACHED (self)) { - inspector_show_window (self); - } - gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (self->priv->item_inspector), - TRUE); - - return TRUE; -} - static gboolean -on_inspector_close_window (WebKitWebInspector *inspector, - GwhBrowser *self) +on_inspector_closed (WebKitWebInspector *inspector, + GwhBrowser *self) { - gtk_widget_hide (self->priv->inspector_view); - inspector_hide_window (self); gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (self->priv->item_inspector), FALSE); - gtk_widget_grab_focus (gtk_widget_get_toplevel (self->priv->web_view)); - - return TRUE; -} - -static gboolean -on_inspector_detach_window (WebKitWebInspector *inspector, - GwhBrowser *self) -{ - inspector_set_detached (self, TRUE); - - return TRUE; -} - -static gboolean -on_inspector_attach_window (WebKitWebInspector *inspector, - GwhBrowser *self) -{ - inspector_set_detached (self, FALSE); - - return TRUE; + return FALSE; } static gboolean -on_inspector_window_delete_event (GtkWidget *window, - GdkEvent *event, - GwhBrowser *self) +on_inspector_opened (WebKitWebInspector *inspector, + GwhBrowser *self) { - webkit_web_inspector_close (self->priv->inspector); - - return TRUE; + gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (self->priv->item_inspector), + TRUE); + return FALSE; } /* web view events hanlding */ @@ -519,20 +417,9 @@ update_load_status (GwhBrowser *self) { gboolean loading = FALSE; WebKitWebView *web_view = WEBKIT_WEB_VIEW (self->priv->web_view); - - switch (webkit_web_view_get_load_status (web_view)) { - case WEBKIT_LOAD_PROVISIONAL: - case WEBKIT_LOAD_COMMITTED: - case WEBKIT_LOAD_FIRST_VISUALLY_NON_EMPTY_LAYOUT: - loading = TRUE; - break; - - case WEBKIT_LOAD_FINISHED: - case WEBKIT_LOAD_FAILED: - loading = FALSE; - break; - } - + + loading = webkit_web_view_is_loading (web_view); + gtk_widget_set_sensitive (GTK_WIDGET (self->priv->item_reload), ! loading); gtk_widget_set_visible (GTK_WIDGET (self->priv->item_reload), ! loading); gtk_widget_set_sensitive (GTK_WIDGET (self->priv->item_cancel), loading); @@ -542,23 +429,23 @@ update_load_status (GwhBrowser *self) } static void -on_web_view_load_status_notify (GObject *object, - GParamSpec *pspec, - GwhBrowser *self) +on_web_view_load_changed (WebKitWebView *object, + WebKitLoadEvent load_event, + GwhBrowser *self) { update_load_status (self); } static gboolean -on_web_view_load_error (WebKitWebView *web_view, - WebKitWebFrame *web_frame, - gchar *uri, - gpointer web_error, - GwhBrowser *self) +on_web_view_load_failed (WebKitWebView *web_view, + WebKitLoadEvent load_event, + gchar *failing_uri, + GError *error, + GwhBrowser *self) { update_load_status (self); - return FALSE; /* we didn't really handled the error, so return %FALSE */ + return FALSE; /* we didn't really handle the error, so return %FALSE */ } static void @@ -575,14 +462,14 @@ on_web_view_uri_notify (GObject *object, } static void -on_web_view_icon_uri_notify (GObject *object, - GParamSpec *pspec, - GwhBrowser *self) +on_web_view_favicon_notify (GObject *object, + GParamSpec *pspec, + GwhBrowser *self) { - const gchar *icon_uri; + const cairo_surface_t *icon_surface; - icon_uri = webkit_web_view_get_icon_uri (WEBKIT_WEB_VIEW (self->priv->web_view)); - set_location_icon (self, icon_uri); + icon_surface = webkit_web_view_get_favicon (WEBKIT_WEB_VIEW (self->priv->web_view)); + set_location_icon (self, icon_surface); } static void @@ -592,7 +479,7 @@ on_web_view_progress_notify (GObject *object, { gdouble value; - value = webkit_web_view_get_progress (WEBKIT_WEB_VIEW (self->priv->web_view)); + value = webkit_web_view_get_estimated_load_progress (WEBKIT_WEB_VIEW (self->priv->web_view)); if (value >= 1.0) { value = 0.0; } @@ -601,8 +488,9 @@ on_web_view_progress_notify (GObject *object, static void -on_item_flip_orientation_activate (GtkMenuItem *item, - GwhBrowser *self) +on_item_flip_orientation_activate (GSimpleAction *action, + GVariant *parameter, + GwhBrowser *self) { gtk_orientable_set_orientation (GTK_ORIENTABLE (self), gtk_orientable_get_orientation (GTK_ORIENTABLE (self)) == GTK_ORIENTATION_VERTICAL @@ -611,82 +499,124 @@ on_item_flip_orientation_activate (GtkMenuItem *item, } static void -on_item_zoom_100_activate (GtkMenuItem *item, - GwhBrowser *self) +on_item_zoom_100_activate (WebKitWebView *view) { - webkit_web_view_set_zoom_level (WEBKIT_WEB_VIEW (self->priv->web_view), 1.0); + webkit_web_view_set_zoom_level (view, 1.0); } static void -on_item_full_content_zoom_activate (GtkCheckMenuItem *item, - GwhBrowser *self) +on_item_full_content_zoom_activate (GSimpleAction *action, + GVariant *dummy_parameter, + GwhBrowser *self) { - webkit_web_view_set_full_content_zoom (WEBKIT_WEB_VIEW (self->priv->web_view), - gtk_check_menu_item_get_active (item)); + WebKitSettings *settings; + gboolean zoom_text_only; + + settings = webkit_web_view_get_settings (WEBKIT_WEB_VIEW (self->priv->web_view)); + + zoom_text_only = !webkit_settings_get_zoom_text_only (settings); + webkit_settings_set_zoom_text_only (settings, zoom_text_only); + g_simple_action_set_state (action, g_variant_new_boolean (!zoom_text_only)); } -static void -on_web_view_populate_popup (WebKitWebView *view, - GtkMenu *menu, - GwhBrowser *self) +static void web_view_zoom (WebKitWebView *view, gdouble factor) { - GtkWidget *item; - GtkWidget *submenu; - - #define ADD_SEPARATOR(menu) \ - item = gtk_separator_menu_item_new (); \ - gtk_widget_show (item); \ - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item) - - ADD_SEPARATOR (menu); - + gdouble zoom_level = webkit_web_view_get_zoom_level (view); + webkit_web_view_set_zoom_level (view, zoom_level * factor); +} + +static void web_view_zoom_in (WebKitWebView *view) +{ + web_view_zoom (view, zoom_in_factor); +} + +static void web_view_zoom_out (WebKitWebView *view) +{ + web_view_zoom (view, zoom_out_factor); +} + +static gboolean +on_web_view_context_menu (WebKitWebView *view, + WebKitContextMenu *context_menu, + GdkEvent *event, + WebKitHitTestResult *hit_test_result, + GwhBrowser *self) +{ + WebKitContextMenuItem *item; + WebKitContextMenu *submenu; + GAction *action; + GVariant *action_state; + + webkit_context_menu_append (context_menu, + webkit_context_menu_item_new_separator ()); + /* Zoom menu */ - submenu = gtk_menu_new (); - item = gtk_menu_item_new_with_mnemonic (_("_Zoom")); - gtk_widget_show (item); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + submenu = webkit_context_menu_new (); + item = webkit_context_menu_item_new_with_submenu (_("_Zoom"), submenu); + webkit_context_menu_append (context_menu, item); + /* zoom in */ - item = gtk_image_menu_item_new_from_stock (GTK_STOCK_ZOOM_IN, NULL); - g_signal_connect_swapped (item, "activate", - G_CALLBACK (webkit_web_view_zoom_in), view); - gtk_menu_shell_append (GTK_MENU_SHELL (submenu), item); + action = g_simple_action_new ("zoom-in", NULL); + g_signal_connect_swapped (action, "activate", + G_CALLBACK (web_view_zoom_in), view); + item = webkit_context_menu_item_new_from_gaction (action, _("Zoom _In"), + NULL); + webkit_context_menu_append (submenu, item); + /* zoom out */ - item = gtk_image_menu_item_new_from_stock (GTK_STOCK_ZOOM_OUT, NULL); - g_signal_connect_swapped (item, "activate", - G_CALLBACK (webkit_web_view_zoom_out), view); - gtk_menu_shell_append (GTK_MENU_SHELL (submenu), item); + action = g_simple_action_new ("zoom-out", NULL); + g_signal_connect_swapped (action, "activate", + G_CALLBACK (web_view_zoom_out), view); + item = webkit_context_menu_item_new_from_gaction (action, _("Zoom _Out"), + NULL); + webkit_context_menu_append (submenu, item); + /* zoom 1:1 */ - ADD_SEPARATOR (submenu); - item = gtk_image_menu_item_new_from_stock (GTK_STOCK_ZOOM_100, NULL); - g_signal_connect (item, "activate", - G_CALLBACK (on_item_zoom_100_activate), self); - gtk_menu_shell_append (GTK_MENU_SHELL (submenu), item); + webkit_context_menu_append (submenu, + webkit_context_menu_item_new_separator ()); + action = g_simple_action_new ("zoom-reset", NULL); + g_signal_connect_swapped (action, "activate", + G_CALLBACK (on_item_zoom_100_activate), view); + item = webkit_context_menu_item_new_from_gaction (action, _("_Reset Zoom"), + NULL); + webkit_context_menu_append (submenu, item); + /* full content zoom */ - ADD_SEPARATOR (submenu); - item = gtk_check_menu_item_new_with_mnemonic (_("Full-_content zoom")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), - webkit_web_view_get_full_content_zoom (view)); - g_signal_connect (item, "activate", - G_CALLBACK (on_item_full_content_zoom_activate), self); - gtk_menu_shell_append (GTK_MENU_SHELL (submenu), item); - /* show zoom sumbenu */ - gtk_widget_show_all (submenu); - - ADD_SEPARATOR (menu); - - item = gtk_menu_item_new_with_label (_("Flip panes orientation")); - g_signal_connect (item, "activate", - G_CALLBACK (on_item_flip_orientation_activate), self); - gtk_widget_show (item); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + webkit_context_menu_append (submenu, + webkit_context_menu_item_new_separator ()); + action_state = g_variant_new_boolean ( + webkit_settings_get_zoom_text_only (webkit_web_view_get_settings (view))); + + action = g_simple_action_new_stateful ( + "full-content-zoom", + NULL, + action_state + ); + item = webkit_context_menu_item_new_from_gaction (action, + _("Full-_content zoom"), + NULL); + g_simple_action_set_enabled (action, TRUE); + webkit_context_menu_append (submenu, item); + g_signal_connect (action, "activate", + on_item_full_content_zoom_activate, self); + + /* flip panes orientation */ + webkit_context_menu_append (context_menu, + webkit_context_menu_item_new_separator ()); + action = g_simple_action_new ("flip-panes", NULL); + g_signal_connect_swapped (action, "activate", + G_CALLBACK (on_item_flip_orientation_activate), + view); + item = webkit_context_menu_item_new_from_gaction ( + action, _("_Flip panes orientation"), NULL); + webkit_context_menu_append (context_menu, item); if (! INSPECTOR_VISIBLE (self) || INSPECTOR_DETACHED (self)) { - gtk_widget_set_sensitive (item, FALSE); + g_simple_action_set_enabled (action, FALSE); } - - #undef ADD_SEPARATOR - - g_signal_emit (self, signals[POPULATE_POPUP], 0, menu); + + g_signal_emit (self, signals[POPULATE_POPUP], 0, context_menu); + + return FALSE; } static gboolean @@ -696,18 +626,32 @@ on_web_view_scroll_event (GtkWidget *widget, { guint mods = event->state & gtk_accelerator_get_default_mod_mask (); gboolean handled = FALSE; + +#if GTK_CHECK_VERSION(3, 0, 0) + gdouble delta; + gdouble factor; +#endif if (mods == GDK_CONTROL_MASK) { handled = TRUE; switch (event->direction) { case GDK_SCROLL_DOWN: - webkit_web_view_zoom_out (WEBKIT_WEB_VIEW (self->priv->web_view)); + web_view_zoom_out (WEBKIT_WEB_VIEW (self->priv->web_view)); break; case GDK_SCROLL_UP: - webkit_web_view_zoom_in (WEBKIT_WEB_VIEW (self->priv->web_view)); + web_view_zoom_in (WEBKIT_WEB_VIEW (self->priv->web_view)); break; - + +#if GTK_CHECK_VERSION(3, 0, 0) + case GDK_SCROLL_SMOOTH: + delta = event->delta_x + event->delta_y; + factor = pow (delta < 0 ? zoom_in_factor : zoom_out_factor, + fabs (delta)); + web_view_zoom (WEBKIT_WEB_VIEW (self->priv->web_view), factor); + break; +#endif + default: handled = FALSE; } @@ -877,7 +821,7 @@ gwh_browser_class_init (GwhBrowserClass *klass) G_STRUCT_OFFSET (GwhBrowserClass, populate_popup), NULL, NULL, g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, GTK_TYPE_MENU); + G_TYPE_NONE, 1, WEBKIT_TYPE_CONTEXT_MENU); g_object_class_override_property (object_class, PROP_ORIENTATION, @@ -1019,33 +963,6 @@ create_toolbar (GwhBrowser *self) return toolbar; } -static GtkWidget * -create_inspector_window (GwhBrowser *self) -{ - gboolean skips_taskbar; - gboolean window_type; - - g_object_get (self->priv->settings, - "wm-secondary-windows-skip-taskbar", &skips_taskbar, - "wm-secondary-windows-type", &window_type, - NULL); - self->priv->inspector_window_x = self->priv->inspector_window_y = 0; - self->priv->inspector_window = g_object_new (GTK_TYPE_WINDOW, - "type", GTK_WINDOW_TOPLEVEL, - "skip-taskbar-hint", skips_taskbar, - "type-hint", window_type, - "title", _("Web inspector"), - NULL); - g_signal_connect (self->priv->inspector_window, "delete-event", - G_CALLBACK (on_inspector_window_delete_event), self); - g_signal_connect (self->priv->settings, "notify::wm-secondary-windows-skip-taskbar", - G_CALLBACK (on_settings_wm_windows_skip_taskbar_notify), self); - g_signal_connect (self->priv->settings, "notify::wm-secondary-windows-type", - G_CALLBACK (on_settings_wm_windows_type_notify), self); - - return self->priv->inspector_window; -} - static guint get_statusbar_context_id (GtkStatusbar *statusbar) { @@ -1059,18 +976,24 @@ get_statusbar_context_id (GtkStatusbar *statusbar) } static void -on_web_view_hovering_over_link (WebKitWebView *view, - gchar *title, - gchar *uri, - GwhBrowser *self) +on_web_view_mouse_target_changed (WebKitWebView *view, + WebKitHitTestResult *hit_test_result, + guint modifiers, + GwhBrowser *self) { GtkStatusbar *statusbar = GTK_STATUSBAR (self->priv->statusbar); - + const gchar *uri; + if (self->priv->hovered_link) { gtk_statusbar_pop (statusbar, get_statusbar_context_id (statusbar)); g_free (self->priv->hovered_link); self->priv->hovered_link = NULL; } + + if (!webkit_hit_test_result_context_is_link (hit_test_result)) + return; + + uri = webkit_hit_test_result_get_link_uri (hit_test_result); if (uri && *uri) { self->priv->hovered_link = g_strdup (uri); gtk_statusbar_push (statusbar, get_statusbar_context_id (statusbar), @@ -1114,7 +1037,8 @@ static void gwh_browser_init (GwhBrowser *self) { GtkWidget *scrolled; - WebKitWebSettings *wkws; + WebKitSettings *wkws; + WebKitWebContext *wkcontext; gboolean inspector_detached; self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GWH_TYPE_BROWSER, @@ -1125,6 +1049,9 @@ gwh_browser_init (GwhBrowser *self) self->priv->web_view = webkit_web_view_new (); wkws = webkit_web_view_get_settings (WEBKIT_WEB_VIEW (self->priv->web_view)); g_object_set (wkws, "enable-developer-extras", TRUE, NULL); + + wkcontext = webkit_web_view_get_context (WEBKIT_WEB_VIEW (self->priv->web_view)); + webkit_web_context_set_favicon_database_directory (wkcontext, NULL); self->priv->settings = gwh_settings_get_default (); g_object_get (self->priv->settings, @@ -1149,7 +1076,6 @@ gwh_browser_init (GwhBrowser *self) GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); self->priv->inspector_web_view = NULL; - self->priv->inspector_window = create_inspector_window (self); gtk_container_add (GTK_CONTAINER (inspector_detached ? self->priv->inspector_window : self->priv->paned), @@ -1168,33 +1094,27 @@ gwh_browser_init (GwhBrowser *self) G_CALLBACK (on_orientation_notify), self); self->priv->inspector = webkit_web_view_get_inspector (WEBKIT_WEB_VIEW (self->priv->web_view)); - g_signal_connect (self->priv->inspector, "inspect-web-view", - G_CALLBACK (on_inspector_inspect_web_view), self); - g_signal_connect (self->priv->inspector, "show-window", - G_CALLBACK (on_inspector_show_window), self); - g_signal_connect (self->priv->inspector, "close-window", - G_CALLBACK (on_inspector_close_window), self); - g_signal_connect (self->priv->inspector, "detach-window", - G_CALLBACK (on_inspector_detach_window), self); - g_signal_connect (self->priv->inspector, "attach-window", - G_CALLBACK (on_inspector_attach_window), self); + g_signal_connect (self->priv->inspector, "bring-to-front", + G_CALLBACK (on_inspector_opened), self); + g_signal_connect (self->priv->inspector, "closed", + G_CALLBACK (on_inspector_closed), self); g_signal_connect (G_OBJECT (self->priv->web_view), "notify::progress", G_CALLBACK (on_web_view_progress_notify), self); g_signal_connect (G_OBJECT (self->priv->web_view), "notify::uri", G_CALLBACK (on_web_view_uri_notify), self); - g_signal_connect (G_OBJECT (self->priv->web_view), "notify::load-status", - G_CALLBACK (on_web_view_load_status_notify), self); - g_signal_connect (G_OBJECT (self->priv->web_view), "notify::load-error", - G_CALLBACK (on_web_view_load_error), self); - g_signal_connect (G_OBJECT (self->priv->web_view), "notify::icon-uri", - G_CALLBACK (on_web_view_icon_uri_notify), self); - g_signal_connect (G_OBJECT (self->priv->web_view), "populate-popup", - G_CALLBACK (on_web_view_populate_popup), self); + g_signal_connect (G_OBJECT (self->priv->web_view), "load-changed", + G_CALLBACK (on_web_view_load_changed), self); + g_signal_connect (G_OBJECT (self->priv->web_view), "load-failed", + G_CALLBACK (on_web_view_load_failed), self); + g_signal_connect (G_OBJECT (self->priv->web_view), "notify::favicon", + G_CALLBACK (on_web_view_favicon_notify), self); + g_signal_connect (G_OBJECT (self->priv->web_view), "context-menu", + G_CALLBACK (on_web_view_context_menu), self); g_signal_connect (G_OBJECT (self->priv->web_view), "scroll-event", G_CALLBACK (on_web_view_scroll_event), self); - g_signal_connect (G_OBJECT (self->priv->web_view), "hovering-over-link", - G_CALLBACK (on_web_view_hovering_over_link), self); + g_signal_connect (G_OBJECT (self->priv->web_view), "mouse-target-changed", + G_CALLBACK (on_web_view_mouse_target_changed), self); g_signal_connect (G_OBJECT (self->priv->web_view), "leave-notify-event", G_CALLBACK (on_web_view_leave_notify_event), self); g_signal_connect (G_OBJECT (self->priv->web_view), "enter-notify-event", @@ -1215,8 +1135,6 @@ gwh_browser_init (GwhBrowser *self) G_CALLBACK (on_settings_browser_bookmarks_notify), self); g_signal_connect (self->priv->settings, "notify::browser-orientation", G_CALLBACK (on_settings_browser_orientation_notify), self); - g_signal_connect (self->priv->settings, "notify::inspector-detached", - G_CALLBACK (on_settings_inspector_detached_notify), self); g_signal_connect (self->priv->settings, "notify::inspector-window-geometry", G_CALLBACK (on_settings_inspector_window_geometry_notify), self); } @@ -1251,7 +1169,7 @@ gwh_browser_set_uri (GwhBrowser *self, } g_free (scheme); if (g_strcmp0 (real_uri, gwh_browser_get_uri (self)) != 0) { - webkit_web_view_open (WEBKIT_WEB_VIEW (self->priv->web_view), real_uri); + webkit_web_view_load_uri (WEBKIT_WEB_VIEW (self->priv->web_view), real_uri); g_object_notify (G_OBJECT (self), "uri"); } g_free (real_uri); Modified: webhelper/src/gwh-browser.h 6 lines changed, 3 insertions(+), 3 deletions(-) =================================================================== @@ -22,7 +22,7 @@ #include <glib.h> #include <gtk/gtk.h> -#include <webkit/webkit.h> +#include <webkit2/webkit2.h> G_BEGIN_DECLS @@ -56,8 +56,8 @@ struct _GwhBrowserClass { GtkVBoxClass parent_class; - void (*populate_popup) (GwhBrowser *browser, - GtkMenu *menu); + void (*populate_popup) (GwhBrowser *browser, + WebKitContextMenu *menu); }; Modified: webhelper/src/gwh-plugin.c 50 lines changed, 31 insertions(+), 19 deletions(-) =================================================================== @@ -240,33 +240,45 @@ on_document_save (GObject *obj, } static void -on_item_auto_reload_toggled (GtkCheckMenuItem *item, - gpointer dummy) +on_item_auto_reload_toggled (GAction *action, + GVariant *parameter, + gpointer dummy) { + gboolean browser_auto_reload; + + g_object_get (G_OBJECT (G_settings), + "browser-auto-reload", &browser_auto_reload, NULL); g_object_set (G_OBJECT (G_settings), "browser-auto-reload", - gtk_check_menu_item_get_active (item), NULL); + !browser_auto_reload, NULL); + g_simple_action_set_state (action, g_variant_new_boolean (browser_auto_reload)); } static void -on_browser_populate_popup (GwhBrowser *browser, - GtkMenu *menu, - gpointer dummy) +on_browser_populate_popup (GwhBrowser *browser, + WebKitContextMenu *menu, + gpointer dummy) { - GtkWidget *item; - gboolean auto_reload = FALSE; - - item = gtk_separator_menu_item_new (); - gtk_widget_show (item); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - + GAction *action; + gboolean auto_reload = FALSE; + GVariant *action_state; + WebKitContextMenuItem *item; + + webkit_context_menu_append (menu, + webkit_context_menu_item_new_separator ()); + g_object_get (G_OBJECT (G_settings), "browser-auto-reload", &auto_reload, NULL); - item = gtk_check_menu_item_new_with_mnemonic (_("Reload upon document saving")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), auto_reload); - gtk_widget_show (item); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - g_signal_connect (item, "toggled", G_CALLBACK (on_item_auto_reload_toggled), - NULL); + action_state = g_variant_new_boolean (auto_reload); + action = g_simple_action_new_stateful ( + "browser-auto-reload", + NULL, + action_state + ); + item = webkit_context_menu_item_new_from_gaction ( + action, _("Reload upon document saving"), NULL); + webkit_context_menu_append (menu, item); + g_signal_connect (action, "activate", + on_item_auto_reload_toggled, NULL); } static void -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/plugins.geany.org] 3ae608: Add Pagetitle to index.php
by Dominic Hopf
29 May '18
29 May '18
Branch: refs/heads/dmaphy/Issue_12_Add_Pagetitle Author: Dominic Hopf <dmaphy(a)fedoraproject.org> Committer: Dominic Hopf <dmaphy(a)fedoraproject.org> Date: Tue, 29 May 2018 19:51:42 UTC Commit: 3ae608ea490de4411d3cdf83489793a4dfafdd78
https://github.com/geany/plugins.geany.org/commit/3ae608ea490de4411d3cdf834…
Log Message: ----------- Add Pagetitle to index.php Modified Paths: -------------- index.php Modified: index.php 5 lines changed, 4 insertions(+), 1 deletions(-) =================================================================== @@ -16,17 +16,20 @@ if (file_exists(CONTENTPATH . $_GET['site'] . '.html')) { define('CONTENTFILE', CONTENTPATH . $_GET['site'] . '.html'); + define('PAGETITLE', $_GET['site']); } else { define('CONTENTFILE', CONTENTPATH . '404.html'); + define('PAGETITLE', 'Plugin could not be found.'); } } else { define('CONTENTFILE', CONTENTPATH . 'start.html'); + define('PAGETITLE', ''); } print '<?xml version="1.0"?>'; @@ -37,7 +40,7 @@ <html xmlns="
http://www.w3.org/1999/xhtml
" xml:lang="en"> <head> - <title>Plugins for Geany</title> + <title>Plugins for Geany [<?php print PAGETITLE ?>]</title> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <link rel="stylesheet" type="text/css" href="./stylesheets/mainstyle.css" /> </head> -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/plugins.geany.org] 3ae608: Add Pagetitle to index.php
by Dominic Hopf
29 May '18
29 May '18
Branch: refs/heads/master Author: Dominic Hopf <dmaphy(a)fedoraproject.org> Committer: Dominic Hopf <dmaphy(a)fedoraproject.org> Date: Tue, 29 May 2018 19:51:42 UTC Commit: 3ae608ea490de4411d3cdf83489793a4dfafdd78
https://github.com/geany/plugins.geany.org/commit/3ae608ea490de4411d3cdf834…
Log Message: ----------- Add Pagetitle to index.php Modified Paths: -------------- index.php Modified: index.php 5 lines changed, 4 insertions(+), 1 deletions(-) =================================================================== @@ -16,17 +16,20 @@ if (file_exists(CONTENTPATH . $_GET['site'] . '.html')) { define('CONTENTFILE', CONTENTPATH . $_GET['site'] . '.html'); + define('PAGETITLE', $_GET['site']); } else { define('CONTENTFILE', CONTENTPATH . '404.html'); + define('PAGETITLE', 'Plugin could not be found.'); } } else { define('CONTENTFILE', CONTENTPATH . 'start.html'); + define('PAGETITLE', ''); } print '<?xml version="1.0"?>'; @@ -37,7 +40,7 @@ <html xmlns="
http://www.w3.org/1999/xhtml
" xml:lang="en"> <head> - <title>Plugins for Geany</title> + <title>Plugins for Geany [<?php print PAGETITLE ?>]</title> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <link rel="stylesheet" type="text/css" href="./stylesheets/mainstyle.css" /> </head> -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/plugins.geany.org] 100bb1: Dynamically get the version for some gpg commands
by Dominic Hopf
29 May '18
29 May '18
Branch: refs/heads/dmaphy/Issue_12_Add_Pagetitle Author: Dominic Hopf <dmaphy(a)fedoraproject.org> Committer: Dominic Hopf <dmaphy(a)fedoraproject.org> Date: Tue, 29 May 2018 19:27:01 UTC Commit: 100bb17b83c95771534cadd87ead70a5d4c2c25d
https://github.com/geany/plugins.geany.org/commit/100bb17b83c95771534cadd87…
Log Message: ----------- Dynamically get the version for some gpg commands Modified Paths: -------------- content/downloads.html Modified: content/downloads.html 6 lines changed, 3 insertions(+), 3 deletions(-) =================================================================== @@ -136,8 +136,8 @@ <h2>Verifying Signatures</h2> <ul> <li>Import the key via <code>gpg --recv-keys B5688B006F78F01E</code></li> <li>Verify the downloaded archive either with - <code>gpg --verify geany-plugins-1.29.tar.bz2.sig geany-plugins-1.29.tar.bz2</code> or - <code>gpg --verify geany-plugins-1.29.tar.gz.sig geany-plugins-1.29.tar.gz</code> + <code>gpg --verify geany-plugins-<?php print $version ?>.tar.bz2.sig geany-plugins-<?php print $version ?>.tar.bz2</code> or + <code>gpg --verify geany-plugins-<?php print $version ?>.tar.gz.sig geany-plugins-<?php print $version ?>.tar.gz</code> </li> </ul> @@ -149,7 +149,7 @@ <h2>Verifying Signatures</h2> <code> wget
http://download.geany.org/frlan-pubkey.txt
<br /> gpg --import < frlan-pubkey.txt<br /> -gpg --verify geany-plugins-1.29.tar.bz2.sig geany-plugins-1.29.tar.bz2 +gpg --verify geany-plugins-<?php print $version ?>.tar.bz2.sig geany-plugins-<?php print $version ?>.tar.bz2 </code> <h2>Download directly from version control</h2> -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/plugins.geany.org] 100bb1: Dynamically get the version for some gpg commands
by Dominic Hopf
29 May '18
29 May '18
Branch: refs/heads/master Author: Dominic Hopf <dmaphy(a)fedoraproject.org> Committer: Dominic Hopf <dmaphy(a)fedoraproject.org> Date: Tue, 29 May 2018 19:27:01 UTC Commit: 100bb17b83c95771534cadd87ead70a5d4c2c25d
https://github.com/geany/plugins.geany.org/commit/100bb17b83c95771534cadd87…
Log Message: ----------- Dynamically get the version for some gpg commands Modified Paths: -------------- content/downloads.html Modified: content/downloads.html 6 lines changed, 3 insertions(+), 3 deletions(-) =================================================================== @@ -136,8 +136,8 @@ <h2>Verifying Signatures</h2> <ul> <li>Import the key via <code>gpg --recv-keys B5688B006F78F01E</code></li> <li>Verify the downloaded archive either with - <code>gpg --verify geany-plugins-1.29.tar.bz2.sig geany-plugins-1.29.tar.bz2</code> or - <code>gpg --verify geany-plugins-1.29.tar.gz.sig geany-plugins-1.29.tar.gz</code> + <code>gpg --verify geany-plugins-<?php print $version ?>.tar.bz2.sig geany-plugins-<?php print $version ?>.tar.bz2</code> or + <code>gpg --verify geany-plugins-<?php print $version ?>.tar.gz.sig geany-plugins-<?php print $version ?>.tar.gz</code> </li> </ul> @@ -149,7 +149,7 @@ <h2>Verifying Signatures</h2> <code> wget
http://download.geany.org/frlan-pubkey.txt
<br /> gpg --import < frlan-pubkey.txt<br /> -gpg --verify geany-plugins-1.29.tar.bz2.sig geany-plugins-1.29.tar.bz2 +gpg --verify geany-plugins-<?php print $version ?>.tar.bz2.sig geany-plugins-<?php print $version ?>.tar.bz2 </code> <h2>Download directly from version control</h2> -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
← Newer
1
2
3
Older →
Jump to page:
1
2
3
Results per page:
10
25
50
100
200