diff --git a/ChangeLog b/ChangeLog index c0b3443355..d66d2b8e63 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +Tue Aug 31 17:07:41 2004 Jonathan Blandford + + * gtk/gtktreeviewcolumn.c + (gtk_tree_view_column_cell_process_action): constrain cell area to + passed in cell_area, #147867 + + * gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_get_size): if + ellipsizing, get_size is only 3 chars wide. + + * docs/tree-column-sizing.png: Add Matthias's excellent image. + 2004-08-28 Robert Ögren On Win32, do not produce tablet motion or button events while a diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index c0b3443355..d66d2b8e63 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,14 @@ +Tue Aug 31 17:07:41 2004 Jonathan Blandford + + * gtk/gtktreeviewcolumn.c + (gtk_tree_view_column_cell_process_action): constrain cell area to + passed in cell_area, #147867 + + * gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_get_size): if + ellipsizing, get_size is only 3 chars wide. + + * docs/tree-column-sizing.png: Add Matthias's excellent image. + 2004-08-28 Robert Ögren On Win32, do not produce tablet motion or button events while a diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index c0b3443355..d66d2b8e63 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,14 @@ +Tue Aug 31 17:07:41 2004 Jonathan Blandford + + * gtk/gtktreeviewcolumn.c + (gtk_tree_view_column_cell_process_action): constrain cell area to + passed in cell_area, #147867 + + * gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_get_size): if + ellipsizing, get_size is only 3 chars wide. + + * docs/tree-column-sizing.png: Add Matthias's excellent image. + 2004-08-28 Robert Ögren On Win32, do not produce tablet motion or button events while a diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index c0b3443355..d66d2b8e63 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,14 @@ +Tue Aug 31 17:07:41 2004 Jonathan Blandford + + * gtk/gtktreeviewcolumn.c + (gtk_tree_view_column_cell_process_action): constrain cell area to + passed in cell_area, #147867 + + * gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_get_size): if + ellipsizing, get_size is only 3 chars wide. + + * docs/tree-column-sizing.png: Add Matthias's excellent image. + 2004-08-28 Robert Ögren On Win32, do not produce tablet motion or button events while a diff --git a/docs/reference/gdk-pixbuf/tmpl/file-loading.sgml b/docs/reference/gdk-pixbuf/tmpl/file-loading.sgml index 2c046580b2..2757d674b9 100644 --- a/docs/reference/gdk-pixbuf/tmpl/file-loading.sgml +++ b/docs/reference/gdk-pixbuf/tmpl/file-loading.sgml @@ -52,6 +52,19 @@ End: @Returns: + + + + + +@filename: +@width: +@height: +@keep_aspect_ratio: +@error: +@Returns: + + diff --git a/docs/tree-column-sizing.png b/docs/tree-column-sizing.png new file mode 100644 index 0000000000..5a7f2158ba Binary files /dev/null and b/docs/tree-column-sizing.png differ diff --git a/gtk/gtkcellrenderertext.c b/gtk/gtkcellrenderertext.c index ef64be14da..4c7bd27788 100644 --- a/gtk/gtkcellrenderertext.c +++ b/gtk/gtkcellrenderertext.c @@ -1382,12 +1382,32 @@ gtk_cell_renderer_text_get_size (GtkCellRenderer *cell, pango_layout_get_pixel_extents (layout, NULL, &rect); - if (width) - *width = GTK_CELL_RENDERER (celltext)->xpad * 2 + rect.width; - if (height) *height = GTK_CELL_RENDERER (celltext)->ypad * 2 + rect.height; + /* The minimum size for ellipsized labels is ~ 3 chars */ + if (width) + { + if (priv->ellipsize) + { + PangoContext *context; + PangoFontMetrics *metrics; + gint char_width; + + context = pango_layout_get_context (layout); + metrics = pango_context_get_metrics (context, widget->style->font_desc, NULL); + + char_width = pango_font_metrics_get_approximate_char_width (metrics); + pango_font_metrics_unref (metrics); + + *width += (PANGO_PIXELS (char_width) * 3); + } + else + { + *width = GTK_CELL_RENDERER (celltext)->xpad * 2 + rect.width; + } + } + if (cell_area) { if (x_offset) diff --git a/gtk/gtktreeviewcolumn.c b/gtk/gtktreeviewcolumn.c index 70349d9646..eea8180433 100644 --- a/gtk/gtktreeviewcolumn.c +++ b/gtk/gtktreeviewcolumn.c @@ -2621,6 +2621,9 @@ gtk_tree_view_column_cell_get_size (GtkTreeViewColumn *tree_column, /* rendering, event handling and rendering focus are somewhat complicated, and * quite a bit of code. Rather than duplicate them, we put them together to * keep the code in one place. + * + * To better understand what's going on, check out + * docs/tree-column-sizing.png */ enum { CELL_ACTION_RENDER, @@ -2713,10 +2716,10 @@ gtk_tree_view_column_cell_process_action (GtkTreeViewColumn *tree_column, if (info->expand == TRUE) expand_cell_count ++; full_requested_width += info->requested_width; + /* FIXME: We prolly need to include tree_column->spacing here */ } - extra_space = cell_area->width + horizontal_separator - full_requested_width; - + extra_space = cell_area->width - full_requested_width; if (extra_space < 0) extra_space = 0; else if (extra_space > 0 && expand_cell_count > 0) @@ -2740,13 +2743,26 @@ gtk_tree_view_column_cell_process_action (GtkTreeViewColumn *tree_column, info->real_width = info->requested_width + (info->expand?extra_space:0); + /* We constrain ourselves to only the width available */ + if (real_cell_area.x + info->real_width > cell_area->x + cell_area->width) + { + info->real_width = cell_area->x + cell_area->width - real_cell_area.x; + } + + if (real_cell_area.x > cell_area->x + cell_area->width) + break; + real_cell_area.width = info->real_width; + real_background_area.width= real_cell_area.x + real_cell_area.width - real_background_area.x; real_cell_area.width -= 2 * focus_line_width; rtl_cell_area = real_cell_area; rtl_background_area = real_background_area; + + + if (rtl) { rtl_cell_area.x = cell_area->x + cell_area->width - (real_cell_area.x - cell_area->x) - real_cell_area.width; @@ -2895,6 +2911,15 @@ gtk_tree_view_column_cell_process_action (GtkTreeViewColumn *tree_column, info->real_width = info->requested_width + (info->expand?extra_space:0); + /* We constrain ourselves to only the width available */ + if (real_cell_area.x + info->real_width > cell_area->x + cell_area->width) + { + info->real_width = cell_area->x + cell_area->width - real_cell_area.x; + } + + if (real_cell_area.x > cell_area->x + cell_area->width) + break; + real_cell_area.width = info->real_width; real_background_area.width = real_cell_area.x + real_cell_area.width - real_background_area.x;