[gtk+/treeview-refactor-staging: 10/13] Added GtkTreeViewColumn:cell-area construct-only property.
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/treeview-refactor-staging: 10/13] Added GtkTreeViewColumn:cell-area construct-only property.
- Date: Sat, 4 Dec 2010 08:00:39 +0000 (UTC)
commit 691eca3b002c1fb2f84bdae3e1908f888ff363e2
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Wed Dec 1 23:26:25 2010 +0900
Added GtkTreeViewColumn:cell-area construct-only property.
Allow feeding treeviewcolumn a custom cell-area (or not a custom one,
but allow sharing the cell-area with say, the combo-box area).
This patch also:
- Fixes signal connections to the area (now they do eventually get
disconnected at dispose time, they are handled regardless if a
treeview is set but execute safely, at least there is only one
connection/disconnection).
- Fixes refcounting on the cell_area (GtkCellArea is GInitiallyUnowned).
- Adds a constructor() in order to build the cell-area if one has
not been provided by the caller before hand at g_object_new()
construct time.
gtk/gtktreeviewcolumn.c | 99 +++++++++++++++++++++++++++++++++++------------
1 files changed, 74 insertions(+), 25 deletions(-)
---
diff --git a/gtk/gtktreeviewcolumn.c b/gtk/gtktreeviewcolumn.c
index e0291b1..950e676 100644
--- a/gtk/gtktreeviewcolumn.c
+++ b/gtk/gtktreeviewcolumn.c
@@ -193,7 +193,8 @@ enum
PROP_REORDERABLE,
PROP_SORT_INDICATOR,
PROP_SORT_ORDER,
- PROP_SORT_COLUMN_ID
+ PROP_SORT_COLUMN_ID,
+ PROP_CELL_AREA
};
enum
@@ -394,6 +395,21 @@ gtk_tree_view_column_class_init (GtkTreeViewColumnClass *class)
-1,
GTK_PARAM_READWRITE));
+ /**
+ * GtkTreeViewColumn:cell-area:
+ *
+ * The #GtkCellArea used to layout cell renderers for this column.
+ *
+ * Since: 3.0
+ */
+ g_object_class_install_property (object_class,
+ PROP_CELL_AREA,
+ g_param_spec_object ("cell-area",
+ P_("Cell Area"),
+ P_("The GtkCellArea used to layout cells"),
+ GTK_TYPE_CELL_AREA,
+ GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
g_type_class_add_private (class, sizeof (GtkTreeViewColumnPrivate));
}
@@ -445,9 +461,40 @@ gtk_tree_view_column_init (GtkTreeViewColumn *tree_column)
priv->fixed_width = 1;
priv->use_resized_width = FALSE;
priv->title = g_strdup ("");
+}
+
+static GObject *
+gtk_tree_view_column_constructor (GType type,
+ guint n_construct_properties,
+ GObjectConstructParam *construct_properties)
+{
+ GtkTreeViewColumn *tree_column;
+ GtkTreeViewColumnPrivate *priv;
+ GObject *object;
+
+ object = G_OBJECT_CLASS (gtk_tree_view_column_parent_class)->constructor
+ (type, n_construct_properties, construct_properties);
+
+ tree_column = (GtkTreeViewColumn *) object;
+ priv = tree_column->priv;
+
+ if (!priv->cell_area)
+ {
+ priv->cell_area = gtk_cell_area_box_new ();
+ g_object_ref_sink (priv->cell_area);
+ }
- priv->cell_area = gtk_cell_area_box_new ();
gtk_cell_area_set_style_detail (priv->cell_area, "treeview");
+
+ priv->add_editable_signal =
+ g_signal_connect (priv->cell_area, "add-editable",
+ G_CALLBACK (gtk_tree_view_column_add_editable_callback),
+ tree_column);
+ priv->remove_editable_signal =
+ g_signal_connect (priv->cell_area, "remove-editable",
+ G_CALLBACK (gtk_tree_view_column_remove_editable_callback),
+ tree_column);
+
priv->cell_area_context = gtk_cell_area_create_context (priv->cell_area);
priv->context_changed_signal =
@@ -476,8 +523,15 @@ gtk_tree_view_column_dispose (GObject *object)
if (priv->cell_area)
{
+ g_signal_handler_disconnect (priv->cell_area,
+ priv->add_editable_signal);
+ g_signal_handler_disconnect (priv->cell_area,
+ priv->remove_editable_signal);
+
g_object_unref (priv->cell_area);
priv->cell_area = NULL;
+ priv->add_editable_signal = 0;
+ priv->remove_editable_signal = 0;
}
if (priv->child)
@@ -598,7 +652,7 @@ gtk_tree_view_column_set_property (GObject *object,
area = g_value_get_object (value);
if (area)
- tree_column->cell_area = g_object_ref_sink (area);
+ tree_column->priv->cell_area = g_object_ref_sink (area);
break;
default:
@@ -705,7 +759,7 @@ gtk_tree_view_column_get_property (GObject *object,
break;
case PROP_CELL_AREA:
- g_value_set_object (value, tree_column->cell_area);
+ g_value_set_object (value, tree_column->priv->cell_area);
break;
default:
@@ -1206,15 +1260,18 @@ gtk_tree_view_column_add_editable_callback (GtkCellArea *area,
GtkTreeViewColumnPrivate *priv = column->priv;
GtkTreePath *path;
- path = gtk_tree_path_new_from_string (path_string);
-
- _gtk_tree_view_add_editable (GTK_TREE_VIEW (priv->tree_view),
- column,
- path,
- edit_widget,
- cell_area);
-
- gtk_tree_path_free (path);
+ if (priv->tree_view)
+ {
+ path = gtk_tree_path_new_from_string (path_string);
+
+ _gtk_tree_view_add_editable (GTK_TREE_VIEW (priv->tree_view),
+ column,
+ path,
+ edit_widget,
+ cell_area);
+
+ gtk_tree_path_free (path);
+ }
}
static void
@@ -1226,9 +1283,10 @@ gtk_tree_view_column_remove_editable_callback (GtkCellArea *area,
GtkTreeViewColumn *column = user_data;
GtkTreeViewColumnPrivate *priv = column->priv;
- _gtk_tree_view_remove_editable (GTK_TREE_VIEW (priv->tree_view),
- column,
- edit_widget);
+ if (priv->tree_view)
+ _gtk_tree_view_remove_editable (GTK_TREE_VIEW (priv->tree_view),
+ column,
+ edit_widget);
}
/* Exported Private Functions.
@@ -1325,15 +1383,6 @@ _gtk_tree_view_column_set_tree_view (GtkTreeViewColumn *column,
priv->tree_view = GTK_WIDGET (tree_view);
gtk_tree_view_column_create_button (column);
- priv->add_editable_signal =
- g_signal_connect (priv->cell_area, "add-editable",
- G_CALLBACK (gtk_tree_view_column_add_editable_callback),
- column);
- priv->remove_editable_signal =
- g_signal_connect (priv->cell_area, "remove-editable",
- G_CALLBACK (gtk_tree_view_column_remove_editable_callback),
- column);
-
priv->property_changed_signal =
g_signal_connect_swapped (tree_view,
"notify::model",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]