Re: Fixed as a NO_WINDOW



Tim Janik <timj gtk org> writes:

> On 18 Nov 2001, Owen Taylor wrote:
> 
> > 
> > Those were all the API changes. Really, no kidding. Well, almost.
> > 
> > GtkFixed _really_ needs to be a NO_WINDOW widget; this 
> > has been bugging me since 1.0.
> > 
> >  * For correct theming
> >  * For consistency with all other containers that don't draw anything.
> >  * For reduced overhead.
> > 
> > Effects:
> > 
> >  * I couldn't find any code in GNOME cvs that this will break
> > 
> >  * If there is something that breaks, insert:
> > 
> > +    GTK_WIDGET_UNSET_FLAGS (fixed, GTK_WIDGET_NO_WINDOW)
> >    
> >    after creating the fixed.
> > 
> >    (I added the hack of making this work, because I'm pretty sure 
> >    people frequently use GtkFixed as an equivalent of a widget in some
> >    other toolkit with fixed placement, and I don't want
> >    such people to have write a new widget.)
> 
> arg! the GtkFixed NO_WINDOW part is fine, but people shall _never_ use
> GTK_WIDGET_[UN]SET_FLAGS() in third-party code. 
> checking for GTK_WIDGET_NO_WINDOW in gtkfixed.c to create a window
> on demand is somewhat questionable, it might be usable for derived widgets,
> but it's ugly as hell.
> 
> however, i'll not accept an API change (whether last minute or not) that makes
> GTK_WIDGET_UNSET_FLAGS/GTK_WIDGET_SET_FLAGS public API for toolkit users,
> regardless of the flag being passed.
> 
> besides, there's really no need to do that, people can simply put GtkFixed into
> an eventbox.

I _am_ trying to get a release out here. But, OK, if it makes it
happy, I'll add the following patch. Adding a property and the
necessary accompaniment -- the capability to change while the widget is 
realized -- is left for an excercise for the reader. And left for
a post-2.0 release.

This capability is needed:
 
 - So people don't need to rework their code to match the change.

 - Because people trying to build emulation layers for legacy
   toolkits on top of GTK+ frequently want something like 
   "A hierarchy of fixed positioning containers with windows",
   so "GtkFixed with a window" is an interesting widget, and
   something I don't want to remove from the toolkit, even if
   I wouldn't have added it in the first place.

Regards,
                                        Owen

Index: gtk/gtkfixed.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkfixed.c,v
retrieving revision 1.30
diff -u -p -r1.30 gtkfixed.c
--- gtk/gtkfixed.c	2001/11/18 23:33:21	1.30
+++ gtk/gtkfixed.c	2001/11/19 20:40:09
@@ -505,3 +505,46 @@ gtk_fixed_forall (GtkContainer *containe
       (* callback) (child->widget, callback_data);
     }
 }
+
+/**
+ * gtk_fixed_set_has_window:
+ * @fixed: a #GtkFixed
+ * @has_window: %TRUE if a separate window should be created
+ * 
+ * Sets whether a #GtkFixed widget is created with a separate
+ * #GdkWindow for widget->window or not. (By default, it will be
+ * created with no separate #GdkWindow). This function must be called
+ * when the widget is in an unrealized state.
+ **/
+void
+gtk_fixed_set_has_window (GtkFixed *fixed,
+			  gboolean  has_window)
+{
+  g_return_if_fail (GTK_IS_FIXED (fixed));
+  g_return_if_fail (GTK_WIDGET_REALIZED (fixed));
+
+  if (!has_window != GTK_WIDGET_NO_WINDOW (fixed))
+    {
+      if (has_window)
+	GTK_WIDGET_UNSET_FLAGS (fixed, GTK_NO_WINDOW);
+      else
+	GTK_WIDGET_SET_FLAGS (fixed, GTK_NO_WINDOW);
+    }
+}
+
+/**
+ * gtk_fixed_get_has_window:
+ * @fixed: a #GtkWidget
+ * 
+ * Gets whether the #GtkFixed has it's own #GdkWindow.
+ * See gdk_fixed_set_has_window().
+ * 
+ * Return value: 
+ **/
+gboolean
+gtk_fixed_get_has_window (GtkFixed *fixed)
+{
+  g_return_if_fail (GTK_IS_FIXED (fixed));
+
+  return !GTK_WIDGET_NO_WINDOW (fixed);
+}
Index: gtk/gtkfixed.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkfixed.h,v
retrieving revision 1.10
diff -u -p -r1.10 gtkfixed.h
--- gtk/gtkfixed.h	2001/08/10 03:46:07	1.10
+++ gtk/gtkfixed.h	2001/11/19 20:40:09
@@ -79,6 +79,9 @@ void       gtk_fixed_move              (
                                         GtkWidget      *widget,
                                         gint            x,
                                         gint            y);
+void       gtk_fixed_set_has_window    (GtkFixed       *fixed,
+					gboolean        has_window);
+gboolean   gtk_fixed_get_has_window    (GtkFixed       *fixed);
 
 #ifdef __cplusplus
 }


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