summaryrefslogtreecommitdiff
path: root/gtk/gtkcellrenderer.c
diff options
context:
space:
mode:
authorJonathan Blandford <jrb@redhat.com>2001-06-30 02:38:17 +0000
committerJonathan Blandford <jrb@src.gnome.org>2001-06-30 02:38:17 +0000
commitee5ff7ddc23a90018b35102ac87e6ac41928da10 (patch)
tree4fc92ac89e40d45262882177cffc21521c50651c /gtk/gtkcellrenderer.c
parent49c1e6dc8969a06d5b016700f3a64e31d082b7e3 (diff)
downloadgtk+-ee5ff7ddc23a90018b35102ac87e6ac41928da10.tar.gz
changed new_with_types to just plain new, fixing the number of columns,
Fri Jun 29 22:13:28 2001 Jonathan Blandford <jrb@redhat.com> * gtk/gtktreestore.c (gtk_tree_store_new): changed new_with_types to just plain new, fixing the number of columns, and column types at creation time. * gtk/gtkliststore.c (gtk_list_store_new): ditto. * gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_set_fixed_height_from_font): FIX the height to a specific font. * gtk/gtktreeview.c (gtk_tree_view_is_expander_column): fix brokenness. * tests/*c: change to work with new store models.
Diffstat (limited to 'gtk/gtkcellrenderer.c')
-rw-r--r--gtk/gtkcellrenderer.c110
1 files changed, 109 insertions, 1 deletions
diff --git a/gtk/gtkcellrenderer.c b/gtk/gtkcellrenderer.c
index 69e4711ec6..610d807bdb 100644
--- a/gtk/gtkcellrenderer.c
+++ b/gtk/gtkcellrenderer.c
@@ -40,6 +40,8 @@ enum {
PROP_YALIGN,
PROP_XPAD,
PROP_YPAD,
+ PROP_WIDTH,
+ PROP_HEIGHT,
};
@@ -78,6 +80,8 @@ gtk_cell_renderer_init (GtkCellRenderer *cell)
cell->can_activate = FALSE;
cell->visible = TRUE;
+ cell->width = -1;
+ cell->height = -1;
cell->xalign = 0.5;
cell->yalign = 0.5;
cell->xpad = 0;
@@ -156,6 +160,28 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class)
2,
G_PARAM_READABLE |
G_PARAM_WRITABLE));
+
+ g_object_class_install_property (object_class,
+ PROP_WIDTH,
+ g_param_spec_int ("width",
+ _("width"),
+ _("The fixed width."),
+ -1,
+ 100,
+ -1,
+ G_PARAM_READABLE |
+ G_PARAM_WRITABLE));
+
+ g_object_class_install_property (object_class,
+ PROP_HEIGHT,
+ g_param_spec_int ("height",
+ _("height"),
+ _("The fixed height."),
+ -1,
+ 100,
+ -1,
+ G_PARAM_READABLE |
+ G_PARAM_WRITABLE));
}
static void
@@ -186,6 +212,12 @@ gtk_cell_renderer_get_property (GObject *object,
case PROP_YPAD:
g_value_set_uint (value, cell->ypad);
break;
+ case PROP_WIDTH:
+ g_value_set_int (value, cell->width);
+ break;
+ case PROP_HEIGHT:
+ g_value_set_int (value, cell->height);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -227,6 +259,14 @@ gtk_cell_renderer_set_property (GObject *object,
cell->ypad = g_value_get_uint (value);
g_object_notify (object, "ypad");
break;
+ case PROP_WIDTH:
+ cell->width = g_value_get_int (value);
+ g_object_notify (object, "width");
+ break;
+ case PROP_HEIGHT:
+ cell->height = g_value_get_int (value);
+ g_object_notify (object, "height");
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -257,10 +297,29 @@ gtk_cell_renderer_get_size (GtkCellRenderer *cell,
gint *width,
gint *height)
{
+ gint *real_width = NULL;
+ gint *real_height = NULL;
+
g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
g_return_if_fail (GTK_CELL_RENDERER_GET_CLASS (cell)->get_size != NULL);
- GTK_CELL_RENDERER_GET_CLASS (cell)->get_size (cell, widget, cell_area, x_offset, y_offset, width, height);
+ if (width)
+ {
+ if (cell->width == -1)
+ real_width = width;
+ else
+ *width = cell->width;
+ }
+ if (height)
+ {
+ if (cell->height == -1)
+ real_height = height;
+ else
+ *height = cell->height;
+ }
+
+ if (real_width || real_height)
+ GTK_CELL_RENDERER_GET_CLASS (cell)->get_size (cell, widget, cell_area, x_offset, y_offset, real_width, real_height);
}
/**
@@ -353,3 +412,52 @@ gtk_cell_renderer_event (GtkCellRenderer *cell,
flags);
}
+/**
+ * gtk_cell_renderer_set_fixed_size:
+ * @cell: A #GtkCellRenderer
+ * @width: the width of the cell renderer, or -1
+ * @height: the height of the cell renderer, or -1
+ *
+ * Sets the renderer size to be explicit, independent of the properties set.
+ **/
+void
+gtk_cell_renderer_set_fixed_size (GtkCellRenderer *cell,
+ gint width,
+ gint height)
+{
+ g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
+ g_return_if_fail (width >= -1 && height >= -1);
+
+ if (width != cell->width)
+ {
+ cell->width = width;
+ g_object_notify (G_OBJECT (cell), "width");
+ }
+
+ if (height != cell->height)
+ {
+ cell->height = height;
+ g_object_notify (G_OBJECT (cell), "height");
+ }
+}
+
+/**
+ * gtk_cell_renderer_get_fixed_size:
+ * @cell: A #GtkCellRenderer
+ * @width: location to fill in with the fixed width of the widget, or %NULL
+ * @height: location to fill in with the fixed height of the widget, or %NULL
+ *
+ * Fills in @width and @height with the appropriate size of @cell.
+ **/
+void
+gtk_cell_renderer_get_fixed_size (GtkCellRenderer *cell,
+ gint *width,
+ gint *height)
+{
+ g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
+
+ if (width)
+ (* width) = cell->width;
+ if (height)
+ (* height) = cell->height;
+}