Re: BonoboView sizing problems



Michael Meeks <michael helixcode com> writes:

> > However, there is a simple way to fix this without breaking any existing
> > API - all we need to do is to implement BonoboControl::getDesiredSize()
> > which currently does nothing.
> 
> 	The thing is; that these APIs are left as a throw back to the old
> and broken way of sizing Gtk widgets, which instead of going through the
> plug / socket queue tried to do it synchrnonously and directly. I really
> want to discourage people doing this again. Hmm.
> 
> 	Still; I suppose it's an easy solution, we can do it if you like,
> but do it quickly so I don't feel the pain.

Hi Michael,

after thinking a bit about this, I think it's not so completely wrong to
implement BonoboControl::getDesiredSize():

a) After the ControlFrame's socket has been created, my implementation
   returns exactly the same as a direct gtk_widget_size_request() on the
   ControlFrame's wrapper widget.

b) Before the socket has been created, a direct gtk_widget_size_request()
   on the ControlFrame's wrapper widget fails (it returns (1,1)), but my
   implementation already does the right thing.

So basically, there's no difference except that my getDesiredSize() is less
error-prone and works no matter whether the socket has been created or not.

I also added back bonobo_control_frame_size_request(), this function still
existed in the header file, but was not implemented.

===
2000-11-30  Martin Baulig  <baulig suse de>

	* bonobo/bonobo-control.c (impl_Bonobo_Control_getDesiredSize):
	Implement this; this calls gtk_widget_size_request() on the
	Control's widget.

	* bonobo/bonobo-control-frame.c (bonobo_control_frame_size_request):
	Implement this function.

===

Here's the patch:

Index: bonobo/bonobo-control-frame.c
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-control-frame.c,v
retrieving revision 1.45
diff -u -u -p -r1.45 bonobo-control-frame.c
--- bonobo/bonobo-control-frame.c	2000/11/07 14:52:17	1.45
+++ bonobo/bonobo-control-frame.c	2000/11/30 15:42:57
@@ -937,3 +937,40 @@ bonobo_control_frame_get_control_propert
 
 	return pbag;
 }
+
+void
+bonobo_control_frame_size_request (BonoboControlFrame *control_frame,
+				   int *desired_width, int *desired_height)
+{
+	CORBA_Environment ev;
+	CORBA_short width, height;
+
+	g_return_if_fail (control_frame != NULL);
+	g_return_if_fail (BONOBO_IS_CONTROL_FRAME (control_frame));
+	g_return_if_fail (desired_width != NULL);
+	g_return_if_fail (desired_height != NULL);
+
+	/*
+	 * Check that this ControLFrame actually has a Control associated
+	 * with it.
+	 */
+	g_return_if_fail (control_frame->priv->control != CORBA_OBJECT_NIL);
+
+	CORBA_exception_init (&ev);
+
+	Bonobo_Control_getDesiredSize (control_frame->priv->control,
+				       &width, &height, &ev);
+
+	if (ev._major != CORBA_NO_EXCEPTION) {
+		bonobo_object_check_env (
+			BONOBO_OBJECT (control_frame),
+			(CORBA_Object) control_frame->priv->control, &ev);
+
+		width = height = 0;
+	}
+
+	*desired_width = width;
+	*desired_height = height;
+
+	CORBA_exception_free (&ev);
+}
Index: bonobo/bonobo-control.c
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-control.c,v
retrieving revision 1.53
diff -u -u -p -r1.53 bonobo-control.c
--- bonobo/bonobo-control.c	2000/11/29 22:10:57	1.53
+++ bonobo/bonobo-control.c	2000/11/30 15:42:58
@@ -370,13 +370,17 @@ impl_Bonobo_Control_setSize (PortableSer
 
 static void
 impl_Bonobo_Control_getDesiredSize (PortableServer_Servant  servant,
-				  CORBA_short            *desired_width,
-				  CORBA_short            *desired_height,
-				  CORBA_Environment      *ev)
+				    CORBA_short            *desired_width,
+				    CORBA_short            *desired_height,
+				    CORBA_Environment      *ev)
 {
-	/*
-	 * Nothing.
-	 */
+	BonoboControl *control = BONOBO_CONTROL (bonobo_object_from_servant (servant));
+	GtkRequisition requisition;
+
+	gtk_widget_size_request (control->priv->widget, &requisition);
+
+	*desired_width = requisition.width;
+	*desired_height = requisition.height;
 }
 
 static GtkStateType
Can I commit ?

-- 
Martin Baulig
martin gnome org (private)
baulig suse de (work)


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