client: Port client codebase to handy-1

This commit is contained in:
Michael Gratton 2020-08-17 09:48:09 +10:00 committed by Michael James Gratton
parent 2d12b25e2c
commit 5b097c3076
9 changed files with 67 additions and 24 deletions

View file

@ -390,6 +390,7 @@ public class Application.Client : Gtk.Application {
// Calls Gtk.init(), amongst other things
base.startup();
Hdy.init();
this.engine = new Geary.Engine(get_resource_directory());
this.config = new Configuration(SCHEMA_ID);
@ -967,7 +968,7 @@ public class Application.Client : Gtk.Application {
this,
new Geary.ProblemReport(err)
);
dialog.run();
dialog.show();
}
if (mutex_token != Geary.Nonblocking.Mutex.INVALID_TOKEN) {

View file

@ -35,7 +35,7 @@ public class Components.PreferencesWindow : Hdy.PreferencesWindow {
this.title = plugin.get_name();
this.subtitle = plugin.get_description();
this.activatable_widget = this.sw;
this.add_action(this.sw);
this.add(this.sw);
plugins.plugin_activated.connect((info) => {
if (this.plugin == info) {
@ -124,7 +124,7 @@ public class Components.PreferencesWindow : Hdy.PreferencesWindow {
autoselect_row.title = _("_Automatically select next message");
autoselect_row.use_underline = true;
autoselect_row.activatable_widget = autoselect;
autoselect_row.add_action(autoselect);
autoselect_row.add(autoselect);
var display_preview = new Gtk.Switch();
display_preview.valign = CENTER;
@ -134,7 +134,7 @@ public class Components.PreferencesWindow : Hdy.PreferencesWindow {
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);
display_preview_row.add(display_preview);
var three_pane_view = new Gtk.Switch();
three_pane_view.valign = CENTER;
@ -144,7 +144,7 @@ public class Components.PreferencesWindow : Hdy.PreferencesWindow {
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);
three_pane_view_row.add(three_pane_view);
var single_key_shortucts = new Gtk.Switch();
single_key_shortucts.valign = CENTER;
@ -157,7 +157,7 @@ public class Components.PreferencesWindow : Hdy.PreferencesWindow {
);
single_key_shortucts_row.use_underline = true;
single_key_shortucts_row.activatable_widget = single_key_shortucts;
single_key_shortucts_row.add_action(single_key_shortucts);
single_key_shortucts_row.add(single_key_shortucts);
var startup_notifications = new Gtk.Switch();
startup_notifications.valign = CENTER;
@ -171,7 +171,7 @@ public class Components.PreferencesWindow : Hdy.PreferencesWindow {
"Geary will keep running after all windows are closed"
);
startup_notifications_row.activatable_widget = startup_notifications;
startup_notifications_row.add_action(startup_notifications);
startup_notifications_row.add(startup_notifications);
var group = new Hdy.PreferencesGroup();
/// Translators: Preferences group title
@ -188,8 +188,6 @@ public class Components.PreferencesWindow : Hdy.PreferencesWindow {
/// Translators: Preferences page title
page.title = _("Preferences");
page.icon_name = "preferences-other-symbolic";
page.propagate_natural_height = true;
page.propagate_natural_width = true;
page.add(group);
page.show_all();
@ -251,13 +249,59 @@ public class Components.PreferencesWindow : Hdy.PreferencesWindow {
/// Translators: Preferences page title
page.title = _("Plugins");
page.icon_name = "application-x-addon-symbolic";
page.propagate_natural_width = true;
page.add(group);
page.show_all();
add(page);
}
private Hdy.ActionRow new_plugin_row(Peas.PluginInfo plugin) {
var @switch = new Gtk.Switch();
@switch.active = plugin.is_loaded();
@switch.notify["active"].connect_after(
() => enable_plugin(plugin, switch)
);
@switch.valign = CENTER;
var row = new Hdy.ActionRow();
row.title = plugin.get_name();
row.subtitle = plugin.get_description();
row.activatable_widget = @switch;
row.add(@switch);
return row;
}
private void enable_plugin(Peas.PluginInfo plugin, Gtk.Switch @switch) {
if (@switch.active && !plugin.is_loaded()) {
bool loaded = false;
try {
loaded = this.plugins.load_optional(plugin);
} catch (GLib.Error err) {
warning(
"Plugin %s not able to be loaded: %s",
plugin.get_name(), err.message
);
}
if (!loaded) {
@switch.active = false;
}
} else if (!@switch.active && plugin.is_loaded()) {
bool unloaded = false;
try {
unloaded = this.plugins.unload_optional(plugin);
} catch (GLib.Error err) {
warning(
"Plugin %s not able to be loaded: %s",
plugin.get_name(), err.message
);
}
if (!unloaded) {
@switch.active = true;
}
}
}
private void on_close() {
close();
}

View file

@ -113,8 +113,7 @@ public class Components.ProblemReportInfoBar : InfoBar {
main.application,
this.report
);
dialog.run();
dialog.destroy();
dialog.show();
}
}

View file

@ -39,8 +39,8 @@ public class SearchBar : Hdy.SearchBar {
this.entry.placeholder_text = DEFAULT_SEARCH_TEXT;
this.entry.has_focus = true;
var column = new Hdy.Column();
column.maximum_width = 450;
var column = new Hdy.Clamp();
column.maximum_size = 450;
column.add(this.entry);
connect_entry(this.entry);

View file

@ -95,13 +95,13 @@ public class MainToolbar : Gtk.Box {
public void set_conversation_header(Gtk.HeaderBar header) {
conversation_header.hide();
this.header_group.add_header_bar(header);
this.header_group.add_gtk_header_bar(header);
pack_start(header, true, true);
}
public void remove_conversation_header(Gtk.HeaderBar header) {
remove(header);
this.header_group.remove_header_bar(header);
this.header_group.remove_gtk_header_bar(header);
conversation_header.show();
}

View file

@ -9,7 +9,7 @@
* Displays technical details when a problem has been reported.
*/
[GtkTemplate (ui = "/org/gnome/Geary/problem-details-dialog.ui")]
public class Dialogs.ProblemDetailsDialog : Hdy.Dialog {
public class Dialogs.ProblemDetailsDialog : Gtk.Dialog {
private const string ACTION_CLOSE = "problem-details-close";

View file

@ -7,15 +7,13 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="HdyColumn">
<object class="HdyClamp">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">16</property>
<property name="margin_right">16</property>
<property name="margin_top">32</property>
<property name="margin_bottom">32</property>
<property name="maximum_width">500</property>
<property name="linear_growth_width">1</property>
<child>
<object class="GtkGrid">
<property name="visible">True</property>

View file

@ -19,15 +19,13 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="HdyColumn">
<object class="HdyClamp">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">16</property>
<property name="margin_right">16</property>
<property name="margin_top">32</property>
<property name="margin_bottom">32</property>
<property name="maximum_width">500</property>
<property name="linear_growth_width">1</property>
<child>
<object class="GtkFrame">
<property name="visible">True</property>

View file

@ -3,8 +3,11 @@
<interface>
<requires lib="gtk+" version="3.20"/>
<requires lib="libhandy" version="0.0"/>
<template class="DialogsProblemDetailsDialog" parent="HdyDialog">
<template class="DialogsProblemDetailsDialog" parent="GtkDialog">
<property name="can_focus">False</property>
<property name="modal">True</property>
<property name="type_hint">dialog</property>
<property name="window_position">center</property>
<child type="titlebar">
<object class="GtkHeaderBar">
<property name="visible">True</property>