99
99
/* File actions. */
101
{ "FileNewWindow", NULL, N_("_New Window"), "<control>N", NULL,
102
G_CALLBACK (window_cmd_file_new_window) },
101
103
{ "FileOpen", NULL, N_("_Open…"), "<control>O", NULL,
102
104
G_CALLBACK (window_cmd_file_open) },
103
105
{ "FileSaveAs", NULL, N_("Save _As…"), "<shift><control>S", NULL,
110
112
G_CALLBACK (window_cmd_file_send_to) },
111
113
{ "FileCloseTab", NULL, N_("_Close"), "<control>W", NULL,
112
114
G_CALLBACK (window_cmd_file_close_window) },
115
{ "FileQuit", NULL, N_("_Quit"), "<control>Q", NULL,
116
G_CALLBACK (window_cmd_file_quit) },
114
118
/* Edit actions. */
133
137
G_CALLBACK (window_cmd_edit_find_next) },
134
138
{ "EditFindPrev", NULL, N_("Find Pre_vious"), "<shift><control>G", NULL,
135
139
G_CALLBACK (window_cmd_edit_find_prev) },
140
{ "EditBookmarks", NULL, N_("_Bookmarks"), "<control>B", NULL,
141
G_CALLBACK (window_cmd_edit_bookmarks) },
142
{ "EditHistory", NULL, N_("_History"), "<control>H", NULL,
143
G_CALLBACK (window_cmd_edit_history) },
144
{ "EditPreferences", NULL, N_("Preferences"), "<control>e", NULL,
145
G_CALLBACK (window_cmd_edit_preferences) },
146
{ "EditPersonalData", NULL, N_("Personal Data"), "<control>m", NULL,
147
G_CALLBACK (window_cmd_edit_personal_data) },
137
149
/* View actions. */
174
186
G_CALLBACK (window_cmd_tabs_move_right) },
175
187
{ "TabsDetach", NULL, N_("_Detach Tab"), NULL, NULL,
176
188
G_CALLBACK (window_cmd_tabs_detach) },
192
{ "HelpAbout", NULL, N_("_About"), NULL, NULL,
193
G_CALLBACK (window_cmd_help_about) }
179
196
static const GtkToggleActionEntry ephy_menu_toggle_entries [] =
261
278
/* FIXME: PageMenu should have its accel without being in the
262
279
* extra keybindings, but does not seem to work for some
264
{ GDK_KEY_e, GDK_MOD1_MASK, "PageMenu", TRUE },
281
{ GDK_KEY_F10, 0, "PageMenu", TRUE },
265
282
{ GDK_KEY_Home, GDK_MOD1_MASK, "FileHome", TRUE },
266
283
/* FIXME: these are not in any menu for now, so add them here. */
267
284
{ GDK_KEY_F11, 0, "ViewFullscreen", FALSE },
970
988
ephy_window_delete_event (GtkWidget *widget,
971
989
GdkEventAny *event)
973
EphyWindow *window = EPHY_WINDOW (widget);
974
EphySession *session;
975
EphyEmbed *modified_embed = NULL;
976
GList *tabs, *l, *windows;
977
guint number_windows;
978
gboolean modified = FALSE;
980
/* We ignore the delete_event if the disable_quit lockdown has been set
982
if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
983
EPHY_PREFS_LOCKDOWN_QUIT)) return TRUE;
985
tabs = impl_get_children (EPHY_EMBED_CONTAINER (window));
986
for (l = tabs; l != NULL; l = l->next)
988
EphyEmbed *embed = (EphyEmbed *) l->data;
990
g_return_val_if_fail (EPHY_IS_EMBED (embed), FALSE);
992
if (ephy_web_view_has_modified_forms (ephy_embed_get_web_view (embed)))
995
modified_embed = embed;
1003
/* jump to the first tab with modified forms */
1004
impl_set_active_child (EPHY_EMBED_CONTAINER (window),
1007
if (confirm_close_with_modified_forms (window) == FALSE)
1009
/* stop window close */
1015
if (window_has_ongoing_downloads (window) && confirm_close_with_downloads (window) == FALSE)
1017
/* stop window close */
1021
/* If this is the last window, save its state in the session. */
1022
session = EPHY_SESSION (ephy_shell_get_session (ephy_shell));
1023
windows = ephy_session_get_windows (session);
1024
number_windows = g_list_length (windows);
1025
g_list_free (windows);
1027
if (number_windows == 1)
1029
ephy_session_close (session);
1032
/* See bug #114689 */
1033
gtk_widget_hide (widget);
991
if (!ephy_window_close (EPHY_WINDOW (widget)))
1035
994
/* proceed with window close */
1036
995
if (GTK_WIDGET_CLASS (ephy_window_parent_class)->delete_event)
3414
3373
g_signal_handler_disconnect (window,
3415
3374
priv->set_focus_handler);
3376
if (priv->app_menu_visibility_handler != 0)
3377
g_signal_handler_disconnect (gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (window))),
3378
priv->app_menu_visibility_handler);
3417
3380
G_OBJECT_CLASS (ephy_window_parent_class)->finalize (object);
3419
3382
LOG ("EphyWindow finalised %p", object);
3556
static const gchar* app_actions[] = {
3567
ephy_window_toggle_visibility_for_app_menu (EphyWindow *window)
3569
const gchar *action_name;
3570
gboolean shows_app_menu;
3571
GtkSettings *settings;
3575
settings = gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (window)));
3576
g_object_get (settings,
3577
"gtk-shell-shows-app-menu", &shows_app_menu,
3580
for (idx = 0; idx < G_N_ELEMENTS (app_actions); idx++) {
3581
action_name = app_actions[idx];
3582
action = gtk_action_group_get_action (window->priv->action_group, action_name);
3584
gtk_action_set_visible (action, !shows_app_menu);
3593
3588
static GObject *
3594
3589
ephy_window_constructor (GType type,
3595
3590
guint n_construct_properties,
3769
/* We never want the menubar shown, we merge the app menu into
3770
* our super menu manually when running outside the Shell. */
3771
gtk_application_window_set_show_menubar (GTK_APPLICATION_WINDOW (window), FALSE);
3773
ephy_window_toggle_visibility_for_app_menu (window);
3774
priv->app_menu_visibility_handler = g_signal_connect_swapped (gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (window))),
3775
"notify::gtk-shell-shows-app-menu",
3776
G_CALLBACK (ephy_window_toggle_visibility_for_app_menu), window);
3774
3778
/* ensure the UI is updated */
3775
3779
gtk_ui_manager_ensure_update (priv->manager);
4166
4170
return window->priv->location_controller;
4174
* ephy_window_close:
4175
* @window: an #EphyWindow
4177
* Try to close the window. The window might refuse to close
4178
* if there are ongoing download operations or unsubmitted
4181
* Returns: %TRUE if the window is closed, or %FALSE otherwise
4184
ephy_window_close (EphyWindow *window)
4186
EphySession *session;
4187
EphyEmbed *modified_embed = NULL;
4188
GList *tabs, *l, *windows;
4189
guint number_windows;
4190
gboolean modified = FALSE;
4192
/* We ignore the delete_event if the disable_quit lockdown has been set
4194
if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
4195
EPHY_PREFS_LOCKDOWN_QUIT)) return FALSE;
4197
tabs = impl_get_children (EPHY_EMBED_CONTAINER (window));
4198
for (l = tabs; l != NULL; l = l->next)
4200
EphyEmbed *embed = (EphyEmbed *) l->data;
4202
g_return_val_if_fail (EPHY_IS_EMBED (embed), FALSE);
4204
if (ephy_web_view_has_modified_forms (ephy_embed_get_web_view (embed)))
4207
modified_embed = embed;
4215
/* jump to the first tab with modified forms */
4216
impl_set_active_child (EPHY_EMBED_CONTAINER (window),
4219
if (confirm_close_with_modified_forms (window) == FALSE)
4221
/* stop window close */
4227
if (window_has_ongoing_downloads (window) && confirm_close_with_downloads (window) == FALSE)
4229
/* stop window close */
4233
/* If this is the last window, save its state in the session. */
4234
session = EPHY_SESSION (ephy_shell_get_session (ephy_shell));
4235
windows = ephy_session_get_windows (session);
4236
number_windows = g_list_length (windows);
4237
g_list_free (windows);
4239
if (number_windows == 1)
4241
ephy_session_close (session);
4244
/* See bug #114689 */
4245
gtk_widget_hide (GTK_WIDGET (window));