Commit ec0d9f51 authored by Julian Sparber's avatar Julian Sparber

contact-editor: use trash icon on small sizes

- Replace the label on the remove contact button with a trash icon.
- Use a constant as threshold for resizing
parent 3b90a5e2
......@@ -93,7 +93,6 @@
<child>
<object class="GtkButton" id="remove_button">
<property name="visible">True</property>
<property name="label" translatable="yes">Remove Contact</property>
<style>
<class name="destructive-action"/>
</style>
......
......@@ -119,13 +119,27 @@ public class Contacts.ContactEditor : ContactForm {
this.writable_personas = new HashMap<string, HashMap<string, Field?>> ();
this.container_grid.size_allocate.connect(on_container_grid_size_allocate);
bool small = false;
int old_width = this.get_allocated_width ();
Image trash_icon = new Image.from_icon_name ("user-trash-symbolic", IconSize.MENU);
string label = _("Remove Contact");
this.remove_button.image = trash_icon;
this.remove_button.label = label;
size_allocate.connect(() => {
Allocation size;
get_allocation(out size);
if (size.width < 400) {
this.avatar.set_display_size (PROFILE_SMALL_SIZE);
} else {
this.avatar.set_display_size (PROFILE_SIZE);
int width = this.get_allocated_width ();
if (old_width != width) {
if (!small && width <= RESIZE_WIDTH) {
this.avatar.set_display_size (PROFILE_SMALL_SIZE);
this.remove_button.image = trash_icon;
this.remove_button.label = null;
small = true;
} else if (small && width > RESIZE_WIDTH) {
this.avatar.set_display_size (PROFILE_SIZE);
this.remove_button.image = null;
this.remove_button.label = label;
small = false;
}
old_width = this.get_allocated_width ();
}
});
}
......@@ -144,6 +158,14 @@ public class Contacts.ContactEditor : ContactForm {
this.linked_button.hide ();
}
/* Set the initial remove_button content based on the width */
int width = this.get_allocated_width ();
if (width <= RESIZE_WIDTH)
this.remove_button.label = null;
else
this.remove_button.image = null;
create_avatar_button ();
create_name_entry ();
......@@ -915,6 +937,10 @@ public class Contacts.ContactEditor : ContactForm {
private void create_avatar_button () {
this.avatar = new Avatar (PROFILE_SIZE, this.contact);
int width = this.get_allocated_width ();
if (width <= RESIZE_WIDTH)
this.avatar.set_display_size (PROFILE_SMALL_SIZE);
var button = new Button ();
button.get_accessible ().set_name (_("Change avatar"));
button.image = this.avatar;
......
......@@ -21,6 +21,7 @@ using Gee;
const int PROFILE_SIZE = 128;
const int PROFILE_SMALL_SIZE = 95;
const int RESIZE_WIDTH = 450;
/**
* The ContactPage is the right pane. It consists of 3 possible pages:
......
......@@ -84,7 +84,7 @@ public class Contacts.ContactSheet : ContactForm {
size_allocate.connect(() => {
Allocation size;
get_allocation(out size);
if (size.width < 400) {
if (size.width < RESIZE_WIDTH) {
image_frame.set_display_size (PROFILE_SMALL_SIZE);
} else {
image_frame.set_display_size (PROFILE_SIZE);
......
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