[geary/wip/765516-gtk-widget-conversation-viewer: 139/142] Implement "Search for messages from" for email addresses.



commit 1c51b0d4a1f0dd40728969b1952978cf74806e7e
Author: Michael James Gratton <mike vee net>
Date:   Mon Aug 22 23:18:07 2016 +1000

    Implement "Search for messages from" for email addresses.

 src/client/application/geary-controller.vala       |    5 ++++
 .../conversation-viewer/conversation-message.vala  |   26 ++++++++++++++++----
 ui/conversation-message-menus.ui                   |    6 ++++
 3 files changed, 32 insertions(+), 5 deletions(-)
---
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index 1902547..389edeb 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -2794,6 +2794,11 @@ public class GearyController : Geary.BaseObject {
                         }
                     });
                 mview.save_image.connect(on_save_buffer_to_file);
+                mview.search_activated.connect((op, value) => {
+                        string search = op + ":" + value;
+                        show_search_bar(search);
+                        do_search(search);
+                    });
                 return true;
             });
         view.save_attachments.connect(on_save_attachments);
diff --git a/src/client/conversation-viewer/conversation-message.vala 
b/src/client/conversation-viewer/conversation-message.vala
index 250a9e7..d3417a3 100644
--- a/src/client/conversation-viewer/conversation-message.vala
+++ b/src/client/conversation-viewer/conversation-message.vala
@@ -91,6 +91,7 @@ public class ConversationMessage : Gtk.Grid {
     private const string ACTION_OPEN_INSPECTOR = "open_inspector";
     private const string ACTION_OPEN_LINK = "open_link";
     private const string ACTION_SAVE_IMAGE = "save_image";
+    private const string ACTION_SEARCH_FROM = "search_from";
     private const string ACTION_SELECT_ALL = "select_all";
 
 
@@ -158,6 +159,7 @@ public class ConversationMessage : Gtk.Grid {
     private MenuModel context_menu_email;
     private MenuModel context_menu_image;
     private MenuModel context_menu_main;
+    private MenuModel context_menu_contact;
     private MenuModel? context_menu_inspector = null;
 
     // Last known DOM element under the context menu
@@ -195,6 +197,9 @@ public class ConversationMessage : Gtk.Grid {
     /** Fired when the user saves an inline displayed image. */
     public signal void save_image(string? filename, Geary.Memory.Buffer buffer);
 
+    /** Fired when the user activates a specific search shortcut. */
+    public signal void search_activated(string operator, string value);
+
 
     /**
      * Constructs a new view to display an RFC 823 message headers and body.
@@ -231,6 +236,10 @@ public class ConversationMessage : Gtk.Grid {
                 ReplacedImage? replaced_image = get_replaced_image();
                 save_image(replaced_image.filename, replaced_image.buffer);
             });
+        add_action(ACTION_SEARCH_FROM, true, VariantType.STRING)
+            .activate.connect((param) => {
+                search_activated("from", param.get_string());
+            });
         add_action(ACTION_SELECT_ALL, true).activate.connect(() => {
                 web_view.select_all();
             });
@@ -246,6 +255,7 @@ public class ConversationMessage : Gtk.Grid {
         context_menu_email = (MenuModel) builder.get_object("context_menu_email");
         context_menu_image = (MenuModel) builder.get_object("context_menu_image");
         context_menu_main = (MenuModel) builder.get_object("context_menu_main");
+        context_menu_contact = (MenuModel) builder.get_object("context_menu_contact");
         if (Args.inspector) {
             context_menu_inspector =
                 (MenuModel) builder.get_object("context_menu_inspector");
@@ -624,12 +634,18 @@ public class ConversationMessage : Gtk.Grid {
         address_box.child_activated.connect((box, child) => {
                 AddressFlowBoxChild address_child = child as AddressFlowBoxChild;
                 if (address_child != null) {
-                    Menu menu = set_action_param_string(
-                        context_menu_email,
-                        "mailto:"; + address_child.address.address
-                    );
+                    string address = address_child.address.address;
+                    Menu model = new Menu();
+                    model.append_section(
+                        null, set_action_param_string(
+                            this.context_menu_email, "mailto:"; + address
+                    ));
+                    model.append_section(
+                        null, set_action_param_string(
+                            this.context_menu_contact, address
+                    ));
                     Gtk.Popover popover =
-                        new Gtk.Popover.from_model(child, menu);
+                        new Gtk.Popover.from_model(child, model);
                     popover.set_position(Gtk.PositionType.BOTTOM);
                     popover.show();
                 }
diff --git a/ui/conversation-message-menus.ui b/ui/conversation-message-menus.ui
index 3122e49..f589bf7 100644
--- a/ui/conversation-message-menus.ui
+++ b/ui/conversation-message-menus.ui
@@ -38,6 +38,12 @@
         <attribute name="action">msg.copy_selection</attribute>
       </item>
     </section>
+    <section id="context_menu_contact">
+      <item>
+        <attribute name="label" translatable="yes">Search for messages from</attribute>
+        <attribute name="action">msg.search_from</attribute>
+      </item>
+    </section>
     <section id="context_menu_inspector">
       <item>
         <attribute name="label" translatable="yes">_Inspect...</attribute>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]