Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gtk
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nikita Churaev
gtk
Commits
4af33fa2
Commit
4af33fa2
authored
Jan 30, 1998
by
Tim Janik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hm, initital refcount revolution commit ;)
still some gnits left, but keep working on it ;) -timj
parent
ee7038f9
Changes
56
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
56 changed files
with
2026 additions
and
1657 deletions
+2026
-1657
REFCOUNTING
REFCOUNTING
+114
-5
gdk/gdk.h
gdk/gdk.h
+2
-0
gdk/gdkgc.c
gdk/gdkgc.c
+27
-6
gdk/gdkprivate.h
gdk/gdkprivate.h
+4
-3
gtk/gtkadjustment.c
gtk/gtkadjustment.c
+12
-0
gtk/gtkadjustment.h
gtk/gtkadjustment.h
+4
-0
gtk/gtkbin.c
gtk/gtkbin.c
+0
-25
gtk/gtkbox.c
gtk/gtkbox.c
+0
-34
gtk/gtkbutton.c
gtk/gtkbutton.c
+4
-25
gtk/gtkcolorsel.c
gtk/gtkcolorsel.c
+4
-24
gtk/gtkcontainer.c
gtk/gtkcontainer.c
+82
-10
gtk/gtkcontainer.h
gtk/gtkcontainer.h
+9
-0
gtk/gtkcurve.c
gtk/gtkcurve.c
+4
-5
gtk/gtkentry.c
gtk/gtkentry.c
+5
-6
gtk/gtkfixed.c
gtk/gtkfixed.c
+1
-33
gtk/gtkframe.c
gtk/gtkframe.c
+4
-5
gtk/gtkgamma.c
gtk/gtkgamma.c
+1
-4
gtk/gtkinputdialog.c
gtk/gtkinputdialog.c
+4
-5
gtk/gtklabel.c
gtk/gtklabel.c
+12
-16
gtk/gtklist.c
gtk/gtklist.c
+51
-37
gtk/gtkmain.c
gtk/gtkmain.c
+25
-67
gtk/gtkmenu.c
gtk/gtkmenu.c
+5
-2
gtk/gtkmenuitem.c
gtk/gtkmenuitem.c
+5
-4
gtk/gtkmenushell.c
gtk/gtkmenushell.c
+14
-43
gtk/gtkmisc.c
gtk/gtkmisc.c
+1
-0
gtk/gtknotebook.c
gtk/gtknotebook.c
+5
-40
gtk/gtkobject.c
gtk/gtkobject.c
+245
-67
gtk/gtkobject.h
gtk/gtkobject.h
+23
-26
gtk/gtkoptionmenu.c
gtk/gtkoptionmenu.c
+18
-14
gtk/gtkpaned.c
gtk/gtkpaned.c
+9
-33
gtk/gtkpixmap.c
gtk/gtkpixmap.c
+4
-5
gtk/gtkpreview.c
gtk/gtkpreview.c
+4
-5
gtk/gtkrange.c
gtk/gtkrange.c
+27
-11
gtk/gtkruler.c
gtk/gtkruler.c
+1
-0
gtk/gtkscale.c
gtk/gtkscale.c
+0
-17
gtk/gtkscrolledwindow.c
gtk/gtkscrolledwindow.c
+28
-2
gtk/gtkselection.c
gtk/gtkselection.c
+1
-0
gtk/gtksignal.c
gtk/gtksignal.c
+156
-155
gtk/gtksignal.h
gtk/gtksignal.h
+2
-2
gtk/gtkstyle.c
gtk/gtkstyle.c
+2
-2
gtk/gtktable.c
gtk/gtktable.c
+4
-25
gtk/gtktext.c
gtk/gtktext.c
+30
-17
gtk/gtktoolbar.c
gtk/gtktoolbar.c
+1
-1
gtk/gtktooltips.c
gtk/gtktooltips.c
+86
-82
gtk/gtktooltips.h
gtk/gtktooltips.h
+20
-13
gtk/gtktree.c
gtk/gtktree.c
+32
-15
gtk/gtktreeitem.c
gtk/gtktreeitem.c
+30
-6
gtk/gtktypeutils.c
gtk/gtktypeutils.c
+21
-0
gtk/gtktypeutils.h
gtk/gtktypeutils.h
+57
-54
gtk/gtkviewport.c
gtk/gtkviewport.c
+25
-1
gtk/gtkwidget.c
gtk/gtkwidget.c
+437
-387
gtk/gtkwidget.h
gtk/gtkwidget.h
+235
-226
gtk/gtkwindow.c
gtk/gtkwindow.c
+87
-60
gtk/gtkwindow.h
gtk/gtkwindow.h
+2
-0
gtk/testgtk.c
gtk/testgtk.c
+20
-16
tests/testgtk.c
tests/testgtk.c
+20
-16
No files found.
REFCOUNTING
View file @
4af33fa2
...
...
@@ -7,10 +7,14 @@ functions that follow these conventions:
*_new: Create a new structure with a reference count of 1.
*_ref: Increase ref count by one.
*_unref: Decrease ref count by one. If the count drops to zero,
free the memory. No user visible actions should take place,
like destryoing windows, etc.
run aprropriate finalization code and free the memory.
No user visible actions should take place, like
destryoing windows, etc.
Some structures also provide a *_destroy function.
Some structures also provide a *_destroy function, but it is generally
unrelated to freeing the memory. `Destroying' merely renders an
object `unusable'. But as long as there are references to it, it will
stick around.
GdkWindow
---------
...
...
@@ -28,7 +32,7 @@ ref_count is updated accordingly.
You can call gdk_window_destroy more than once on a particular
GdkWindow, it will only be destroyed when it hasn't been yet. The
ref_count is *always* decremented, tho.
ref_count is *always* decremented, tho.
Be careful.
GdkPixmap
---------
...
...
@@ -86,7 +90,112 @@ There is no gtk_style_destroy function.
GtkObject
---------
This one is the most tricky and I'm still meditating over it.
GtkObjects follow the usual ref_counting strategy, but with a twist.
They are created with a ref_count of 1. GtkObjects are able able to
run finalization code when the ref_count drops to zero but you cannot
register arbitrary signal handlers to run at finalization time.
There is also the old gtk_object_destroy function and the "destroy"
signal but they are somewhat independent from finalization. Just as
stated at the top of this text, gtk_object_destroy merely renders an
object unusable. When the object is a container widget for example,
it unrealizes that widget, removes all children and disconnects all
signal handlers. The finalization code is different, it would for
example free associated memory for text strings and release the
attached style.
[This is the biggest change. Every widget must be revised to have a
proper "destroy" function, etc. Such a destroy function must be able
to be called any number of times and generally leave the widget in a
minimal but consistent state. The "finalization" function is new and
should perform last-minute cleanup actions. It can assume that the
"destroy" function has been called as the last function on this
widget.
Essentially, the old "destroy" function has been split into a
"finalize" plus a "destroy" function.]
It is not possible to create GtkObjects with a ref_count of 0 (as it
is done now) because the first ref/unref pair will destroy it
unintentionally.
To be mostly backward compatible with existing practice, a GtkObject
leads a more complicated life than the other reference counted structures.
When a GtkObject is created, it starts out in a special state called
"floating" (this is the twist). This means that it is alive and has a
reference to it, but the `owner' of this reference is not known.
There are certain `potential owners' that will adopt a floating
GtkObject. For GtkWidgets the most common adopters are the parent
widget.
When you want to adopt a possibly floating GtkObject, you call
gtk_object_sink on it. This clears the floating state of the
GtkObject and decrements the ref_count by one, if it has been floating
previously. Once the floating state has been cleared, it will never
be set again.
All widgets that are part of the display are linked into a
parent/child tree. The link from the parent to a child is reflected
in the ref_count of the child, but the link from the child to the
parent is not reflected in the ref_count of the parent.
Like a GtkObject, a GtkWidget is created with a ref_count of 1 and
initially flagged as `floating'. As soon as it is added as a child to
a parent, the `floating' flag is cleared and never will be set again.
Not even when it is later unparented. The act of clearing the
`floating' flag also decrements the ref_count of the widget by one.
When the widget is unparented, its underlying GdkWindow is destroyed
(when it has one), it loses its reference from the parent and
naturally the ref_count is decremented.
It is considered a bug if a widget still has a GdkWindow when it is
being freed.
Toplevel widgets, which don't have a `natural' parent, are adopted by
a special widget, maybe a GtkDisplay or GtkScreen. This special
parent of all toplevel widgets is never freed. The toplevel widgets
are added to this parent as soon as they are created. [Maybe this
special widget will only exist conceptually because toplevel widgets
are identified by parent == NULL through-out the code.]
So, the typical career of a GtkWindow and the GtkButton that sits in
it looks like this:
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
// window is created with ref_count == 1. It is not flagged as
// `floating' because it has already been added to the special
// parent of all toplevel widgets.
button = gtk_button_new_with_label ("Yo!");
// button->ref_count == 1 and it is flagged as `floating'.
gtk_container_add (window, button);
// button->ref_count still == 1, but it is no longer `floating'.
gtk_widget_show (button);
gtk_widget_show (window);
// The widgets get their GdkWindows, nothing significant happens to
// the ref_counts.
Then, when the user wants to get rid of the window:
gtk_widget_destroy (window);
// The GdkWindow of `window' and all its child GdkWindows are
// destroyed.
// window is removed from its (conceptual) parent and its ref_count
// drops to zero. The destroy code of `window' destroyes `button'.
// The destriction of the button removes it from its parent, the
// button->ref_count drops to zero and the button is freed, too.
- Marius Vollmer <mvo@zagadka.ping.de>
gdk/gdk.h
View file @
4af33fa2
...
...
@@ -300,6 +300,8 @@ GdkGC* gdk_gc_new (GdkWindow *window);
GdkGC
*
gdk_gc_new_with_values
(
GdkWindow
*
window
,
GdkGCValues
*
values
,
GdkGCValuesMask
values_mask
);
GdkGC
*
gdk_gc_ref
(
GdkGC
*
gc
);
void
gdk_gc_unref
(
GdkGC
*
gc
);
void
gdk_gc_destroy
(
GdkGC
*
gc
);
void
gdk_gc_get_values
(
GdkGC
*
gc
,
GdkGCValues
*
values
);
...
...
gdk/gdkgc.c
View file @
4af33fa2
...
...
@@ -50,6 +50,7 @@ gdk_gc_new_with_values (GdkWindow *window,
xwindow
=
window_private
->
xwindow
;
private
->
xdisplay
=
window_private
->
xdisplay
;
private
->
ref_count
=
1
;
xvalues
.
function
=
GXcopy
;
xvalues
.
fill_style
=
FillSolid
;
...
...
@@ -220,15 +221,35 @@ gdk_gc_new_with_values (GdkWindow *window,
void
gdk_gc_destroy
(
GdkGC
*
gc
)
{
GdkGCPrivate
*
private
;
gdk_gc_unref
(
gc
);
}
g_return_if_fail
(
gc
!=
NULL
);
GdkGC
*
gdk_gc_ref
(
GdkGC
*
gc
)
{
GdkGCPrivate
*
private
=
(
GdkGCPrivate
*
)
gc
;
private
=
(
GdkGCPrivate
*
)
gc
;
XFreeGC
(
private
->
xdisplay
,
private
->
xgc
);
g_return_val_if_fail
(
gc
!=
NULL
,
NULL
);
private
->
ref_count
+=
1
;
return
gc
;
}
memset
(
gc
,
0
,
sizeof
(
GdkGCPrivate
));
g_free
(
gc
);
void
gdk_gc_unref
(
GdkGC
*
gc
)
{
GdkGCPrivate
*
private
=
(
GdkGCPrivate
*
)
gc
;
g_return_if_fail
(
gc
!=
NULL
);
if
(
private
->
ref_count
>
1
)
private
->
ref_count
-=
1
;
else
{
XFreeGC
(
private
->
xdisplay
,
private
->
xgc
);
memset
(
gc
,
0
,
sizeof
(
GdkGCPrivate
));
g_free
(
gc
);
}
}
void
...
...
gdk/gdkprivate.h
View file @
4af33fa2
...
...
@@ -58,8 +58,8 @@ struct _GdkWindowPrivate
guint16
width
;
guint16
height
;
guint8
resize_count
;
guint8
ref_count
;
guint8
window_type
;
guint
ref_count
;
guint
destroyed
:
2
;
guint
dnd_drag_enabled
:
1
,
dnd_drag_datashow
:
1
,
...
...
@@ -104,6 +104,7 @@ struct _GdkGCPrivate
GdkGC
gc
;
GC
xgc
;
Display
*
xdisplay
;
guint
ref_count
;
};
struct
_GdkColormapPrivate
...
...
@@ -114,7 +115,7 @@ struct _GdkColormapPrivate
GdkVisual
*
visual
;
gint
private_val
;
gint
next_color
;
gint
ref_count
;
g
u
int
ref_count
;
};
struct
_GdkVisualPrivate
...
...
@@ -130,7 +131,7 @@ struct _GdkFontPrivate
/* generic pointer point to XFontStruct or XFontSet */
gpointer
xfont
;
Display
*
xdisplay
;
gint
ref_count
;
g
u
int
ref_count
;
};
struct
_GdkCursorPrivate
...
...
gtk/gtkadjustment.c
View file @
4af33fa2
...
...
@@ -117,3 +117,15 @@ gtk_adjustment_new (gfloat value,
return
GTK_OBJECT
(
adjustment
);
}
void
gtk_adjustment_set_value
(
GtkAdjustment
*
adjustment
,
gfloat
value
)
{
g_return_if_fail
(
adjustment
!=
NULL
);
g_return_if_fail
(
GTK_IS_ADJUSTMENT
(
adjustment
));
adjustment
->
value
=
CLAMP
(
value
,
adjustment
->
lower
,
adjustment
->
upper
);
gtk_signal_emit_by_name
(
GTK_OBJECT
(
adjustment
),
"value_changed"
);
}
gtk/gtkadjustment.h
View file @
4af33fa2
...
...
@@ -64,6 +64,10 @@ GtkObject* gtk_adjustment_new (gfloat value,
gfloat
step_increment
,
gfloat
page_increment
,
gfloat
page_size
);
void
gtk_adjustment_set_value
(
GtkAdjustment
*
adjustment
,
gfloat
value
);
#ifdef __cplusplus
...
...
gtk/gtkbin.c
View file @
4af33fa2
...
...
@@ -20,7 +20,6 @@
static
void
gtk_bin_class_init
(
GtkBinClass
*
klass
);
static
void
gtk_bin_init
(
GtkBin
*
bin
);
static
void
gtk_bin_destroy
(
GtkObject
*
object
);
static
void
gtk_bin_map
(
GtkWidget
*
widget
);
static
void
gtk_bin_unmap
(
GtkWidget
*
widget
);
static
void
gtk_bin_draw
(
GtkWidget
*
widget
,
...
...
@@ -76,8 +75,6 @@ gtk_bin_class_init (GtkBinClass *class)
parent_class
=
gtk_type_class
(
gtk_container_get_type
());
object_class
->
destroy
=
gtk_bin_destroy
;
widget_class
->
map
=
gtk_bin_map
;
widget_class
->
unmap
=
gtk_bin_unmap
;
widget_class
->
draw
=
gtk_bin_draw
;
...
...
@@ -97,27 +94,6 @@ gtk_bin_init (GtkBin *bin)
}
static
void
gtk_bin_destroy
(
GtkObject
*
object
)
{
GtkBin
*
bin
;
g_return_if_fail
(
object
!=
NULL
);
g_return_if_fail
(
GTK_IS_BIN
(
object
));
bin
=
GTK_BIN
(
object
);
if
(
bin
->
child
)
{
bin
->
child
->
parent
=
NULL
;
gtk_object_unref
(
GTK_OBJECT
(
bin
->
child
));
gtk_widget_destroy
(
bin
->
child
);
}
if
(
GTK_OBJECT_CLASS
(
parent_class
)
->
destroy
)
(
*
GTK_OBJECT_CLASS
(
parent_class
)
->
destroy
)
(
object
);
}
static
void
gtk_bin_map
(
GtkWidget
*
widget
)
{
...
...
@@ -261,7 +237,6 @@ gtk_bin_remove (GtkContainer *container,
if
(
bin
->
child
==
widget
)
{
gtk_widget_unparent
(
widget
);
bin
->
child
=
NULL
;
if
(
GTK_WIDGET_VISIBLE
(
widget
)
&&
GTK_WIDGET_VISIBLE
(
container
))
...
...
gtk/gtkbox.c
View file @
4af33fa2
...
...
@@ -31,7 +31,6 @@ static void gtk_box_get_arg (GtkBox *box,
static
void
gtk_box_set_arg
(
GtkBox
*
box
,
GtkArg
*
arg
,
guint
arg_id
);
static
void
gtk_box_destroy
(
GtkObject
*
object
);
static
void
gtk_box_map
(
GtkWidget
*
widget
);
static
void
gtk_box_unmap
(
GtkWidget
*
widget
);
static
void
gtk_box_draw
(
GtkWidget
*
widget
,
...
...
@@ -90,8 +89,6 @@ gtk_box_class_init (GtkBoxClass *class)
gtk_object_add_arg_type
(
"GtkBox::spacing"
,
GTK_TYPE_INT
,
ARG_SPACING
);
gtk_object_add_arg_type
(
"GtkBox::homogeneous"
,
GTK_TYPE_BOOL
,
ARG_HOMOGENEOUS
);
object_class
->
destroy
=
gtk_box_destroy
;
widget_class
->
map
=
gtk_box_map
;
widget_class
->
unmap
=
gtk_box_unmap
;
widget_class
->
draw
=
gtk_box_draw
;
...
...
@@ -419,37 +416,6 @@ gtk_box_set_child_packing (GtkBox *box,
}
}
static
void
gtk_box_destroy
(
GtkObject
*
object
)
{
GtkBox
*
box
;
GtkBoxChild
*
child
;
GList
*
children
;
g_return_if_fail
(
object
!=
NULL
);
g_return_if_fail
(
GTK_IS_BOX
(
object
));
box
=
GTK_BOX
(
object
);
children
=
box
->
children
;
while
(
children
)
{
child
=
children
->
data
;
children
=
children
->
next
;
child
->
widget
->
parent
=
NULL
;
gtk_object_unref
(
GTK_OBJECT
(
child
->
widget
));
gtk_widget_destroy
(
child
->
widget
);
g_free
(
child
);
}
g_list_free
(
box
->
children
);
if
(
GTK_OBJECT_CLASS
(
parent_class
)
->
destroy
)
(
*
GTK_OBJECT_CLASS
(
parent_class
)
->
destroy
)
(
object
);
}
static
void
gtk_box_map
(
GtkWidget
*
widget
)
{
...
...
gtk/gtkbutton.c
View file @
4af33fa2
...
...
@@ -48,7 +48,6 @@ static void gtk_button_init (GtkButton *button);
static
void
gtk_button_set_arg
(
GtkButton
*
button
,
GtkArg
*
arg
,
guint
arg_id
);
static
void
gtk_button_destroy
(
GtkObject
*
object
);
static
void
gtk_button_map
(
GtkWidget
*
widget
);
static
void
gtk_button_unmap
(
GtkWidget
*
widget
);
static
void
gtk_button_realize
(
GtkWidget
*
widget
);
...
...
@@ -170,8 +169,6 @@ gtk_button_class_init (GtkButtonClass *klass)
gtk_object_class_add_signals
(
object_class
,
button_signals
,
LAST_SIGNAL
);
object_class
->
destroy
=
gtk_button_destroy
;
widget_class
->
activate_signal
=
button_signals
[
CLICKED
];
widget_class
->
map
=
gtk_button_map
;
widget_class
->
unmap
=
gtk_button_unmap
;
...
...
@@ -223,7 +220,10 @@ gtk_button_set_arg (GtkButton *button,
gtk_container_disable_resize
(
GTK_CONTAINER
(
button
));
if
(
button
->
child
)
gtk_widget_destroy
(
button
->
child
);
{
gtk_widget_unparent
(
button
->
child
);
button
->
child
=
NULL
;
}
label
=
gtk_label_new
(
GTK_VALUE_STRING
(
*
arg
));
gtk_widget_show
(
label
);
...
...
@@ -289,27 +289,6 @@ gtk_button_leave (GtkButton *button)
gtk_signal_emit
(
GTK_OBJECT
(
button
),
button_signals
[
LEAVE
]);
}
static
void
gtk_button_destroy
(
GtkObject
*
object
)
{
GtkButton
*
button
;
g_return_if_fail
(
object
!=
NULL
);
g_return_if_fail
(
GTK_IS_BUTTON
(
object
));
button
=
GTK_BUTTON
(
object
);
if
(
button
->
child
)
{
button
->
child
->
parent
=
NULL
;
gtk_object_unref
(
GTK_OBJECT
(
button
->
child
));
gtk_widget_destroy
(
button
->
child
);
}
if
(
GTK_OBJECT_CLASS
(
parent_class
)
->
destroy
)
(
*
GTK_OBJECT_CLASS
(
parent_class
)
->
destroy
)
(
object
);
}
static
void
gtk_button_map
(
GtkWidget
*
widget
)
{
...
...
gtk/gtkcolorsel.c
View file @
4af33fa2
...
...
@@ -109,7 +109,7 @@ static void gtk_color_selection_rgb_updater (GtkWidget *widget,
static
void
gtk_color_selection_opacity_updater
(
GtkWidget
*
widget
,
gpointer
data
);
static
void
gtk_color_selection_realize
(
GtkWidget
*
widget
);
static
void
gtk_color_selection_
destroy
(
GtkObject
*
object
);
static
void
gtk_color_selection_
finalize
(
GtkObject
*
object
);
static
void
gtk_color_selection_color_changed
(
GtkColorSelection
*
colorsel
);
static
void
gtk_color_selection_update_input
(
GtkWidget
*
scale
,
GtkWidget
*
entry
,
...
...
@@ -159,8 +159,6 @@ static void gtk_color_selection_hsv_to_rgb (gdouble h, gdouble s, gdoub
static
void
gtk_color_selection_rgb_to_hsv
(
gdouble
r
,
gdouble
g
,
gdouble
b
,
gdouble
*
h
,
gdouble
*
s
,
gdouble
*
v
);
static
void
gtk_color_selection_dialog_destroy
(
GtkObject
*
object
);
static
GtkVBoxClass
*
color_selection_parent_class
=
NULL
;
static
GtkWindowClass
*
color_selection_dialog_parent_class
=
NULL
;
...
...
@@ -229,7 +227,7 @@ gtk_color_selection_class_init (GtkColorSelectionClass *klass)
gtk_object_class_add_signals
(
object_class
,
color_selection_signals
,
LAST_SIGNAL
);
object_class
->
destroy
=
gtk_color_selection_destroy
;
object_class
->
finalize
=
gtk_color_selection_finalize
;
widget_class
->
realize
=
gtk_color_selection_realize
;
}
...
...
@@ -515,7 +513,7 @@ gtk_color_selection_realize (GtkWidget *widget)
}
static
void
gtk_color_selection_
destroy
(
GtkObject
*
object
)
gtk_color_selection_
finalize
(
GtkObject
*
object
)
{
GtkColorSelection
*
colorsel
;
...
...
@@ -531,8 +529,7 @@ gtk_color_selection_destroy (GtkObject *object)
if
(
colorsel
->
sample_buf
!=
NULL
)
g_free
(
colorsel
->
sample_buf
);
if
(
GTK_OBJECT_CLASS
(
color_selection_parent_class
)
->
destroy
)
(
*
GTK_OBJECT_CLASS
(
color_selection_parent_class
)
->
destroy
)
(
object
);
(
*
GTK_OBJECT_CLASS
(
color_selection_parent_class
)
->
finalize
)
(
object
);
}
static
void
...
...
@@ -1423,8 +1420,6 @@ gtk_color_selection_dialog_class_init (GtkColorSelectionDialogClass *klass)
object_class
=
(
GtkObjectClass
*
)
klass
;
color_selection_dialog_parent_class
=
gtk_type_class
(
gtk_window_get_type
());
object_class
->
destroy
=
gtk_color_selection_dialog_destroy
;
}
static
void
...
...
@@ -1477,18 +1472,3 @@ gtk_color_selection_dialog_new (const gchar *title)
return
GTK_WIDGET
(
colorseldiag
);
}
static
void
gtk_color_selection_dialog_destroy
(
GtkObject
*
object
)
{
GtkColorSelectionDialog
*
colorseldiag
;
g_return_if_fail
(
object
!=
NULL
);
g_return_if_fail
(
GTK_IS_COLOR_SELECTION_DIALOG
(
object
));
colorseldiag
=
GTK_COLOR_SELECTION_DIALOG
(
object
);
if
(
GTK_OBJECT_CLASS
(
color_selection_dialog_parent_class
)
->
destroy
)
(
*
GTK_OBJECT_CLASS
(
color_selection_dialog_parent_class
)
->
destroy
)
(
object
);
}
gtk/gtkcontainer.c
View file @
4af33fa2
...
...
@@ -71,6 +71,7 @@ static void gtk_container_marshal_signal_4 (GtkObject *object,
static
void
gtk_container_class_init
(
GtkContainerClass
*
klass
);
static
void
gtk_container_init
(
GtkContainer
*
container
);
static
void
gtk_container_destroy
(
GtkObject
*
object
);
static
void
gtk_container_get_arg
(
GtkContainer
*
container
,
GtkArg
*
arg
,
guint
arg_id
);
...
...
@@ -101,6 +102,7 @@ static void gtk_container_hide_all (GtkWidget *widget);
static
gint
container_signals
[
LAST_SIGNAL
]
=
{
0
};
static
GtkWidgetClass
*
parent_class
=
NULL
;
guint
gtk_container_get_type
()
...
...
@@ -134,7 +136,8 @@ gtk_container_class_init (GtkContainerClass *class)
object_class
=
(
GtkObjectClass
*
)
class
;
widget_class
=
(
GtkWidgetClass
*
)
class
;
parent_class
=
gtk_type_class
(
gtk_widget_get_type
());
gtk_object_add_arg_type
(
"GtkContainer::border_width"
,
GTK_TYPE_LONG
,
ARG_BORDER_WIDTH
);
gtk_object_add_arg_type
(
"GtkContainer::auto_resize"
,
GTK_TYPE_BOOL
,
ARG_AUTO_RESIZE
);
gtk_object_add_arg_type
(
"GtkContainer::block_resize"
,
GTK_TYPE_BOOL
,
ARG_BLOCK_RESIZE
);
...
...
@@ -182,10 +185,12 @@ gtk_container_class_init (GtkContainerClass *class)
GTK_TYPE_DIRECTION_TYPE
);
gtk_object_class_add_signals
(
object_class
,
container_signals
,
LAST_SIGNAL
);
object_class
->
destroy
=
gtk_container_destroy
;
/* Other container classes should overwrite show_all and hide_all,
unless they make all their children accessable
through gtk_container_foreach.
* for the purpose of showing internal children also, which are not
* accessable
through gtk_container_foreach.
*/
widget_class
->
show_all
=
gtk_container_show_all
;
widget_class
->
hide_all
=
gtk_container_hide_all
;
...
...
@@ -202,6 +207,29 @@ gtk_container_init (GtkContainer *container)
container
->
auto_resize
=
TRUE
;
container
->
need_resize
=
FALSE
;
container
->
block_resize
=
FALSE
;
container
->
resize_widgets
=
NULL
;
}
static
void
gtk_container_destroy
(
GtkObject
*
object
)
{
GSList
*
node
;
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
);
}
g_slist_free
(
GTK_CONTAINER
(
object
)
->
resize_widgets
);
GTK_CONTAINER
(
object
)
->
resize_widgets
=
NULL
;
gtk_container_foreach
(
GTK_CONTAINER
(
object
),
(
GtkCallback
)
gtk_widget_destroy
,
NULL
);
if
(
GTK_OBJECT_CLASS
(
parent_class
)
->
destroy
)
(
*
GTK_OBJECT_CLASS
(
parent_class
)
->
destroy
)
(
object
);
}
static
void
...
...
@@ -330,7 +358,7 @@ gtk_container_unblock_resize (GtkContainer *container)
{
g_return_if_fail
(
container
!=
NULL
);
g_return_if_fail
(
GTK_IS_CONTAINER
(
container
));
container
->
block_resize
=
FALSE
;
}
...
...
@@ -338,12 +366,12 @@ gint
gtk_container_need_resize
(
GtkContainer
*
container
)
{
gint
return_val
;
g_return_val_if_fail
(
container
!=
NULL
,
FALSE
);
g_return_val_if_fail
(
GTK_IS_CONTAINER
(
container
),
FALSE
);
return_val
=
FALSE
;
if
(
!
container
->
block_resize
)
{
if
(
container
->
auto_resize
)
...
...
@@ -353,7 +381,7 @@ gtk_container_need_resize (GtkContainer *container)
else
container
->
need_resize
=
TRUE
;
}
return
return_val
;
}
...
...
@@ -367,12 +395,56 @@ gtk_container_foreach (GtkContainer *container,
callback
,
callback_data
);
}
typedef
struct
_GtkForeachData
GtkForeachData
;
struct
_GtkForeachData
{
GtkObject
*
container
;
GtkCallbackMarshal
callback
;
gpointer
callback_data
;
};
static
void
gtk_container_foreach_unmarshal
(
GtkWidget
*
child
,
gpointer
data
)
{
GtkForeachData
*
fdata
=
(
GtkForeachData
*
)
data
;
GtkArg
args
[
2
];
/* first argument */
args
[
0
].
name
=
NULL
;
args
[
0
].
type
=
GTK_OBJECT
(
child
)
->
klass
->
type
;
GTK_VALUE_OBJECT
(
args
[
0
])
=
GTK_OBJECT
(
child
);
/* location for return value */
args
[
1
].
name
=
NULL
;
args
[
1
].
type
=
GTK_TYPE_NONE
;
fdata
->
callback
(
fdata
->
container
,
fdata
->
callback_data
,
1
,
args
);
}
void
gtk_container_foreach_interp
(
GtkContainer
*
container
,
GtkCallbackMarshal
callback
,
gpointer
callback_data
,
GtkDestroyNotify
notify
)
{
GtkForeachData
fdata
;
fdata
.
container
=
GTK_OBJECT
(
container
);
fdata
.
callback
=
callback
;
fdata
.
callback_data
=
callback_data
;
gtk_container_foreach
(
container
,
gtk_container_foreach_unmarshal
,
&
fdata
);
notify
(
callback_data
);
}
gint
gtk_container_focus
(
GtkContainer
*
container
,
GtkDirectionType
direction
)
{
gint
return_val
;
gtk_signal_emit
(
GTK_OBJECT
(
container
),
container_signals
[
FOCUS
],
direction
,
&
return_val
);
...
...
gtk/gtkcontainer.h
View file @
4af33fa2
...
...
@@ -47,6 +47,11 @@ struct _GtkContainer
guint
auto_resize
:
1
;
guint
need_resize
:
1
;
guint
block_resize
:
1
;
/* The list of children that requested a resize
*/
GSList
*
resize_widgets
;
};
struct
_GtkContainerClass
...
...
@@ -82,6 +87,10 @@ 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
);
...
...
gtk/gtkcurve.c
View file @
4af33fa2
...
...
@@ -45,7 +45,7 @@ static gint curve_type_changed_signal = 0;
/* forward declarations: */
static
void
gtk_curve_class_init
(
GtkCurveClass
*
class
);
static
void
gtk_curve_init
(
GtkCurve
*
curve
);
static
void
gtk_curve_
destroy
(
GtkObject
*
object
);
static
void
gtk_curve_
finalize
(
GtkObject
*
object
);
guint
...
...
@@ -86,7 +86,7 @@ gtk_curve_class_init (GtkCurveClass *class)
gtk_signal_default_marshaller
,
GTK_TYPE_NONE
,
0
);
gtk_object_class_add_signals
(
object_class
,
&
curve_type_changed_signal
,
1
);
object_class
->
destroy
=
gtk_curve_destroy
;
object_class
->
finalize
=
gtk_curve_finalize
;
}
static
void
...
...
@@ -842,7 +842,7 @@ gtk_curve_new (void)
}
static
void
gtk_curve_
destroy
(
GtkObject
*
object
)
gtk_curve_
finalize
(
GtkObject
*
object
)
{
GtkCurve
*
curve
;
...
...
@@ -857,6 +857,5 @@ gtk_curve_destroy (GtkObject *object)
if
(
curve
->
ctlpoint
)
g_free
(
curve
->
ctlpoint
);
if
(
GTK_OBJECT_CLASS
(
parent_class
)
->
destroy
)
(
*
GTK_OBJECT_CLASS
(
parent_class
)
->
destroy
)
(
object
);
(
*
GTK_OBJECT_CLASS
(
parent_class
)
->
finalize
)
(
object
);
}
gtk/gtkentry.c
View file @
4af33fa2
...
...
@@ -64,7 +64,7 @@ static void gtk_entry_marshal_signal_2 (GtkObject *object,
static
void
gtk_entry_class_init
(
GtkEntryClass
*
klass
);
static
void
gtk_entry_init
(
GtkEntry
*
entry
);
static
void
gtk_entry_
destroy
(
GtkObject
*
object
);
static
void
gtk_entry_
finalize
(
GtkObject
*
object
);
static
void
gtk_entry_realize
(
GtkWidget
*
widget
);
static
void
gtk_entry_unrealize
(
GtkWidget
*
widget
);
static
void
gtk_entry_draw_focus
(
GtkWidget
*
widget
);
...
...
@@ -289,7 +289,7 @@ gtk_entry_class_init (GtkEntryClass *class)
gtk_object_class_add_signals
(
object_class
,
entry_signals
,
LAST_SIGNAL
);
object_class
->
destroy
=
gtk_entry_destroy
;
object_class
->
finalize
=
gtk_entry_finalize
;
widget_class
->
realize
=
gtk_entry_realize
;
widget_class
->
unrealize
=
gtk_entry_unrealize
;
...
...
@@ -521,7 +521,7 @@ gtk_entry_marshal_signal_2 (GtkObject *object,
}
static
void
gtk_entry_
destroy
(
GtkObject
*
object
)
gtk_entry_
finalize
(
GtkObject
*
object
)
{
GtkEntry
*
entry
;
...
...
@@ -548,8 +548,7 @@ gtk_entry_destroy (GtkObject *object)
if
(
entry
->
backing_pixmap
)
gdk_pixmap_unref
(
entry
->
backing_pixmap
);
if
(
GTK_OBJECT_CLASS
(
parent_class
)
->
destroy
)
(
*
GTK_OBJECT_CLASS
(
parent_class
)
->
destroy
)
(
object
);
(
*
GTK_OBJECT_CLASS
(
parent_class
)
->
finalize
)
(
object
);