GTK_RESIZE_NEEDED is a private flag now.

Mon Feb  2 04:15:08 1998  Tim Janik  <timj@gimp.org>

        * gtk/gtkcontainer.h:
        * gtk/gtkcontainer.c: GTK_RESIZE_NEEDED is a private flag now.
          (gtk_container_register_toplevel): new function.
          (gtk_container_unregister_toplevel): new function.

        * gtk/gtkmain.c: GTK_LEAVE_PENDING is a private flag now.

        * gtk/gtkmenu.c: call gtk_container_register_toplevel in
          gtk_menu_class_init instead of this dirty gtk_widget_set_parent(,NULL)
          hack. new default handler gtk_menu_destroy for calling
          gtk_container_unregister_toplevel. removed GTK_ANCHORED, GTK_UNMAPPED.

        * gtk/gtkobject.h: macro cleanups, added GTK_DESTROYED flag.

        * gtk/gtkobject.c: only emit DESTROY signal if !GTK_OBJECT_DESTROYED
          (object).

        * gtk/gtkprivate.h: new file that will not be automatically included.
          it holds the private flags for GtkWidget along with it's SET/UNSET
          and examination macros.

        * gtk/gtkwidget.c: private flags: GTK_RESIZE_NEEDED, GTK_REDRAW_PENDING,
          GTK_RESIZE_PENDING, GTK_IN_REPARENT, GTK_USER_STYLE. GTK_ANCHORED is
          replaced by GTK_TOPLEVEL. added missing UNSET for GTK_IN_REPARENT.
          removed the gtk_widget_set_parent(, NULL) hack for toplevels.
          upon destroy free memory for widgets with GTK_WIDGET_HAS_SHAPE_MASK.

        * gtk/gtkwidget.h: split up the widget flags into a public and a private
          portion. added an extra field private_flags to GtkWidget without making
          it bigger by using an alignment gap of 16 bit. macro cleanups.

        * gtk/gtkwindow.c: removed GTK_ANCHORED. new function gtk_window_destroy
          for calling gtk_container_unregister_toplevel. removed the
          gtk_widget_set_parent(,NULL), call gtk_container_register_toplevel
          instead. remove GTK_UNMAPPED. GTK_RESIZE_NEEDED is private now.

        * gtk/gtksignal.c (gtk_signal_disconnect): removed a bug on
          removal that cut off the handler list -> living_objects == 0
          with testgtk. made some warnings more descriptive.
          new function gtk_signal_connect_object_while_alive, which
          will automatically destroy the connection once one of the objects
          is destroyed. didn't include this before removal of the above
          mentioned bug.

* reflected refcounting revolution in ChangeLog
This commit is contained in:
Tim Janik 1998-02-02 04:54:25 +00:00 committed by Tim Janik
parent 81fe36047e
commit eef38289b2
12 changed files with 348 additions and 256 deletions

View File

@ -149,6 +149,7 @@ gtkinclude_HEADERS = \
gtkpaned.h \
gtkpixmap.h \
gtkpreview.h \
gtkprivate.h \
gtkprogressbar.h \
gtkradiobutton.h \
gtkradiomenuitem.h \

View File

@ -17,6 +17,7 @@
*/
#include <string.h>
#include "gtkcontainer.h"
#include "gtkprivate.h"
#include "gtksignal.h"
@ -215,12 +216,15 @@ gtk_container_destroy (GtkObject *object)
{
GSList *node;
g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_CONTAINER (object));
for (node = GTK_CONTAINER (object)->resize_widgets; node; node = node->next)
{
GtkWidget *child;
child = (GtkWidget*) node->data;
GTK_WIDGET_UNSET_FLAGS (child, GTK_RESIZE_NEEDED);
GTK_PRIVATE_UNSET_FLAGS (child, GTK_RESIZE_NEEDED);
}
g_slist_free (GTK_CONTAINER (object)->resize_widgets);
GTK_CONTAINER (object)->resize_widgets = NULL;
@ -466,6 +470,18 @@ gtk_container_children (GtkContainer *container)
return g_list_reverse (children);
}
void
gtk_container_register_toplevel (GtkContainer *container)
{
gtk_widget_ref (GTK_WIDGET (container));
gtk_object_sink (GTK_OBJECT (container));
}
void
gtk_container_unregister_toplevel (GtkContainer *container)
{
gtk_widget_unref (GTK_WIDGET (container));
}
static void
gtk_container_marshal_signal_1 (GtkObject *object,

View File

@ -43,6 +43,7 @@ struct _GtkContainer
GtkWidget widget;
GtkWidget *focus_child;
gint16 border_width;
guint auto_resize : 1;
guint need_resize : 1;
@ -72,29 +73,32 @@ struct _GtkContainerClass
guint gtk_container_get_type (void);
void gtk_container_border_width (GtkContainer *container,
gint border_width);
void gtk_container_add (GtkContainer *container,
GtkWidget *widget);
void gtk_container_remove (GtkContainer *container,
GtkWidget *widget);
void gtk_container_disable_resize (GtkContainer *container);
void gtk_container_enable_resize (GtkContainer *container);
void gtk_container_block_resize (GtkContainer *container);
void gtk_container_unblock_resize (GtkContainer *container);
gint gtk_container_need_resize (GtkContainer *container);
void gtk_container_foreach (GtkContainer *container,
GtkCallback callback,
gpointer callback_data);
void gtk_container_foreach_interp (GtkContainer *container,
GtkCallbackMarshal callback,
gpointer callback_data,
GtkDestroyNotify notify);
gint gtk_container_focus (GtkContainer *container,
GtkDirectionType direction);
GList* gtk_container_children (GtkContainer *container);
guint gtk_container_get_type (void);
void gtk_container_border_width (GtkContainer *container,
gint border_width);
void gtk_container_add (GtkContainer *container,
GtkWidget *widget);
void gtk_container_remove (GtkContainer *container,
GtkWidget *widget);
void gtk_container_disable_resize (GtkContainer *container);
void gtk_container_enable_resize (GtkContainer *container);
void gtk_container_block_resize (GtkContainer *container);
void gtk_container_unblock_resize (GtkContainer *container);
gint gtk_container_need_resize (GtkContainer *container);
void gtk_container_foreach (GtkContainer *container,
GtkCallback callback,
gpointer callback_data);
void gtk_container_foreach_interp (GtkContainer *container,
GtkCallbackMarshal callback,
gpointer callback_data,
GtkDestroyNotify notify);
gint gtk_container_focus (GtkContainer *container,
GtkDirectionType direction);
GList* gtk_container_children (GtkContainer *container);
void gtk_container_register_toplevel (GtkContainer *container);
void gtk_container_unregister_toplevel (GtkContainer *container);
#ifdef __cplusplus
}

View File

@ -31,6 +31,7 @@
#include "gtkvscrollbar.h"
#include "gtkwidget.h"
#include "gtkwindow.h"
#include "gtkprivate.h"
/* Private type definitions
@ -439,14 +440,14 @@ gtk_main_iteration_do (gboolean blocking)
{
gtk_widget_event (grab_widget, event);
if (event_widget == grab_widget)
GTK_WIDGET_SET_FLAGS (event_widget, GTK_LEAVE_PENDING);
GTK_PRIVATE_SET_FLAGS (event_widget, GTK_LEAVE_PENDING);
}
break;
case GDK_LEAVE_NOTIFY:
if (event_widget && GTK_WIDGET_LEAVE_PENDING (event_widget))
{
GTK_WIDGET_UNSET_FLAGS (event_widget, GTK_LEAVE_PENDING);
GTK_PRIVATE_UNSET_FLAGS (event_widget, GTK_LEAVE_PENDING);
gtk_widget_event (event_widget, event);
}
else if (grab_widget && GTK_WIDGET_IS_SENSITIVE (grab_widget))
@ -1194,11 +1195,11 @@ gtk_print (gchar *str)
if (!window)
{
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
/*
* gtk_signal_connect (GTK_OBJECT (window), "destroy",
* (GtkSignalFunc) gtk_widget_destroyed,
* &window);
*/
gtk_signal_connect (GTK_OBJECT (window), "destroy",
(GtkSignalFunc) gtk_widget_destroyed,
&window);
gtk_window_set_title (GTK_WINDOW (window), "Messages");
box1 = gtk_vbox_new (FALSE, 0);

View File

@ -28,6 +28,7 @@
static void gtk_menu_class_init (GtkMenuClass *klass);
static void gtk_menu_init (GtkMenu *menu);
static void gtk_menu_destroy (GtkObject *object);
static void gtk_menu_show (GtkWidget *widget);
static void gtk_menu_map (GtkWidget *widget);
static void gtk_menu_unmap (GtkWidget *widget);
@ -50,6 +51,7 @@ static void gtk_menu_deactivate (GtkMenuShell *menu_shell);
static void gtk_menu_show_all (GtkWidget *widget);
static void gtk_menu_hide_all (GtkWidget *widget);
static GtkMenuShellClass *parent_class = NULL;
guint
gtk_menu_get_type ()
@ -78,13 +80,18 @@ gtk_menu_get_type ()
static void
gtk_menu_class_init (GtkMenuClass *class)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
GtkContainerClass *container_class;
GtkMenuShellClass *menu_shell_class;
object_class = (GtkObjectClass*) class;
widget_class = (GtkWidgetClass*) class;
container_class = (GtkContainerClass*) class;
menu_shell_class = (GtkMenuShellClass*) class;
parent_class = gtk_type_class (gtk_menu_shell_get_type ());
object_class->destroy = gtk_menu_destroy;
widget_class->show = gtk_menu_show;
widget_class->map = gtk_menu_map;
@ -108,7 +115,7 @@ gtk_menu_class_init (GtkMenuClass *class)
static void
gtk_menu_init (GtkMenu *menu)
{
GTK_WIDGET_SET_FLAGS (menu, GTK_ANCHORED | GTK_TOPLEVEL);
GTK_WIDGET_SET_FLAGS (menu, GTK_TOPLEVEL);
menu->parent_menu_item = NULL;
menu->old_active_menu_item = NULL;
@ -118,8 +125,19 @@ gtk_menu_init (GtkMenu *menu)
GTK_MENU_SHELL (menu)->menu_flag = TRUE;
/* gtk_container_add (gtk_root, GTK_WIDGET (menu)); */
gtk_widget_set_parent (GTK_WIDGET (menu), NULL);
gtk_container_register_toplevel (GTK_CONTAINER (menu));
}
static void
gtk_menu_destroy (GtkObject *object)
{
g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_MENU (object));
gtk_container_unregister_toplevel (GTK_CONTAINER (object));
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
GtkWidget*
@ -292,7 +310,6 @@ gtk_menu_map (GtkWidget *widget)
menu = GTK_MENU (widget);
menu_shell = GTK_MENU_SHELL (widget);
GTK_WIDGET_SET_FLAGS (menu_shell, GTK_MAPPED);
GTK_WIDGET_UNSET_FLAGS (menu_shell, GTK_UNMAPPED);
gtk_widget_size_request (widget, &widget->requisition);
@ -357,7 +374,6 @@ gtk_menu_unmap (GtkWidget *widget)
g_return_if_fail (GTK_IS_MENU (widget));
GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
GTK_WIDGET_SET_FLAGS (widget, GTK_UNMAPPED);
gdk_window_hide (widget->window);
}
@ -560,9 +576,6 @@ gtk_menu_expose (GtkWidget *widget,
g_return_val_if_fail (GTK_IS_MENU (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
if (!GTK_WIDGET_UNMAPPED (widget))
GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
if (GTK_WIDGET_DRAWABLE (widget))
{
gtk_menu_paint (widget);

View File

@ -105,7 +105,9 @@ gtk_object_debug (void)
printf ("%d living objects\n", obj_count);
for (node = living_objs; node; node = node->next)
{
GtkObject *obj = (GtkObject *)node->data;
GtkObject *obj;
obj = (GtkObject*) node->data;
/*
printf ("%p: %s %d %s\n",
obj, gtk_type_name (GTK_OBJECT_TYPE (obj)),
@ -186,6 +188,25 @@ gtk_object_class_init (GtkObjectClass *class)
class->finalize = gtk_object_finalize;
}
/*****************************************
* gtk_object_real_destroy:
*
* arguments:
*
* results:
*****************************************/
static void
gtk_object_real_destroy (GtkObject *object)
{
g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_OBJECT (object));
/* FIXME: gtk_signal_handlers_destroy (object); */
/* object->klass = gtk_type_class (gtk_destroyed_get_type ()); */
}
/*****************************************
* gtk_object_init:
*
@ -197,7 +218,8 @@ gtk_object_class_init (GtkObjectClass *class)
static void
gtk_object_init (GtkObject *object)
{
object->flags = GTK_FLOATING;
GTK_OBJECT_FLAGS (object) = GTK_FLOATING;
object->ref_count = 1;
object->object_data = NULL;
@ -474,26 +496,11 @@ gtk_object_destroy (GtkObject *object)
g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_OBJECT (object));
gtk_signal_emit (object, object_signals[DESTROY]);
}
/*****************************************
* gtk_object_real_destroy:
*
* arguments:
*
* results:
*****************************************/
static void
gtk_object_real_destroy (GtkObject *object)
{
g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_OBJECT (object));
gtk_signal_handlers_destroy (object);
/* object->klass = gtk_type_class (gtk_destroyed_get_type ()); */
if (!GTK_OBJECT_DESTROYED (object))
{
GTK_OBJECT_SET_FLAGS (object, GTK_DESTROYED);
gtk_signal_emit (object, object_signals[DESTROY]);
}
}
/*****************************************

View File

@ -28,18 +28,6 @@ extern "C" {
#endif /* __cplusplus */
/* GtkObject only uses the first 3 bits of the "flags" field.
* They refer to the following flags.
* GtkWidget uses the remaining bits. Though this is a kinda nasty
* break up, it does make the size of GtkWidget smaller.
*/
enum
{
GTK_FLOATING = 1 << 0,
GTK_RESERVED_1 = 1 << 1,
GTK_RESERVED_2 = 1 << 2
};
/* The debugging versions of the casting macros make sure the cast is "ok"
* before proceeding, but they are definately slower than their less
@ -47,48 +35,62 @@ enum
*/
#ifdef NDEBUG
#define GTK_CHECK_CAST(obj,cast_type,cast) ((cast*) obj)
#define GTK_CHECK_CLASS_CAST(klass,cast_type,cast) ((cast*) klass)
#define GTK_CHECK_CAST(obj,cast_type,cast) ((cast*) (obj))
#define GTK_CHECK_CLASS_CAST(klass,cast_type,cast) ((cast*) (klass))
#else /* NDEBUG */
#define GTK_CHECK_CAST(obj,cast_type,cast) \
((cast*) gtk_object_check_cast ((GtkObject*) obj, cast_type))
((cast*) gtk_object_check_cast ((GtkObject*) (obj), cast_type))
#define GTK_CHECK_CLASS_CAST(klass,cast_type,cast) \
((cast*) gtk_object_check_class_cast ((GtkObjectClass*) klass, cast_type))
((cast*) gtk_object_check_class_cast ((GtkObjectClass*) (klass), cast_type))
#endif /* NDEBUG */
/* Determines whether 'obj' is a type of 'otype'.
*/
#define GTK_CHECK_TYPE(obj,otype) (gtk_type_is_a (((GtkObject*) obj)->klass->type, otype))
#define GTK_CHECK_TYPE(obj,otype) (gtk_type_is_a (((GtkObject*) (obj))->klass->type, otype))
/* Macro for casting a pointer to a GtkObject pointer.
*/
#define GTK_OBJECT(obj) GTK_CHECK_CAST (obj, gtk_object_get_type (), GtkObject)
#define GTK_OBJECT(obj) GTK_CHECK_CAST ((obj), gtk_object_get_type (), GtkObject)
/* Macros for extracting various fields from GtkObject and
* GtkObjectClass.
/* Macros for extracting various fields from GtkObject and GtkObjectClass.
*/
#define GTK_OBJECT_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gtk_object_get_type (), GtkObjectClass)
#define GTK_OBJECT_FLAGS(obj) (GTK_OBJECT (obj)->flags)
#define GTK_OBJECT_FLOATING(obj) (GTK_OBJECT_FLAGS (obj) & GTK_FLOATING)
#define GTK_OBJECT_DESTROY(obj) (GTK_OBJECT (obj)->klass->destroy)
#define GTK_OBJECT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), gtk_object_get_type (), GtkObjectClass))
#define GTK_OBJECT_TYPE(obj) (GTK_OBJECT (obj)->klass->type)
#define GTK_OBJECT_SIGNALS(obj) (GTK_OBJECT (obj)->klass->signals)
#define GTK_OBJECT_NSIGNALS(obj) (GTK_OBJECT (obj)->klass->nsignals)
/* GtkObject only uses the first 4 bits of the flags field.
* GtkWidget uses the remaining bits. Though this is a kinda nasty
* break up, it does make the size of GtkWidget smaller.
*/
enum
{
GTK_DESTROYED = 1 << 0,
GTK_FLOATING = 1 << 1,
GTK_RESERVED_1 = 1 << 2,
GTK_RESERVED_2 = 1 << 3
};
/* Macros for extracting the object_flags from GtkObject.
*/
#define GTK_OBJECT_FLAGS(obj) (GTK_OBJECT (obj)->flags)
#define GTK_OBJECT_DESTROYED(obj) (GTK_OBJECT_FLAGS (obj) & GTK_DESTROYED)
#define GTK_OBJECT_FLOATING(obj) (GTK_OBJECT_FLAGS (obj) & GTK_FLOATING)
/* Macros for setting and clearing bits in the object_flags field of GtkObject.
*/
#define GTK_OBJECT_SET_FLAGS(obj,flag) G_STMT_START{ (GTK_OBJECT_FLAGS (obj) |= (flag)); }G_STMT_END
#define GTK_OBJECT_UNSET_FLAGS(obj,flag) G_STMT_START{ (GTK_OBJECT_FLAGS (obj) &= ~(flag)); }G_STMT_END
/* Macro for testing whether "obj" is of type GtkObject.
*/
#define GTK_IS_OBJECT(obj) GTK_CHECK_TYPE (obj, gtk_object_get_type ())
/* Macros for setting and clearing bits in the "flags" field of GtkObject.
*/
#define GTK_OBJECT_SET_FLAGS(obj,flag) (GTK_OBJECT_FLAGS (obj) |= (flag))
#define GTK_OBJECT_UNSET_FLAGS(obj,flag) (GTK_OBJECT_FLAGS (obj) &= ~(flag))
#define GTK_IS_OBJECT(obj) (GTK_CHECK_TYPE ((obj), gtk_object_get_type ()))
typedef struct _GtkObjectClass GtkObjectClass;
@ -99,10 +101,16 @@ typedef struct _GtkObjectClass GtkObjectClass;
*/
struct _GtkObject
{
/* 32 bits of flags. GtkObject only uses 3 of these bits and
/* A pointer to the objects class. This will actually point to
* the derived objects class struct (which will be derived from
* GtkObjectClass).
*/
GtkObjectClass *klass;
/* 32 bits of flags. GtkObject only uses 4 of these bits and
* GtkWidget uses the rest. This is done because structs are
* aligned on 4 or 8 byte boundaries. If bitfields were used
* both here and in GtkWidget much space would be wasted.
* aligned on 4 or 8 byte boundaries. If a new bitfield were
* used in GtkWidget much space would be wasted.
*/
guint32 flags;
@ -111,12 +119,6 @@ struct _GtkObject
*/
guint ref_count;
/* A pointer to the objects class. This will actually point to
* the derived objects class struct (which will be derived from
* GtkObjectClass).
*/
GtkObjectClass *klass;
/* The list of signal handlers and other data
* fields for this object.
*/

View File

@ -140,7 +140,7 @@ static GHashTable *signal_info_hash_table = NULL;
static gint next_signal = 1;
static gint next_handler_id = 1;
static const char *handler_key = "signal_handlers";
static const gchar *handler_key = "gtk-signal-handlers";
static GMemChunk *handler_mem_chunk = NULL;
static GMemChunk *emission_mem_chunk = NULL;
@ -532,6 +532,59 @@ gtk_signal_connect_object_after (GtkObject *object,
TRUE, FALSE);
}
typedef struct _GtkDisconnectInfo GtkDisconnectInfo;
struct _GtkDisconnectInfo
{
GtkObject *object1;
gint disconnect_handler1;
gint signal_handler;
GtkObject *object2;
gint disconnect_handler2;
};
static gint
gtk_alive_disconnecter (GtkDisconnectInfo *info)
{
g_return_val_if_fail (info != NULL, 0);
gtk_signal_disconnect (info->object1, info->disconnect_handler1);
gtk_signal_disconnect (info->object1, info->signal_handler);
gtk_signal_disconnect (info->object2, info->disconnect_handler2);
g_free (info);
return 0;
}
void
gtk_signal_connect_object_while_alive (GtkObject *object,
const gchar *signal,
GtkSignalFunc func,
GtkObject *alive_object)
{
GtkDisconnectInfo *info;
g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_OBJECT (object));
g_return_if_fail (signal != NULL);
g_return_if_fail (func != NULL);
g_return_if_fail (alive_object != NULL);
g_return_if_fail (GTK_IS_OBJECT (alive_object));
info = g_new (GtkDisconnectInfo, 1);
info->object1 = object;
info->object2 = alive_object;
info->signal_handler = gtk_signal_connect_object (object, signal, func, alive_object);
info->disconnect_handler1 = gtk_signal_connect_object (info->object1,
"destroy",
GTK_SIGNAL_FUNC (gtk_alive_disconnecter),
(GtkObject*) info);
info->disconnect_handler2 = gtk_signal_connect_object (info->object2,
"destroy",
GTK_SIGNAL_FUNC (gtk_alive_disconnecter),
(GtkObject*) info);
}
void
gtk_signal_disconnect (GtkObject *object,
gint anid)
@ -554,8 +607,7 @@ gtk_signal_disconnect (GtkObject *object,
if (prev)
prev->next = tmp->next;
else
gtk_object_set_data (object, handler_key, tmp->next);
gtk_signal_handler_unref (tmp, object);
gtk_signal_handler_unref (tmp, object);
return;
}
@ -563,7 +615,7 @@ gtk_signal_disconnect (GtkObject *object,
tmp = tmp->next;
}
g_warning ("could not find handler (%d)", anid);
g_warning ("gtk_signal_disconnect(): could not find handler (%d)", anid);
}
void
@ -594,7 +646,7 @@ gtk_signal_disconnect_by_data (GtkObject *object,
}
if (!found_one)
g_warning ("could not find handler containing data (0x%0lX)", (long) data);
g_warning ("gtk_signal_disconnect_by_data(): could not find handler containing data (0x%0lX)", (long) data);
}
void
@ -621,7 +673,7 @@ gtk_signal_handler_block (GtkObject *object,
tmp = tmp->next;
}
g_warning ("could not find handler (%d)", anid);
g_warning ("gtk_signal_handler_block(): could not find handler (%d)", anid);
}
void
@ -651,7 +703,7 @@ gtk_signal_handler_block_by_data (GtkObject *object,
}
if (!found_one)
g_warning ("could not find handler containing data (0x%0lX)", (long) data);
g_warning ("gtk_signal_handler_block_by_data(): could not find handler containing data (0x%0lX)", (long) data);
}
void
@ -678,7 +730,7 @@ gtk_signal_handler_unblock (GtkObject *object,
tmp = tmp->next;
}
g_warning ("could not find handler (%d)", anid);
g_warning ("gtk_signal_handler_unblock(): could not find handler (%d)", anid);
}
void
@ -708,7 +760,7 @@ gtk_signal_handler_unblock_by_data (GtkObject *object,
}
if (!found_one)
g_warning ("could not find handler containing data (0x%0lX)", (long) data);
g_warning ("gtk_signal_handler_unblock_by_data(): could not find handler containing data (0x%0lX)", (long) data);
}
void

View File

@ -108,6 +108,12 @@ gint gtk_signal_connect_interp (GtkObject *object,
gpointer data,
GtkDestroyNotify destroy_func,
gint after);
void gtk_signal_connect_object_while_alive (GtkObject *object,
const gchar *signal,
GtkSignalFunc func,
GtkObject *alive_object);
void gtk_signal_disconnect (GtkObject *object,
gint anid);
void gtk_signal_disconnect_by_data (GtkObject *object,

View File

@ -24,6 +24,7 @@
#include "gtksignal.h"
#include "gtkwidget.h"
#include "gtkwindow.h"
#include "gtkprivate.h"
#include "gdk/gdk.h"
#include "gdk/gdkx.h"
@ -881,7 +882,7 @@ gtk_widget_init (GtkWidget *widget)
GdkColormap *colormap;
GdkVisual *visual;
GTK_WIDGET_SET_FLAGS (widget, GTK_SENSITIVE | GTK_PARENT_SENSITIVE);
GTK_PRIVATE_FLAGS (widget) = 0;
widget->state = GTK_STATE_NORMAL;
widget->saved_state = GTK_STATE_NORMAL;
widget->name = NULL;
@ -894,6 +895,8 @@ gtk_widget_init (GtkWidget *widget)
widget->window = NULL;
widget->parent = NULL;
GTK_WIDGET_SET_FLAGS (widget, GTK_SENSITIVE | GTK_PARENT_SENSITIVE);
widget->style = gtk_widget_peek_style ();
gtk_style_ref (widget->style);
@ -1227,7 +1230,7 @@ gtk_widget_hide_all (GtkWidget *widget)
if (toplevel != widget)
GTK_CONTAINER (toplevel)->resize_widgets =
g_slist_remove (GTK_CONTAINER (toplevel)->resize_widgets, widget);
GTK_WIDGET_UNSET_FLAGS (widget, GTK_RESIZE_NEEDED);
GTK_PRIVATE_UNSET_FLAGS (widget, GTK_RESIZE_NEEDED);
}
widget_class = GTK_WIDGET_CLASS(GTK_OBJECT(widget)->klass);
@ -1310,11 +1313,10 @@ gtk_widget_realize (GtkWidget *widget)
gtk_signal_emit (GTK_OBJECT (widget), widget_signals[REALIZE]);
if (GTK_WIDGET_HAS_SHAPE_MASK(widget))
if (GTK_WIDGET_HAS_SHAPE_MASK (widget))
{
shape_info = gtk_object_get_data (GTK_OBJECT (widget),
shape_info_key);
g_assert (shape_info != 0);
gdk_window_shape_combine_mask (widget->window,
shape_info->shape_mask,
shape_info->offset_x,
@ -1396,7 +1398,7 @@ gtk_widget_queue_draw (GtkWidget *widget)
parent = parent->parent;
}
GTK_WIDGET_SET_FLAGS (widget, GTK_REDRAW_PENDING);
GTK_PRIVATE_SET_FLAGS (widget, GTK_REDRAW_PENDING);
if (gtk_widget_redraw_queue == NULL)
gtk_idle_add ((GtkFunction) gtk_widget_idle_draw, NULL);
@ -1436,13 +1438,13 @@ gtk_widget_queue_resize (GtkWidget *widget)
g_return_if_fail (widget != NULL);
toplevel = gtk_widget_get_toplevel (widget);
if (GTK_WIDGET_ANCHORED (toplevel))
if (GTK_WIDGET_TOPLEVEL (toplevel))
{
if (GTK_WIDGET_VISIBLE (toplevel))
{
if (!GTK_WIDGET_RESIZE_PENDING (toplevel))
{
GTK_WIDGET_SET_FLAGS (toplevel, GTK_RESIZE_PENDING);
GTK_PRIVATE_SET_FLAGS (toplevel, GTK_RESIZE_PENDING);
if (gtk_widget_resize_queue == NULL)
gtk_idle_add ((GtkFunction) gtk_widget_idle_sizer, NULL);
gtk_widget_resize_queue = g_slist_prepend (gtk_widget_resize_queue, toplevel);
@ -1450,7 +1452,7 @@ gtk_widget_queue_resize (GtkWidget *widget)
if (!GTK_WIDGET_RESIZE_NEEDED (widget))
{
GTK_WIDGET_SET_FLAGS (widget, GTK_RESIZE_NEEDED);
GTK_PRIVATE_SET_FLAGS (widget, GTK_RESIZE_NEEDED);
GTK_CONTAINER (toplevel)->resize_widgets =
g_slist_prepend (GTK_CONTAINER (toplevel)->resize_widgets, widget);
}
@ -1881,7 +1883,7 @@ gtk_widget_reparent (GtkWidget *widget,
{
/* Set a flag so that gtk_widget_unparent doesn't unrealize widget
*/
GTK_WIDGET_SET_FLAGS (widget, GTK_IN_REPARENT);
GTK_PRIVATE_SET_FLAGS (widget, GTK_IN_REPARENT);
}
gtk_widget_ref (widget);
@ -1917,6 +1919,8 @@ gtk_widget_reparent (GtkWidget *widget,
}
else
gdk_window_reparent (widget->window, gtk_widget_get_parent_window (widget), 0, 0);
GTK_PRIVATE_UNSET_FLAGS (widget, GTK_IN_REPARENT);
}
}
}
@ -2230,18 +2234,6 @@ gtk_widget_set_parent (GtkWidget *widget,
g_return_if_fail (widget != NULL);
g_assert (widget->parent == NULL);
if (GTK_WIDGET_TOPLEVEL (widget))
{
g_assert (parent == NULL);
g_assert (!GTK_WIDGET_TOPLEVEL_ONSCREEN (widget));
gtk_widget_ref (widget);
gtk_object_sink (GTK_OBJECT (widget));
GTK_WIDGET_SET_FLAGS (widget, GTK_TOPLEVEL_ONSCREEN);
return;
}
g_return_if_fail (parent != NULL);
gtk_widget_ref (widget);
@ -2259,7 +2251,7 @@ gtk_widget_set_parent (GtkWidget *widget,
while (parent->parent != NULL)
parent = parent->parent;
if (GTK_WIDGET_ANCHORED (parent))
if (GTK_WIDGET_TOPLEVEL (parent))
{
if (!GTK_WIDGET_USER_STYLE (widget))
{
@ -2347,7 +2339,7 @@ gtk_widget_set_style (GtkWidget *widget,
{
g_return_if_fail (widget != NULL);
GTK_WIDGET_SET_FLAGS (widget, GTK_USER_STYLE);
GTK_PRIVATE_SET_FLAGS (widget, GTK_USER_STYLE);
gtk_widget_set_style_internal (widget, style);
}
@ -3085,13 +3077,13 @@ gtk_widget_real_destroy (GtkObject *object)
if (GTK_WIDGET_REDRAW_PENDING (widget))
{
gtk_widget_redraw_queue = g_slist_remove (gtk_widget_redraw_queue, widget);
GTK_WIDGET_UNSET_FLAGS (widget, GTK_REDRAW_PENDING);
GTK_PRIVATE_UNSET_FLAGS (widget, GTK_REDRAW_PENDING);
}
if (GTK_WIDGET_RESIZE_PENDING (widget))
{
gtk_widget_resize_queue = g_slist_remove (gtk_widget_resize_queue, widget);
GTK_WIDGET_UNSET_FLAGS (widget, GTK_RESIZE_PENDING);
GTK_PRIVATE_UNSET_FLAGS (widget, GTK_RESIZE_PENDING);
}
if (GTK_WIDGET_RESIZE_NEEDED (widget))
@ -3101,23 +3093,18 @@ gtk_widget_real_destroy (GtkObject *object)
toplevel = gtk_widget_get_toplevel (widget);
GTK_CONTAINER (toplevel)->resize_widgets =
g_slist_remove (GTK_CONTAINER (toplevel)->resize_widgets, widget);
GTK_WIDGET_UNSET_FLAGS (widget, GTK_RESIZE_NEEDED);
GTK_PRIVATE_UNSET_FLAGS (widget, GTK_RESIZE_NEEDED);
}
if (GTK_WIDGET_HAS_SHAPE_MASK (widget))
gtk_widget_shape_combine_mask (widget, NULL, -1, -1);
gtk_grab_remove (widget);
gtk_selection_remove_all (widget);
gtk_widget_unrealize (widget);
if (widget->parent)
gtk_container_remove (GTK_CONTAINER (widget->parent), widget);
else if (GTK_WIDGET_TOPLEVEL (widget) &&
GTK_WIDGET_TOPLEVEL_ONSCREEN (widget))
{
/* printf ("special toplevel case %p %s\n", widget, gtk_type_name (GTK_WIDGET_TYPE (widget)));
*/
GTK_WIDGET_UNSET_FLAGS (widget, GTK_TOPLEVEL_ONSCREEN);
gtk_widget_unref (widget);
}
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
@ -3381,7 +3368,7 @@ gtk_widget_real_queue_draw (GtkWidget *widget)
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
GTK_WIDGET_UNSET_FLAGS (widget, GTK_REDRAW_PENDING);
GTK_PRIVATE_UNSET_FLAGS (widget, GTK_REDRAW_PENDING);
gtk_widget_draw (widget, NULL);
return FALSE;
@ -3401,7 +3388,7 @@ gtk_widget_real_queue_resize (GtkWidget *widget)
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
GTK_WIDGET_UNSET_FLAGS (widget, GTK_RESIZE_PENDING);
GTK_PRIVATE_UNSET_FLAGS (widget, GTK_RESIZE_PENDING);
gtk_container_need_resize (GTK_CONTAINER (widget));
return FALSE;
@ -3709,32 +3696,44 @@ gtk_widget_shape_combine_mask (GtkWidget *widget,
GtkWidgetShapeInfo* shape_info;
g_return_if_fail (widget != NULL);
g_return_if_fail (shape_mask != NULL);
/* set_shape doesn't work on widgets without gdk window */
g_return_if_fail (!GTK_WIDGET_NO_WINDOW (widget));
/*
* remember shape mask for later gtk_widget_realize's
*/
shape_info = gtk_object_get_data (GTK_OBJECT (widget), shape_info_key);
if (!shape_info)
if (!shape_mask)
{
shape_info = g_new (GtkWidgetShapeInfo, 1);
gtk_object_set_data (GTK_OBJECT (widget), shape_info_key, shape_info);
GTK_PRIVATE_UNSET_FLAGS (widget, GTK_HAS_SHAPE_MASK);
shape_info = gtk_object_get_data (GTK_OBJECT (widget), shape_info_key);
gtk_object_remove_data (GTK_OBJECT (widget), shape_info_key);
g_free (shape_info);
if (widget->window)
{
/* FIXME: we need gdk code here that removes the shape from a window
*/
}
}
else
{
GTK_PRIVATE_SET_FLAGS (widget, GTK_HAS_SHAPE_MASK);
shape_info = gtk_object_get_data (GTK_OBJECT (widget), shape_info_key);
if (!shape_info)
{
shape_info = g_new (GtkWidgetShapeInfo, 1);
gtk_object_set_data (GTK_OBJECT (widget), shape_info_key, shape_info);
}
shape_info->shape_mask = shape_mask;
shape_info->offset_x = offset_x;
shape_info->offset_y = offset_y;
/* set shape if widget has a gdk window allready.
* otherwise the shape is scheduled to be set by gtk_widget_realize.
*/
if (widget->window)
gdk_window_shape_combine_mask (widget->window, shape_mask,
offset_x, offset_y);
}
shape_info->shape_mask = shape_mask;
shape_info->offset_x = offset_x;
shape_info->offset_y = offset_y;
GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_SHAPE_MASK);
/*
* set shape if widget has a gdk window allready.
* otherwise the shape is scheduled to be set by gtk_widget_realize.
*/
if (widget->window)
gdk_window_shape_combine_mask (widget->window, shape_mask,
offset_x, offset_y);
}
/*****************************************

View File

@ -30,97 +30,71 @@ extern "C" {
#endif /* __cplusplus */
/* The flags that are used in the flags member of the GtkObject
* structure.
/* The flags that are used by GtkWidget on top of the
* flags field of GtkObject.
*/
enum
{
GTK_VISIBLE = 1 << 3,
GTK_MAPPED = 1 << 4,
GTK_UNMAPPED = 1 << 5,
GTK_REALIZED = 1 << 6,
GTK_SENSITIVE = 1 << 7,
GTK_PARENT_SENSITIVE = 1 << 8,
GTK_NO_WINDOW = 1 << 9,
GTK_HAS_FOCUS = 1 << 10,
GTK_CAN_FOCUS = 1 << 11,
GTK_HAS_DEFAULT = 1 << 12,
GTK_CAN_DEFAULT = 1 << 13,
GTK_PROPAGATE_STATE = 1 << 14,
GTK_ANCHORED = 1 << 15,
GTK_BASIC = 1 << 16,
GTK_USER_STYLE = 1 << 17,
GTK_HAS_GRAB = 1 << 18,
GTK_REDRAW_PENDING = 1 << 19,
GTK_RESIZE_PENDING = 1 << 20,
GTK_RESIZE_NEEDED = 1 << 21,
GTK_HAS_SHAPE_MASK = 1 << 22,
GTK_LEAVE_PENDING = 1 << 23,
GTK_TOPLEVEL = 1 << 24,
GTK_TOPLEVEL_ONSCREEN = 1 << 25,
/* Private flag. If set, don't unrealize a widget when it is removed
* from its parent. Used by gtk_widget_reparent().
*/
GTK_IN_REPARENT = 1 << 26
GTK_TOPLEVEL = 1 << 4,
GTK_NO_WINDOW = 1 << 5,
GTK_REALIZED = 1 << 6,
GTK_MAPPED = 1 << 7,
GTK_VISIBLE = 1 << 8,
GTK_SENSITIVE = 1 << 9,
GTK_PARENT_SENSITIVE = 1 << 10,
GTK_CAN_FOCUS = 1 << 11,
GTK_HAS_FOCUS = 1 << 12,
GTK_CAN_DEFAULT = 1 << 13,
GTK_HAS_DEFAULT = 1 << 14,
GTK_HAS_GRAB = 1 << 15,
GTK_BASIC = 1 << 16
};
/* Macro for casting a pointer to a GtkWidget pointer.
*/
#define GTK_WIDGET(obj) GTK_CHECK_CAST (obj, gtk_widget_get_type (), GtkWidget)
#define GTK_WIDGET(wid) GTK_CHECK_CAST ((wid), gtk_widget_get_type (), GtkWidget)
/* Macro for casting the "class" field of an object to
* a GtkWidgetClass pointer.
/* Macro for casting the klass field of a widget to a GtkWidgetClass pointer.
*/
#define GTK_WIDGET_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gtk_widget_get_type (), GtkWidgetClass)
#define GTK_WIDGET_CLASS(klass) GTK_CHECK_CLASS_CAST ((klass), gtk_widget_get_type (), GtkWidgetClass)
/* Macros for extracting various fields from GtkWidget and
* GtkWidgetClass structures.
/* Macros for extracting various fields from GtkWidget and GtkWidgetClass.
*/
#define GTK_WIDGET_TYPE(obj) (GTK_OBJECT_TYPE (obj))
#define GTK_WIDGET_STATE(obj) (GTK_WIDGET (obj)->state)
#define GTK_WIDGET_SAVED_STATE(obj) (GTK_WIDGET (obj)->saved_state)
#define GTK_WIDGET_VISIBLE(obj) (GTK_OBJECT_FLAGS (obj) & GTK_VISIBLE)
#define GTK_WIDGET_MAPPED(obj) (GTK_OBJECT_FLAGS (obj) & GTK_MAPPED)
#define GTK_WIDGET_UNMAPPED(obj) (GTK_OBJECT_FLAGS (obj) & GTK_UNMAPPED)
#define GTK_WIDGET_REALIZED(obj) (GTK_OBJECT_FLAGS (obj) & GTK_REALIZED)
#define GTK_WIDGET_SENSITIVE(obj) (GTK_OBJECT_FLAGS (obj) & GTK_SENSITIVE)
#define GTK_WIDGET_PARENT_SENSITIVE(obj) (GTK_OBJECT_FLAGS (obj) & GTK_PARENT_SENSITIVE)
#define GTK_WIDGET_IS_SENSITIVE(obj) ((GTK_WIDGET_SENSITIVE (obj) && \
GTK_WIDGET_PARENT_SENSITIVE (obj)) != 0)
#define GTK_WIDGET_NO_WINDOW(obj) (GTK_OBJECT_FLAGS (obj) & GTK_NO_WINDOW)
#define GTK_WIDGET_HAS_FOCUS(obj) (GTK_OBJECT_FLAGS (obj) & GTK_HAS_FOCUS)
#define GTK_WIDGET_CAN_FOCUS(obj) (GTK_OBJECT_FLAGS (obj) & GTK_CAN_FOCUS)
#define GTK_WIDGET_HAS_DEFAULT(obj) (GTK_OBJECT_FLAGS (obj) & GTK_HAS_DEFAULT)
#define GTK_WIDGET_CAN_DEFAULT(obj) (GTK_OBJECT_FLAGS (obj) & GTK_CAN_DEFAULT)
#define GTK_WIDGET_PROPAGATE_STATE(obj) (GTK_OBJECT_FLAGS (obj) & GTK_PROPAGATE_STATE)
#define GTK_WIDGET_DRAWABLE(obj) (GTK_WIDGET_VISIBLE (obj) && GTK_WIDGET_MAPPED (obj))
#define GTK_WIDGET_ANCHORED(obj) (GTK_OBJECT_FLAGS (obj) & GTK_ANCHORED)
#define GTK_WIDGET_BASIC(obj) (GTK_OBJECT_FLAGS (obj) & GTK_BASIC)
#define GTK_WIDGET_USER_STYLE(obj) (GTK_OBJECT_FLAGS (obj) & GTK_USER_STYLE)
#define GTK_WIDGET_HAS_GRAB(obj) (GTK_OBJECT_FLAGS (obj) & GTK_HAS_GRAB)
#define GTK_WIDGET_REDRAW_PENDING(obj) (GTK_OBJECT_FLAGS (obj) & GTK_REDRAW_PENDING)
#define GTK_WIDGET_RESIZE_PENDING(obj) (GTK_OBJECT_FLAGS (obj) & GTK_RESIZE_PENDING)
#define GTK_WIDGET_RESIZE_NEEDED(obj) (GTK_OBJECT_FLAGS (obj) & GTK_RESIZE_NEEDED)
#define GTK_WIDGET_HAS_SHAPE_MASK(obj) (GTK_OBJECT_FLAGS (obj) & GTK_HAS_SHAPE_MASK)
#define GTK_WIDGET_LEAVE_PENDING(obj) (GTK_OBJECT_FLAGS (obj) & GTK_LEAVE_PENDING)
#define GTK_WIDGET_TOPLEVEL(obj) (GTK_OBJECT_FLAGS (obj) & GTK_TOPLEVEL)
#define GTK_WIDGET_TOPLEVEL_ONSCREEN(obj) (GTK_OBJECT_FLAGS (obj) & GTK_TOPLEVEL_ONSCREEN)
#define GTK_WIDGET_IN_REPARENT(obj) (GTK_OBJECT_FLAGS (obj) & GTK_IN_REPARENT)
#define GTK_WIDGET_TYPE(wid) (GTK_OBJECT_TYPE (wid))
#define GTK_WIDGET_STATE(wid) (GTK_WIDGET (wid)->state)
#define GTK_WIDGET_SAVED_STATE(wid) (GTK_WIDGET (wid)->saved_state)
/* Macros for extracting the widget flags from GtkWidget.
*/
#define GTK_WIDGET_FLAGS(wid) (GTK_OBJECT_FLAGS (wid))
#define GTK_WIDGET_TOPLEVEL(wid) (GTK_WIDGET_FLAGS (wid) & GTK_TOPLEVEL)
#define GTK_WIDGET_NO_WINDOW(wid) (GTK_WIDGET_FLAGS (wid) & GTK_NO_WINDOW)
#define GTK_WIDGET_REALIZED(wid) (GTK_WIDGET_FLAGS (wid) & GTK_REALIZED)
#define GTK_WIDGET_MAPPED(wid) (GTK_WIDGET_FLAGS (wid) & GTK_MAPPED)
#define GTK_WIDGET_VISIBLE(wid) (GTK_WIDGET_FLAGS (wid) & GTK_VISIBLE)
#define GTK_WIDGET_DRAWABLE(wid) (GTK_WIDGET_VISIBLE (wid) && GTK_WIDGET_MAPPED (wid))
#define GTK_WIDGET_SENSITIVE(wid) (GTK_WIDGET_FLAGS (wid) & GTK_SENSITIVE)
#define GTK_WIDGET_PARENT_SENSITIVE(wid) (GTK_WIDGET_FLAGS (wid) & GTK_PARENT_SENSITIVE)
#define GTK_WIDGET_IS_SENSITIVE(wid) ((GTK_WIDGET_SENSITIVE (wid) && \
GTK_WIDGET_PARENT_SENSITIVE (wid)) != 0)
#define GTK_WIDGET_CAN_FOCUS(wid) (GTK_WIDGET_FLAGS (wid) & GTK_CAN_FOCUS)
#define GTK_WIDGET_HAS_FOCUS(wid) (GTK_WIDGET_FLAGS (wid) & GTK_HAS_FOCUS)
#define GTK_WIDGET_CAN_DEFAULT(wid) (GTK_WIDGET_FLAGS (wid) & GTK_CAN_DEFAULT)
#define GTK_WIDGET_HAS_DEFAULT(wid) (GTK_WIDGET_FLAGS (wid) & GTK_HAS_DEFAULT)
#define GTK_WIDGET_HAS_GRAB(wid) (GTK_WIDGET_FLAGS (wid) & GTK_HAS_GRAB)
#define GTK_WIDGET_BASIC(wid) (GTK_WIDGET_FLAGS (wid) & GTK_BASIC)
/* Macros for setting and clearing widget flags.
*/
#define GTK_WIDGET_SET_FLAGS(wid,flag) G_STMT_START{ (GTK_WIDGET_FLAGS (wid) |= (flag)); }G_STMT_END
#define GTK_WIDGET_UNSET_FLAGS(wid,flag) G_STMT_START{ (GTK_WIDGET_FLAGS (wid) &= ~(flag)); }G_STMT_END
/* Macros for testing whether "wid" is of type GtkWidget.
*/
#define GTK_IS_WIDGET(wid) GTK_CHECK_TYPE ((wid), GTK_TYPE_WIDGET)
#define GTK_TYPE_WIDGET (gtk_widget_get_type ())
/* Macro for testing whether "obj" is of type GtkWidget.
*/
#define GTK_IS_WIDGET(obj) GTK_CHECK_TYPE (obj, GTK_TYPE_WIDGET)
/* Macros for setting and clearing widget flags. Notice
* that these are only wrappers for the macros which
* set and clear the flags in the GtkObject structure.
*/
#define GTK_WIDGET_SET_FLAGS(obj,flag) (GTK_OBJECT_SET_FLAGS (obj, flag))
#define GTK_WIDGET_UNSET_FLAGS(obj,flag) (GTK_OBJECT_UNSET_FLAGS (obj, flag))
typedef struct _GtkRequisition GtkRequisition;
@ -189,6 +163,13 @@ struct _GtkWidget
*/
GtkObject object;
/* 16 bits of internally used private flags.
* this will be packed into the same 4 byte alignment frame that
* state and saved_state go. we therefore don't waste any new
* space on this.
*/
guint16 private_flags;
/* The state of the widget. There are actually only
* 5 widget states (defined in "gtkenums.h").
*/

View File

@ -20,6 +20,7 @@
#include "gdk/gdk.h"
#include "gdk/gdkkeysyms.h"
#include "gdk/gdkx.h"
#include "gtkprivate.h"
#include "gtksignal.h"
#include "gtkwindow.h"
@ -64,6 +65,7 @@ static void gtk_window_set_arg (GtkWindow *window,
static void gtk_window_get_arg (GtkWindow *window,
GtkArg *arg,
guint arg_id);
static void gtk_window_destroy (GtkObject *object);
static void gtk_window_finalize (GtkObject *object);
static void gtk_window_show (GtkWidget *widget);
static void gtk_window_hide (GtkWidget *widget);
@ -177,6 +179,7 @@ gtk_window_class_init (GtkWindowClass *klass)
gtk_object_class_add_signals (object_class, window_signals, LAST_SIGNAL);
object_class->destroy = gtk_window_destroy;
object_class->finalize = gtk_window_finalize;
widget_class->show = gtk_window_show;
@ -206,7 +209,7 @@ static void
gtk_window_init (GtkWindow *window)
{
GTK_WIDGET_UNSET_FLAGS (window, GTK_NO_WINDOW);
GTK_WIDGET_SET_FLAGS (window, GTK_ANCHORED | GTK_TOPLEVEL);
GTK_WIDGET_SET_FLAGS (window, GTK_TOPLEVEL);
window->title = NULL;
window->wmclass_name = NULL;
@ -224,8 +227,7 @@ gtk_window_init (GtkWindow *window)
window->position = GTK_WIN_POS_NONE;
window->use_uposition = TRUE;
/* gtk_container_add (gtk_root, GTK_WIDGET (window)); */
gtk_widget_set_parent (GTK_WIDGET (window), NULL);
gtk_container_register_toplevel (GTK_CONTAINER (window));
}
static void
@ -481,6 +483,18 @@ gtk_window_marshal_signal_2 (GtkObject *object,
(* rfunc) (object, GTK_VALUE_POINTER (args[0]), func_data);
}
static void
gtk_window_destroy (GtkObject *object)
{
g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_WINDOW (object));
gtk_container_unregister_toplevel (GTK_CONTAINER (object));
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
static void
gtk_window_finalize (GtkObject *object)
{
@ -525,7 +539,6 @@ gtk_window_map (GtkWidget *widget)
g_return_if_fail (GTK_IS_WINDOW (widget));
GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
GTK_WIDGET_UNSET_FLAGS (widget, GTK_UNMAPPED);
gtk_window_move_resize (widget);
window = GTK_WINDOW (widget);
@ -548,7 +561,6 @@ gtk_window_unmap (GtkWidget *widget)
g_return_if_fail (GTK_IS_WINDOW (widget));
GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
GTK_WIDGET_SET_FLAGS (widget, GTK_UNMAPPED);
gdk_window_hide (widget->window);
window = GTK_WINDOW (widget);
@ -670,9 +682,6 @@ gtk_window_expose_event (GtkWidget *widget,
g_return_val_if_fail (GTK_IS_WINDOW (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
if (!GTK_WIDGET_UNMAPPED (widget))
GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
if (GTK_WIDGET_DRAWABLE (widget))
if (GTK_WIDGET_CLASS (parent_class)->expose_event)
return (* GTK_WIDGET_CLASS (parent_class)->expose_event) (widget, event);
@ -1064,7 +1073,8 @@ gtk_real_window_move_resize (GtkWindow *window,
* widgets and reallocate their sizes appropriately. We
* make the optimization of not performing reallocation
* for a widget who also has a parent in the resize widgets
* list.
* list. GTK_RESIZE_NEEDED is used for flagging those
* parents inside this function.
*/
GSList *resize_widgets, *node;
@ -1075,7 +1085,7 @@ gtk_real_window_move_resize (GtkWindow *window,
{
child = (GtkWidget *)node->data;
GTK_WIDGET_UNSET_FLAGS (child, GTK_RESIZE_NEEDED);
GTK_PRIVATE_UNSET_FLAGS (child, GTK_RESIZE_NEEDED);
widget = child->parent;
while (widget &&
@ -1084,7 +1094,7 @@ gtk_real_window_move_resize (GtkWindow *window,
widget = widget->parent;
if (widget)
GTK_WIDGET_SET_FLAGS (widget, GTK_RESIZE_NEEDED);
GTK_PRIVATE_SET_FLAGS (widget, GTK_RESIZE_NEEDED);
}
for (node = resize_widgets; node; node = node->next)
@ -1105,7 +1115,7 @@ gtk_real_window_move_resize (GtkWindow *window,
{
if (GTK_WIDGET_RESIZE_NEEDED (widget))
{
GTK_WIDGET_UNSET_FLAGS (resize_container, GTK_RESIZE_NEEDED);
GTK_PRIVATE_UNSET_FLAGS (resize_container, GTK_RESIZE_NEEDED);
resize_container = widget;
}
widget = widget->parent;
@ -1125,7 +1135,7 @@ gtk_real_window_move_resize (GtkWindow *window,
widget = tmp_list->data;
tmp_list = tmp_list->next;
GTK_WIDGET_UNSET_FLAGS (widget, GTK_RESIZE_NEEDED);
GTK_PRIVATE_UNSET_FLAGS (widget, GTK_RESIZE_NEEDED);
gtk_widget_size_allocate (widget, &widget->allocation);
gtk_widget_queue_draw (widget);
}