Commit aff11a4b authored by Andrzej's avatar Andrzej

Ellipsize labels in a compact list mode.

parent c4d3a3a9
...@@ -80,7 +80,8 @@ thunar_compact_view_init (ThunarCompactView *compact_view) ...@@ -80,7 +80,8 @@ thunar_compact_view_init (ThunarCompactView *compact_view)
/* setup the name renderer (wrap only very long names) */ /* setup the name renderer (wrap only very long names) */
g_object_set (G_OBJECT (THUNAR_STANDARD_VIEW (compact_view)->name_renderer), g_object_set (G_OBJECT (THUNAR_STANDARD_VIEW (compact_view)->name_renderer),
"wrap-mode", PANGO_WRAP_WORD_CHAR, "wrap-mode", PANGO_WRAP_WORD_CHAR,
"wrap-width", 1280, "ellipsize-mode", PANGO_ELLIPSIZE_MIDDLE,
"wrap-width", 200,
"xalign", 0.0f, "xalign", 0.0f,
"yalign", 0.5f, "yalign", 0.5f,
NULL); NULL);
......
...@@ -46,6 +46,7 @@ enum ...@@ -46,6 +46,7 @@ enum
PROP_TEXT, PROP_TEXT,
PROP_WRAP_MODE, PROP_WRAP_MODE,
PROP_WRAP_WIDTH, PROP_WRAP_WIDTH,
PROP_ELLIPSIZE_MODE,
}; };
enum enum
...@@ -117,27 +118,28 @@ struct _ThunarTextRendererClass ...@@ -117,27 +118,28 @@ struct _ThunarTextRendererClass
struct _ThunarTextRenderer struct _ThunarTextRenderer
{ {
GtkCellRenderer __parent__; GtkCellRenderer __parent__;
PangoLayout *layout; PangoLayout *layout;
GtkWidget *widget; GtkWidget *widget;
gboolean text_static; gboolean text_static;
gchar *text; gchar *text;
gint char_width; gint char_width;
gint char_height; gint char_height;
PangoWrapMode wrap_mode; PangoWrapMode wrap_mode;
gint wrap_width; gint wrap_width;
gboolean follow_state; PangoEllipsizeMode ellipsize_mode;
gint focus_width;; gboolean follow_state;
PangoAlignment alignment; gint focus_width;
PangoAlignment alignment;
/* underline prelited rows */ /* underline prelited rows */
gboolean follow_prelit; gboolean follow_prelit;
/* cell editing support */ /* cell editing support */
GtkWidget *entry; GtkWidget *entry;
gboolean entry_menu_active; gboolean entry_menu_active;
gint entry_menu_popdown_timer_id; gint entry_menu_popdown_timer_id;
}; };
...@@ -254,6 +256,24 @@ thunar_text_renderer_class_init (ThunarTextRendererClass *klass) ...@@ -254,6 +256,24 @@ thunar_text_renderer_class_init (ThunarTextRendererClass *klass)
-1, G_MAXINT, -1, -1, G_MAXINT, -1,
EXO_PARAM_READWRITE)); EXO_PARAM_READWRITE));
/**
* ThunarTextRenderer:ellipsize-mode:
*
* Specifies whether to break the string into multiple lines or
* to shorten the line, if the cell renderer does not have enough room
* to display the entire string. This property has
* no effect unless the wrap-width property is set.
**/
g_object_class_install_property (gobject_class,
PROP_ELLIPSIZE_MODE,
g_param_spec_enum ("ellipsize-mode",
"ellipsize-mode",
"ellipsize-mode",
PANGO_TYPE_ELLIPSIZE_MODE,
PANGO_ELLIPSIZE_NONE,
EXO_PARAM_READWRITE));
/** /**
* ThunarTextRenderer::edited: * ThunarTextRenderer::edited:
* @text_renderer : a #ThunarTextRenderer. * @text_renderer : a #ThunarTextRenderer.
...@@ -336,6 +356,10 @@ thunar_text_renderer_get_property (GObject *object, ...@@ -336,6 +356,10 @@ thunar_text_renderer_get_property (GObject *object,
g_value_set_int (value, text_renderer->wrap_width); g_value_set_int (value, text_renderer->wrap_width);
break; break;
case PROP_ELLIPSIZE_MODE:
g_value_set_enum (value, text_renderer->ellipsize_mode);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
...@@ -389,6 +413,10 @@ thunar_text_renderer_set_property (GObject *object, ...@@ -389,6 +413,10 @@ thunar_text_renderer_set_property (GObject *object,
gtk_cell_renderer_set_fixed_size (GTK_CELL_RENDERER (text_renderer), -1, -1); gtk_cell_renderer_set_fixed_size (GTK_CELL_RENDERER (text_renderer), -1, -1);
break; break;
case PROP_ELLIPSIZE_MODE:
text_renderer->ellipsize_mode = g_value_get_enum (value);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
...@@ -432,6 +460,7 @@ thunar_text_renderer_get_size (GtkCellRenderer *renderer, ...@@ -432,6 +460,7 @@ thunar_text_renderer_get_size (GtkCellRenderer *renderer,
/* calculate the real text dimension */ /* calculate the real text dimension */
pango_layout_set_width (text_renderer->layout, text_renderer->wrap_width * PANGO_SCALE); pango_layout_set_width (text_renderer->layout, text_renderer->wrap_width * PANGO_SCALE);
pango_layout_set_wrap (text_renderer->layout, text_renderer->wrap_mode); pango_layout_set_wrap (text_renderer->layout, text_renderer->wrap_mode);
pango_layout_set_ellipsize (text_renderer->layout, text_renderer->ellipsize_mode);
pango_layout_set_text (text_renderer->layout, text_renderer->text, -1); pango_layout_set_text (text_renderer->layout, text_renderer->text, -1);
pango_layout_get_pixel_size (text_renderer->layout, &text_width, &text_height); pango_layout_get_pixel_size (text_renderer->layout, &text_width, &text_height);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment