[epiphany/wip/gtkaction-to-gaction] Use GAction for fullscreen toggle
- From: Iulian Radu <iulianradu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/wip/gtkaction-to-gaction] Use GAction for fullscreen toggle
- Date: Fri, 1 Jul 2016 20:00:13 +0000 (UTC)
commit ba8f78bc0a38b4a3ff7dec56a2f55932e1f27d2b
Author: Iulian Radu <iulian radu67 gmail com>
Date: Fri Jul 1 17:46:01 2016 +0300
Use GAction for fullscreen toggle
src/ephy-lockdown.c | 6 +++---
src/ephy-window.c | 30 +++++++++++++-----------------
src/window-commands.c | 26 ++++++++++++++++----------
src/window-commands.h | 5 +++--
4 files changed, 35 insertions(+), 32 deletions(-)
---
diff --git a/src/ephy-lockdown.c b/src/ephy-lockdown.c
index 50cefbf..a4a83e4 100644
--- a/src/ephy-lockdown.c
+++ b/src/ephy-lockdown.c
@@ -100,8 +100,6 @@ typedef struct {
static const BindAction window_actions[] = {
{ EPHY_PREFS_LOCKDOWN_ARBITRARY_URL, "GoLocation", "sensitive" },
-
- { EPHY_PREFS_LOCKDOWN_FULLSCREEN, "ViewFullscreen", "sensitive" },
};
static const BindAction app_actions[] = {
@@ -114,7 +112,9 @@ static const BindAction new_window_actions[] = {
{ EPHY_PREFS_LOCKDOWN_SAVE_TO_DISK, "save-as", "enabled" },
- { EPHY_PREFS_LOCKDOWN_PRINTING, "print", "enabled" }
+ { EPHY_PREFS_LOCKDOWN_PRINTING, "print", "enabled" },
+
+ { EPHY_PREFS_LOCKDOWN_FULLSCREEN, "fullscreen", "enabled" }
};
static const BindAction popup_actions[] = {
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 306b40c..59d8325 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -94,10 +94,6 @@ static const GtkActionEntry ephy_menu_entries [] = {
static const GtkToggleActionEntry ephy_menu_toggle_entries [] =
{
- /* View actions. */
-
- { "ViewFullscreen", NULL, N_("_Fullscreen"), "F11", NULL,
- G_CALLBACK (window_cmd_view_fullscreen), FALSE },
{ "ViewPopupWindows", NULL, N_("Popup _Windows"), NULL, NULL,
G_CALLBACK (ephy_window_view_popup_windows_cb), FALSE },
};
@@ -168,9 +164,6 @@ static const struct {
gboolean fromToolbar;
} extra_keybindings [] = {
{ GDK_KEY_Home, GDK_MOD1_MASK, "FileHome", TRUE },
- /* FIXME: these are not in any menu for now, so add them here. */
- { GDK_KEY_F11, 0, "ViewFullscreen", FALSE },
-
/* Go */
{ GDK_KEY_l, GDK_CONTROL_MASK, "GoLocation", FALSE },
{ GDK_KEY_F6, 0, "GoLocation", FALSE },
@@ -209,7 +202,9 @@ const struct {
{ "win.select-all", { "<Primary>A", NULL } },
+ /* Toggle actions */
{ "win.browse-with-caret", { "F7", NULL } },
+ { "win.fullscreen", { "F11", NULL } },
/* Navigation */
{ "toolbar.stop", { "Escape", "Stop", NULL } },
@@ -974,7 +969,9 @@ static const GActionEntry window_entries [] =
{ "select-all", window_cmd_edit_select_all },
- { "browse-with-caret", activate_toggle, NULL, "false", window_cmd_change_browse_with_caret }
+ /* Toggle actions */
+ { "browse-with-caret", activate_toggle, NULL, "false", window_cmd_change_browse_with_caret },
+ { "fullscreen", activate_toggle, NULL, "false", window_cmd_change_fullscreen_state }
};
static const GActionEntry tab_entries [] = {
@@ -2843,8 +2840,8 @@ ephy_window_state_event (GtkWidget *widget,
}
if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN) {
- GtkActionGroup *action_group;
- GtkAction *action;
+ GActionGroup *action_group;
+ GAction *action;
gboolean fullscreen;
fullscreen = event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN;
@@ -2855,19 +2852,18 @@ ephy_window_state_event (GtkWidget *widget,
ephy_window_unfullscreen (window);
}
- action_group = window->action_group;
+ action_group = gtk_widget_get_action_group (GTK_WIDGET (window), "win");
- action = gtk_action_group_get_action (action_group, "ViewFullscreen");
- g_signal_handlers_block_by_func
- (action, G_CALLBACK (window_cmd_view_fullscreen), window);
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), fullscreen);
- g_signal_handlers_unblock_by_func
- (action, G_CALLBACK (window_cmd_view_fullscreen), window);
+ action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "fullscreen");
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE);
+ g_action_change_state (action, g_variant_new_boolean (fullscreen));
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), TRUE);
}
return FALSE;
}
+
static void
ephy_window_finalize (GObject *object)
{
diff --git a/src/window-commands.c b/src/window-commands.c
index fcce56e..cceafe4 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -346,16 +346,6 @@ window_cmd_edit_preferences (GtkAction *action,
}
void
-window_cmd_view_fullscreen (GtkAction *action,
- EphyWindow *window)
-{
- if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
- gtk_window_fullscreen (GTK_WINDOW (window));
- else
- gtk_window_unfullscreen (GTK_WINDOW (window));
-}
-
-void
window_cmd_file_new_tab (GSimpleAction *action,
GVariant *value,
gpointer user_data)
@@ -1730,6 +1720,22 @@ window_cmd_change_browse_with_caret (GSimpleAction *action,
}
void
+window_cmd_change_fullscreen_state (GSimpleAction *action,
+ GVariant *state,
+ gpointer user_data)
+{
+ gboolean active;
+
+ active = g_variant_get_boolean (state);
+ if (active)
+ gtk_window_fullscreen (GTK_WINDOW (user_data));
+ else
+ gtk_window_unfullscreen (GTK_WINDOW (user_data));
+
+ g_simple_action_set_state (action, g_variant_new_boolean (active));
+}
+
+void
window_cmd_tabs_previous (GSimpleAction *action,
GVariant *variant,
gpointer user_data)
diff --git a/src/window-commands.h b/src/window-commands.h
index d2e5da7..53304b0 100644
--- a/src/window-commands.h
+++ b/src/window-commands.h
@@ -45,8 +45,6 @@ void window_cmd_undo_close_tab (GtkAction *action,
EphyWindow *window);
void window_cmd_file_send_to (GtkAction *action,
EphyWindow *window);
-void window_cmd_view_fullscreen (GtkAction *action,
- EphyWindow *window);
void window_cmd_file_new_tab (GSimpleAction *action,
GVariant *value,
gpointer user_data);
@@ -137,6 +135,9 @@ void window_cmd_edit_select_all (GSimpleAction *action,
void window_cmd_change_browse_with_caret (GSimpleAction *action,
GVariant *state,
gpointer user_data);
+void window_cmd_change_fullscreen_state (GSimpleAction *action,
+ GVariant *state,
+ gpointer user_data);
void window_cmd_tabs_previous (GSimpleAction *action,
GVariant *state,
gpointer user_data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]