[epiphany] application mode: add button to open in default browser to non-app uris
- From: Gustavo Noronha Silva <gns src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] application mode: add button to open in default browser to non-app uris
- Date: Tue, 24 Oct 2017 17:33:16 +0000 (UTC)
commit 0c3e4b26ffcb4d49ba7bbbe186f2ea314df5e449
Author: Gustavo Noronha Silva <gns gnome org>
Date: Sun Oct 8 11:07:26 2017 -0300
application mode: add button to open in default browser to non-app uris
https://bugzilla.gnome.org/show_bug.cgi?id=788845
lib/widgets/ephy-title-widget.c | 4 +++
src/ephy-header-bar.c | 42 +++++++++++++++++++++++++++++++++++++++
src/ephy-window.c | 12 ++++++++++-
src/window-commands.c | 20 ++++++++++++++++++
src/window-commands.h | 3 ++
5 files changed, 80 insertions(+), 1 deletions(-)
---
diff --git a/lib/widgets/ephy-title-widget.c b/lib/widgets/ephy-title-widget.c
index 1b1d4e8..25afc48 100644
--- a/lib/widgets/ephy-title-widget.c
+++ b/lib/widgets/ephy-title-widget.c
@@ -76,6 +76,8 @@ ephy_title_widget_set_address (EphyTitleWidget *widget,
g_assert (iface->set_address);
iface->set_address (widget, address);
+
+ g_object_notify (G_OBJECT (widget), "address");
}
EphySecurityLevel
@@ -103,4 +105,6 @@ ephy_title_widget_set_security_level (EphyTitleWidget *widget,
g_assert (iface->set_security_level);
iface->set_security_level (widget, security_level);
+
+ g_object_notify (G_OBJECT (widget), "security-level");
}
diff --git a/src/ephy-header-bar.c b/src/ephy-header-bar.c
index 894936f..c47086f 100644
--- a/src/ephy-header-bar.c
+++ b/src/ephy-header-bar.c
@@ -34,6 +34,7 @@
#include "ephy-embed-prefs.h"
#include "ephy-embed-utils.h"
#include "ephy-favicon-helpers.h"
+#include "ephy-file-helpers.h"
#include "ephy-flatpak-utils.h"
#include "ephy-gui.h"
#include "ephy-history-service.h"
@@ -75,6 +76,7 @@ struct _EphyHeaderBar {
GtkWidget *downloads_button;
GtkWidget *downloads_popover;
GtkWidget *zoom_level_button;
+ GtkWidget *open_in_browser_revealer;
guint navigation_buttons_menu_timeout;
};
@@ -603,6 +605,26 @@ notebook_show_tabs_changed_cb (GtkNotebook *notebook,
}
static void
+address_changed_cb (EphyTitleWidget *title_widget,
+ GParamSpec *pspec,
+ EphyHeaderBar *header_bar)
+{
+ const char *uri;
+ gboolean is_app_related;
+
+ uri = ephy_title_widget_get_address (title_widget);
+ is_app_related = ephy_embed_shell_uri_looks_related_to_app (ephy_embed_shell_get_default (), uri);
+
+ if (is_app_related) {
+ gtk_revealer_set_reveal_child (GTK_REVEALER (header_bar->open_in_browser_revealer), FALSE);
+ gtk_widget_hide (header_bar->open_in_browser_revealer);
+ } else {
+ gtk_widget_show (header_bar->open_in_browser_revealer);
+ gtk_revealer_set_reveal_child (GTK_REVEALER (header_bar->open_in_browser_revealer), TRUE);
+ }
+}
+
+static void
ephy_header_bar_constructed (GObject *object)
{
EphyHeaderBar *header_bar = EPHY_HEADER_BAR (object);
@@ -751,6 +773,26 @@ ephy_header_bar_constructed (GObject *object)
gtk_menu_button_set_popover (GTK_MENU_BUTTON (button), GTK_WIDGET (ephy_bookmarks_popover_new
(header_bar->window)));
gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), button);
+ /* Open in browser */
+ if (ephy_embed_shell_get_mode (ephy_embed_shell_get_default ()) == EPHY_EMBED_SHELL_MODE_APPLICATION) {
+ header_bar->open_in_browser_revealer = gtk_revealer_new ();
+ gtk_revealer_set_transition_type (GTK_REVEALER (header_bar->open_in_browser_revealer),
GTK_REVEALER_TRANSITION_TYPE_CROSSFADE);
+ gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), header_bar->open_in_browser_revealer);
+
+ button = gtk_button_new ();
+ gtk_button_set_label (GTK_BUTTON (button), _("Open in browser"));
+ gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
+ gtk_widget_set_tooltip_text (button, _("Open the page in your default browser"));
+ gtk_actionable_set_action_name (GTK_ACTIONABLE (button),
+ "toolbar.open-in-browser");
+
+ gtk_container_add (GTK_CONTAINER (header_bar->open_in_browser_revealer), button);
+ gtk_widget_show (button);
+
+ g_signal_connect (header_bar->title_widget, "notify::address",
+ G_CALLBACK (address_changed_cb), header_bar);
+ }
+
/* Downloads */
downloads_manager = ephy_embed_shell_get_downloads_manager (ephy_embed_shell_get_default ());
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 4a9cffc..e97a112 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -122,6 +122,9 @@ const struct {
{ "toolbar.reload", { "<Primary>R", "<shift><Primary>R", "F5", "<Primary>F5", "<shift>F5",
"<shift><Primary>F5", "Refresh", "Reload", NULL } },
{ "toolbar.combined-stop-reload", { NULL } },
+ /* Application mode */
+ { "toolbar.open-in-browser", { NULL } },
+
/* Tabs */
{ "tab.previous", { "<Primary>Page_Up", "<Primary>KP_9", "<shift><Primary>Tab", NULL } },
{ "tab.next", { "<Primary>Page_Down", "<Primary>KP_3", "<Primary>Tab", NULL } },
@@ -831,7 +834,9 @@ static const GActionEntry toolbar_entries [] = {
{ "stop", window_cmd_stop },
{ "reload", window_cmd_reload },
{ "always-stop", window_cmd_stop },
- { "combined-stop-reload", window_cmd_combined_stop_reload, NULL, "false",
ephy_header_bar_change_combined_stop_reload_state }
+ { "combined-stop-reload", window_cmd_combined_stop_reload, NULL, "false",
ephy_header_bar_change_combined_stop_reload_state },
+
+ { "open-in-browser", window_cmd_open_in_browser }
};
static const GActionEntry popup_entries [] = {
@@ -982,6 +987,11 @@ _ephy_window_set_default_actions_sensitive (EphyWindow *window,
"combined-stop-reload");
ephy_action_change_sensitivity_flags (G_SIMPLE_ACTION (action),
flags, set);
+
+ action = g_action_map_lookup_action (G_ACTION_MAP (action_group),
+ "open-in-browser");
+ ephy_action_change_sensitivity_flags (G_SIMPLE_ACTION (action),
+ flags, set);
}
static void
diff --git a/src/window-commands.c b/src/window-commands.c
index 8f05398..378e4e1 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -918,6 +918,26 @@ window_cmd_open (GSimpleAction *action,
gtk_native_dialog_show (GTK_NATIVE_DIALOG (dialog));
}
+void
+window_cmd_open_in_browser (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ EphyWindow *window = user_data;
+ EphyEmbed *embed;
+ EphyWebView *view;
+ const char *uri;
+
+ embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+ g_assert (embed != NULL);
+
+ view = ephy_embed_get_web_view (embed);
+ uri = ephy_web_view_get_address (view);
+
+ ephy_file_open_uri_in_default_browser (uri, GDK_CURRENT_TIME,
+ gtk_window_get_screen (GTK_WINDOW (window)));
+}
+
typedef struct {
EphyWebView *view;
GtkWidget *image;
diff --git a/src/window-commands.h b/src/window-commands.h
index 5d1b75a..41028d9 100644
--- a/src/window-commands.h
+++ b/src/window-commands.h
@@ -83,6 +83,9 @@ void window_cmd_new_tab (GSimpleAction *action,
void window_cmd_open (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
+void window_cmd_open_in_browser (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data);
void window_cmd_save_as (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]