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
src/contacts-accounts-list.vala
src/contacts-address-map.vala
src/contacts-app.vala
src/contacts-avatar.vala
src/contacts-avatar-dialog.vala
src/contacts-contact-editor.vala
src/contacts-contact-frame.vala
src/contacts-contact-list.vala
src/contacts-contact-pane.vala
src/contacts-contact-sheet.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);
}
......
/* -*- 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 ();
......
......@@ -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;
......
......@@ -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);
}
}
......
......@@ -96,13 +96,13 @@ 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);
......
......@@ -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);
......
......@@ -78,12 +78,12 @@ 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);
......
......@@ -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',
......
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