[geary/wip/765516-gtk-widget-conversation-viewer: 26/58] Use two different buttons in ConversationMessage to show starred state.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/765516-gtk-widget-conversation-viewer: 26/58] Use two different buttons in ConversationMessage to show starred state.
- Date: Fri, 13 May 2016 02:18:33 +0000 (UTC)
commit 8da8aa35092b5572db0e80100aea8ab46267567d
Author: Michael James Gratton <mike vee net>
Date: Sat Apr 16 15:43:54 2016 +1000
Use two different buttons in ConversationMessage to show starred state.
Having two buttons means we don't need to change the image and handler
when clicked, just manage their visbility.
* src/client/conversation-viewer/conversation-message.vala
(ConversationMessage): Add both a star and unstar template child,
update their state as the message's state changes.
* ui/conversation-message.ui: Rename flag button to "star", add new
unstar button.
.../conversation-viewer/conversation-message.vala | 40 ++++++++++++-------
ui/conversation-message.ui | 31 ++++++++++++++-
2 files changed, 53 insertions(+), 18 deletions(-)
---
diff --git a/src/client/conversation-viewer/conversation-message.vala
b/src/client/conversation-viewer/conversation-message.vala
index 28fff94..afc42d4 100644
--- a/src/client/conversation-viewer/conversation-message.vala
+++ b/src/client/conversation-viewer/conversation-message.vala
@@ -82,7 +82,9 @@ public class ConversationMessage : Gtk.Box {
[GtkChild]
private Gtk.Image attachment_icon;
[GtkChild]
- private Gtk.Button flag_button;
+ private Gtk.Button star_button;
+ [GtkChild]
+ private Gtk.Button unstar_button;
[GtkChild]
private Gtk.MenuButton message_menubutton;
@@ -251,7 +253,8 @@ public class ConversationMessage : Gtk.Box {
header_revealer.set_reveal_child(true);
header_revealer.set_transition_type(revealer);
- flag_button.set_sensitive(true);
+ star_button.set_sensitive(true);
+ unstar_button.set_sensitive(true);
message_menubutton.set_sensitive(true);
// XXX this is pretty gross
@@ -268,7 +271,8 @@ public class ConversationMessage : Gtk.Box {
avatar_image.set_pixel_size(24); // XXX constant
preview_revealer.set_reveal_child(true);
header_revealer.set_reveal_child(false);
- flag_button.set_sensitive(false);
+ star_button.set_sensitive(false);
+ unstar_button.set_sensitive(false);
message_menubutton.set_sensitive(false);
body_revealer.set_reveal_child(false);
}
@@ -369,8 +373,24 @@ public class ConversationMessage : Gtk.Box {
}
public void update_flags(Geary.Email email) {
- toggle_class("read");
- toggle_class("starred");
+ Geary.EmailFlags flags = email.email_flags;
+ Gtk.StyleContext style = get_style_context();
+
+ if (flags.is_unread()) {
+ style.add_class("geary_unread");
+ } else {
+ style.remove_class("geary_unread");
+ }
+
+ if (flags.is_flagged()) {
+ style.add_class("geary_starred");
+ star_button.hide();
+ unstar_button.show();
+ } else {
+ style.remove_class("geary_starred");
+ star_button.show();
+ unstar_button.hide();
+ }
//if (email.email_flags.is_outbox_sent()) {
// email_warning.set_inner_html(
@@ -1069,16 +1089,6 @@ public class ConversationMessage : Gtk.Box {
// return containing_folder.special_folder_type == Geary.SpecialFolderType.DRAFTS;
// }
- private void toggle_class(string cls) {
- Gtk.StyleContext context = get_style_context();
- if (context.has_class(cls)) {
- context.add_class(cls);
- } else {
- context.remove_class(cls);
- }
-
- }
-
private static bool is_content_type_supported_inline(Geary.Mime.ContentType content_type) {
foreach (string mime_type in INLINE_MIME_TYPES) {
try {
diff --git a/ui/conversation-message.ui b/ui/conversation-message.ui
index e88210f..286581a 100644
--- a/ui/conversation-message.ui
+++ b/ui/conversation-message.ui
@@ -406,13 +406,14 @@
</packing>
</child>
<child>
- <object class="GtkButton" id="flag_button">
+ <object class="GtkButton" id="star_button">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
- <property name="tooltip_text" translatable="yes">Toggle this message's flag</property>
+ <property name="tooltip_text" translatable="yes">Mark this message as starred</property>
<property name="valign">start</property>
+ <property name="action_name">win.message_star</property>
<property name="relief">none</property>
<child>
<object class="GtkImage">
@@ -429,6 +430,30 @@
</packing>
</child>
<child>
+ <object class="GtkButton" id="unstar_button">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Mark this message as not starred</property>
+ <property name="valign">start</property>
+ <property name="action_name">win.message_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="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkMenuButton" id="message_menubutton">
<property name="visible">True</property>
<property name="sensitive">False</property>
@@ -448,7 +473,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">2</property>
+ <property name="position">3</property>
</packing>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]