Commit db8c55a8 authored by Niels De Graef's avatar Niels De Graef

Rename ContactFrame to Avatar.

It's shorter *and* it's more obvious.
parent 0c97a75c
...@@ -15,9 +15,9 @@ data/ui/contacts-window.ui ...@@ -15,9 +15,9 @@ data/ui/contacts-window.ui
src/contacts-accounts-list.vala src/contacts-accounts-list.vala
src/contacts-address-map.vala src/contacts-address-map.vala
src/contacts-app.vala src/contacts-app.vala
src/contacts-avatar.vala
src/contacts-avatar-dialog.vala src/contacts-avatar-dialog.vala
src/contacts-contact-editor.vala src/contacts-contact-editor.vala
src/contacts-contact-frame.vala
src/contacts-contact-list.vala src/contacts-contact-list.vala
src/contacts-contact-pane.vala src/contacts-contact-pane.vala
src/contacts-contact-sheet.vala src/contacts-contact-sheet.vala
......
...@@ -56,7 +56,7 @@ public class Contacts.AvatarDialog : Dialog { ...@@ -56,7 +56,7 @@ public class Contacts.AvatarDialog : Dialog {
[GtkChild] [GtkChild]
private Box webcam_button_box; private Box webcam_button_box;
private ContactFrame current_avatar; private Avatar current_avatar;
#if HAVE_CHEESE #if HAVE_CHEESE
private Cheese.Flash flash; private Cheese.Flash flash;
...@@ -82,10 +82,10 @@ public class Contacts.AvatarDialog : Dialog { ...@@ -82,10 +82,10 @@ public class Contacts.AvatarDialog : Dialog {
this.contact = contact; this.contact = contact;
// Load the current avatar // Load the current avatar
this.current_avatar = new ContactFrame (MAIN_SIZE); this.current_avatar = new Avatar (MAIN_SIZE);
if (contact != null) { if (contact != null) {
contact.keep_widget_uptodate (this.current_avatar, (w) => { 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 { } else {
this.current_avatar.set_image (null, null); this.current_avatar.set_image (null, null);
...@@ -162,18 +162,18 @@ public class Contacts.AvatarDialog : Dialog { ...@@ -162,18 +162,18 @@ public class Contacts.AvatarDialog : Dialog {
return pixbuf.scale_simple (w, h, Gdk.InterpType.HYPER); return pixbuf.scale_simple (w, h, Gdk.InterpType.HYPER);
} }
private ContactFrame create_frame (Gdk.Pixbuf source_pixbuf) { private Avatar create_frame (Gdk.Pixbuf source_pixbuf) {
var image_frame = new ContactFrame (ICONS_SIZE, true); var avatar = new Avatar (ICONS_SIZE, true);
var pixbuf = source_pixbuf.scale_simple (ICONS_SIZE, ICONS_SIZE, Gdk.InterpType.HYPER); 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); var avatar_pixbuf = scale_pixbuf_for_avatar_use (source_pixbuf);
image_frame.clicked.connect ( () => { avatar.clicked.connect ( () => {
selected_pixbuf (avatar_pixbuf); 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; var details = persona as AvatarDetails;
if (details == null || details.avatar == null) if (details == null || details.avatar == null)
return null; return null;
...@@ -189,14 +189,14 @@ public class Contacts.AvatarDialog : Dialog { ...@@ -189,14 +189,14 @@ public class Contacts.AvatarDialog : Dialog {
return null; return null;
} }
private ContactFrame? frame_for_filename (string filename) { private Avatar? frame_for_filename (string filename) {
ContactFrame? image_frame = null; Avatar? avatar = null;
try { try {
var pixbuf = new Gdk.Pixbuf.from_file (filename); var pixbuf = new Gdk.Pixbuf.from_file (filename);
return create_frame (pixbuf); return create_frame (pixbuf);
} catch { } catch {
} }
return image_frame; return avatar;
} }
private void selected_pixbuf (Gdk.Pixbuf pixbuf) { private void selected_pixbuf (Gdk.Pixbuf pixbuf) {
...@@ -210,7 +210,7 @@ public class Contacts.AvatarDialog : Dialog { ...@@ -210,7 +210,7 @@ public class Contacts.AvatarDialog : Dialog {
private void update_thumbnail_grids () { private void update_thumbnail_grids () {
if (this.contact != null) { if (this.contact != null) {
foreach (var p in contact.individual.personas) { foreach (var p in contact.individual.personas) {
ContactFrame? frame = frame_for_persona (p); Avatar? frame = frame_for_persona (p);
if (frame != null) if (frame != null)
this.personas_thumbnail_grid.add (frame); this.personas_thumbnail_grid.add (frame);
} }
...@@ -219,7 +219,7 @@ public class Contacts.AvatarDialog : Dialog { ...@@ -219,7 +219,7 @@ public class Contacts.AvatarDialog : Dialog {
var stock_files = Utils.get_stock_avatars (); var stock_files = Utils.get_stock_avatars ();
foreach (var file_name in stock_files) { foreach (var file_name in stock_files) {
ContactFrame? frame = frame_for_filename (file_name); Avatar? frame = frame_for_filename (file_name);
if (frame != null) if (frame != null)
this.stock_thumbnail_grid.add (frame); this.stock_thumbnail_grid.add (frame);
} }
......
/* -*- Mode: vala; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 8 -*- */
/* /*
* Copyright (C) 2011 Alexander Larsson <alexl@redhat.com> * Copyright (C) 2011 Alexander Larsson <alexl@redhat.com>
* *
...@@ -20,14 +19,18 @@ using Gtk; ...@@ -20,14 +19,18 @@ using Gtk;
using Folks; using Folks;
using Gee; 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 int size;
private Gdk.Pixbuf? pixbuf; private Gdk.Pixbuf? pixbuf;
private Pango.Layout? layout; private Pango.Layout? layout;
public signal void clicked (); public signal void clicked ();
public ContactFrame (int size, bool with_button = false) { public Avatar (int size, bool with_button = false) {
this.size = size; this.size = size;
var image = new Image (); var image = new Image ();
......
...@@ -77,7 +77,7 @@ public class Contacts.ContactEditor : Grid { ...@@ -77,7 +77,7 @@ public class Contacts.ContactEditor : Grid {
private Entry name_entry; private Entry name_entry;
private ContactFrame avatar_frame; private Avatar avatar;
[GtkChild] [GtkChild]
private ScrolledWindow main_sw; private ScrolledWindow main_sw;
...@@ -804,7 +804,7 @@ public class Contacts.ContactEditor : Grid { ...@@ -804,7 +804,7 @@ public class Contacts.ContactEditor : Grid {
linked_button.show (); linked_button.show ();
linked_button.sensitive = contact.individual.personas.size > 1; linked_button.sensitive = contact.individual.personas.size > 1;
create_avatar_frame (); create_avatar_button ();
create_name_entry (); create_name_entry ();
int i = 3; int i = 3;
...@@ -855,7 +855,7 @@ public class Contacts.ContactEditor : Grid { ...@@ -855,7 +855,7 @@ public class Contacts.ContactEditor : Grid {
remove_button.hide (); remove_button.hide ();
linked_button.hide (); linked_button.hide ();
create_avatar_frame (); create_avatar_button ();
create_name_entry (); create_name_entry ();
this.last_row = 2; this.last_row = 2;
...@@ -959,31 +959,31 @@ public class Contacts.ContactEditor : Grid { ...@@ -959,31 +959,31 @@ public class Contacts.ContactEditor : Grid {
container_grid.show_all (); container_grid.show_all ();
} }
// Creates the contact's current avatar, the big frame on top of the Editor // Creates the contact's current avatar in a big button on top of the Editor
private void create_avatar_frame () { private void create_avatar_button () {
this.avatar_frame = new ContactFrame (PROFILE_SIZE, true); this.avatar = new Avatar (PROFILE_SIZE, true);
this.avatar_frame.vexpand = false; this.avatar.vexpand = false;
this.avatar_frame.valign = Align.START; this.avatar.valign = Align.START;
(this.avatar_frame.get_child () as Button).relief = ReliefStyle.NORMAL; (this.avatar.get_child () as Button).relief = ReliefStyle.NORMAL;
this.avatar_frame.clicked.connect (on_avatar_frame_clicked); this.avatar.clicked.connect (on_avatar_frame_clicked);
if (this.contact != null) { if (this.contact != null) {
this.contact.keep_widget_uptodate (this.avatar_frame, (w) => { this.contact.keep_widget_uptodate (this.avatar, (w) => {
this.avatar_frame.set_image (this.contact.individual, this.contact); this.avatar.set_image (this.contact.individual, this.contact);
}); });
} else { } 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 // Show the avatar dialog when the avatar is clicked
private void on_avatar_frame_clicked () { private void on_avatar_frame_clicked () {
var dialog = new AvatarDialog ((Window) get_toplevel (), this.contact); var dialog = new AvatarDialog ((Window) get_toplevel (), this.contact);
dialog.set_avatar.connect ( (icon) => { dialog.set_avatar.connect ( (icon) => {
this.avatar_frame.set_data ("value", icon); this.avatar.set_data ("value", icon);
this.avatar_frame.set_data ("changed", true); this.avatar.set_data ("changed", true);
Gdk.Pixbuf? a_pixbuf = null; Gdk.Pixbuf? a_pixbuf = null;
try { try {
...@@ -992,17 +992,17 @@ public class Contacts.ContactEditor : Grid { ...@@ -992,17 +992,17 @@ public class Contacts.ContactEditor : Grid {
} catch { } catch {
} }
this.avatar_frame.set_pixbuf (a_pixbuf); this.avatar.set_pixbuf (a_pixbuf);
}); });
dialog.run (); dialog.run ();
} }
public bool avatar_changed () { public bool avatar_changed () {
return this.avatar_frame.get_data<bool> ("changed"); return this.avatar.get_data<bool> ("changed");
} }
public Value get_avatar_value () { 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 ()); Value v = Value (icon.get_type ());
v.set_object (icon); v.set_object (icon);
return v; return v;
......
...@@ -28,7 +28,7 @@ public class Contacts.ContactList : ListBox { ...@@ -28,7 +28,7 @@ public class Contacts.ContactList : ListBox {
private class ContactDataRow : ListBoxRow { private class ContactDataRow : ListBoxRow {
public Contact contact; public Contact contact;
public Label label; public Label label;
public ContactFrame image_frame; private Avatar avatar;
public CheckButton selector_button; public CheckButton selector_button;
public bool filtered; public bool filtered;
...@@ -40,9 +40,9 @@ public class Contacts.ContactList : ListBox { ...@@ -40,9 +40,9 @@ public class Contacts.ContactList : ListBox {
Grid grid = new Grid (); Grid grid = new Grid ();
grid.margin = 6; grid.margin = 6;
grid.set_column_spacing (10); grid.set_column_spacing (10);
image_frame = new ContactFrame (Contact.LIST_AVATAR_SIZE); this.avatar = new Avatar (Contact.LIST_AVATAR_SIZE);
image_frame.set_shadow_type (ShadowType.IN); this.avatar.set_shadow_type (ShadowType.IN);
image_frame.get_style_context ().add_class ("main-avatar-frame"); this.avatar.get_style_context ().add_class ("main-avatar-frame");
label = new Label (""); label = new Label ("");
label.set_ellipsize (Pango.EllipsizeMode.END); label.set_ellipsize (Pango.EllipsizeMode.END);
...@@ -54,7 +54,7 @@ public class Contacts.ContactList : ListBox { ...@@ -54,7 +54,7 @@ public class Contacts.ContactList : ListBox {
selector_button.set_halign (Align.END); selector_button.set_halign (Align.END);
selector_button.set_hexpand (true); 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 (label, 1, 0, 1, 1);
grid.attach (selector_button, 2, 0, 1, 1); grid.attach (selector_button, 2, 0, 1, 1);
this.add (grid); this.add (grid);
...@@ -66,7 +66,7 @@ public class Contacts.ContactList : ListBox { ...@@ -66,7 +66,7 @@ public class Contacts.ContactList : ListBox {
// Update widgets // Update widgets
this.label.set_text (this.contact.display_name); 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);
} }
} }
......
...@@ -96,14 +96,14 @@ public class Contacts.ContactSheet : Grid { ...@@ -96,14 +96,14 @@ public class Contacts.ContactSheet : Grid {
} }
public void update (Contact c) { 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.get_style_context ().add_class ("main-avatar-frame");
image_frame.set_shadow_type (ShadowType.IN); image_frame.set_shadow_type (ShadowType.IN);
image_frame.set_vexpand (false); image_frame.set_vexpand (false);
image_frame.set_valign (Align.START); image_frame.set_valign (Align.START);
c.keep_widget_uptodate (image_frame, (w) => { 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); attach (image_frame, 0, 0, 1, 3);
var name_label = new Label (null); var name_label = new Label (null);
......
...@@ -42,11 +42,11 @@ public class Contacts.LinkSuggestionGrid : Grid { ...@@ -42,11 +42,11 @@ public class Contacts.LinkSuggestionGrid : Grid {
public LinkSuggestionGrid (Contact contact) { public LinkSuggestionGrid (Contact contact) {
get_style_context ().add_class ("contacts-suggestion"); 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.hexpand = false;
image_frame.margin = 12; image_frame.margin = 12;
contact.keep_widget_uptodate (image_frame, (w) => { 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 (); image_frame.show ();
attach (image_frame, 0, 0, 1, 2); attach (image_frame, 0, 0, 1, 2);
......
...@@ -78,13 +78,13 @@ public class Contacts.LinkedAccountsDialog : Dialog { ...@@ -78,13 +78,13 @@ public class Contacts.LinkedAccountsDialog : Dialog {
var row_grid = new Grid (); 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.set_hexpand (false);
image_frame.margin = 6; image_frame.margin = 6;
image_frame.margin_end = 12; image_frame.margin_end = 12;
contact.keep_widget_uptodate (image_frame, (w) => { 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); row_grid.attach (image_frame, 0, 0, 1, 2);
var display_name = new Label (""); var display_name = new Label ("");
......
...@@ -8,9 +8,9 @@ install_data('org.gnome.Contacts.gschema.xml', ...@@ -8,9 +8,9 @@ install_data('org.gnome.Contacts.gschema.xml',
contacts_vala_sources = [ contacts_vala_sources = [
'contacts-accounts-list.vala', 'contacts-accounts-list.vala',
'contacts-app.vala', 'contacts-app.vala',
'contacts-avatar.vala',
'contacts-avatar-dialog.vala', 'contacts-avatar-dialog.vala',
'contacts-contact-editor.vala', 'contacts-contact-editor.vala',
'contacts-contact-frame.vala',
'contacts-contact-list.vala', 'contacts-contact-list.vala',
'contacts-contact-pane.vala', 'contacts-contact-pane.vala',
'contacts-contact-sheet.vala', 'contacts-contact-sheet.vala',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment