diff options
author | Niels De Graef <nielsdegraef@gmail.com> | 2018-01-16 16:03:05 +0100 |
---|---|---|
committer | Niels De Graef <nielsdegraef@gmail.com> | 2018-01-16 16:03:05 +0100 |
commit | db8c55a8e4c76e89afa90243b048f820b7ea38e6 (patch) | |
tree | 996168d2d78f87ddac26343696905f59f48b8efa /src | |
parent | 0c97a75c6af52b3e08653fc301aaa01753f88a9c (diff) | |
download | gnome-contacts-db8c55a8e4c76e89afa90243b048f820b7ea38e6.tar.gz |
Rename ContactFrame to Avatar.
It's shorter *and* it's more obvious.
Diffstat (limited to 'src')
-rw-r--r-- | src/contacts-avatar-dialog.vala | 28 | ||||
-rw-r--r-- | src/contacts-avatar.vala (renamed from src/contacts-contact-frame.vala) | 9 | ||||
-rw-r--r-- | src/contacts-contact-editor.vala | 38 | ||||
-rw-r--r-- | src/contacts-contact-list.vala | 12 | ||||
-rw-r--r-- | src/contacts-contact-sheet.vala | 6 | ||||
-rw-r--r-- | src/contacts-link-suggestion-grid.vala | 4 | ||||
-rw-r--r-- | src/contacts-linked-accounts-dialog.vala | 6 | ||||
-rw-r--r-- | src/meson.build | 2 |
8 files changed, 54 insertions, 51 deletions
diff --git a/src/contacts-avatar-dialog.vala b/src/contacts-avatar-dialog.vala index 58f3010..293a3f8 100644 --- a/src/contacts-avatar-dialog.vala +++ b/src/contacts-avatar-dialog.vala @@ -56,7 +56,7 @@ public class Contacts.AvatarDialog : Dialog { [GtkChild] private Box webcam_button_box; - private ContactFrame current_avatar; + private Avatar current_avatar; #if HAVE_CHEESE private Cheese.Flash flash; @@ -82,10 +82,10 @@ public class Contacts.AvatarDialog : Dialog { this.contact = contact; // Load the current avatar - this.current_avatar = new ContactFrame (MAIN_SIZE); + this.current_avatar = new Avatar (MAIN_SIZE); if (contact != null) { contact.keep_widget_uptodate (this.current_avatar, (w) => { - (w as ContactFrame).set_image (contact.individual, contact); + (w as Avatar).set_image (contact.individual, contact); }); } else { this.current_avatar.set_image (null, null); @@ -162,18 +162,18 @@ public class Contacts.AvatarDialog : Dialog { return pixbuf.scale_simple (w, h, Gdk.InterpType.HYPER); } - private ContactFrame create_frame (Gdk.Pixbuf source_pixbuf) { - var image_frame = new ContactFrame (ICONS_SIZE, true); + private Avatar create_frame (Gdk.Pixbuf source_pixbuf) { + var avatar = new Avatar (ICONS_SIZE, true); var pixbuf = source_pixbuf.scale_simple (ICONS_SIZE, ICONS_SIZE, Gdk.InterpType.HYPER); - image_frame.set_pixbuf (pixbuf); + avatar.set_pixbuf (pixbuf); var avatar_pixbuf = scale_pixbuf_for_avatar_use (source_pixbuf); - image_frame.clicked.connect ( () => { + avatar.clicked.connect ( () => { selected_pixbuf (avatar_pixbuf); }); - return image_frame; + return avatar; } - private ContactFrame? frame_for_persona (Persona persona) { + private Avatar? frame_for_persona (Persona persona) { var details = persona as AvatarDetails; if (details == null || details.avatar == null) return null; @@ -189,14 +189,14 @@ public class Contacts.AvatarDialog : Dialog { return null; } - private ContactFrame? frame_for_filename (string filename) { - ContactFrame? image_frame = null; + private Avatar? frame_for_filename (string filename) { + Avatar? avatar = null; try { var pixbuf = new Gdk.Pixbuf.from_file (filename); return create_frame (pixbuf); } catch { } - return image_frame; + return avatar; } private void selected_pixbuf (Gdk.Pixbuf pixbuf) { @@ -210,7 +210,7 @@ public class Contacts.AvatarDialog : Dialog { private void update_thumbnail_grids () { if (this.contact != null) { foreach (var p in contact.individual.personas) { - ContactFrame? frame = frame_for_persona (p); + Avatar? frame = frame_for_persona (p); if (frame != null) this.personas_thumbnail_grid.add (frame); } @@ -219,7 +219,7 @@ public class Contacts.AvatarDialog : Dialog { var stock_files = Utils.get_stock_avatars (); foreach (var file_name in stock_files) { - ContactFrame? frame = frame_for_filename (file_name); + Avatar? frame = frame_for_filename (file_name); if (frame != null) this.stock_thumbnail_grid.add (frame); } diff --git a/src/contacts-contact-frame.vala b/src/contacts-avatar.vala index b1ec072..efd2170 100644 --- a/src/contacts-contact-frame.vala +++ b/src/contacts-avatar.vala @@ -1,4 +1,3 @@ -/* -*- Mode: vala; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 8 -*- */ /* * Copyright (C) 2011 Alexander Larsson <alexl@redhat.com> * @@ -20,14 +19,18 @@ using Gtk; using Folks; using Gee; -public class Contacts.ContactFrame : Frame { +/** + * The Avatar of a Contact is responsible for showing an {@link Individual}'s + * avatar, or a fallback if it's not available. + */ +public class Contacts.Avatar : Frame { private int size; private Gdk.Pixbuf? pixbuf; private Pango.Layout? layout; public signal void clicked (); - public ContactFrame (int size, bool with_button = false) { + public Avatar (int size, bool with_button = false) { this.size = size; var image = new Image (); diff --git a/src/contacts-contact-editor.vala b/src/contacts-contact-editor.vala index b94dba5..f42bc72 100644 --- a/src/contacts-contact-editor.vala +++ b/src/contacts-contact-editor.vala @@ -77,7 +77,7 @@ public class Contacts.ContactEditor : Grid { private Entry name_entry; - private ContactFrame avatar_frame; + private Avatar avatar; [GtkChild] private ScrolledWindow main_sw; @@ -804,7 +804,7 @@ public class Contacts.ContactEditor : Grid { linked_button.show (); linked_button.sensitive = contact.individual.personas.size > 1; - create_avatar_frame (); + create_avatar_button (); create_name_entry (); int i = 3; @@ -855,7 +855,7 @@ public class Contacts.ContactEditor : Grid { remove_button.hide (); linked_button.hide (); - create_avatar_frame (); + create_avatar_button (); create_name_entry (); this.last_row = 2; @@ -959,31 +959,31 @@ public class Contacts.ContactEditor : Grid { container_grid.show_all (); } - // Creates the contact's current avatar, the big frame on top of the Editor - private void create_avatar_frame () { - this.avatar_frame = new ContactFrame (PROFILE_SIZE, true); - this.avatar_frame.vexpand = false; - this.avatar_frame.valign = Align.START; - (this.avatar_frame.get_child () as Button).relief = ReliefStyle.NORMAL; - this.avatar_frame.clicked.connect (on_avatar_frame_clicked); + // Creates the contact's current avatar in a big button on top of the Editor + private void create_avatar_button () { + this.avatar = new Avatar (PROFILE_SIZE, true); + this.avatar.vexpand = false; + this.avatar.valign = Align.START; + (this.avatar.get_child () as Button).relief = ReliefStyle.NORMAL; + this.avatar.clicked.connect (on_avatar_frame_clicked); if (this.contact != null) { - this.contact.keep_widget_uptodate (this.avatar_frame, (w) => { - this.avatar_frame.set_image (this.contact.individual, this.contact); + this.contact.keep_widget_uptodate (this.avatar, (w) => { + this.avatar.set_image (this.contact.individual, this.contact); }); } else { - this.avatar_frame.set_image (null, null); + this.avatar.set_image (null, null); } - this.container_grid.attach (this.avatar_frame, 0, 0, 1, 3); + this.container_grid.attach (this.avatar, 0, 0, 1, 3); } // Show the avatar dialog when the avatar is clicked private void on_avatar_frame_clicked () { var dialog = new AvatarDialog ((Window) get_toplevel (), this.contact); dialog.set_avatar.connect ( (icon) => { - this.avatar_frame.set_data ("value", icon); - this.avatar_frame.set_data ("changed", true); + this.avatar.set_data ("value", icon); + this.avatar.set_data ("changed", true); Gdk.Pixbuf? a_pixbuf = null; try { @@ -992,17 +992,17 @@ public class Contacts.ContactEditor : Grid { } catch { } - this.avatar_frame.set_pixbuf (a_pixbuf); + this.avatar.set_pixbuf (a_pixbuf); }); dialog.run (); } public bool avatar_changed () { - return this.avatar_frame.get_data<bool> ("changed"); + return this.avatar.get_data<bool> ("changed"); } public Value get_avatar_value () { - GLib.Icon icon = this.avatar_frame.get_data<GLib.Icon> ("value"); + GLib.Icon icon = this.avatar.get_data<GLib.Icon> ("value"); Value v = Value (icon.get_type ()); v.set_object (icon); return v; diff --git a/src/contacts-contact-list.vala b/src/contacts-contact-list.vala index 1d074d2..5a055f4 100644 --- a/src/contacts-contact-list.vala +++ b/src/contacts-contact-list.vala @@ -28,7 +28,7 @@ public class Contacts.ContactList : ListBox { private class ContactDataRow : ListBoxRow { public Contact contact; public Label label; - public ContactFrame image_frame; + private Avatar avatar; public CheckButton selector_button; public bool filtered; @@ -40,9 +40,9 @@ public class Contacts.ContactList : ListBox { Grid grid = new Grid (); grid.margin = 6; grid.set_column_spacing (10); - image_frame = new ContactFrame (Contact.LIST_AVATAR_SIZE); - image_frame.set_shadow_type (ShadowType.IN); - image_frame.get_style_context ().add_class ("main-avatar-frame"); + this.avatar = new Avatar (Contact.LIST_AVATAR_SIZE); + this.avatar.set_shadow_type (ShadowType.IN); + this.avatar.get_style_context ().add_class ("main-avatar-frame"); label = new Label (""); label.set_ellipsize (Pango.EllipsizeMode.END); @@ -54,7 +54,7 @@ public class Contacts.ContactList : ListBox { selector_button.set_halign (Align.END); selector_button.set_hexpand (true); - grid.attach (image_frame, 0, 0, 1, 1); + grid.attach (this.avatar, 0, 0, 1, 1); grid.attach (label, 1, 0, 1, 1); grid.attach (selector_button, 2, 0, 1, 1); this.add (grid); @@ -66,7 +66,7 @@ public class Contacts.ContactList : ListBox { // Update widgets this.label.set_text (this.contact.display_name); - this.image_frame.set_image (this.contact.individual, this.contact); + this.avatar.set_image (this.contact.individual, this.contact); } } diff --git a/src/contacts-contact-sheet.vala b/src/contacts-contact-sheet.vala index 0323c75..985982b 100644 --- a/src/contacts-contact-sheet.vala +++ b/src/contacts-contact-sheet.vala @@ -96,14 +96,14 @@ public class Contacts.ContactSheet : Grid { } public void update (Contact c) { - var image_frame = new ContactFrame (PROFILE_SIZE); + var image_frame = new Avatar (PROFILE_SIZE); image_frame.get_style_context ().add_class ("main-avatar-frame"); image_frame.set_shadow_type (ShadowType.IN); image_frame.set_vexpand (false); image_frame.set_valign (Align.START); c.keep_widget_uptodate (image_frame, (w) => { - (w as ContactFrame).set_image (c.individual, c); - }); + (w as Avatar).set_image (c.individual, c); + }); attach (image_frame, 0, 0, 1, 3); var name_label = new Label (null); diff --git a/src/contacts-link-suggestion-grid.vala b/src/contacts-link-suggestion-grid.vala index e8733b5..03994ae 100644 --- a/src/contacts-link-suggestion-grid.vala +++ b/src/contacts-link-suggestion-grid.vala @@ -42,11 +42,11 @@ public class Contacts.LinkSuggestionGrid : Grid { public LinkSuggestionGrid (Contact contact) { get_style_context ().add_class ("contacts-suggestion"); - var image_frame = new ContactFrame (Contact.SMALL_AVATAR_SIZE); + var image_frame = new Avatar (Contact.SMALL_AVATAR_SIZE); image_frame.hexpand = false; image_frame.margin = 12; contact.keep_widget_uptodate (image_frame, (w) => { - (w as ContactFrame).set_image (contact.individual, contact); + (w as Avatar).set_image (contact.individual, contact); }); image_frame.show (); attach (image_frame, 0, 0, 1, 2); diff --git a/src/contacts-linked-accounts-dialog.vala b/src/contacts-linked-accounts-dialog.vala index 0c902f0..95a69b4 100644 --- a/src/contacts-linked-accounts-dialog.vala +++ b/src/contacts-linked-accounts-dialog.vala @@ -78,13 +78,13 @@ public class Contacts.LinkedAccountsDialog : Dialog { var row_grid = new Grid (); - var image_frame = new ContactFrame (Contact.SMALL_AVATAR_SIZE); + var image_frame = new Avatar (Contact.SMALL_AVATAR_SIZE); image_frame.set_hexpand (false); image_frame.margin = 6; image_frame.margin_end = 12; contact.keep_widget_uptodate (image_frame, (w) => { - (w as ContactFrame).set_image (contact.individual, contact); - }); + (w as Avatar).set_image (contact.individual, contact); + }); row_grid.attach (image_frame, 0, 0, 1, 2); var display_name = new Label (""); diff --git a/src/meson.build b/src/meson.build index a7bbf95..b072ad0 100644 --- a/src/meson.build +++ b/src/meson.build @@ -8,9 +8,9 @@ install_data('org.gnome.Contacts.gschema.xml', contacts_vala_sources = [ 'contacts-accounts-list.vala', 'contacts-app.vala', + 'contacts-avatar.vala', 'contacts-avatar-dialog.vala', 'contacts-contact-editor.vala', - 'contacts-contact-frame.vala', 'contacts-contact-list.vala', 'contacts-contact-pane.vala', 'contacts-contact-sheet.vala', |