Commit 23a4b6d3 authored by Julian Sparber's avatar Julian Sparber

LinkSuggestion: Change orientation on suggestion based on avaible space

parent d66abfee
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<interface> <interface>
<!-- interface-requires gtk+ 3.22 --> <!-- interface-requires gtk+ 3.22 -->
<template class="ContactsLinkSuggestionGrid" parent="GtkGrid"> <template class="ContactsLinkSuggestionGrid" parent="GtkBox">
<property name="orientation">horizontal</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="valign">end</property> <property name="valign">end</property>
<property name="column_spacing">6</property>
<child> <child>
<object class="GtkLabel" id="description_label"> <object class="GtkGrid" id="grid">
<property name="orientation">horizontal</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="valign">end</property> <property name="column_spacing">6</property>
<property name="halign">start</property> <child>
<property name="hexpand">True</property> <object class="GtkLabel" id="description_label">
<property name="margin_top">12</property> <property name="visible">True</property>
<property name="wrap">True</property> <property name="valign">end</property>
<property name="wrap_mode">word-char</property> <property name="halign">start</property>
</object> <property name="hexpand">True</property>
<packing> <property name="margin_top">12</property>
<property name="left_attach">1</property> <property name="wrap">True</property>
<property name="top_attach">0</property> <property name="wrap_mode">word-char</property>
<property name="height">1</property> </object>
</packing> <packing>
</child> <property name="left_attach">1</property>
<child> <property name="top_attach">0</property>
<object class="GtkLabel" id="extra_info_label"> <property name="height">1</property>
<property name="visible">False</property> </packing>
<property name="valign">start</property> </child>
<property name="halign">start</property> <child>
<property name="hexpand">True</property> <object class="GtkLabel" id="extra_info_label">
<property name="margin_bottom">12</property> <property name="visible">False</property>
<style> <property name="valign">start</property>
<class name="dim-label"/> <property name="halign">start</property>
</style> <property name="hexpand">True</property>
<property name="margin_bottom">12</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
<property name="height">1</property>
</packing>
</child>
</object> </object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
<property name="height">1</property>
</packing>
</child> </child>
<child> <child>
<object class="GtkBox"> <object class="GtkBox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="valign">center</property> <property name="valign">center</property>
<property name="halign">center</property>
<property name="orientation">horizontal</property> <property name="orientation">horizontal</property>
<property name="spacing">6</property> <property name="spacing">6</property>
<property name="margin_top">12</property> <property name="margin_top">12</property>
...@@ -79,11 +86,6 @@ ...@@ -79,11 +86,6 @@
</object> </object>
</child> </child>
</object> </object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">0</property>
<property name="height">2</property>
</packing>
</child> </child>
</template> </template>
</interface> </interface>
...@@ -102,6 +102,7 @@ public class Contacts.ContactPane : Stack { ...@@ -102,6 +102,7 @@ public class Contacts.ContactPane : Stack {
remove_suggestion_grid (); remove_suggestion_grid ();
this.suggestion_grid = new LinkSuggestionGrid (c); this.suggestion_grid = new LinkSuggestionGrid (c);
bind_property ("narrow", this.suggestion_grid, "orientation", BindingFlags.SYNC_CREATE);
parent_overlay.add_overlay (this.suggestion_grid); parent_overlay.add_overlay (this.suggestion_grid);
this.suggestion_grid.suggestion_accepted.connect ( () => { this.suggestion_grid.suggestion_accepted.connect ( () => {
......
...@@ -25,9 +25,11 @@ using Gee; ...@@ -25,9 +25,11 @@ using Gee;
* and another (hopefully) similar contact. * and another (hopefully) similar contact.
*/ */
[GtkTemplate (ui = "/org/gnome/Contacts/ui/contacts-link-suggestion-grid.ui")] [GtkTemplate (ui = "/org/gnome/Contacts/ui/contacts-link-suggestion-grid.ui")]
public class Contacts.LinkSuggestionGrid : Grid { public class Contacts.LinkSuggestionGrid : Box {
private const int AVATAR_SIZE = 54; private const int AVATAR_SIZE = 54;
[GtkChild]
private Gtk.Grid grid;
[GtkChild] [GtkChild]
private Gtk.Label description_label; private Gtk.Label description_label;
[GtkChild] [GtkChild]
...@@ -37,6 +39,8 @@ public class Contacts.LinkSuggestionGrid : Grid { ...@@ -37,6 +39,8 @@ public class Contacts.LinkSuggestionGrid : Grid {
[GtkChild] [GtkChild]
private Gtk.Button reject_button; private Gtk.Button reject_button;
public bool narrow { get; set; default = true; }
public signal void suggestion_accepted (); public signal void suggestion_accepted ();
public signal void suggestion_rejected (); public signal void suggestion_rejected ();
...@@ -47,7 +51,7 @@ public class Contacts.LinkSuggestionGrid : Grid { ...@@ -47,7 +51,7 @@ public class Contacts.LinkSuggestionGrid : Grid {
image_frame.hexpand = false; image_frame.hexpand = false;
image_frame.margin = 12; image_frame.margin = 12;
image_frame.show (); image_frame.show ();
attach (image_frame, 0, 0, 1, 2); grid.attach (image_frame, 0, 0, 1, 2);
this.description_label.xalign = 0; this.description_label.xalign = 0;
this.description_label.label = contact.is_main? this.description_label.label = contact.is_main?
......
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