[glom] Use the new Gtk::ComboBox CellArea API to align columns properly.



commit f9a7f0c25c8921b2d225131bcb3696db0b6a0814
Author: Murray Cumming <murrayc murrayc com>
Date:   Thu Feb 10 12:07:44 2011 +0100

    Use the new Gtk::ComboBox CellArea API to align columns properly.
    
    * glom/mode_data/datawidget/combo.cc: Get the CellAreaBox and use its
    more-useful pack() method instead of the standard one, so that the columns
    really align.

 ChangeLog                          |    8 ++++++++
 glom/mode_data/datawidget/combo.cc |   18 +++++++++---------
 2 files changed, 17 insertions(+), 9 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 03d4cfa..d11b5c0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-02-10  Murray Cumming  <murrayc murrayc com>
+
+	Use the new Gtk::ComboBox CellArea API to align columns properly.
+
+	* glom/mode_data/datawidget/combo.cc: Get the CellAreaBox and use its 
+	more-useful pack() method instead of the standard one, so that the columns 
+	really align.
+
 1.19.3:
 
 2011-02-07  Murray Cumming  <murrayc murrayc com>
diff --git a/glom/mode_data/datawidget/combo.cc b/glom/mode_data/datawidget/combo.cc
index 9f86217..670f360 100644
--- a/glom/mode_data/datawidget/combo.cc
+++ b/glom/mode_data/datawidget/combo.cc
@@ -95,11 +95,17 @@ void ComboGlom::set_choices_fixed(const FieldFormatting::type_list_values& list_
     clear(); //This breaks GtkCombo with has-entry.
   }
 
+  Glib::RefPtr<Gtk::CellAreaBox> cell_area = 
+    Glib::RefPtr<Gtk::CellAreaBox>::cast_dynamic(get_area());
+  if(!cell_area)
+  {
+    std::cerr << G_STRFUNC << ": Unexpected or null CellArea type." << std::endl;
+    return;
+  }
+  
   const guint columns_count = model->get_n_columns();
   for(guint i = 0; i < columns_count; ++i)
   {
-
-
     //set_entry_text_column() adds its own CellRenderer,
     //which we cannot replace without confusing (and crashing) GtkComboBox.
     if(i == 0 && get_has_entry())
@@ -109,13 +115,7 @@ void ComboGlom::set_choices_fixed(const FieldFormatting::type_list_values& list_
     cell->property_xalign() = 0.0f;
 
     //Use the renderer:
-    //We don't expand the first column, so we can align the other columns.
-    //Otherwise the other columns appear center-aligned.
-    //This bug is relevant: https://bugzilla.gnome.org/show_bug.cgi?id=629133
-    if(i == 0)
-      pack_start(*cell, false);
-    else
-      pack_start(*cell, false);
+    cell_area->pack_start(*cell, true /* expand */, true /* align */, true /* fixed */);
 
     //Make the renderer render the column:
     add_attribute(*cell, "text", i);



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