[geary/bug/728002-webkit2: 19/140] Impromptu minor cell renderer cleanup (long story).



commit 330dc10f71b2749f2395c55abc361bd68c5d8184
Author: Michael James Gratton <mike vee net>
Date:   Wed Nov 23 12:01:31 2016 +1100

    Impromptu minor cell renderer cleanup (long story).

 .../conversation-list-cell-renderer.vala           |   34 +++++++++++++++----
 .../formatted-conversation-data.vala               |   12 +------
 2 files changed, 29 insertions(+), 17 deletions(-)
---
diff --git a/src/client/conversation-list/conversation-list-cell-renderer.vala 
b/src/client/conversation-list/conversation-list-cell-renderer.vala
index d678e9d..36e1d66 100644
--- a/src/client/conversation-list/conversation-list-cell-renderer.vala
+++ b/src/client/conversation-list/conversation-list-cell-renderer.vala
@@ -13,15 +13,26 @@ public class ConversationListCellRenderer : Gtk.CellRenderer {
     
     public ConversationListCellRenderer() {
     }
-    
-    public override void get_size(Gtk.Widget widget, Gdk.Rectangle? cell_area, out int x_offset, 
-        out int y_offset, out int width, out int height) {
+
+    public override void get_preferred_height(Gtk.Widget widget,
+                                              out int minimum_size,
+                                              out int natural_size) {
         if (example_data == null)
             style_changed(widget);
-        
-        example_data.get_size(widget, cell_area, out x_offset, out y_offset, out width, out height);
+
+        minimum_size = natural_size = example_data.get_height();
     }
-    
+
+    public override void get_preferred_width(Gtk.Widget widget,
+                                              out int minimum_size,
+                                              out int natural_size) {
+        // Set width to 1 (rather than 0) to work around certain
+        // themes that cause the conversation list to be shown as
+        // "squished":
+        // https://bugzilla.gnome.org/show_bug.cgi?id=713954
+        minimum_size = natural_size = 1;
+    }
+
     public override void render(Cairo.Context ctx, Gtk.Widget widget, Gdk.Rectangle background_area, 
         Gdk.Rectangle cell_area, Gtk.CellRendererState flags) {
         if (data != null)
@@ -42,5 +53,14 @@ public class ConversationListCellRenderer : Gtk.CellRenderer {
     public static void set_hover_selected(bool hover) {
         hover_selected = hover;
     }
-}
 
+    // This is implemented because it's required; ignore it and look at get_preferred_height() instead.
+    public override void get_size(Gtk.Widget widget, Gdk.Rectangle? cell_area, out int x_offset, 
+        out int y_offset, out int width, out int height) {
+        // Set values to avoid compiler warning.
+        x_offset = 0;
+        y_offset = 0;
+        width = 0;
+        height = 0;
+    }
+}
diff --git a/src/client/conversation-list/formatted-conversation-data.vala 
b/src/client/conversation-list/formatted-conversation-data.vala
index 922e94d..ae9afc6 100644
--- a/src/client/conversation-list/formatted-conversation-data.vala
+++ b/src/client/conversation-list/formatted-conversation-data.vala
@@ -230,17 +230,9 @@ public class FormattedConversationData : Geary.BaseObject {
     }
     
     // Must call calculate_sizes() first.
-    public void get_size(Gtk.Widget widget, Gdk.Rectangle? cell_area, out int x_offset, 
-        out int y_offset, out int width, out int height) {
+    public int get_height() {
         assert(cell_height != -1); // ensures calculate_sizes() was called.
-        
-        x_offset = 0;
-        y_offset = 0;
-        // set width to 1 (rather than 0) to work around certain themes that cause the
-        // conversation list to be shown as "squished":
-        // https://bugzilla.gnome.org/show_bug.cgi?id=713954
-        width = 1;
-        height = cell_height;
+        return cell_height;
     }
     
     // Can be used for rendering or calculating height.


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