GNOME Bugzilla – Bug 703648
Only 1 tab/window setting
Last modified: 2018-08-03 19:58:54 UTC
In some use cases of kiosk mode, the users will only have 1 tab/window full-screen. Everything will be opened in the same view. For these situations we should add a new setting as part of the lockdown settings that allow to set this behavior.
Created attachment 250509 [details] [review] Introduced support for only 1 tab/window behaviour
Review of attachment 250509 [details] [review]: LGTM, but we also need to disable new window commands like (Ctrl+N). You can do it with the following code: diff --git a/src/ephy-lockdown.c b/src/ephy-lockdown.c index 548f117..f7994ac 100644 --- a/src/ephy-lockdown.c +++ b/src/ephy-lockdown.c @@ -95,6 +95,9 @@ typedef struct { } BindAction; static const BindAction window_actions[] = { + { EPHY_PREFS_LOCKDOWN_MULTIPLE_TABS, "FileNewWindow", "sensitive" }, + { EPHY_PREFS_LOCKDOWN_MULTIPLE_TABS, "FileNewWindowIncognito", "sensitive" }, + { EPHY_PREFS_LOCKDOWN_PRINTING, "FilePrint", "sensitive" }, { EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING, "FileBookmarkPage", "sensitive" }, @@ -199,6 +202,7 @@ window_added_cb (GtkApplication *application, GtkUIManager *manager; GtkActionGroup *action_group; GtkAction *action; + GAction *gaction; GSettings *settings; EphyLocationController *location_controller; @@ -225,6 +229,22 @@ window_added_cb (GtkApplication *application, action_group, window_actions, G_N_ELEMENTS (window_actions)); + gaction = g_action_map_lookup_action (G_ACTION_MAP (application), + "new"); + g_settings_bind (EPHY_SETTINGS_LOCKDOWN, + EPHY_PREFS_LOCKDOWN_MULTIPLE_TABS, + gaction, "enabled", + G_SETTINGS_BIND_GET | + G_SETTINGS_BIND_INVERT_BOOLEAN); + + gaction = g_action_map_lookup_action (G_ACTION_MAP (application), + "new-incognito"); + g_settings_bind (EPHY_SETTINGS_LOCKDOWN, + EPHY_PREFS_LOCKDOWN_MULTIPLE_TABS, + gaction, "enabled", + G_SETTINGS_BIND_GET | + G_SETTINGS_BIND_INVERT_BOOLEAN); + action_group = find_action_group (manager, "PopupsActions"); bind_settings_and_actions (EPHY_SETTINGS_LOCKDOWN, action_group, popup_actions, Please review it and merge it with your patch.
Created attachment 250641 [details] [review] Introduced support for only 1 tab/window behaviour Applied comments suggested. However, the changes suggested to disable the CTRL+N functionality have been finally applied at ephy-shell.c, as they will need to be removed too for the application mode, as it's already reported at https://bugzilla.gnome.org/show_bug.cgi?id=703929.
Review of attachment 250641 [details] [review]: Thanks for the new patch I've just applied it to kiosk-mode branch. We should provide a new patch rebased against master too.
Created attachment 267902 [details] [review] Introduced support for only 1 tab/window behaviour I have updated the patch to make it work with the last master version.
Review of attachment 267902 [details] [review]: This will need to be rebased, since it's been so long. :( ::: src/ephy-window.c @@ +2208,3 @@ + if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN, EPHY_PREFS_LOCKDOWN_MULTIPLE_TABS)) { + return TRUE; + }; Omit the braces around a single-line conditional statement. And certainly omit the semicolon. :) ::: src/window-commands.c @@ +975,1 @@ window_cmd_file_new_window (GtkAction *action, Hm, I am not sure it makes sense to modify the implementation of these commands to make them fail. Wouldn't it be better to check the value of these settings before triggering the commands, to prevent them from ever being run in the first place? On the one hand, it's generally better to do such checks at the lowest possible level to prevent future code from forgetting to add checks in all the right places, but in this case I think it semantically makes more sense that the actions do the actions, and checks occur up higher. I don't mind too much either way, but please consider this. @@ +976,3 @@ EphyWindow *window) { + if ( !g_settings_get_boolean(EPHY_SETTINGS_LOCKDOWN, EPHY_PREFS_LOCKDOWN_MULTIPLE_TABS) ) { No extra spaces after the opening parenthesis and before the closing parenthesis, please. And don't forget the space before the opening parenthesis in the function call: if (!g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN, EPHY_PREFS_LOCKDOWN_MULTIPLE_TABS)) { @@ +980,3 @@ + NULL, NULL, NULL, + EPHY_NEW_TAB_IN_NEW_WINDOW | + EPHY_NEW_TAB_HOME_PAGE); These lines should be re-indented. @@ +988,3 @@ EphyWindow *window) { + if ( !g_settings_get_boolean(EPHY_SETTINGS_LOCKDOWN, EPHY_PREFS_LOCKDOWN_MULTIPLE_TABS) ) { if (!g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN, EPHY_PREFS_LOCKDOWN_MULTIPLE_TABS)) {
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/epiphany/issues/200.