[gtk+/client-side-decorations] ellipsize client-side title labels
- From: Cody Russell <bratsche src gnome org>
- To: svn-commits-list gnome org
- Subject: [gtk+/client-side-decorations] ellipsize client-side title labels
- Date: Thu, 9 Jul 2009 15:08:51 +0000 (UTC)
commit 66124f0617682c6b77182729c46632c8af0e1144
Author: Cody Russell <bratsche gnome org>
Date: Thu Jul 9 16:08:40 2009 +0100
ellipsize client-side title labels
gtk/gtkwindow.c | 65 ++++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 52 insertions(+), 13 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 4c9252b..3d79648 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -1638,6 +1638,7 @@ gtk_window_set_label_widget (GtkWindow *window,
priv->title_label = label;
gtk_widget_set_parent (priv->title_label, GTK_WIDGET (window));
+ gtk_label_set_ellipsize (GTK_LABEL (priv->title_label), PANGO_ELLIPSIZE_END);
if (label)
{
@@ -5445,6 +5446,44 @@ gtk_window_size_request (GtkWidget *widget,
}
}
+static gint
+get_available_size_for_label (GtkWindow *window)
+{
+ GtkWidget *widget;
+ GtkWindowPrivate *priv;
+ gint border_width = 0;
+ gint available_size;
+
+ if (!is_client_side_decorated (window))
+ return 0;
+
+ widget = GTK_WIDGET (window);
+ priv = GTK_WINDOW_GET_PRIVATE (window);
+
+ available_size = widget->allocation.width;
+
+ if (priv->client_side_decorations & GDK_DECOR_BORDER)
+ {
+ gtk_widget_style_get (widget,
+ "decoration-border-width", &border_width,
+ NULL);
+ }
+
+ available_size -= border_width * 2;
+
+ if (priv->title_icon && GTK_WIDGET_VISIBLE (priv->title_icon))
+ {
+ available_size -= priv->title_icon->allocation.width;
+ }
+
+ if (priv->button_box && GTK_WIDGET_VISIBLE (priv->button_box))
+ {
+ available_size -= priv->button_box->allocation.width;
+ }
+
+ return available_size;
+}
+
static void
gtk_window_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
@@ -5493,13 +5532,25 @@ gtk_window_size_allocate (GtkWidget *widget,
gtk_widget_size_allocate (priv->title_icon, &deco_allocation);
}
+ if (client_decorated && priv->button_box && GTK_WIDGET_VISIBLE (priv->button_box))
+ {
+ gtk_widget_get_child_requisition (priv->button_box, &box_requisition);
+
+ box_allocation.x = allocation->width - frame_width - box_requisition.width;
+ box_allocation.y = frame_width;
+ box_allocation.width = box_requisition.width;
+ box_allocation.height = box_requisition.height;
+
+ gtk_widget_size_allocate (priv->button_box, &box_allocation);
+ }
+
if (client_decorated && priv->title_label && GTK_WIDGET_VISIBLE (priv->title_label))
{
gtk_widget_get_child_requisition (priv->title_label, &deco_requisition);
deco_allocation.x = 2 * frame_width + icon_width;
deco_allocation.y = frame_width;
- deco_allocation.width = deco_requisition.width;
+ deco_allocation.width = MAX (deco_requisition.width, get_available_size_for_label (window));
deco_allocation.height = deco_requisition.height;
title_width = deco_allocation.width;
@@ -5507,18 +5558,6 @@ gtk_window_size_allocate (GtkWidget *widget,
gtk_widget_size_allocate (priv->title_label, &deco_allocation);
}
- if (client_decorated && priv->button_box && GTK_WIDGET_VISIBLE (priv->button_box))
- {
- gtk_widget_get_child_requisition (priv->button_box, &box_requisition);
-
- box_allocation.x = allocation->width - frame_width - box_requisition.width;
- box_allocation.y = frame_width;
- box_allocation.width = box_requisition.width;
- box_allocation.height = box_requisition.height;
-
- gtk_widget_size_allocate (priv->button_box, &box_allocation);
- }
-
if (window->bin.child && GTK_WIDGET_VISIBLE (window->bin.child))
{
if (client_decorated && window->type != GTK_WINDOW_POPUP)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]