[geary/wip/730682-refine-convo-list] Convert ConversationListItem to directly extend Gtk.ListBoxRow.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/730682-refine-convo-list] Convert ConversationListItem to directly extend Gtk.ListBoxRow.
- Date: Sun, 24 Dec 2017 08:11:27 +0000 (UTC)
commit 79c4e111442ad449f3ec08f61952045b834d0ef7
Author: Michael James Gratton <mike vee net>
Date: Sun Dec 24 16:52:29 2017 +1030
Convert ConversationListItem to directly extend Gtk.ListBoxRow.
.../conversation-list/conversation-list-item.vala | 2 +-
.../conversation-list/conversation-list.vala | 24 +-
ui/conversation-list-item.ui | 268 ++++++++++----------
3 files changed, 150 insertions(+), 144 deletions(-)
---
diff --git a/src/client/conversation-list/conversation-list-item.vala
b/src/client/conversation-list/conversation-list-item.vala
index 29dcb05..91f545a 100644
--- a/src/client/conversation-list/conversation-list-item.vala
+++ b/src/client/conversation-list/conversation-list-item.vala
@@ -9,7 +9,7 @@
* A Gtk.ListBoxRow child that displays a conversation in the list.
*/
[GtkTemplate (ui = "/org/gnome/Geary/conversation-list-item.ui")]
-public class ConversationListItem : Gtk.Grid {
+public class ConversationListItem : Gtk.ListBoxRow {
private const string STARRED_CLASS = "geary-starred";
private const string UNREAD_CLASS = "geary-unread";
diff --git a/src/client/conversation-list/conversation-list.vala
b/src/client/conversation-list/conversation-list.vala
index 7c12e3e..caf8d16 100644
--- a/src/client/conversation-list/conversation-list.vala
+++ b/src/client/conversation-list/conversation-list.vala
@@ -111,14 +111,10 @@ public class ConversationList : Gtk.ListBox {
public void select_conversation(Geary.App.Conversation target) {
for (int i = 0; i < this.model.get_n_items(); i++) {
- Gtk.ListBoxRow? row = get_row_at_index(i);
- if (row != null) {
- ConversationListItem item =
- (ConversationListItem) row.get_child();
- if (item.conversation == target) {
- select_row(row);
- break;
- }
+ ConversationListItem? row = get_item_at_index(i);
+ if (row.conversation == target) {
+ select_row(row);
+ break;
}
}
}
@@ -129,8 +125,12 @@ public class ConversationList : Gtk.ListBox {
return visible;
}
- private Gtk.ListBoxRow? restore_selection() {
- Gtk.ListBoxRow? row = null;
+ private inline ConversationListItem? get_item_at_index(int index) {
+ return get_row_at_index(index) as ConversationListItem;
+ }
+
+ private ConversationListItem? restore_selection() {
+ ConversationListItem? row = null;
if (this.selected_index >= 0) {
int new_index = this.selected_index;
if (new_index >= this.model.get_n_items()) {
@@ -165,7 +165,7 @@ public class ConversationList : Gtk.ListBox {
private void selection_changed() {
if (!this.selection_frozen) {
Geary.App.Conversation? selected = null;
- Gtk.ListBoxRow? row = get_selected_row();
+ ConversationListItem? row = get_selected_row() as ConversationListItem;
// If a row was de-selected then we need to work out if
// that was because of a conversation being removed from
@@ -177,7 +177,7 @@ public class ConversationList : Gtk.ListBox {
}
if (row != null) {
- selected = ((ConversationListItem) row.get_child()).conversation;
+ selected = row.conversation;
this.selected_index = row.get_index();
} else {
this.selected_index = -1;
diff --git a/ui/conversation-list-item.ui b/ui/conversation-list-item.ui
index a3f1547..c6b2e87 100644
--- a/ui/conversation-list-item.ui
+++ b/ui/conversation-list-item.ui
@@ -2,166 +2,172 @@
<!-- Generated with glade 3.20.0 -->
<interface>
<requires lib="gtk+" version="3.20"/>
- <template class="ConversationListItem" parent="GtkGrid">
+ <template class="ConversationListItem" parent="GtkListBoxRow">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkLabel" id="participants">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">start</property>
- <property name="valign">start</property>
- <property name="margin_bottom">2</property>
- <property name="hexpand">True</property>
- <property name="label" translatable="yes">Participants</property>
- <property name="ellipsize">end</property>
- <property name="single_line_mode">True</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="subject">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">start</property>
- <property name="hexpand">True</property>
- <property name="label" translatable="yes">Subject</property>
- <property name="ellipsize">end</property>
- <property name="single_line_mode">True</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">1</property>
- <property name="width">2</property>
- </packing>
- </child>
+ <property name="can_focus">True</property>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="vexpand">True</property>
<child>
- <object class="GtkButton" id="star_button">
+ <object class="GtkLabel" id="participants">
<property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="no_show_all">True</property>
- <property name="tooltip_text" translatable="yes" comments="Note: The application will never show
this button at the same time as unstar_button, one will always be hidden.">Mark this message as
starred</property>
- <property name="valign">center</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="valign">start</property>
+ <property name="margin_bottom">2</property>
+ <property name="hexpand">True</property>
+ <property name="label" translatable="yes">Participants</property>
+ <property name="ellipsize">end</property>
+ <property name="single_line_mode">True</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="subject">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="hexpand">True</property>
+ <property name="label" translatable="yes">Subject</property>
+ <property name="ellipsize">end</property>
+ <property name="single_line_mode">True</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ <property name="width">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkGrid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="vexpand">True</property>
- <property name="action_name">eml.star</property>
- <property name="relief">none</property>
<child>
- <object class="GtkImage">
+ <object class="GtkButton" id="star_button">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="icon_name">non-starred-symbolic</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="no_show_all">True</property>
+ <property name="tooltip_text" translatable="yes" comments="Note: The application will never
show this button at the same time as unstar_button, one will always be hidden.">Mark this message as
starred</property>
+ <property name="valign">center</property>
+ <property name="vexpand">True</property>
+ <property name="action_name">eml.star</property>
+ <property name="relief">none</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">non-starred-symbolic</property>
+ </object>
+ </child>
</object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="unstar_button">
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="no_show_all">True</property>
+ <property name="tooltip_text" translatable="yes" comments="Note: The application will never
show this button at the same time as star_button, one will always be hidden.">Mark this message as not
starred</property>
+ <property name="valign">center</property>
+ <property name="vexpand">True</property>
+ <property name="action_name">eml.unstar</property>
+ <property name="relief">none</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">starred-symbolic</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="height">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="preview">
+ <property name="can_focus">False</property>
+ <property name="no_show_all">True</property>
+ <property name="halign">start</property>
+ <property name="hexpand">True</property>
+ <property name="label" translatable="yes" comments="Placeholder for preview text used while
loading the preview for a message in the conversation list.">…</property>
+ <property name="ellipsize">end</property>
+ <property name="single_line_mode">True</property>
+ <property name="xalign">0</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">2</property>
+ <property name="width">2</property>
</packing>
</child>
<child>
- <object class="GtkButton" id="unstar_button">
- <property name="sensitive">False</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
+ <object class="GtkLabel" id="count">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="no_show_all">True</property>
- <property name="tooltip_text" translatable="yes" comments="Note: The application will never show
this button at the same time as star_button, one will always be hidden.">Mark this message as not
starred</property>
+ <property name="halign">end</property>
<property name="valign">center</property>
<property name="vexpand">True</property>
- <property name="action_name">eml.unstar</property>
- <property name="relief">none</property>
- <child>
- <object class="GtkImage">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="icon_name">starred-symbolic</property>
- </object>
- </child>
+ <property name="label" translatable="yes">0</property>
+ <attributes>
+ <attribute name="scale" value="0.95999999999999996"/>
+ </attributes>
+ <style>
+ <class name="geary-count"/>
+ </style>
</object>
<packing>
- <property name="left_attach">0</property>
+ <property name="left_attach">3</property>
+ <property name="top_attach">1</property>
+ <property name="height">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="date">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">end</property>
+ <property name="valign">start</property>
+ <property name="label" translatable="yes">Date</property>
+ <style>
+ <class name="geary-date"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
<property name="top_attach">0</property>
+ <property name="width">2</property>
</packing>
</child>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- <property name="height">3</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="preview">
- <property name="can_focus">False</property>
- <property name="no_show_all">True</property>
- <property name="halign">start</property>
- <property name="hexpand">True</property>
- <property name="label" translatable="yes" comments="Placeholder for preview text used while loading
the preview for a message in the conversation list.">…</property>
- <property name="ellipsize">end</property>
- <property name="single_line_mode">True</property>
- <property name="xalign">0</property>
- <style>
- <class name="dim-label"/>
- </style>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">2</property>
- <property name="width">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="count">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="no_show_all">True</property>
- <property name="halign">end</property>
- <property name="valign">center</property>
- <property name="vexpand">True</property>
- <property name="label" translatable="yes">0</property>
- <attributes>
- <attribute name="scale" value="0.95999999999999996"/>
- </attributes>
- <style>
- <class name="geary-count"/>
- </style>
- </object>
- <packing>
- <property name="left_attach">3</property>
- <property name="top_attach">1</property>
- <property name="height">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="date">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">end</property>
- <property name="valign">start</property>
- <property name="label" translatable="yes">Date</property>
<style>
- <class name="geary-date"/>
+ <class name="geary-conversation-list-item"/>
</style>
</object>
- <packing>
- <property name="left_attach">2</property>
- <property name="top_attach">0</property>
- <property name="width">2</property>
- </packing>
</child>
- <style>
- <class name="geary-conversation-list-item"/>
- </style>
</template>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]