Re: ANNOUNCE: gtkmm 2.91.7



Sorry, I pressed reply instead of reply to all.


---------- Forwarded message ----------
From: Krzesimir Nowak <qdlacz gmail com>
Date: 2010/12/24
Subject: Re: ANNOUNCE: gtkmm 2.91.7
To: Murray Cumming <murrayc murrayc com>


2010/12/24 Murray Cumming <murrayc murrayc com>:
> On Fri, 2010-12-24 at 13:14 +0100, Krzesimir Nowak wrote:
>> 2010/12/22 Murray Cumming <murrayc murrayc com>:
>> > On Wed, 2010-12-22 at 12:31 +0100, Murray Cumming wrote:
>> >> WARNING: TreeViews seems to be mostly empty in this version, but I'm releasing
>> >> this unstable version anyway. Maybe someone can discover what the problem is.
>> >
>> > This is not a problem with plain GTK+, so maybe something in gtkmm is
>> > causing it. Maybe some vfunc, for instance.
>> >
>> > I'm not likely to have much time over the next few weeks, so I'd
>> > appreciate any help in debugging this.
>> >
>>
>> I have some suspicions about newly introduced cell stuff.
>> Especially a piece of code in gtkcelllayout.c beginning from line 133:
>>
>> if (iface->pack_start)
>>   iface->pack_start (cell_layout, cell, expand);
>> else
>>   {
>>     area = iface->get_area (cell_layout);
>>
>>     if (area)
>>       gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (area), cell, expand);
>>   }
>>
>> The `if (iface->pack_start)' is true, because gtkmm puts there its own
>> function calling a C++ virtual method if possible. But none is called
>> when a type is not a derived one (here - Gtk::CellRendererText), so
>> it tries to call the original C vfunc. But this vfunc is NULL, so in the
>> end `iface->pack_start (cell_layout, cell, expand);' is a NOP. In that
>> case `else' part should be executed, but in C++ it isn't. This should
>> probably be fixed in C by giving GtkCellRendererText pack_start
>> vfunc a body in `else'. What do you think?
>
> CCing Tristan, the author of that code, who might agree.
>
> In general, yes, it is a bad idea for C GObjects to check if a vfunc is
> NULL. It should do default behaviour in a default implementation, not in
> the case that there is no default implementation.
>

Just to check I quickly added the default implementations of GtkCellLayout
methods in GtkTreeViewColumn and then tree example
in gtkmm-documentation (examples/book/treeview/tree) started working
like a charm. I'm attaching the patch just to see if it is correct way of doing
things.
From bc87971bbacdc479caa1a4da284a28c891d90a64 Mon Sep 17 00:00:00 2001
From: Krzesimir Nowak <qdlacz gmail com>
Date: Fri, 24 Dec 2010 14:23:08 +0100
Subject: [PATCH] Added default implementations of GtkCellLayout methods in GtkTreeViewColumn.

---
 gtk/gtktreeviewcolumn.c |   92 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 92 insertions(+), 0 deletions(-)

diff --git a/gtk/gtktreeviewcolumn.c b/gtk/gtktreeviewcolumn.c
index 43f5921..71a296a 100644
--- a/gtk/gtktreeviewcolumn.c
+++ b/gtk/gtktreeviewcolumn.c
@@ -76,6 +76,28 @@ static GObject *gtk_tree_view_column_constructor               (GType
 
 /* GtkCellLayout implementation */
 static GtkCellArea *gtk_tree_view_column_cell_layout_get_area  (GtkCellLayout           *cell_layout);
+static void gtk_tree_view_column_cell_layout_pack_start        (GtkCellLayout           *cell_layout,
+                                                                GtkCellRenderer         *cell,
+                                                                gboolean                 expand);
+static void gtk_tree_view_column_cell_layout_pack_end          (GtkCellLayout           *cell_layout,
+                                                                GtkCellRenderer         *cell,
+                                                                gboolean                 expand);
+static void gtk_tree_view_column_cell_layout_clear             (GtkCellLayout           *cell_layout);
+static void gtk_tree_view_column_cell_layout_add_attribute     (GtkCellLayout           *cell_layout,
+                                                                GtkCellRenderer         *cell,
+                                                                const gchar             *attribute,
+                                                                gint                     column);
+static void gtk_tree_view_column_cell_layout_clear_attributes  (GtkCellLayout           *cell_layout,
+                                                                GtkCellRenderer         *cell);
+static void gtk_tree_view_column_cell_layout_set_cell_data_func(GtkCellLayout           *cell_layout,
+                                                                GtkCellRenderer         *cell,
+                                                                GtkCellLayoutDataFunc    func,
+                                                                gpointer                 func_data,
+                                                                GDestroyNotify           destroy);
+static void gtk_tree_view_column_cell_layout_reorder           (GtkCellLayout           *cell_layout,
+                                                                GtkCellRenderer         *cell,
+                                                                gint                     position);
+static GList* gtk_tree_view_column_cell_layout_get_cells       (GtkCellLayout           *cell_layout);
 
 /* Button handling code */
 static void gtk_tree_view_column_create_button                 (GtkTreeViewColumn       *tree_column);
@@ -436,6 +458,14 @@ static void
 gtk_tree_view_column_cell_layout_init (GtkCellLayoutIface *iface)
 {
   iface->get_area = gtk_tree_view_column_cell_layout_get_area;
+  iface->pack_start = gtk_tree_view_column_cell_layout_pack_start;
+  iface->pack_end = gtk_tree_view_column_cell_layout_pack_end;
+  iface->clear = gtk_tree_view_column_cell_layout_clear;
+  iface->add_attribute = gtk_tree_view_column_cell_layout_add_attribute;
+  iface->clear_attributes = gtk_tree_view_column_cell_layout_clear_attributes;
+  iface->set_cell_data_func = gtk_tree_view_column_cell_layout_set_cell_data_func;
+  iface->reorder = gtk_tree_view_column_cell_layout_reorder;
+  iface->get_cells = gtk_tree_view_column_cell_layout_get_cells;
 }
 
 static void
@@ -790,6 +820,68 @@ gtk_tree_view_column_cell_layout_get_area (GtkCellLayout   *cell_layout)
   return priv->cell_area;
 }
 
+static void
+gtk_tree_view_column_cell_layout_pack_start (GtkCellLayout   *cell_layout,
+                                             GtkCellRenderer *cell,
+                                             gboolean         expand)
+{
+  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (gtk_tree_view_column_cell_layout_get_area(cell_layout)), cell, expand);
+}
+
+static void
+gtk_tree_view_column_cell_layout_pack_end (GtkCellLayout   *cell_layout,
+                                           GtkCellRenderer *cell,
+                                           gboolean         expand)
+{
+  gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (gtk_tree_view_column_cell_layout_get_area(cell_layout)), cell, expand);
+}
+
+static void
+gtk_tree_view_column_cell_layout_clear (GtkCellLayout *cell_layout)
+{
+  gtk_cell_layout_clear (GTK_CELL_LAYOUT (gtk_tree_view_column_cell_layout_get_area(cell_layout)));
+}
+
+static void
+gtk_tree_view_column_cell_layout_add_attribute (GtkCellLayout   *cell_layout,
+                                                GtkCellRenderer *cell,
+                                                const gchar     *attribute,
+                                                gint             column)
+{
+  gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (gtk_tree_view_column_cell_layout_get_area(cell_layout)), cell, attribute, column);
+}
+
+static void
+gtk_tree_view_column_cell_layout_clear_attributes (GtkCellLayout   *cell_layout,
+                                                   GtkCellRenderer *cell)
+{
+  gtk_cell_layout_clear_attributes (GTK_CELL_LAYOUT (gtk_tree_view_column_cell_layout_get_area(cell_layout)), cell);
+}
+
+static void
+gtk_tree_view_column_cell_layout_set_cell_data_func (GtkCellLayout         *cell_layout,
+                                                     GtkCellRenderer       *cell,
+                                                     GtkCellLayoutDataFunc  func,
+                                                     gpointer               func_data,
+                                                     GDestroyNotify         destroy)
+{
+  gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (gtk_tree_view_column_cell_layout_get_area(cell_layout)), cell, func, func_data, destroy);
+}
+
+static void
+gtk_tree_view_column_cell_layout_reorder (GtkCellLayout   *cell_layout,
+                                          GtkCellRenderer *cell,
+                                          gint             position)
+{
+  gtk_cell_layout_reorder (GTK_CELL_LAYOUT (gtk_tree_view_column_cell_layout_get_area(cell_layout)), cell, position);
+}
+
+static GList*
+gtk_tree_view_column_cell_layout_get_cells (GtkCellLayout *cell_layout)
+{
+  return gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (gtk_tree_view_column_cell_layout_get_area(cell_layout)));
+}
+
 /* Button handling code
  */
 static void
-- 
1.7.0.4



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