[Xfce4-commits] <postler:master> Select the part button according to the part

Christian Dywan noreply at xfce.org
Fri Dec 17 04:12:03 CET 2010


Updating branch refs/heads/master
         to 23fe3e96f7ba361803dbf815e1c02edac6dc0e25 (commit)
       from b21b73adf3d580f8e266e4355b8ce0ea00cb83a0 (commit)

commit 23fe3e96f7ba361803dbf815e1c02edac6dc0e25
Author: Christian Dywan <christian at twotoasts.de>
Date:   Fri Dec 17 03:48:18 2010 +0100

    Select the part button according to the part
    
    If the part is chosen after parsing the message fully,
    we need to listen to the current-part property.

 postler/postler-content.vala |    3 ++-
 postler/postler-viewer.vala  |   20 ++++++++++++++++----
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/postler/postler-content.vala b/postler/postler-content.vala
index 6c14fef..761b7ba 100644
--- a/postler/postler-content.vala
+++ b/postler/postler-content.vala
@@ -877,7 +877,8 @@ public class Postler.Content : WebKit.WebView {
     }
 
     public void display_part (MessagePart message_part) {
-        current_part = message_part;
+        if (current_part != message_part)
+            current_part = message_part;
 
         string body_chunk;
         string mime_type = message_part.mime_type;
diff --git a/postler/postler-viewer.vala b/postler/postler-viewer.vala
index 68b85a5..36e23dc 100644
--- a/postler/postler-viewer.vala
+++ b/postler/postler-viewer.vala
@@ -13,7 +13,7 @@ public class Postler.Viewer : Gtk.VBox {
     Gtk.InfoBar infobar;
     Postler.Content content;
     Gtk.VBox message_parts;
-    Gtk.ToggleButton last_button;
+    Gtk.ToggleButton? last_button;
     Gtk.Toolbar findbar;
     Gtk.Entry find_entry;
 
@@ -47,6 +47,7 @@ public class Postler.Viewer : Gtk.VBox {
         message_parts.parent.parent.set_no_show_all (true);
         notify_message_parts (content, null);
         content.notify["message-parts"].connect (notify_message_parts);
+        content.notify["current-part"].connect (notify_current_part);
 
         findbar = new Gtk.Toolbar ();
         pack_start (findbar, false, false, 0);
@@ -108,7 +109,6 @@ public class Postler.Viewer : Gtk.VBox {
         var children = message_parts.get_children ();
         foreach (var child in children)
             child.destroy ();
-        uint index = 0;
         foreach (var part in content.message_parts) {
             string icon_name = icon_name_for_mime_type (part.mime_type, this);
             var icon = new Gtk.Image.from_icon_name (icon_name,
@@ -124,18 +124,30 @@ public class Postler.Viewer : Gtk.VBox {
                 button.active = true;
             }
             button.clicked.connect ((button) => {
-                last_button.active = false;
+                if (last_button != null)
+                    last_button.active = false;
                 last_button = button as Gtk.ToggleButton;
                 MessagePart current_part = button.get_data ("part");
                 content.display_part (current_part);
             });
             message_parts.pack_start (button, false, false, 0);
-            index++;
         }
         message_parts.parent.parent.set_no_show_all (false);
         scrollable.show_all ();
     }
 
+    void notify_current_part () {
+        foreach (var child in message_parts.get_children ()) {
+            MessagePart part = child.get_data ("part");
+            if (part == content.current_part) {
+                var button = child as Gtk.ToggleButton;
+                if (!button.active)
+                    button.active = true;
+                break;
+            }
+        }
+    }
+
     bool key_pressed (Gdk.EventKey event) {
         uint character = Gdk.unicode_to_keyval (event.keyval);
         if (character == (event.keyval | 0x01000000))



More information about the Xfce4-commits mailing list