Convert prefs dialog to a HdyPreferencesWindow
Move it to the Components package, use libhandy preferences widgets for the UI.
This commit is contained in:
parent
93311aeb1f
commit
e11e2bd279
7 changed files with 128 additions and 189 deletions
|
|
@ -37,6 +37,7 @@ src/client/components/components-entry-undo.vala
|
|||
src/client/components/components-in-app-notification.vala
|
||||
src/client/components/components-inspector.vala
|
||||
src/client/components/components-placeholder-pane.vala
|
||||
src/client/components/components-preferences-window.vala
|
||||
src/client/components/components-validator.vala
|
||||
src/client/components/count-badge.vala
|
||||
src/client/components/folder-popover.vala
|
||||
|
|
@ -73,7 +74,6 @@ src/client/dialogs/attachment-dialog.vala
|
|||
src/client/dialogs/certificate-warning-dialog.vala
|
||||
src/client/dialogs/dialogs-problem-details-dialog.vala
|
||||
src/client/dialogs/password-dialog.vala
|
||||
src/client/dialogs/preferences-dialog.vala
|
||||
src/client/dialogs/upgrade-dialog.vala
|
||||
src/client/folder-list/folder-list-abstract-folder-entry.vala
|
||||
src/client/folder-list/folder-list-account-branch.vala
|
||||
|
|
@ -440,6 +440,5 @@ ui/main-toolbar.ui
|
|||
ui/main-toolbar-menus.ui
|
||||
ui/main-window-info-bar.ui
|
||||
ui/password-dialog.glade
|
||||
ui/preferences-dialog.ui
|
||||
ui/problem-details-dialog.ui
|
||||
ui/upgrade_dialog.glade
|
||||
|
|
|
|||
|
|
@ -440,6 +440,7 @@ public class Application.Client : Gtk.Application {
|
|||
MainWindow.add_accelerators(this);
|
||||
Composer.Widget.add_accelerators(this);
|
||||
Components.Inspector.add_accelerators(this);
|
||||
Components.PreferencesWindow.add_accelerators(this);
|
||||
Dialogs.ProblemDetailsDialog.add_accelerators(this);
|
||||
|
||||
// Manually place a hold on the application otherwise the
|
||||
|
|
@ -609,10 +610,10 @@ public class Application.Client : Gtk.Application {
|
|||
public async void show_preferences() {
|
||||
yield this.present();
|
||||
|
||||
PreferencesDialog dialog = new PreferencesDialog(
|
||||
get_active_window(), this
|
||||
Components.PreferencesWindow prefs = new Components.PreferencesWindow(
|
||||
get_active_main_window()
|
||||
);
|
||||
dialog.run();
|
||||
prefs.show();
|
||||
}
|
||||
|
||||
public async void new_composer(string? mailto) {
|
||||
|
|
|
|||
122
src/client/components/components-preferences-window.vala
Normal file
122
src/client/components/components-preferences-window.vala
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
/*
|
||||
* Copyright 2016 Software Freedom Conservancy Inc.
|
||||
* Copyright 2019 Michael Gratton <mike@vee.net>
|
||||
*
|
||||
* This software is licensed under the GNU Lesser General Public License
|
||||
* (version 2.1 or later). See the COPYING file in this distribution.
|
||||
*/
|
||||
|
||||
public class Components.PreferencesWindow : Hdy.PreferencesWindow {
|
||||
|
||||
|
||||
private const string ACTION_CLOSE = "preferences-close";
|
||||
|
||||
private const ActionEntry[] WINDOW_ACTIONS = {
|
||||
{ Action.Window.CLOSE, on_close },
|
||||
{ ACTION_CLOSE, on_close },
|
||||
};
|
||||
|
||||
|
||||
public static void add_accelerators(Application.Client app) {
|
||||
app.add_window_accelerators(ACTION_CLOSE, { "Escape" } );
|
||||
}
|
||||
|
||||
|
||||
/** Returns the window's associated client application instance. */
|
||||
public new Application.Client application {
|
||||
get { return (Application.Client) base.get_application(); }
|
||||
set { base.set_application(value); }
|
||||
}
|
||||
|
||||
|
||||
public PreferencesWindow(Application.MainWindow parent) {
|
||||
Object(
|
||||
application: parent.application,
|
||||
transient_for: parent
|
||||
);
|
||||
|
||||
var autoselect = new Gtk.Switch();
|
||||
autoselect.valign = CENTER;
|
||||
|
||||
var autoselect_row = new Hdy.ActionRow();
|
||||
/// Translators: Preferences label
|
||||
autoselect_row.title = _("_Automatically select next message");
|
||||
autoselect_row.use_underline = true;
|
||||
autoselect_row.activatable_widget = autoselect;
|
||||
autoselect_row.add_action(autoselect);
|
||||
|
||||
var display_preview = new Gtk.Switch();
|
||||
display_preview.valign = CENTER;
|
||||
|
||||
var display_preview_row = new Hdy.ActionRow();
|
||||
/// Translators: Preferences label
|
||||
display_preview_row.title = _("_Display conversation preview");
|
||||
display_preview_row.use_underline = true;
|
||||
display_preview_row.activatable_widget = display_preview;
|
||||
display_preview_row.add_action(display_preview);
|
||||
|
||||
var three_pane_view = new Gtk.Switch();
|
||||
three_pane_view.valign = CENTER;
|
||||
|
||||
var three_pane_view_row = new Hdy.ActionRow();
|
||||
/// Translators: Preferences label
|
||||
three_pane_view_row.title = _("Use _three pane view");
|
||||
three_pane_view_row.use_underline = true;
|
||||
three_pane_view_row.activatable_widget = three_pane_view;
|
||||
three_pane_view_row.add_action(three_pane_view);
|
||||
|
||||
var startup_notifications = new Gtk.Switch();
|
||||
startup_notifications.valign = CENTER;
|
||||
|
||||
var startup_notifications_row = new Hdy.ActionRow();
|
||||
/// Translators: Preferences label
|
||||
startup_notifications_row.title = _("_Watch for new mail when closed");
|
||||
startup_notifications_row.use_underline = true;
|
||||
/// Translators: Preferences tooltip
|
||||
startup_notifications_row.tooltip_text = _(
|
||||
"Geary will keep running after all windows are closed"
|
||||
);
|
||||
startup_notifications_row.activatable_widget = startup_notifications;
|
||||
startup_notifications_row.add_action(startup_notifications);
|
||||
|
||||
var group = new Hdy.PreferencesGroup();
|
||||
/// Translators: Preferences group title
|
||||
//group.title = _("General");
|
||||
/// Translators: Preferences group description
|
||||
//group.description = _("General application preferences");
|
||||
group.add(autoselect_row);
|
||||
group.add(display_preview_row);
|
||||
group.add(three_pane_view_row);
|
||||
group.add(startup_notifications_row);
|
||||
|
||||
var page = new Hdy.PreferencesPage();
|
||||
page.propagate_natural_height = true;
|
||||
page.add(group);
|
||||
page.show_all();
|
||||
|
||||
add(page);
|
||||
|
||||
GLib.SimpleActionGroup window_actions = new GLib.SimpleActionGroup();
|
||||
window_actions.add_action_entries(WINDOW_ACTIONS, this);
|
||||
insert_action_group(Action.Window.GROUP_NAME, window_actions);
|
||||
|
||||
Application.Configuration config = this.application.config;
|
||||
config.bind(Application.Configuration.AUTOSELECT_KEY, autoselect, "state");
|
||||
config.bind(Application.Configuration.DISPLAY_PREVIEW_KEY, display_preview, "state");
|
||||
config.bind(Application.Configuration.FOLDER_LIST_PANE_HORIZONTAL_KEY, three_pane_view, "state");
|
||||
config.bind(Application.Configuration.STARTUP_NOTIFICATIONS_KEY, startup_notifications, "state");
|
||||
|
||||
this.delete_event.connect(on_delete);
|
||||
}
|
||||
|
||||
private void on_close() {
|
||||
close();
|
||||
}
|
||||
|
||||
private bool on_delete() {
|
||||
// Sync startup notification option with file state
|
||||
this.application.autostart.sync_with_config();
|
||||
return Gdk.EVENT_PROPAGATE;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
/* Copyright 2016 Software Freedom Conservancy Inc.
|
||||
*
|
||||
* This software is licensed under the GNU Lesser General Public License
|
||||
* (version 2.1 or later). See the COPYING file in this distribution.
|
||||
*/
|
||||
|
||||
[GtkTemplate (ui = "/org/gnome/Geary/preferences-dialog.ui")]
|
||||
public class PreferencesDialog : Gtk.Dialog {
|
||||
|
||||
[GtkChild]
|
||||
private Gtk.CheckButton autoselect;
|
||||
|
||||
[GtkChild]
|
||||
private Gtk.CheckButton display_preview;
|
||||
|
||||
[GtkChild]
|
||||
private Gtk.CheckButton three_pane_view;
|
||||
|
||||
[GtkChild]
|
||||
private Gtk.CheckButton startup_notifications;
|
||||
|
||||
[GtkChild]
|
||||
private Gtk.HeaderBar header;
|
||||
|
||||
private Application.Client app;
|
||||
|
||||
public PreferencesDialog(Gtk.Window parent, Application.Client app) {
|
||||
set_transient_for(parent);
|
||||
set_titlebar(this.header);
|
||||
this.app = app;
|
||||
|
||||
Application.Configuration config = app.config;
|
||||
config.bind(Application.Configuration.AUTOSELECT_KEY, autoselect, "active");
|
||||
config.bind(Application.Configuration.DISPLAY_PREVIEW_KEY, display_preview, "active");
|
||||
config.bind(Application.Configuration.FOLDER_LIST_PANE_HORIZONTAL_KEY, three_pane_view, "active");
|
||||
config.bind(Application.Configuration.STARTUP_NOTIFICATIONS_KEY, startup_notifications, "active");
|
||||
}
|
||||
|
||||
public new void run() {
|
||||
// Sync startup notification option with file state
|
||||
this.app.autostart.sync_with_config();
|
||||
|
||||
base.run();
|
||||
destroy();
|
||||
}
|
||||
}
|
||||
|
|
@ -37,6 +37,7 @@ geary_client_vala_sources = files(
|
|||
'components/components-inspector-log-view.vala',
|
||||
'components/components-inspector-system-view.vala',
|
||||
'components/components-placeholder-pane.vala',
|
||||
'components/components-preferences-window.vala',
|
||||
'components/components-validator.vala',
|
||||
'components/count-badge.vala',
|
||||
'components/folder-popover.vala',
|
||||
|
|
@ -78,7 +79,6 @@ geary_client_vala_sources = files(
|
|||
'dialogs/certificate-warning-dialog.vala',
|
||||
'dialogs/dialogs-problem-details-dialog.vala',
|
||||
'dialogs/password-dialog.vala',
|
||||
'dialogs/preferences-dialog.vala',
|
||||
'dialogs/upgrade-dialog.vala',
|
||||
|
||||
'folder-list/folder-list-abstract-folder-entry.vala',
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@
|
|||
<file compressed="true" preprocess="xml-stripblanks">main-toolbar-menus.ui</file>
|
||||
<file compressed="true" preprocess="xml-stripblanks">main-window-info-bar.ui</file>
|
||||
<file compressed="true" preprocess="xml-stripblanks">password-dialog.glade</file>
|
||||
<file compressed="true" preprocess="xml-stripblanks">preferences-dialog.ui</file>
|
||||
<file compressed="true" preprocess="xml-stripblanks">problem-details-dialog.ui</file>
|
||||
<file compressed="true">signature-web-view.js</file>
|
||||
<file compressed="true" preprocess="xml-stripblanks">upgrade_dialog.glade</file>
|
||||
|
|
|
|||
|
|
@ -1,136 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.22.1 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.14"/>
|
||||
<template class="PreferencesDialog" parent="GtkDialog">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="border_width">12</property>
|
||||
<property name="window_position">center-on-parent</property>
|
||||
<property name="default_height">0</property>
|
||||
<property name="type_hint">dialog</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar" id="header">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="title" translatable="yes">Preferences</property>
|
||||
<property name="has_subtitle">False</property>
|
||||
<property name="show_close_button">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child internal-child="vbox">
|
||||
<object class="GtkBox">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">2</property>
|
||||
<child internal-child="action_area">
|
||||
<object class="GtkButtonBox">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="layout_style">end</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack_type">end</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkGrid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="autoselect">
|
||||
<property name="label" translatable="yes">_Automatically select next message</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="margin_left">12</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="margin_start">12</property>
|
||||
<property name="margin_end">5</property>
|
||||
<property name="margin_top">5</property>
|
||||
<property name="margin_bottom">5</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="display_preview">
|
||||
<property name="label" translatable="yes">_Display conversation preview</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="margin_left">12</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="margin_start">12</property>
|
||||
<property name="margin_end">5</property>
|
||||
<property name="margin_top">5</property>
|
||||
<property name="margin_bottom">5</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="three_pane_view">
|
||||
<property name="label" translatable="yes">Use _three pane view</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="margin_left">12</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="margin_start">12</property>
|
||||
<property name="margin_end">5</property>
|
||||
<property name="margin_top">5</property>
|
||||
<property name="margin_bottom">5</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="startup_notifications">
|
||||
<property name="label" translatable="yes">_Watch for new mail when closed</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="tooltip_text" translatable="yes">Geary will keep running after all windows are closed</property>
|
||||
<property name="margin_left">12</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="margin_start">12</property>
|
||||
<property name="margin_end">5</property>
|
||||
<property name="margin_top">5</property>
|
||||
<property name="margin_bottom">5</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
</interface>
|
||||
Loading…
Add table
Add a link
Reference in a new issue