diff options
author | Niels De Graef <nielsdegraef@gmail.com> | 2022-09-07 10:40:06 +0200 |
---|---|---|
committer | Niels De Graef <nielsdegraef@gmail.com> | 2022-09-08 07:16:50 +0200 |
commit | ca63c4912bd5f161b5bfc8067f40f3715fc97b88 (patch) | |
tree | a3ab8d38c02f860f40d6a391311bea53eae4f42b | |
parent | 4ec2456f9fbc43ff8403e244a22d40a0aa514af5 (diff) | |
download | gnome-contacts-ca63c4912bd5f161b5bfc8067f40f3715fc97b88.tar.gz |
utils: Cleanup and remove all Gtk/Adw related methods
We had quite a few functions that were no longer being used or had only
one specific user (so we can remove it from the generic `Utils`
namespace).
Finally, by removing all UI-related functions (those using GTK or
libadwaita) we allow moving it into the "core" library
-rw-r--r-- | src/contacts-avatar-selector.vala | 8 | ||||
-rw-r--r-- | src/contacts-contact-editor.vala | 8 | ||||
-rw-r--r-- | src/contacts-linked-personas-dialog.vala | 4 | ||||
-rw-r--r-- | src/contacts-type-combo.vala | 9 | ||||
-rw-r--r-- | src/contacts-utils.vala | 29 | ||||
-rw-r--r-- | src/core/contacts-type-set.vala | 17 |
6 files changed, 16 insertions, 59 deletions
diff --git a/src/contacts-avatar-selector.vala b/src/contacts-avatar-selector.vala index cfe92aa..4660351 100644 --- a/src/contacts-avatar-selector.vala +++ b/src/contacts-avatar-selector.vala @@ -232,8 +232,12 @@ public class Contacts.AvatarSelector : Gtk.Dialog { } } catch (GLib.Error e) { warning ("Failed to set avatar: %s", e.message); - Utils.show_error_dialog (_("Failed to set avatar."), - this.get_root () as Gtk.Window); + var dialog = new Adw.MessageDialog (get_root () as Gtk.Window, + null, + _("Failed to set avatar.")); + dialog.add_response ("close", _("_Close")); + dialog.default_response = "close"; + dialog.show(); } finally { chooser.destroy (); } diff --git a/src/contacts-contact-editor.vala b/src/contacts-contact-editor.vala index e7f9fc6..5509646 100644 --- a/src/contacts-contact-editor.vala +++ b/src/contacts-contact-editor.vala @@ -110,8 +110,12 @@ public class Contacts.ContactEditor : Gtk.Widget { avatar_selector.set_avatar_on_contact (); } catch (Error e) { warning ("Failed to set avatar: %s", e.message); - Utils.show_error_dialog (_("Failed to set avatar."), - get_root () as Gtk.Window); + var dialog = new Adw.MessageDialog (get_root () as Gtk.Window, + null, + _("Failed to set avatar.")); + dialog.add_response ("close", _("_Close")); + dialog.default_response = "close"; + dialog.show(); } } avatar_selector.destroy (); diff --git a/src/contacts-linked-personas-dialog.vala b/src/contacts-linked-personas-dialog.vala index 7d87095..f010554 100644 --- a/src/contacts-linked-personas-dialog.vala +++ b/src/contacts-linked-personas-dialog.vala @@ -86,4 +86,8 @@ public class Contacts.LinkedPersonasDialog : Gtk.Dialog { return row_grid; } + + private void add_separator (Gtk.ListBoxRow row, Gtk.ListBoxRow? before_row) { + row.set_header (new Gtk.Separator (Gtk.Orientation.HORIZONTAL)); + } } diff --git a/src/contacts-type-combo.vala b/src/contacts-type-combo.vala index 2940a5e..67d68b9 100644 --- a/src/contacts-type-combo.vala +++ b/src/contacts-type-combo.vala @@ -44,15 +44,6 @@ public class Contacts.TypeComboRow : Adw.ComboRow { } /** - * Sets the value to the type of the given {@link Folks.AbstractFieldDetails}. - */ - public void set_selected_from_field_details (AbstractFieldDetails details) { - uint position = 0; - this.type_set.lookup_by_field_details (details, out position); - this.selected = position; - } - - /** * Sets the value to the type that best matches the given vcard type * (for example "HOME" or "WORK"). */ diff --git a/src/contacts-utils.vala b/src/contacts-utils.vala index 7edaa7c..ec38207 100644 --- a/src/contacts-utils.vala +++ b/src/contacts-utils.vala @@ -17,12 +17,6 @@ using Folks; -namespace Contacts { - public void add_separator (Gtk.ListBoxRow row, Gtk.ListBoxRow? before_row) { - row.set_header (new Gtk.Separator (Gtk.Orientation.HORIZONTAL)); - } -} - namespace Contacts.Utils { public void set_primary_store (Edsf.PersonaStore e_store) { @@ -38,15 +32,6 @@ namespace Contacts.Utils { return null; } - public void grab_entry_focus_no_select (Gtk.SearchEntry entry) { - int start, end; - if (!entry.get_selection_bounds (out start, out end)) { - start = end = entry.get_position (); - } - entry.grab_focus (); - entry.select_region (start, end); - } - public string[] get_stock_avatars () { string[] files = {}; var system_data_dirs = Environment.get_system_data_dirs (); @@ -69,13 +54,6 @@ namespace Contacts.Utils { return files; } - public void show_error_dialog (string error, Gtk.Window toplevel) { - var dialog = new Adw.MessageDialog (toplevel, null, error); - dialog.add_response ("close", _("_Close")); - dialog.default_response = "close"; - dialog.show(); - } - public bool persona_is_main (Persona persona) { var store = persona.store; if (!store.is_primary_store) @@ -125,13 +103,6 @@ namespace Contacts.Utils { return !has_main_persona (self) || !has_mainable_persona (other); } - public ListModel fields_to_sorted (Gee.Collection<AbstractFieldDetails> fields) { - var res = new ListStore (typeof (AbstractFieldDetails)); - foreach (var afd in fields) - res.append (afd); - return new Gtk.SortListModel ((owned) res, new AbstractFieldDetailsSorter ()); - } - /* We claim something is "removable" if at least one persona is removable, that will typically unlink the rest. */ public bool can_remove_personas (Individual individual) { diff --git a/src/core/contacts-type-set.vala b/src/core/contacts-type-set.vala index 8e46299..94877db 100644 --- a/src/core/contacts-type-set.vala +++ b/src/core/contacts-type-set.vala @@ -44,14 +44,6 @@ public class Contacts.TypeSet : Object, GLib.ListModel { } /** - * Returns the display name for the type of the given AbstractFieldDetails. - */ - public unowned string format_type (AbstractFieldDetails detail) { - var d = lookup_by_field_details (detail); - return d.display_name; - } - - /** * Adds the TypeDescriptor to the {@link TypeSet}'s store. * @param descriptor The TypeDescription to be added */ @@ -138,15 +130,6 @@ public class Contacts.TypeSet : Object, GLib.ListModel { } /** - * Looks up the TypeDescriptor for the given field details. If the descriptor - * is not found, it will be created and returned, so this never returns null. - */ - public TypeDescriptor lookup_by_field_details (AbstractFieldDetails detail, - out uint position = null) { - return lookup_by_parameters (detail.parameters, out position); - } - - /** * Looks up the TypeDescriptor for the given parameters. If the descriptor * is not found, it will be created and returned, so this never returns null. */ |