diff options
author | Niels De Graef <nielsdegraef@gmail.com> | 2020-11-30 21:22:08 +0100 |
---|---|---|
committer | Niels De Graef <nielsdegraef@gmail.com> | 2020-11-30 21:25:19 +0100 |
commit | e0671976f2d3628cb488e911b8ab4cc00193698d (patch) | |
tree | 41daee7d9d9efdc8a6db2785edc5fc4483e0e5d5 | |
parent | 687adab8db19f1534007c1a0416ae836f80d60b6 (diff) | |
download | gnome-contacts-e0671976f2d3628cb488e911b8ab4cc00193698d.tar.gz |
Import only the Folks namspace
This commit removes all remaining occurrences `using Gtk;`, `using Gee;`
and `using Hdy;`. There's a number of reasons why we're doing this, but
to list a few:
* The `Gtk` and `Hdy` namespaces have had issues before with types
having the same name (ie HdyHeaderBar and GtkHeaderBar) which could
suddenly break the build.
* By omitting namespaces, it's harder to see for new contributors what
the actual type is of a certain variable when they want to look up the
API
* In the long term, we want to get rid of Gee, as it's clear that it's
not really maintained, and has some serious performance drawbacks.
24 files changed, 310 insertions, 338 deletions
diff --git a/src/contacts-accounts-list.vala b/src/contacts-accounts-list.vala index 7e96657..4c9a0f6 100644 --- a/src/contacts-accounts-list.vala +++ b/src/contacts-accounts-list.vala @@ -15,13 +15,11 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -using Gtk; -using Hdy; using Folks; [GtkTemplate (ui = "/org/gnome/Contacts/ui/contacts-accounts-list.ui")] -public class Contacts.AccountsList : ListBox { - private ListBoxRow last_selected_row; +public class Contacts.AccountsList : Gtk.ListBox { + private Gtk.ListBoxRow last_selected_row; private Store contacts_store; @@ -36,7 +34,7 @@ public class Contacts.AccountsList : ListBox { this.set_header_func (add_separator); } - public override void row_activated (ListBoxRow row) { + public override void row_activated (Gtk.ListBoxRow row) { if (row == null) return; @@ -45,11 +43,11 @@ public class Contacts.AccountsList : ListBox { return; } - var checkmark = row.get_data<Image> ("checkmark"); + var checkmark = row.get_data<Gtk.Image> ("checkmark"); checkmark.show (); if (last_selected_row != null) { - checkmark = last_selected_row.get_data<Image> ("checkmark"); + checkmark = last_selected_row.get_data<Gtk.Image> ("checkmark"); if (checkmark != null) checkmark.hide (); } @@ -89,23 +87,25 @@ public class Contacts.AccountsList : ListBox { source_account_id = goa_source_ext.account_id; } - var row = new ActionRow (); + var row = new Hdy.ActionRow (); row.set_data ("store", persona_store); Gtk.Image provider_image; if (source_account_id != "") provider_image = Contacts.get_icon_for_goa_account (source_account_id); else - provider_image = new Image.from_icon_name (Config.APP_ID, IconSize.DIALOG); + provider_image = new Gtk.Image.from_icon_name (Config.APP_ID, + Gtk.IconSize.DIALOG); row.add_prefix (provider_image); row.title = provider_name; row.subtitle = parent_source.display_name; row.show_all (); row.no_show_all = true; - var checkmark = new Image.from_icon_name ("object-select-symbolic", IconSize.MENU); + var checkmark = new Gtk.Image.from_icon_name ("object-select-symbolic", + Gtk.IconSize.MENU); checkmark.set ("margin-end", 6, - "valign", Align.CENTER, - "halign", Align.END, + "valign", Gtk.Align.CENTER, + "halign", Gtk.Align.END, "vexpand", true, "hexpand", true); row.add (checkmark); @@ -120,16 +120,17 @@ public class Contacts.AccountsList : ListBox { } if (local_store != null) { - var local_row = new ActionRow (); - var provider_image = new Image.from_icon_name (Config.APP_ID, IconSize.DIALOG); + var local_row = new Hdy.ActionRow (); + var provider_image = new Gtk.Image.from_icon_name (Config.APP_ID, + Gtk.IconSize.DIALOG); local_row.add_prefix (provider_image); local_row.title = _("Local Address Book"); local_row.show_all (); local_row.no_show_all = true; - var checkmark = new Image.from_icon_name ("object-select-symbolic", IconSize.MENU); + var checkmark = new Gtk.Image.from_icon_name ("object-select-symbolic", Gtk.IconSize.MENU); checkmark.set ("margin-end", 6, - "valign", Align.CENTER, - "halign", Align.END, + "valign", Gtk.Align.CENTER, + "halign", Gtk.Align.END, "vexpand", true, "hexpand", true); local_row.add (checkmark); diff --git a/src/contacts-avatar-selector.vala b/src/contacts-avatar-selector.vala index 34dc412..fb83e37 100644 --- a/src/contacts-avatar-selector.vala +++ b/src/contacts-avatar-selector.vala @@ -15,7 +15,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -using Gtk; using Folks; /** @@ -26,7 +25,7 @@ using Folks; * After a user has initially chosen an avatar, we provide a cropping tool. */ [GtkTemplate (ui = "/org/gnome/Contacts/ui/contacts-avatar-selector.ui")] -public class Contacts.AvatarSelector : Popover { +public class Contacts.AvatarSelector : Gtk.Popover { const int ICONS_SIZE = 64; const int MAIN_SIZE = 128; const string AVATAR_BUTTON_CSS_NAME = "avatar-button"; @@ -36,13 +35,13 @@ public class Contacts.AvatarSelector : Popover { private Individual individual; [GtkChild] - private FlowBox personas_thumbnail_grid; + private Gtk.FlowBox personas_thumbnail_grid; [GtkChild] - private FlowBox stock_thumbnail_grid; + private Gtk.FlowBox stock_thumbnail_grid; #if HAVE_CHEESE [GtkChild] - private Button cheese_button; + private Gtk.Button cheese_button; private int num_cameras; private Cheese.CameraDeviceMonitor camera_monitor; #endif @@ -116,25 +115,25 @@ public class Contacts.AvatarSelector : Popover { } } - private FlowBoxChild create_thumbnail (Gdk.Pixbuf source_pixbuf) { + private Gtk.FlowBoxChild create_thumbnail (Gdk.Pixbuf source_pixbuf) { var avatar = new Avatar (ICONS_SIZE); avatar.set_pixbuf (source_pixbuf); - var button = new Button (); + var button = new Gtk.Button (); button.get_style_context ().add_class (AVATAR_BUTTON_CSS_NAME); button.image = avatar; button.clicked.connect ( () => { selected_pixbuf (scale_pixbuf_for_avatar_use (source_pixbuf)); this.popdown (); }); - var child = new FlowBoxChild (); + var child = new Gtk.FlowBoxChild (); child.add (button); - child.set_halign (Align.START); + child.set_halign (Gtk.Align.START); return child; } - private FlowBoxChild? thumbnail_for_persona (Persona persona) { + private Gtk.FlowBoxChild? thumbnail_for_persona (Persona persona) { var details = persona as AvatarDetails; if (details == null || details.avatar == null) return null; @@ -149,7 +148,7 @@ public class Contacts.AvatarSelector : Popover { return null; } - private FlowBoxChild? thumbnail_for_filename (string filename) { + private Gtk.FlowBoxChild? thumbnail_for_filename (string filename) { try { return create_thumbnail (new Gdk.Pixbuf.from_file (filename)); } catch (Error e) { @@ -179,7 +178,7 @@ public class Contacts.AvatarSelector : Popover { } [GtkCallback] - private void on_cheese_clicked (Button button) { + private void on_cheese_clicked (Gtk.Button button) { var dialog = new CropCheeseDialog.for_cheese ((Window) this.get_toplevel()); dialog.show_all (); dialog.picture_selected.connect ( (pix) => { @@ -189,14 +188,14 @@ public class Contacts.AvatarSelector : Popover { } [GtkCallback] - private void on_file_clicked (Button button) { - var chooser = new FileChooserNative (_("Browse for more pictures"), - (Gtk.Window)this.get_toplevel (), - FileChooserAction.OPEN, - _("_Open"), _("_Cancel")); + private void on_file_clicked (Gtk.Button button) { + var chooser = new Gtk.FileChooserNative (_("Browse for more pictures"), + (Gtk.Window) this.get_toplevel (), + Gtk.FileChooserAction.OPEN, + _("_Open"), _("_Cancel")); chooser.set_modal (true); chooser.set_local_only (false); - var preview = new Image (); + var preview = new Gtk.Image (); preview.set_size_request (MAIN_SIZE, -1); chooser.set_preview_widget (preview); chooser.set_use_preview_label (false); @@ -209,7 +208,7 @@ public class Contacts.AvatarSelector : Popover { chooser.set_current_folder (folder); chooser.response.connect ( (response) => { - if (response != ResponseType.ACCEPT) { + if (response != Gtk.ResponseType.ACCEPT) { chooser.destroy (); return; } @@ -241,12 +240,12 @@ public class Contacts.AvatarSelector : Popover { this.popdown(); } - private void update_preview (FileChooser chooser) { + private void update_preview (Gtk.FileChooser chooser) { var uri = chooser.get_preview_uri (); if (uri != null) { Gdk.Pixbuf? pixbuf = null; - var preview = chooser.get_preview_widget () as Image; + var preview = chooser.get_preview_widget () as Gtk.Image; var file = File.new_for_uri (uri); try { @@ -262,13 +261,14 @@ public class Contacts.AvatarSelector : Popover { debug ("Couldn't generate thumbnail for file '%s': %s", uri, e.message); } - if (chooser is Dialog) - ((Dialog) chooser).set_response_sensitive (ResponseType.ACCEPT, (pixbuf != null)); + if (chooser is Gtk.Dialog) + ((Gtk.Dialog) chooser).set_response_sensitive (Gtk.ResponseType.ACCEPT, + (pixbuf != null)); if (pixbuf != null) preview.set_from_pixbuf (pixbuf); else - preview.set_from_icon_name ("dialog-question", IconSize.DIALOG); + preview.set_from_icon_name ("dialog-question", Gtk.IconSize.DIALOG); } chooser.set_preview_widget_active (true); diff --git a/src/contacts-avatar.vala b/src/contacts-avatar.vala index cfb32cd..3365306 100644 --- a/src/contacts-avatar.vala +++ b/src/contacts-avatar.vala @@ -16,7 +16,6 @@ */ using Folks; -using Gee; /** * The Avatar of a Contact is responsible for showing an {@link Folks.Individual}'s diff --git a/src/contacts-contact-list.vala b/src/contacts-contact-list.vala index 96f49f6..07103af 100644 --- a/src/contacts-contact-list.vala +++ b/src/contacts-contact-list.vala @@ -16,7 +16,6 @@ */ using Folks; -using Gee; /** * The ContactList is the actual list of {@link Individual}s that the user sees on @@ -278,8 +277,8 @@ public class Contacts.ContactList : Gtk.ListBox { return null; } - public LinkedList<Individual> get_marked_contacts () { - var cs = new LinkedList<Individual> (); + public Gee.LinkedList<Individual> get_marked_contacts () { + var cs = new Gee.LinkedList<Individual> (); foreach (weak Gtk.Widget widget in get_children ()) { unowned var row = widget as ContactDataRow; if (row.selector_button.active) @@ -288,8 +287,8 @@ public class Contacts.ContactList : Gtk.ListBox { return cs; } - public LinkedList<Individual> get_marked_contacts_and_hide () { - var cs = new LinkedList<Individual> (); + public Gee.LinkedList<Individual> get_marked_contacts_and_hide () { + var cs = new Gee.LinkedList<Individual> (); foreach (weak Gtk.Widget widget in get_children ()) { unowned var row = widget as ContactDataRow; if (row.selector_button.active) { diff --git a/src/contacts-contact-pane.vala b/src/contacts-contact-pane.vala index 7b3a6e6..6ab9c2c 100644 --- a/src/contacts-contact-pane.vala +++ b/src/contacts-contact-pane.vala @@ -15,9 +15,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -using Gtk; using Folks; -using Gee; const int PROFILE_SIZE = 128; @@ -27,26 +25,26 @@ const int PROFILE_SIZE = 128; * and a ContactEditor to edit contact information. */ [GtkTemplate (ui = "/org/gnome/Contacts/ui/contacts-contact-pane.ui")] -public class Contacts.ContactPane : ScrolledWindow { +public class Contacts.ContactPane : Gtk.ScrolledWindow { - private Window parent_window; + private Contacts.Window parent_window; private Store store; public Individual? individual { get; set; default = null; } [GtkChild] - private Stack stack; + private Gtk.Stack stack; [GtkChild] - private Grid none_selected_page; + private Gtk.Grid none_selected_page; [GtkChild] - private Container contact_sheet_page; + private Gtk.Container contact_sheet_page; private ContactSheet? sheet = null; [GtkChild] - private Box contact_editor_page; + private Gtk.Box contact_editor_page; private ContactEditor? editor = null; public bool on_edit_mode = false; @@ -60,13 +58,13 @@ public class Contacts.ContactPane : ScrolledWindow { public signal void display_name_changed (string new_display_name); - public ContactPane (Window parent_window, Store contacts_store) { + public ContactPane (Contacts.Window parent_window, Store contacts_store) { this.parent_window = parent_window; this.store = contacts_store; } public void add_suggestion (Individual i) { - var parent_overlay = this.get_parent () as Overlay; + var parent_overlay = this.get_parent () as Gtk.Overlay; remove_suggestion_grid (); this.suggestion_grid = new LinkSuggestionGrid (i); @@ -75,7 +73,7 @@ public class Contacts.ContactPane : ScrolledWindow { this.suggestion_grid.suggestion_accepted.connect ( () => { var linked_contact = this.individual.display_name; var operation = new LinkOperation (this.store); - var to_link = new LinkedList<Individual> (); + var to_link = new Gee.LinkedList<Individual> (); to_link.add (this.individual); to_link.add (i); operation.execute.begin (to_link); @@ -217,7 +215,7 @@ public class Contacts.ContactPane : ScrolledWindow { } var fake_persona = new FakePersona (FakePersonaStore.the_store(), writeable_properties, details); - var fake_personas = new HashSet<FakePersona> (); + var fake_personas = new Gee.HashSet<FakePersona> (); fake_personas.add (fake_persona); this.individual = new FakeIndividual(fake_personas); @@ -258,11 +256,11 @@ public class Contacts.ContactPane : ScrolledWindow { private void show_message_dialog (string message) { var dialog = - new MessageDialog (this.parent_window, - DialogFlags.DESTROY_WITH_PARENT | DialogFlags.MODAL, - MessageType.ERROR, - ButtonsType.OK, - "%s", message); + new Gtk.MessageDialog (this.parent_window, + Gtk.DialogFlags.DESTROY_WITH_PARENT | Gtk.DialogFlags.MODAL, + Gtk.MessageType.ERROR, + Gtk.ButtonsType.OK, + "%s", message); dialog.run (); dialog.destroy (); } diff --git a/src/contacts-contact-sheet.vala b/src/contacts-contact-sheet.vala index 669e771..813d26c 100644 --- a/src/contacts-contact-sheet.vala +++ b/src/contacts-contact-sheet.vala @@ -15,16 +15,14 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -using Gtk; using Folks; -using Gee; /** * The contact sheet displays the actual information of a contact. * * (Note: to edit a contact, use the {@link ContactEditor} instead. */ -public class Contacts.ContactSheet : Grid { +public class Contacts.ContactSheet : Gtk.Grid { private int last_row = 0; private Individual individual; private unowned Store store; @@ -53,51 +51,54 @@ public class Contacts.ContactSheet : Grid { update (); } - private Label create_persona_store_label (Persona p) { - var store_name = new Label (Utils.format_persona_store_name_for_contact (p)); + private Gtk.Label create_persona_store_label (Persona p) { + var store_name = new Gtk.Label (Utils.format_persona_store_name_for_contact (p)); var attrList = new Pango.AttrList (); attrList.insert (Pango.attr_weight_new (Pango.Weight.BOLD)); store_name.set_attributes (attrList); - store_name.set_halign (Align.START); + store_name.set_halign (Gtk.Align.START); store_name.set_ellipsize (Pango.EllipsizeMode.MIDDLE); return store_name; } - private Button create_button (string icon) { - var button = new Button.from_icon_name (icon, IconSize.BUTTON); - button.set_halign (Align.END); + private Gtk.Button create_button (string icon) { + var button = new Gtk.Button.from_icon_name (icon, Gtk.IconSize.BUTTON); + button.set_halign (Gtk.Align.END); button.get_style_context ().add_class ("flatten"); return button; } - void add_row_with_label (string label_value, string value, Widget? btn1 = null, Widget? btn2 =null) { + void add_row_with_label (string label_value, + string value, + Gtk.Widget? btn1 = null, + Gtk.Widget? btn2 =null) { if (value == "" || value == null) return; - var type_label = new Label (label_value); + var type_label = new Gtk.Label (label_value); type_label.xalign = 1.0f; - type_label.set_halign (Align.END); - type_label.set_valign (Align.CENTER); + type_label.set_halign (Gtk.Align.END); + type_label.set_valign (Gtk.Align.CENTER); type_label.get_style_context ().add_class ("dim-label"); this.attach (type_label, 0, this.last_row, 1, 1); - var value_label = new Label (value); + var value_label = new Gtk.Label (value); value_label.set_line_wrap (true); value_label.xalign = 0.0f; - value_label.set_halign (Align.START); + value_label.set_halign (Gtk.Align.START); value_label.set_ellipsize (Pango.EllipsizeMode.END); value_label.wrap_mode = Pango.WrapMode.CHAR; value_label.set_selectable (true); if (btn1 != null || btn2 !=null) { - var value_box = new Box(Orientation.HORIZONTAL, 12); - value_box.pack_start(value_label, false, false, 0); + var value_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 12); + value_box.pack_start (value_label, false, false, 0); if (btn1 != null) - value_box.pack_end(btn1, false, false, 0); + value_box.pack_end (btn1, false, false, 0); if (btn2 != null) - value_box.pack_end(btn2, false, false, 0); + value_box.pack_end (btn2, false, false, 0); this.attach (value_box, 1, this.last_row, 1, 1); } else { this.attach (value_label, 1, this.last_row, 1, 1); @@ -111,7 +112,7 @@ public class Contacts.ContactSheet : Grid { var image_frame = new Avatar (PROFILE_SIZE, this.individual); image_frame.set_vexpand (false); - image_frame.set_valign (Align.START); + image_frame.set_valign (Gtk.Align.START); this.attach (image_frame, 0, 0, 1, 3); @@ -150,7 +151,7 @@ public class Contacts.ContactSheet : Grid { } private void create_name_label () { - var name_label = new Label (""); + var name_label = new Gtk.Label (""); name_label.ellipsize = Pango.EllipsizeMode.END; name_label.xalign = 0f; name_label.selectable = true; @@ -262,9 +263,11 @@ public class Contacts.ContactSheet : Grid { foreach (var url in url_details.urls) { var button = create_button ("web-browser-symbolic"); button.clicked.connect (() => { - var window = (Window) button.get_toplevel (); + var window = (Contacts.Window) button.get_toplevel (); try { - show_uri_on_window (window, fallback_to_https (url.value), Gdk.CURRENT_TIME); + Gtk.show_uri_on_window (window, + fallback_to_https (url.value), + Gdk.CURRENT_TIME); } catch (Error e) { var message = "Failed to open url '%s'".printf(url.value); diff --git a/src/contacts-crop-cheese-dialog.vala b/src/contacts-crop-cheese-dialog.vala index 5c8fdaf..e0c9439 100644 --- a/src/contacts-crop-cheese-dialog.vala +++ b/src/contacts-crop-cheese-dialog.vala @@ -15,14 +15,12 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -using Gtk; - [GtkTemplate (ui = "/org/gnome/Contacts/ui/contacts-crop-cheese-dialog.ui")] public class Contacts.CropCheeseDialog : Gtk.Window { [GtkChild] - private Stack stack; + private Gtk.Stack stack; [GtkChild] - private Button take_another_button; + private Gtk.Button take_another_button; private Cc.CropArea crop_area; private const string STACK_NAME_CROP = "crop"; @@ -65,19 +63,19 @@ public class Contacts.CropCheeseDialog : Gtk.Window { } [GtkCallback] - private void on_cancel_clicked (Button button) { + private void on_cancel_clicked (Gtk.Button button) { this.destroy (); } [GtkCallback] - private void on_take_another_clicked (Button button) { + private void on_take_another_clicked (Gtk.Button button) { #if HAVE_CHEESE this.stack.set_visible_child_name (STACK_NAME_CHEESE); #endif } [GtkCallback] - private void on_take_pic_clicked (Button button) { + private void on_take_pic_clicked (Gtk.Button button) { #if HAVE_CHEESE var camera = this.cheese.get_camera () as Cheese.Camera; this.flash.fire (); @@ -94,11 +92,11 @@ public class Contacts.CropCheeseDialog : Gtk.Window { } [GtkCallback] - private void on_done_clicked (Button button) { + private void on_done_clicked (Gtk.Button button) { picture_selected (this.crop_area.get_picture ()); destroy(); } - + [GtkCallback] private void on_destroy () { #if HAVE_CHEESE diff --git a/src/contacts-editor-property.vala b/src/contacts-editor-property.vala index 0a908ca..e80e54e 100644 --- a/src/contacts-editor-property.vala +++ b/src/contacts-editor-property.vala @@ -16,35 +16,32 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -using Gtk; using Folks; -using Gee; - public class Contacts.BirthdayEditor : Gtk.Dialog { - private SpinButton day_spin; - private ComboBoxText month_combo; - private SpinButton year_spin; + private Gtk.SpinButton day_spin; + private Gtk.ComboBoxText month_combo; + private Gtk.SpinButton year_spin; public bool is_set { get; set; default = false; } public signal void changed (); delegate void AdjustingDateFn (); - public DateTime get_birthday () { - return new DateTime.local (year_spin.get_value_as_int (), - month_combo.get_active () + 1, - day_spin.get_value_as_int (), - 0, 0, 0).to_utc (); + public GLib.DateTime get_birthday () { + return new GLib.DateTime.local (year_spin.get_value_as_int (), + month_combo.get_active () + 1, + day_spin.get_value_as_int (), + 0, 0, 0).to_utc (); } - public BirthdayEditor (Window window, DateTime birthday) { + public BirthdayEditor (Gtk.Window window, DateTime birthday) { Object (transient_for: window, use_header_bar: 1); - day_spin = new SpinButton.with_range (1.0, 31.0, 1.0); + day_spin = new Gtk.SpinButton.with_range (1.0, 31.0, 1.0); day_spin.set_digits (0); day_spin.numeric = true; day_spin.set_value ((double)birthday.to_local ().get_day_of_month ()); - month_combo = new ComboBoxText (); + month_combo = new Gtk.ComboBoxText (); var january = new DateTime.local (1, 1, 1, 1, 1, 1); for (int i = 0; i < 12; i++) { var month = january.add_months (i); @@ -53,47 +50,47 @@ public class Contacts.BirthdayEditor : Gtk.Dialog { month_combo.set_active (birthday.to_local ().get_month () - 1); month_combo.hexpand = true; - year_spin = new SpinButton.with_range (1800, 3000, 1); + year_spin = new Gtk.SpinButton.with_range (1800, 3000, 1); year_spin.set_digits (0); year_spin.numeric = true; year_spin.set_value ((double)birthday.to_local ().get_year ()); // Create grid and labels - Box box = new Box (Orientation.VERTICAL, 12); - Grid grid = new Grid (); + var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 12); + var grid = new Gtk.Grid (); grid.set_column_spacing (12); grid.set_row_spacing (12); - Label day = new Label(_("Day")); - day.set_halign (Align.END); + Gtk.Label day = new Gtk.Label(_("Day")); + day.set_halign (Gtk.Align.END); grid.attach (day, 0, 0); grid.attach (day_spin, 1, 0); - Label month = new Label(_("Month")); - month.set_halign (Align.END); + Gtk.Label month = new Gtk.Label(_("Month")); + month.set_halign (Gtk.Align.END); grid.attach (month, 0, 1); grid.attach (month_combo, 1, 1); - Label year = new Label(_("Year")); - year.set_halign (Align.END); + Gtk.Label year = new Gtk.Label(_("Year")); + year.set_halign (Gtk.Align.END); grid.attach (year, 0, 2); grid.attach (year_spin, 1, 2); box.pack_start (grid); var content = this.get_content_area (); - content.set_valign (Align.CENTER); + content.set_valign (Gtk.Align.CENTER); content.add (box); this.title = _("Change Address Book"); - add_buttons (_("Set"), ResponseType.OK, - _("Cancel"), ResponseType.CANCEL, - null); - var ok_button = this.get_widget_for_response (ResponseType.OK); + add_buttons (_("Set"), Gtk.ResponseType.OK, + _("Cancel"), Gtk.ResponseType.CANCEL, + null); + var ok_button = this.get_widget_for_response (Gtk.ResponseType.OK); ok_button.get_style_context ().add_class ("suggested-action"); this.response.connect ((id) => { switch (id) { - case ResponseType.OK: + case Gtk.ResponseType.OK: this.is_set = true; changed (); break; - case ResponseType.CANCEL: + case Gtk.ResponseType.CANCEL: break; } this.destroy (); @@ -130,8 +127,8 @@ public class Contacts.BirthdayEditor : Gtk.Dialog { } } -public class Contacts.AddressEditor : Box { - private Entry? entries[7]; /* must be the number of elements in postal_element_props */ +public class Contacts.AddressEditor : Gtk.Box { + private Gtk.Entry? entries[7]; /* must be the number of elements in postal_element_props */ private const string[] postal_element_props = {"street", "extension", "locality", "region", "postal_code", "po_box", "country"}; private static string[] postal_element_names = {_("Street"), _("Extension"), _("City"), _("State/Province"), _("Zip/Postal Code"), _("PO box"), _("Country")}; @@ -140,13 +137,13 @@ public class Contacts.AddressEditor : Box { public AddressEditor (PostalAddressFieldDetails details) { set_hexpand (true); - set_orientation (Orientation.VERTICAL); + set_orientation (Gtk.Orientation.VERTICAL); for (int i = 0; i < entries.length; i++) { string postal_part; details.value.get (AddressEditor.postal_element_props[i], out postal_part); - entries[i] = new Entry (); + entries[i] = new Gtk.Entry (); entries[i].set_hexpand (true); entries[i].set ("placeholder-text", AddressEditor.postal_element_names[i]); @@ -179,23 +176,23 @@ public class Contacts.AddressEditor : Box { } } -public class Contacts.EditorPropertyRow : ListBoxRow { +public class Contacts.EditorPropertyRow : Gtk.ListBoxRow { public bool is_empty { get; set; default = true; } public bool is_removed { get; set; default = false; } public string ptype { get; private set; } - public Box container; - public Box header; - public Revealer revealer; + public Gtk.Box container; + public Gtk.Box header; + public Gtk.Revealer revealer; construct { - this.revealer = new Revealer (); + this.revealer = new Gtk.Revealer (); //TODO: bind orientation property to available space - var box = new Box (Orientation.VERTICAL, 6); - box.set_valign (Align.START); + var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 6); + box.set_valign (Gtk.Align.START); box.set_can_focus (false); - this.container = new Box (Orientation.HORIZONTAL, 6); + this.container = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6); this.container.set_can_focus (false); - this.header = new Box (Orientation.HORIZONTAL, 6); + this.header = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6); this.header.set_can_focus (false); box.pack_start (this.header); box.pack_end (this.container); @@ -240,16 +237,19 @@ public class Contacts.EditorPropertyRow : ListBoxRow { } public void add_base_label (string label) { - var title_label = new Label (label); + var title_label = new Gtk.Label (label); title_label.set_hexpand (false); - title_label.set_halign (Align.START); + title_label.set_halign (Gtk.Align.START); title_label.margin_end = 6; this.header.pack_start (title_label); } - public void add_base_combo (Set<AbstractFieldDetails> details_set, string label, TypeSet combo_type, AbstractFieldDetails details) { - var title_label = new Label (label); - title_label.set_halign (Align.START); + public void add_base_combo (Gee.Set<AbstractFieldDetails> details_set, + string label, + TypeSet combo_type, + AbstractFieldDetails details) { + var title_label = new Gtk.Label (label); + title_label.set_halign (Gtk.Align.START); this.header.pack_start (title_label); TypeCombo combo = new TypeCombo (combo_type); combo.set_hexpand (false); @@ -265,11 +265,11 @@ public class Contacts.EditorPropertyRow : ListBoxRow { } //FIXME: create only one add_base_entry - public void add_base_entry_email (Set<AbstractFieldDetails> details_set, + public void add_base_entry_email (Gee.Set<AbstractFieldDetails> details_set, EmailFieldDetails details, string placeholder) { - var value_entry = new Entry (); - value_entry.set_input_purpose (InputPurpose.EMAIL); + var value_entry = new Gtk.Entry (); + value_entry.set_input_purpose (Gtk.InputPurpose.EMAIL); value_entry.placeholder_text = placeholder; value_entry.set_text (details.value); value_entry.set_hexpand (true); @@ -286,11 +286,11 @@ public class Contacts.EditorPropertyRow : ListBoxRow { }); } - public void add_base_entry_phone (Set<AbstractFieldDetails> details_set, + public void add_base_entry_phone (Gee.Set<AbstractFieldDetails> details_set, PhoneFieldDetails details, string placeholder) { - var value_entry = new Entry (); - value_entry.set_input_purpose (InputPurpose.PHONE); + var value_entry = new Gtk.Entry (); + value_entry.set_input_purpose (Gtk.InputPurpose.PHONE); value_entry.placeholder_text = placeholder; value_entry.set_text (details.value); value_entry.set_hexpand (true); @@ -308,12 +308,12 @@ public class Contacts.EditorPropertyRow : ListBoxRow { }); } - public void add_base_entry_url (Set<AbstractFieldDetails> details_set, + public void add_base_entry_url (Gee.Set<AbstractFieldDetails> details_set, UrlFieldDetails details, string placeholder) { - var value_entry = new Entry (); + var value_entry = new Gtk.Entry (); value_entry.placeholder_text = placeholder; - value_entry.set_input_purpose (InputPurpose.URL); + value_entry.set_input_purpose (Gtk.InputPurpose.URL); value_entry.set_text (details.value); value_entry.set_hexpand (true); this.container.pack_start (value_entry); @@ -330,11 +330,11 @@ public class Contacts.EditorPropertyRow : ListBoxRow { }); } - public void add_base_delete (Set<AbstractFieldDetails> details_set, + public void add_base_delete (Gee.Set<AbstractFieldDetails> details_set, AbstractFieldDetails details) { - var delete_button = new Button.from_icon_name ("user-trash-symbolic"); + var delete_button = new Gtk.Button.from_icon_name ("user-trash-symbolic"); delete_button.get_accessible ().set_name (_("Delete field")); - delete_button.set_valign (Align.START); + delete_button.set_valign (Gtk.Align.START); this.bind_property ("is-empty", delete_button, "sensitive", BindingFlags.SYNC_CREATE | BindingFlags.INVERT_BOOLEAN); this.container.pack_end (delete_button, false); @@ -351,7 +351,7 @@ public class Contacts.EditorPropertyRow : ListBoxRow { * A widget representing a property of a persona in the editor {@link Contact}. * We can have more then one property in one properity e.g. Emails therefore we need to return a List */ -public class Contacts.EditorProperty : ArrayList<EditorPropertyRow> { +public class Contacts.EditorProperty : Gee.ArrayList<EditorPropertyRow> { public bool writeable { get; private set; default = false; } public EditorProperty (Persona persona, string property_name, bool only_new = false) { @@ -439,9 +439,10 @@ public class Contacts.EditorProperty : ArrayList<EditorPropertyRow> { } } - private EditorPropertyRow create_for_email (Set<AbstractFieldDetails> set, EmailFieldDetails? details = null) { + private EditorPropertyRow create_for_email (Gee.Set<AbstractFieldDetails> set, + EmailFieldDetails? details = null) { if (details == null) { - var parameters = new HashMultiMap<string, string> (); + var parameters = new Gee.HashMultiMap<string, string> (); parameters["type"] = "PERSONAL"; var new_details = new EmailFieldDetails ("", parameters); set.add(new_details); @@ -456,9 +457,10 @@ public class Contacts.EditorProperty : ArrayList<EditorPropertyRow> { return box; } - private EditorPropertyRow create_for_phone (Set<AbstractFieldDetails> set, PhoneFieldDetails? details = null) { + private EditorPropertyRow create_for_phone (Gee.Set<AbstractFieldDetails> set, + PhoneFieldDetails? details = null) { if (details == null) { - var parameters = new HashMultiMap<string, string> (); + var parameters = new Gee.HashMultiMap<string, string> (); parameters["type"] = "CELL"; var new_details = new PhoneFieldDetails ("", parameters); set.add(new_details); @@ -475,9 +477,10 @@ public class Contacts.EditorProperty : ArrayList<EditorPropertyRow> { } // TODO: add support for different types of urls - private EditorPropertyRow create_for_url (Set<AbstractFieldDetails> set, UrlFieldDetails? details = null) { + private EditorPropertyRow create_for_url (Gee.Set<AbstractFieldDetails> set, + UrlFieldDetails? details = null) { if (details == null) { - var parameters = new HashMultiMap<string, string> (); + var parameters = new Gee.HashMultiMap<string, string> (); parameters["type"] = "PERSONAL"; var new_details = new UrlFieldDetails ("", parameters); set.add(new_details); @@ -497,7 +500,7 @@ public class Contacts.EditorProperty : ArrayList<EditorPropertyRow> { var box = new EditorPropertyRow ("nickname"); box.add_base_label (_("Nickname")); - var value_entry = new Entry (); + var value_entry = new Gtk.Entry (); value_entry.set_text (details.nickname); value_entry.set_hexpand (true); box.container.pack_start (value_entry); @@ -513,10 +516,10 @@ public class Contacts.EditorProperty : ArrayList<EditorPropertyRow> { } // TODO: support different types of nodes - private EditorPropertyRow create_for_note (Set<NoteFieldDetails> details_set, + private EditorPropertyRow create_for_note (Gee.Set<NoteFieldDetails> details_set, NoteFieldDetails? details = null) { if (details == null) { - var parameters = new HashMultiMap<string, string> (); + var parameters = new Gee.HashMultiMap<string, string> (); parameters["type"] = "PERSONAL"; var new_details = new NoteFieldDetails ("", parameters); details_set.add(new_details); @@ -525,10 +528,10 @@ public class Contacts.EditorProperty : ArrayList<EditorPropertyRow> { var box = new EditorPropertyRow ("notes"); box.add_base_label (_("Note")); - var sw = new ScrolledWindow (null, null); - sw.set_shadow_type (ShadowType.OUT); + var sw = new Gtk.ScrolledWindow (null, null); + sw.set_shadow_type (Gtk.ShadowType.OUT); sw.set_size_request (-1, 100); - var value_text = new TextView (); + var value_text = new Gtk.TextView (); value_text.get_buffer ().set_text (details.value); value_text.set_hexpand (true); sw.add (value_text); @@ -537,7 +540,7 @@ public class Contacts.EditorProperty : ArrayList<EditorPropertyRow> { box.add_base_delete (details_set, details); value_text.get_buffer ().changed.connect (() => { - TextIter start, end; + Gtk.TextIter start, end; value_text.get_buffer ().get_start_iter (out start); value_text.get_buffer ().get_end_iter (out end); details.value = value_text.get_buffer ().get_text (start, end, true); @@ -562,11 +565,11 @@ public class Contacts.EditorProperty : ArrayList<EditorPropertyRow> { var box = new EditorPropertyRow ("birthday"); box.add_base_label (_("Birthday")); - var button = new Button.with_label (_("Set Birthday")); + var button = new Gtk.Button.with_label (_("Set Birthday")); box.container.pack_start (button); button.clicked.connect (() => { - Window parent_window = button.get_toplevel () as Window; + var parent_window = button.get_toplevel () as Gtk.Window; if (parent_window != null) { var dialog = new BirthdayEditor (parent_window, date); @@ -583,9 +586,9 @@ public class Contacts.EditorProperty : ArrayList<EditorPropertyRow> { box.is_empty = details.birthday == null; - var delete_button = new Button.from_icon_name ("user-trash-symbolic"); + var delete_button = new Gtk.Button.from_icon_name ("user-trash-symbolic"); delete_button.get_accessible ().set_name (_("Delete field")); - delete_button.set_valign (Align.START); + delete_button.set_valign (Gtk.Align.START); box.bind_property ("is-empty", delete_button, "sensitive", BindingFlags.SYNC_CREATE | BindingFlags.INVERT_BOOLEAN); box.container.pack_end (delete_button, false); @@ -600,10 +603,10 @@ public class Contacts.EditorProperty : ArrayList<EditorPropertyRow> { return box; } - private EditorPropertyRow create_for_address (Set<PostalAddressFieldDetails> details_set, + private EditorPropertyRow create_for_address (Gee.Set<PostalAddressFieldDetails> details_set, PostalAddressFieldDetails? details = null) { if (details == null) { - var parameters = new HashMultiMap<string, string> (); + var parameters = new Gee.HashMultiMap<string, string> (); parameters["type"] = "HOME"; var address = new PostalAddress(null, null, null, null, null, null, null, null, null); var new_details = new PostalAddressFieldDetails (address, parameters); diff --git a/src/contacts-fake-persona-store.vala b/src/contacts-fake-persona-store.vala index 7a5d458..b7127bc 100644 --- a/src/contacts-fake-persona-store.vala +++ b/src/contacts-fake-persona-store.vala @@ -16,7 +16,6 @@ */ using Folks; -using Gee; /** * A "dummy" store which is used to have an equivalent of a PersonaStore for a @@ -29,18 +28,18 @@ public class Contacts.FakePersonaStore : PersonaStore { _the_store = new FakePersonaStore (); return _the_store; } - private HashMap<string, Persona> _personas; - private Map<string, Persona> _personas_ro; + private Gee.HashMap<string, Persona> _personas; + private Gee.Map<string, Persona> _personas_ro; public override string type_id { get { return "fake"; } } public FakePersonaStore () { Object (id: "uri", display_name: "fake store"); - this._personas = new HashMap<string, Persona> (); + this._personas = new Gee.HashMap<string, Persona> (); this._personas_ro = this._personas.read_only_view; } - public override Map<string, Persona> personas { + public override Gee.Map<string, Persona> personas { get { return this._personas_ro; } } @@ -71,16 +70,16 @@ public class Contacts.FakePersonaStore : PersonaStore { const string BACKEND_NAME = "fake-store"; public class Contacts.FakePersona : Persona, -AvatarDetails, -BirthdayDetails, -EmailDetails, -ImDetails, -NameDetails, -NoteDetails, -PhoneDetails, -UrlDetails, -PostalAddressDetails -{ + AvatarDetails, + BirthdayDetails, + EmailDetails, + ImDetails, + NameDetails, + NoteDetails, + PhoneDetails, + UrlDetails, + PostalAddressDetails { + private HashTable<string, Value?> properties; // Keep track of the persona in the actual store public weak Persona real_persona { get; set; default = null; } @@ -97,10 +96,10 @@ PostalAddressDetails } } - private ArrayList<string> _changed_properties; + private Gee.ArrayList<string> _changed_properties; construct { - this._changed_properties = new ArrayList<string> (); + this._changed_properties = new Gee.ArrayList<string> (); } public LoadableIcon? avatar { @@ -149,72 +148,72 @@ PostalAddressDetails set {} } - public Set<PhoneFieldDetails> phone_numbers { + public Gee.Set<PhoneFieldDetails> phone_numbers { get { unowned Value? value = this.properties.get ("phone-numbers"); if (value == null) { - var new_value = Value (typeof (Set)); + var new_value = GLib.Value (typeof (Gee.Set)); var set = new FakeHashSet<PhoneFieldDetails> (); new_value.set_object (set); set.changed.connect (() => { notify_property ("phone-numbers"); }); this.properties.set ("phone-numbers", new_value); value = this.properties.get ("phone-numbers"); } - return (Set<PhoneFieldDetails>) value; + return (Gee.Set<PhoneFieldDetails>) value; } set { this.properties.set ("phone-numbers", value); } } - public Set<UrlFieldDetails> urls { + public Gee.Set<UrlFieldDetails> urls { get { unowned Value? value = this.properties.get ("urls"); if (value == null) { - var new_value = Value (typeof (Set)); + var new_value = Value (typeof (Gee.Set)); var set = new FakeHashSet<UrlFieldDetails> (); new_value.set_object (set); set.changed.connect (() => { notify_property ("urls"); }); this.properties.set ("urls", new_value); value = new_value; } - return (Set<UrlFieldDetails>) value; + return (Gee.Set<UrlFieldDetails>) value; } set { this.properties.set ("urls", value); } } - public Set<PostalAddressFieldDetails> postal_addresses { + public Gee.Set<PostalAddressFieldDetails> postal_addresses { get { unowned Value? value = this.properties.get ("postal-addresses"); if (value == null) { - var new_value = Value (typeof (Set)); + var new_value = Value (typeof (Gee.Set)); var set = new FakeHashSet<PostalAddressFieldDetails> (); new_value.set_object (set); set.changed.connect (() => { notify_property ("postal-addresses"); }); this.properties.set ("postal-addresses", new_value); value = new_value; } - return (Set<PostalAddressFieldDetails>) value; + return (Gee.Set<PostalAddressFieldDetails>) value; } set { this.properties.set ("postal-addresses", value); } } - public Set<NoteFieldDetails> notes { + public Gee.Set<NoteFieldDetails> notes { get { unowned Value? value = this.properties.get ("notes"); if (value == null) { - var new_value = Value (typeof (Set)); + var new_value = Value (typeof (Gee.Set)); var set = new FakeHashSet<NoteFieldDetails> (); new_value.set_object (set); set.changed.connect (() => { notify_property ("notes"); }); this.properties.set ("notes", new_value); value = new_value; } - return (Set<NoteFieldDetails>) value; + return (Gee.Set<NoteFieldDetails>) value; } set { this.properties.set ("notes", value); @@ -238,36 +237,36 @@ PostalAddressDetails set {} } - public MultiMap<string,ImFieldDetails> im_addresses { + public Gee.MultiMap<string,ImFieldDetails> im_addresses { get { unowned Value? value = this.properties.get ("im-addresses"); if (value == null) { - var new_value = Value (typeof (MultiMap)); + var new_value = Value (typeof (Gee.MultiMap)); var set = new FakeHashMultiMap<string, ImFieldDetails> (); new_value.set_object (set); this.properties.set ("im-addresses", new_value); set.changed.connect (() => { notify_property ("im-addresses"); }); value = new_value; } - return (MultiMap<string, ImFieldDetails>) value; + return (Gee.MultiMap<string, ImFieldDetails>) value; } set { this.properties.set ("im-addresses", value); } } - public Set<EmailFieldDetails> email_addresses { + public Gee.Set<EmailFieldDetails> email_addresses { get { unowned Value? value = this.properties.get ("email-addresses"); if (value == null) { - var new_value = Value (typeof (Set)); + var new_value = Value (typeof (Gee.Set)); var set = new FakeHashSet<EmailFieldDetails> (); set.changed.connect (() => { notify_property ("email-addresses"); }); new_value.set_object (set); this.properties.set ("email-addresses", new_value); value = new_value; } - return (Set<EmailFieldDetails>) value; + return (Gee.Set<EmailFieldDetails>) value; } set { this.properties.set ("email-addresses", value); @@ -422,8 +421,8 @@ PostalAddressDetails yield ((BirthdayDetails) persona).change_calendar_event_id ((string?) new_value); break; case "email-addresses": - var original = (Set<EmailFieldDetails>) new_value; - var copy = new HashSet<EmailFieldDetails> (); + var original = (Gee.Set<EmailFieldDetails>) new_value; + var copy = new Gee.HashSet<EmailFieldDetails> (); foreach (var e in original) { if (e.value != null && e.value != "") copy.add (new EmailFieldDetails (e.value, e.parameters)); @@ -437,13 +436,13 @@ PostalAddressDetails yield ((GenderDetails) persona).change_gender ((Gender) new_value); break; case "groups": - yield ((GroupDetails) persona).change_groups ((Set<string>) new_value); + yield ((GroupDetails) persona).change_groups ((Gee.Set<string>) new_value); break; case "im-addresses": - yield ((ImDetails) persona).change_im_addresses ((MultiMap<string, ImFieldDetails>) new_value); + yield ((ImDetails) persona).change_im_addresses ((Gee.MultiMap<string, ImFieldDetails>) new_value); break; case "local-ids": - yield ((LocalIdDetails) persona).change_local_ids ((Set<string>) new_value); + yield ((LocalIdDetails) persona).change_local_ids ((Gee.Set<string>) new_value); break; case "structured-name": yield ((NameDetails) persona).change_structured_name ((StructuredName?) new_value); @@ -455,8 +454,8 @@ PostalAddressDetails yield ((NameDetails) persona).change_nickname ((string) new_value); break; case "notes": - var original = (Set<NoteFieldDetails>) new_value; - var copy = new HashSet<NoteFieldDetails> (); + var original = (Gee.Set<NoteFieldDetails>) new_value; + var copy = new Gee.HashSet<NoteFieldDetails> (); foreach (var e in original) { if (e.value != null && e.value != "") copy.add (new NoteFieldDetails (e.value, e.parameters)); @@ -464,8 +463,8 @@ PostalAddressDetails yield ((NoteDetails) persona).change_notes (copy); break; case "phone-numbers": - var original = (Set<PhoneFieldDetails>) new_value; - var copy = new HashSet<PhoneFieldDetails> (); + var original = (Gee.Set<PhoneFieldDetails>) new_value; + var copy = new Gee.HashSet<PhoneFieldDetails> (); foreach (var e in original) { if (e.value != null && e.value != "") copy.add (new PhoneFieldDetails (e.value, e.parameters)); @@ -473,8 +472,8 @@ PostalAddressDetails yield ((PhoneDetails) persona).change_phone_numbers (copy); break; case "postal-addresses": - var original = (Set<PostalAddressFieldDetails>) new_value; - var copy = new HashSet<PostalAddressFieldDetails> (); + var original = (Gee.Set<PostalAddressFieldDetails>) new_value; + var copy = new Gee.HashSet<PostalAddressFieldDetails> (); foreach (var e in original) { if (e.value != null && !e.value.is_empty ()) copy.add (new PostalAddressFieldDetails (e.value, e.parameters)); @@ -482,11 +481,11 @@ PostalAddressDetails yield ((PostalAddressDetails) persona).change_postal_addresses (copy); break; case "roles": - yield ((RoleDetails) persona).change_roles ((Set<RoleFieldDetails>) new_value); + yield ((RoleDetails) persona).change_roles ((Gee.Set<RoleFieldDetails>) new_value); break; case "urls": - var original = (Set<UrlFieldDetails>) new_value; - var copy = new HashSet<UrlFieldDetails> (); + var original = (Gee.Set<UrlFieldDetails>) new_value; + var copy = new Gee.HashSet<UrlFieldDetails> (); foreach (var e in original) { if (e.value != null && e.value != "") copy.add (new UrlFieldDetails (e.value, e.parameters)); @@ -494,7 +493,7 @@ PostalAddressDetails yield ((UrlDetails) persona).change_urls (copy); break; case "web-service-addresses": - yield ((WebServiceDetails) persona).change_web_service_addresses ((MultiMap<string, WebServiceFieldDetails>) new_value); + yield ((WebServiceDetails) persona).change_web_service_addresses ((Gee.MultiMap<string, WebServiceFieldDetails>) new_value); break; default: critical ("Unknown property '%s' in Contact.set_persona_property().", property_name); @@ -509,7 +508,7 @@ PostalAddressDetails public class Contacts.FakeIndividual : Individual { public weak Individual real_individual { get; set; default = null; } public weak FakePersona primary_persona { get; set; default = null; } - public FakeIndividual (Set<FakePersona>? personas) { + public FakeIndividual (Gee.Set<FakePersona>? personas) { base (personas); foreach (var p in personas) { // Keep track of the main persona @@ -519,7 +518,7 @@ public class Contacts.FakeIndividual : Individual { } public FakeIndividual.from_real (Individual individual) { - var fake_personas = new HashSet<FakePersona> (); + var fake_personas = new Gee.HashSet<FakePersona> (); foreach (var p in individual.personas) { var fake_p = new FakePersona.from_real (p); // Keep track of the main persona diff --git a/src/contacts-im-service.vala b/src/contacts-im-service.vala index d97b7fe..aceef3f 100644 --- a/src/contacts-im-service.vala +++ b/src/contacts-im-service.vala @@ -15,9 +15,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -using Gtk; using Folks; -using Gee; /** * ImService is a helper struct that maps a service identifier to the @@ -59,8 +57,8 @@ public struct Contacts.ImService { /** * Returns the display name for the given IM service in a nicely presented way. */ - public static string get_display_name (string service_name) { - foreach (var d in data) + public static unowned string get_display_name (string service_name) { + foreach (unowned ImService d in data) if (d.service_name == service_name) return dgettext (Config.GETTEXT_PACKAGE, d.display_name); diff --git a/src/contacts-in-app-notification.vala b/src/contacts-in-app-notification.vala index dc5d035..25857e2 100644 --- a/src/contacts-in-app-notification.vala +++ b/src/contacts-in-app-notification.vala @@ -15,19 +15,17 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -using Gtk; - [GtkTemplate (ui = "/org/gnome/Contacts/ui/contacts-in-app-notification.ui")] -public class Contacts.InAppNotification : Revealer { +public class Contacts.InAppNotification : Gtk.Revealer { // Close the in-app notification after 5 seconds by default. private const uint DEFAULT_KEEPALIVE = 5; [GtkChild] - private Grid grid; + private Gtk.Grid grid; [GtkChild] - private Label label; - public Label message_label { + private Gtk.Label label; + public Gtk.Label message_label { get { return this.label; } } @@ -39,7 +37,7 @@ public class Contacts.InAppNotification : Revealer { /** * Creates an in-app notification with the given message, and an accompanying button if not null. */ - public InAppNotification (string message, Button? button = null) { + public InAppNotification (string message, Gtk.Button? button = null) { this.label.label = message; if (button != null) { @@ -73,7 +71,7 @@ public class Contacts.InAppNotification : Revealer { } [GtkCallback] - private void on_close_button_clicked(Button close_button) { + private void on_close_button_clicked(Gtk.Button close_button) { dismiss(); } } diff --git a/src/contacts-link-suggestion-grid.vala b/src/contacts-link-suggestion-grid.vala index 99846b1..cad38dc 100644 --- a/src/contacts-link-suggestion-grid.vala +++ b/src/contacts-link-suggestion-grid.vala @@ -15,9 +15,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -using Gtk; using Folks; -using Gee; /** * The LinkSuggestionGrid is show at the bottom of the ContactPane. @@ -25,7 +23,7 @@ using Gee; * and another (hopefully) similar contact. */ [GtkTemplate (ui = "/org/gnome/Contacts/ui/contacts-link-suggestion-grid.ui")] -public class Contacts.LinkSuggestionGrid : Grid { +public class Contacts.LinkSuggestionGrid : Gtk.Grid { private const int AVATAR_SIZE = 54; [GtkChild] diff --git a/src/contacts-linked-personas-dialog.vala b/src/contacts-linked-personas-dialog.vala index 8ae9413..9c26b4d 100644 --- a/src/contacts-linked-personas-dialog.vala +++ b/src/contacts-linked-personas-dialog.vala @@ -15,21 +15,20 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -using Gtk; using Folks; [GtkTemplate (ui = "/org/gnome/Contacts/ui/contacts-linked-personas-dialog.ui")] -public class Contacts.LinkedPersonasDialog : Dialog { +public class Contacts.LinkedPersonasDialog : Gtk.Dialog { private const int AVATAR_SIZE = 54; [GtkChild] - private ListBox linked_accounts_view; + private Gtk.ListBox linked_accounts_view; private Individual individual; public bool any_unlinked = false; - public LinkedPersonasDialog (Window main_win, Store store, Individual individual) { + public LinkedPersonasDialog (Gtk.Window main_win, Store store, Individual individual) { Object ( use_header_bar: 1, transient_for: main_win, @@ -48,7 +47,7 @@ public class Contacts.LinkedPersonasDialog : Dialog { continue; } - var row_grid = new Grid (); + var row_grid = new Gtk.Grid (); var image_frame = new Avatar (AVATAR_SIZE, individual); image_frame.set_hexpand (false); @@ -56,24 +55,24 @@ public class Contacts.LinkedPersonasDialog : Dialog { image_frame.margin_end = 12; row_grid.attach (image_frame, 0, 0, 1, 2); - var display_name = new Label (""); - display_name.set_halign (Align.START); - display_name.set_valign (Align.END); + var display_name = new Gtk.Label (""); + display_name.set_halign (Gtk.Align.START); + display_name.set_valign (Gtk.Align.END); display_name.set_hexpand (true); display_name.set_markup (Markup.printf_escaped ("<span font='bold'>%s</span>", p.display_id)); row_grid.attach (display_name, 1, 0, 1, 1); - var store_name = new Label (Contacts.Utils.format_persona_store_name_for_contact (p)); - store_name.set_halign (Align.START); - store_name.set_valign (Align.START); + var store_name = new Gtk.Label (Contacts.Utils.format_persona_store_name_for_contact (p)); + store_name.set_halign (Gtk.Align.START); + store_name.set_valign (Gtk.Align.START); store_name.set_hexpand (true); store_name.get_style_context ().add_class ("dim-label"); row_grid.attach (store_name, 1, 1, 1, 1); - var button = new Button.with_label (_("Unlink")); + var button = new Gtk.Button.with_label (_("Unlink")); button.margin_end = 6; - button.set_valign (Align.CENTER); + button.set_valign (Gtk.Align.CENTER); button.get_child ().margin = 1; row_grid.attach (button, 2, 0, 1, 2); diff --git a/src/contacts-linking.vala b/src/contacts-linking.vala index 4b8f7fc..010cc91 100644 --- a/src/contacts-linking.vala +++ b/src/contacts-linking.vala @@ -16,24 +16,23 @@ */ using Folks; -using Gee; namespace Contacts { public class LinkOperation : Object { private weak Store store; - private HashSet<HashSet<Persona>> personas_to_link; + private Gee.HashSet<Gee.HashSet<Persona>> personas_to_link; private bool finished { get; set; default = false; } public LinkOperation(Store store) { this.store = store; - this.personas_to_link = new HashSet<HashSet<Persona>> (); + this.personas_to_link = new Gee.HashSet<Gee.HashSet<Persona>> (); } // Link individuals - public async void execute (LinkedList<Individual> individuals) { - var personas_to_link = new HashSet<Persona> (); + public async void execute (Gee.LinkedList<Individual> individuals) { + var personas_to_link = new Gee.HashSet<Persona> (); foreach (var i in individuals) { - var saved_personas = new HashSet<Persona> (); + var saved_personas = new Gee.HashSet<Persona> (); foreach (var persona in i.personas) { personas_to_link.add (persona); saved_personas.add (persona); @@ -73,11 +72,11 @@ namespace Contacts { public class UnLinkOperation : Object { private weak Store store; - private HashSet<Persona> personas; + private Gee.HashSet<Persona> personas; public UnLinkOperation(Store store) { this.store = store; - this.personas = new HashSet<Persona> (); + this.personas = new Gee.HashSet<Persona> (); } /* Remove a personas from individual */ diff --git a/src/contacts-list-pane.vala b/src/contacts-list-pane.vala index a886afa..0d85fa3 100644 --- a/src/contacts-list-pane.vala +++ b/src/contacts-list-pane.vala @@ -15,12 +15,10 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -using Gee; -using Gtk; using Folks; [GtkTemplate (ui = "/org/gnome/Contacts/ui/contacts-list-pane.ui")] -public class Contacts.ListPane : Frame { +public class Contacts.ListPane : Gtk.Frame { private Store store; [GtkChild] @@ -28,23 +26,23 @@ public class Contacts.ListPane : Frame { private ContactList contacts_list; [GtkChild] - public SearchEntry filter_entry; + public Gtk.SearchEntry filter_entry; private SimpleQuery filter_query; [GtkChild] - private Button link_button; + private Gtk.Button link_button; [GtkChild] - private Button delete_button; + private Gtk.Button delete_button; [GtkChild] - private ActionBar actions_bar; + private Gtk.ActionBar actions_bar; public UiState state { get; set; } public signal void selection_changed (Individual? individual); - public signal void link_contacts (LinkedList<Individual> individual); - public signal void delete_contacts (LinkedList<Individual> individual); + public signal void link_contacts (Gee.LinkedList<Individual> individual); + public signal void delete_contacts (Gee.LinkedList<Individual> individual); public signal void contacts_marked (int contacts_marked); public ListPane (Settings settings, Store contacts_store) { @@ -88,7 +86,7 @@ public class Contacts.ListPane : Frame { } [GtkCallback] - private void filter_entry_changed (Editable editable) { + private void filter_entry_changed (Gtk.Editable editable) { this.filter_query.query_string = this.filter_entry.text; } diff --git a/src/contacts-setup-window.vala b/src/contacts-setup-window.vala index 4f07605..eab16d5 100644 --- a/src/contacts-setup-window.vala +++ b/src/contacts-setup-window.vala @@ -15,18 +15,15 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -using Gee; -using Gtk; -using Hdy; using Folks; [GtkTemplate (ui = "/org/gnome/Contacts/ui/contacts-setup-window.ui")] public class Contacts.SetupWindow : Gtk.ApplicationWindow { [GtkChild] - private Clamp content; + private Hdy.Clamp content; [GtkChild] - private Button setup_done_button; + private Gtk.Button setup_done_button; private AccountsList setup_accounts_list; diff --git a/src/contacts-shell-search-provider.vala b/src/contacts-shell-search-provider.vala index ad96732..2911434 100644 --- a/src/contacts-shell-search-provider.vala +++ b/src/contacts-shell-search-provider.vala @@ -15,7 +15,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -using Gee; using Folks; [DBus (name = "org.gnome.Shell.SearchProvider2")] @@ -104,8 +103,8 @@ public class Contacts.SearchProvider : Object { private async HashTable<string, Variant>[] get_metas (owned string[] ids) throws Error { this.app.hold (); - var results = new ArrayList<HashTable> (); - foreach (var id in ids) { + var results = new Gee.ArrayList<HashTable> (); + foreach (unowned string id in ids) { Individual indiv = null; try { indiv = yield aggregator.look_up_individual (id); diff --git a/src/contacts-type-combo.vala b/src/contacts-type-combo.vala index db998a4..7104fcf 100644 --- a/src/contacts-type-combo.vala +++ b/src/contacts-type-combo.vala @@ -15,8 +15,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -using Gtk; -using Gee; using Folks; /** @@ -25,7 +23,7 @@ using Folks; * to choose between "Personal", "Home" and "Work" for email addresses, * together with all the custom labels it has encountered since then. */ -public class Contacts.TypeCombo : ComboBox { +public class Contacts.TypeCombo : Gtk.ComboBox { private unowned TypeSet type_set; @@ -34,7 +32,7 @@ public class Contacts.TypeCombo : ComboBox { */ public TypeDescriptor active_descriptor { get { - TreeIter iter; + Gtk.TreeIter iter; get_active_iter (out iter); assert (!is_separator (this.model, iter)); @@ -49,12 +47,12 @@ public class Contacts.TypeCombo : ComboBox { } construct { - this.valign = Align.START; - this.halign = Align.FILL; + this.valign = Gtk.Align.START; + this.halign = Gtk.Align.FILL; this.hexpand = true; this.visible = true; - var renderer = new CellRendererText (); + var renderer = new Gtk.CellRendererText (); pack_start (renderer, true); set_attributes (renderer, "text", 0); @@ -71,7 +69,7 @@ public class Contacts.TypeCombo : ComboBox { this.model = type_set.store; } - private bool is_separator (TreeModel model, TreeIter iter) { + private bool is_separator (Gtk.TreeModel model, Gtk.TreeIter iter) { unowned string? s; model.get (iter, 0, out s); return s == null; @@ -89,7 +87,7 @@ public class Contacts.TypeCombo : ComboBox { * (for example "HOME" or "WORK"). */ public void set_active_from_vcard_type (string type) { - TreeIter iter; + Gtk.TreeIter iter; this.type_set.get_iter_for_vcard_type (type, out iter); set_active_iter (iter); } diff --git a/src/contacts-type-descriptor.vala b/src/contacts-type-descriptor.vala index 90f0489..8335f56 100644 --- a/src/contacts-type-descriptor.vala +++ b/src/contacts-type-descriptor.vala @@ -15,8 +15,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -using Gtk; -using Gee; using Folks; /** @@ -47,7 +45,7 @@ public class Contacts.TypeDescriptor : Object { private Source source; public string? name = null; public string[]? vcard_types = null; - public TreeIter iter; + public Gtk.TreeIter iter; /** * Returns the translated name for this property. @@ -93,7 +91,7 @@ public class Contacts.TypeDescriptor : Object { debug ("Saving type %s", to_string ()); var old_parameters = details.parameters; - var new_parameters = new HashMultiMap<string, string> (); + var new_parameters = new Gee.HashMultiMap<string, string> (); // Check whether PREF VCard "flag" is set bool has_pref = false; diff --git a/src/contacts-typeset.vala b/src/contacts-typeset.vala index 63b4518..3208ac4 100644 --- a/src/contacts-typeset.vala +++ b/src/contacts-typeset.vala @@ -15,8 +15,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -using Gtk; -using Gee; using Folks; /** @@ -51,28 +49,32 @@ public class Contacts.TypeSet : Object { } /** - * Returns the TreeIter which corresponds to the type of the given - * AbstractFieldDetails. + * Returns the {@link Gtk.TreeIter} which corresponds to the type of the + * given {@link Folks.AbstractFieldDetails}. */ - public void get_iter_for_field_details (AbstractFieldDetails detail, out TreeIter iter) { + public void get_iter_for_field_details (AbstractFieldDetails detail, + out Gtk.TreeIter iter) { // Note that we shouldn't have null here, but it's there just to be sure. var d = lookup_descriptor_for_field_details (detail); iter = d.iter; } /** - * Returns the TreeIter which corresponds the best to the given vcard type. + * Returns the {@link Gtk.TreeIter} which corresponds the best to the given + * vcard type. + * * @param type A VCard-like type, such as "HOME" or "CELL". */ - public void get_iter_for_vcard_type (string type, out TreeIter iter) { + public void get_iter_for_vcard_type (string type, out Gtk.TreeIter iter) { unowned TypeDescriptor? d = lookup_descriptor_by_vcard_type (type); iter = (d != null)? d.iter : this.other_dummy.iter; } /** - * Returns the TreeIter which corresponds the best to the given custom label. + * Returns the {@link Gtk.TreeIter} which corresponds the best to the given + * custom label. */ - public void get_iter_for_custom_label (string label, out TreeIter iter) { + public void get_iter_for_custom_label (string label, out Gtk.TreeIter iter) { var descr = get_descriptor_for_custom_label (label); if (descr == null) descr = create_descriptor_for_custom_label (label); @@ -110,7 +112,7 @@ public class Contacts.TypeSet : Object { * @return The appropriate TypeDescriptor or null if no match was found. */ public unowned TypeDescriptor? lookup_descriptor_in_store (string display_name) { - TreeIter iter; + Gtk.TreeIter iter; // Make sure we handle an empty store if (!this.store.get_iter_first (out iter)) diff --git a/src/contacts-utils.vala b/src/contacts-utils.vala index b63efeb..8466882 100644 --- a/src/contacts-utils.vala +++ b/src/contacts-utils.vala @@ -15,20 +15,15 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -using Gtk; using Folks; -using Gee; -using DBus; -using GLib; -using Gdk; namespace Contacts { public bool is_set (string? str) { return str != null && str != ""; } - public void add_separator (ListBoxRow row, ListBoxRow? before_row) { - row.set_header (new Separator (Orientation.HORIZONTAL)); + public void add_separator (Gtk.ListBoxRow row, Gtk.ListBoxRow? before_row) { + row.set_header (new Gtk.Separator (Gtk.Orientation.HORIZONTAL)); } [DBus (name = "org.freedesktop.Application")] @@ -47,7 +42,7 @@ namespace Contacts { try { string object_path = "/" + app_id.replace(".", "/"); - Display display = Display.get_default (); + Gdk.Display display = Gdk.Display.get_default (); DesktopAppInfo info = new DesktopAppInfo (app_id + ".desktop"); Gdk.AppLaunchContext context = display.get_app_launch_context (); @@ -64,7 +59,7 @@ namespace Contacts { data.insert ("desktop-startup-id", new Variant.string (startup_id)); con.ActivateAction (action, param_array, data); } catch (Error e) { - debug ("Failed to activate action" + action); + debug ("Failed to activate action '%s': %s", action, e.message); } } } @@ -114,14 +109,14 @@ namespace Contacts.Utils { } #endif - public T? get_first<T> (Collection<T> collection) { + public T? get_first<T> (Gee.Collection<T> collection) { var i = collection.iterator(); if (i.next()) return i.get(); return null; } - public void grab_entry_focus_no_select (Entry entry) { + public void grab_entry_focus_no_select (Gtk.Entry entry) { int start, end; if (!entry.get_selection_bounds (out start, out end)) { start = end = entry.get_position (); @@ -293,8 +288,8 @@ namespace Contacts.Utils { return 0; } - public Gee.List<T> sort_fields<T> (Collection<T> fields) { - var res = new ArrayList<T>(); + public Gee.List<T> sort_fields<T> (Gee.Collection<T> fields) { + var res = new Gee.ArrayList<T>(); res.add_all (fields); res.sort (Contacts.Utils.compare_fields); return res; @@ -380,7 +375,7 @@ namespace Contacts.Utils { return strcmp (store_a.id, store_b.id); }; - var persona_list = new ArrayList<Persona>(); + var persona_list = new Gee.ArrayList<Persona>(); foreach (var persona in individual.personas) if (persona.store.type_id != "key-file") persona_list.add (persona); @@ -508,8 +503,6 @@ namespace Contacts.Utils { public async void set_persona_property (Persona persona, string property_name, Value new_value) throws PropertyError, IndividualAggregatorError { - /* FIXME: It should be possible to move these all to being delegates which are - * passed to the functions which currently call this one; but only once bgo#604827 is fixed. */ switch (property_name) { case "alias": yield ((AliasDetails) persona).change_alias ((string) new_value); @@ -524,7 +517,7 @@ namespace Contacts.Utils { yield ((BirthdayDetails) persona).change_calendar_event_id ((string?) new_value); break; case "email-addresses": - yield ((EmailDetails) persona).change_email_addresses ((Set<EmailFieldDetails>) new_value); + yield ((EmailDetails) persona).change_email_addresses ((Gee.Set<EmailFieldDetails>) new_value); break; case "is-favourite": yield ((FavouriteDetails) persona).change_is_favourite ((bool) new_value); @@ -533,13 +526,13 @@ namespace Contacts.Utils { yield ((GenderDetails) persona).change_gender ((Gender) new_value); break; case "groups": - yield ((GroupDetails) persona).change_groups ((Set<string>) new_value); + yield ((GroupDetails) persona).change_groups ((Gee.Set<string>) new_value); break; case "im-addresses": - yield ((ImDetails) persona).change_im_addresses ((MultiMap<string, ImFieldDetails>) new_value); + yield ((ImDetails) persona).change_im_addresses ((Gee.MultiMap<string, ImFieldDetails>) new_value); break; case "local-ids": - yield ((LocalIdDetails) persona).change_local_ids ((Set<string>) new_value); + yield ((LocalIdDetails) persona).change_local_ids ((Gee.Set<string>) new_value); break; case "structured-name": yield ((NameDetails) persona).change_structured_name ((StructuredName?) new_value); @@ -551,22 +544,22 @@ namespace Contacts.Utils { yield ((NameDetails) persona).change_nickname ((string) new_value); break; case "notes": - yield ((NoteDetails) persona).change_notes ((Set<NoteFieldDetails>) new_value); + yield ((NoteDetails) persona).change_notes ((Gee.Set<NoteFieldDetails>) new_value); break; case "phone-numbers": - yield ((PhoneDetails) persona).change_phone_numbers ((Set<PhoneFieldDetails>) new_value); + yield ((PhoneDetails) persona).change_phone_numbers ((Gee.Set<PhoneFieldDetails>) new_value); break; case "postal-addresses": - yield ((PostalAddressDetails) persona).change_postal_addresses ((Set<PostalAddressFieldDetails>) new_value); + yield ((PostalAddressDetails) persona).change_postal_addresses ((Gee.Set<PostalAddressFieldDetails>) new_value); break; case "roles": - yield ((RoleDetails) persona).change_roles ((Set<RoleFieldDetails>) new_value); + yield ((RoleDetails) persona).change_roles ((Gee.Set<RoleFieldDetails>) new_value); break; case "urls": - yield ((UrlDetails) persona).change_urls ((Set<UrlFieldDetails>) new_value); + yield ((UrlDetails) persona).change_urls ((Gee.Set<UrlFieldDetails>) new_value); break; case "web-service-addresses": - yield ((WebServiceDetails) persona).change_web_service_addresses ((MultiMap<string, WebServiceFieldDetails>) new_value); + yield ((WebServiceDetails) persona).change_web_service_addresses ((Gee.MultiMap<string, WebServiceFieldDetails>) new_value); break; default: critical ("Unknown property '%s' in Contact.set_persona_property().", property_name); diff --git a/src/contacts-vcard-type-mapping.vala b/src/contacts-vcard-type-mapping.vala index 08ed7ac..13772d4 100644 --- a/src/contacts-vcard-type-mapping.vala +++ b/src/contacts-vcard-type-mapping.vala @@ -15,8 +15,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -using Gtk; -using Gee; using Folks; /** @@ -44,7 +42,7 @@ internal struct Contacts.VcardTypeMapping { * For example: [ HOME, FOO, PREF, BLAH ] should match the [ HOME ] VCard * type, but not [ HOME, FAX ] */ - public bool matches (Collection<string> types) { + public bool matches (Gee.Collection<string> types) { for (int i = 0; i < MAX_TYPES && this.types[i] != null; i++) { bool occurs_in_list = false; foreach (var type in types) { diff --git a/src/main.vala b/src/main.vala index 4d80021..284a0d4 100644 --- a/src/main.vala +++ b/src/main.vala @@ -15,7 +15,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -using Gtk; using Contacts; public static int diff --git a/tests/basic-test.vala b/tests/basic-test.vala index 9cf1517..86ee407 100644 --- a/tests/basic-test.vala +++ b/tests/basic-test.vala @@ -15,8 +15,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -using Gee; - void main (string[] args) { Test.init (ref args); Test.add_func ("/utils/get_first", Contacts.UtilsTests.get_first); @@ -25,7 +23,7 @@ void main (string[] args) { namespace Contacts.UtilsTests { private void get_first () { - Collection<Object> empty = Collection.empty (); + Gee.Collection<Object> empty = Gee.Collection.empty (); assert_true (Utils.get_first (empty) == null); } } |