Commit fb8c806b by Adrien Plazas

Many fixes

parent 555598ce
......@@ -23,6 +23,8 @@
#include <gtk/gtk.h>
#include "ephy-title-widget.h"
#include "ephy-action-bar-end.h"
#include "ephy-action-bar-start.h"
#include "ephy-adaptive-mode.h"
#include "ephy-window.h"
......@@ -34,14 +36,12 @@ G_DECLARE_FINAL_TYPE (EphyHeaderBar, ephy_header_bar, EPHY, HEADER_BAR, GtkHeade
GtkWidget *ephy_header_bar_new (EphyWindow *window);
void ephy_header_bar_change_combined_stop_reload_state (GSimpleAction *action,
GVariant *state,
gpointer user_data);
EphyTitleWidget *ephy_header_bar_get_title_widget (EphyHeaderBar *header_bar);
GtkWidget *ephy_header_bar_get_zoom_level_button (EphyHeaderBar *header_bar);
GtkWidget *ephy_header_bar_get_page_menu_button (EphyHeaderBar *header_bar);
EphyWindow *ephy_header_bar_get_window (EphyHeaderBar *header_bar);
EphyActionBarStart *ephy_header_bar_get_action_bar_start (EphyHeaderBar *header_bar);
EphyActionBarEnd *ephy_header_bar_get_action_bar_end (EphyHeaderBar *header_bar);
void ephy_header_bar_set_adaptive_mode (EphyHeaderBar *header_bar,
EphyAdaptiveMode adaptive_mode);
......
......@@ -711,6 +711,23 @@ enable_edit_actions_sensitivity (EphyWindow *window)
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), TRUE);
}
static void
change_combined_stop_reload_state (GSimpleAction *action,
GVariant *loading,
gpointer user_data)
{
EphyWindow *window = EPHY_WINDOW (user_data);
EphyActionBarStart *header_bar_start = ephy_header_bar_get_action_bar_start (EPHY_HEADER_BAR (window->header_bar));
EphyActionBarStart *action_bar_start = ephy_action_bar_get_action_bar_start (EPHY_ACTION_BAR (window->action_bar));
ephy_action_bar_start_change_combined_stop_reload_state (header_bar_start,
g_variant_get_boolean (loading));
ephy_action_bar_start_change_combined_stop_reload_state (action_bar_start,
g_variant_get_boolean (loading));
g_simple_action_set_state (action, loading);
}
static const GActionEntry window_entries [] =
{
{ "page-menu", window_cmd_page_menu },
......@@ -770,7 +787,7 @@ 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", change_combined_stop_reload_state },
{ "open-in-browser", window_cmd_open_in_browser }
};
......@@ -2940,6 +2957,37 @@ sync_user_input_cb (EphyLocationController *action,
}
static void
update_new_tab_button_visibility (EphyWindow *window)
{
gboolean visible = !gtk_notebook_get_show_tabs (window->notebook);
EphyActionBarEnd *header_bar_end = ephy_header_bar_get_action_bar_end (EPHY_HEADER_BAR (window->header_bar));
EphyActionBarEnd *action_bar_end = ephy_action_bar_get_action_bar_end (EPHY_ACTION_BAR (window->action_bar));
if (visible) {
ephy_action_bar_end_set_show_new_tab_button (header_bar_end, TRUE);
ephy_action_bar_end_set_show_new_tab_button (action_bar_end, TRUE);
} else {
/* Note the animation here doesn't actually work, since we hide the revealer
* right away. That's not ideal, but not much we can do about it, since
* hiding the revealer results in the location entry expanding, and that
* needs to happen immediately or it looks pretty bad, so we can't wait
* until the animation completes. Using the revealer is still worthwhile
* because the new tab button reveal animation is more important.
*/
ephy_action_bar_end_set_show_new_tab_button (header_bar_end, FALSE);
ephy_action_bar_end_set_show_new_tab_button (action_bar_end, FALSE);
}
}
static void
notebook_show_tabs_changed_cb (GtkNotebook *notebook,
GParamSpec *pspec,
EphyWindow *window)
{
update_new_tab_button_visibility (window);
}
static void
title_widget_lock_clicked_cb (EphyTitleWidget *title_widget,
GdkRectangle *lock_position,
gpointer user_data)
......@@ -2967,12 +3015,41 @@ title_widget_lock_clicked_cb (EphyTitleWidget *title_widget,
gtk_popover_popup (GTK_POPOVER (security_popover));
}
static void
address_changed_cb (EphyTitleWidget *title_widget,
GParamSpec *pspec,
EphyActionBarEnd *action_bar_end)
{
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);
ephy_action_bar_end_set_show_open_in_browser_button (action_bar_end, is_app_related);
}
static void
setup_open_in_browser_revealer (EphyTitleWidget *title_widget,
EphyActionBarEnd *action_bar_end)
{
/* Open in browser */
if (ephy_embed_shell_get_mode (ephy_embed_shell_get_default ()) == EPHY_EMBED_SHELL_MODE_APPLICATION) {
g_signal_connect (title_widget, "notify::address",
G_CALLBACK (address_changed_cb), action_bar_end);
}
else
/* FIXME: Somehow the widget is visible and must be hidden here. */
ephy_action_bar_end_set_show_open_in_browser_button (action_bar_end, FALSE);
}
static GtkWidget *
setup_header_bar (EphyWindow *window)
{
GtkWidget *header_bar;
EphyEmbedShellMode app_mode;
EphyTitleWidget *title_widget;
EphyActionBarEnd *action_bar_end;
header_bar = ephy_header_bar_new (window);
gtk_window_set_titlebar (GTK_WINDOW (window), header_bar);
......@@ -2986,6 +3063,9 @@ setup_header_bar (EphyWindow *window)
g_signal_connect (title_widget, "lock-clicked",
G_CALLBACK (title_widget_lock_clicked_cb), window);
action_bar_end = ephy_header_bar_get_action_bar_end (EPHY_HEADER_BAR (header_bar));
setup_open_in_browser_revealer (title_widget, action_bar_end);
return header_bar;
}
......@@ -3012,11 +3092,19 @@ static GtkWidget *
setup_action_bar (EphyWindow *window)
{
GtkWidget *action_bar;
EphyHeaderBar *header_bar;
EphyTitleWidget *title_widget;
EphyActionBarEnd *action_bar_end;
action_bar = (GtkWidget *) ephy_action_bar_new ();
gtk_revealer_set_transition_type (GTK_REVEALER (action_bar), GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP);
gtk_widget_show (action_bar);
header_bar = EPHY_HEADER_BAR (ephy_window_get_header_bar (window));
title_widget = ephy_header_bar_get_title_widget (header_bar);
action_bar_end = ephy_action_bar_get_action_bar_end (EPHY_ACTION_BAR (action_bar));
setup_open_in_browser_revealer (title_widget, action_bar_end);
return action_bar;
}
......@@ -3123,6 +3211,8 @@ ephy_window_constructed (GObject *object)
setup_tab_accels (window);
window->notebook = setup_notebook (window);
g_signal_connect_object (window->notebook, "notify::show-tabs",
G_CALLBACK (notebook_show_tabs_changed_cb), window, 0);
/* Setup the toolbar. */
window->header_bar = setup_header_bar (window);
......@@ -3197,6 +3287,8 @@ ephy_window_constructed (GObject *object)
SENS_FLAG_CHROME, TRUE);
}
update_new_tab_button_visibility (window);
ephy_window_set_chrome (window, chrome);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment