[epiphany] Use HdyPreferencesWindow as the prefs dialog
- From: Jan-Michael Brummer <jbrummer src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] Use HdyPreferencesWindow as the prefs dialog
- Date: Wed, 29 Jul 2020 15:51:34 +0000 (UTC)
commit ace46576f28e3a3e52e2a27d417236f1c8956e23
Author: Adrien Plazas <kekun plazas laposte net>
Date: Thu Jul 23 10:23:37 2020 +0200
Use HdyPreferencesWindow as the prefs dialog
This also sets to default with to 800.
Create subpages lazily, hopefully this speeds up the dialog startup.
src/preferences/ephy-prefs-dialog.c | 58 +++++++++--------
src/preferences/ephy-prefs-dialog.h | 2 +-
src/resources/gtk/prefs-dialog.ui | 124 +++++-------------------------------
3 files changed, 46 insertions(+), 138 deletions(-)
---
diff --git a/src/preferences/ephy-prefs-dialog.c b/src/preferences/ephy-prefs-dialog.c
index 66e8eef26..c771e2780 100644
--- a/src/preferences/ephy-prefs-dialog.c
+++ b/src/preferences/ephy-prefs-dialog.c
@@ -22,30 +22,25 @@
#include "config.h"
+#include "clear-data-view.h"
#include "ephy-data-view.h"
#include "ephy-embed-utils.h"
#include "ephy-gui.h"
#include "ephy-prefs-dialog.h"
+#include "passwords-view.h"
#include "prefs-general-page.h"
#include "prefs-sync-page.h"
struct _EphyPrefsDialog {
- HdyWindow parent_instance;
-
- HdyDeck *deck;
- GtkWidget *prefs_pages_view;
- GtkWidget *notebook;
+ HdyPreferencesWindow parent_instance;
PrefsGeneralPage *general_page;
PrefsSyncPage *sync_page;
- GtkStack *data_views_stack;
GtkWidget *active_data_view;
- GtkWidget *passwords_view;
- GtkWidget *clear_data_view;
};
-G_DEFINE_TYPE (EphyPrefsDialog, ephy_prefs_dialog, HDY_TYPE_WINDOW)
+G_DEFINE_TYPE (EphyPrefsDialog, ephy_prefs_dialog, HDY_TYPE_PREFERENCES_WINDOW)
static gboolean
on_key_press_event (EphyPrefsDialog *prefs_dialog,
@@ -69,12 +64,26 @@ on_delete_event (EphyPrefsDialog *prefs_dialog)
gtk_widget_destroy (GTK_WIDGET (prefs_dialog));
}
+static void
+on_any_data_view_back_button_clicked (GtkWidget *data_view,
+ EphyPrefsDialog *prefs_dialog)
+{
+ hdy_preferences_window_close_subpage (HDY_PREFERENCES_WINDOW (prefs_dialog));
+
+ prefs_dialog->active_data_view = NULL;
+}
+
static void
present_data_view (EphyPrefsDialog *prefs_dialog,
GtkWidget *presented_view)
{
- gtk_stack_set_visible_child (prefs_dialog->data_views_stack, presented_view);
- hdy_deck_navigate (prefs_dialog->deck, HDY_NAVIGATION_DIRECTION_FORWARD);
+ g_signal_connect_object (presented_view, "back-button-clicked",
+ G_CALLBACK (on_any_data_view_back_button_clicked),
+ prefs_dialog, 0);
+
+ hdy_preferences_window_present_subpage (HDY_PREFERENCES_WINDOW (prefs_dialog),
+ presented_view);
+
prefs_dialog->active_data_view = presented_view;
}
@@ -82,22 +91,22 @@ static void
on_passwords_row_activated (GtkWidget *privacy_page,
EphyPrefsDialog *prefs_dialog)
{
- present_data_view (prefs_dialog, prefs_dialog->passwords_view);
+ GtkWidget *view = g_object_new (EPHY_TYPE_PASSWORDS_VIEW,
+ "visible", TRUE,
+ NULL);
+
+ present_data_view (prefs_dialog, view);
}
static void
on_clear_data_row_activated (GtkWidget *privacy_page,
EphyPrefsDialog *prefs_dialog)
{
- present_data_view (prefs_dialog, prefs_dialog->clear_data_view);
-}
+ GtkWidget *view = g_object_new (EPHY_TYPE_CLEAR_DATA_VIEW,
+ "visible", TRUE,
+ NULL);
-static void
-on_any_data_view_back_button_clicked (GtkWidget *data_view,
- EphyPrefsDialog *prefs_dialog)
-{
- prefs_dialog->active_data_view = NULL;
- hdy_deck_navigate (prefs_dialog->deck, HDY_NAVIGATION_DIRECTION_BACK);
+ present_data_view (prefs_dialog, view);
}
static void
@@ -108,21 +117,14 @@ ephy_prefs_dialog_class_init (EphyPrefsDialogClass *klass)
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/epiphany/gtk/prefs-dialog.ui");
- gtk_widget_class_bind_template_child (widget_class, EphyPrefsDialog, deck);
- gtk_widget_class_bind_template_child (widget_class, EphyPrefsDialog, prefs_pages_view);
- gtk_widget_class_bind_template_child (widget_class, EphyPrefsDialog, notebook);
gtk_widget_class_bind_template_child (widget_class, EphyPrefsDialog, general_page);
gtk_widget_class_bind_template_child (widget_class, EphyPrefsDialog, sync_page);
- gtk_widget_class_bind_template_child (widget_class, EphyPrefsDialog, data_views_stack);
- gtk_widget_class_bind_template_child (widget_class, EphyPrefsDialog, passwords_view);
- gtk_widget_class_bind_template_child (widget_class, EphyPrefsDialog, clear_data_view);
/* Template file callbacks */
gtk_widget_class_bind_template_callback (widget_class, on_key_press_event);
gtk_widget_class_bind_template_callback (widget_class, on_delete_event);
gtk_widget_class_bind_template_callback (widget_class, on_passwords_row_activated);
gtk_widget_class_bind_template_callback (widget_class, on_clear_data_row_activated);
- gtk_widget_class_bind_template_callback (widget_class, on_any_data_view_back_button_clicked);
}
static void
@@ -136,7 +138,7 @@ ephy_prefs_dialog_init (EphyPrefsDialog *dialog)
if (mode == EPHY_EMBED_SHELL_MODE_BROWSER)
prefs_sync_page_setup (dialog->sync_page);
else
- gtk_notebook_remove_page (GTK_NOTEBOOK (dialog->notebook), -1);
+ gtk_container_remove (GTK_CONTAINER (dialog), GTK_WIDGET (dialog->sync_page));
ephy_gui_ensure_window_group (GTK_WINDOW (dialog));
}
diff --git a/src/preferences/ephy-prefs-dialog.h b/src/preferences/ephy-prefs-dialog.h
index cbca5f596..064cdb5f7 100644
--- a/src/preferences/ephy-prefs-dialog.h
+++ b/src/preferences/ephy-prefs-dialog.h
@@ -28,6 +28,6 @@ G_BEGIN_DECLS
#define EPHY_TYPE_PREFS_DIALOG (ephy_prefs_dialog_get_type ())
-G_DECLARE_FINAL_TYPE (EphyPrefsDialog, ephy_prefs_dialog, EPHY, PREFS_DIALOG, HdyWindow)
+G_DECLARE_FINAL_TYPE (EphyPrefsDialog, ephy_prefs_dialog, EPHY, PREFS_DIALOG, HdyPreferencesWindow)
G_END_DECLS
diff --git a/src/resources/gtk/prefs-dialog.ui b/src/resources/gtk/prefs-dialog.ui
index ec3c947d0..85a932187 100644
--- a/src/resources/gtk/prefs-dialog.ui
+++ b/src/resources/gtk/prefs-dialog.ui
@@ -1,125 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.0"/>
- <template class="EphyPrefsDialog" parent="HdyWindow">
+ <template class="EphyPrefsDialog" parent="HdyPreferencesWindow">
<property name="role">epiphany-preferences</property>
<property name="modal">True</property>
<property name="window-position">center</property>
<property name="destroy-with-parent">True</property>
<property name="icon-name">gtk-preferences</property>
- <property name="type-hint">dialog</property>
- <property name="default-width">600</property>
+ <property name="default-width">640</property>
<property name="default-height">800</property>
+ <property name="can-swipe-back">True</property>
<signal name="key-press-event" handler="on_key_press_event"/>
<signal name="delete-event" handler="on_delete_event"/>
<child>
- <object class="HdyDeck" id="deck">
- <property name="visible">True</property>
- <property name="can-swipe-back">True</property>
- <child>
- <object class="GtkBox" id="prefs_pages_view">
- <property name="visible">True</property>
- <property name="orientation">vertical</property>
- <child>
- <object class="HdyHeaderBar">
- <property name="visible">True</property>
- <property name="title" translatable="yes">Preferences</property>
- <property name="show-close-button">True</property>
- </object>
- </child>
- <child>
- <object class="GtkNotebook" id="notebook">
- <property name="visible">True</property>
- <property name="scrollable">True</property>
- <property name="show_border">False</property>
- <child>
- <object class="PrefsGeneralPage" id="general_page">
- </object>
- </child>
- <child type="tab">
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="label" translatable="yes">General</property>
- </object>
- <packing>
- <property name="tab_fill">False</property>
- </packing>
- </child>
- <child>
- <object class="PrefsPrivacyPage">
- <signal name="passwords-row-activated" handler="on_passwords_row_activated"/>
- <signal name="clear-data-row-activated" handler="on_clear_data_row_activated"/>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- <child type="tab">
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Privacy</property>
- </object>
- <packing>
- <property name="position">1</property>
- <property name="tab_fill">False</property>
- </packing>
- </child>
- <child>
- <object class="PrefsAppearancePage">
- </object>
- <packing>
- <property name="position">2</property>
- </packing>
- </child>
- <child type="tab">
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Appearance</property>
- </object>
- <packing>
- <property name="position">2</property>
- <property name="tab_fill">False</property>
- </packing>
- </child>
- <child>
- <object class="PrefsSyncPage" id="sync_page">
- </object>
- </child>
- <child type="tab">
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Sync</property>
- </object>
- <packing>
- <property name="tab_fill">False</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- </packing>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkStack" id="data_views_stack">
- <property name="transition-type">GTK_STACK_TRANSITION_TYPE_NONE</property>
- <property name="visible">True</property>
- <child>
- <object class="EphyPasswordsView" id="passwords_view">
- <property name="visible">True</property>
- <signal name="back-button-clicked" handler="on_any_data_view_back_button_clicked"/>
- </object>
- </child>
- <child>
- <object class="ClearDataView" id="clear_data_view">
- <property name="visible">True</property>
- <signal name="back-button-clicked" handler="on_any_data_view_back_button_clicked"/>
- </object>
- </child>
- </object>
- </child>
+ <object class="PrefsGeneralPage" id="general_page"/>
+ </child>
+ <child>
+ <object class="PrefsPrivacyPage">
+ <signal name="passwords-row-activated" handler="on_passwords_row_activated"/>
+ <signal name="clear-data-row-activated" handler="on_clear_data_row_activated"/>
</object>
</child>
+ <child>
+ <object class="PrefsAppearancePage"/>
+ </child>
+ <child>
+ <object class="PrefsSyncPage" id="sync_page"/>
+ </child>
</template>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]