[epiphany] clear-data-dialog: Make it a EphyDataDialog
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] clear-data-dialog: Make it a EphyDataDialog
- Date: Fri, 17 Jan 2020 16:52:31 +0000 (UTC)
commit c8e671ebd6630edf70bd9c84e88ce0d7bac541d7
Author: Adrien Plazas <kekun plazas laposte net>
Date: Tue Jul 9 17:27:12 2019 +0200
clear-data-dialog: Make it a EphyDataDialog
This will help factoring its code with other data management dialogs.
Fixes https://gitlab.gnome.org/GNOME/epiphany/issues/832.
src/clear-data-dialog.c | 41 ++----
src/clear-data-dialog.h | 4 +-
src/prefs-dialog.c | 4 +-
src/resources/gtk/clear-data-dialog.ui | 239 +++++++++++----------------------
4 files changed, 96 insertions(+), 192 deletions(-)
---
diff --git a/src/clear-data-dialog.c b/src/clear-data-dialog.c
index de7e25f18..29a47a701 100644
--- a/src/clear-data-dialog.c
+++ b/src/clear-data-dialog.c
@@ -38,16 +38,12 @@ typedef enum {
} Timespan;
struct _ClearDataDialog {
- GtkDialog parent_instance;
+ EphyDataDialog parent_instance;
- GtkWidget *clear_button;
GtkWidget *treeview;
GtkTreeModel *treestore;
GtkTreeModelFilter *treemodelfilter;
GtkWidget *timespan_combo;
- GtkWidget *search_entry;
- GtkSpinner *spinner;
- GtkStack *stack;
Timespan timespan;
GCancellable *cancellable;
@@ -61,7 +57,7 @@ enum {
SENSITIVE_COLUMN
};
-G_DEFINE_TYPE (ClearDataDialog, clear_data_dialog, GTK_TYPE_DIALOG)
+G_DEFINE_TYPE (ClearDataDialog, clear_data_dialog, EPHY_TYPE_DATA_DIALOG)
#define PERSISTENT_DATA_TYPES WEBKIT_WEBSITE_DATA_DISK_CACHE | \
WEBKIT_WEBSITE_DATA_OFFLINE_APPLICATION_CACHE | \
@@ -133,18 +129,17 @@ website_data_fetched_cb (WebKitWebsiteDataManager *manager,
return;
}
- gtk_spinner_stop (dialog->spinner);
+ ephy_data_dialog_set_is_loading (EPHY_DATA_DIALOG (dialog), FALSE);
if (!data_list) {
- gtk_stack_set_visible_child_name (dialog->stack, "nodata");
+ ephy_data_dialog_set_has_data (EPHY_DATA_DIALOG (dialog), FALSE);
if (error)
g_error_free (error);
return;
}
- gtk_widget_set_sensitive (dialog->clear_button, TRUE);
- gtk_stack_set_visible_child_name (dialog->stack, "view");
+ ephy_data_dialog_set_has_data (EPHY_DATA_DIALOG (dialog), TRUE);
treestore = GTK_TREE_STORE (dialog->treestore);
for (guint i = 0; i < G_N_ELEMENTS (data_entries); i++) {
@@ -193,9 +188,7 @@ all_children_visible (GtkTreeModel *model,
}
static void
-clear_data_dialog_response_cb (GtkDialog *widget,
- int response,
- ClearDataDialog *dialog)
+on_clear_all_clicked (ClearDataDialog *dialog)
{
GtkTreeIter top_iter;
WebKitWebsiteDataTypes types_to_clear = 0;
@@ -203,11 +196,6 @@ clear_data_dialog_response_cb (GtkDialog *widget,
WebKitWebsiteDataTypes types_to_remove = 0;
GTimeSpan timespan;
- if (response != GTK_RESPONSE_OK) {
- gtk_widget_destroy (GTK_WIDGET (dialog));
- return;
- }
-
if (!gtk_tree_model_get_iter_first (dialog->treestore, &top_iter)) {
gtk_widget_destroy (GTK_WIDGET (dialog));
return;
@@ -363,8 +351,7 @@ timespan_combo_changed_cb (GtkComboBox *combo,
}
static void
-search_entry_changed_cb (GtkSearchEntry *entry,
- ClearDataDialog *dialog)
+search_text_changed_cb (ClearDataDialog *dialog)
{
gtk_tree_model_filter_refilter (dialog->treemodelfilter);
}
@@ -381,7 +368,7 @@ row_visible_func (GtkTreeModel *model,
if (gtk_tree_model_iter_has_child (model, iter))
return TRUE;
- search_text = gtk_entry_get_text (GTK_ENTRY (dialog->search_entry));
+ search_text = ephy_data_dialog_get_search_text (EPHY_DATA_DIALOG (dialog));
if (!search_text || search_text[0] == '\0')
return TRUE;
@@ -429,18 +416,14 @@ clear_data_dialog_class_init (ClearDataDialogClass *klass)
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/epiphany/gtk/clear-data-dialog.ui");
- gtk_widget_class_bind_template_child (widget_class, ClearDataDialog, clear_button);
gtk_widget_class_bind_template_child (widget_class, ClearDataDialog, treeview);
gtk_widget_class_bind_template_child (widget_class, ClearDataDialog, treestore);
gtk_widget_class_bind_template_child (widget_class, ClearDataDialog, treemodelfilter);
gtk_widget_class_bind_template_child (widget_class, ClearDataDialog, timespan_combo);
- gtk_widget_class_bind_template_child (widget_class, ClearDataDialog, search_entry);
- gtk_widget_class_bind_template_child (widget_class, ClearDataDialog, spinner);
- gtk_widget_class_bind_template_child (widget_class, ClearDataDialog, stack);
gtk_widget_class_bind_template_callback (widget_class, item_toggled_cb);
gtk_widget_class_bind_template_callback (widget_class, timespan_combo_changed_cb);
- gtk_widget_class_bind_template_callback (widget_class, clear_data_dialog_response_cb);
- gtk_widget_class_bind_template_callback (widget_class, search_entry_changed_cb);
+ gtk_widget_class_bind_template_callback (widget_class, on_clear_all_clicked);
+ gtk_widget_class_bind_template_callback (widget_class, search_text_changed_cb);
}
static void
@@ -456,9 +439,7 @@ clear_data_dialog_init (ClearDataDialog *dialog)
gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->timespan_combo),
dialog->timespan);
- gtk_widget_set_sensitive (dialog->clear_button, FALSE);
- gtk_spinner_start (dialog->spinner);
- gtk_stack_set_visible_child_name (dialog->stack, "spinner");
+ ephy_data_dialog_set_is_loading (EPHY_DATA_DIALOG (dialog), TRUE);
dialog->cancellable = g_cancellable_new ();
diff --git a/src/clear-data-dialog.h b/src/clear-data-dialog.h
index 220885335..e38eae12c 100644
--- a/src/clear-data-dialog.h
+++ b/src/clear-data-dialog.h
@@ -23,10 +23,12 @@
#include <glib-object.h>
#include <gtk/gtk.h>
+#include "ephy-data-dialog.h"
+
G_BEGIN_DECLS
#define EPHY_TYPE_CLEAR_DATA_DIALOG (clear_data_dialog_get_type ())
-G_DECLARE_FINAL_TYPE (ClearDataDialog, clear_data_dialog, EPHY, CLEAR_DATA_DIALOG, GtkDialog)
+G_DECLARE_FINAL_TYPE (ClearDataDialog, clear_data_dialog, EPHY, CLEAR_DATA_DIALOG, EphyDataDialog)
G_END_DECLS
diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c
index 3b9a8534d..d51d67014 100644
--- a/src/prefs-dialog.c
+++ b/src/prefs-dialog.c
@@ -1851,9 +1851,7 @@ clear_personal_data_button_clicked_cb (GtkWidget *button,
{
ClearDataDialog *clear_dialog;
- clear_dialog = g_object_new (EPHY_TYPE_CLEAR_DATA_DIALOG,
- "use-header-bar", TRUE,
- NULL);
+ clear_dialog = g_object_new (EPHY_TYPE_CLEAR_DATA_DIALOG, NULL);
gtk_window_set_transient_for (GTK_WINDOW (clear_dialog), GTK_WINDOW (dialog));
gtk_window_set_modal (GTK_WINDOW (clear_dialog), TRUE);
gtk_window_present_with_time (GTK_WINDOW (clear_dialog), gtk_get_current_event_time ());
diff --git a/src/resources/gtk/clear-data-dialog.ui b/src/resources/gtk/clear-data-dialog.ui
index 0030e9531..e181c9b2b 100644
--- a/src/resources/gtk/clear-data-dialog.ui
+++ b/src/resources/gtk/clear-data-dialog.ui
@@ -18,149 +18,95 @@
<object class="GtkTreeModelFilter" id="treemodelfilter">
<property name="child_model">treestore</property>
</object>
- <template class="ClearDataDialog" parent="GtkDialog">
- <property name="height_request">500</property>
- <property name="modal">True</property>
- <property name="window_position">center</property>
- <property name="destroy_with_parent">True</property>
- <property name="type_hint">dialog</property>
- <signal name="response" handler="clear_data_dialog_response_cb"/>
- <signal name="key-press-event" handler="gtk_search_bar_handle_event" object="search_bar" swapped="true"/>
- <child internal-child="headerbar">
- <object class="GtkHeaderBar">
- <property name="title" translatable="yes">Clear Personal Data</property>
- <property name="show-close-button">True</property>
+ <template class="ClearDataDialog" parent="EphyDataDialog">
+ <property name="title" translatable="yes">Personal Data</property>
+ <property name="clear_all_description" translatable="yes">Remove all personal data</property>
+ <property name="search_description" translatable="yes">Search personal data</property>
+ <property name="empty_title" translatable="yes">There is no Personal Data</property>
+ <property name="empty_description" translatable="yes">Personal data will be listed here</property>
+ <property name="has_search_results">True</property>
+ <property name="can_clear">True</property>
+ <signal name="clear-all-clicked" handler="on_clear_all_clicked"/>
+ <signal name="notify::search-text" handler="search_text_changed_cb" swapped="yes"/>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolled_window">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
<child>
- <object class="GtkButton" id="clear_button">
- <property name="label" translatable="yes">C_lear</property>
+ <object class="HdyColumn">
<property name="visible">True</property>
- <property name="use_underline">True</property>
- <property name="valign">center</property>
- <style>
- <class name="destructive-action"/>
- <class name="text-button"/>
- </style>
- </object>
- </child>
- <child>
- <object class="GtkToggleButton" id="search_button">
- <property name="visible">True</property>
- <property name="valign">center</property>
- <accelerator key="F" modifiers="GDK_CONTROL_MASK" signal="clicked"/>
- <style>
- <class name="image-button"/>
- </style>
- <child internal-child="accessible">
- <object class="AtkObject">
- <property name="AtkObject::accessible-name" translatable="yes">Search</property>
- <property name="AtkObject::accessible-description" translatable="yes">Filter
domains</property>
- </object>
- </child>
- <child>
- <object class="GtkImage">
- <property name="visible">True</property>
- <property name="icon-name">edit-find-symbolic</property>
- <property name="icon-size">1</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="pack-type">end</property>
- </packing>
- </child>
- </object>
- </child>
- <child internal-child="vbox">
- <object class="GtkBox">
- <property name="border_width">0</property>
- <child>
- <object class="GtkSearchBar" id="search_bar">
- <property name="visible">True</property>
- <property name="search-mode-enabled" bind-source="search_button" bind-property="active"
bind-flags="bidirectional|sync-create"/>
- <child>
- <object class="GtkSearchEntry" id="search_entry">
- <property name="visible">True</property>
- <property name="width-request">300</property> <!-- looks cool and same as passwords-dialog
-->
- <property name="primary_icon_name">edit-find-symbolic</property>
- <property name="primary_icon_activatable">False</property>
- <property name="primary_icon_sensitive">False</property>
- <property name="placeholder_text" translatable="yes">Search domains</property>
- <signal name="search-changed" handler="search_entry_changed_cb"/>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="orientation">vertical</property>
- <property name="border_width">15</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="halign">start</property>
- <property name="label" translatable="yes">You can select a period of time to clear data for
all websites modified in that period. If you choose from the beginning of time, then you can also clear data
only for particular websites.</property>
- <property name="wrap">True</property>
- <property name="max_width_chars">50</property>
- </object>
- </child>
+ <property name="can_focus">False</property>
+ <property name="margin_start">6</property>
+ <property name="margin_end">6</property>
+ <property name="maximum_width">600</property>
+ <property name="linear_growth_width">400</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="orientation">vertical</property>
- <property name="spacing">6</property>
+ <property name="margin_top">6</property>
+ <property name="margin_bottom">6</property>
+ <property name="spacing">12</property>
<child>
- <object class="GtkBox">
+ <object class="GtkLabel">
<property name="visible">True</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Clear selected personal data
_from:</property>
- <property name="use-underline">True</property>
- <property name="mnemonic-widget">timespan_combo</property>
- </object>
- </child>
- <child>
- <object class="GtkComboBoxText" id="timespan_combo">
- <property name="visible">True</property>
- <signal name="changed" handler="timespan_combo_changed_cb"/>
- <items>
- <item translatable="yes">the past hour</item>
- <item translatable="yes">the past day</item>
- <item translatable="yes">the past week</item>
- <item translatable="yes">the past four weeks</item>
- <item translatable="yes">the beginning of time</item>
- </items>
- </object>
- <packing>
- <property name="expand">False</property>
- </packing>
- </child>
+ <property name="label" translatable="yes">You can select a period of time to clear data
for all websites modified in that period. If you choose from the beginning of time, then you can also clear
data only for particular websites.</property>
+ <property name="xalign">0</property>
+ <property name="wrap">True</property>
+ <property name="justify">left</property>
</object>
</child>
<child>
- <object class="GtkStack" id="stack">
+ <object class="GtkBox">
<property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
<child>
- <object class="GtkSpinner" id="spinner">
+ <object class="GtkFlowBox">
<property name="visible">True</property>
- <property name="width_request">32</property>
- <property name="height_request">32</property>
- <property name="halign">center</property>
- <property name="valign">center</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
+ <property name="column_spacing">12</property>
+ <property name="selection_mode">none</property>
+ <property name="max_children_per_line">2</property>
+ <property name="min_children_per_line">1</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Clear selected personal data
_from:</property>
+ <property name="use-underline">True</property>
+ <property name="mnemonic-widget">timespan_combo</property>
+ <property name="halign">start</property>
+ <property name="xalign">0</property>
+ <property name="wrap">True</property>
+ <property name="justify">left</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkComboBoxText" id="timespan_combo">
+ <property name="visible">True</property>
+ <property name="halign">end</property>
+ <signal name="changed" handler="timespan_combo_changed_cb"/>
+ <items>
+ <item translatable="yes">the past hour</item>
+ <item translatable="yes">the past day</item>
+ <item translatable="yes">the past week</item>
+ <item translatable="yes">the past four weeks</item>
+ <item translatable="yes">the beginning of time</item>
+ </items>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ </packing>
+ </child>
</object>
- <packing>
- <property name="name">spinner</property>
- </packing>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="expand">True</property>
+ <property name="min_content_height">100</property>
+ <style>
+ <class name="frame"/>
+ </style>
<child>
<object class="GtkTreeView" id="treeview">
<property name="visible">True</property>
@@ -198,49 +144,26 @@
</object>
</child>
</object>
- <packing>
- <property name="name">view</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">center</property>
- <property name="valign">center</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <property name="label" translatable="yes">No data found</property>
- <attributes>
- <attribute name="scale" value="1.4"/>
- </attributes>
- </object>
- <packing>
- <property name="name">nodata</property>
- </packing>
</child>
</object>
</child>
- </object>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="halign">start</property>
- <property name="label" translatable="yes">You cannot undo this action. The data you are
choosing to clear will be removed forever.</property>
- <property name="wrap">True</property>
- <property name="max_width_chars">50</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">You cannot undo this action. The data you are
choosing to clear will be removed forever.</property>
+ <property name="justify">left</property>
+ <property name="xalign">0</property>
+ <property name="wrap">True</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
</object>
</child>
</object>
</child>
</object>
</child>
- <action-widgets>
- <action-widget response="-5">clear_button</action-widget>
- </action-widgets>
</template>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]