[gnumeric] widget-editable-label.c: simplify.



commit 41bbfd490f403e4c4f46b3199822a707559fd235
Author: Morten Welinder <terra gnome org>
Date:   Wed May 13 16:25:43 2009 -0400

    widget-editable-label.c: simplify.
---
 src/widgets/ChangeLog               |    2 +
 src/widgets/widget-editable-label.c |   85 +----------------------------------
 2 files changed, 3 insertions(+), 84 deletions(-)

diff --git a/src/widgets/ChangeLog b/src/widgets/ChangeLog
index c857cc5..1edf156 100644
--- a/src/widgets/ChangeLog
+++ b/src/widgets/ChangeLog
@@ -1,5 +1,7 @@
 2009-05-13  Morten Welinder  <terra gnome org>
 
+	* widget-editable-label.c (el_size_request): Simplify.
+
 	* gnm-notebook.c: Add a copy of gtknotebook.c until that can be
 	fixed.  Fixes #580837.
 
diff --git a/src/widgets/widget-editable-label.c b/src/widgets/widget-editable-label.c
index 2c41bc3..b152054 100644
--- a/src/widgets/widget-editable-label.c
+++ b/src/widgets/widget-editable-label.c
@@ -44,8 +44,6 @@ struct _EditableLabel {
 	unsigned int text_set;
 	unsigned int editable : 1;
 	unsigned int set_cursor_after_motion : 1;
-	int max_width;
-	gulong parent_width_request_handler;
 };
 
 typedef struct {
@@ -210,23 +208,14 @@ el_key_press_event (GtkWidget *w, GdkEventKey *event)
 static void
 el_size_request (GtkWidget *w, GtkRequisition *req)
 {
-	EditableLabel *el = EDITABLE_LABEL (w);
 	PangoRectangle logical_rect;
 	PangoLayout *layout;
-	int desired;
 
 	parent_class->size_request (w, req);
 	layout = gtk_entry_get_layout (GTK_ENTRY (w));
 	pango_layout_get_extents (layout, NULL, &logical_rect);
 
-	desired = logical_rect.width / PANGO_SCALE + 2 * 2;
-
-	/* We need to be absurdly careful not to allocate too much as
-	   the notebook acts strangely.  See bug #580837.  */
-	req->width = MIN (desired, el->max_width);
-
-	/* The above isn't working right.  Neuter.  */
-	req->width = desired;
+	req->width = logical_rect.width / PANGO_SCALE + 2 * 2;
 }
 
 static void
@@ -288,75 +277,6 @@ el_class_init (GtkObjectClass *object_class)
 }
 
 static void
-cb_width_changed (GtkWidget *parent, GParamSpec *pspec, EditableLabel *el)
-{
-	int old_max_width = el->max_width;
-
-	el->max_width = G_MAXINT;
-	if (GTK_IS_NOTEBOOK (parent) &&
-	    gtk_notebook_get_scrollable (GTK_NOTEBOOK (parent))) {
-		int width, height;
-
-		gtk_widget_get_size_request (parent, &width, &height);
-		if (width > 0) {
-			/* See el_size_request */
-
-			int focus_width;
-			int tab_overlap, tab_curvature;
-			int arrow_spacing, scroll_arrow_hlength;
-			int tab_hborder;
-			int padding;
-
-			gtk_widget_style_get
-				(parent,
-				 "focus-line-width", &focus_width,
-				 "tab-overlap", &tab_overlap,
-				 "tab-curvature", &tab_curvature,
-				 "arrow-spacing", &arrow_spacing,
-				 "scroll-arrow-hlength", &scroll_arrow_hlength,
-				 NULL);
-			g_object_get (G_OBJECT (parent),
-				      "tab-hborder", &tab_hborder,
-				      NULL);
-			padding = 2 * (scroll_arrow_hlength +
-				       arrow_spacing +
-				       tab_curvature + 
-				       focus_width +
-				       tab_hborder +
-				       parent->style->xthickness);
-			padding += 10;  /* Safety margin.  */
-			el->max_width = MAX (1, width - padding);
-		}
-	}
-
-	if (el->max_width != old_max_width)
-		gtk_widget_queue_resize (GTK_WIDGET (el));
-}
-
-static void
-cb_parent_set (EditableLabel *el, GtkWidget *old_parent, gpointer user)
-{
-	GtkWidget *w = GTK_WIDGET (el);
-	GtkWidget *parent = gtk_widget_get_parent (w);
-
-	if (el->parent_width_request_handler) {
-		g_signal_handler_disconnect (old_parent,
-					     el->parent_width_request_handler);
-		el->parent_width_request_handler = 0;
-	}
-
-	cb_width_changed (parent, NULL, el);
-	if (parent)
-		el->parent_width_request_handler =
-			g_signal_connect (G_OBJECT (parent),
-					  "notify::width-request",
-					  G_CALLBACK (cb_width_changed),
-					  el);
-
-	gtk_widget_queue_resize (w);
-}
-
-static void
 el_init (GObject *obj)
 {
 	EditableLabel *el = EDITABLE_LABEL (obj);
@@ -364,9 +284,6 @@ el_init (GObject *obj)
 	el->set_cursor_after_motion = FALSE;
 	g_signal_connect (obj, "changed",
 			  G_CALLBACK (gtk_widget_queue_resize), NULL);
-	el->max_width = G_MAXINT;
-	g_signal_connect (obj, "parent-set",
-			  G_CALLBACK (cb_parent_set), NULL);
 }
 
 GSF_CLASS (EditableLabel, editable_label,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]