[geary/mjog/port-to-libhandy-1: 5/10] client: Port client codebase to handy-1
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/port-to-libhandy-1: 5/10] client: Port client codebase to handy-1
- Date: Tue, 18 Aug 2020 12:19:17 +0000 (UTC)
commit 58d7436a53589dae9f4b66828d9fb470de744768
Author: Michael Gratton <mike vee net>
Date: Mon Aug 17 09:48:09 2020 +1000
client: Port client codebase to handy-1
src/client/application/application-client.vala | 3 +-
.../components/components-preferences-window.vala | 62 ++++++++++++++++++----
.../components-problem-report-info-bar.vala | 3 +-
src/client/components/components-search-bar.vala | 4 +-
src/client/components/main-toolbar.vala | 4 +-
.../dialogs/dialogs-problem-details-dialog.vala | 2 +-
ui/components-inspector-error-view.ui | 4 +-
ui/components-inspector-system-view.ui | 4 +-
ui/problem-details-dialog.ui | 5 +-
9 files changed, 67 insertions(+), 24 deletions(-)
---
diff --git a/src/client/application/application-client.vala b/src/client/application/application-client.vala
index ff7b15b5b..430027282 100644
--- a/src/client/application/application-client.vala
+++ b/src/client/application/application-client.vala
@@ -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) {
diff --git a/src/client/components/components-preferences-window.vala
b/src/client/components/components-preferences-window.vala
index 65edae644..2fcb8ca9c 100644
--- a/src/client/components/components-preferences-window.vala
+++ b/src/client/components/components-preferences-window.vala
@@ -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();
}
diff --git a/src/client/components/components-problem-report-info-bar.vala
b/src/client/components/components-problem-report-info-bar.vala
index 63a6dfa1a..d2042f8c3 100644
--- a/src/client/components/components-problem-report-info-bar.vala
+++ b/src/client/components/components-problem-report-info-bar.vala
@@ -113,8 +113,7 @@ public class Components.ProblemReportInfoBar : InfoBar {
main.application,
this.report
);
- dialog.run();
- dialog.destroy();
+ dialog.show();
}
}
diff --git a/src/client/components/components-search-bar.vala
b/src/client/components/components-search-bar.vala
index 3988a2aab..c5f1076af 100644
--- a/src/client/components/components-search-bar.vala
+++ b/src/client/components/components-search-bar.vala
@@ -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);
diff --git a/src/client/components/main-toolbar.vala b/src/client/components/main-toolbar.vala
index 2a160f8b2..31f87df6c 100644
--- a/src/client/components/main-toolbar.vala
+++ b/src/client/components/main-toolbar.vala
@@ -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();
}
diff --git a/src/client/dialogs/dialogs-problem-details-dialog.vala
b/src/client/dialogs/dialogs-problem-details-dialog.vala
index 2dcfcb0c8..34e4cb9c3 100644
--- a/src/client/dialogs/dialogs-problem-details-dialog.vala
+++ b/src/client/dialogs/dialogs-problem-details-dialog.vala
@@ -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";
diff --git a/ui/components-inspector-error-view.ui b/ui/components-inspector-error-view.ui
index 133402354..78df053ee 100644
--- a/ui/components-inspector-error-view.ui
+++ b/ui/components-inspector-error-view.ui
@@ -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>
diff --git a/ui/components-inspector-system-view.ui b/ui/components-inspector-system-view.ui
index 8ef50dc40..e470f9d57 100644
--- a/ui/components-inspector-system-view.ui
+++ b/ui/components-inspector-system-view.ui
@@ -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>
diff --git a/ui/problem-details-dialog.ui b/ui/problem-details-dialog.ui
index 5e667fed5..bb3e03066 100644
--- a/ui/problem-details-dialog.ui
+++ b/ui/problem-details-dialog.ui
@@ -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>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]