[epiphany] history-dialog: Disable forget actions in incognito mode
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] history-dialog: Disable forget actions in incognito mode
- Date: Sun, 19 Feb 2017 18:53:06 +0000 (UTC)
commit 0f0e3ea6f1b9c388b33adb0d4d797de07debd64f
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Sun Feb 19 12:50:47 2017 -0600
history-dialog: Disable forget actions in incognito mode
They always fail, because the history service is read-only.
I investigated using a separate history service in read/write mode, but
couldn't get it to work properly. Carlos prefers not to modify anything
in incognito mode anyway.
src/ephy-history-dialog.c | 30 +++++++++++++++++++++++++++---
src/resources/gtk/history-dialog.ui | 4 ++--
2 files changed, 29 insertions(+), 5 deletions(-)
---
diff --git a/src/ephy-history-dialog.c b/src/ephy-history-dialog.c
index 5295322..b1e43c7 100644
--- a/src/ephy-history-dialog.c
+++ b/src/ephy-history-dialog.c
@@ -57,6 +57,9 @@ struct _EphyHistoryDialog {
GtkWidget *location_renderer;
GMenuModel *treeview_popup_menu_model;
+ GtkWidget *forget_all_button;
+ GtkWidget *forget_button;
+
GActionGroup *action_group;
GList *urls;
@@ -507,13 +510,16 @@ static void
update_selection_actions (GActionGroup *action_group,
gboolean has_selection)
{
+ EphyEmbedShell *shell = ephy_embed_shell_get_default ();
GAction *forget_action;
GAction *open_selection_action;
- forget_action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "forget");
- open_selection_action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "open-selection");
+ if (ephy_embed_shell_get_mode (shell) != EPHY_EMBED_SHELL_MODE_INCOGNITO) {
+ forget_action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "forget");
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (forget_action), has_selection);
+ }
- g_simple_action_set_enabled (G_SIMPLE_ACTION (forget_action), has_selection);
+ open_selection_action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "open-selection");
g_simple_action_set_enabled (G_SIMPLE_ACTION (open_selection_action), has_selection);
}
@@ -670,6 +676,8 @@ ephy_history_dialog_class_init (EphyHistoryDialogClass *klass)
gtk_widget_class_bind_template_child (widget_class, EphyHistoryDialog, date_renderer);
gtk_widget_class_bind_template_child (widget_class, EphyHistoryDialog, location_renderer);
gtk_widget_class_bind_template_child (widget_class, EphyHistoryDialog, treeview_popup_menu_model);
+ gtk_widget_class_bind_template_child (widget_class, EphyHistoryDialog, forget_all_button);
+ gtk_widget_class_bind_template_child (widget_class, EphyHistoryDialog, forget_button);
gtk_widget_class_bind_template_callback (widget_class, on_treeview_row_activated);
gtk_widget_class_bind_template_callback (widget_class, on_treeview_key_press_event);
@@ -761,6 +769,10 @@ create_action_group (EphyHistoryDialog *self)
static void
ephy_history_dialog_init (EphyHistoryDialog *self)
{
+ EphyEmbedShell *shell = ephy_embed_shell_get_default ();
+ const char *tooltip;
+ GAction *action;
+
gtk_widget_init_template (GTK_WIDGET (self));
self->cancellable = g_cancellable_new ();
@@ -794,5 +806,17 @@ ephy_history_dialog_init (EphyHistoryDialog *self)
self->action_group = create_action_group (self);
gtk_widget_insert_action_group (GTK_WIDGET (self), "history", self->action_group);
+ if (ephy_embed_shell_get_mode (shell) == EPHY_EMBED_SHELL_MODE_INCOGNITO) {
+ tooltip = _("It is not possible to modify history when in incognito mode.");
+ gtk_widget_set_tooltip_text (self->forget_all_button, tooltip);
+ gtk_widget_set_tooltip_text (self->forget_button, tooltip);
+
+ action = g_action_map_lookup_action (G_ACTION_MAP (self->action_group), "forget");
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE);
+
+ action = g_action_map_lookup_action (G_ACTION_MAP (self->action_group), "forget-all");
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE);
+ }
+
update_selection_actions (self->action_group, FALSE);
}
diff --git a/src/resources/gtk/history-dialog.ui b/src/resources/gtk/history-dialog.ui
index e9f57f4..cb56f52 100644
--- a/src/resources/gtk/history-dialog.ui
+++ b/src/resources/gtk/history-dialog.ui
@@ -40,7 +40,7 @@
<property name="title" translatable="yes">History</property>
<property name="show-close-button">True</property>
<child>
- <object class="GtkButton">
+ <object class="GtkButton" id="forget_all_button">
<property name="label" translatable="yes">C_lear All</property>
<property name="visible">True</property>
<property name="use_underline">True</property>
@@ -163,7 +163,7 @@
<object class="GtkBox">
<property name="visible">True</property>
<child>
- <object class="GtkButton">
+ <object class="GtkButton" id="forget_button">
<property name="visible">True</property>
<property name="tooltip_text" translatable="yes">Remove the selected pages from
history</property>
<property name="action-name">history.forget</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]