summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
Diffstat (limited to 'gtk')
-rw-r--r--gtk/Makefile.am1
-rwxr-xr-xgtk/genmarshal.pl43
-rwxr-xr-xgtk/gtk.def2
-rw-r--r--gtk/gtkaccelgroup.c4
-rw-r--r--gtk/gtkaccellabel.c13
-rw-r--r--gtk/gtkadjustment.c4
-rw-r--r--gtk/gtkarg.c47
-rw-r--r--gtk/gtkargcollector.c31
-rw-r--r--gtk/gtkbindings.c4
-rw-r--r--gtk/gtkbutton.c30
-rw-r--r--gtk/gtkcalendar.c34
-rw-r--r--gtk/gtkcheckbutton.c28
-rw-r--r--gtk/gtkcheckmenuitem.c10
-rw-r--r--gtk/gtkclist.c2076
-rw-r--r--gtk/gtkcolorsel.c645
-rw-r--r--gtk/gtkcolorsel.h45
-rw-r--r--gtk/gtkcolorseldialog.c33
-rw-r--r--gtk/gtkcolorseldialog.h8
-rw-r--r--gtk/gtkcombo.c31
-rw-r--r--gtk/gtkcontainer.c58
-rw-r--r--gtk/gtkcontainer.h3
-rw-r--r--gtk/gtkctree.c1479
-rw-r--r--gtk/gtkcurve.c16
-rw-r--r--gtk/gtkdata.c2
-rw-r--r--gtk/gtkeditable.c44
-rw-r--r--gtk/gtkentry.c11
-rw-r--r--gtk/gtkfilesel.c34
-rw-r--r--gtk/gtkframe.c11
-rw-r--r--gtk/gtkhandlebox.c4
-rw-r--r--gtk/gtkhscale.c6
-rw-r--r--gtk/gtkhscrollbar.c4
-rw-r--r--gtk/gtkhsv.c2243
-rw-r--r--gtk/gtkhsv.h83
-rw-r--r--gtk/gtkinputdialog.c16
-rw-r--r--gtk/gtkitem.c6
-rw-r--r--gtk/gtkitemfactory.c20
-rw-r--r--gtk/gtklabel.c33
-rw-r--r--gtk/gtklayout.c29
-rw-r--r--gtk/gtklist.c17
-rw-r--r--gtk/gtklistitem.c20
-rw-r--r--gtk/gtkmain.c2
-rw-r--r--gtk/gtkmarshal.list2
-rw-r--r--gtk/gtkmarshalers.list2
-rw-r--r--gtk/gtkmenu.c44
-rw-r--r--gtk/gtkmenu.h1
-rw-r--r--gtk/gtkmenuitem.c24
-rw-r--r--gtk/gtkmenushell.c23
-rw-r--r--gtk/gtknotebook.c2
-rw-r--r--gtk/gtkobject.c313
-rw-r--r--gtk/gtkobject.h76
-rw-r--r--gtk/gtkpixmap.c11
-rw-r--r--gtk/gtkplug.c18
-rw-r--r--gtk/gtkpreview.c11
-rw-r--r--gtk/gtkprogress.c84
-rw-r--r--gtk/gtkprogressbar.c2
-rw-r--r--gtk/gtkradiobutton.c10
-rw-r--r--gtk/gtkrange.c80
-rw-r--r--gtk/gtkruler.c8
-rw-r--r--gtk/gtkscale.c6
-rw-r--r--gtk/gtkscrolledwindow.c50
-rw-r--r--gtk/gtksignal.c21
-rw-r--r--gtk/gtksocket.c18
-rw-r--r--gtk/gtkspinbutton.c70
-rw-r--r--gtk/gtkstatusbar.c47
-rw-r--r--gtk/gtktable.c39
-rw-r--r--gtk/gtktext.c82
-rw-r--r--gtk/gtktipsquery.c8
-rw-r--r--gtk/gtktogglebutton.c2
-rw-r--r--gtk/gtktoolbar.c15
-rw-r--r--gtk/gtktree.c6
-rw-r--r--gtk/gtktreeitem.c4
-rw-r--r--gtk/gtktypeutils.c1074
-rw-r--r--gtk/gtktypeutils.h328
-rw-r--r--gtk/gtkviewport.c85
-rw-r--r--gtk/gtkvscale.c6
-rw-r--r--gtk/gtkvscrollbar.c4
-rw-r--r--gtk/gtkwidget.c301
-rw-r--r--gtk/gtkwidget.h2
-rw-r--r--gtk/gtkwindow.c68
-rw-r--r--gtk/gtkwindow.h3
-rw-r--r--gtk/maketypes.awk2
-rw-r--r--gtk/testdnd.c6
-rw-r--r--gtk/testgtk.c25
83 files changed, 4618 insertions, 5595 deletions
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index 6c2a2d6adf..278825aebd 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -92,6 +92,7 @@ gtk_public_h_sources = @STRIP_BEGIN@ \
gtkhscale.h \
gtkhscrollbar.h \
gtkhseparator.h \
+ gtkhsv.h \
gtkimage.h \
gtkinputdialog.h \
gtkinvisible.h \
diff --git a/gtk/genmarshal.pl b/gtk/genmarshal.pl
index 067afd3fb2..cfde7948b7 100755
--- a/gtk/genmarshal.pl
+++ b/gtk/genmarshal.pl
@@ -13,11 +13,7 @@
"OBJECT"=>"gpointer",
# complex types. These need special handling.
- "FOREIGN"=>"FOREIGN",
- "C_CALLBACK"=>"C_CALLBACK",
- "SIGNAL"=>"SIGNAL",
- "ARGS"=>"ARGS",
- "CALLBACK"=>"CALLBACK"
+ "SIGNAL"=>"SIGNAL"
);
if ($#ARGV != 2) {
@@ -106,24 +102,7 @@ EOT
print OS "typedef $trans{$retval} (*GtkSignal_$funcname) (GtkObject *object, \n";
$argn = 1;
for (@params) {
- if($_ eq "C_CALLBACK") {
- print OS "gpointer arg".$argn."a,\n";
- print OS "gpointer arg".$argn."b,\n";
- $argn++;
- } elsif($_ eq "SIGNAL") {
- print OS "gpointer arg".$argn."a,\n";
- print OS "gpointer arg".$argn."b,\n";
- $argn++;
- } elsif($_ eq "ARGS") {
- print OS "gpointer arg".$argn."a,\n";
- print OS "gpointer arg".$argn."b,\n";
- $argn++;
- } elsif($_ eq "CALLBACK") {
- print OS "gpointer arg".$argn."a,\n";
- print OS "gpointer arg".$argn."b,\n";
- print OS "gpointer arg".$argn."c,\n";
- $argn++;
- } elsif($_ eq "FOREIGN") {
+ if($_ eq "SIGNAL") {
print OS "gpointer arg".$argn."a,\n";
print OS "gpointer arg".$argn."b,\n";
$argn++;
@@ -153,27 +132,11 @@ EOT
print OS " (* rfunc) (object,\n";
for($i = 0; $i < (scalar @params); $i++) {
- if($params[$i] eq "C_CALLBACK") {
- print OS <<EOT;
-GTK_VALUE_C_CALLBACK(args[$i]).func,
-GTK_VALUE_C_CALLBACK(args[$i]).func_data,
-EOT
- } elsif ($params[$i] eq "SIGNAL") {
+ if ($params[$i] eq "SIGNAL") {
print OS <<EOT;
GTK_VALUE_SIGNAL(args[$i]).f,
GTK_VALUE_SIGNAL(args[$i]).d,
EOT
- } elsif ($params[$i] eq "CALLBACK") {
- print OS <<EOT;
-GTK_VALUE_CALLBACK(args[$i]).marshal,
-GTK_VALUE_CALLBACK(args[$i]).data,
-GTK_VALUE_CALLBACK(args[$i]).notify,
-EOT
- } elsif ($params[$i] eq "FOREIGN") {
- print OS <<EOT;
-GTK_VALUE_FOREIGN(args[$i]).data,
-GTK_VALUE_FOREIGN(args[$i]).notify,
-EOT
} elsif ($params[$i] eq "NONE") {
} else {
print OS " GTK_VALUE_$params[$i](args[$i]),\n";
diff --git a/gtk/gtk.def b/gtk/gtk.def
index 5cc80d511f..40be976e44 100755
--- a/gtk/gtk.def
+++ b/gtk/gtk.def
@@ -685,8 +685,6 @@ EXPORTS
gtk_marshal_INT__POINTER
gtk_marshal_INT__POINTER_CHAR_CHAR
gtk_marshal_NONE__BOOL
- gtk_marshal_NONE__C_CALLBACK
- gtk_marshal_NONE__C_CALLBACK_C_CALLBACK
gtk_marshal_NONE__INT
gtk_marshal_NONE__INT_FLOAT
gtk_marshal_NONE__INT_FLOAT_BOOL
diff --git a/gtk/gtkaccelgroup.c b/gtk/gtkaccelgroup.c
index ddf6510a66..04dbfd0d60 100644
--- a/gtk/gtkaccelgroup.c
+++ b/gtk/gtkaccelgroup.c
@@ -656,7 +656,7 @@ gtk_accel_group_create_add (GtkType class_type,
GtkSignalRunType signal_flags,
guint handler_offset)
{
- g_return_val_if_fail (gtk_type_is_a (class_type, GTK_TYPE_OBJECT), 0);
+ g_return_val_if_fail (GTK_TYPE_IS_OBJECT (class_type), 0);
return gtk_signal_new ("add-accelerator",
signal_flags,
@@ -676,7 +676,7 @@ gtk_accel_group_create_remove (GtkType class_type,
GtkSignalRunType signal_flags,
guint handler_offset)
{
- g_return_val_if_fail (gtk_type_is_a (class_type, GTK_TYPE_OBJECT), 0);
+ g_return_val_if_fail (GTK_TYPE_IS_OBJECT (class_type), 0);
return gtk_signal_new ("remove-accelerator",
signal_flags,
diff --git a/gtk/gtkaccellabel.c b/gtk/gtkaccellabel.c
index 6861c29875..665396aa21 100644
--- a/gtk/gtkaccellabel.c
+++ b/gtk/gtkaccellabel.c
@@ -48,7 +48,7 @@ static void gtk_accel_label_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void gtk_accel_label_destroy (GtkObject *object);
-static void gtk_accel_label_finalize (GtkObject *object);
+static void gtk_accel_label_finalize (GObject *object);
static void gtk_accel_label_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static gint gtk_accel_label_expose_event (GtkWidget *widget,
@@ -87,6 +87,7 @@ gtk_accel_label_get_type (void)
static void
gtk_accel_label_class_init (GtkAccelLabelClass *class)
{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (class);
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
GtkMiscClass *misc_class;
@@ -102,10 +103,11 @@ gtk_accel_label_class_init (GtkAccelLabelClass *class)
gtk_object_add_arg_type ("GtkAccelLabel::accel_widget", GTK_TYPE_WIDGET, GTK_ARG_READWRITE, ARG_ACCEL_WIDGET);
+ gobject_class->finalize = gtk_accel_label_finalize;
+
object_class->set_arg = gtk_accel_label_set_arg;
object_class->get_arg = gtk_accel_label_get_arg;
object_class->destroy = gtk_accel_label_destroy;
- object_class->finalize = gtk_accel_label_finalize;
widget_class->size_request = gtk_accel_label_size_request;
widget_class->expose_event = gtk_accel_label_expose_event;
@@ -200,18 +202,17 @@ gtk_accel_label_destroy (GtkObject *object)
}
static void
-gtk_accel_label_finalize (GtkObject *object)
+gtk_accel_label_finalize (GObject *object)
{
GtkAccelLabel *accel_label;
- g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_ACCEL_LABEL (object));
accel_label = GTK_ACCEL_LABEL (object);
g_free (accel_label->accel_string);
- GTK_OBJECT_CLASS (parent_class)->finalize (object);
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
guint
@@ -376,7 +377,7 @@ gtk_accel_label_refetch (GtkAccelLabel *accel_label)
g_return_val_if_fail (accel_label != NULL, FALSE);
g_return_val_if_fail (GTK_IS_ACCEL_LABEL (accel_label), FALSE);
- class = GTK_ACCEL_LABEL_CLASS (GTK_OBJECT (accel_label)->klass);
+ class = GTK_ACCEL_LABEL_GET_CLASS (accel_label);
g_free (accel_label->accel_string);
accel_label->accel_string = NULL;
diff --git a/gtk/gtkadjustment.c b/gtk/gtkadjustment.c
index 31173ae0e3..d33f32897d 100644
--- a/gtk/gtkadjustment.c
+++ b/gtk/gtkadjustment.c
@@ -77,14 +77,14 @@ gtk_adjustment_class_init (GtkAdjustmentClass *class)
adjustment_signals[CHANGED] =
gtk_signal_new ("changed",
GTK_RUN_FIRST | GTK_RUN_NO_RECURSE,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkAdjustmentClass, changed),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
adjustment_signals[VALUE_CHANGED] =
gtk_signal_new ("value_changed",
GTK_RUN_FIRST | GTK_RUN_NO_RECURSE,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkAdjustmentClass, value_changed),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
diff --git a/gtk/gtkarg.c b/gtk/gtkarg.c
index bdd7003c09..105df1626d 100644
--- a/gtk/gtkarg.c
+++ b/gtk/gtkarg.c
@@ -65,7 +65,7 @@ gtk_arg_type_new_static (GtkType base_class_type,
gchar *p;
g_return_val_if_fail (arg_name != NULL, NULL);
- g_return_val_if_fail (GTK_FUNDAMENTAL_TYPE (base_class_type) == GTK_TYPE_OBJECT, NULL);
+ g_return_val_if_fail (GTK_TYPE_IS_OBJECT (base_class_type), NULL);
g_return_val_if_fail (class_n_args_offset != 0, NULL);
g_return_val_if_fail (arg_info_hash_table != NULL, NULL);
g_return_val_if_fail (arg_type > GTK_TYPE_NONE, NULL);
@@ -214,7 +214,7 @@ gtk_arg_get_info (GtkType object_type,
else
{
otype = object_type;
- while (!*info_p && GTK_FUNDAMENTAL_TYPE (otype) == GTK_TYPE_OBJECT)
+ while (!*info_p && GTK_TYPE_IS_OBJECT (otype))
{
GtkArgInfo info;
@@ -440,12 +440,6 @@ gtk_arg_reset (GtkArg *arg)
g_return_if_fail (arg != NULL);
fundamental_type = GTK_FUNDAMENTAL_TYPE (arg->type);
- if (fundamental_type > GTK_TYPE_FUNDAMENTAL_LAST)
- {
- fundamental_type = gtk_type_get_varargs_type (fundamental_type);
- if (!fundamental_type)
- fundamental_type = GTK_FUNDAMENTAL_TYPE (arg->type);
- }
if (fundamental_type == GTK_TYPE_STRING)
{
@@ -503,12 +497,6 @@ gtk_arg_values_equal (const GtkArg *arg1,
GTK_FUNDAMENTAL_TYPE (arg2->type), FALSE);
fundamental_type = GTK_FUNDAMENTAL_TYPE (arg1->type);
- if (fundamental_type > GTK_TYPE_FUNDAMENTAL_LAST)
- {
- fundamental_type = gtk_type_get_varargs_type (fundamental_type);
- if (!fundamental_type)
- fundamental_type = GTK_FUNDAMENTAL_TYPE (arg1->type);
- }
switch (fundamental_type)
{
@@ -555,20 +543,7 @@ gtk_arg_values_equal (const GtkArg *arg1,
case GTK_TYPE_BOXED:
equal = GTK_VALUE_BOXED (*arg1) == GTK_VALUE_BOXED (*arg2);
break;
- case GTK_TYPE_FOREIGN:
- equal = (GTK_VALUE_FOREIGN (*arg1).data == GTK_VALUE_FOREIGN (*arg2).data &&
- GTK_VALUE_FOREIGN (*arg1).notify == GTK_VALUE_FOREIGN (*arg2).notify);
- break;
- case GTK_TYPE_CALLBACK:
- equal = (GTK_VALUE_CALLBACK (*arg1).marshal == GTK_VALUE_CALLBACK (*arg2).marshal &&
- GTK_VALUE_CALLBACK (*arg1).data == GTK_VALUE_CALLBACK (*arg2).data &&
- GTK_VALUE_CALLBACK (*arg1).notify == GTK_VALUE_CALLBACK (*arg2).notify);
- break;
- case GTK_TYPE_ARGS:
- equal = (GTK_VALUE_ARGS (*arg1).n_args == GTK_VALUE_ARGS (*arg2).n_args &&
- GTK_VALUE_ARGS (*arg1).args == GTK_VALUE_ARGS (*arg2).args);
- break;
- case GTK_TYPE_OBJECT:
+ case G_TYPE_OBJECT:
equal = GTK_VALUE_OBJECT (*arg1) == GTK_VALUE_OBJECT (*arg2);
break;
case GTK_TYPE_POINTER:
@@ -578,10 +553,6 @@ gtk_arg_values_equal (const GtkArg *arg1,
equal = (GTK_VALUE_SIGNAL (*arg1).f == GTK_VALUE_SIGNAL (*arg2).f &&
GTK_VALUE_SIGNAL (*arg1).d == GTK_VALUE_SIGNAL (*arg2).d);
break;
- case GTK_TYPE_C_CALLBACK:
- equal = (GTK_VALUE_C_CALLBACK (*arg1).func == GTK_VALUE_C_CALLBACK (*arg2).func &&
- GTK_VALUE_C_CALLBACK (*arg1).func_data == GTK_VALUE_C_CALLBACK (*arg2).func_data);
- break;
default:
g_warning ("gtk_arg_values_equal() used with unknown type `%s'", gtk_type_name (arg1->type));
equal = FALSE;
@@ -601,12 +572,6 @@ gtk_arg_to_valueloc (GtkArg *arg,
g_return_if_fail (value_pointer != NULL);
fundamental_type = GTK_FUNDAMENTAL_TYPE (arg->type);
- if (fundamental_type > GTK_TYPE_FUNDAMENTAL_LAST)
- {
- fundamental_type = gtk_type_get_varargs_type (fundamental_type);
- if (!fundamental_type)
- fundamental_type = GTK_FUNDAMENTAL_TYPE (arg->type);
- }
switch (fundamental_type)
{
@@ -661,15 +626,11 @@ gtk_arg_to_valueloc (GtkArg *arg,
case GTK_TYPE_STRING:
case GTK_TYPE_POINTER:
case GTK_TYPE_BOXED:
- case GTK_TYPE_OBJECT:
+ case G_TYPE_OBJECT:
p_pointer = value_pointer;
*p_pointer = GTK_VALUE_POINTER (*arg);
break;
case GTK_TYPE_SIGNAL:
- case GTK_TYPE_ARGS:
- case GTK_TYPE_FOREIGN:
- case GTK_TYPE_CALLBACK:
- case GTK_TYPE_C_CALLBACK:
case GTK_TYPE_NONE:
case GTK_TYPE_INVALID:
/* it doesn't make much sense to retrive these values,
diff --git a/gtk/gtkargcollector.c b/gtk/gtkargcollector.c
index e92316d6c3..4ec3d6ad5c 100644
--- a/gtk/gtkargcollector.c
+++ b/gtk/gtkargcollector.c
@@ -38,13 +38,7 @@ G_STMT_START { \
GtkType fundamental_type; \
\
fundamental_type = GTK_FUNDAMENTAL_TYPE (arg->type); \
- if (fundamental_type > GTK_TYPE_FUNDAMENTAL_LAST) \
- { \
- fundamental_type = gtk_type_get_varargs_type (fundamental_type); \
- if (!fundamental_type) \
- fundamental_type = GTK_FUNDAMENTAL_TYPE (arg->type); \
- } \
- \
+ \
error_msg = NULL; \
switch (fundamental_type) \
{ \
@@ -124,42 +118,25 @@ G_STMT_START { \
GTK_VALUE_SIGNAL (*arg).f = va_arg (var_args, GtkSignalFunc); \
GTK_VALUE_SIGNAL (*arg).d = va_arg (var_args, gpointer); \
break; \
- case GTK_TYPE_ARGS: \
- GTK_VALUE_ARGS (*arg).n_args = va_arg (var_args, gint); \
- GTK_VALUE_ARGS (*arg).args = va_arg (var_args, GtkArg*); \
- break; \
- case GTK_TYPE_FOREIGN: \
- GTK_VALUE_FOREIGN (*arg).data = va_arg (var_args, gpointer); \
- GTK_VALUE_FOREIGN (*arg).notify = va_arg (var_args, GtkDestroyNotify); \
- break; \
- case GTK_TYPE_CALLBACK: \
- GTK_VALUE_CALLBACK (*arg).marshal = va_arg (var_args, GtkCallbackMarshal); \
- GTK_VALUE_CALLBACK (*arg).data = va_arg (var_args, gpointer); \
- GTK_VALUE_CALLBACK (*arg).notify = va_arg (var_args, GtkDestroyNotify); \
- break; \
- case GTK_TYPE_C_CALLBACK: \
- GTK_VALUE_C_CALLBACK (*arg).func = va_arg (var_args, GtkFunction); \
- GTK_VALUE_C_CALLBACK (*arg).func_data = va_arg (var_args, gpointer); \
- break; \
\
/* we do some extra sanity checking when collecting objects, \
* i.e. if the object pointer is not NULL, we check whether we \
* actually got an object pointer within the desired class branch. \
*/ \
- case GTK_TYPE_OBJECT: \
+ case G_TYPE_OBJECT: \
GTK_VALUE_OBJECT (*arg) = va_arg (var_args, GtkObject*); \
if (GTK_VALUE_OBJECT (*arg) != NULL) \
{ \
register GtkObject *object = GTK_VALUE_OBJECT (*arg); \
\
- if (object->klass == NULL) \
+ if (((GTypeInstance*) object)->g_class == NULL) \
error_msg = g_strconcat ("invalid unclassed object pointer for argument type `", \
gtk_type_name (arg->type), \
"'", \
NULL); \
else if (!gtk_type_is_a (GTK_OBJECT_TYPE (object), arg->type)) \
error_msg = g_strconcat ("invalid object `", \
- gtk_type_name (GTK_OBJECT_TYPE (object)), \
+ gtk_type_name (G_OBJECT_TYPE (object)), \
"' for argument type `", \
gtk_type_name (arg->type), \
"'", \
diff --git a/gtk/gtkbindings.c b/gtk/gtkbindings.c
index 13d7dfb4c3..09a151e520 100644
--- a/gtk/gtkbindings.c
+++ b/gtk/gtkbindings.c
@@ -458,10 +458,10 @@ gtk_binding_set_by_class (gpointer object_class)
if (binding_set)
return binding_set;
- binding_set = gtk_binding_set_new (gtk_type_name (class->type));
+ binding_set = gtk_binding_set_new (gtk_type_name (GTK_CLASS_TYPE (class)));
gtk_binding_set_add_path (binding_set,
GTK_PATH_CLASS,
- gtk_type_name (class->type),
+ gtk_type_name (GTK_CLASS_TYPE (class)),
GTK_PATH_PRIO_GTK);
g_dataset_id_set_data (class, key_id_class_binding_set, binding_set);
diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c
index 1e5a36208c..3f0e4ff620 100644
--- a/gtk/gtkbutton.c
+++ b/gtk/gtkbutton.c
@@ -108,20 +108,20 @@ gtk_button_get_type (void)
if (!button_type)
{
- static const GtkTypeInfo button_info =
+ static const GTypeInfo button_info =
{
- "GtkButton",
- sizeof (GtkButton),
sizeof (GtkButtonClass),
- (GtkClassInitFunc) gtk_button_class_init,
- (GtkObjectInitFunc) gtk_button_init,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) gtk_button_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (GtkButton),
+ 16, /* n_preallocs */
+ (GInstanceInitFunc) gtk_button_init,
};
- button_type = gtk_type_unique (GTK_TYPE_BIN, &button_info);
- gtk_type_set_chunk_alloc (button_type, 16);
+ button_type = g_type_register_static (GTK_TYPE_BIN, "GtkButton", &button_info);
}
return button_type;
@@ -146,35 +146,35 @@ gtk_button_class_init (GtkButtonClass *klass)
button_signals[PRESSED] =
gtk_signal_new ("pressed",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkButtonClass, pressed),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
button_signals[RELEASED] =
gtk_signal_new ("released",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkButtonClass, released),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
button_signals[CLICKED] =
gtk_signal_new ("clicked",
GTK_RUN_FIRST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkButtonClass, clicked),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
button_signals[ENTER] =
gtk_signal_new ("enter",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkButtonClass, enter),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
button_signals[LEAVE] =
gtk_signal_new ("leave",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkButtonClass, leave),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
diff --git a/gtk/gtkcalendar.c b/gtk/gtkcalendar.c
index 96cad9e032..1f220bda4d 100644
--- a/gtk/gtkcalendar.c
+++ b/gtk/gtkcalendar.c
@@ -324,18 +324,20 @@ gtk_calendar_get_type (void)
if (!calendar_type)
{
- static const GtkTypeInfo calendar_info =
+ static const GTypeInfo calendar_info =
{
- "GtkCalendar",
- sizeof (GtkCalendar),
sizeof (GtkCalendarClass),
- (GtkClassInitFunc) gtk_calendar_class_init,
- (GtkObjectInitFunc) gtk_calendar_init,
- (GtkArgSetFunc) NULL,
- (GtkArgGetFunc) NULL,
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) gtk_calendar_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (GtkCalendar),
+ 16, /* n_preallocs */
+ (GInstanceInitFunc) gtk_calendar_init,
};
-
- calendar_type = gtk_type_unique (GTK_TYPE_WIDGET, &calendar_info);
+
+ calendar_type = g_type_register_static (GTK_TYPE_WIDGET, "GtkCalendar", &calendar_info);
}
return calendar_type;
@@ -371,37 +373,37 @@ gtk_calendar_class_init (GtkCalendarClass *class)
gtk_calendar_signals[MONTH_CHANGED_SIGNAL] =
gtk_signal_new ("month_changed",
- GTK_RUN_FIRST, object_class->type,
+ GTK_RUN_FIRST, GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkCalendarClass, month_changed),
gtk_signal_default_marshaller, GTK_TYPE_NONE, 0);
gtk_calendar_signals[DAY_SELECTED_SIGNAL] =
gtk_signal_new ("day_selected",
- GTK_RUN_FIRST, object_class->type,
+ GTK_RUN_FIRST, GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkCalendarClass, day_selected),
gtk_signal_default_marshaller, GTK_TYPE_NONE, 0);
gtk_calendar_signals[DAY_SELECTED_DOUBLE_CLICK_SIGNAL] =
gtk_signal_new ("day_selected_double_click",
- GTK_RUN_FIRST, object_class->type,
+ GTK_RUN_FIRST, GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkCalendarClass, day_selected_double_click),
gtk_signal_default_marshaller, GTK_TYPE_NONE, 0);
gtk_calendar_signals[PREV_MONTH_SIGNAL] =
gtk_signal_new ("prev_month",
- GTK_RUN_FIRST, object_class->type,
+ GTK_RUN_FIRST, GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkCalendarClass, prev_month),
gtk_signal_default_marshaller, GTK_TYPE_NONE, 0);
gtk_calendar_signals[NEXT_MONTH_SIGNAL] =
gtk_signal_new ("next_month",
- GTK_RUN_FIRST, object_class->type,
+ GTK_RUN_FIRST, GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkCalendarClass, next_month),
gtk_signal_default_marshaller, GTK_TYPE_NONE, 0);
gtk_calendar_signals[PREV_YEAR_SIGNAL] =
gtk_signal_new ("prev_year",
- GTK_RUN_FIRST, object_class->type,
+ GTK_RUN_FIRST, GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkCalendarClass, prev_year),
gtk_signal_default_marshaller, GTK_TYPE_NONE, 0);
gtk_calendar_signals[NEXT_YEAR_SIGNAL] =
gtk_signal_new ("next_year",
- GTK_RUN_FIRST, object_class->type,
+ GTK_RUN_FIRST, GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkCalendarClass, next_year),
gtk_signal_default_marshaller, GTK_TYPE_NONE, 0);
diff --git a/gtk/gtkcheckbutton.c b/gtk/gtkcheckbutton.c
index 19de8a8bfd..c9d88bc5f5 100644
--- a/gtk/gtkcheckbutton.c
+++ b/gtk/gtkcheckbutton.c
@@ -31,8 +31,6 @@
#define INDICATOR_SIZE 10
#define INDICATOR_SPACING 2
-#define CHECK_BUTTON_CLASS(w) GTK_CHECK_BUTTON_CLASS (GTK_OBJECT (w)->klass)
-
static void gtk_check_button_class_init (GtkCheckButtonClass *klass);
static void gtk_check_button_init (GtkCheckButton *check_button);
@@ -229,11 +227,11 @@ gtk_check_button_size_request (GtkWidget *widget,
if (toggle_button->draw_indicator)
{
- requisition->width += (CHECK_BUTTON_CLASS (widget)->indicator_size +
- CHECK_BUTTON_CLASS (widget)->indicator_spacing * 3 + 2);
+ requisition->width += (GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size +
+ GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_spacing * 3 + 2);
- temp = (CHECK_BUTTON_CLASS (widget)->indicator_size +
- CHECK_BUTTON_CLASS (widget)->indicator_spacing * 2);
+ temp = (GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size +
+ GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_spacing * 2);
requisition->height = MAX (requisition->height, temp) + 2;
}
}
@@ -267,15 +265,15 @@ gtk_check_button_size_allocate (GtkWidget *widget,
if (GTK_BIN (button)->child && GTK_WIDGET_VISIBLE (GTK_BIN (button)->child))
{
child_allocation.x = (GTK_CONTAINER (widget)->border_width +
- CHECK_BUTTON_CLASS (widget)->indicator_size +
- CHECK_BUTTON_CLASS (widget)->indicator_spacing * 3 + 1 +
+ GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size +
+ GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_spacing * 3 + 1 +
widget->allocation.x);
child_allocation.y = GTK_CONTAINER (widget)->border_width + 1 +
widget->allocation.y;
child_allocation.width = MAX (1, allocation->width -
(GTK_CONTAINER (widget)->border_width +
- CHECK_BUTTON_CLASS (widget)->indicator_size +
- CHECK_BUTTON_CLASS (widget)->indicator_spacing * 3 + 1) -
+ GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size +
+ GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_spacing * 3 + 1) -
GTK_CONTAINER (widget)->border_width - 1);
child_allocation.height = MAX (1, allocation->height - (GTK_CONTAINER (widget)->border_width + 1) * 2);
@@ -337,7 +335,7 @@ gtk_check_button_draw_indicator (GtkCheckButton *check_button,
g_return_if_fail (check_button != NULL);
g_return_if_fail (GTK_IS_CHECK_BUTTON (check_button));
- class = CHECK_BUTTON_CLASS (check_button);
+ class = GTK_CHECK_BUTTON_GET_CLASS (check_button);
if (class->draw_indicator)
(* class->draw_indicator) (check_button, area);
@@ -387,10 +385,10 @@ gtk_real_check_button_draw_indicator (GtkCheckButton *check_button,
new_area.width, new_area.height);
}
- x = widget->allocation.x + CHECK_BUTTON_CLASS (widget)->indicator_spacing + GTK_CONTAINER (widget)->border_width;
- y = widget->allocation.y + (widget->allocation.height - CHECK_BUTTON_CLASS (widget)->indicator_size) / 2;
- width = CHECK_BUTTON_CLASS (widget)->indicator_size;
- height = CHECK_BUTTON_CLASS (widget)->indicator_size;
+ x = widget->allocation.x + GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_spacing + GTK_CONTAINER (widget)->border_width;
+ y = widget->allocation.y + (widget->allocation.height - GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size) / 2;
+ width = GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size;
+ height = GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size;
if (GTK_TOGGLE_BUTTON (widget)->active)
{
diff --git a/gtk/gtkcheckmenuitem.c b/gtk/gtkcheckmenuitem.c
index 852a7ba0e2..d149fdbc09 100644
--- a/gtk/gtkcheckmenuitem.c
+++ b/gtk/gtkcheckmenuitem.c
@@ -29,8 +29,6 @@
#include "gtksignal.h"
-#define CHECK_MENU_ITEM_CLASS(w) GTK_CHECK_MENU_ITEM_CLASS (GTK_OBJECT (w)->klass)
-
enum {
TOGGLED,
@@ -106,7 +104,7 @@ gtk_check_menu_item_class_init (GtkCheckMenuItemClass *klass)
check_menu_item_signals[TOGGLED] =
gtk_signal_new ("toggled",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkCheckMenuItemClass, toggled),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
@@ -223,10 +221,10 @@ gtk_check_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item,
{
g_return_if_fail (check_menu_item != NULL);
g_return_if_fail (GTK_IS_CHECK_MENU_ITEM (check_menu_item));
- g_return_if_fail (CHECK_MENU_ITEM_CLASS (check_menu_item) != NULL);
+ g_return_if_fail (GTK_CHECK_MENU_ITEM_GET_CLASS (check_menu_item) != NULL);
- if (CHECK_MENU_ITEM_CLASS (check_menu_item)->draw_indicator)
- (* CHECK_MENU_ITEM_CLASS (check_menu_item)->draw_indicator) (check_menu_item, area);
+ if (GTK_CHECK_MENU_ITEM_GET_CLASS (check_menu_item)->draw_indicator)
+ (* GTK_CHECK_MENU_ITEM_GET_CLASS (check_menu_item)->draw_indicator) (check_menu_item, area);
}
static void
diff --git a/gtk/gtkclist.c b/gtk/gtkclist.c
index c01095a234..15c2499420 100644
--- a/gtk/gtkclist.c
+++ b/gtk/gtkclist.c
@@ -78,17 +78,17 @@ COLUMN_FROM_XPIXEL (GtkCList * clist,
gint x)
{
gint i, cx;
-
+
for (i = 0; i < clist->columns; i++)
if (clist->column[i].visible)
{
cx = clist->column[i].area.x + clist->hoffset;
-
+
if (x >= (cx - (COLUMN_INSET + CELL_SPACING)) &&
x <= (cx + clist->column[i].area.width + COLUMN_INSET))
return i;
}
-
+
/* no match */
return -1;
}
@@ -111,10 +111,10 @@ static inline gint
LIST_WIDTH (GtkCList * clist)
{
gint last_column;
-
+
for (last_column = clist->columns - 1;
last_column >= 0 && !clist->column[last_column].visible; last_column--);
-
+
if (last_column >= 0)
return (clist->column[last_column].area.x +
clist->column[last_column].area.width +
@@ -128,13 +128,11 @@ LIST_WIDTH (GtkCList * clist)
g_list_nth ((clist)->row_list, (row)))
-#define GTK_CLIST_CLASS_FW(_widget_) GTK_CLIST_CLASS (((GtkObject*) (_widget_))->klass)
-
/* redraw the list if it's not frozen */
#define CLIST_UNFROZEN(clist) (((GtkCList*) (clist))->freeze_count == 0)
#define CLIST_REFRESH(clist) G_STMT_START { \
if (CLIST_UNFROZEN (clist)) \
- GTK_CLIST_CLASS_FW (clist)->refresh ((GtkCList*) (clist)); \
+ GTK_CLIST_GET_CLASS (clist)->refresh ((GtkCList*) (clist)); \
} G_STMT_END
@@ -182,7 +180,7 @@ static void gtk_clist_init (GtkCList *clist);
/* GtkObject Methods */
static void gtk_clist_destroy (GtkObject *object);
-static void gtk_clist_finalize (GtkObject *object);
+static void gtk_clist_finalize (GObject *object);
static void gtk_clist_set_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
@@ -399,7 +397,7 @@ static void draw_drag_highlight (GtkCList *clist,
GtkCListRow *dest_row,
gint dest_row_number,
GtkCListDragPos drag_pos);
-
+
/* Size Allocation / Requisition */
static void size_allocate_title_buttons (GtkCList *clist);
static void size_allocate_columns (GtkCList *clist,
@@ -466,7 +464,7 @@ GtkType
gtk_clist_get_type (void)
{
static GtkType clist_type = 0;
-
+
if (!clist_type)
{
static const GtkTypeInfo clist_info =
@@ -480,27 +478,34 @@ gtk_clist_get_type (void)
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL,
};
-
+
clist_type = gtk_type_unique (GTK_TYPE_CONTAINER, &clist_info);
}
-
+
return clist_type;
}
static void
gtk_clist_class_init (GtkCListClass *klass)
{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
GtkContainerClass *container_class;
GtkBindingSet *binding_set;
-
+
object_class = (GtkObjectClass *) klass;
widget_class = (GtkWidgetClass *) klass;
container_class = (GtkContainerClass *) klass;
-
+
parent_class = gtk_type_class (GTK_TYPE_CONTAINER);
-
+
+ gobject_class->finalize = gtk_clist_finalize;
+
+ object_class->set_arg = gtk_clist_set_arg;
+ object_class->get_arg = gtk_clist_get_arg;
+ object_class->destroy = gtk_clist_destroy;
+
gtk_object_add_arg_type ("GtkCList::n_columns",
GTK_TYPE_UINT,
GTK_ARG_READWRITE | GTK_ARG_CONSTRUCT_ONLY,
@@ -533,24 +538,19 @@ gtk_clist_class_init (GtkCListClass *klass)
GTK_TYPE_SORT_TYPE,
GTK_ARG_READWRITE,
ARG_SORT_TYPE);
- object_class->set_arg = gtk_clist_set_arg;
- object_class->get_arg = gtk_clist_get_arg;
- object_class->destroy = gtk_clist_destroy;
- object_class->finalize = gtk_clist_finalize;
-
-
+
widget_class->set_scroll_adjustments_signal =
gtk_signal_new ("set_scroll_adjustments",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkCListClass, set_scroll_adjustments),
gtk_marshal_NONE__POINTER_POINTER,
GTK_TYPE_NONE, 2, GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT);
-
+
clist_signals[SELECT_ROW] =
gtk_signal_new ("select_row",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkCListClass, select_row),
gtk_marshal_NONE__INT_INT_POINTER,
GTK_TYPE_NONE, 3,
@@ -560,7 +560,7 @@ gtk_clist_class_init (GtkCListClass *klass)
clist_signals[UNSELECT_ROW] =
gtk_signal_new ("unselect_row",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkCListClass, unselect_row),
gtk_marshal_NONE__INT_INT_POINTER,
GTK_TYPE_NONE, 3, GTK_TYPE_INT,
@@ -568,78 +568,78 @@ gtk_clist_class_init (GtkCListClass *klass)
clist_signals[ROW_MOVE] =
gtk_signal_new ("row_move",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkCListClass, row_move),
gtk_marshal_NONE__INT_INT,
GTK_TYPE_NONE, 2, GTK_TYPE_INT, GTK_TYPE_INT);
clist_signals[CLICK_COLUMN] =
gtk_signal_new ("click_column",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkCListClass, click_column),
gtk_marshal_NONE__INT,
GTK_TYPE_NONE, 1, GTK_TYPE_INT);
clist_signals[RESIZE_COLUMN] =
gtk_signal_new ("resize_column",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkCListClass, resize_column),
gtk_marshal_NONE__INT_INT,
GTK_TYPE_NONE, 2, GTK_TYPE_INT, GTK_TYPE_INT);
-
+
clist_signals[TOGGLE_FOCUS_ROW] =
gtk_signal_new ("toggle_focus_row",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkCListClass, toggle_focus_row),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
clist_signals[SELECT_ALL] =
gtk_signal_new ("select_all",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkCListClass, select_all),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
clist_signals[UNSELECT_ALL] =
gtk_signal_new ("unselect_all",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkCListClass, unselect_all),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
clist_signals[UNDO_SELECTION] =
gtk_signal_new ("undo_selection",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkCListClass, undo_selection),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
clist_signals[START_SELECTION] =
gtk_signal_new ("start_selection",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkCListClass, start_selection),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
clist_signals[END_SELECTION] =
gtk_signal_new ("end_selection",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkCListClass, end_selection),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
clist_signals[TOGGLE_ADD_MODE] =
gtk_signal_new ("toggle_add_mode",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkCListClass, toggle_add_mode),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
clist_signals[EXTEND_SELECTION] =
gtk_signal_new ("extend_selection",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkCListClass, extend_selection),
gtk_marshal_NONE__ENUM_FLOAT_BOOL,
GTK_TYPE_NONE, 3,
@@ -647,26 +647,26 @@ gtk_clist_class_init (GtkCListClass *klass)
clist_signals[SCROLL_VERTICAL] =
gtk_signal_new ("scroll_vertical",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkCListClass, scroll_vertical),
gtk_marshal_NONE__ENUM_FLOAT,
GTK_TYPE_NONE, 2, GTK_TYPE_SCROLL_TYPE, GTK_TYPE_FLOAT);
clist_signals[SCROLL_HORIZONTAL] =
gtk_signal_new ("scroll_horizontal",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkCListClass, scroll_horizontal),
gtk_marshal_NONE__ENUM_FLOAT,
GTK_TYPE_NONE, 2, GTK_TYPE_SCROLL_TYPE, GTK_TYPE_FLOAT);
clist_signals[ABORT_COLUMN_RESIZE] =
gtk_signal_new ("abort_column_resize",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkCListClass, abort_column_resize),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
gtk_object_class_add_signals (object_class, clist_signals, LAST_SIGNAL);
-
+
widget_class->realize = gtk_clist_realize;
widget_class->unrealize = gtk_clist_unrealize;
widget_class->map = gtk_clist_map;
@@ -690,14 +690,14 @@ gtk_clist_class_init (GtkCListClass *klass)
widget_class->drag_drop = gtk_clist_drag_drop;
widget_class->drag_data_get = gtk_clist_drag_data_get;
widget_class->drag_data_received = gtk_clist_drag_data_received;
-
+
/* container_class->add = NULL; use the default GtkContainerClass warning */
/* container_class->remove=NULL; use the default GtkContainerClass warning */
-
+
container_class->forall = gtk_clist_forall;
container_class->focus = gtk_clist_focus;
container_class->set_focus_child = gtk_clist_set_focus_child;
-
+
klass->set_scroll_adjustments = gtk_clist_set_scroll_adjustments;
klass->refresh = clist_refresh;
klass->select_row = real_select_row;
@@ -727,7 +727,7 @@ gtk_clist_class_init (GtkCListClass *klass)
klass->abort_column_resize = abort_column_resize;
klass->set_cell_contents = set_cell_contents;
klass->cell_size_request = cell_size_request;
-
+
binding_set = gtk_binding_set_by_class (klass);
gtk_binding_entry_add_signal (binding_set, GDK_Up, 0,
"scroll_vertical", 2,
@@ -753,7 +753,7 @@ gtk_clist_class_init (GtkCListClass *klass)
"scroll_vertical", 2,
GTK_TYPE_ENUM, GTK_SCROLL_JUMP,
GTK_TYPE_FLOAT, 1.0);
-
+
gtk_binding_entry_add_signal (binding_set, GDK_Up, GDK_SHIFT_MASK,
"extend_selection", 3,
GTK_TYPE_ENUM, GTK_SCROLL_STEP_BACKWARD,
@@ -780,7 +780,7 @@ gtk_clist_class_init (GtkCListClass *klass)
"extend_selection", 3,
GTK_TYPE_ENUM, GTK_SCROLL_JUMP,
GTK_TYPE_FLOAT, 1.0, GTK_TYPE_BOOL, TRUE);
-
+
gtk_binding_entry_add_signal (binding_set, GDK_Left, 0,
"scroll_horizontal", 2,
GTK_TYPE_ENUM, GTK_SCROLL_STEP_BACKWARD,
@@ -797,7 +797,7 @@ gtk_clist_class_init (GtkCListClass *klass)
"scroll_horizontal", 2,
GTK_TYPE_ENUM, GTK_SCROLL_JUMP,
GTK_TYPE_FLOAT, 1.0);
-
+
gtk_binding_entry_add_signal (binding_set, GDK_Escape, 0,
"undo_selection", 0);
gtk_binding_entry_add_signal (binding_set, GDK_Escape, 0,
@@ -832,9 +832,9 @@ gtk_clist_set_arg (GtkObject *object,
guint arg_id)
{
GtkCList *clist;
-
+
clist = GTK_CLIST (object);
-
+
switch (arg_id)
{
case ARG_N_COLUMNS: /* construct-only arg, only set when !GTK_CONSTRUCTED */
@@ -873,13 +873,13 @@ gtk_clist_get_arg (GtkObject *object,
guint arg_id)
{
GtkCList *clist;
-
+
clist = GTK_CLIST (object);
-
+
switch (arg_id)
{
guint i;
-
+
case ARG_N_COLUMNS:
GTK_VALUE_UINT (*arg) = clist->columns;
break;
@@ -921,73 +921,73 @@ static void
gtk_clist_init (GtkCList *clist)
{
clist->flags = 0;
-
+
GTK_WIDGET_UNSET_FLAGS (clist, GTK_NO_WINDOW);
GTK_WIDGET_SET_FLAGS (clist, GTK_CAN_FOCUS);
GTK_CLIST_SET_FLAG (clist, CLIST_CHILD_HAS_FOCUS);
GTK_CLIST_SET_FLAG (clist, CLIST_DRAW_DRAG_LINE);
GTK_CLIST_SET_FLAG (clist, CLIST_USE_DRAG_ICONS);
-
+
clist->row_mem_chunk = NULL;
clist->cell_mem_chunk = NULL;
-
+
clist->freeze_count = 0;
-
+
clist->rows = 0;
clist->row_center_offset = 0;
clist->row_height = 0;
clist->row_list = NULL;
clist->row_list_end = NULL;
-
+
clist->columns = 0;
-
+
clist->title_window = NULL;
clist->column_title_area.x = 0;
clist->column_title_area.y = 0;
clist->column_title_area.width = 1;
clist->column_title_area.height = 1;
-
+
clist->clist_window = NULL;
clist->clist_window_width = 1;
clist->clist_window_height = 1;
-
+
clist->hoffset = 0;
clist->voffset = 0;
-
+
clist->shadow_type = GTK_SHADOW_IN;
clist->vadjustment = NULL;
clist->hadjustment = NULL;
-
+
clist->button_actions[0] = GTK_BUTTON_SELECTS | GTK_BUTTON_DRAGS;
clist->button_actions[1] = GTK_BUTTON_IGNORED;
clist->button_actions[2] = GTK_BUTTON_IGNORED;
clist->button_actions[3] = GTK_BUTTON_IGNORED;
clist->button_actions[4] = GTK_BUTTON_IGNORED;
-
+
clist->cursor_drag = NULL;
clist->xor_gc = NULL;
clist->fg_gc = NULL;
clist->bg_gc = NULL;
clist->x_drag = 0;
-
+
clist->selection_mode = GTK_SELECTION_SINGLE;
clist->selection = NULL;
clist->selection_end = NULL;
clist->undo_selection = NULL;
clist->undo_unselection = NULL;
-
+
clist->focus_row = -1;
clist->undo_anchor = -1;
-
+
clist->anchor = -1;
clist->anchor_state = GTK_STATE_SELECTED;
clist->drag_pos = -1;
clist->htimer = 0;
clist->vtimer = 0;
-
+
clist->click_cell.row = -1;
clist->click_cell.column = -1;
-
+
clist->compare = default_compare;
clist->sort_type = GTK_SORT_ASCENDING;
clist->sort_column = 0;
@@ -1003,10 +1003,10 @@ gtk_clist_construct (GtkCList *clist,
g_return_if_fail (GTK_IS_CLIST (clist));
g_return_if_fail (columns > 0);
g_return_if_fail (GTK_OBJECT_CONSTRUCTED (clist) == FALSE);
-
+
/* mark the object as constructed */
gtk_object_constructed (GTK_OBJECT (clist));
-
+
/* initalize memory chunks, if this has not been done by any
* possibly derived widget
*/
@@ -1016,23 +1016,23 @@ gtk_clist_construct (GtkCList *clist,
sizeof (GtkCListRow) *
CLIST_OPTIMUM_SIZE,
G_ALLOC_AND_FREE);
-
+
if (!clist->cell_mem_chunk)
clist->cell_mem_chunk = g_mem_chunk_new ("clist cell mem chunk",
sizeof (GtkCell) * columns,
sizeof (GtkCell) * columns *
CLIST_OPTIMUM_SIZE,
G_ALLOC_AND_FREE);
-
+
/* set number of columns, allocate memory */
clist->columns = columns;
clist->column = columns_new (clist);
-
+
/* there needs to be at least one column button
* because there is alot of code that will break if it
* isn't there*/
column_button_create (clist, 0);
-
+
if (titles)
{
guint i;
@@ -1064,16 +1064,16 @@ gtk_clist_new (gint columns)
{
return gtk_clist_new_with_titles (columns, NULL);
}
-
+
GtkWidget*
gtk_clist_new_with_titles (gint columns,
gchar *titles[])
{
GtkWidget *widget;
-
+
widget = gtk_type_new (GTK_TYPE_CLIST);
gtk_clist_construct (GTK_CLIST (widget), columns, titles);
-
+
return widget;
}
@@ -1082,7 +1082,7 @@ gtk_clist_set_hadjustment (GtkCList *clist,
GtkAdjustment *adjustment)
{
GtkAdjustment *old_adjustment;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
if (adjustment)
@@ -1092,20 +1092,20 @@ gtk_clist_set_hadjustment (GtkCList *clist,
return;
old_adjustment = clist->hadjustment;
-
+
if (clist->hadjustment)
{
gtk_signal_disconnect_by_data (GTK_OBJECT (clist->hadjustment), clist);
gtk_object_unref (GTK_OBJECT (clist->hadjustment));
}
-
+
clist->hadjustment = adjustment;
-
+
if (clist->hadjustment)
{
gtk_object_ref (GTK_OBJECT (clist->hadjustment));
gtk_object_sink (GTK_OBJECT (clist->hadjustment));
-
+
gtk_signal_connect (GTK_OBJECT (clist->hadjustment), "changed",
(GtkSignalFunc) hadjustment_changed,
(gpointer) clist);
@@ -1113,7 +1113,7 @@ gtk_clist_set_hadjustment (GtkCList *clist,
(GtkSignalFunc) hadjustment_value_changed,
(gpointer) clist);
}
-
+
if (!clist->hadjustment || !old_adjustment)
gtk_widget_queue_resize (GTK_WIDGET (clist));
}
@@ -1123,7 +1123,7 @@ gtk_clist_get_hadjustment (GtkCList *clist)
{
g_return_val_if_fail (clist != NULL, NULL);
g_return_val_if_fail (GTK_IS_CLIST (clist), NULL);
-
+
return clist->hadjustment;
}
@@ -1132,30 +1132,30 @@ gtk_clist_set_vadjustment (GtkCList *clist,
GtkAdjustment *adjustment)
{
GtkAdjustment *old_adjustment;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
if (adjustment)
g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
-
+
if (clist->vadjustment == adjustment)
return;
old_adjustment = clist->vadjustment;
-
+
if (clist->vadjustment)
{
gtk_signal_disconnect_by_data (GTK_OBJECT (clist->vadjustment), clist);
gtk_object_unref (GTK_OBJECT (clist->vadjustment));
}
-
+
clist->vadjustment = adjustment;
-
+
if (clist->vadjustment)
{
gtk_object_ref (GTK_OBJECT (clist->vadjustment));
gtk_object_sink (GTK_OBJECT (clist->vadjustment));
-
+
gtk_signal_connect (GTK_OBJECT (clist->vadjustment), "changed",
(GtkSignalFunc) vadjustment_changed,
(gpointer) clist);
@@ -1163,7 +1163,7 @@ gtk_clist_set_vadjustment (GtkCList *clist,
(GtkSignalFunc) vadjustment_value_changed,
(gpointer) clist);
}
-
+
if (!clist->vadjustment || !old_adjustment)
gtk_widget_queue_resize (GTK_WIDGET (clist));
}
@@ -1173,7 +1173,7 @@ gtk_clist_get_vadjustment (GtkCList *clist)
{
g_return_val_if_fail (clist != NULL, NULL);
g_return_val_if_fail (GTK_IS_CLIST (clist), NULL);
-
+
return clist->vadjustment;
}
@@ -1194,9 +1194,9 @@ gtk_clist_set_shadow_type (GtkCList *clist,
{
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
clist->shadow_type = type;
-
+
if (GTK_WIDGET_VISIBLE (clist))
gtk_widget_queue_resize (GTK_WIDGET (clist));
}
@@ -1207,21 +1207,21 @@ gtk_clist_set_selection_mode (GtkCList *clist,
{
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (mode == clist->selection_mode)
return;
-
+
clist->selection_mode = mode;
clist->anchor = -1;
clist->anchor_state = GTK_STATE_SELECTED;
clist->drag_pos = -1;
clist->undo_anchor = clist->focus_row;
-
+
g_list_free (clist->undo_selection);
g_list_free (clist->undo_unselection);
clist->undo_selection = NULL;
clist->undo_unselection = NULL;
-
+
switch (mode)
{
case GTK_SELECTION_MULTIPLE:
@@ -1239,7 +1239,7 @@ gtk_clist_freeze (GtkCList *clist)
{
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
clist->freeze_count++;
}
@@ -1248,7 +1248,7 @@ gtk_clist_thaw (GtkCList *clist)
{
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (clist->freeze_count)
{
clist->freeze_count--;
@@ -1280,7 +1280,7 @@ gtk_clist_column_titles_show (GtkCList *clist)
{
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (!GTK_CLIST_SHOW_TITLES(clist))
{
GTK_CLIST_SET_FLAG (clist, CLIST_SHOW_TITLES);
@@ -1295,7 +1295,7 @@ gtk_clist_column_titles_hide (GtkCList *clist)
{
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (GTK_CLIST_SHOW_TITLES(clist))
{
GTK_CLIST_UNSET_FLAG (clist, CLIST_SHOW_TITLES);
@@ -1311,18 +1311,18 @@ gtk_clist_column_title_active (GtkCList *clist,
{
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (column < 0 || column >= clist->columns)
return;
if (!clist->column[column].button || !clist->column[column].button_passive)
return;
-
+
clist->column[column].button_passive = FALSE;
-
+
gtk_signal_disconnect_by_func (GTK_OBJECT (clist->column[column].button),
(GtkSignalFunc) column_title_passive_func,
NULL);
-
+
GTK_WIDGET_SET_FLAGS (clist->column[column].button, GTK_CAN_FOCUS);
if (GTK_WIDGET_VISIBLE (clist))
gtk_widget_queue_draw (clist->column[column].button);
@@ -1333,27 +1333,27 @@ gtk_clist_column_title_passive (GtkCList *clist,
gint column)
{
GtkButton *button;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (column < 0 || column >= clist->columns)
return;
if (!clist->column[column].button || clist->column[column].button_passive)
return;
-
+
button = GTK_BUTTON (clist->column[column].button);
-
+
clist->column[column].button_passive = TRUE;
-
+
if (button->button_down)
gtk_button_released (button);
if (button->in_button)
gtk_button_leave (button);
-
+
gtk_signal_connect (GTK_OBJECT (clist->column[column].button), "event",
(GtkSignalFunc) column_title_passive_func, NULL);
-
+
GTK_WIDGET_UNSET_FLAGS (clist->column[column].button, GTK_CAN_FOCUS);
if (GTK_WIDGET_VISIBLE (clist))
gtk_widget_queue_draw (clist->column[column].button);
@@ -1363,13 +1363,13 @@ void
gtk_clist_column_titles_active (GtkCList *clist)
{
gint i;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (!GTK_CLIST_SHOW_TITLES(clist))
return;
-
+
for (i = 0; i < clist->columns; i++)
gtk_clist_column_title_active (clist, i);
}
@@ -1378,13 +1378,13 @@ void
gtk_clist_column_titles_passive (GtkCList *clist)
{
gint i;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (!GTK_CLIST_SHOW_TITLES(clist))
return;
-
+
for (i = 0; i < clist->columns; i++)
gtk_clist_column_title_passive (clist, i);
}
@@ -1398,13 +1398,13 @@ gtk_clist_set_column_title (GtkCList *clist,
GtkWidget *old_widget;
GtkWidget *alignment = NULL;
GtkWidget *label;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (column < 0 || column >= clist->columns)
return;
-
+
/* if the column button doesn't currently exist,
* it has to be created first */
if (!clist->column[column].button)
@@ -1412,34 +1412,34 @@ gtk_clist_set_column_title (GtkCList *clist,
column_button_create (clist, column);
new_button = 1;
}
-
+
column_title_new (clist, column, title);
-
+
/* remove and destroy the old widget */
old_widget = GTK_BIN (clist->column[column].button)->child;
if (old_widget)
gtk_container_remove (GTK_CONTAINER (clist->column[column].button), old_widget);
-
+
/* create new alignment based no column justification */
switch (clist->column[column].justification)
{
case GTK_JUSTIFY_LEFT:
alignment = gtk_alignment_new (0.0, 0.5, 0.0, 0.0);
break;
-
+
case GTK_JUSTIFY_RIGHT:
alignment = gtk_alignment_new (1.0, 0.5, 0.0, 0.0);
break;
-
+
case GTK_JUSTIFY_CENTER:
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
break;
-
+
case GTK_JUSTIFY_FILL:
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
break;
}
-
+
gtk_widget_push_composite_child ();
label = gtk_label_new (clist->column[column].title);
gtk_widget_pop_composite_child ();
@@ -1447,7 +1447,7 @@ gtk_clist_set_column_title (GtkCList *clist,
gtk_container_add (GTK_CONTAINER (clist->column[column].button), alignment);
gtk_widget_show (label);
gtk_widget_show (alignment);
-
+
/* if this button didn't previously exist, then the
* column button positions have to be re-computed */
if (GTK_WIDGET_VISIBLE (clist) && new_button)
@@ -1460,10 +1460,10 @@ gtk_clist_get_column_title (GtkCList *clist,
{
g_return_val_if_fail (clist != NULL, NULL);
g_return_val_if_fail (GTK_IS_CLIST (clist), NULL);
-
+
if (column < 0 || column >= clist->columns)
return NULL;
-
+
return clist->column[column].title;
}
@@ -1474,13 +1474,13 @@ gtk_clist_set_column_widget (GtkCList *clist,
{
gint new_button = 0;
GtkWidget *old_widget;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (column < 0 || column >= clist->columns)
return;
-
+
/* if the column button doesn't currently exist,
* it has to be created first */
if (!clist->column[column].button)
@@ -1488,22 +1488,22 @@ gtk_clist_set_column_widget (GtkCList *clist,
column_button_create (clist, column);
new_button = 1;
}
-
+
column_title_new (clist, column, NULL);
-
+
/* remove and destroy the old widget */
old_widget = GTK_BIN (clist->column[column].button)->child;
if (old_widget)
gtk_container_remove (GTK_CONTAINER (clist->column[column].button),
old_widget);
-
+
/* add and show the widget */
if (widget)
{
gtk_container_add (GTK_CONTAINER (clist->column[column].button), widget);
gtk_widget_show (widget);
}
-
+
/* if this button didn't previously exist, then the
* column button positions have to be re-computed */
if (GTK_WIDGET_VISIBLE (clist) && new_button)
@@ -1516,13 +1516,13 @@ gtk_clist_get_column_widget (GtkCList *clist,
{
g_return_val_if_fail (clist != NULL, NULL);
g_return_val_if_fail (GTK_IS_CLIST (clist), NULL);
-
+
if (column < 0 || column >= clist->columns)
return NULL;
-
+
if (clist->column[column].button)
return GTK_BUTTON (clist->column[column].button)->child;
-
+
return NULL;
}
@@ -1532,44 +1532,44 @@ gtk_clist_set_column_justification (GtkCList *clist,
GtkJustification justification)
{
GtkWidget *alignment;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (column < 0 || column >= clist->columns)
return;
-
+
clist->column[column].justification = justification;
-
+
/* change the alinment of the button title if it's not a
* custom widget */
if (clist->column[column].title)
{
alignment = GTK_BIN (clist->column[column].button)->child;
-
+
switch (clist->column[column].justification)
{
case GTK_JUSTIFY_LEFT:
gtk_alignment_set (GTK_ALIGNMENT (alignment), 0.0, 0.5, 0.0, 0.0);
break;
-
+
case GTK_JUSTIFY_RIGHT:
gtk_alignment_set (GTK_ALIGNMENT (alignment), 1.0, 0.5, 0.0, 0.0);
break;
-
+
case GTK_JUSTIFY_CENTER:
gtk_alignment_set (GTK_ALIGNMENT (alignment), 0.5, 0.5, 0.0, 0.0);
break;
-
+
case GTK_JUSTIFY_FILL:
gtk_alignment_set (GTK_ALIGNMENT (alignment), 0.5, 0.5, 0.0, 0.0);
break;
-
+
default:
break;
}
}
-
+
if (CLIST_UNFROZEN (clist))
draw_rows (clist, NULL);
}
@@ -1581,28 +1581,28 @@ gtk_clist_set_column_visibility (GtkCList *clist,
{
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (column < 0 || column >= clist->columns)
return;
if (clist->column[column].visible == visible)
return;
-
+
/* don't hide last visible column */
if (!visible)
{
gint i;
gint vis_columns = 0;
-
+
for (i = 0, vis_columns = 0; i < clist->columns && vis_columns < 2; i++)
if (clist->column[i].visible)
vis_columns++;
-
+
if (vis_columns < 2)
return;
}
-
+
clist->column[column].visible = visible;
-
+
if (clist->column[column].button)
{
if (visible)
@@ -1621,16 +1621,16 @@ gtk_clist_set_column_resizeable (GtkCList *clist,
{
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (column < 0 || column >= clist->columns)
return;
if (clist->column[column].resizeable == resizeable)
return;
-
+
clist->column[column].resizeable = resizeable;
if (resizeable)
clist->column[column].auto_resize = FALSE;
-
+
if (GTK_WIDGET_VISIBLE (clist))
size_allocate_title_buttons (clist);
}
@@ -1642,12 +1642,12 @@ gtk_clist_set_column_auto_resize (GtkCList *clist,
{
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (column < 0 || column >= clist->columns)
return;
if (clist->column[column].auto_resize == auto_resize)
return;
-
+
clist->column[column].auto_resize = auto_resize;
if (auto_resize)
{
@@ -1655,12 +1655,12 @@ gtk_clist_set_column_auto_resize (GtkCList *clist,
if (!GTK_CLIST_AUTO_RESIZE_BLOCKED(clist))
{
gint width;
-
+
width = gtk_clist_optimal_column_width (clist, column);
gtk_clist_set_column_width (clist, column, width);
}
}
-
+
if (GTK_WIDGET_VISIBLE (clist))
size_allocate_title_buttons (clist);
}
@@ -1670,20 +1670,20 @@ gtk_clist_columns_autosize (GtkCList *clist)
{
gint i;
gint width;
-
+
g_return_val_if_fail (clist != NULL, 0);
g_return_val_if_fail (GTK_IS_CLIST (clist), 0);
-
+
gtk_clist_freeze (clist);
width = 0;
for (i = 0; i < clist->columns; i++)
{
gtk_clist_set_column_width (clist, i,
gtk_clist_optimal_column_width (clist, i));
-
+
width += clist->column[i].width;
}
-
+
gtk_clist_thaw (clist);
return width;
}
@@ -1695,66 +1695,66 @@ gtk_clist_optimal_column_width (GtkCList *clist,
GtkRequisition requisition;
GList *list;
gint width;
-
+
g_return_val_if_fail (clist != NULL, 0);
g_return_val_if_fail (GTK_CLIST (clist), 0);
-
+
if (column < 0 || column > clist->columns)
return 0;
-
+
if (GTK_CLIST_SHOW_TITLES(clist) && clist->column[column].button)
width = (clist->column[column].button->requisition.width)
#if 0
- (CELL_SPACING + (2 * COLUMN_INSET)))
+ (CELL_SPACING + (2 * COLUMN_INSET)))
#endif
- ;
- else
- width = 0;
+ ;
+ else
+ width = 0;
- for (list = clist->row_list; list; list = list->next)
- {
- GTK_CLIST_CLASS_FW (clist)->cell_size_request
- (clist, GTK_CLIST_ROW (list), column, &requisition);
- width = MAX (width, requisition.width);
- }
+for (list = clist->row_list; list; list = list->next)
+{
+ GTK_CLIST_GET_CLASS (clist)->cell_size_request
+ (clist, GTK_CLIST_ROW (list), column, &requisition);
+ width = MAX (width, requisition.width);
+}
- return width;
+return width;
}
void
gtk_clist_set_column_width (GtkCList *clist,
- gint column,
- gint width)
+ gint column,
+ gint width)
{
- g_return_if_fail (clist != NULL);
- g_return_if_fail (GTK_IS_CLIST (clist));
+g_return_if_fail (clist != NULL);
+g_return_if_fail (GTK_IS_CLIST (clist));
- if (column < 0 || column >= clist->columns)
- return;
-
- gtk_signal_emit (GTK_OBJECT (clist), clist_signals[RESIZE_COLUMN],
- column, width);
-}
+if (column < 0 || column >= clist->columns)
+ return;
+
+ gtk_signal_emit (GTK_OBJECT (clist), clist_signals[RESIZE_COLUMN],
+ column, width);
+ }
void
gtk_clist_set_column_min_width (GtkCList *clist,
- gint column,
- gint min_width)
+ gint column,
+ gint min_width)
{
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (column < 0 || column >= clist->columns)
return;
if (clist->column[column].min_width == min_width)
return;
-
+
if (clist->column[column].max_width >= 0 &&
clist->column[column].max_width < min_width)
clist->column[column].min_width = clist->column[column].max_width;
else
clist->column[column].min_width = min_width;
-
+
if (clist->column[column].area.width < clist->column[column].min_width)
gtk_clist_set_column_width (clist, column,clist->column[column].min_width);
}
@@ -1766,12 +1766,12 @@ gtk_clist_set_column_max_width (GtkCList *clist,
{
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (column < 0 || column >= clist->columns)
return;
if (clist->column[column].max_width == max_width)
return;
-
+
if (clist->column[column].min_width >= 0 && max_width >= 0 &&
clist->column[column].min_width > max_width)
clist->column[column].max_width = clist->column[column].min_width;
@@ -1802,17 +1802,17 @@ column_auto_resize (GtkCList *clist,
{
/* resize column if needed for auto_resize */
GtkRequisition requisition;
-
+
if (!clist->column[column].auto_resize ||
GTK_CLIST_AUTO_RESIZE_BLOCKED(clist))
return;
-
+
if (clist_row)
- GTK_CLIST_CLASS_FW (clist)->cell_size_request (clist, clist_row,
- column, &requisition);
+ GTK_CLIST_GET_CLASS (clist)->cell_size_request (clist, clist_row,
+ column, &requisition);
else
requisition.width = 0;
-
+
if (requisition.width > clist->column[column].width)
gtk_clist_set_column_width (clist, column, requisition.width);
else if (requisition.width < old_width &&
@@ -1820,7 +1820,7 @@ column_auto_resize (GtkCList *clist,
{
GList *list;
gint new_width = 0;
-
+
/* run a "gtk_clist_optimal_column_width" but break, if
* the column doesn't shrink */
if (GTK_CLIST_SHOW_TITLES(clist) && clist->column[column].button)
@@ -1828,10 +1828,10 @@ column_auto_resize (GtkCList *clist,
(CELL_SPACING + (2 * COLUMN_INSET)));
else
new_width = 0;
-
+
for (list = clist->row_list; list; list = list->next)
{
- GTK_CLIST_CLASS_FW (clist)->cell_size_request
+ GTK_CLIST_GET_CLASS (clist)->cell_size_request
(clist, GTK_CLIST_ROW (list), column, &requisition);
new_width = MAX (new_width, requisition.width);
if (new_width == clist->column[column].width)
@@ -1850,7 +1850,7 @@ real_resize_column (GtkCList *clist,
{
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (column < 0 || column >= clist->columns)
return;
@@ -1859,17 +1859,17 @@ real_resize_column (GtkCList *clist,
if (clist->column[column].max_width >= 0 &&
width > clist->column[column].max_width)
width = clist->column[column].max_width;
-
+
clist->column[column].width = width;
clist->column[column].width_set = TRUE;
-
+
/* FIXME: this is quite expensive to do if the widget hasn't
* been size_allocated yet, and pointless. Should
* a flag be kept
*/
size_allocate_columns (clist, TRUE);
size_allocate_title_buttons (clist);
-
+
CLIST_REFRESH (clist);
}
@@ -1878,18 +1878,18 @@ abort_column_resize (GtkCList *clist)
{
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (!GTK_CLIST_IN_DRAG(clist))
return;
-
+
GTK_CLIST_UNSET_FLAG (clist, CLIST_IN_DRAG);
gtk_grab_remove (GTK_WIDGET (clist));
gdk_pointer_ungrab (GDK_CURRENT_TIME);
clist->drag_pos = -1;
-
+
if (clist->x_drag >= 0 && clist->x_drag <= clist->clist_window_width - 1)
draw_xor_line (clist);
-
+
if (GTK_CLIST_ADD_MODE(clist))
{
gdk_gc_set_line_attributes (clist->xor_gc, 1, GDK_LINE_ON_OFF_DASH, 0,0);
@@ -1904,20 +1904,20 @@ size_allocate_title_buttons (GtkCList *clist)
gint last_column;
gint last_button = 0;
gint i;
-
+
if (!GTK_WIDGET_REALIZED (clist))
return;
-
+
button_allocation.x = clist->hoffset;
button_allocation.y = 0;
button_allocation.width = 0;
button_allocation.height = clist->column_title_area.height;
-
+
/* find last visible column */
for (last_column = clist->columns - 1; last_column >= 0; last_column--)
if (clist->column[last_column].visible)
break;
-
+
for (i = 0; i < last_column; i++)
{
if (!clist->column[i].visible)
@@ -1926,21 +1926,21 @@ size_allocate_title_buttons (GtkCList *clist)
gdk_window_hide (clist->column[i].window);
continue;
}
-
+
button_allocation.width += (clist->column[i].area.width +
CELL_SPACING + 2 * COLUMN_INSET);
-
+
if (!clist->column[i + 1].button)
{
gdk_window_hide (clist->column[i].window);
continue;
}
-
+
gtk_widget_size_allocate (clist->column[last_button].button,
&button_allocation);
button_allocation.x += button_allocation.width;
button_allocation.width = 0;
-
+
if (clist->column[last_button].resizeable)
{
gdk_window_show (clist->column[last_button].window);
@@ -1951,19 +1951,19 @@ size_allocate_title_buttons (GtkCList *clist)
}
else
gdk_window_hide (clist->column[last_button].window);
-
+
last_button = i + 1;
}
-
+
button_allocation.width += (clist->column[last_column].area.width +
2 * (CELL_SPACING + COLUMN_INSET));
gtk_widget_size_allocate (clist->column[last_button].button,
&button_allocation);
-
+
if (clist->column[last_button].resizeable)
{
button_allocation.x += button_allocation.width;
-
+
gdk_window_show (clist->column[last_button].window);
gdk_window_move_resize (clist->column[last_button].window,
button_allocation.x - (DRAG_WIDTH / 2),
@@ -1980,14 +1980,14 @@ size_allocate_columns (GtkCList *clist,
gint xoffset = CELL_SPACING + COLUMN_INSET;
gint last_column;
gint i;
-
+
/* find last visible column and calculate correct column width */
for (last_column = clist->columns - 1;
last_column >= 0 && !clist->column[last_column].visible; last_column--);
-
+
if (last_column < 0)
return;
-
+
for (i = 0; i <= last_column; i++)
{
if (!clist->column[i].visible)
@@ -1999,14 +1999,14 @@ size_allocate_columns (GtkCList *clist,
clist->column[i].auto_resize && clist->column[i].button)
{
gint width;
-
+
width = (clist->column[i].button->requisition.width -
(CELL_SPACING + (2 * COLUMN_INSET)));
-
+
if (width > clist->column[i].width)
gtk_clist_set_column_width (clist, i, width);
}
-
+
clist->column[i].area.width = clist->column[i].width;
xoffset += clist->column[i].width + CELL_SPACING + (2* COLUMN_INSET);
}
@@ -2018,7 +2018,7 @@ size_allocate_columns (GtkCList *clist,
xoffset += clist->column[i].button->requisition.width;
}
}
-
+
clist->column[last_column].area.width = clist->column[last_column].area.width
+ MAX (0, clist->clist_window_width + COLUMN_INSET - xoffset);
}
@@ -2028,18 +2028,18 @@ list_requisition_width (GtkCList *clist)
{
gint width = CELL_SPACING;
gint i;
-
+
for (i = clist->columns - 1; i >= 0; i--)
{
if (!clist->column[i].visible)
continue;
-
+
if (clist->column[i].width_set)
width += clist->column[i].width + CELL_SPACING + (2 * COLUMN_INSET);
else if (GTK_CLIST_SHOW_TITLES(clist) && clist->column[i].button)
width += clist->column[i].button->requisition.width;
}
-
+
return width;
}
@@ -2056,20 +2056,20 @@ new_column_width (GtkCList *clist,
gint cx;
gint dx;
gint last_column;
-
+
/* first translate the x position from widget->window
* to clist->clist_window */
cx = *x - xthickness;
-
+
for (last_column = clist->columns - 1;
last_column >= 0 && !clist->column[last_column].visible; last_column--);
-
+
/* calculate new column width making sure it doesn't end up
* less than the minimum width */
dx = (COLUMN_LEFT_XPIXEL (clist, column) + COLUMN_INSET +
(column < last_column) * CELL_SPACING);
width = cx - dx;
-
+
if (width < MAX (COLUMN_MIN_WIDTH, clist->column[column].min_width))
{
width = MAX (COLUMN_MIN_WIDTH, clist->column[column].min_width);
@@ -2083,10 +2083,10 @@ new_column_width (GtkCList *clist,
cx = dx + clist->column[column].max_width;
*x = cx + xthickness;
}
-
+
if (cx < 0 || cx > clist->clist_window_width)
*x = -1;
-
+
return width;
}
@@ -2095,16 +2095,16 @@ column_button_create (GtkCList *clist,
gint column)
{
GtkWidget *button;
-
+
gtk_widget_push_composite_child ();
button = clist->column[column].button = gtk_button_new ();
gtk_widget_pop_composite_child ();
-
+
if (GTK_WIDGET_REALIZED (clist) && clist->title_window)
gtk_widget_set_parent_window (clist->column[column].button,
clist->title_window);
gtk_widget_set_parent (button, GTK_WIDGET (clist));
-
+
gtk_signal_connect (GTK_OBJECT (button), "clicked",
(GtkSignalFunc) column_button_clicked,
(gpointer) clist);
@@ -2117,17 +2117,17 @@ column_button_clicked (GtkWidget *widget,
{
gint i;
GtkCList *clist;
-
+
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_CLIST (data));
-
+
clist = GTK_CLIST (data);
-
+
/* find the column who's button was pressed */
for (i = 0; i < clist->columns; i++)
if (clist->column[i].button == widget)
break;
-
+
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[CLICK_COLUMN], i);
}
@@ -2171,17 +2171,17 @@ gtk_clist_get_cell_type (GtkCList *clist,
gint column)
{
GtkCListRow *clist_row;
-
+
g_return_val_if_fail (clist != NULL, -1);
g_return_val_if_fail (GTK_IS_CLIST (clist), -1);
-
+
if (row < 0 || row >= clist->rows)
return -1;
if (column < 0 || column >= clist->columns)
return -1;
-
+
clist_row = ROW_ELEMENT (clist, row)->data;
-
+
return clist_row->cell[column].type;
}
@@ -2192,26 +2192,26 @@ gtk_clist_set_text (GtkCList *clist,
const gchar *text)
{
GtkCListRow *clist_row;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (row < 0 || row >= clist->rows)
return;
if (column < 0 || column >= clist->columns)
return;
-
+
clist_row = ROW_ELEMENT (clist, row)->data;
-
+
/* if text is null, then the cell is empty */
- GTK_CLIST_CLASS_FW (clist)->set_cell_contents
+ GTK_CLIST_GET_CLASS (clist)->set_cell_contents
(clist, clist_row, column, GTK_CELL_TEXT, text, 0, NULL, NULL);
-
+
/* redraw the list if it's not frozen */
if (CLIST_UNFROZEN (clist))
{
if (gtk_clist_row_is_visible (clist, row) != GTK_VISIBILITY_NONE)
- GTK_CLIST_CLASS_FW (clist)->draw_row (clist, NULL, row, clist_row);
+ GTK_CLIST_GET_CLASS (clist)->draw_row (clist, NULL, row, clist_row);
}
}
@@ -2222,23 +2222,23 @@ gtk_clist_get_text (GtkCList *clist,
gchar **text)
{
GtkCListRow *clist_row;
-
+
g_return_val_if_fail (clist != NULL, 0);
g_return_val_if_fail (GTK_IS_CLIST (clist), 0);
-
+
if (row < 0 || row >= clist->rows)
return 0;
if (column < 0 || column >= clist->columns)
return 0;
-
+
clist_row = ROW_ELEMENT (clist, row)->data;
-
+
if (clist_row->cell[column].type != GTK_CELL_TEXT)
return 0;
-
+
if (text)
*text = GTK_CELL_TEXT (clist_row->cell[column])->text;
-
+
return 1;
}
@@ -2250,29 +2250,29 @@ gtk_clist_set_pixmap (GtkCList *clist,
GdkBitmap *mask)
{
GtkCListRow *clist_row;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (row < 0 || row >= clist->rows)
return;
if (column < 0 || column >= clist->columns)
return;
-
+
clist_row = ROW_ELEMENT (clist, row)->data;
gdk_pixmap_ref (pixmap);
if (mask) gdk_pixmap_ref (mask);
- GTK_CLIST_CLASS_FW (clist)->set_cell_contents
+ GTK_CLIST_GET_CLASS (clist)->set_cell_contents
(clist, clist_row, column, GTK_CELL_PIXMAP, NULL, 0, pixmap, mask);
-
+
/* redraw the list if it's not frozen */
if (CLIST_UNFROZEN (clist))
{
if (gtk_clist_row_is_visible (clist, row) != GTK_VISIBILITY_NONE)
- GTK_CLIST_CLASS_FW (clist)->draw_row (clist, NULL, row, clist_row);
+ GTK_CLIST_GET_CLASS (clist)->draw_row (clist, NULL, row, clist_row);
}
}
@@ -2284,27 +2284,27 @@ gtk_clist_get_pixmap (GtkCList *clist,
GdkBitmap **mask)
{
GtkCListRow *clist_row;
-
+
g_return_val_if_fail (clist != NULL, 0);
g_return_val_if_fail (GTK_IS_CLIST (clist), 0);
-
+
if (row < 0 || row >= clist->rows)
return 0;
if (column < 0 || column >= clist->columns)
return 0;
-
+
clist_row = ROW_ELEMENT (clist, row)->data;
-
+
if (clist_row->cell[column].type != GTK_CELL_PIXMAP)
return 0;
-
+
if (pixmap)
- {
- *pixmap = GTK_CELL_PIXMAP (clist_row->cell[column])->pixmap;
- /* mask can be NULL */
- *mask = GTK_CELL_PIXMAP (clist_row->cell[column])->mask;
- }
-
+ {
+ *pixmap = GTK_CELL_PIXMAP (clist_row->cell[column])->pixmap;
+ /* mask can be NULL */
+ *mask = GTK_CELL_PIXMAP (clist_row->cell[column])->mask;
+ }
+
return 1;
}
@@ -2318,27 +2318,27 @@ gtk_clist_set_pixtext (GtkCList *clist,
GdkBitmap *mask)
{
GtkCListRow *clist_row;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (row < 0 || row >= clist->rows)
return;
if (column < 0 || column >= clist->columns)
return;
-
+
clist_row = ROW_ELEMENT (clist, row)->data;
gdk_pixmap_ref (pixmap);
if (mask) gdk_pixmap_ref (mask);
- GTK_CLIST_CLASS_FW (clist)->set_cell_contents
+ GTK_CLIST_GET_CLASS (clist)->set_cell_contents
(clist, clist_row, column, GTK_CELL_PIXTEXT, text, spacing, pixmap, mask);
-
+
/* redraw the list if it's not frozen */
if (CLIST_UNFROZEN (clist))
{
if (gtk_clist_row_is_visible (clist, row) != GTK_VISIBILITY_NONE)
- GTK_CLIST_CLASS_FW (clist)->draw_row (clist, NULL, row, clist_row);
+ GTK_CLIST_GET_CLASS (clist)->draw_row (clist, NULL, row, clist_row);
}
}
@@ -2352,30 +2352,30 @@ gtk_clist_get_pixtext (GtkCList *clist,
GdkBitmap **mask)
{
GtkCListRow *clist_row;
-
+
g_return_val_if_fail (clist != NULL, 0);
g_return_val_if_fail (GTK_IS_CLIST (clist), 0);
-
+
if (row < 0 || row >= clist->rows)
return 0;
if (column < 0 || column >= clist->columns)
return 0;
-
+
clist_row = ROW_ELEMENT (clist, row)->data;
-
+
if (clist_row->cell[column].type != GTK_CELL_PIXTEXT)
return 0;
-
+
if (text)
*text = GTK_CELL_PIXTEXT (clist_row->cell[column])->text;
if (spacing)
*spacing = GTK_CELL_PIXTEXT (clist_row->cell[column])->spacing;
if (pixmap)
*pixmap = GTK_CELL_PIXTEXT (clist_row->cell[column])->pixmap;
-
+
/* mask can be NULL */
*mask = GTK_CELL_PIXTEXT (clist_row->cell[column])->mask;
-
+
return 1;
}
@@ -2388,29 +2388,29 @@ gtk_clist_set_shift (GtkCList *clist,
{
GtkRequisition requisition = { 0 };
GtkCListRow *clist_row;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (row < 0 || row >= clist->rows)
return;
if (column < 0 || column >= clist->columns)
return;
-
+
clist_row = ROW_ELEMENT (clist, row)->data;
-
+
if (clist->column[column].auto_resize &&
!GTK_CLIST_AUTO_RESIZE_BLOCKED(clist))
- GTK_CLIST_CLASS_FW (clist)->cell_size_request (clist, clist_row,
- column, &requisition);
-
+ GTK_CLIST_GET_CLASS (clist)->cell_size_request (clist, clist_row,
+ column, &requisition);
+
clist_row->cell[column].vertical = vertical;
clist_row->cell[column].horizontal = horizontal;
-
+
column_auto_resize (clist, clist_row, column, requisition.width);
-
+
if (CLIST_UNFROZEN (clist) && gtk_clist_row_is_visible (clist, row) != GTK_VISIBILITY_NONE)
- GTK_CLIST_CLASS_FW (clist)->draw_row (clist, NULL, row, clist_row);
+ GTK_CLIST_GET_CLASS (clist)->draw_row (clist, NULL, row, clist_row);
}
/* PRIVATE CELL FUNCTIONS
@@ -2428,16 +2428,16 @@ set_cell_contents (GtkCList *clist,
GdkBitmap *mask)
{
GtkRequisition requisition;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
g_return_if_fail (clist_row != NULL);
-
+
if (clist->column[column].auto_resize &&
!GTK_CLIST_AUTO_RESIZE_BLOCKED(clist))
- GTK_CLIST_CLASS_FW (clist)->cell_size_request (clist, clist_row,
- column, &requisition);
-
+ GTK_CLIST_GET_CLASS (clist)->cell_size_request (clist, clist_row,
+ column, &requisition);
+
switch (clist_row->cell[column].type)
{
case GTK_CELL_EMPTY:
@@ -2462,9 +2462,9 @@ set_cell_contents (GtkCList *clist,
default:
break;
}
-
+
clist_row->cell[column].type = GTK_CELL_EMPTY;
-
+
switch (type)
{
case GTK_CELL_TEXT:
@@ -2496,7 +2496,7 @@ set_cell_contents (GtkCList *clist,
default:
break;
}
-
+
if (clist->column[column].auto_resize &&
!GTK_CLIST_AUTO_RESIZE_BLOCKED(clist))
column_auto_resize (clist, clist_row, column, requisition.width);
@@ -2511,14 +2511,14 @@ cell_size_request (GtkCList *clist,
GtkStyle *style;
gint width;
gint height;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
g_return_if_fail (requisition != NULL);
-
+
get_cell_style (clist, clist_row, GTK_STATE_NORMAL, column, &style,
NULL, NULL);
-
+
switch (clist_row->cell[column].type)
{
case GTK_CELL_TEXT:
@@ -2534,7 +2534,7 @@ cell_size_request (GtkCList *clist,
GTK_CELL_PIXTEXT (clist_row->cell[column])->spacing +
gdk_string_width (style->font,
GTK_CELL_TEXT (clist_row->cell[column])->text);
-
+
requisition->height = MAX (style->font->ascent + style->font->descent,
height);
break;
@@ -2549,7 +2549,7 @@ cell_size_request (GtkCList *clist,
requisition->height = 0;
break;
}
-
+
requisition->width += clist_row->cell[column].horizontal;
requisition->height += clist_row->cell[column].vertical;
}
@@ -2568,8 +2568,8 @@ gtk_clist_prepend (GtkCList *clist,
g_return_val_if_fail (clist != NULL, -1);
g_return_val_if_fail (GTK_IS_CLIST (clist), -1);
g_return_val_if_fail (text != NULL, -1);
-
- return GTK_CLIST_CLASS_FW (clist)->insert_row (clist, 0, text);
+
+ return GTK_CLIST_GET_CLASS (clist)->insert_row (clist, 0, text);
}
gint
@@ -2579,8 +2579,8 @@ gtk_clist_append (GtkCList *clist,
g_return_val_if_fail (clist != NULL, -1);
g_return_val_if_fail (GTK_IS_CLIST (clist), -1);
g_return_val_if_fail (text != NULL, -1);
-
- return GTK_CLIST_CLASS_FW (clist)->insert_row (clist, clist->rows, text);
+
+ return GTK_CLIST_GET_CLASS (clist)->insert_row (clist, clist->rows, text);
}
gint
@@ -2591,18 +2591,18 @@ gtk_clist_insert (GtkCList *clist,
g_return_val_if_fail (clist != NULL, -1);
g_return_val_if_fail (GTK_IS_CLIST (clist), -1);
g_return_val_if_fail (text != NULL, -1);
-
+
if (row < 0 || row > clist->rows)
row = clist->rows;
-
- return GTK_CLIST_CLASS_FW (clist)->insert_row (clist, row, text);
+
+ return GTK_CLIST_GET_CLASS (clist)->insert_row (clist, row, text);
}
void
gtk_clist_remove (GtkCList *clist,
gint row)
{
- GTK_CLIST_CLASS_FW (clist)->remove_row (clist, row);
+ GTK_CLIST_GET_CLASS (clist)->remove_row (clist, row);
}
void
@@ -2611,7 +2611,7 @@ gtk_clist_clear (GtkCList *clist)
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
- GTK_CLIST_CLASS_FW (clist)->clear (clist);
+ GTK_CLIST_GET_CLASS (clist)->clear (clist);
}
/* PRIVATE INSERT/REMOVE ROW FUNCTIONS
@@ -2627,24 +2627,24 @@ real_insert_row (GtkCList *clist,
{
gint i;
GtkCListRow *clist_row;
-
+
g_return_val_if_fail (clist != NULL, -1);
g_return_val_if_fail (GTK_IS_CLIST (clist), -1);
g_return_val_if_fail (text != NULL, -1);
-
+
/* return if out of bounds */
if (row < 0 || row > clist->rows)
return -1;
-
+
/* create the row */
clist_row = row_new (clist);
-
+
/* set the text in the row's columns */
for (i = 0; i < clist->columns; i++)
if (text[i])
- GTK_CLIST_CLASS_FW (clist)->set_cell_contents
+ GTK_CLIST_GET_CLASS (clist)->set_cell_contents
(clist, clist_row, i, GTK_CELL_TEXT, text[i], 0, NULL ,NULL);
-
+
if (!clist->rows)
{
clist->row_list = g_list_append (clist->row_list, clist_row);
@@ -2687,32 +2687,32 @@ real_insert_row (GtkCList *clist,
clist_row))->next;
else
clist->row_list = g_list_insert (clist->row_list, clist_row, row);
-
+
}
clist->rows++;
-
+
if (row < ROW_FROM_YPIXEL (clist, 0))
clist->voffset -= (clist->row_height + CELL_SPACING);
-
+
/* syncronize the selection list */
sync_selection (clist, row, SYNC_INSERT);
-
+
if (clist->rows == 1)
{
clist->focus_row = 0;
if (clist->selection_mode == GTK_SELECTION_BROWSE)
gtk_clist_select_row (clist, 0, -1);
}
-
+
/* redraw the list if it isn't frozen */
if (CLIST_UNFROZEN (clist))
{
adjust_adjustments (clist, FALSE);
-
+
if (gtk_clist_row_is_visible (clist, row) != GTK_VISIBILITY_NONE)
draw_rows (clist, NULL);
}
-
+
return row;
}
@@ -2723,22 +2723,22 @@ real_remove_row (GtkCList *clist,
gint was_visible, was_selected;
GList *list;
GtkCListRow *clist_row;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
/* return if out of bounds */
if (row < 0 || row > (clist->rows - 1))
return;
-
+
was_visible = (gtk_clist_row_is_visible (clist, row) != GTK_VISIBILITY_NONE);
was_selected = 0;
-
+
/* get the row we're going to delete */
list = ROW_ELEMENT (clist, row);
g_assert (list != NULL);
clist_row = list->data;
-
+
/* if we're removing a selected row, we have to make sure
* it's properly unselected, and then sync up the clist->selected
* list to reflect the deincrimented indexies of rows after the
@@ -2746,7 +2746,7 @@ real_remove_row (GtkCList *clist,
if (clist_row->state == GTK_STATE_SELECTED)
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[UNSELECT_ROW],
row, -1, NULL);
-
+
/* reset the row end pointer if we're removing at the end of the list */
clist->rows--;
if (clist->row_list == list)
@@ -2754,29 +2754,29 @@ real_remove_row (GtkCList *clist,
if (clist->row_list_end == list)
clist->row_list_end = g_list_previous (list);
g_list_remove (list, clist_row);
-
+
/*if (clist->focus_row >=0 &&
- (row <= clist->focus_row || clist->focus_row >= clist->rows))
- clist->focus_row--;*/
-
+ (row <= clist->focus_row || clist->focus_row >= clist->rows))
+ clist->focus_row--;*/
+
if (row < ROW_FROM_YPIXEL (clist, 0))
clist->voffset += clist->row_height + CELL_SPACING;
-
+
sync_selection (clist, row, SYNC_REMOVE);
-
+
if (clist->selection_mode == GTK_SELECTION_BROWSE && !clist->selection &&
clist->focus_row >= 0)
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[SELECT_ROW],
clist->focus_row, -1, NULL);
-
+
/* toast the row */
row_delete (clist, clist_row);
-
+
/* redraw the row if it isn't frozen */
if (CLIST_UNFROZEN (clist))
{
adjust_adjustments (clist, FALSE);
-
+
if (was_visible)
draw_rows (clist, NULL);
}
@@ -2788,15 +2788,15 @@ real_clear (GtkCList *clist)
GList *list;
GList *free_list;
gint i;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
/* free up the selection list */
g_list_free (clist->selection);
g_list_free (clist->undo_selection);
g_list_free (clist->undo_unselection);
-
+
clist->selection = NULL;
clist->selection_end = NULL;
clist->undo_selection = NULL;
@@ -2807,7 +2807,7 @@ real_clear (GtkCList *clist)
clist->undo_anchor = -1;
clist->anchor_state = GTK_STATE_SELECTED;
clist->drag_pos = -1;
-
+
/* remove all the rows */
GTK_CLIST_SET_FLAG (clist, CLIST_AUTO_RESIZE_BLOCKED);
free_list = clist->row_list;
@@ -2847,33 +2847,33 @@ real_row_move (GtkCList *clist,
GList *list;
gint first, last;
gint d;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (GTK_CLIST_AUTO_SORT(clist))
return;
-
+
if (source_row < 0 || source_row >= clist->rows ||
dest_row < 0 || dest_row >= clist->rows ||
source_row == dest_row)
return;
-
+
gtk_clist_freeze (clist);
-
+
/* unlink source row */
clist_row = ROW_ELEMENT (clist, source_row)->data;
if (source_row == clist->rows - 1)
clist->row_list_end = clist->row_list_end->prev;
clist->row_list = g_list_remove (clist->row_list, clist_row);
clist->rows--;
-
+
/* relink source row */
clist->row_list = g_list_insert (clist->row_list, clist_row, dest_row);
if (dest_row == clist->rows)
clist->row_list_end = clist->row_list_end->next;
clist->rows++;
-
+
/* sync selection */
if (source_row > dest_row)
{
@@ -2887,7 +2887,7 @@ real_row_move (GtkCList *clist,
last = dest_row;
d = -1;
}
-
+
for (list = clist->selection; list; list = list->next)
{
if (list->data == GINT_TO_POINTER (source_row))
@@ -2901,7 +2901,7 @@ real_row_move (GtkCList *clist,
clist->focus_row = dest_row;
else if (clist->focus_row > first)
clist->focus_row += d;
-
+
gtk_clist_thaw (clist);
}
@@ -2927,20 +2927,20 @@ gtk_clist_moveto (GtkCList *clist,
{
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (row < -1 || row >= clist->rows)
return;
if (column < -1 || column >= clist->columns)
return;
-
+
row_align = CLAMP (row_align, 0, 1);
col_align = CLAMP (col_align, 0, 1);
-
+
/* adjust horizontal scrollbar */
if (clist->hadjustment && column >= 0)
{
gint x;
-
+
x = (COLUMN_LEFT (clist, column) - CELL_SPACING - COLUMN_INSET -
(col_align * (clist->clist_window_width - 2 * COLUMN_INSET -
CELL_SPACING - clist->column[column].area.width)));
@@ -2952,7 +2952,7 @@ gtk_clist_moveto (GtkCList *clist,
else
gtk_adjustment_set_value (clist->hadjustment, x);
}
-
+
/* adjust vertical scrollbar */
if (clist->vadjustment && row >= 0)
move_vertical (clist, row, row_align);
@@ -2963,12 +2963,12 @@ gtk_clist_set_row_height (GtkCList *clist,
guint height)
{
GtkWidget *widget;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
widget = GTK_WIDGET (clist);
-
+
if (height > 0)
{
clist->row_height = height;
@@ -2979,7 +2979,7 @@ gtk_clist_set_row_height (GtkCList *clist,
GTK_CLIST_UNSET_FLAG (clist, CLIST_ROW_HEIGHT_SET);
clist->row_height = 0;
}
-
+
if (GTK_WIDGET_REALIZED (clist))
{
if (!GTK_CLIST_ROW_HEIGHT_SET(clist))
@@ -2993,7 +2993,7 @@ gtk_clist_set_row_height (GtkCList *clist,
widget->style->font->ascent -
widget->style->font->descent - 1) / 2;
}
-
+
CLIST_REFRESH (clist);
}
@@ -3012,15 +3012,15 @@ gtk_clist_set_row_data_full (GtkCList *clist,
GtkDestroyNotify destroy)
{
GtkCListRow *clist_row;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (row < 0 || row > (clist->rows - 1))
return;
-
+
clist_row = ROW_ELEMENT (clist, row)->data;
-
+
if (clist_row->destroy)
clist_row->destroy (clist_row->data);
@@ -3033,13 +3033,13 @@ gtk_clist_get_row_data (GtkCList *clist,
gint row)
{
GtkCListRow *clist_row;
-
+
g_return_val_if_fail (clist != NULL, NULL);
g_return_val_if_fail (GTK_IS_CLIST (clist), NULL);
-
+
if (row < 0 || row > (clist->rows - 1))
return NULL;
-
+
clist_row = ROW_ELEMENT (clist, row)->data;
return clist_row->data;
}
@@ -3050,14 +3050,14 @@ gtk_clist_find_row_from_data (GtkCList *clist,
{
GList *list;
gint n;
-
+
g_return_val_if_fail (clist != NULL, -1);
g_return_val_if_fail (GTK_IS_CLIST (clist), -1);
-
+
for (n = 0, list = clist->row_list; list; n++, list = list->next)
if (GTK_CLIST_ROW (list)->data == data)
return n;
-
+
return -1;
}
@@ -3067,19 +3067,19 @@ gtk_clist_swap_rows (GtkCList *clist,
gint row2)
{
gint first, last;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
g_return_if_fail (row1 != row2);
-
+
if (GTK_CLIST_AUTO_SORT(clist))
return;
-
+
gtk_clist_freeze (clist);
-
+
first = MIN (row1, row2);
last = MAX (row1, row2);
-
+
gtk_clist_row_move (clist, last, first);
gtk_clist_row_move (clist, first + 1, last);
@@ -3093,15 +3093,15 @@ gtk_clist_row_move (GtkCList *clist,
{
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (GTK_CLIST_AUTO_SORT(clist))
return;
-
+
if (source_row < 0 || source_row >= clist->rows ||
dest_row < 0 || dest_row >= clist->rows ||
source_row == dest_row)
return;
-
+
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[ROW_MOVE],
source_row, dest_row);
}
@@ -3111,28 +3111,28 @@ gtk_clist_row_is_visible (GtkCList *clist,
gint row)
{
gint top;
-
+
g_return_val_if_fail (clist != NULL, 0);
g_return_val_if_fail (GTK_IS_CLIST (clist), 0);
-
+
if (row < 0 || row >= clist->rows)
return GTK_VISIBILITY_NONE;
-
+
if (clist->row_height == 0)
return GTK_VISIBILITY_NONE;
-
+
if (row < ROW_FROM_YPIXEL (clist, 0))
return GTK_VISIBILITY_NONE;
-
+
if (row > ROW_FROM_YPIXEL (clist, clist->clist_window_height))
return GTK_VISIBILITY_NONE;
-
+
top = ROW_TOP_YPIXEL (clist, row);
-
+
if ((top < 0)
|| ((top + clist->row_height) >= clist->clist_window_height))
return GTK_VISIBILITY_PARTIAL;
-
+
return GTK_VISIBILITY_FULL;
}
@@ -3142,15 +3142,15 @@ gtk_clist_set_foreground (GtkCList *clist,
GdkColor *color)
{
GtkCListRow *clist_row;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (row < 0 || row >= clist->rows)
return;
-
+
clist_row = ROW_ELEMENT (clist, row)->data;
-
+
if (color)
{
clist_row->foreground = *color;
@@ -3161,9 +3161,9 @@ gtk_clist_set_foreground (GtkCList *clist,
}
else
clist_row->fg_set = FALSE;
-
+
if (CLIST_UNFROZEN (clist) && gtk_clist_row_is_visible (clist, row) != GTK_VISIBILITY_NONE)
- GTK_CLIST_CLASS_FW (clist)->draw_row (clist, NULL, row, clist_row);
+ GTK_CLIST_GET_CLASS (clist)->draw_row (clist, NULL, row, clist_row);
}
void
@@ -3172,15 +3172,15 @@ gtk_clist_set_background (GtkCList *clist,
GdkColor *color)
{
GtkCListRow *clist_row;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (row < 0 || row >= clist->rows)
return;
-
+
clist_row = ROW_ELEMENT (clist, row)->data;
-
+
if (color)
{
clist_row->background = *color;
@@ -3191,10 +3191,10 @@ gtk_clist_set_background (GtkCList *clist,
}
else
clist_row->bg_set = FALSE;
-
+
if (CLIST_UNFROZEN (clist)
&& (gtk_clist_row_is_visible (clist, row) != GTK_VISIBILITY_NONE))
- GTK_CLIST_CLASS_FW (clist)->draw_row (clist, NULL, row, clist_row);
+ GTK_CLIST_GET_CLASS (clist)->draw_row (clist, NULL, row, clist_row);
}
/* PUBLIC ROW/CELL STYLE FUNCTIONS
@@ -3211,34 +3211,34 @@ gtk_clist_set_cell_style (GtkCList *clist,
{
GtkRequisition requisition = { 0 };
GtkCListRow *clist_row;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (row < 0 || row >= clist->rows)
return;
if (column < 0 || column >= clist->columns)
return;
-
+
clist_row = ROW_ELEMENT (clist, row)->data;
-
+
if (clist_row->cell[column].style == style)
return;
-
+
if (clist->column[column].auto_resize &&
!GTK_CLIST_AUTO_RESIZE_BLOCKED(clist))
- GTK_CLIST_CLASS_FW (clist)->cell_size_request (clist, clist_row,
- column, &requisition);
-
+ GTK_CLIST_GET_CLASS (clist)->cell_size_request (clist, clist_row,
+ column, &requisition);
+
if (clist_row->cell[column].style)
{
if (GTK_WIDGET_REALIZED (clist))
gtk_style_detach (clist_row->cell[column].style);
gtk_style_unref (clist_row->cell[column].style);
}
-
+
clist_row->cell[column].style = style;
-
+
if (clist_row->cell[column].style)
{
gtk_style_ref (clist_row->cell[column].style);
@@ -3248,14 +3248,14 @@ gtk_clist_set_cell_style (GtkCList *clist,
gtk_style_attach (clist_row->cell[column].style,
clist->clist_window);
}
-
+
column_auto_resize (clist, clist_row, column, requisition.width);
-
+
/* redraw the list if it's not frozen */
if (CLIST_UNFROZEN (clist))
{
if (gtk_clist_row_is_visible (clist, row) != GTK_VISIBILITY_NONE)
- GTK_CLIST_CLASS_FW (clist)->draw_row (clist, NULL, row, clist_row);
+ GTK_CLIST_GET_CLASS (clist)->draw_row (clist, NULL, row, clist_row);
}
}
@@ -3265,15 +3265,15 @@ gtk_clist_get_cell_style (GtkCList *clist,
gint column)
{
GtkCListRow *clist_row;
-
+
g_return_val_if_fail (clist != NULL, NULL);
g_return_val_if_fail (GTK_IS_CLIST (clist), NULL);
-
+
if (row < 0 || row >= clist->rows || column < 0 || column >= clist->columns)
return NULL;
-
+
clist_row = ROW_ELEMENT (clist, row)->data;
-
+
return clist_row->cell[column].style;
}
@@ -3286,40 +3286,40 @@ gtk_clist_set_row_style (GtkCList *clist,
GtkCListRow *clist_row;
gint *old_width;
gint i;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (row < 0 || row >= clist->rows)
return;
-
+
clist_row = ROW_ELEMENT (clist, row)->data;
-
+
if (clist_row->style == style)
return;
-
+
old_width = g_new (gint, clist->columns);
-
+
if (!GTK_CLIST_AUTO_RESIZE_BLOCKED(clist))
{
for (i = 0; i < clist->columns; i++)
if (clist->column[i].auto_resize)
{
- GTK_CLIST_CLASS_FW (clist)->cell_size_request (clist, clist_row,
- i, &requisition);
+ GTK_CLIST_GET_CLASS (clist)->cell_size_request (clist, clist_row,
+ i, &requisition);
old_width[i] = requisition.width;
}
}
-
+
if (clist_row->style)
{
if (GTK_WIDGET_REALIZED (clist))
gtk_style_detach (clist_row->style);
gtk_style_unref (clist_row->style);
}
-
+
clist_row->style = style;
-
+
if (clist_row->style)
{
gtk_style_ref (clist_row->style);
@@ -3328,18 +3328,18 @@ gtk_clist_set_row_style (GtkCList *clist,
clist_row->style = gtk_style_attach (clist_row->style,
clist->clist_window);
}
-
+
if (GTK_CLIST_AUTO_RESIZE_BLOCKED(clist))
for (i = 0; i < clist->columns; i++)
column_auto_resize (clist, clist_row, i, old_width[i]);
-
+
g_free (old_width);
-
+
/* redraw the list if it's not frozen */
if (CLIST_UNFROZEN (clist))
{
if (gtk_clist_row_is_visible (clist, row) != GTK_VISIBILITY_NONE)
- GTK_CLIST_CLASS_FW (clist)->draw_row (clist, NULL, row, clist_row);
+ GTK_CLIST_GET_CLASS (clist)->draw_row (clist, NULL, row, clist_row);
}
}
@@ -3348,15 +3348,15 @@ gtk_clist_get_row_style (GtkCList *clist,
gint row)
{
GtkCListRow *clist_row;
-
+
g_return_val_if_fail (clist != NULL, NULL);
g_return_val_if_fail (GTK_IS_CLIST (clist), NULL);
-
+
if (row < 0 || row >= clist->rows)
return NULL;
-
+
clist_row = ROW_ELEMENT (clist, row)->data;
-
+
return clist_row->style;
}
@@ -3375,20 +3375,20 @@ gtk_clist_set_selectable (GtkCList *clist,
gboolean selectable)
{
GtkCListRow *clist_row;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (row < 0 || row >= clist->rows)
return;
-
+
clist_row = ROW_ELEMENT (clist, row)->data;
-
+
if (selectable == clist_row->selectable)
return;
-
+
clist_row->selectable = selectable;
-
+
if (!selectable && clist_row->state == GTK_STATE_SELECTED)
{
if (clist->anchor >= 0 &&
@@ -3396,7 +3396,7 @@ gtk_clist_set_selectable (GtkCList *clist,
{
clist->drag_button = 0;
remove_grab (clist);
- GTK_CLIST_CLASS_FW (clist)->resync_selection (clist, NULL);
+ GTK_CLIST_GET_CLASS (clist)->resync_selection (clist, NULL);
}
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[UNSELECT_ROW],
row, -1, NULL);
@@ -3409,10 +3409,10 @@ gtk_clist_get_selectable (GtkCList *clist,
{
g_return_val_if_fail (clist != NULL, FALSE);
g_return_val_if_fail (GTK_IS_CLIST (clist), FALSE);
-
+
if (row < 0 || row >= clist->rows)
return FALSE;
-
+
return GTK_CLIST_ROW (ROW_ELEMENT (clist, row))->selectable;
}
@@ -3423,12 +3423,12 @@ gtk_clist_select_row (GtkCList *clist,
{
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (row < 0 || row >= clist->rows)
return;
if (column < -1 || column >= clist->columns)
return;
-
+
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[SELECT_ROW],
row, column, NULL);
}
@@ -3440,12 +3440,12 @@ gtk_clist_unselect_row (GtkCList *clist,
{
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (row < 0 || row >= clist->rows)
return;
if (column < -1 || column >= clist->columns)
return;
-
+
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[UNSELECT_ROW],
row, column, NULL);
}
@@ -3455,8 +3455,8 @@ gtk_clist_select_all (GtkCList *clist)
{
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
- GTK_CLIST_CLASS_FW (clist)->select_all (clist);
+
+ GTK_CLIST_GET_CLASS (clist)->select_all (clist);
}
void
@@ -3464,8 +3464,8 @@ gtk_clist_unselect_all (GtkCList *clist)
{
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
- GTK_CLIST_CLASS_FW (clist)->unselect_all (clist);
+
+ GTK_CLIST_GET_CLASS (clist)->unselect_all (clist);
}
void
@@ -3473,7 +3473,7 @@ gtk_clist_undo_selection (GtkCList *clist)
{
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (clist->selection_mode == GTK_SELECTION_EXTENDED &&
(clist->undo_selection || clist->undo_unselection))
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[UNDO_SELECTION]);
@@ -3514,17 +3514,17 @@ toggle_row (GtkCList *clist,
GdkEvent *event)
{
GtkCListRow *clist_row;
-
+
switch (clist->selection_mode)
{
case GTK_SELECTION_EXTENDED:
case GTK_SELECTION_MULTIPLE:
case GTK_SELECTION_SINGLE:
clist_row = ROW_ELEMENT (clist, row)->data;
-
+
if (!clist_row)
return;
-
+
if (clist_row->state == GTK_STATE_SELECTED)
{
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[UNSELECT_ROW],
@@ -3543,9 +3543,9 @@ fake_toggle_row (GtkCList *clist,
gint row)
{
GList *work;
-
+
work = ROW_ELEMENT (clist, row);
-
+
if (!work || !GTK_CLIST_ROW (work)->selectable)
return;
@@ -3556,8 +3556,8 @@ fake_toggle_row (GtkCList *clist,
if (CLIST_UNFROZEN (clist) &&
gtk_clist_row_is_visible (clist, row) != GTK_VISIBILITY_NONE)
- GTK_CLIST_CLASS_FW (clist)->draw_row (clist, NULL, row,
- GTK_CLIST_ROW (work));
+ GTK_CLIST_GET_CLASS (clist)->draw_row (clist, NULL, row,
+ GTK_CLIST_ROW (work));
}
static void
@@ -3565,11 +3565,11 @@ toggle_focus_row (GtkCList *clist)
{
g_return_if_fail (clist != 0);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if ((gdk_pointer_is_grabbed () && GTK_WIDGET_HAS_GRAB (clist)) ||
clist->focus_row < 0 || clist->focus_row >= clist->rows)
return;
-
+
switch (clist->selection_mode)
{
case GTK_SELECTION_SINGLE:
@@ -3581,7 +3581,7 @@ toggle_focus_row (GtkCList *clist)
g_list_free (clist->undo_unselection);
clist->undo_selection = NULL;
clist->undo_unselection = NULL;
-
+
clist->anchor = clist->focus_row;
clist->drag_pos = clist->focus_row;
clist->undo_anchor = clist->focus_row;
@@ -3589,9 +3589,9 @@ toggle_focus_row (GtkCList *clist)
if (GTK_CLIST_ADD_MODE(clist))
fake_toggle_row (clist, clist->focus_row);
else
- GTK_CLIST_CLASS_FW (clist)->fake_unselect_all (clist,clist->focus_row);
-
- GTK_CLIST_CLASS_FW (clist)->resync_selection (clist, NULL);
+ GTK_CLIST_GET_CLASS (clist)->fake_unselect_all (clist,clist->focus_row);
+
+ GTK_CLIST_GET_CLASS (clist)->resync_selection (clist, NULL);
break;
default:
break;
@@ -3607,7 +3607,7 @@ toggle_add_mode (GtkCList *clist)
if ((gdk_pointer_is_grabbed () && GTK_WIDGET_HAS_GRAB (clist)) ||
clist->selection_mode != GTK_SELECTION_EXTENDED)
return;
-
+
gtk_clist_draw_focus (GTK_WIDGET (clist));
if (!GTK_CLIST_ADD_MODE(clist))
{
@@ -3635,45 +3635,45 @@ real_select_row (GtkCList *clist,
GList *list;
gint sel_row;
gboolean row_selected;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (row < 0 || row > (clist->rows - 1))
return;
-
+
switch (clist->selection_mode)
{
case GTK_SELECTION_SINGLE:
case GTK_SELECTION_BROWSE:
-
+
row_selected = FALSE;
list = clist->selection;
-
+
while (list)
{
sel_row = GPOINTER_TO_INT (list->data);
list = list->next;
-
+
if (row == sel_row)
row_selected = TRUE;
else
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[UNSELECT_ROW],
sel_row, column, event);
}
-
+
if (row_selected)
return;
default:
break;
}
-
+
clist_row = ROW_ELEMENT (clist, row)->data;
-
+
if (clist_row->state != GTK_STATE_NORMAL || !clist_row->selectable)
return;
-
+
clist_row->state = GTK_STATE_SELECTED;
if (!clist->selection)
{
@@ -3687,7 +3687,7 @@ real_select_row (GtkCList *clist,
if (CLIST_UNFROZEN (clist)
&& (gtk_clist_row_is_visible (clist, row) != GTK_VISIBILITY_NONE))
- GTK_CLIST_CLASS_FW (clist)->draw_row (clist, NULL, row, clist_row);
+ GTK_CLIST_GET_CLASS (clist)->draw_row (clist, NULL, row, clist_row);
}
static void
@@ -3697,29 +3697,29 @@ real_unselect_row (GtkCList *clist,
GdkEvent *event)
{
GtkCListRow *clist_row;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (row < 0 || row > (clist->rows - 1))
return;
-
+
clist_row = ROW_ELEMENT (clist, row)->data;
-
+
if (clist_row->state == GTK_STATE_SELECTED)
{
clist_row->state = GTK_STATE_NORMAL;
-
+
if (clist->selection_end &&
clist->selection_end->data == GINT_TO_POINTER (row))
clist->selection_end = clist->selection_end->prev;
-
+
clist->selection = g_list_remove (clist->selection,
GINT_TO_POINTER (row));
if (CLIST_UNFROZEN (clist)
&& (gtk_clist_row_is_visible (clist, row) != GTK_VISIBILITY_NONE))
- GTK_CLIST_CLASS_FW (clist)->draw_row (clist, NULL, row, clist_row);
+ GTK_CLIST_GET_CLASS (clist)->draw_row (clist, NULL, row, clist_row);
}
}
@@ -3728,38 +3728,38 @@ real_select_all (GtkCList *clist)
{
GList *list;
gint i;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (gdk_pointer_is_grabbed () && GTK_WIDGET_HAS_GRAB (clist))
return;
-
+
switch (clist->selection_mode)
{
case GTK_SELECTION_SINGLE:
case GTK_SELECTION_BROWSE:
return;
-
+
case GTK_SELECTION_EXTENDED:
g_list_free (clist->undo_selection);
g_list_free (clist->undo_unselection);
clist->undo_selection = NULL;
clist->undo_unselection = NULL;
-
+
if (clist->rows &&
((GtkCListRow *) (clist->row_list->data))->state !=
GTK_STATE_SELECTED)
fake_toggle_row (clist, 0);
-
+
clist->anchor_state = GTK_STATE_SELECTED;
clist->anchor = 0;
clist->drag_pos = 0;
clist->undo_anchor = clist->focus_row;
update_extended_selection (clist, clist->rows);
- GTK_CLIST_CLASS_FW (clist)->resync_selection (clist, NULL);
+ GTK_CLIST_GET_CLASS (clist)->resync_selection (clist, NULL);
return;
-
+
case GTK_SELECTION_MULTIPLE:
for (i = 0, list = clist->row_list; list; i++, list = list->next)
{
@@ -3776,13 +3776,13 @@ real_unselect_all (GtkCList *clist)
{
GList *list;
gint i;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (gdk_pointer_is_grabbed () && GTK_WIDGET_HAS_GRAB (clist))
return;
-
+
switch (clist->selection_mode)
{
case GTK_SELECTION_BROWSE:
@@ -3799,7 +3799,7 @@ real_unselect_all (GtkCList *clist)
g_list_free (clist->undo_unselection);
clist->undo_selection = NULL;
clist->undo_unselection = NULL;
-
+
clist->anchor = -1;
clist->drag_pos = -1;
clist->undo_anchor = clist->focus_row;
@@ -3807,7 +3807,7 @@ real_unselect_all (GtkCList *clist)
default:
break;
}
-
+
list = clist->selection;
while (list)
{
@@ -3825,7 +3825,7 @@ fake_unselect_all (GtkCList *clist,
GList *list;
GList *work;
gint i;
-
+
if (row >= 0 && (work = ROW_ELEMENT (clist, row)))
{
if (GTK_CLIST_ROW (work)->state == GTK_STATE_NORMAL &&
@@ -3835,26 +3835,26 @@ fake_unselect_all (GtkCList *clist,
if (CLIST_UNFROZEN (clist) &&
gtk_clist_row_is_visible (clist, row) != GTK_VISIBILITY_NONE)
- GTK_CLIST_CLASS_FW (clist)->draw_row (clist, NULL, row,
- GTK_CLIST_ROW (work));
+ GTK_CLIST_GET_CLASS (clist)->draw_row (clist, NULL, row,
+ GTK_CLIST_ROW (work));
}
}
-
+
clist->undo_selection = clist->selection;
clist->selection = NULL;
clist->selection_end = NULL;
-
+
for (list = clist->undo_selection; list; list = list->next)
{
if ((i = GPOINTER_TO_INT (list->data)) == row ||
!(work = g_list_nth (clist->row_list, i)))
continue;
-
+
GTK_CLIST_ROW (work)->state = GTK_STATE_NORMAL;
if (CLIST_UNFROZEN (clist) &&
gtk_clist_row_is_visible (clist, i) != GTK_VISIBILITY_NONE)
- GTK_CLIST_CLASS_FW (clist)->draw_row (clist, NULL, i,
- GTK_CLIST_ROW (work));
+ GTK_CLIST_GET_CLASS (clist)->draw_row (clist, NULL, i,
+ GTK_CLIST_ROW (work));
}
}
@@ -3862,33 +3862,33 @@ static void
real_undo_selection (GtkCList *clist)
{
GList *work;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if ((gdk_pointer_is_grabbed () && GTK_WIDGET_HAS_GRAB (clist)) ||
clist->selection_mode != GTK_SELECTION_EXTENDED)
return;
-
- GTK_CLIST_CLASS_FW (clist)->resync_selection (clist, NULL);
-
+
+ GTK_CLIST_GET_CLASS (clist)->resync_selection (clist, NULL);
+
if (!(clist->undo_selection || clist->undo_unselection))
{
gtk_clist_unselect_all (clist);
return;
}
-
+
for (work = clist->undo_selection; work; work = work->next)
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[SELECT_ROW],
GPOINTER_TO_INT (work->data), -1, NULL);
-
+
for (work = clist->undo_unselection; work; work = work->next)
{
/* g_print ("unselect %d\n",GPOINTER_TO_INT (work->data)); */
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[UNSELECT_ROW],
GPOINTER_TO_INT (work->data), -1, NULL);
}
-
+
if (GTK_WIDGET_HAS_FOCUS(clist) && clist->focus_row != clist->undo_anchor)
{
gtk_clist_draw_focus (GTK_WIDGET (clist));
@@ -3899,12 +3899,12 @@ real_undo_selection (GtkCList *clist)
clist->focus_row = clist->undo_anchor;
clist->undo_anchor = -1;
-
+
g_list_free (clist->undo_selection);
g_list_free (clist->undo_unselection);
clist->undo_selection = NULL;
clist->undo_unselection = NULL;
-
+
if (ROW_TOP_YPIXEL (clist, clist->focus_row) + clist->row_height >
clist->clist_window_height)
gtk_clist_moveto (clist, clist->focus_row, -1, 1, 0);
@@ -3923,20 +3923,20 @@ set_anchor (GtkCList *clist,
if (clist->selection_mode != GTK_SELECTION_EXTENDED || clist->anchor >= 0)
return;
-
+
g_list_free (clist->undo_selection);
g_list_free (clist->undo_unselection);
clist->undo_selection = NULL;
clist->undo_unselection = NULL;
-
+
if (add_mode)
fake_toggle_row (clist, anchor);
else
{
- GTK_CLIST_CLASS_FW (clist)->fake_unselect_all (clist, anchor);
+ GTK_CLIST_GET_CLASS (clist)->fake_unselect_all (clist, anchor);
clist->anchor_state = GTK_STATE_SELECTED;
}
-
+
clist->anchor = anchor;
clist->drag_pos = anchor;
clist->undo_anchor = undo_anchor;
@@ -3951,18 +3951,18 @@ resync_selection (GtkCList *clist,
gint row;
GList *list;
GtkCListRow *clist_row;
-
+
if (clist->selection_mode != GTK_SELECTION_EXTENDED)
return;
-
+
if (clist->anchor < 0 || clist->drag_pos < 0)
return;
-
+
gtk_clist_freeze (clist);
-
+
i = MIN (clist->anchor, clist->drag_pos);
e = MAX (clist->anchor, clist->drag_pos);
-
+
if (clist->undo_selection)
{
list = clist->selection;
@@ -3989,7 +3989,7 @@ resync_selection (GtkCList *clist,
}
}
}
-
+
if (clist->anchor < clist->drag_pos)
{
for (list = g_list_nth (clist->row_list, i); i <= e;
@@ -4051,10 +4051,10 @@ resync_selection (GtkCList *clist,
for (list = clist->undo_unselection; list; list = list->next)
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[SELECT_ROW],
GPOINTER_TO_INT (list->data), -1, event);
-
+
clist->anchor = -1;
clist->drag_pos = -1;
-
+
gtk_clist_thaw (clist);
}
@@ -4074,15 +4074,15 @@ update_extended_selection (GtkCList *clist,
gint h1 = 0;
gint h2 = 0;
gint top;
-
+
if (clist->selection_mode != GTK_SELECTION_EXTENDED || clist->anchor == -1)
return;
-
+
if (row < 0)
row = 0;
if (row >= clist->rows)
row = clist->rows - 1;
-
+
/* extending downwards */
if (row > clist->drag_pos && clist->anchor <= clist->drag_pos)
{
@@ -4127,12 +4127,12 @@ update_extended_selection (GtkCList *clist,
else
e1 = row - 1;
}
-
+
clist->drag_pos = row;
-
+
area.x = 0;
area.width = clist->clist_window_width;
-
+
/* restore the elements between s1 and e1 */
if (s1 >= 0)
{
@@ -4140,14 +4140,14 @@ update_extended_selection (GtkCList *clist,
i++, list = list->next)
if (GTK_CLIST_ROW (list)->selectable)
{
- if (GTK_CLIST_CLASS_FW (clist)->selection_find (clist, i, list))
+ if (GTK_CLIST_GET_CLASS (clist)->selection_find (clist, i, list))
GTK_CLIST_ROW (list)->state = GTK_STATE_SELECTED;
else
GTK_CLIST_ROW (list)->state = GTK_STATE_NORMAL;
}
-
+
top = ROW_TOP_YPIXEL (clist, clist->focus_row);
-
+
if (top + clist->row_height <= 0)
{
area.y = 0;
@@ -4166,11 +4166,11 @@ update_extended_selection (GtkCList *clist,
gtk_clist_moveto (clist, clist->focus_row, -1, 0, 0);
else if (top + clist->row_height > clist->clist_window_height)
gtk_clist_moveto (clist, clist->focus_row, -1, 1, 0);
-
+
y1 = ROW_TOP_YPIXEL (clist, s1) - 1;
h1 = (e1 - s1 + 1) * (clist->row_height + CELL_SPACING);
}
-
+
/* extend the selection between s2 and e2 */
if (s2 >= 0)
{
@@ -4179,9 +4179,9 @@ update_extended_selection (GtkCList *clist,
if (GTK_CLIST_ROW (list)->selectable &&
GTK_CLIST_ROW (list)->state != clist->anchor_state)
GTK_CLIST_ROW (list)->state = clist->anchor_state;
-
+
top = ROW_TOP_YPIXEL (clist, clist->focus_row);
-
+
if (top + clist->row_height <= 0)
{
area.y = 0;
@@ -4200,11 +4200,11 @@ update_extended_selection (GtkCList *clist,
gtk_clist_moveto (clist, clist->focus_row, -1, 0, 0);
else if (top + clist->row_height > clist->clist_window_height)
gtk_clist_moveto (clist, clist->focus_row, -1, 1, 0);
-
+
y2 = ROW_TOP_YPIXEL (clist, s2) - 1;
h2 = (e2 - s2 + 1) * (clist->row_height + CELL_SPACING);
}
-
+
area.y = MAX (0, MIN (y1, y2));
if (area.y > clist->clist_window_height)
area.y = 0;
@@ -4219,10 +4219,10 @@ start_selection (GtkCList *clist)
{
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (gdk_pointer_is_grabbed () && GTK_WIDGET_HAS_GRAB (clist))
return;
-
+
set_anchor (clist, GTK_CLIST_ADD_MODE(clist), clist->focus_row,
clist->focus_row);
}
@@ -4232,11 +4232,11 @@ end_selection (GtkCList *clist)
{
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (gdk_pointer_is_grabbed () && GTK_WIDGET_HAS_FOCUS(clist))
return;
-
- GTK_CLIST_CLASS_FW (clist)->resync_selection (clist, NULL);
+
+ GTK_CLIST_GET_CLASS (clist)->resync_selection (clist, NULL);
}
static void
@@ -4247,25 +4247,25 @@ extend_selection (GtkCList *clist,
{
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if ((gdk_pointer_is_grabbed () && GTK_WIDGET_HAS_GRAB (clist)) ||
clist->selection_mode != GTK_SELECTION_EXTENDED)
return;
-
+
if (auto_start_selection)
set_anchor (clist, GTK_CLIST_ADD_MODE(clist), clist->focus_row,
clist->focus_row);
else if (clist->anchor == -1)
return;
-
+
move_focus_row (clist, scroll_type, position);
-
+
if (ROW_TOP_YPIXEL (clist, clist->focus_row) + clist->row_height >
clist->clist_window_height)
gtk_clist_moveto (clist, clist->focus_row, -1, 1, 0);
else if (ROW_TOP_YPIXEL (clist, clist->focus_row) < 0)
gtk_clist_moveto (clist, clist->focus_row, -1, 0, 0);
-
+
update_extended_selection (clist, clist->focus_row);
}
@@ -4276,12 +4276,12 @@ sync_selection (GtkCList *clist,
{
GList *list;
gint d;
-
+
if (mode == SYNC_INSERT)
d = 1;
else
d = -1;
-
+
if (clist->focus_row >= row)
{
if (d > 0 || clist->focus_row > row)
@@ -4291,20 +4291,20 @@ sync_selection (GtkCList *clist,
else if (clist->focus_row >= clist->rows)
clist->focus_row = clist->rows - 1;
}
-
- GTK_CLIST_CLASS_FW (clist)->resync_selection (clist, NULL);
-
+
+ GTK_CLIST_GET_CLASS (clist)->resync_selection (clist, NULL);
+
g_list_free (clist->undo_selection);
g_list_free (clist->undo_unselection);
clist->undo_selection = NULL;
clist->undo_unselection = NULL;
-
+
clist->anchor = -1;
clist->drag_pos = -1;
clist->undo_anchor = clist->focus_row;
-
+
list = clist->selection;
-
+
while (list)
{
if (GPOINTER_TO_INT (list->data) >= row)
@@ -4322,25 +4322,25 @@ gtk_clist_destroy (GtkObject *object)
{
gint i;
GtkCList *clist;
-
+
g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_CLIST (object));
-
+
clist = GTK_CLIST (object);
-
+
/* freeze the list */
clist->freeze_count++;
-
+
/* get rid of all the rows */
gtk_clist_clear (clist);
-
+
/* Since we don't have a _remove method, unparent the children
* instead of destroying them so the focus will be unset properly.
* (For other containers, the _remove method takes care of the
* unparent) The destroy will happen when the refcount drops
* to zero.
*/
-
+
/* unref adjustments */
if (clist->hadjustment)
{
@@ -4354,9 +4354,9 @@ gtk_clist_destroy (GtkObject *object)
gtk_object_unref (GTK_OBJECT (clist->vadjustment));
clist->vadjustment = NULL;
}
-
+
remove_grab (clist);
-
+
/* destroy the column buttons */
for (i = 0; i < clist->columns; i++)
if (clist->column[i].button)
@@ -4364,28 +4364,26 @@ gtk_clist_destroy (GtkObject *object)
gtk_widget_unparent (clist->column[i].button);
clist->column[i].button = NULL;
}
-
+
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(*GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
static void
-gtk_clist_finalize (GtkObject *object)
+gtk_clist_finalize (GObject *object)
{
GtkCList *clist;
-
- g_return_if_fail (object != NULL);
+
g_return_if_fail (GTK_IS_CLIST (object));
-
+
clist = GTK_CLIST (object);
-
+
columns_delete (clist);
-
+
g_mem_chunk_destroy (clist->cell_mem_chunk);
g_mem_chunk_destroy (clist->row_mem_chunk);
-
- if (GTK_OBJECT_CLASS (parent_class)->finalize)
- (*GTK_OBJECT_CLASS (parent_class)->finalize) (object);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
/* GTKWIDGET
@@ -4415,14 +4413,14 @@ gtk_clist_realize (GtkWidget *widget)
gint border_width;
gint i;
gint j;
-
+
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_CLIST (widget));
-
+
clist = GTK_CLIST (widget);
-
+
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
-
+
border_width = GTK_CONTAINER (widget)->border_width;
attributes.window_type = GDK_WINDOW_CHILD;
@@ -4440,18 +4438,18 @@ gtk_clist_realize (GtkWidget *widget)
GDK_KEY_PRESS_MASK |
GDK_KEY_RELEASE_MASK);
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
-
+
/* main window */
widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
&attributes, attributes_mask);
gdk_window_set_user_data (widget->window, clist);
-
+
widget->style = gtk_style_attach (widget->style, widget->window);
-
+
gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
-
+
/* column-title window */
-
+
attributes.x = clist->column_title_area.x;
attributes.y = clist->column_title_area.y;
attributes.width = clist->column_title_area.width;
@@ -4460,17 +4458,17 @@ gtk_clist_realize (GtkWidget *widget)
clist->title_window = gdk_window_new (widget->window, &attributes,
attributes_mask);
gdk_window_set_user_data (clist->title_window, clist);
-
+
gtk_style_set_background (widget->style, clist->title_window,
GTK_STATE_NORMAL);
gdk_window_show (clist->title_window);
-
+
/* set things up so column buttons are drawn in title window */
for (i = 0; i < clist->columns; i++)
if (clist->column[i].button)
gtk_widget_set_parent_window (clist->column[i].button,
clist->title_window);
-
+
/* clist-window */
attributes.x = (clist->internal_allocation.x +
widget->style->klass->xthickness);
@@ -4483,13 +4481,13 @@ gtk_clist_realize (GtkWidget *widget)
clist->clist_window = gdk_window_new (widget->window, &attributes,
attributes_mask);
gdk_window_set_user_data (clist->clist_window, clist);
-
+
gdk_window_set_background (clist->clist_window,
&widget->style->base[GTK_STATE_NORMAL]);
gdk_window_show (clist->clist_window);
gdk_window_get_size (clist->clist_window, &clist->clist_window_width,
&clist->clist_window_height);
-
+
/* create resize windows */
attributes.wclass = GDK_INPUT_ONLY;
attributes.event_mask = (GDK_BUTTON_PRESS_MASK |
@@ -4500,31 +4498,31 @@ gtk_clist_realize (GtkWidget *widget)
attributes_mask = GDK_WA_CURSOR;
attributes.cursor = gdk_cursor_new (GDK_SB_H_DOUBLE_ARROW);
clist->cursor_drag = attributes.cursor;
-
+
attributes.x = LIST_WIDTH (clist) + 1;
attributes.y = 0;
attributes.width = 0;
attributes.height = 0;
-
+
for (i = 0; i < clist->columns; i++)
{
clist->column[i].window = gdk_window_new (clist->title_window,
&attributes, attributes_mask);
gdk_window_set_user_data (clist->column[i].window, clist);
}
-
+
/* This is slightly less efficient than creating them with the
* right size to begin with, but easier
*/
size_allocate_title_buttons (clist);
-
+
/* GCs */
clist->fg_gc = gdk_gc_new (widget->window);
clist->bg_gc = gdk_gc_new (widget->window);
/* We'll use this gc to do scrolling as well */
gdk_gc_set_exposures (clist->fg_gc, TRUE);
-
+
values.foreground = (widget->style->white.pixel==0 ?
widget->style->black:widget->style->white);
values.function = GDK_XOR;
@@ -4534,22 +4532,22 @@ gtk_clist_realize (GtkWidget *widget)
GDK_GC_FOREGROUND |
GDK_GC_FUNCTION |
GDK_GC_SUBWINDOW);
-
+
/* attach optional row/cell styles, allocate foreground/background colors */
list = clist->row_list;
for (i = 0; i < clist->rows; i++)
{
clist_row = list->data;
list = list->next;
-
+
if (clist_row->style)
clist_row->style = gtk_style_attach (clist_row->style,
clist->clist_window);
-
+
if (clist_row->fg_set || clist_row->bg_set)
{
GdkColormap *colormap;
-
+
colormap = gtk_widget_get_colormap (widget);
if (clist_row->fg_set)
gdk_color_alloc (colormap, &clist_row->foreground);
@@ -4569,33 +4567,33 @@ gtk_clist_unrealize (GtkWidget *widget)
{
gint i;
GtkCList *clist;
-
+
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_CLIST (widget));
-
+
clist = GTK_CLIST (widget);
-
+
/* freeze the list */
clist->freeze_count++;
-
+
if (GTK_WIDGET_MAPPED (widget))
gtk_clist_unmap (widget);
-
+
GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
-
+
/* detach optional row/cell styles */
if (GTK_WIDGET_REALIZED (widget))
{
GtkCListRow *clist_row;
GList *list;
gint j;
-
+
list = clist->row_list;
for (i = 0; i < clist->rows; i++)
{
clist_row = list->data;
list = list->next;
-
+
if (clist_row->style)
gtk_style_detach (clist_row->style);
for (j = 0; j < clist->columns; j++)
@@ -4603,12 +4601,12 @@ gtk_clist_unrealize (GtkWidget *widget)
gtk_style_detach (clist_row->cell[j].style);
}
}
-
+
gdk_cursor_destroy (clist->cursor_drag);
gdk_gc_destroy (clist->xor_gc);
gdk_gc_destroy (clist->fg_gc);
gdk_gc_destroy (clist->bg_gc);
-
+
for (i = 0; i < clist->columns; i++)
{
if (clist->column[i].button)
@@ -4620,20 +4618,20 @@ gtk_clist_unrealize (GtkWidget *widget)
clist->column[i].window = NULL;
}
}
-
+
gdk_window_set_user_data (clist->clist_window, NULL);
gdk_window_destroy (clist->clist_window);
clist->clist_window = NULL;
-
+
gdk_window_set_user_data (clist->title_window, NULL);
gdk_window_destroy (clist->title_window);
clist->title_window = NULL;
-
+
clist->cursor_drag = NULL;
clist->xor_gc = NULL;
clist->fg_gc = NULL;
clist->bg_gc = NULL;
-
+
if (GTK_WIDGET_CLASS (parent_class)->unrealize)
(* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
}
@@ -4643,16 +4641,16 @@ gtk_clist_map (GtkWidget *widget)
{
gint i;
GtkCList *clist;
-
+
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_CLIST (widget));
-
+
clist = GTK_CLIST (widget);
-
+
if (!GTK_WIDGET_MAPPED (widget))
{
GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
-
+
/* map column buttons */
for (i = 0; i < clist->columns; i++)
{
@@ -4668,11 +4666,11 @@ gtk_clist_map (GtkWidget *widget)
gdk_window_raise (clist->column[i].window);
gdk_window_show (clist->column[i].window);
}
-
+
gdk_window_show (clist->title_window);
gdk_window_show (clist->clist_window);
gdk_window_show (widget->window);
-
+
/* unfreeze the list */
clist->freeze_count = 0;
}
@@ -4683,30 +4681,30 @@ gtk_clist_unmap (GtkWidget *widget)
{
gint i;
GtkCList *clist;
-
+
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_CLIST (widget));
-
+
clist = GTK_CLIST (widget);
-
+
if (GTK_WIDGET_MAPPED (widget))
{
GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
-
+
if (gdk_pointer_is_grabbed () && GTK_WIDGET_HAS_GRAB (clist))
{
remove_grab (clist);
-
- GTK_CLIST_CLASS_FW (widget)->resync_selection (clist, NULL);
-
+
+ GTK_CLIST_GET_CLASS (widget)->resync_selection (clist, NULL);
+
clist->click_cell.row = -1;
clist->click_cell.column = -1;
clist->drag_button = 0;
-
+
if (GTK_CLIST_IN_DRAG(clist))
{
gpointer drag_data;
-
+
GTK_CLIST_UNSET_FLAG (clist, CLIST_IN_DRAG);
drag_data = gtk_object_get_data (GTK_OBJECT (clist),
"gtk-site-data");
@@ -4715,21 +4713,21 @@ gtk_clist_unmap (GtkWidget *widget)
drag_data);
}
}
-
+
for (i = 0; i < clist->columns; i++)
if (clist->column[i].window)
gdk_window_hide (clist->column[i].window);
-
+
gdk_window_hide (clist->clist_window);
gdk_window_hide (clist->title_window);
gdk_window_hide (widget->window);
-
+
/* unmap column buttons */
for (i = 0; i < clist->columns; i++)
if (clist->column[i].button &&
GTK_WIDGET_MAPPED (clist->column[i].button))
gtk_widget_unmap (clist->column[i].button);
-
+
/* freeze the list */
clist->freeze_count++;
}
@@ -4743,21 +4741,21 @@ gtk_clist_draw (GtkWidget *widget,
gint border_width;
GdkRectangle child_area;
int i;
-
+
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_CLIST (widget));
g_return_if_fail (area != NULL);
-
+
if (GTK_WIDGET_DRAWABLE (widget))
{
clist = GTK_CLIST (widget);
border_width = GTK_CONTAINER (widget)->border_width;
-
+
gdk_window_clear_area (widget->window,
area->x - border_width,
area->y - border_width,
area->width, area->height);
-
+
/* draw list shadow/border */
gtk_draw_shadow (widget->style, widget->window,
GTK_STATE_NORMAL, clist->shadow_type,
@@ -4767,10 +4765,10 @@ gtk_clist_draw (GtkWidget *widget,
clist->clist_window_height +
(2 * widget->style->klass->ythickness) +
clist->column_title_area.height);
-
+
gdk_window_clear_area (clist->clist_window, 0, 0, 0, 0);
draw_rows (clist, NULL);
-
+
for (i = 0; i < clist->columns; i++)
{
if (!clist->column[i].visible)
@@ -4787,15 +4785,15 @@ gtk_clist_expose (GtkWidget *widget,
GdkEventExpose *event)
{
GtkCList *clist;
-
+
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_CLIST (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
-
+
if (GTK_WIDGET_DRAWABLE (widget))
{
clist = GTK_CLIST (widget);
-
+
/* draw border */
if (event->window == widget->window)
gtk_draw_shadow (widget->style, widget->window,
@@ -4806,12 +4804,12 @@ gtk_clist_expose (GtkWidget *widget,
clist->clist_window_height +
(2 * widget->style->klass->ythickness) +
clist->column_title_area.height);
-
+
/* exposure events on the list */
if (event->window == clist->clist_window)
draw_rows (clist, &event->area);
}
-
+
return FALSE;
}
@@ -4820,24 +4818,24 @@ gtk_clist_style_set (GtkWidget *widget,
GtkStyle *previous_style)
{
GtkCList *clist;
-
+
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_CLIST (widget));
-
+
if (GTK_WIDGET_CLASS (parent_class)->style_set)
(*GTK_WIDGET_CLASS (parent_class)->style_set) (widget, previous_style);
-
+
clist = GTK_CLIST (widget);
-
+
if (GTK_WIDGET_REALIZED (widget))
{
gtk_style_set_background (widget->style, widget->window, widget->state);
gtk_style_set_background (widget->style, clist->title_window, GTK_STATE_SELECTED);
gdk_window_set_background (clist->clist_window, &widget->style->base[GTK_STATE_NORMAL]);
}
-
+
/* Fill in data after widget has correct style */
-
+
/* text properties */
if (!GTK_CLIST_ROW_HEIGHT_SET(clist))
{
@@ -4849,13 +4847,13 @@ gtk_clist_style_set (GtkWidget *widget,
clist->row_center_offset = 1.5 + (clist->row_height +
widget->style->font->ascent -
widget->style->font->descent - 1) / 2;
-
+
/* Column widths */
if (!GTK_CLIST_AUTO_RESIZE_BLOCKED(clist))
{
gint width;
gint i;
-
+
for (i = 0; i < clist->columns; i++)
if (clist->column[i].auto_resize)
{
@@ -4873,11 +4871,11 @@ gtk_clist_key_press (GtkWidget *widget,
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_CLIST (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
-
+
if (GTK_WIDGET_CLASS (parent_class)->key_press_event &&
GTK_WIDGET_CLASS (parent_class)->key_press_event (widget, event))
return TRUE;
-
+
switch (event->keyval)
{
case GDK_Tab:
@@ -4905,42 +4903,42 @@ gtk_clist_button_press (GtkWidget *widget,
gint row;
gint column;
gint button_actions;
-
+
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_CLIST (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
-
+
clist = GTK_CLIST (widget);
-
+
button_actions = clist->button_actions[event->button - 1];
-
+
if (button_actions == GTK_BUTTON_IGNORED)
return FALSE;
-
+
/* selections on the list */
if (event->window == clist->clist_window)
{
x = event->x;
y = event->y;
-
+
if (get_selection_info (clist, x, y, &row, &column))
{
gint old_row = clist->focus_row;
-
+
if (clist->focus_row == -1)
old_row = row;
-
+
if (event->type == GDK_BUTTON_PRESS)
{
GdkEventMask mask = ((1 << (4 + event->button)) |
GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_RELEASE_MASK);
-
+
if (gdk_pointer_grab (clist->clist_window, FALSE, mask,
NULL, NULL, event->time))
return FALSE;
gtk_grab_add (widget);
-
+
clist->click_cell.row = row;
clist->click_cell.column = column;
clist->drag_button = event->button;
@@ -4949,11 +4947,11 @@ gtk_clist_button_press (GtkWidget *widget,
{
clist->click_cell.row = -1;
clist->click_cell.column = -1;
-
+
clist->drag_button = 0;
remove_grab (clist);
}
-
+
if (button_actions & GTK_BUTTON_SELECTS)
{
if (GTK_CLIST_ADD_MODE(clist))
@@ -4986,10 +4984,10 @@ gtk_clist_button_press (GtkWidget *widget,
clist->focus_row = row;
}
}
-
+
if (!GTK_WIDGET_HAS_FOCUS(widget))
gtk_widget_grab_focus (widget);
-
+
if (button_actions & GTK_BUTTON_SELECTS)
{
switch (clist->selection_mode)
@@ -5017,7 +5015,7 @@ gtk_clist_button_press (GtkWidget *widget,
if (clist->anchor != -1)
{
update_extended_selection (clist, clist->focus_row);
- GTK_CLIST_CLASS_FW (clist)->resync_selection
+ GTK_CLIST_GET_CLASS (clist)->resync_selection
(clist, (GdkEvent *) event);
}
gtk_signal_emit (GTK_OBJECT (clist),
@@ -5025,7 +5023,7 @@ gtk_clist_button_press (GtkWidget *widget,
row, column, event);
break;
}
-
+
if (event->state & GDK_CONTROL_MASK)
{
if (event->state & GDK_SHIFT_MASK)
@@ -5052,14 +5050,14 @@ gtk_clist_button_press (GtkWidget *widget,
}
break;
}
-
+
if (event->state & GDK_SHIFT_MASK)
{
set_anchor (clist, FALSE, old_row, old_row);
update_extended_selection (clist, clist->focus_row);
break;
}
-
+
if (clist->anchor == -1)
set_anchor (clist, FALSE, row, old_row);
else
@@ -5072,36 +5070,36 @@ gtk_clist_button_press (GtkWidget *widget,
}
return FALSE;
}
-
+
/* press on resize windows */
for (i = 0; i < clist->columns; i++)
if (clist->column[i].resizeable && clist->column[i].window &&
event->window == clist->column[i].window)
{
gpointer drag_data;
-
+
if (gdk_pointer_grab (clist->column[i].window, FALSE,
GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON1_MOTION_MASK |
GDK_BUTTON_RELEASE_MASK,
NULL, NULL, event->time))
return FALSE;
-
+
gtk_grab_add (widget);
GTK_CLIST_SET_FLAG (clist, CLIST_IN_DRAG);
-
+
/* block attached dnd signal handler */
drag_data = gtk_object_get_data (GTK_OBJECT (clist), "gtk-site-data");
if (drag_data)
gtk_signal_handler_block_by_data (GTK_OBJECT (clist), drag_data);
-
+
if (!GTK_WIDGET_HAS_FOCUS(widget))
gtk_widget_grab_focus (widget);
-
+
clist->drag_pos = i;
clist->x_drag = (COLUMN_LEFT_XPIXEL(clist, i) + COLUMN_INSET +
clist->column[i].area.width + CELL_SPACING);
-
+
if (GTK_CLIST_ADD_MODE(clist))
gdk_gc_set_line_attributes (clist->xor_gc, 1, GDK_LINE_SOLID, 0, 0);
draw_xor_line (clist);
@@ -5115,17 +5113,17 @@ gtk_clist_button_release (GtkWidget *widget,
{
GtkCList *clist;
gint button_actions;
-
+
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_CLIST (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
-
+
clist = GTK_CLIST (widget);
-
+
button_actions = clist->button_actions[event->button - 1];
if (button_actions == GTK_BUTTON_IGNORED)
return FALSE;
-
+
/* release on resize windows */
if (GTK_CLIST_IN_DRAG(clist))
{
@@ -5133,46 +5131,46 @@ gtk_clist_button_release (GtkWidget *widget,
gint width;
gint x;
gint i;
-
+
i = clist->drag_pos;
clist->drag_pos = -1;
-
+
/* unblock attached dnd signal handler */
drag_data = gtk_object_get_data (GTK_OBJECT (clist), "gtk-site-data");
if (drag_data)
gtk_signal_handler_unblock_by_data (GTK_OBJECT (clist), drag_data);
-
+
GTK_CLIST_UNSET_FLAG (clist, CLIST_IN_DRAG);
gtk_widget_get_pointer (widget, &x, NULL);
gtk_grab_remove (widget);
gdk_pointer_ungrab (event->time);
-
+
if (clist->x_drag >= 0)
draw_xor_line (clist);
-
+
if (GTK_CLIST_ADD_MODE(clist))
{
gdk_gc_set_line_attributes (clist->xor_gc, 1,
GDK_LINE_ON_OFF_DASH, 0, 0);
gdk_gc_set_dashes (clist->xor_gc, 0, "\4\4", 2);
}
-
+
width = new_column_width (clist, i, &x);
gtk_clist_set_column_width (clist, i, width);
return FALSE;
}
-
+
if (clist->drag_button == event->button)
{
gint row;
gint column;
-
+
clist->drag_button = 0;
clist->click_cell.row = -1;
clist->click_cell.column = -1;
-
+
remove_grab (clist);
-
+
if (button_actions & GTK_BUTTON_SELECTS)
{
switch (clist->selection_mode)
@@ -5182,7 +5180,7 @@ gtk_clist_button_release (GtkWidget *widget,
!GTK_WIDGET_CAN_FOCUS (widget) ||
event->x < 0 || event->x >= clist->clist_window_width ||
event->y < 0 || event->y >= clist->clist_window_height)
- GTK_CLIST_CLASS_FW (clist)->resync_selection
+ GTK_CLIST_GET_CLASS (clist)->resync_selection
(clist, (GdkEvent *) event);
break;
case GTK_SELECTION_SINGLE:
@@ -5213,17 +5211,17 @@ gtk_clist_motion (GtkWidget *widget,
gint row;
gint new_width;
gint button_actions = 0;
-
+
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_CLIST (widget), FALSE);
-
+
clist = GTK_CLIST (widget);
if (!(gdk_pointer_is_grabbed () && GTK_WIDGET_HAS_GRAB (clist)))
return FALSE;
-
+
if (clist->drag_button > 0)
button_actions = clist->button_actions[clist->drag_button - 1];
-
+
if (GTK_CLIST_IN_DRAG(clist))
{
if (event->is_hint || event->window != widget->window)
@@ -5237,13 +5235,13 @@ gtk_clist_motion (GtkWidget *widget,
/* x_drag < 0 indicates that the xor line is already invisible */
if (clist->x_drag >= 0)
draw_xor_line (clist);
-
+
clist->x_drag = x;
-
+
if (clist->x_drag >= 0)
draw_xor_line (clist);
}
-
+
if (new_width <= MAX (COLUMN_MIN_WIDTH + 1,
clist->column[clist->drag_pos].min_width + 1))
{
@@ -5263,7 +5261,7 @@ gtk_clist_motion (GtkWidget *widget,
return FALSE;
}
}
-
+
if (event->is_hint || event->window != clist->clist_window)
gdk_window_get_pointer (clist->clist_window, &x, &y, NULL);
else
@@ -5271,7 +5269,7 @@ gtk_clist_motion (GtkWidget *widget,
x = event->x;
y = event->y;
}
-
+
if (GTK_CLIST_REORDERABLE(clist) && button_actions & GTK_BUTTON_DRAGS)
{
/* delayed drag start */
@@ -5287,25 +5285,25 @@ gtk_clist_motion (GtkWidget *widget,
clist->column[clist->click_cell.column].area.width)))
{
GtkTargetList *target_list;
-
+
target_list = gtk_target_list_new (&clist_target_table, 1);
gtk_drag_begin (widget, target_list, GDK_ACTION_MOVE,
clist->drag_button, (GdkEvent *)event);
-
+
}
return TRUE;
}
-
+
/* horizontal autoscrolling */
if (clist->hadjustment && LIST_WIDTH (clist) > clist->clist_window_width &&
(x < 0 || x >= clist->clist_window_width))
{
if (clist->htimer)
return FALSE;
-
+
clist->htimer = gtk_timeout_add
(SCROLL_TIME, (GtkFunction) horizontal_timeout, clist);
-
+
if (!((x < 0 && clist->hadjustment->value == 0) ||
(x >= clist->clist_window_width &&
clist->hadjustment->value ==
@@ -5317,46 +5315,46 @@ gtk_clist_motion (GtkWidget *widget,
move_horizontal (clist, 1 + (x - clist->clist_window_width) / 2);
}
}
-
+
if (GTK_CLIST_IN_DRAG(clist))
return FALSE;
-
+
/* vertical autoscrolling */
row = ROW_FROM_YPIXEL (clist, y);
-
+
/* don't scroll on last pixel row if it's a cell spacing */
if (y == clist->clist_window_height - 1 &&
y == ROW_TOP_YPIXEL (clist, row-1) + clist->row_height)
return FALSE;
-
+
if (LIST_HEIGHT (clist) > clist->clist_window_height &&
(y < 0 || y >= clist->clist_window_height))
{
if (clist->vtimer)
return FALSE;
-
+
clist->vtimer = gtk_timeout_add (SCROLL_TIME,
(GtkFunction) vertical_timeout, clist);
-
+
if (clist->drag_button &&
((y < 0 && clist->focus_row == 0) ||
(y >= clist->clist_window_height &&
clist->focus_row == clist->rows - 1)))
return FALSE;
}
-
+
row = CLAMP (row, 0, clist->rows - 1);
-
+
if (button_actions & GTK_BUTTON_SELECTS &
!gtk_object_get_data (GTK_OBJECT (widget), "gtk-site-data"))
{
if (row == clist->focus_row)
return FALSE;
-
+
gtk_clist_draw_focus (widget);
clist->focus_row = row;
gtk_clist_draw_focus (widget);
-
+
switch (clist->selection_mode)
{
case GTK_SELECTION_BROWSE:
@@ -5376,7 +5374,7 @@ gtk_clist_motion (GtkWidget *widget,
else if (ROW_TOP_YPIXEL(clist, row) + clist->row_height >
clist->clist_window_height)
move_vertical (clist, row, 1);
-
+
return FALSE;
}
@@ -5386,16 +5384,16 @@ gtk_clist_size_request (GtkWidget *widget,
{
GtkCList *clist;
gint i;
-
+
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_CLIST (widget));
g_return_if_fail (requisition != NULL);
-
+
clist = GTK_CLIST (widget);
-
+
requisition->width = 0;
requisition->height = 0;
-
+
/* compute the size of the column title (title) area */
clist->column_title_area.height = 0;
if (GTK_CLIST_SHOW_TITLES(clist))
@@ -5410,13 +5408,13 @@ gtk_clist_size_request (GtkWidget *widget,
MAX (clist->column_title_area.height,
child_requisition.height);
}
-
+
requisition->width += (widget->style->klass->xthickness +
GTK_CONTAINER (widget)->border_width) * 2;
requisition->height += (clist->column_title_area.height +
(widget->style->klass->ythickness +
GTK_CONTAINER (widget)->border_width) * 2);
-
+
/* if (!clist->hadjustment) */
requisition->width += list_requisition_width (clist);
/* if (!clist->vadjustment) */
@@ -5430,15 +5428,15 @@ gtk_clist_size_allocate (GtkWidget *widget,
GtkCList *clist;
GtkAllocation clist_allocation;
gint border_width;
-
+
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_CLIST (widget));
g_return_if_fail (allocation != NULL);
-
+
clist = GTK_CLIST (widget);
widget->allocation = *allocation;
border_width = GTK_CONTAINER (widget)->border_width;
-
+
if (GTK_WIDGET_REALIZED (widget))
{
gdk_window_move_resize (widget->window,
@@ -5447,7 +5445,7 @@ gtk_clist_size_allocate (GtkWidget *widget,
allocation->width - border_width * 2,
allocation->height - border_width * 2);
}
-
+
/* use internal allocation structure for all the math
* because it's easier than always subtracting the container
* border width */
@@ -5457,7 +5455,7 @@ gtk_clist_size_allocate (GtkWidget *widget,
border_width * 2);
clist->internal_allocation.height = MAX (1, (gint)allocation->height -
border_width * 2);
-
+
/* allocate clist window assuming no scrollbars */
clist_allocation.x = (clist->internal_allocation.x +
widget->style->klass->xthickness);
@@ -5499,7 +5497,7 @@ gtk_clist_size_allocate (GtkWidget *widget,
/* column button allocation */
size_allocate_columns (clist, FALSE);
size_allocate_title_buttons (clist);
-
+
adjust_adjustments (clist, TRUE);
}
@@ -5514,16 +5512,16 @@ gtk_clist_forall (GtkContainer *container,
{
GtkCList *clist;
guint i;
-
+
g_return_if_fail (container != NULL);
g_return_if_fail (GTK_IS_CLIST (container));
g_return_if_fail (callback != NULL);
-
+
if (!include_internals)
return;
-
+
clist = GTK_CLIST (container);
-
+
/* callback for the column buttons */
for (i = 0; i < clist->columns; i++)
if (clist->column[i].button)
@@ -5548,13 +5546,13 @@ get_cell_style (GtkCList *clist,
GdkGC **bg_gc)
{
gint fg_state;
-
+
if ((state == GTK_STATE_NORMAL) &&
(GTK_WIDGET (clist)->state == GTK_STATE_INSENSITIVE))
fg_state = GTK_STATE_INSENSITIVE;
else
fg_state = state;
-
+
if (clist_row->cell[column].style)
{
if (style)
@@ -5593,7 +5591,7 @@ get_cell_style (GtkCList *clist,
else
*bg_gc = GTK_WIDGET (clist)->style->base_gc[state];
}
-
+
if (state != GTK_STATE_SELECTED)
{
if (fg_gc && clist_row->fg_set)
@@ -5617,13 +5615,13 @@ draw_cell_pixmap (GdkWindow *window,
{
gint xsrc = 0;
gint ysrc = 0;
-
+
if (mask)
{
gdk_gc_set_clip_mask (fg_gc, mask);
gdk_gc_set_clip_origin (fg_gc, x, y);
}
-
+
if (x < clip_rectangle->x)
{
xsrc = clip_rectangle->x - x;
@@ -5632,7 +5630,7 @@ draw_cell_pixmap (GdkWindow *window,
}
if (x + width > clip_rectangle->x + clip_rectangle->width)
width = clip_rectangle->x + clip_rectangle->width - x;
-
+
if (y < clip_rectangle->y)
{
ysrc = clip_rectangle->y - y;
@@ -5641,12 +5639,12 @@ draw_cell_pixmap (GdkWindow *window,
}
if (y + height > clip_rectangle->y + clip_rectangle->height)
height = clip_rectangle->y + clip_rectangle->height - y;
-
+
gdk_draw_pixmap (window, fg_gc, pixmap, xsrc, ysrc, x, y, width, height);
gdk_gc_set_clip_origin (fg_gc, 0, 0);
if (mask)
gdk_gc_set_clip_mask (fg_gc, NULL);
-
+
return x + MAX (width, 0);
}
@@ -5665,39 +5663,39 @@ draw_row (GtkCList *clist,
gint last_column;
gint state;
gint i;
-
+
g_return_if_fail (clist != NULL);
-
+
/* bail now if we arn't drawable yet */
if (!GTK_WIDGET_DRAWABLE (clist) || row < 0 || row >= clist->rows)
return;
-
+
widget = GTK_WIDGET (clist);
-
+
/* if the function is passed the pointer to the row instead of null,
* it avoids this expensive lookup */
if (!clist_row)
clist_row = ROW_ELEMENT (clist, row)->data;
-
+
/* rectangle of the entire row */
row_rectangle.x = 0;
row_rectangle.y = ROW_TOP_YPIXEL (clist, row);
row_rectangle.width = clist->clist_window_width;
row_rectangle.height = clist->row_height;
-
+
/* rectangle of the cell spacing above the row */
cell_rectangle.x = 0;
cell_rectangle.y = row_rectangle.y - CELL_SPACING;
cell_rectangle.width = row_rectangle.width;
cell_rectangle.height = CELL_SPACING;
-
+
/* rectangle used to clip drawing operations, its y and height
* positions only need to be set once, so we set them once here.
* the x and width are set withing the drawing loop below once per
* column */
clip_rectangle.y = row_rectangle.y;
clip_rectangle.height = row_rectangle.height;
-
+
if (clist_row->state == GTK_STATE_NORMAL)
{
if (clist_row->fg_set)
@@ -5705,9 +5703,9 @@ draw_row (GtkCList *clist,
if (clist_row->bg_set)
gdk_gc_set_foreground (clist->bg_gc, &clist_row->background);
}
-
+
state = clist_row->state;
-
+
/* draw the cell borders and background */
if (area)
{
@@ -5721,12 +5719,12 @@ draw_row (GtkCList *clist,
intersect_rectangle.y,
intersect_rectangle.width,
intersect_rectangle.height);
-
+
/* the last row has to clear its bottom cell spacing too */
if (clist_row == clist->row_list_end->data)
{
cell_rectangle.y += clist->row_height + CELL_SPACING;
-
+
if (gdk_rectangle_intersect (area, &cell_rectangle,
&intersect_rectangle))
gdk_draw_rectangle (clist->clist_window,
@@ -5737,10 +5735,10 @@ draw_row (GtkCList *clist,
intersect_rectangle.width,
intersect_rectangle.height);
}
-
+
if (!gdk_rectangle_intersect (area, &row_rectangle,&intersect_rectangle))
return;
-
+
}
else
{
@@ -5752,12 +5750,12 @@ draw_row (GtkCList *clist,
cell_rectangle.y,
cell_rectangle.width,
cell_rectangle.height);
-
+
/* the last row has to clear its bottom cell spacing too */
if (clist_row == clist->row_list_end->data)
{
cell_rectangle.y += clist->row_height + CELL_SPACING;
-
+
gdk_draw_rectangle (clist->clist_window,
widget->style->base_gc[GTK_STATE_ACTIVE],
TRUE,
@@ -5771,28 +5769,28 @@ draw_row (GtkCList *clist,
for (last_column = clist->columns - 1;
last_column >= 0 && !clist->column[last_column].visible; last_column--)
;
-
+
/* iterate and draw all the columns (row cells) and draw their contents */
for (i = 0; i < clist->columns; i++)
{
GtkStyle *style;
GdkGC *fg_gc;
GdkGC *bg_gc;
-
+
gint width;
gint height;
gint pixmap_width;
gint offset = 0;
gint row_center_offset;
-
+
if (!clist->column[i].visible)
continue;
-
+
get_cell_style (clist, clist_row, state, i, &style, &fg_gc, &bg_gc);
-
+
clip_rectangle.x = clist->column[i].area.x + clist->hoffset;
clip_rectangle.width = clist->column[i].area.width;
-
+
/* calculate clipping region clipping region */
clip_rectangle.x -= COLUMN_INSET + CELL_SPACING;
clip_rectangle.width += (2 * COLUMN_INSET + CELL_SPACING +
@@ -5801,14 +5799,14 @@ draw_row (GtkCList *clist,
if (area && !gdk_rectangle_intersect (area, &clip_rectangle,
&intersect_rectangle))
continue;
-
+
gdk_draw_rectangle (clist->clist_window, bg_gc, TRUE,
rect->x, rect->y, rect->width, rect->height);
-
+
clip_rectangle.x += COLUMN_INSET + CELL_SPACING;
clip_rectangle.width -= (2 * COLUMN_INSET + CELL_SPACING +
(i == last_column) * CELL_SPACING);
-
+
/* calculate real width for column justification */
pixmap_width = 0;
offset = 0;
@@ -5836,7 +5834,7 @@ draw_row (GtkCList *clist,
continue;
break;
}
-
+
switch (clist->column[i].justification)
{
case GTK_JUSTIFY_LEFT:
@@ -5852,7 +5850,7 @@ draw_row (GtkCList *clist,
(clip_rectangle.width / 2) - (width / 2));
break;
};
-
+
/* Draw Text and/or Pixmap */
switch (clist_row->cell[i].type)
{
@@ -5878,11 +5876,11 @@ draw_row (GtkCList *clist,
case GTK_CELL_TEXT:
if (style != GTK_WIDGET (clist)->style)
row_center_offset = (((clist->row_height - style->font->ascent -
- style->font->descent - 1) / 2) + 1.5 +
+ style->font->descent - 1) / 2) + 1.5 +
style->font->ascent);
else
row_center_offset = clist->row_center_offset;
-
+
gdk_gc_set_clip_rectangle (fg_gc, &clip_rectangle);
gdk_draw_string (clist->clist_window, style->font, fg_gc,
offset,
@@ -5897,7 +5895,7 @@ draw_row (GtkCList *clist,
break;
}
}
-
+
/* draw focus rectangle */
if (clist->focus_row == row &&
GTK_WIDGET_CAN_FOCUS (widget) && GTK_WIDGET_HAS_FOCUS(widget))
@@ -5928,14 +5926,14 @@ draw_rows (GtkCList *clist,
gint i;
gint first_row;
gint last_row;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (clist->row_height == 0 ||
!GTK_WIDGET_DRAWABLE (clist))
return;
-
+
if (area)
{
first_row = ROW_FROM_YPIXEL (clist, area->y);
@@ -5946,28 +5944,28 @@ draw_rows (GtkCList *clist,
first_row = ROW_FROM_YPIXEL (clist, 0);
last_row = ROW_FROM_YPIXEL (clist, clist->clist_window_height);
}
-
+
/* this is a small special case which exposes the bottom cell line
* on the last row -- it might go away if I change the wall the cell
* spacings are drawn
*/
if (clist->rows == first_row)
first_row--;
-
+
list = ROW_ELEMENT (clist, first_row);
i = first_row;
while (list)
{
clist_row = list->data;
list = list->next;
-
+
if (i > last_row)
return;
-
- GTK_CLIST_CLASS_FW (clist)->draw_row (clist, area, i, clist_row);
+
+ GTK_CLIST_GET_CLASS (clist)->draw_row (clist, area, i, clist_row);
i++;
}
-
+
if (!area)
gdk_window_clear_area (clist->clist_window, 0,
ROW_TOP_YPIXEL (clist, i), 0, 0);
@@ -5977,11 +5975,11 @@ static void
draw_xor_line (GtkCList *clist)
{
GtkWidget *widget;
-
+
g_return_if_fail (clist != NULL);
-
+
widget = GTK_WIDGET (clist);
-
+
gdk_draw_line (widget->window, clist->xor_gc,
clist->x_drag,
widget->style->klass->ythickness,
@@ -6015,26 +6013,26 @@ get_selection_info (GtkCList *clist,
gint *column)
{
gint trow, tcol;
-
+
g_return_val_if_fail (clist != NULL, 0);
g_return_val_if_fail (GTK_IS_CLIST (clist), 0);
-
+
/* bounds checking, return false if the user clicked
* on a blank area */
trow = ROW_FROM_YPIXEL (clist, y);
if (trow >= clist->rows)
return 0;
-
+
if (row)
*row = trow;
-
+
tcol = COLUMN_FROM_XPIXEL (clist, x);
if (tcol >= clist->columns)
return 0;
-
+
if (column)
*column = tcol;
-
+
return 1;
}
@@ -6069,7 +6067,7 @@ adjust_adjustments (GtkCList *clist,
clist->vadjustment->step_increment = clist->row_height;
clist->vadjustment->lower = 0;
clist->vadjustment->upper = LIST_HEIGHT (clist);
-
+
if (clist->clist_window_height - clist->voffset > LIST_HEIGHT (clist) ||
(clist->voffset + (gint)clist->vadjustment->value) != 0)
{
@@ -6080,7 +6078,7 @@ adjust_adjustments (GtkCList *clist,
}
gtk_signal_emit_by_name (GTK_OBJECT (clist->vadjustment), "changed");
}
-
+
if (clist->hadjustment)
{
clist->hadjustment->page_size = clist->clist_window_width;
@@ -6088,7 +6086,7 @@ adjust_adjustments (GtkCList *clist,
clist->hadjustment->step_increment = 10;
clist->hadjustment->lower = 0;
clist->hadjustment->upper = LIST_WIDTH (clist);
-
+
if (clist->clist_window_width - clist->hoffset > LIST_WIDTH (clist) ||
(clist->hoffset + (gint)clist->hadjustment->value) != 0)
{
@@ -6099,15 +6097,15 @@ adjust_adjustments (GtkCList *clist,
}
gtk_signal_emit_by_name (GTK_OBJECT (clist->hadjustment), "changed");
}
-
+
if (!block_resize && (!clist->vadjustment || !clist->hadjustment))
{
GtkWidget *widget;
GtkRequisition requisition;
-
+
widget = GTK_WIDGET (clist);
gtk_widget_size_request (widget, &requisition);
-
+
if ((!clist->hadjustment &&
requisition.width != widget->allocation.width) ||
(!clist->vadjustment &&
@@ -6121,10 +6119,10 @@ vadjustment_changed (GtkAdjustment *adjustment,
gpointer data)
{
GtkCList *clist;
-
+
g_return_if_fail (adjustment != NULL);
g_return_if_fail (data != NULL);
-
+
clist = GTK_CLIST (data);
}
@@ -6133,10 +6131,10 @@ hadjustment_changed (GtkAdjustment *adjustment,
gpointer data)
{
GtkCList *clist;
-
+
g_return_if_fail (adjustment != NULL);
g_return_if_fail (data != NULL);
-
+
clist = GTK_CLIST (data);
}
@@ -6147,23 +6145,23 @@ vadjustment_value_changed (GtkAdjustment *adjustment,
GtkCList *clist;
GdkRectangle area;
gint diff, value;
-
+
g_return_if_fail (adjustment != NULL);
g_return_if_fail (data != NULL);
g_return_if_fail (GTK_IS_CLIST (data));
-
+
clist = GTK_CLIST (data);
-
+
if (!GTK_WIDGET_DRAWABLE (clist) || adjustment != clist->vadjustment)
return;
-
+
value = adjustment->value;
-
+
if (value > -clist->voffset)
{
/* scroll down */
diff = value + clist->voffset;
-
+
/* we have to re-draw the whole screen here... */
if (diff >= clist->clist_window_height)
{
@@ -6171,13 +6169,13 @@ vadjustment_value_changed (GtkAdjustment *adjustment,
draw_rows (clist, NULL);
return;
}
-
+
if ((diff != 0) && (diff != clist->clist_window_height))
gdk_window_copy_area (clist->clist_window, clist->fg_gc,
0, 0, clist->clist_window, 0, diff,
clist->clist_window_width,
clist->clist_window_height - diff);
-
+
area.x = 0;
area.y = clist->clist_window_height - diff;
area.width = clist->clist_window_width;
@@ -6187,7 +6185,7 @@ vadjustment_value_changed (GtkAdjustment *adjustment,
{
/* scroll up */
diff = -clist->voffset - value;
-
+
/* we have to re-draw the whole screen here... */
if (diff >= clist->clist_window_height)
{
@@ -6195,23 +6193,23 @@ vadjustment_value_changed (GtkAdjustment *adjustment,
draw_rows (clist, NULL);
return;
}
-
+
if ((diff != 0) && (diff != clist->clist_window_height))
gdk_window_copy_area (clist->clist_window, clist->fg_gc,
0, diff, clist->clist_window, 0, 0,
clist->clist_window_width,
clist->clist_window_height - diff);
-
+
area.x = 0;
area.y = 0;
area.width = clist->clist_window_width;
area.height = diff;
}
-
+
clist->voffset = -value;
if ((diff != 0) && (diff != clist->clist_window_height))
check_exposures (clist);
-
+
draw_rows (clist, &area);
}
@@ -6225,18 +6223,18 @@ hadjustment_value_changed (GtkAdjustment *adjustment,
gint y = 0;
gint diff = 0;
gint value;
-
+
g_return_if_fail (adjustment != NULL);
g_return_if_fail (data != NULL);
g_return_if_fail (GTK_IS_CLIST (data));
-
+
clist = GTK_CLIST (data);
-
+
if (!GTK_WIDGET_DRAWABLE (clist) || adjustment != clist->hadjustment)
return;
-
+
value = adjustment->value;
-
+
/* move the column buttons and resize windows */
for (i = 0; i < clist->columns; i++)
{
@@ -6258,7 +6256,7 @@ hadjustment_value_changed (GtkAdjustment *adjustment,
}
}
}
-
+
if (value > -clist->hoffset)
{
/* scroll right */
@@ -6272,12 +6270,12 @@ hadjustment_value_changed (GtkAdjustment *adjustment,
draw_rows (clist, NULL);
return;
}
-
+
if (GTK_WIDGET_CAN_FOCUS(clist) && GTK_WIDGET_HAS_FOCUS(clist) &&
!GTK_CLIST_CHILD_HAS_FOCUS(clist) && GTK_CLIST_ADD_MODE(clist))
{
y = ROW_TOP_YPIXEL (clist, clist->focus_row);
-
+
gdk_draw_rectangle (clist->clist_window, clist->xor_gc, FALSE, 0, y,
clist->clist_window_width - 1,
clist->row_height - 1);
@@ -6290,7 +6288,7 @@ hadjustment_value_changed (GtkAdjustment *adjustment,
0,
clist->clist_window_width - diff,
clist->clist_window_height);
-
+
area.x = clist->clist_window_width - diff;
}
else
@@ -6298,7 +6296,7 @@ hadjustment_value_changed (GtkAdjustment *adjustment,
/* scroll left */
if (!(diff = -clist->hoffset - value))
return;
-
+
clist->hoffset = -value;
/* we have to re-draw the whole screen here... */
@@ -6317,7 +6315,7 @@ hadjustment_value_changed (GtkAdjustment *adjustment,
clist->clist_window_width - 1,
clist->row_height - 1);
}
-
+
gdk_window_copy_area (clist->clist_window,
clist->fg_gc,
diff, 0,
@@ -6326,16 +6324,16 @@ hadjustment_value_changed (GtkAdjustment *adjustment,
0,
clist->clist_window_width - diff,
clist->clist_window_height);
-
+
area.x = 0;
}
-
+
area.y = 0;
area.width = diff;
area.height = clist->clist_window_height;
-
+
check_exposures (clist);
-
+
if (GTK_WIDGET_CAN_FOCUS(clist) && GTK_WIDGET_HAS_FOCUS(clist) &&
!GTK_CLIST_CHILD_HAS_FOCUS(clist))
{
@@ -6384,10 +6382,10 @@ static void
check_exposures (GtkCList *clist)
{
GdkEvent *event;
-
+
if (!GTK_WIDGET_REALIZED (clist))
return;
-
+
/* Make sure graphics expose events are processed before scrolling
* again */
while ((event = gdk_event_get_graphics_expose (clist->clist_window)) != NULL)
@@ -6417,9 +6415,9 @@ columns_new (GtkCList *clist)
{
GtkCListColumn *column;
gint i;
-
+
column = g_new (GtkCListColumn, clist->columns);
-
+
for (i = 0; i < clist->columns; i++)
{
column[i].area.x = 0;
@@ -6439,7 +6437,7 @@ columns_new (GtkCList *clist)
column[i].button_passive = FALSE;
column[i].justification = GTK_JUSTIFY_LEFT;
}
-
+
return column;
}
@@ -6450,7 +6448,7 @@ column_title_new (GtkCList *clist,
{
if (clist->column[column].title)
g_free (clist->column[column].title);
-
+
clist->column[column].title = g_strdup (title);
}
@@ -6458,11 +6456,11 @@ static void
columns_delete (GtkCList *clist)
{
gint i;
-
+
for (i = 0; i < clist->columns; i++)
if (clist->column[i].title)
g_free (clist->column[i].title);
-
+
g_free (clist->column);
}
@@ -6471,10 +6469,10 @@ row_new (GtkCList *clist)
{
int i;
GtkCListRow *clist_row;
-
+
clist_row = g_chunk_new (GtkCListRow, clist->row_mem_chunk);
clist_row->cell = g_chunk_new (GtkCell, clist->cell_mem_chunk);
-
+
for (i = 0; i < clist->columns; i++)
{
clist_row->cell[i].type = GTK_CELL_EMPTY;
@@ -6482,7 +6480,7 @@ row_new (GtkCList *clist)
clist_row->cell[i].horizontal = 0;
clist_row->cell[i].style = NULL;
}
-
+
clist_row->fg_set = FALSE;
clist_row->bg_set = FALSE;
clist_row->style = NULL;
@@ -6490,7 +6488,7 @@ row_new (GtkCList *clist)
clist_row->state = GTK_STATE_NORMAL;
clist_row->data = NULL;
clist_row->destroy = NULL;
-
+
return clist_row;
}
@@ -6499,10 +6497,10 @@ row_delete (GtkCList *clist,
GtkCListRow *clist_row)
{
gint i;
-
+
for (i = 0; i < clist->columns; i++)
{
- GTK_CLIST_CLASS_FW (clist)->set_cell_contents
+ GTK_CLIST_GET_CLASS (clist)->set_cell_contents
(clist, clist_row, i, GTK_CELL_EMPTY, NULL, 0, NULL, NULL);
if (clist_row->cell[i].style)
{
@@ -6511,17 +6509,17 @@ row_delete (GtkCList *clist,
gtk_style_unref (clist_row->cell[i].style);
}
}
-
+
if (clist_row->style)
{
if (GTK_WIDGET_REALIZED (clist))
gtk_style_detach (clist_row->style);
gtk_style_unref (clist_row->style);
}
-
+
if (clist_row->destroy)
clist_row->destroy (clist_row->data);
-
+
g_mem_chunk_free (clist->cell_mem_chunk, clist_row->cell);
g_mem_chunk_free (clist->row_mem_chunk, clist_row);
}
@@ -6541,17 +6539,17 @@ gtk_clist_focus (GtkContainer *container,
GtkCList *clist;
GtkWidget *focus_child;
gint old_row;
-
+
g_return_val_if_fail (container != NULL, FALSE);
g_return_val_if_fail (GTK_IS_CLIST (container), FALSE);
-
+
if (!GTK_WIDGET_IS_SENSITIVE (container))
return FALSE;
clist = GTK_CLIST (container);
focus_child = container->focus_child;
old_row = clist->focus_row;
-
+
switch (direction)
{
case GTK_DIR_LEFT:
@@ -6562,7 +6560,7 @@ gtk_clist_focus (GtkContainer *container,
return TRUE;
gtk_container_set_focus_child (container, NULL);
return FALSE;
- }
+ }
gtk_widget_grab_focus (GTK_WIDGET (container));
return TRUE;
case GTK_DIR_DOWN:
@@ -6570,7 +6568,7 @@ gtk_clist_focus (GtkContainer *container,
if (GTK_CLIST_CHILD_HAS_FOCUS(clist))
{
gboolean tf = FALSE;
-
+
if (((focus_child && direction == GTK_DIR_DOWN) ||
!(tf = title_focus (clist, GTK_DIR_TAB_FORWARD)))
&& clist->rows)
@@ -6578,7 +6576,7 @@ gtk_clist_focus (GtkContainer *container,
if (clist->focus_row < 0)
{
clist->focus_row = 0;
-
+
if ((clist->selection_mode == GTK_SELECTION_BROWSE ||
clist->selection_mode == GTK_SELECTION_EXTENDED) &&
!clist->selection)
@@ -6589,7 +6587,7 @@ gtk_clist_focus (GtkContainer *container,
gtk_widget_grab_focus (GTK_WIDGET (container));
return TRUE;
}
-
+
if (tf)
return TRUE;
}
@@ -6614,17 +6612,17 @@ gtk_clist_focus (GtkContainer *container,
gtk_widget_grab_focus (GTK_WIDGET (container));
return TRUE;
}
-
+
GTK_CLIST_SET_FLAG (clist, CLIST_CHILD_HAS_FOCUS);
-
+
if (title_focus (clist, direction))
return TRUE;
-
+
break;
default:
break;
}
-
+
gtk_container_set_focus_child (container, NULL);
return FALSE;
}
@@ -6633,13 +6631,13 @@ static void
gtk_clist_draw_focus (GtkWidget *widget)
{
GtkCList *clist;
-
+
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_CLIST (widget));
-
+
if (!GTK_WIDGET_DRAWABLE (widget) || !GTK_WIDGET_CAN_FOCUS (widget))
return;
-
+
clist = GTK_CLIST (widget);
if (clist->focus_row >= 0)
gdk_draw_rectangle (clist->clist_window, clist->xor_gc, FALSE,
@@ -6653,21 +6651,21 @@ gtk_clist_focus_in (GtkWidget *widget,
GdkEventFocus *event)
{
GtkCList *clist;
-
+
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_CLIST (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
-
+
GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS);
GTK_CLIST_UNSET_FLAG (widget, CLIST_CHILD_HAS_FOCUS);
-
+
clist = GTK_CLIST (widget);
-
+
if (clist->selection_mode == GTK_SELECTION_BROWSE &&
clist->selection == NULL && clist->focus_row > -1)
{
GList *list;
-
+
list = g_list_nth (clist->row_list, clist->focus_row);
if (list && GTK_CLIST_ROW (list)->selectable)
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[SELECT_ROW],
@@ -6677,7 +6675,7 @@ gtk_clist_focus_in (GtkWidget *widget,
}
else
gtk_widget_draw_focus (widget);
-
+
return FALSE;
}
@@ -6686,20 +6684,20 @@ gtk_clist_focus_out (GtkWidget *widget,
GdkEventFocus *event)
{
GtkCList *clist;
-
+
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_CLIST (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
-
+
GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS);
GTK_CLIST_SET_FLAG (widget, CLIST_CHILD_HAS_FOCUS);
-
+
gtk_widget_draw_focus (widget);
clist = GTK_CLIST (widget);
-
- GTK_CLIST_CLASS_FW (widget)->resync_selection (clist, (GdkEvent *) event);
-
+
+ GTK_CLIST_GET_CLASS (widget)->resync_selection (clist, (GdkEvent *) event);
+
return FALSE;
}
@@ -6709,13 +6707,13 @@ gtk_clist_set_focus_child (GtkContainer *container,
{
g_return_if_fail (container != NULL);
g_return_if_fail (GTK_IS_CLIST (container));
-
+
if (child)
{
g_return_if_fail (GTK_IS_WIDGET (child));
GTK_CLIST_SET_FLAG (container, CLIST_CHILD_HAS_FOCUS);
}
-
+
parent_class->set_focus_child (container, child);
}
@@ -6729,12 +6727,12 @@ title_focus (GtkCList *clist,
gint d = 1;
gint i = 0;
gint j;
-
+
if (!GTK_CLIST_SHOW_TITLES(clist))
return FALSE;
-
+
focus_child = GTK_CONTAINER (clist)->focus_child;
-
+
for (last_column = clist->columns - 1;
last_column >= 0 && !clist->column[last_column].visible; last_column--)
;
@@ -6771,7 +6769,7 @@ title_focus (GtkCList *clist,
}
break;
}
-
+
if (focus_child)
while (i < clist->columns)
{
@@ -6794,9 +6792,9 @@ title_focus (GtkCList *clist,
}
i++;
}
-
+
j = i;
-
+
if (!return_val)
while (j >= 0 && j < clist->columns)
{
@@ -6852,12 +6850,12 @@ move_focus_row (GtkCList *clist,
gfloat position)
{
GtkWidget *widget;
-
+
g_return_if_fail (clist != 0);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
widget = GTK_WIDGET (clist);
-
+
switch (scroll_type)
{
case GTK_SCROLL_STEP_BACKWARD:
@@ -6914,17 +6912,17 @@ scroll_horizontal (GtkCList *clist,
{
gint column = 0;
gint last_column;
-
+
g_return_if_fail (clist != 0);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (gdk_pointer_is_grabbed () && GTK_WIDGET_HAS_GRAB (clist))
return;
-
+
for (last_column = clist->columns - 1;
last_column >= 0 && !clist->column[last_column].visible; last_column--)
;
-
+
switch (scroll_type)
{
case GTK_SCROLL_STEP_BACKWARD:
@@ -6951,17 +6949,17 @@ scroll_horizontal (GtkCList *clist,
{
gint vis_columns = 0;
gint i;
-
+
for (i = 0; i <= last_column; i++)
if (clist->column[i].visible)
vis_columns++;
-
+
column = position * vis_columns;
-
+
for (i = 0; i <= last_column && column > 0; i++)
if (clist->column[i].visible)
column--;
-
+
column = i;
}
else
@@ -6970,7 +6968,7 @@ scroll_horizontal (GtkCList *clist,
default:
break;
}
-
+
if (COLUMN_LEFT_XPIXEL (clist, column) < CELL_SPACING + COLUMN_INSET)
gtk_clist_moveto (clist, -1, column, 0, 0);
else if (COLUMN_LEFT_XPIXEL (clist, column) + CELL_SPACING + COLUMN_INSET - 1
@@ -6989,23 +6987,23 @@ scroll_vertical (GtkCList *clist,
gfloat position)
{
gint old_focus_row;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (gdk_pointer_is_grabbed () && GTK_WIDGET_HAS_GRAB (clist))
return;
-
+
switch (clist->selection_mode)
{
case GTK_SELECTION_EXTENDED:
if (clist->anchor >= 0)
return;
case GTK_SELECTION_BROWSE:
-
+
old_focus_row = clist->focus_row;
move_focus_row (clist, scroll_type, position);
-
+
if (old_focus_row != clist->focus_row)
{
if (clist->selection_mode == GTK_SELECTION_BROWSE)
@@ -7017,7 +7015,7 @@ scroll_vertical (GtkCList *clist,
clist->undo_anchor = old_focus_row;
}
}
-
+
switch (gtk_clist_row_is_visible (clist, clist->focus_row))
{
case GTK_VISIBILITY_NONE:
@@ -7071,7 +7069,7 @@ scroll_vertical (GtkCList *clist,
break;
default:
move_focus_row (clist, scroll_type, position);
-
+
if (ROW_TOP_YPIXEL (clist, clist->focus_row) + clist->row_height >
clist->clist_window_height)
gtk_clist_moveto (clist, clist->focus_row, -1, 1, 0);
@@ -7086,10 +7084,10 @@ move_horizontal (GtkCList *clist,
gint diff)
{
gfloat value;
-
+
if (!clist->hadjustment)
return;
-
+
value = CLAMP (clist->hadjustment->value + diff, 0.0,
clist->hadjustment->upper - clist->hadjustment->page_size);
gtk_adjustment_set_value(clist->hadjustment, value);
@@ -7101,17 +7099,17 @@ move_vertical (GtkCList *clist,
gfloat align)
{
gfloat value;
-
+
if (!clist->vadjustment)
return;
-
+
value = (ROW_TOP_YPIXEL (clist, row) - clist->voffset -
align * (clist->clist_window_height - clist->row_height) +
(2 * align - 1) * CELL_SPACING);
-
+
if (value + clist->vadjustment->page_size > clist->vadjustment->upper)
value = clist->vadjustment->upper - clist->vadjustment->page_size;
-
+
gtk_adjustment_set_value(clist->vadjustment, value);
}
@@ -7119,16 +7117,16 @@ static gint
horizontal_timeout (GtkCList *clist)
{
GdkEventMotion event = { 0 };
-
+
GDK_THREADS_ENTER ();
-
+
clist->htimer = 0;
-
+
event.type = GDK_MOTION_NOTIFY;
event.send_event = TRUE;
-
+
gtk_clist_motion (GTK_WIDGET (clist), &event);
-
+
GDK_THREADS_LEAVE ();
return FALSE;
@@ -7138,18 +7136,18 @@ static gint
vertical_timeout (GtkCList *clist)
{
GdkEventMotion event = { 0 };
-
+
GDK_THREADS_ENTER ();
-
+
clist->vtimer = 0;
-
+
event.type = GDK_MOTION_NOTIFY;
event.send_event = TRUE;
-
+
gtk_clist_motion (GTK_WIDGET (clist), &event);
-
+
GDK_THREADS_LEAVE ();
-
+
return FALSE;
}
@@ -7162,13 +7160,13 @@ remove_grab (GtkCList *clist)
if (gdk_pointer_is_grabbed ())
gdk_pointer_ungrab (GDK_CURRENT_TIME);
}
-
+
if (clist->htimer)
{
gtk_timeout_remove (clist->htimer);
clist->htimer = 0;
}
-
+
if (clist->vtimer)
{
gtk_timeout_remove (clist->vtimer);
@@ -7188,8 +7186,8 @@ gtk_clist_sort (GtkCList *clist)
{
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
- GTK_CLIST_CLASS_FW (clist)->sort_list (clist);
+
+ GTK_CLIST_GET_CLASS (clist)->sort_list (clist);
}
void
@@ -7198,7 +7196,7 @@ gtk_clist_set_compare_func (GtkCList *clist,
{
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
clist->compare = (cmp_func) ? cmp_func : default_compare;
}
@@ -7234,10 +7232,10 @@ gtk_clist_set_sort_column (GtkCList *clist,
{
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (column < 0 || column >= clist->columns)
return;
-
+
clist->sort_column = column;
}
@@ -7254,10 +7252,10 @@ default_compare (GtkCList *clist,
{
char *text1 = NULL;
char *text2 = NULL;
-
+
GtkCListRow *row1 = (GtkCListRow *) ptr1;
GtkCListRow *row2 = (GtkCListRow *) ptr2;
-
+
switch (row1->cell[clist->sort_column].type)
{
case GTK_CELL_TEXT:
@@ -7269,7 +7267,7 @@ default_compare (GtkCList *clist,
default:
break;
}
-
+
switch (row2->cell[clist->sort_column].type)
{
case GTK_CELL_TEXT:
@@ -7281,13 +7279,13 @@ default_compare (GtkCList *clist,
default:
break;
}
-
+
if (!text2)
return (text1 != NULL);
-
+
if (!text1)
return -1;
-
+
return strcmp (text1, text2);
}
@@ -7297,31 +7295,31 @@ real_sort_list (GtkCList *clist)
GList *list;
GList *work;
gint i;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (clist->rows <= 1)
return;
-
+
if (gdk_pointer_is_grabbed () && GTK_WIDGET_HAS_GRAB (clist))
return;
-
+
gtk_clist_freeze (clist);
-
+
if (clist->anchor != -1 && clist->selection_mode == GTK_SELECTION_EXTENDED)
{
- GTK_CLIST_CLASS_FW (clist)->resync_selection (clist, NULL);
+ GTK_CLIST_GET_CLASS (clist)->resync_selection (clist, NULL);
g_list_free (clist->undo_selection);
g_list_free (clist->undo_unselection);
clist->undo_selection = NULL;
clist->undo_unselection = NULL;
}
-
+
clist->row_list = gtk_clist_mergesort (clist, clist->row_list, clist->rows);
-
+
work = clist->selection;
-
+
for (i = 0, list = clist->row_list; i < clist->rows; i++, list = list->next)
{
if (GTK_CLIST_ROW (list)->state == GTK_STATE_SELECTED)
@@ -7333,7 +7331,7 @@ real_sort_list (GtkCList *clist)
if (i == clist->rows - 1)
clist->row_list_end = list;
}
-
+
gtk_clist_thaw (clist);
}
@@ -7345,9 +7343,9 @@ gtk_clist_merge (GtkCList *clist,
GList z = { 0 }; /* auxiliary node */
GList *c;
gint cmp;
-
+
c = &z;
-
+
while (a || b)
{
if (a && !b)
@@ -7387,7 +7385,7 @@ gtk_clist_merge (GtkCList *clist,
}
}
}
-
+
return z.next;
}
@@ -7398,7 +7396,7 @@ gtk_clist_mergesort (GtkCList *clist,
{
GList *half;
gint i;
-
+
if (num == 1)
{
return list;
@@ -7409,15 +7407,15 @@ gtk_clist_mergesort (GtkCList *clist,
half = list;
for (i = 0; i < num / 2; i++)
half = half->next;
-
+
/* cut the list in two */
half->prev->next = NULL;
half->prev = NULL;
-
+
/* recursively sort both lists */
return gtk_clist_merge (clist,
- gtk_clist_mergesort (clist, list, num / 2),
- gtk_clist_mergesort (clist, half, num - num / 2));
+ gtk_clist_mergesort (clist, list, num / 2),
+ gtk_clist_mergesort (clist, half, num - num / 2));
}
}
@@ -7427,7 +7425,7 @@ static void
drag_source_info_destroy (gpointer data)
{
GtkCListCellInfo *info = data;
-
+
g_free (info);
}
@@ -7435,7 +7433,7 @@ static void
drag_dest_info_destroy (gpointer data)
{
GtkCListDestInfo *info = data;
-
+
g_free (info);
}
@@ -7446,15 +7444,15 @@ drag_dest_cell (GtkCList *clist,
GtkCListDestInfo *dest_info)
{
GtkWidget *widget;
-
+
widget = GTK_WIDGET (clist);
-
+
dest_info->insert_pos = GTK_CLIST_DRAG_NONE;
-
+
y -= (GTK_CONTAINER (clist)->border_width +
widget->style->klass->ythickness +
clist->column_title_area.height);
-
+
dest_info->cell.row = ROW_FROM_YPIXEL (clist, y);
if (dest_info->cell.row >= clist->rows)
{
@@ -7463,15 +7461,15 @@ drag_dest_cell (GtkCList *clist,
}
if (dest_info->cell.row < -1)
dest_info->cell.row = -1;
-
+
x -= GTK_CONTAINER (widget)->border_width + widget->style->klass->xthickness;
dest_info->cell.column = COLUMN_FROM_XPIXEL (clist, x);
-
+
if (dest_info->cell.row >= 0)
{
gint y_delta;
gint h = 0;
-
+
y_delta = y - ROW_TOP_YPIXEL (clist, dest_info->cell.row);
if (GTK_CLIST_DRAW_DRAG_RECT(clist))
@@ -7484,7 +7482,7 @@ drag_dest_cell (GtkCList *clist,
dest_info->insert_pos = GTK_CLIST_DRAG_BEFORE;
h = clist->row_height / 2;
}
-
+
if (GTK_CLIST_DRAW_DRAG_LINE(clist))
{
if (y_delta < h)
@@ -7501,21 +7499,21 @@ gtk_clist_drag_begin (GtkWidget *widget,
{
GtkCList *clist;
GtkCListCellInfo *info;
-
+
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_CLIST (widget));
g_return_if_fail (context != NULL);
-
+
clist = GTK_CLIST (widget);
-
+
clist->drag_button = 0;
remove_grab (clist);
-
+
switch (clist->selection_mode)
{
case GTK_SELECTION_EXTENDED:
update_extended_selection (clist, clist->focus_row);
- GTK_CLIST_CLASS_FW (clist)->resync_selection (clist, NULL);
+ GTK_CLIST_GET_CLASS (clist)->resync_selection (clist, NULL);
break;
case GTK_SELECTION_SINGLE:
case GTK_SELECTION_MULTIPLE:
@@ -7523,24 +7521,24 @@ gtk_clist_drag_begin (GtkWidget *widget,
case GTK_SELECTION_BROWSE:
break;
}
-
+
info = g_dataset_get_data (context, "gtk-clist-drag-source");
-
+
if (!info)
{
info = g_new (GtkCListCellInfo, 1);
-
+
if (clist->click_cell.row < 0)
clist->click_cell.row = 0;
else if (clist->click_cell.row >= clist->rows)
clist->click_cell.row = clist->rows - 1;
info->row = clist->click_cell.row;
info->column = clist->click_cell.column;
-
+
g_dataset_set_data_full (context, "gtk-clist-drag-source", info,
drag_source_info_destroy);
}
-
+
if (GTK_CLIST_USE_DRAG_ICONS (clist))
gtk_drag_set_icon_default (context);
}
@@ -7550,13 +7548,13 @@ gtk_clist_drag_end (GtkWidget *widget,
GdkDragContext *context)
{
GtkCList *clist;
-
+
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_CLIST (widget));
g_return_if_fail (context != NULL);
-
+
clist = GTK_CLIST (widget);
-
+
clist->click_cell.row = -1;
clist->click_cell.column = -1;
}
@@ -7568,13 +7566,13 @@ gtk_clist_drag_leave (GtkWidget *widget,
{
GtkCList *clist;
GtkCListDestInfo *dest_info;
-
+
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_CLIST (widget));
g_return_if_fail (context != NULL);
-
+
clist = GTK_CLIST (widget);
-
+
dest_info = g_dataset_get_data (context, "gtk-clist-drag-dest");
if (dest_info)
@@ -7585,13 +7583,13 @@ gtk_clist_drag_leave (GtkWidget *widget,
{
GList *list;
GdkAtom atom = gdk_atom_intern ("gtk-clist-drag-reorder", FALSE);
-
+
list = context->targets;
while (list)
{
if (atom == GPOINTER_TO_INT (list->data))
{
- GTK_CLIST_CLASS_FW (clist)->draw_drag_highlight
+ GTK_CLIST_GET_CLASS (clist)->draw_drag_highlight
(clist,
g_list_nth (clist->row_list, dest_info->cell.row)->data,
dest_info->cell.row, dest_info->insert_pos);
@@ -7614,33 +7612,33 @@ gtk_clist_drag_motion (GtkWidget *widget,
GtkCList *clist;
GtkCListDestInfo new_info;
GtkCListDestInfo *dest_info;
-
+
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_CLIST (widget), FALSE);
-
+
clist = GTK_CLIST (widget);
-
+
dest_info = g_dataset_get_data (context, "gtk-clist-drag-dest");
-
+
if (!dest_info)
{
dest_info = g_new (GtkCListDestInfo, 1);
-
+
dest_info->insert_pos = GTK_CLIST_DRAG_NONE;
dest_info->cell.row = -1;
dest_info->cell.column = -1;
-
+
g_dataset_set_data_full (context, "gtk-clist-drag-dest", dest_info,
drag_dest_info_destroy);
}
-
+
drag_dest_cell (clist, x, y, &new_info);
-
+
if (GTK_CLIST_REORDERABLE (clist))
{
GList *list;
GdkAtom atom = gdk_atom_intern ("gtk-clist-drag-reorder", FALSE);
-
+
list = context->targets;
while (list)
{
@@ -7648,7 +7646,7 @@ gtk_clist_drag_motion (GtkWidget *widget,
break;
list = list->next;
}
-
+
if (list)
{
if (gtk_drag_get_source_widget (context) != widget ||
@@ -7666,32 +7664,32 @@ gtk_clist_drag_motion (GtkWidget *widget,
}
return TRUE;
}
-
+
if (new_info.cell.row != dest_info->cell.row ||
(new_info.cell.row == dest_info->cell.row &&
dest_info->insert_pos != new_info.insert_pos))
{
if (dest_info->cell.row >= 0)
- GTK_CLIST_CLASS_FW (clist)->draw_drag_highlight
+ GTK_CLIST_GET_CLASS (clist)->draw_drag_highlight
(clist, g_list_nth (clist->row_list,
dest_info->cell.row)->data,
dest_info->cell.row, dest_info->insert_pos);
-
+
dest_info->insert_pos = new_info.insert_pos;
dest_info->cell.row = new_info.cell.row;
dest_info->cell.column = new_info.cell.column;
- GTK_CLIST_CLASS_FW (clist)->draw_drag_highlight
+ GTK_CLIST_GET_CLASS (clist)->draw_drag_highlight
(clist, g_list_nth (clist->row_list,
dest_info->cell.row)->data,
dest_info->cell.row, dest_info->insert_pos);
-
+
gdk_drag_status (context, context->suggested_action, time);
}
return TRUE;
}
}
-
+
dest_info->insert_pos = new_info.insert_pos;
dest_info->cell.row = new_info.cell.row;
dest_info->cell.column = new_info.cell.column;
@@ -7708,13 +7706,13 @@ gtk_clist_drag_drop (GtkWidget *widget,
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_CLIST (widget), FALSE);
g_return_val_if_fail (context != NULL, FALSE);
-
+
if (GTK_CLIST_REORDERABLE (widget) &&
gtk_drag_get_source_widget (context) == widget)
{
GList *list;
GdkAtom atom = gdk_atom_intern ("gtk-clist-drag-reorder", FALSE);
-
+
list = context->targets;
while (list)
{
@@ -7736,14 +7734,14 @@ gtk_clist_drag_data_received (GtkWidget *widget,
guint time)
{
GtkCList *clist;
-
+
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_CLIST (widget));
g_return_if_fail (context != NULL);
g_return_if_fail (selection_data != NULL);
-
+
clist = GTK_CLIST (widget);
-
+
if (GTK_CLIST_REORDERABLE (clist) &&
gtk_drag_get_source_widget (context) == widget &&
selection_data->target ==
@@ -7752,21 +7750,21 @@ gtk_clist_drag_data_received (GtkWidget *widget,
selection_data->length == sizeof (GtkCListCellInfo))
{
GtkCListCellInfo *source_info;
-
+
source_info = (GtkCListCellInfo *)(selection_data->data);
if (source_info)
{
GtkCListDestInfo dest_info;
-
+
drag_dest_cell (clist, x, y, &dest_info);
-
+
if (dest_info.insert_pos == GTK_CLIST_DRAG_AFTER)
dest_info.cell.row++;
if (source_info->row < dest_info.cell.row)
dest_info.cell.row--;
if (dest_info.cell.row != source_info->row)
gtk_clist_row_move (clist, source_info->row, dest_info.cell.row);
-
+
g_dataset_remove_data (context, "gtk-clist-drag-dest");
}
}
@@ -7783,21 +7781,21 @@ gtk_clist_drag_data_get (GtkWidget *widget,
g_return_if_fail (GTK_IS_CLIST (widget));
g_return_if_fail (context != NULL);
g_return_if_fail (selection_data != NULL);
-
+
if (selection_data->target ==
gdk_atom_intern ("gtk-clist-drag-reorder", FALSE))
{
GtkCListCellInfo *info;
-
+
info = g_dataset_get_data (context, "gtk-clist-drag-source");
-
+
if (info)
{
GtkCListCellInfo ret_info;
-
+
ret_info.row = info->row;
ret_info.column = info->column;
-
+
gtk_selection_data_set (selection_data, selection_data->target,
GTK_TYPE_POINTER, (guchar *) &ret_info,
sizeof (GtkCListCellInfo));
@@ -7815,9 +7813,9 @@ draw_drag_highlight (GtkCList *clist,
GtkCListDragPos drag_pos)
{
gint y;
-
+
y = ROW_TOP_YPIXEL (clist, dest_row_number) - 1;
-
+
switch (drag_pos)
{
case GTK_CLIST_DRAG_NONE:
@@ -7840,15 +7838,15 @@ gtk_clist_set_reorderable (GtkCList *clist,
gboolean reorderable)
{
GtkWidget *widget;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if ((GTK_CLIST_REORDERABLE(clist) != 0) == reorderable)
return;
-
+
widget = GTK_WIDGET (clist);
-
+
if (reorderable)
{
GTK_CLIST_SET_FLAG (clist, CLIST_REORDERABLE);
@@ -7869,7 +7867,7 @@ gtk_clist_set_use_drag_icons (GtkCList *clist,
{
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
-
+
if (use_icons != 0)
GTK_CLIST_SET_FLAG (clist, CLIST_USE_DRAG_ICONS);
else
@@ -7891,9 +7889,9 @@ gtk_clist_set_button_actions (GtkCList *clist,
remove_grab (clist);
clist->drag_button = 0;
}
-
- GTK_CLIST_CLASS_FW (clist)->resync_selection (clist, NULL);
-
+
+ GTK_CLIST_GET_CLASS (clist)->resync_selection (clist, NULL);
+
clist->button_actions[button] = button_actions;
}
}
diff --git a/gtk/gtkcolorsel.c b/gtk/gtkcolorsel.c
index 6af300bd9e..9071f89246 100644
--- a/gtk/gtkcolorsel.c
+++ b/gtk/gtkcolorsel.c
@@ -1,4 +1,4 @@
- /* GTK - The GIMP Toolkit
+/* GTK - The GIMP Toolkit
* Copyright (C) 2000 Red Hat, Inc.
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
@@ -25,8 +25,7 @@
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
-#include <glib.h>
-#include "gdk/gdkx.h"
+#include "x11/gdkx.h"
#include "gdk/gdkkeysyms.h"
#include "gtkcolorsel.h"
#include "gtkhsv.h"
@@ -72,15 +71,17 @@ typedef struct _ColorSelectionPrivate ColorSelectionPrivate;
struct _ColorSelectionPrivate
{
- /* < Private > */
- gboolean use_opacity;
- gboolean use_palette;
- gboolean changing;
- gboolean default_set;
-
+ guint use_opacity : 1;
+ guint use_palette : 1;
+ guint changing : 1;
+ guint default_set : 1;
+
+ /* The color dropper */
+ guint moving_dropper : 1;
+
gdouble color[COLORSEL_NUM_CHANNELS];
gdouble old_color[COLORSEL_NUM_CHANNELS];
-
+
GtkWidget *triangle_colorsel;
GtkWidget *hue_spinbutton;
GtkWidget *sat_spinbutton;
@@ -93,28 +94,25 @@ struct _ColorSelectionPrivate
GtkWidget *opacity_entry;
GtkWidget *palette_frame;
GtkWidget *hex_entry;
-
+
/* The Palette code */
- GtkWidget *custom_palette [CUSTOM_PALETTE_WIDTH][CUSTOM_PALETTE_HEIGHT];
+ GtkWidget *custom_palette [GTK_CUSTOM_PALETTE_WIDTH][GTK_CUSTOM_PALETTE_HEIGHT];
GtkWidget *last_palette;
-
+
/* The color_sample stuff */
GtkWidget *sample_area;
GtkWidget *old_sample;
GtkWidget *cur_sample;
GtkWidget *colorsel;
-
- /* The color dropper */
- gboolean moving_dropper;
};
-static void gtk_color_selection_init (GtkColorSelection *colorsel);
+static void gtk_color_selection_init (GtkColorSelection *colorsel);
static void gtk_color_selection_class_init (GtkColorSelectionClass *klass);
-static void gtk_color_selection_destroy (GtkObject *object);
-static void update_color (GtkColorSelection *colorsel);
+static void gtk_color_selection_destroy (GtkObject *object);
+static void update_color (GtkColorSelection *colorsel);
-static GtkVBoxClass *parent_class = NULL;
+static gpointer parent_class = NULL;
static guint color_selection_signals[LAST_SIGNAL] = { 0 };
@@ -206,7 +204,7 @@ color_sample_drag_begin (GtkWidget *widget,
gdouble *colsrc;
GdkColor bg;
gint n, i;
-
+
priv = colorsel->private;
window = gtk_window_new (GTK_WINDOW_POPUP);
gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
@@ -216,29 +214,29 @@ color_sample_drag_begin (GtkWidget *widget,
"gtk-color-selection-drag-window",
window,
(GtkDestroyNotify) gtk_widget_destroy);
-
+
if (widget == priv->old_sample)
colsrc = priv->old_color;
else
colsrc = priv->color;
-
+
for (i=0, n = COLORSEL_RED; n <= COLORSEL_BLUE; n++)
{
colors[i++] = colsrc[n];
}
-
+
if (priv->use_opacity)
{
colors[i] = colsrc[COLORSEL_OPACITY];
}
-
+
bg.red = 0xffff * colors[0];
bg.green = 0xffff * colors[1];
bg.blue = 0xffff * colors[2];
-
+
gdk_color_alloc (gtk_widget_get_colormap (window), &bg);
gdk_window_set_background (window->window, &bg);
-
+
gtk_drag_set_icon_widget (context, window, -2, -2);
}
@@ -265,33 +263,33 @@ color_sample_drop_handle (GtkWidget *widget,
guint16 *vals;
gdouble color[4];
priv = colorsel->private;
-
+
/* This is currently a guint16 array of the format:
* R
* G
* B
* opacity
*/
-
+
if (selection_data->length < 0)
return;
-
+
if ((selection_data->format != 16) ||
(selection_data->length != 8))
{
g_warning ("Received invalid color data\n");
return;
}
-
+
vals = (guint16 *)selection_data->data;
-
+
if (widget == priv->cur_sample)
{
color[0] = (gdouble)vals[0] / 0xffff;
color[1] = (gdouble)vals[1] / 0xffff;
color[2] = (gdouble)vals[2] / 0xffff;
color[3] = (gdouble)vals[3] / 0xffff;
-
+
gtk_color_selection_set_color (colorsel, color);
}
}
@@ -308,19 +306,19 @@ color_sample_drag_handle (GtkWidget *widget,
ColorSelectionPrivate *priv;
guint16 vals[4];
gdouble *colsrc;
-
+
priv = colorsel->private;
-
+
if (widget == priv->old_sample)
colsrc = priv->old_color;
else
colsrc = priv->color;
-
+
vals[0] = colsrc[COLORSEL_RED] * 0xffff;
vals[1] = colsrc[COLORSEL_GREEN] * 0xffff;
vals[2] = colsrc[COLORSEL_BLUE] * 0xffff;
vals[3] = priv->use_opacity ? colsrc[COLORSEL_OPACITY] * 0xffff : 0xffff;
-
+
gtk_selection_data_set (selection_data,
gdk_atom_intern ("application/x-color", FALSE),
16, (guchar *)vals, 8);
@@ -336,14 +334,14 @@ color_sample_draw_sample (GtkColorSelection *colorsel, int which)
gdouble o;
guchar *buf;
ColorSelectionPrivate *priv;
-
+
g_return_if_fail (colorsel != NULL);
priv = colorsel->private;
-
+
g_return_if_fail (priv->sample_area != NULL);
if (!GTK_WIDGET_DRAWABLE (priv->sample_area))
return;
-
+
if (which == 0)
{
da = priv->old_sample;
@@ -358,12 +356,12 @@ color_sample_draw_sample (GtkColorSelection *colorsel, int which)
c[n] = (guchar) (255.0 * priv->color[i]);
goff = priv->old_sample->allocation.width % 32;
}
-
+
wid = da->allocation.width;
heig = da->allocation.height;
-
+
buf = g_new(guchar, 3 * wid * heig);
-
+
#if 0
i = COLORSEL_RED;
for (n = 0; n < 3; n++)
@@ -372,11 +370,11 @@ color_sample_draw_sample (GtkColorSelection *colorsel, int which)
c[n + 3] = (guchar) (255.0 * priv->color[i++]);
}
#endif
-
+
if (priv->use_opacity)
{
o = (which) ? priv->color[COLORSEL_OPACITY] : priv->old_color[COLORSEL_OPACITY];
-
+
for (n = 0; n < 3; n++)
{
cc[n] = (guchar) ((1.0 - o) * 192 + (o * (gdouble) c[n]));
@@ -384,7 +382,7 @@ color_sample_draw_sample (GtkColorSelection *colorsel, int which)
}
cp = cc;
}
-
+
i = 0;
for (y = 0; y < heig; y++)
{
@@ -394,12 +392,12 @@ color_sample_draw_sample (GtkColorSelection *colorsel, int which)
f = 3 * ((((goff + x) % 32) < 16) ^ ((y % 32) < 16));
else
f = 0;
-
+
for (n = 0; n < 3; n++)
buf[i++] = cp[n + f];
}
}
-
+
gdk_draw_rgb_image(da->window,
da->style->black_gc,
0, 0,
@@ -407,10 +405,9 @@ color_sample_draw_sample (GtkColorSelection *colorsel, int which)
GDK_RGB_DITHER_NORMAL,
buf,
3*wid);
-
-
+
+
g_free (buf);
-
}
@@ -442,32 +439,32 @@ color_sample_setup_dnd (GtkColorSelection *colorsel, GtkWidget *sample)
};
ColorSelectionPrivate *priv;
priv = colorsel->private;
-
+
gtk_drag_source_set (sample,
GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
targets, 1,
GDK_ACTION_COPY | GDK_ACTION_MOVE);
-
+
gtk_signal_connect (GTK_OBJECT (sample),
"drag_begin",
GTK_SIGNAL_FUNC (color_sample_drag_begin),
colorsel);
if (sample == priv->cur_sample)
{
-
+
gtk_drag_dest_set (sample,
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
targets, 1,
GDK_ACTION_COPY);
-
+
gtk_signal_connect (GTK_OBJECT (sample),
"drag_end",
GTK_SIGNAL_FUNC (color_sample_drag_end),
colorsel);
}
-
+
gtk_signal_connect (GTK_OBJECT (sample),
"drag_data_get",
GTK_SIGNAL_FUNC (color_sample_drag_handle),
@@ -476,7 +473,7 @@ color_sample_setup_dnd (GtkColorSelection *colorsel, GtkWidget *sample)
"drag_data_received",
GTK_SIGNAL_FUNC (color_sample_drop_handle),
colorsel);
-
+
}
@@ -484,48 +481,36 @@ static void
color_sample_new (GtkColorSelection *colorsel)
{
ColorSelectionPrivate *priv;
-
+
priv = colorsel->private;
-
+
gtk_widget_push_visual(gdk_rgb_get_visual());
gtk_widget_push_colormap(gdk_rgb_get_cmap());
-
+
priv->sample_area = gtk_hbox_new (FALSE, 0);
priv->old_sample = gtk_drawing_area_new ();
priv->cur_sample = gtk_drawing_area_new ();
-
+
gtk_box_pack_start (GTK_BOX (priv->sample_area), priv->old_sample,
TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (priv->sample_area), priv->cur_sample,
TRUE, TRUE, 0);
gtk_widget_pop_visual();
gtk_widget_pop_colormap();
-
+
gtk_signal_connect(GTK_OBJECT (priv->old_sample), "expose_event",
GTK_SIGNAL_FUNC (color_old_sample_expose),
colorsel);
gtk_signal_connect(GTK_OBJECT (priv->cur_sample), "expose_event",
GTK_SIGNAL_FUNC (color_cur_sample_expose),
colorsel);
-
+
color_sample_setup_dnd (colorsel, priv->old_sample);
color_sample_setup_dnd (colorsel, priv->cur_sample);
-
+
gtk_widget_show_all (priv->sample_area);
}
-static void
-color_sample_set_use_opacity (GtkColorSelection *colorsel)
-{
- ColorSelectionPrivate *priv;
-
- g_return_if_fail (colorsel != NULL);
-
- priv = colorsel->private;
-
- color_sample_draw_samples (colorsel);
-}
-
/*
*
@@ -539,9 +524,9 @@ static void
palette_get_color (GtkWidget *drawing_area, gdouble *color)
{
gdouble *color_val;
-
+
g_return_if_fail (color != NULL);
-
+
color_val = gtk_object_get_data (GTK_OBJECT (drawing_area), "color_val");
if (color_val == NULL)
{
@@ -552,7 +537,7 @@ palette_get_color (GtkWidget *drawing_area, gdouble *color)
color[3] = 1.0;
return;
}
-
+
color[0] = color_val[0];
color[1] = color_val[1];
color[2] = color_val[2];
@@ -561,29 +546,31 @@ palette_get_color (GtkWidget *drawing_area, gdouble *color)
#define INTENSITY(r, g, b) ((r) * 0.30 + (g) * 0.59 + (b) * 0.11)
static void
-palette_paint (GtkWidget *drawing_area, GdkRectangle *area, gpointer data)
+palette_paint (GtkWidget *drawing_area,
+ GdkRectangle *area,
+ gpointer data)
{
if (drawing_area->window == NULL)
return;
-
+
gdk_window_clear_area (drawing_area->window,
area->x,
area->y,
area->width,
area->height);
-
+
if (GTK_WIDGET_HAS_FOCUS (drawing_area))
{
GdkGC *gc;
gdouble color[4];
-
+
palette_get_color (drawing_area, color);
-
+
if (INTENSITY (color[0], color[1], color[2]) > 0.5)
gc = drawing_area->style->black_gc;
else
gc = drawing_area->style->white_gc;
-
+
gdk_draw_rectangle (drawing_area->window,
gc, FALSE, 0, 0,
drawing_area->allocation.width - 1,
@@ -592,22 +579,26 @@ palette_paint (GtkWidget *drawing_area, GdkRectangle *area, gpointer data)
}
static void
-palette_expose (GtkWidget *drawing_area, GdkEventExpose *event, gpointer data)
+palette_expose (GtkWidget *drawing_area,
+ GdkEventExpose *event,
+ gpointer data)
{
if (drawing_area->window == NULL)
return;
-
+
palette_paint (drawing_area, &(event->area), data);
}
static void
-palette_focus_in (GtkWidget *drawing_area, GdkEventFocus *event, gpointer data)
+palette_focus_in (GtkWidget *drawing_area,
+ GdkEventFocus *event,
+ gpointer data)
{
ColorSelectionPrivate *priv;
-
+
if (drawing_area->window == NULL)
return;
-
+
priv = GTK_COLOR_SELECTION (data)->private;
priv->last_palette = drawing_area;
GTK_WIDGET_SET_FLAGS (drawing_area, GTK_HAS_FOCUS);
@@ -616,14 +607,18 @@ palette_focus_in (GtkWidget *drawing_area, GdkEventFocus *event, gpointer data)
}
static void
-palette_focus_out (GtkWidget *drawing_area, GdkEventFocus *event, gpointer data)
+palette_focus_out (GtkWidget *drawing_area,
+ GdkEventFocus *event,
+ gpointer data)
{
GTK_WIDGET_UNSET_FLAGS (drawing_area, GTK_HAS_FOCUS);
gtk_widget_queue_clear_area (drawing_area, 0, 0, drawing_area->allocation.x, drawing_area->allocation.y);
}
static void
-palette_press (GtkWidget *drawing_area, GdkEventButton *event, gpointer data)
+palette_press (GtkWidget *drawing_area,
+ GdkEventButton *event,
+ gpointer data)
{
gtk_widget_grab_focus (drawing_area);
if (GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (drawing_area), "color_set")) != 0)
@@ -635,7 +630,9 @@ palette_press (GtkWidget *drawing_area, GdkEventButton *event, gpointer data)
}
static void
-palette_draw (GtkWidget *drawing_area, GdkRectangle *area, gpointer data)
+palette_draw (GtkWidget *drawing_area,
+ GdkRectangle *area,
+ gpointer data)
{
palette_paint (drawing_area, area, data);
}
@@ -645,7 +642,7 @@ palette_unset_color (GtkWidget *drawing_area)
{
if (GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (drawing_area), "color_set")) == 0)
return;
-
+
gtk_widget_reset_rc_styles (drawing_area);
gtk_object_set_data (GTK_OBJECT (drawing_area), "color_set", GINT_TO_POINTER (0));
}
@@ -660,7 +657,7 @@ palette_drag_begin (GtkWidget *widget,
GtkWidget *window;
gdouble colors[4];
GdkColor bg;
-
+
priv = colorsel->private;
window = gtk_window_new (GTK_WINDOW_POPUP);
gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
@@ -670,15 +667,15 @@ palette_drag_begin (GtkWidget *widget,
"gtk-color-selection-drag-window",
window,
(GtkDestroyNotify) gtk_widget_destroy);
-
+
palette_get_color (widget, colors);
bg.red = 0xffff * colors[0];
bg.green = 0xffff * colors[1];
bg.blue = 0xffff * colors[2];
-
+
gdk_color_alloc (gtk_widget_get_colormap (window), &bg);
gdk_window_set_background (window->window, &bg);
-
+
gtk_drag_set_icon_widget (context, window, -2, -2);
}
@@ -692,26 +689,28 @@ palette_drag_handle (GtkWidget *widget,
{
guint16 vals[4];
gdouble colsrc[4];
-
+
palette_get_color (widget, colsrc);
-
+
vals[0] = colsrc[COLORSEL_RED] * 0xffff;
vals[1] = colsrc[COLORSEL_GREEN] * 0xffff;
vals[2] = colsrc[COLORSEL_BLUE] * 0xffff;
vals[3] = 0xffff;
-
+
gtk_selection_data_set (selection_data,
gdk_atom_intern ("application/x-color", FALSE),
16, (guchar *)vals, 8);
}
static void
-palette_set_color (GtkWidget *drawing_area, GtkColorSelection *colorsel, gdouble *color)
+palette_set_color (GtkWidget *drawing_area,
+ GtkColorSelection *colorsel,
+ gdouble *color)
{
GtkRcStyle *rc_style;
gdouble *new_color = g_new (double, 4);
gdouble *old_color;
-
+
rc_style = gtk_rc_style_new ();
rc_style->bg[GTK_STATE_NORMAL].red = color[0]*65535;
rc_style->bg[GTK_STATE_NORMAL].green = color[1]*65535;
@@ -719,7 +718,7 @@ palette_set_color (GtkWidget *drawing_area, GtkColorSelection *colorsel, gdouble
rc_style->color_flags[GTK_STATE_NORMAL] = GTK_RC_BG;
gtk_rc_style_ref (rc_style);
gtk_widget_modify_style (drawing_area, rc_style);
-
+
if (GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (drawing_area), "color_set")) == 0)
{
static const GtkTargetEntry targets[] = {
@@ -729,7 +728,7 @@ palette_set_color (GtkWidget *drawing_area, GtkColorSelection *colorsel, gdouble
GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
targets, 1,
GDK_ACTION_COPY | GDK_ACTION_MOVE);
-
+
gtk_signal_connect (GTK_OBJECT (drawing_area),
"drag_begin",
GTK_SIGNAL_FUNC (palette_drag_begin),
@@ -738,7 +737,7 @@ palette_set_color (GtkWidget *drawing_area, GtkColorSelection *colorsel, gdouble
"drag_data_get",
GTK_SIGNAL_FUNC (palette_drag_handle),
colorsel);
-
+
gtk_object_set_data (GTK_OBJECT (drawing_area), "color_set", GINT_TO_POINTER (1));
}
else
@@ -753,7 +752,7 @@ palette_set_color (GtkWidget *drawing_area, GtkColorSelection *colorsel, gdouble
new_color[1] = color[1];
new_color[2] = color[2];
new_color[3] = 1.0;
-
+
gtk_object_set_data (GTK_OBJECT (drawing_area), "color_val", new_color);
}
@@ -777,19 +776,19 @@ palette_drop_handle (GtkWidget *widget,
{
guint16 *vals;
gdouble color[4];
-
+
if (selection_data->length < 0)
return;
-
+
if ((selection_data->format != 16) ||
(selection_data->length != 8))
{
g_warning ("Received invalid color data\n");
return;
}
-
+
vals = (guint16 *)selection_data->data;
-
+
color[0] = (gdouble)vals[0] / 0xffff;
color[1] = (gdouble)vals[1] / 0xffff;
color[2] = (gdouble)vals[2] / 0xffff;
@@ -798,24 +797,24 @@ palette_drop_handle (GtkWidget *widget,
gtk_color_selection_set_color (GTK_COLOR_SELECTION (data), color);
}
-static int
-palette_activate (GtkWidget *widget,
- GdkEventKey *event,
- gpointer data)
+static gint
+palette_activate (GtkWidget *widget,
+ GdkEventKey *event,
+ gpointer data)
{
GtkColorSelection *colorsel = data;
ColorSelectionPrivate *priv;
-
+
if ((event->keyval == ' ') || (event->keyval == GDK_Return))
{
priv = colorsel->private;
palette_set_color (widget, GTK_COLOR_SELECTION (data), priv->color);
}
-
+
return TRUE;
}
-static GtkWidget *
+static GtkWidget*
palette_new (GtkColorSelection *colorsel)
{
GtkWidget *retval;
@@ -823,29 +822,29 @@ palette_new (GtkColorSelection *colorsel)
static const GtkTargetEntry targets[] = {
{ "application/x-color", 0 }
};
-
+
retval = gtk_drawing_area_new ();
gtk_object_set_data (GTK_OBJECT (retval), "color_set", GINT_TO_POINTER (0));
gtk_widget_set_events (retval, GDK_BUTTON_PRESS_MASK | GDK_EXPOSURE_MASK);
-
+
GTK_WIDGET_SET_FLAGS (retval, GTK_CAN_FOCUS);
gtk_signal_connect (GTK_OBJECT (retval), "focus_in_event", palette_focus_in, colorsel);
gtk_signal_connect (GTK_OBJECT (retval), "focus_out_event", palette_focus_out, colorsel);
gtk_signal_connect (GTK_OBJECT (retval), "draw", palette_draw, colorsel);
gtk_signal_connect (GTK_OBJECT (retval), "expose_event", palette_expose, colorsel);
gtk_signal_connect (GTK_OBJECT (retval), "button_press_event", palette_press, colorsel);
-
+
gtk_drag_dest_set (retval,
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
targets, 1,
GDK_ACTION_COPY);
-
+
gtk_signal_connect (GTK_OBJECT (retval), "drag_end", palette_drag_end, NULL);
gtk_signal_connect (GTK_OBJECT (retval), "drag_data_received", palette_drop_handle, colorsel);
gtk_signal_connect (GTK_OBJECT (retval), "key_press_event", GTK_SIGNAL_FUNC (palette_activate), colorsel);
-
+
return retval;
}
@@ -857,10 +856,10 @@ palette_new (GtkColorSelection *colorsel)
*/
static void
-initialize_cursor ()
+initialize_cursor (void)
{
GdkColor fg, bg;
-
+
GdkPixmap *pixmap =
gdk_bitmap_create_from_data (NULL,
dropper_bits,
@@ -869,19 +868,22 @@ initialize_cursor ()
gdk_bitmap_create_from_data (NULL,
dropper_mask,
DROPPER_WIDTH, DROPPER_HEIGHT);
-
+
gdk_color_white (gdk_colormap_get_system (), &bg);
gdk_color_black (gdk_colormap_get_system (), &fg);
-
+
picker_cursor = gdk_cursor_new_from_pixmap (pixmap, mask, &fg, &bg, DROPPER_X_HOT ,DROPPER_Y_HOT);
-
+
gdk_pixmap_unref (pixmap);
gdk_pixmap_unref (mask);
-
+
}
static void
-grab_color_at_mouse (GtkWidget *button, int x_root, int y_root, gpointer data)
+grab_color_at_mouse (GtkWidget *button,
+ gint x_root,
+ gint y_root,
+ gpointer data)
{
GdkImage *image;
guint32 pixel;
@@ -890,13 +892,13 @@ grab_color_at_mouse (GtkWidget *button, int x_root, int y_root, gpointer data)
ColorSelectionPrivate *priv;
GdkColormap *colormap = gdk_colormap_get_system ();
XColor xcolor;
-
+
priv = colorsel->private;
-
+
image = gdk_image_get (GDK_ROOT_PARENT (), x_root, y_root, 1, 1);
pixel = gdk_image_get_pixel (image, 0, 0);
visual = gdk_colormap_get_visual (colormap);
-
+
switch (visual->type) {
case GDK_VISUAL_DIRECT_COLOR:
case GDK_VISUAL_TRUE_COLOR:
@@ -926,7 +928,7 @@ grab_color_at_mouse (GtkWidget *button, int x_root, int y_root, gpointer data)
g_assert_not_reached ();
break;
}
-
+
gtk_rgb_to_hsv (priv->color[COLORSEL_RED],
priv->color[COLORSEL_GREEN],
priv->color[COLORSEL_BLUE],
@@ -937,33 +939,39 @@ grab_color_at_mouse (GtkWidget *button, int x_root, int y_root, gpointer data)
}
static void
-mouse_motion (GtkWidget *button, GdkEventMotion *event, gpointer data)
+mouse_motion (GtkWidget *button,
+ GdkEventMotion *event,
+ gpointer data)
{
grab_color_at_mouse (button, event->x_root, event->y_root, data);
}
static void
-mouse_release (GtkWidget *button, GdkEventButton *event, gpointer data)
+mouse_release (GtkWidget *button,
+ GdkEventButton *event,
+ gpointer data)
{
GtkColorSelection *colorsel = data;
ColorSelectionPrivate *priv;
priv = colorsel->private;
-
+
gtk_signal_disconnect_by_func (GTK_OBJECT (button), mouse_motion, data);
gtk_signal_disconnect_by_func (GTK_OBJECT (button), mouse_release, data);
-
+
grab_color_at_mouse (button, event->x_root, event->y_root, data);
gdk_pointer_ungrab (0);
}
/* Helper Functions */
static void
-mouse_press (GtkWidget *button, GdkEventButton *event, gpointer data)
+mouse_press (GtkWidget *button,
+ GdkEventButton *event,
+ gpointer data)
{
GtkColorSelection *colorsel = data;
ColorSelectionPrivate *priv;
priv = colorsel->private;
-
+
gtk_signal_connect (GTK_OBJECT (button), "motion_notify_event", mouse_motion, data);
gtk_signal_connect (GTK_OBJECT (button), "button_release_event", mouse_release, data);
gtk_signal_disconnect_by_func (GTK_OBJECT (button), mouse_press, data);
@@ -975,12 +983,12 @@ get_screen_color (GtkWidget *button)
{
GtkColorSelection *colorsel = gtk_object_get_data (GTK_OBJECT (button), "COLORSEL");
ColorSelectionPrivate *priv = colorsel->private;
-
+
if (picker_cursor == NULL)
{
initialize_cursor ();
}
-
+
/* Why do we do this? Because the "clicked" signal will be emitted after the "button_released"
signal. We don't want to do this stuff again, though, or else it will get trapped here. So,
priv->moving_dropper is initialized to FALSE at the initialization of the colorselector,
@@ -990,7 +998,7 @@ get_screen_color (GtkWidget *button)
{
priv->moving_dropper = TRUE;
gtk_signal_connect (GTK_OBJECT (button), "button_press_event", mouse_press, colorsel);
-
+
gdk_pointer_grab (button->window,
FALSE,
GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK,
@@ -1005,19 +1013,20 @@ get_screen_color (GtkWidget *button)
}
void
-hex_changed (GtkWidget *hex_entry, gpointer data)
+hex_changed (GtkWidget *hex_entry,
+ gpointer data)
{
GtkColorSelection *colorsel;
ColorSelectionPrivate *priv;
GdkColor color;
gchar *text;
-
+
colorsel = GTK_COLOR_SELECTION (data);
priv = colorsel->private;
-
+
if (priv->changing)
return;
-
+
text = gtk_editable_get_chars (GTK_EDITABLE (priv->hex_entry), 0, -1);
if (gdk_color_parse (text, &color))
{
@@ -1036,17 +1045,18 @@ hex_changed (GtkWidget *hex_entry, gpointer data)
}
void
-hsv_changed (GtkWidget *hsv, gpointer data)
+hsv_changed (GtkWidget *hsv,
+ gpointer data)
{
GtkColorSelection *colorsel;
ColorSelectionPrivate *priv;
-
+
colorsel = GTK_COLOR_SELECTION (data);
priv = colorsel->private;
-
+
if (priv->changing)
return;
-
+
gtk_hsv_get_color (GTK_HSV (hsv),
&priv->color[COLORSEL_HUE],
&priv->color[COLORSEL_SATURATION],
@@ -1061,17 +1071,18 @@ hsv_changed (GtkWidget *hsv, gpointer data)
}
void
-adjustment_changed (GtkAdjustment *adjustment, gpointer data)
+adjustment_changed (GtkAdjustment *adjustment,
+ gpointer data)
{
GtkColorSelection *colorsel;
ColorSelectionPrivate *priv;
-
+
colorsel = GTK_COLOR_SELECTION (gtk_object_get_data (GTK_OBJECT (adjustment), "COLORSEL"));
priv = colorsel->private;
-
+
if (priv->changing)
return;
-
+
switch (GPOINTER_TO_INT (data))
{
case COLORSEL_SATURATION:
@@ -1097,7 +1108,7 @@ adjustment_changed (GtkAdjustment *adjustment, gpointer data)
case COLORSEL_GREEN:
case COLORSEL_BLUE:
priv->color[GPOINTER_TO_INT (data)] = adjustment->value / 255;
-
+
gtk_rgb_to_hsv (priv->color[COLORSEL_RED],
priv->color[COLORSEL_GREEN],
priv->color[COLORSEL_BLUE],
@@ -1113,53 +1124,57 @@ adjustment_changed (GtkAdjustment *adjustment, gpointer data)
}
void
-opacity_entry_changed (GtkWidget *opacity_entry, gpointer data)
+opacity_entry_changed (GtkWidget *opacity_entry,
+ gpointer data)
{
GtkColorSelection *colorsel;
ColorSelectionPrivate *priv;
GtkAdjustment *adj;
gchar *text;
-
+
colorsel = GTK_COLOR_SELECTION (data);
priv = colorsel->private;
if (priv->changing)
return;
-
+
text = gtk_editable_get_chars (GTK_EDITABLE (priv->opacity_entry), 0, -1);
adj = gtk_range_get_adjustment (GTK_RANGE (priv->opacity_slider));
gtk_adjustment_set_value (adj, g_strtod (text, NULL));
-
+
update_color (colorsel);
-
+
g_free (text);
}
static void
-widget_focus_in (GtkWidget *drawing_area, GdkEventFocus *event, gpointer data)
- /* This signal is connected to by all of the widgets except the "Set Color" button */
- /* This will let you add a color to the currently selected palette */
+widget_focus_in (GtkWidget *drawing_area,
+ GdkEventFocus *event,
+ gpointer data)
{
GtkColorSelection *colorsel = GTK_COLOR_SELECTION (data);
- ColorSelectionPrivate *priv;
-
- priv = colorsel->private;
-
+ ColorSelectionPrivate *priv = colorsel->private;
+
+ /* This signal is connected to by all of the widgets except the "Set Color" button
+ * This will let you add a color to the currently selected palette
+ */
+
priv->last_palette = NULL;
}
static void
make_label_spinbutton (GtkColorSelection *colorsel,
- GtkWidget **spinbutton,
- gchar *text,
- GtkWidget *table,
- gint i, gint j,
- gint channel_type)
+ GtkWidget **spinbutton,
+ gchar *text,
+ GtkWidget *table,
+ gint i,
+ gint j,
+ gint channel_type)
{
GtkWidget *label;
GtkAdjustment *adjust;
-
+
if (channel_type == COLORSEL_HUE)
{
adjust = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 360.0, 1.0, 1.0, 1.0));
@@ -1176,15 +1191,18 @@ make_label_spinbutton (GtkColorSelection *colorsel,
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach_defaults (GTK_TABLE (table), label, i, i+1, j, j+1);
gtk_table_attach_defaults (GTK_TABLE (table), *spinbutton, i+1, i+2, j, j+1);
-
+
}
static void
-make_palette_frame (GtkColorSelection *colorsel, GtkWidget *table, gint i, gint j)
+make_palette_frame (GtkColorSelection *colorsel,
+ GtkWidget *table,
+ gint i,
+ gint j)
{
GtkWidget *frame;
ColorSelectionPrivate *priv;
-
+
priv = colorsel->private;
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
@@ -1201,9 +1219,10 @@ update_color (GtkColorSelection *colorsel)
gchar entryval[12];
gchar opacity_text[32];
gchar *ptr;
+
priv->changing = TRUE;
color_sample_draw_samples (colorsel);
-
+
gtk_hsv_set_color (GTK_HSV (priv->triangle_colorsel),
priv->color[COLORSEL_HUE],
priv->color[COLORSEL_SATURATION],
@@ -1229,15 +1248,15 @@ update_color (GtkColorSelection *colorsel)
gtk_adjustment_set_value (gtk_range_get_adjustment
(GTK_RANGE (priv->opacity_slider)),
priv->color[COLORSEL_OPACITY] * 255);
-
+
g_snprintf (opacity_text, 32, "%.0f", priv->color[COLORSEL_OPACITY] * 255);
gtk_entry_set_text (GTK_ENTRY (priv->opacity_entry), opacity_text);
-
+
g_snprintf (entryval, 11, "#%2X%2X%2X",
(guint) (255 * priv->color[COLORSEL_RED]),
(guint) (255 * priv->color[COLORSEL_GREEN]),
(guint) (255 * priv->color[COLORSEL_BLUE]));
-
+
for (ptr = entryval; *ptr; ptr++)
if (*ptr == ' ')
*ptr = '0';
@@ -1246,36 +1265,42 @@ update_color (GtkColorSelection *colorsel)
}
static void
-add_button_pressed (GtkWidget *button, GtkColorSelection *colorsel)
+add_button_pressed (GtkWidget *button,
+ GtkColorSelection *colorsel)
{
- gint i, j;
ColorSelectionPrivate *priv;
-
+ gint i, j;
+
priv = colorsel->private;
-
- for (j = 0; j < CUSTOM_PALETTE_HEIGHT; j++)
+
+ for (j = 0; j < GTK_CUSTOM_PALETTE_HEIGHT; j++)
{
- for (i = 0; i < CUSTOM_PALETTE_WIDTH; i++)
+ for (i = 0; i < GTK_CUSTOM_PALETTE_WIDTH; i++)
{
/* Either last_palette is set and we're on it, or it's an empty palette */
if ((priv->last_palette && priv->last_palette == priv->custom_palette[i][j]) ||
- ((priv->last_palette == NULL) && (GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (priv->custom_palette[i][j]),
- "color_set")) == 0)))
+ ((priv->last_palette == NULL) &&
+ (GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (priv->custom_palette[i][j]),
+ "color_set")) == 0)))
{
palette_set_color (priv->custom_palette[i][j], colorsel, priv->color);
+
/* forward the selection */
- if ((i == CUSTOM_PALETTE_WIDTH - 1) && (j == CUSTOM_PALETTE_HEIGHT - 1))
+ if ((i == GTK_CUSTOM_PALETTE_WIDTH - 1) && (j == GTK_CUSTOM_PALETTE_HEIGHT - 1))
gtk_widget_grab_focus (priv->custom_palette[0][0]);
- else if (i == CUSTOM_PALETTE_WIDTH - 1)
+ else if (i == GTK_CUSTOM_PALETTE_WIDTH - 1)
gtk_widget_grab_focus (priv->custom_palette[0][j + 1]);
else
gtk_widget_grab_focus (priv->custom_palette[i + 1][j]);
+
return;
}
}
}
+
/* the palette is totally full. Add to the first one totally arbitrarily */
palette_set_color (priv->custom_palette[0][0], colorsel, priv->color);
+
/* forward the selection */
gtk_widget_grab_focus (priv->custom_palette[1][0]);
}
@@ -1284,7 +1309,7 @@ GtkType
gtk_color_selection_get_type (void)
{
static GtkType color_selection_type = 0;
-
+
if (!color_selection_type)
{
static const GtkTypeInfo color_selection_info =
@@ -1298,10 +1323,10 @@ gtk_color_selection_get_type (void)
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL,
};
-
- color_selection_type = gtk_type_unique (gtk_vbox_get_type (), &color_selection_info);
+
+ color_selection_type = gtk_type_unique (GTK_TYPE_VBOX, &color_selection_info);
}
-
+
return color_selection_type;
}
@@ -1309,22 +1334,22 @@ static void
gtk_color_selection_class_init (GtkColorSelectionClass *klass)
{
GtkObjectClass *object_class;
-
+
object_class = (GtkObjectClass*) klass;
-
- parent_class = gtk_type_class (gtk_vbox_get_type ());
-
+
+ parent_class = gtk_type_class (GTK_TYPE_VBOX);
+
color_selection_signals[COLOR_CHANGED] =
gtk_signal_new ("color_changed",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkColorSelectionClass, color_changed),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
-
-
+
+
gtk_object_class_add_signals (object_class, color_selection_signals, LAST_SIGNAL);
-
+
object_class->destroy = gtk_color_selection_destroy;
}
@@ -1342,53 +1367,51 @@ gtk_color_selection_init (GtkColorSelection *colorsel)
GdkBitmap *mask = NULL;
gint i, j;
ColorSelectionPrivate *priv;
-
- priv = colorsel->private = g_new (ColorSelectionPrivate, 1);
+
+ priv = colorsel->private = g_new0 (ColorSelectionPrivate, 1);
priv->changing = FALSE;
priv->default_set = FALSE;
priv->last_palette = NULL;
priv->moving_dropper = FALSE;
-
+
gtk_box_set_spacing (GTK_BOX (colorsel), 4);
top_hbox = gtk_hbox_new (FALSE, 8);
gtk_box_pack_start (GTK_BOX (colorsel), top_hbox, FALSE, FALSE, 0);
-
+
vbox = gtk_vbox_new (FALSE, 4);
priv->triangle_colorsel = gtk_hsv_new ();
gtk_signal_connect (GTK_OBJECT (priv->triangle_colorsel), "changed", hsv_changed, colorsel);
gtk_hsv_set_metrics (GTK_HSV (priv->triangle_colorsel), 174, 15);
gtk_box_pack_start (GTK_BOX (top_hbox), vbox, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), priv->triangle_colorsel, FALSE, FALSE, 0);
-
+
hbox = gtk_hbox_new (FALSE, 4);
gtk_box_pack_end (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
-
+
frame = gtk_frame_new (NULL);
gtk_widget_set_usize (frame, -1, 30);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
color_sample_new (colorsel);
gtk_container_add (GTK_CONTAINER (frame), priv->sample_area);
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
-
+
button = gtk_button_new ();
gtk_signal_connect (GTK_OBJECT (button), "focus_in_event", widget_focus_in, colorsel);
- gtk_widget_set_events (button, GDK_POINTER_MOTION_MASK
- | GDK_POINTER_MOTION_HINT_MASK);
+ gtk_widget_set_events (button, GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK);
gtk_object_set_data (GTK_OBJECT (button), "COLORSEL", colorsel);
gtk_signal_connect (GTK_OBJECT (button), "clicked", get_screen_color, NULL);
dropper_pixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL, gtk_widget_get_colormap (button), &mask, NULL, picker);
dropper_image = gtk_pixmap_new (dropper_pixmap, mask);
gtk_container_add (GTK_CONTAINER (button), dropper_image);
- label = gtk_label_new (_("Color Picker"));
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
-
+
top_right_vbox = gtk_vbox_new (FALSE, 4);
gtk_box_pack_start (GTK_BOX (top_hbox), top_right_vbox, FALSE, FALSE, 0);
table = gtk_table_new (8, 6, FALSE);
gtk_box_pack_start (GTK_BOX (top_right_vbox), table, FALSE, FALSE, 0);
gtk_table_set_row_spacings (GTK_TABLE (table), 4);
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
-
+
make_label_spinbutton (colorsel, &priv->hue_spinbutton, _("Hue:"), table, 0, 0, COLORSEL_HUE);
make_label_spinbutton (colorsel, &priv->sat_spinbutton, _("Saturation:"), table, 0, 1, COLORSEL_SATURATION);
make_label_spinbutton (colorsel, &priv->val_spinbutton, _("Value:"), table, 0, 2, COLORSEL_VALUE);
@@ -1396,7 +1419,7 @@ gtk_color_selection_init (GtkColorSelection *colorsel)
make_label_spinbutton (colorsel, &priv->green_spinbutton, _("Green:"), table, 6, 1, COLORSEL_GREEN);
make_label_spinbutton (colorsel, &priv->blue_spinbutton, _("Blue:"), table, 6, 2, COLORSEL_BLUE);
gtk_table_attach_defaults (GTK_TABLE (table), gtk_hseparator_new (), 0, 8, 3, 4);
-
+
priv->opacity_label = gtk_label_new (_("Opacity:"));
gtk_misc_set_alignment (GTK_MISC (priv->opacity_label), 1.0, 0.5);
gtk_table_attach_defaults (GTK_TABLE (table), priv->opacity_label, 0, 1, 4, 5);
@@ -1411,7 +1434,7 @@ gtk_color_selection_init (GtkColorSelection *colorsel)
gtk_signal_connect (GTK_OBJECT (priv->opacity_entry), "focus_in_event", widget_focus_in, colorsel);
gtk_signal_connect (GTK_OBJECT (priv->opacity_entry), "activate", opacity_entry_changed, colorsel);
gtk_table_attach_defaults (GTK_TABLE (table), priv->opacity_entry, 7, 8, 4, 5);
-
+
label = gtk_label_new (_("Hex Value:"));
gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 5, 6);
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
@@ -1420,14 +1443,14 @@ gtk_color_selection_init (GtkColorSelection *colorsel)
gtk_widget_set_usize (priv->hex_entry, 75, -1);
gtk_table_set_col_spacing (GTK_TABLE (table), 3, 25);
gtk_table_attach_defaults (GTK_TABLE (table), priv->hex_entry, 1, 5, 5, 6);
-
+
/* Set up the palette */
- table = gtk_table_new (CUSTOM_PALETTE_HEIGHT, CUSTOM_PALETTE_WIDTH, TRUE);
+ table = gtk_table_new (GTK_CUSTOM_PALETTE_HEIGHT, GTK_CUSTOM_PALETTE_WIDTH, TRUE);
gtk_table_set_row_spacings (GTK_TABLE (table), 1);
gtk_table_set_col_spacings (GTK_TABLE (table), 1);
- for (i = 0; i < CUSTOM_PALETTE_WIDTH; i++)
+ for (i = 0; i < GTK_CUSTOM_PALETTE_WIDTH; i++)
{
- for (j = 0; j < CUSTOM_PALETTE_HEIGHT; j++)
+ for (j = 0; j < GTK_CUSTOM_PALETTE_HEIGHT; j++)
{
make_palette_frame (colorsel, table, i, j);
}
@@ -1441,16 +1464,16 @@ gtk_color_selection_init (GtkColorSelection *colorsel)
gtk_signal_connect (GTK_OBJECT (button), "clicked", add_button_pressed, colorsel);
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
-
+
gtk_widget_show_all (top_hbox);
-
+
if (priv->use_opacity == FALSE)
{
gtk_widget_hide (priv->opacity_label);
gtk_widget_hide (priv->opacity_slider);
gtk_widget_hide (priv->opacity_entry);
}
-
+
if (priv->use_palette == FALSE)
{
gtk_widget_hide (priv->palette_frame);
@@ -1460,7 +1483,15 @@ gtk_color_selection_init (GtkColorSelection *colorsel)
static void
gtk_color_selection_destroy (GtkObject *object)
{
- g_free (GTK_COLOR_SELECTION (object)->private);
+ GtkColorSelection *cselection = GTK_COLOR_SELECTION (object);
+
+ if (cselection->private)
+ {
+ g_free (cselection->private);
+ cselection->private = NULL;
+ }
+
+ GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
@@ -1483,28 +1514,28 @@ gtk_color_selection_new (void)
color[1] = 1.0;
color[2] = 1.0;
color[3] = 1.0;
-
+
colorsel = gtk_type_new (GTK_TYPE_COLOR_SELECTION);
priv = colorsel->private;
gtk_color_selection_set_color (colorsel, color);
gtk_color_selection_set_use_opacity (colorsel, FALSE);
-
+
/* We want to make sure that default_set is FALSE */
/* This way the user can still set it */
priv->default_set = FALSE;
-
+
return GTK_WIDGET (colorsel);
}
void
-gtk_color_selection_set_update_policy (GtkColorSelection *colorsel,
- GtkUpdateType policy)
+gtk_color_selection_set_update_policy (GtkColorSelection *colorsel,
+ GtkUpdateType policy)
{
g_return_if_fail (colorsel != NULL);
g_return_if_fail (GTK_IS_COLOR_SELECTION (colorsel));
/* */
- g_warning ("This function is deprecated.");
+ g_warning (G_STRLOC ": This function is deprecated.");
}
/**
@@ -1516,13 +1547,15 @@ gtk_color_selection_set_update_policy (GtkColorSelection *colorsel,
* Return value: TRUE if the @colorsel uses opacity. FALSE if it does't.
**/
gboolean
-gtk_color_selection_get_use_opacity (GtkColorSelection *colorsel)
+gtk_color_selection_get_use_opacity (GtkColorSelection *colorsel)
{
ColorSelectionPrivate *priv;
+
g_return_val_if_fail (colorsel != NULL, FALSE);
g_return_val_if_fail (GTK_IS_COLOR_SELECTION (colorsel), FALSE);
-
+
priv = colorsel->private;
+
return priv->use_opacity;
}
@@ -1535,31 +1568,34 @@ gtk_color_selection_get_use_opacity (GtkColorSelection *colorsel)
*
**/
void
-gtk_color_selection_set_use_opacity (GtkColorSelection *colorsel,
- gboolean use_opacity)
+gtk_color_selection_set_use_opacity (GtkColorSelection *colorsel,
+ gboolean use_opacity)
{
ColorSelectionPrivate *priv;
+
g_return_if_fail (colorsel != NULL);
g_return_if_fail (GTK_IS_COLOR_SELECTION (colorsel));
-
+
priv = colorsel->private;
- if (priv->use_opacity == use_opacity)
- return;
-
- priv->use_opacity = use_opacity;
- if (use_opacity)
- {
- gtk_widget_show (priv->opacity_slider);
- gtk_widget_show (priv->opacity_label);
- gtk_widget_show (priv->opacity_entry);
- }
- else
+ use_opacity = use_opacity != FALSE;
+
+ if (priv->use_opacity != use_opacity)
{
- gtk_widget_hide (priv->opacity_slider);
- gtk_widget_hide (priv->opacity_label);
- gtk_widget_hide (priv->opacity_entry);
+ priv->use_opacity = use_opacity;
+ if (use_opacity)
+ {
+ gtk_widget_show (priv->opacity_slider);
+ gtk_widget_show (priv->opacity_label);
+ gtk_widget_show (priv->opacity_entry);
+ }
+ else
+ {
+ gtk_widget_hide (priv->opacity_slider);
+ gtk_widget_hide (priv->opacity_label);
+ gtk_widget_hide (priv->opacity_entry);
+ }
+ color_sample_draw_samples (colorsel);
}
- color_sample_set_use_opacity (colorsel);
}
/**
@@ -1571,13 +1607,14 @@ gtk_color_selection_set_use_opacity (GtkColorSelection *colorsel,
* Return value: TRUE if the palette is used. FALSE if it isn't.
**/
gboolean
-gtk_color_selection_get_use_palette (GtkColorSelection *colorsel)
+gtk_color_selection_get_use_palette (GtkColorSelection *colorsel)
{
ColorSelectionPrivate *priv;
- g_return_val_if_fail (colorsel != NULL, FALSE);
+
g_return_val_if_fail (GTK_IS_COLOR_SELECTION (colorsel), FALSE);
-
+
priv = colorsel->private;
+
return priv->use_palette;
}
@@ -1590,22 +1627,24 @@ gtk_color_selection_get_use_palette (GtkColorSelection *colorsel)
*
**/
void
-gtk_color_selection_set_use_palette (GtkColorSelection *colorsel,
- gboolean use_palette)
+gtk_color_selection_set_use_palette (GtkColorSelection *colorsel,
+ gboolean use_palette)
{
ColorSelectionPrivate *priv;
g_return_if_fail (colorsel != NULL);
g_return_if_fail (GTK_IS_COLOR_SELECTION (colorsel));
-
+
priv = colorsel->private;
- if (priv->use_palette == use_palette)
- return;
-
- priv->use_palette = use_palette;
- if (use_palette)
- gtk_widget_show (priv->palette_frame);
- else
- gtk_widget_hide (priv->palette_frame);
+ use_palette = use_palette != FALSE;
+
+ if (priv->use_palette != use_palette)
+ {
+ priv->use_palette = use_palette;
+ if (use_palette)
+ gtk_widget_show (priv->palette_frame);
+ else
+ gtk_widget_hide (priv->palette_frame);
+ }
}
/**
@@ -1618,15 +1657,15 @@ gtk_color_selection_set_use_palette (GtkColorSelection *colorsel,
*
**/
void
-gtk_color_selection_set_color (GtkColorSelection *colorsel,
- gdouble *color)
+gtk_color_selection_set_color (GtkColorSelection *colorsel,
+ gdouble *color)
{
ColorSelectionPrivate *priv;
gint i;
-
+
g_return_if_fail (colorsel != NULL);
g_return_if_fail (GTK_IS_COLOR_SELECTION (colorsel));
-
+
priv = colorsel->private;
priv->changing = TRUE;
priv->color[COLORSEL_RED] = color[0];
@@ -1657,14 +1696,14 @@ gtk_color_selection_set_color (GtkColorSelection *colorsel,
*
**/
void
-gtk_color_selection_get_color (GtkColorSelection *colorsel,
- gdouble *color)
+gtk_color_selection_get_color (GtkColorSelection *colorsel,
+ gdouble *color)
{
ColorSelectionPrivate *priv;
-
+
g_return_if_fail (colorsel != NULL);
g_return_if_fail (GTK_IS_COLOR_SELECTION (colorsel));
-
+
priv = colorsel->private;
color[0] = priv->color[COLORSEL_RED];
color[1] = priv->color[COLORSEL_GREEN];
@@ -1684,14 +1723,14 @@ gtk_color_selection_get_color (GtkColorSelection *colorsel,
*
**/
void
-gtk_color_selection_set_old_color (GtkColorSelection *colorsel,
- gdouble *color)
+gtk_color_selection_set_old_color (GtkColorSelection *colorsel,
+ gdouble *color)
{
ColorSelectionPrivate *priv;
-
+
g_return_if_fail (colorsel != NULL);
g_return_if_fail (GTK_IS_COLOR_SELECTION (colorsel));
-
+
priv = colorsel->private;
priv->changing = TRUE;
priv->old_color[COLORSEL_RED] = color[0];
@@ -1717,14 +1756,14 @@ gtk_color_selection_set_old_color (GtkColorSelection *colorsel,
*
**/
void
-gtk_color_selection_get_old_color (GtkColorSelection *colorsel,
- gdouble *color)
+gtk_color_selection_get_old_color (GtkColorSelection *colorsel,
+ gdouble *color)
{
ColorSelectionPrivate *priv;
-
+
g_return_if_fail (colorsel != NULL);
g_return_if_fail (GTK_IS_COLOR_SELECTION (colorsel));
-
+
priv = colorsel->private;
color[0] = priv->old_color[COLORSEL_RED];
color[1] = priv->old_color[COLORSEL_GREEN];
@@ -1744,16 +1783,16 @@ gtk_color_selection_get_old_color (GtkColorSelection *colorsel,
**/
void
gtk_color_selection_set_palette_color (GtkColorSelection *colorsel,
- gint x,
- gint y,
- gdouble *color)
+ gint x,
+ gint y,
+ gdouble *color)
{
ColorSelectionPrivate *priv;
-
+
g_return_if_fail (colorsel != NULL);
g_return_if_fail (GTK_IS_COLOR_SELECTION (colorsel));
- g_return_if_fail (x >= 0 && y >= 0 && x < CUSTOM_PALETTE_WIDTH && y < CUSTOM_PALETTE_HEIGHT);
-
+ g_return_if_fail (x >= 0 && y >= 0 && x < GTK_CUSTOM_PALETTE_WIDTH && y < GTK_CUSTOM_PALETTE_HEIGHT);
+
priv = colorsel->private;
palette_set_color (priv->custom_palette[x][y], colorsel, color);
}
@@ -1773,21 +1812,21 @@ gtk_color_selection_set_palette_color (GtkColorSelection *colorsel,
**/
gboolean
gtk_color_selection_get_palette_color (GtkColorSelection *colorsel,
- gint x,
- gint y,
- gdouble *color)
+ gint x,
+ gint y,
+ gdouble *color)
{
ColorSelectionPrivate *priv;
-
+
g_return_val_if_fail (colorsel != NULL, FALSE);
g_return_val_if_fail (GTK_IS_COLOR_SELECTION (colorsel), FALSE);
- g_return_val_if_fail (x >= 0 && y >= 0 && x < CUSTOM_PALETTE_WIDTH && y < CUSTOM_PALETTE_HEIGHT, FALSE);
-
+ g_return_val_if_fail (x >= 0 && y >= 0 && x < GTK_CUSTOM_PALETTE_WIDTH && y < GTK_CUSTOM_PALETTE_HEIGHT, FALSE);
+
priv = colorsel->private;
-
+
if (GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (priv->custom_palette[x][y]), "color_set")) == 0)
return FALSE;
-
+
palette_get_color (priv->custom_palette[x][y], color);
return TRUE;
}
@@ -1803,15 +1842,15 @@ gtk_color_selection_get_palette_color (GtkColorSelection *colorsel,
**/
void
gtk_color_selection_unset_palette_color (GtkColorSelection *colorsel,
- gint x,
- gint y)
+ gint x,
+ gint y)
{
ColorSelectionPrivate *priv;
-
+
g_return_if_fail (colorsel != NULL);
g_return_if_fail (GTK_IS_COLOR_SELECTION (colorsel));
- g_return_if_fail (x >= 0 && y >= 0 && x < CUSTOM_PALETTE_WIDTH && y < CUSTOM_PALETTE_HEIGHT);
-
+ g_return_if_fail (x >= 0 && y >= 0 && x < GTK_CUSTOM_PALETTE_WIDTH && y < GTK_CUSTOM_PALETTE_HEIGHT);
+
priv = colorsel->private;
palette_unset_color (priv->custom_palette[x][y]);
}
@@ -1826,14 +1865,14 @@ gtk_color_selection_unset_palette_color (GtkColorSelection *colorsel,
* if the selection has stopped.
**/
gboolean
-gtk_color_selection_is_adjusting (GtkColorSelection *colorsel)
+gtk_color_selection_is_adjusting (GtkColorSelection *colorsel)
{
ColorSelectionPrivate *priv;
-
+
g_return_val_if_fail (colorsel != NULL, FALSE);
g_return_val_if_fail (GTK_IS_COLOR_SELECTION (colorsel), FALSE);
priv = colorsel->private;
-
+
return (gtk_hsv_is_adjusting (GTK_HSV (priv->triangle_colorsel)));
}
diff --git a/gtk/gtkcolorsel.h b/gtk/gtkcolorsel.h
index 56f11bd806..00104463f5 100644
--- a/gtk/gtkcolorsel.h
+++ b/gtk/gtkcolorsel.h
@@ -34,6 +34,7 @@
extern "C" {
#endif /* __cplusplus */
+
#define GTK_TYPE_COLOR_SELECTION (gtk_color_selection_get_type ())
#define GTK_COLOR_SELECTION(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_COLOR_SELECTION, GtkColorSelection))
#define GTK_COLOR_SELECTION_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_COLOR_SELECTION, GtkColorSelectionClass))
@@ -43,8 +44,8 @@ extern "C" {
/* Number of elements in the custom palatte */
-#define CUSTOM_PALETTE_WIDTH 10
-#define CUSTOM_PALETTE_HEIGHT 2
+#define GTK_CUSTOM_PALETTE_WIDTH 10
+#define GTK_CUSTOM_PALETTE_HEIGHT 2
typedef struct _GtkColorSelection GtkColorSelection;
typedef struct _GtkColorSelectionClass GtkColorSelectionClass;
@@ -52,7 +53,7 @@ typedef struct _GtkColorSelectionClass GtkColorSelectionClass;
struct _GtkColorSelection
{
- GtkVBox parent;
+ GtkVBox parent_instance;
/* < private > */
gpointer private;
@@ -68,16 +69,16 @@ struct _GtkColorSelectionClass
/* ColorSelection */
-GtkType gtk_color_selection_get_type (void);
-GtkWidget *gtk_color_selection_new (void);
-void gtk_color_selection_set_update_policy (GtkColorSelection *colorsel,
- GtkUpdateType policy);
-gboolean gtk_color_selection_get_use_opacity (GtkColorSelection *colorsel);
-void gtk_color_selection_set_use_opacity (GtkColorSelection *colorsel,
- gboolean use_opacity);
-gboolean gtk_color_selection_get_use_palette (GtkColorSelection *colorsel);
-void gtk_color_selection_set_use_palette (GtkColorSelection *colorsel,
- gboolean use_palette);
+GtkType gtk_color_selection_get_type (void);
+GtkWidget * gtk_color_selection_new (void);
+void gtk_color_selection_set_update_policy (GtkColorSelection *colorsel,
+ GtkUpdateType policy);
+gboolean gtk_color_selection_get_use_opacity (GtkColorSelection *colorsel);
+void gtk_color_selection_set_use_opacity (GtkColorSelection *colorsel,
+ gboolean use_opacity);
+gboolean gtk_color_selection_get_use_palette (GtkColorSelection *colorsel);
+void gtk_color_selection_set_use_palette (GtkColorSelection *colorsel,
+ gboolean use_palette);
/* The Color set is an array of doubles, of the following format:
* color[0] = red_channel;
@@ -85,26 +86,26 @@ void gtk_color_selection_set_use_palette (GtkColorSelection *colorsel,
* color[2] = blue_channel;
* color[3] = alpha_channel;
*/
-void gtk_color_selection_set_color (GtkColorSelection *colorsel,
+void gtk_color_selection_set_color (GtkColorSelection *colorsel,
gdouble *color);
-void gtk_color_selection_get_color (GtkColorSelection *colorsel,
+void gtk_color_selection_get_color (GtkColorSelection *colorsel,
gdouble *color);
-void gtk_color_selection_set_old_color (GtkColorSelection *colorsel,
+void gtk_color_selection_set_old_color (GtkColorSelection *colorsel,
gdouble *color);
-void gtk_color_selection_get_old_color (GtkColorSelection *colorsel,
+void gtk_color_selection_get_old_color (GtkColorSelection *colorsel,
gdouble *color);
-void gtk_color_selection_set_palette_color (GtkColorSelection *colorsel,
- gint x,
+void gtk_color_selection_set_palette_color (GtkColorSelection *colorsel,
+ gint x,
gint y,
gdouble *color);
-gboolean gtk_color_selection_get_palette_color (GtkColorSelection *colorsel,
+gboolean gtk_color_selection_get_palette_color (GtkColorSelection *colorsel,
gint x,
gint y,
gdouble *color);
-void gtk_color_selection_unset_palette_color(GtkColorSelection *colorsel,
+void gtk_color_selection_unset_palette_color (GtkColorSelection *colorsel,
gint x,
gint y);
-gboolean gtk_color_selection_is_adjusting (GtkColorSelection *colorsel);
+gboolean gtk_color_selection_is_adjusting (GtkColorSelection *colorsel);
#ifdef __cplusplus
diff --git a/gtk/gtkcolorseldialog.c b/gtk/gtkcolorseldialog.c
index c884ca96dd..4c32b7b213 100644
--- a/gtk/gtkcolorseldialog.c
+++ b/gtk/gtkcolorseldialog.c
@@ -44,7 +44,7 @@ GtkType
gtk_color_selection_dialog_get_type (void)
{
static GtkType color_selection_dialog_type = 0;
-
+
if (!color_selection_dialog_type)
{
GtkTypeInfo colorsel_diag_info =
@@ -58,10 +58,10 @@ gtk_color_selection_dialog_get_type (void)
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL,
};
-
+
color_selection_dialog_type = gtk_type_unique (GTK_TYPE_DIALOG, &colorsel_diag_info);
}
-
+
return color_selection_dialog_type;
}
@@ -69,9 +69,9 @@ static void
gtk_color_selection_dialog_class_init (GtkColorSelectionDialogClass *klass)
{
GtkObjectClass *object_class;
-
+
object_class = (GtkObjectClass*) klass;
-
+
color_selection_dialog_parent_class = gtk_type_class (GTK_TYPE_DIALOG);
}
@@ -79,47 +79,47 @@ static void
gtk_color_selection_dialog_init (GtkColorSelectionDialog *colorseldiag)
{
GtkWidget *action_area_button_box, *frame;
-
+
gtk_widget_set_visual (GTK_WIDGET (colorseldiag), gdk_rgb_get_visual ());
gtk_widget_set_colormap (GTK_WIDGET (colorseldiag), gdk_rgb_get_cmap ());
-
+
gtk_widget_push_visual (gdk_rgb_get_visual ());
gtk_widget_push_colormap (gdk_rgb_get_cmap ());
-
+
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (colorseldiag)->vbox), frame);
gtk_container_set_border_width (GTK_CONTAINER (frame), 10);
gtk_widget_show (frame);
-
+
colorseldiag->colorsel = gtk_color_selection_new ();
gtk_color_selection_set_use_palette (GTK_COLOR_SELECTION(colorseldiag->colorsel), FALSE);
gtk_color_selection_set_use_opacity (GTK_COLOR_SELECTION(colorseldiag->colorsel), FALSE);
gtk_container_add (GTK_CONTAINER (frame), colorseldiag->colorsel);
gtk_widget_show (colorseldiag->colorsel);
-
+
action_area_button_box = gtk_hbutton_box_new ();
gtk_button_box_set_layout (GTK_BUTTON_BOX(action_area_button_box), GTK_BUTTONBOX_END);
gtk_button_box_set_spacing (GTK_BUTTON_BOX(action_area_button_box), 5);
gtk_box_pack_end (GTK_BOX (GTK_DIALOG (colorseldiag)->action_area), action_area_button_box, TRUE, TRUE, 0);
gtk_widget_show (action_area_button_box);
-
+
colorseldiag->ok_button = gtk_button_new_with_label (_("OK"));
GTK_WIDGET_SET_FLAGS (colorseldiag->ok_button, GTK_CAN_DEFAULT);
gtk_box_pack_start (GTK_BOX (action_area_button_box), colorseldiag->ok_button, TRUE, TRUE, 0);
gtk_widget_grab_default (colorseldiag->ok_button);
gtk_widget_show (colorseldiag->ok_button);
-
+
colorseldiag->cancel_button = gtk_button_new_with_label (_("Cancel"));
GTK_WIDGET_SET_FLAGS (colorseldiag->cancel_button, GTK_CAN_DEFAULT);
gtk_box_pack_start (GTK_BOX (action_area_button_box), colorseldiag->cancel_button, TRUE, TRUE, 0);
gtk_widget_show (colorseldiag->cancel_button);
-
+
colorseldiag->help_button = gtk_button_new_with_label (_("Help"));
GTK_WIDGET_SET_FLAGS (colorseldiag->help_button, GTK_CAN_DEFAULT);
gtk_box_pack_start (GTK_BOX (action_area_button_box), colorseldiag->help_button, TRUE, TRUE, 0);
gtk_widget_show (colorseldiag->help_button);
-
+
gtk_widget_pop_colormap ();
gtk_widget_pop_visual ();
}
@@ -128,11 +128,10 @@ GtkWidget*
gtk_color_selection_dialog_new (const gchar *title)
{
GtkColorSelectionDialog *colorseldiag;
-
+
colorseldiag = gtk_type_new (GTK_TYPE_COLOR_SELECTION_DIALOG);
gtk_window_set_title (GTK_WINDOW (colorseldiag), title);
gtk_window_set_policy(GTK_WINDOW (colorseldiag), FALSE, FALSE, TRUE);
-
+
return GTK_WIDGET (colorseldiag);
}
-
diff --git a/gtk/gtkcolorseldialog.h b/gtk/gtkcolorseldialog.h
index ba6530cc21..ac065c906c 100644
--- a/gtk/gtkcolorseldialog.h
+++ b/gtk/gtkcolorseldialog.h
@@ -29,7 +29,7 @@
#include <gtk/gtkdialog.h>
#include <gtk/gtkcolorsel.h>
#include <gtk/gtkvbox.h>
-#include "gtkintl.h"
+#include <gtk/gtkintl.h>
#ifdef __cplusplus
extern "C" {
@@ -49,7 +49,7 @@ typedef struct _GtkColorSelectionDialogClass GtkColorSelectionDialogClass;
struct _GtkColorSelectionDialog
{
- GtkDialog dialog;
+ GtkDialog parent_instance;
GtkWidget *colorsel;
GtkWidget *ok_button;
@@ -64,8 +64,8 @@ struct _GtkColorSelectionDialogClass
/* ColorSelectionDialog */
-GtkType gtk_color_selection_dialog_get_type (void);
-GtkWidget* gtk_color_selection_dialog_new (const gchar *title);
+GtkType gtk_color_selection_dialog_get_type (void);
+GtkWidget* gtk_color_selection_dialog_new (const gchar *title);
#ifdef __cplusplus
diff --git a/gtk/gtkcombo.c b/gtk/gtkcombo.c
index 33cb37669c..fc0f267b01 100644
--- a/gtk/gtkcombo.c
+++ b/gtk/gtkcombo.c
@@ -110,13 +110,18 @@ gtk_combo_class_init (GtkComboClass * klass)
}
static void
-gtk_combo_destroy (GtkObject * combo)
+gtk_combo_destroy (GtkObject *object)
{
- gtk_widget_destroy (GTK_COMBO (combo)->popwin);
- gtk_widget_unref (GTK_COMBO (combo)->popwin);
+ GtkCombo *combo = GTK_COMBO (object);
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (*GTK_OBJECT_CLASS (parent_class)->destroy) (combo);
+ if (combo->popwin)
+ {
+ gtk_widget_destroy (combo->popwin);
+ gtk_widget_unref (combo->popwin);
+ combo->popwin = NULL;
+ }
+
+ GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
static int
@@ -340,9 +345,8 @@ gtk_combo_get_pos (GtkCombo * combo, gint * x, gint * y, gint * height, gint * w
if (!show_hscroll &&
alloc_width < list_requisition.width)
{
- work_height += popup->hscrollbar->requisition.height +
- GTK_SCROLLED_WINDOW_CLASS
- (GTK_OBJECT (combo->popup)->klass)->scrollbar_spacing;
+ work_height += (popup->hscrollbar->requisition.height +
+ GTK_SCROLLED_WINDOW_GET_CLASS (combo->popup)->scrollbar_spacing);
show_hscroll = TRUE;
}
if (!show_vscroll &&
@@ -354,10 +358,8 @@ gtk_combo_get_pos (GtkCombo * combo, gint * x, gint * y, gint * height, gint * w
*y -= (work_height + list_requisition.height + real_height);
break;
}
- alloc_width -=
- popup->vscrollbar->requisition.width +
- GTK_SCROLLED_WINDOW_CLASS
- (GTK_OBJECT (combo->popup)->klass)->scrollbar_spacing;
+ alloc_width -= (popup->vscrollbar->requisition.width +
+ GTK_SCROLLED_WINDOW_GET_CLASS (combo->popup)->scrollbar_spacing);
show_vscroll = TRUE;
}
} while (old_width != alloc_width || old_height != work_height);
@@ -834,7 +836,10 @@ gtk_combo_item_destroy (GtkObject * object)
key = gtk_object_get_data (object, gtk_combo_string_key);
if (key)
- g_free (key);
+ {
+ gtk_object_remove_data (object, gtk_combo_string_key);
+ g_free (key);
+ }
}
void
diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c
index 5e3fbd149e..ec2eca9736 100644
--- a/gtk/gtkcontainer.c
+++ b/gtk/gtkcontainer.c
@@ -173,7 +173,7 @@ gtk_container_class_init (GtkContainerClass *class)
container_signals[ADD] =
gtk_signal_new ("add",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkContainerClass, add),
gtk_marshal_NONE__POINTER,
GTK_TYPE_NONE, 1,
@@ -181,7 +181,7 @@ gtk_container_class_init (GtkContainerClass *class)
container_signals[REMOVE] =
gtk_signal_new ("remove",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkContainerClass, remove),
gtk_marshal_NONE__POINTER,
GTK_TYPE_NONE, 1,
@@ -189,14 +189,14 @@ gtk_container_class_init (GtkContainerClass *class)
container_signals[CHECK_RESIZE] =
gtk_signal_new ("check_resize",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkContainerClass, check_resize),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
container_signals[FOCUS] =
gtk_signal_new ("focus",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkContainerClass, focus),
gtk_marshal_ENUM__ENUM,
GTK_TYPE_DIRECTION_TYPE, 1,
@@ -204,7 +204,7 @@ gtk_container_class_init (GtkContainerClass *class)
container_signals[SET_FOCUS_CHILD] =
gtk_signal_new ("set-focus-child",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkContainerClass, set_focus_child),
gtk_marshal_NONE__POINTER,
GTK_TYPE_NONE, 1,
@@ -237,7 +237,7 @@ gtk_container_child_type (GtkContainer *container)
g_return_val_if_fail (container != NULL, 0);
g_return_val_if_fail (GTK_IS_CONTAINER (container), 0);
- class = GTK_CONTAINER_CLASS (GTK_OBJECT (container)->klass);
+ class = GTK_CONTAINER_GET_CLASS (container);
if (class->child_type)
slot = class->child_type (container);
else
@@ -1104,7 +1104,7 @@ gtk_container_forall (GtkContainer *container,
g_return_if_fail (GTK_IS_CONTAINER (container));
g_return_if_fail (callback != NULL);
- class = GTK_CONTAINER_CLASS (GTK_OBJECT (container)->klass);
+ class = GTK_CONTAINER_GET_CLASS (container);
if (class->forall)
class->forall (container, TRUE, callback, callback_data);
@@ -1121,7 +1121,7 @@ gtk_container_foreach (GtkContainer *container,
g_return_if_fail (GTK_IS_CONTAINER (container));
g_return_if_fail (callback != NULL);
- class = GTK_CONTAINER_CLASS (GTK_OBJECT (container)->klass);
+ class = GTK_CONTAINER_GET_CLASS (container);
if (class->forall)
class->forall (container, FALSE, callback, callback_data);
@@ -1144,8 +1144,8 @@ gtk_container_foreach_unmarshal (GtkWidget *child,
/* first argument */
args[0].name = NULL;
- args[0].type = GTK_OBJECT(child)->klass->type;
- GTK_VALUE_OBJECT(args[0]) = GTK_OBJECT (child);
+ args[0].type = GTK_OBJECT_TYPE (child);
+ GTK_VALUE_OBJECT (args[0]) = GTK_OBJECT (child);
/* location for return value */
args[1].name = NULL;
@@ -1227,42 +1227,6 @@ gtk_container_children (GtkContainer *container)
return g_list_reverse (children);
}
-void
-gtk_container_register_toplevel (GtkContainer *container)
-{
- g_return_if_fail (container != NULL);
-
- toplevel_list = g_list_prepend (toplevel_list, container);
-
- gtk_widget_ref (GTK_WIDGET (container));
- gtk_object_sink (GTK_OBJECT (container));
-}
-
-void
-gtk_container_unregister_toplevel (GtkContainer *container)
-{
- GList *node;
-
- g_return_if_fail (container != NULL);
-
- node = g_list_find (toplevel_list, container);
- g_return_if_fail (node != NULL);
-
- toplevel_list = g_list_remove_link (toplevel_list, node);
- g_list_free_1 (node);
-
- gtk_widget_unref (GTK_WIDGET (container));
-}
-
-GList*
-gtk_container_get_toplevels (void)
-{
- /* XXX: fixme we should ref all these widgets and duplicate
- * the list.
- */
- return toplevel_list;
-}
-
static void
gtk_container_child_position_callback (GtkWidget *widget,
gpointer client_data)
@@ -1327,7 +1291,7 @@ gtk_container_child_composite_name (GtkContainer *container,
{
GtkContainerClass *class;
- class = GTK_CONTAINER_CLASS (GTK_OBJECT (container)->klass);
+ class = GTK_CONTAINER_GET_CLASS (container);
if (class->composite_name)
name = class->composite_name (container, child);
}
diff --git a/gtk/gtkcontainer.h b/gtk/gtkcontainer.h
index f3e1de3586..89e8c36e34 100644
--- a/gtk/gtkcontainer.h
+++ b/gtk/gtkcontainer.h
@@ -141,9 +141,6 @@ void gtk_container_set_focus_vadjustment (GtkContainer *container,
GtkAdjustment *adjustment);
void gtk_container_set_focus_hadjustment (GtkContainer *container,
GtkAdjustment *adjustment);
-void gtk_container_register_toplevel (GtkContainer *container);
-void gtk_container_unregister_toplevel (GtkContainer *container);
-GList* gtk_container_get_toplevels (void);
void gtk_container_resize_children (GtkContainer *container);
diff --git a/gtk/gtkctree.c b/gtk/gtkctree.c
index 8532317b0e..79ebafed39 100644
--- a/gtk/gtkctree.c
+++ b/gtk/gtkctree.c
@@ -56,26 +56,25 @@ COLUMN_FROM_XPIXEL (GtkCList * clist,
gint x)
{
gint i, cx;
-
+
for (i = 0; i < clist->columns; i++)
if (clist->column[i].visible)
{
cx = clist->column[i].area.x + clist->hoffset;
-
+
if (x >= (cx - (COLUMN_INSET + CELL_SPACING)) &&
x <= (cx + clist->column[i].area.width + COLUMN_INSET))
return i;
}
-
+
/* no match */
return -1;
}
-#define GTK_CLIST_CLASS_FW(_widget_) GTK_CLIST_CLASS (((GtkObject*) (_widget_))->klass)
#define CLIST_UNFROZEN(clist) (((GtkCList*) (clist))->freeze_count == 0)
#define CLIST_REFRESH(clist) G_STMT_START { \
if (CLIST_UNFROZEN (clist)) \
- GTK_CLIST_CLASS_FW (clist)->refresh ((GtkCList*) (clist)); \
+ GTK_CLIST_GET_CLASS (clist)->refresh ((GtkCList*) (clist)); \
} G_STMT_END
@@ -319,7 +318,7 @@ GtkType
gtk_ctree_get_type (void)
{
static GtkType ctree_type = 0;
-
+
if (!ctree_type)
{
static const GtkTypeInfo ctree_info =
@@ -333,10 +332,10 @@ gtk_ctree_get_type (void)
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL,
};
-
+
ctree_type = gtk_type_unique (GTK_TYPE_CLIST, &ctree_info);
}
-
+
return ctree_type;
}
@@ -347,15 +346,15 @@ gtk_ctree_class_init (GtkCTreeClass *klass)
GtkWidgetClass *widget_class;
GtkCListClass *clist_class;
GtkBindingSet *binding_set;
-
+
object_class = (GtkObjectClass *) klass;
widget_class = (GtkWidgetClass *) klass;
container_class = (GtkContainerClass *) klass;
clist_class = (GtkCListClass *) klass;
-
+
parent_class = gtk_type_class (GTK_TYPE_CLIST);
container_class = gtk_type_class (GTK_TYPE_CONTAINER);
-
+
gtk_object_add_arg_type ("GtkCTree::n_columns",
GTK_TYPE_UINT,
GTK_ARG_READWRITE | GTK_ARG_CONSTRUCT_ONLY,
@@ -386,39 +385,39 @@ gtk_ctree_class_init (GtkCTreeClass *klass)
ARG_EXPANDER_STYLE);
object_class->set_arg = gtk_ctree_set_arg;
object_class->get_arg = gtk_ctree_get_arg;
-
+
ctree_signals[TREE_SELECT_ROW] =
gtk_signal_new ("tree_select_row",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkCTreeClass, tree_select_row),
gtk_marshal_NONE__POINTER_INT,
GTK_TYPE_NONE, 2, GTK_TYPE_CTREE_NODE, GTK_TYPE_INT);
ctree_signals[TREE_UNSELECT_ROW] =
gtk_signal_new ("tree_unselect_row",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkCTreeClass, tree_unselect_row),
gtk_marshal_NONE__POINTER_INT,
GTK_TYPE_NONE, 2, GTK_TYPE_CTREE_NODE, GTK_TYPE_INT);
ctree_signals[TREE_EXPAND] =
gtk_signal_new ("tree_expand",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkCTreeClass, tree_expand),
gtk_marshal_NONE__POINTER,
GTK_TYPE_NONE, 1, GTK_TYPE_CTREE_NODE);
ctree_signals[TREE_COLLAPSE] =
gtk_signal_new ("tree_collapse",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkCTreeClass, tree_collapse),
gtk_marshal_NONE__POINTER,
GTK_TYPE_NONE, 1, GTK_TYPE_CTREE_NODE);
ctree_signals[TREE_MOVE] =
gtk_signal_new ("tree_move",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkCTreeClass, tree_move),
gtk_marshal_NONE__POINTER_POINTER_POINTER,
GTK_TYPE_NONE, 3, GTK_TYPE_CTREE_NODE,
@@ -426,21 +425,21 @@ gtk_ctree_class_init (GtkCTreeClass *klass)
ctree_signals[CHANGE_FOCUS_ROW_EXPANSION] =
gtk_signal_new ("change_focus_row_expansion",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkCTreeClass,
change_focus_row_expansion),
gtk_marshal_NONE__ENUM,
GTK_TYPE_NONE, 1, GTK_TYPE_CTREE_EXPANSION_TYPE);
gtk_object_class_add_signals (object_class, ctree_signals, LAST_SIGNAL);
-
+
widget_class->realize = gtk_ctree_realize;
widget_class->unrealize = gtk_ctree_unrealize;
widget_class->button_press_event = gtk_ctree_button_press;
-
+
widget_class->drag_begin = gtk_ctree_drag_begin;
widget_class->drag_motion = gtk_ctree_drag_motion;
widget_class->drag_data_received = gtk_ctree_drag_data_received;
-
+
clist_class->select_row = real_select_row;
clist_class->unselect_row = real_unselect_row;
clist_class->row_move = real_row_move;
@@ -459,14 +458,14 @@ gtk_ctree_class_init (GtkCTreeClass *klass)
clist_class->sort_list = real_sort_list;
clist_class->set_cell_contents = set_cell_contents;
clist_class->cell_size_request = cell_size_request;
-
+
klass->tree_select_row = real_tree_select;
klass->tree_unselect_row = real_tree_unselect;
klass->tree_expand = real_tree_expand;
klass->tree_collapse = real_tree_collapse;
klass->tree_move = real_tree_move;
klass->change_focus_row_expansion = change_focus_row_expansion;
-
+
binding_set = gtk_binding_set_by_class (klass);
gtk_binding_entry_add_signal (binding_set,
'+', GDK_SHIFT_MASK,
@@ -515,9 +514,9 @@ gtk_ctree_set_arg (GtkObject *object,
guint arg_id)
{
GtkCTree *ctree;
-
+
ctree = GTK_CTREE (object);
-
+
switch (arg_id)
{
case ARG_N_COLUMNS: /* construct-only arg, only set when !GTK_CONSTRUCTED */
@@ -563,9 +562,9 @@ gtk_ctree_get_arg (GtkObject *object,
guint arg_id)
{
GtkCTree *ctree;
-
+
ctree = GTK_CTREE (object);
-
+
switch (arg_id)
{
case ARG_N_COLUMNS:
@@ -599,12 +598,12 @@ static void
gtk_ctree_init (GtkCTree *ctree)
{
GtkCList *clist;
-
+
GTK_CLIST_SET_FLAG (ctree, CLIST_DRAW_DRAG_RECT);
GTK_CLIST_SET_FLAG (ctree, CLIST_DRAW_DRAG_LINE);
-
+
clist = GTK_CLIST (ctree);
-
+
ctree->tree_indent = 20;
ctree->tree_spacing = 5;
ctree->tree_column = 0;
@@ -612,7 +611,7 @@ gtk_ctree_init (GtkCTree *ctree)
ctree->expander_style = GTK_CTREE_EXPANDER_SQUARE;
ctree->drag_compare = NULL;
ctree->show_stub = TRUE;
-
+
clist->button_actions[0] |= GTK_BUTTON_EXPANDS;
}
@@ -623,24 +622,24 @@ ctree_attach_styles (GtkCTree *ctree,
{
GtkCList *clist;
gint i;
-
+
clist = GTK_CLIST (ctree);
-
+
if (GTK_CTREE_ROW (node)->row.style)
GTK_CTREE_ROW (node)->row.style =
gtk_style_attach (GTK_CTREE_ROW (node)->row.style, clist->clist_window);
-
+
if (GTK_CTREE_ROW (node)->row.fg_set || GTK_CTREE_ROW (node)->row.bg_set)
{
GdkColormap *colormap;
-
+
colormap = gtk_widget_get_colormap (GTK_WIDGET (ctree));
if (GTK_CTREE_ROW (node)->row.fg_set)
gdk_color_alloc (colormap, &(GTK_CTREE_ROW (node)->row.foreground));
if (GTK_CTREE_ROW (node)->row.bg_set)
gdk_color_alloc (colormap, &(GTK_CTREE_ROW (node)->row.background));
}
-
+
for (i = 0; i < clist->columns; i++)
if (GTK_CTREE_ROW (node)->row.cell[i].style)
GTK_CTREE_ROW (node)->row.cell[i].style =
@@ -655,9 +654,9 @@ ctree_detach_styles (GtkCTree *ctree,
{
GtkCList *clist;
gint i;
-
+
clist = GTK_CLIST (ctree);
-
+
if (GTK_CTREE_ROW (node)->row.style)
gtk_style_detach (GTK_CTREE_ROW (node)->row.style);
for (i = 0; i < clist->columns; i++)
@@ -674,15 +673,15 @@ gtk_ctree_realize (GtkWidget *widget)
GtkCTreeNode *node;
GtkCTreeNode *child;
gint i;
-
+
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_CTREE (widget));
-
+
GTK_WIDGET_CLASS (parent_class)->realize (widget);
-
+
ctree = GTK_CTREE (widget);
clist = GTK_CLIST (widget);
-
+
node = GTK_CTREE_NODE (clist->row_list);
for (i = 0; i < clist->rows; i++)
{
@@ -692,7 +691,7 @@ gtk_ctree_realize (GtkWidget *widget)
gtk_ctree_pre_recursive (ctree, child, ctree_attach_styles, NULL);
node = GTK_CTREE_NODE_NEXT (node);
}
-
+
values.foreground = widget->style->fg[GTK_STATE_NORMAL];
values.background = widget->style->base[GTK_STATE_NORMAL];
values.subwindow_mode = GDK_INCLUDE_INFERIORS;
@@ -703,7 +702,7 @@ gtk_ctree_realize (GtkWidget *widget)
GDK_GC_BACKGROUND |
GDK_GC_SUBWINDOW |
GDK_GC_LINE_STYLE);
-
+
if (ctree->line_style == GTK_CTREE_LINES_DOTTED)
{
gdk_gc_set_line_attributes (ctree->lines_gc, 1,
@@ -717,21 +716,21 @@ gtk_ctree_unrealize (GtkWidget *widget)
{
GtkCTree *ctree;
GtkCList *clist;
-
+
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_CTREE (widget));
-
+
GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
-
+
ctree = GTK_CTREE (widget);
clist = GTK_CLIST (widget);
-
+
if (GTK_WIDGET_REALIZED (widget))
{
GtkCTreeNode *node;
GtkCTreeNode *child;
gint i;
-
+
node = GTK_CTREE_NODE (clist->row_list);
for (i = 0; i < clist->rows; i++)
{
@@ -743,7 +742,7 @@ gtk_ctree_unrealize (GtkWidget *widget)
node = GTK_CTREE_NODE_NEXT (node);
}
}
-
+
gdk_gc_destroy (ctree->lines_gc);
}
@@ -754,19 +753,19 @@ gtk_ctree_button_press (GtkWidget *widget,
GtkCTree *ctree;
GtkCList *clist;
gint button_actions;
-
+
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_CTREE (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
-
+
ctree = GTK_CTREE (widget);
clist = GTK_CLIST (widget);
-
+
button_actions = clist->button_actions[event->button - 1];
-
+
if (button_actions == GTK_BUTTON_IGNORED)
return FALSE;
-
+
if (event->window == clist->clist_window)
{
GtkCTreeNode *work;
@@ -774,15 +773,15 @@ gtk_ctree_button_press (GtkWidget *widget,
gint y;
gint row;
gint column;
-
+
x = event->x;
y = event->y;
-
+
if (!gtk_clist_get_selection_info (clist, x, y, &row, &column))
return FALSE;
-
+
work = GTK_CTREE_NODE (g_list_nth (clist->row_list, row));
-
+
if (button_actions & GTK_BUTTON_EXPANDS &&
(GTK_CTREE_ROW (work)->children && !GTK_CTREE_ROW (work)->is_leaf &&
(event->type == GDK_2BUTTON_PRESS ||
@@ -792,7 +791,7 @@ gtk_ctree_button_press (GtkWidget *widget,
gtk_ctree_collapse (ctree, work);
else
gtk_ctree_expand (ctree, work);
-
+
return FALSE;
}
}
@@ -810,16 +809,16 @@ draw_drag_highlight (GtkCList *clist,
gint level;
gint i;
gint y = 0;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CTREE (clist));
-
+
ctree = GTK_CTREE (clist);
-
+
level = ((GtkCTreeRow *)(dest_row))->level;
-
+
y = ROW_TOP_YPIXEL (clist, dest_row_number) - 1;
-
+
switch (drag_pos)
{
case GTK_CLIST_DRAG_NONE:
@@ -840,7 +839,7 @@ draw_drag_highlight (GtkCList *clist,
COLUMN_LEFT_XPIXEL(clist, ctree->tree_column - 1)+
clist->column[ctree->tree_column - 1].area.width,
y);
-
+
gdk_draw_line (clist->clist_window, clist->xor_gc,
COLUMN_LEFT_XPIXEL(clist, ctree->tree_column) +
ctree->tree_indent * level -
@@ -854,7 +853,7 @@ draw_drag_highlight (GtkCList *clist,
y,
COLUMN_LEFT_XPIXEL(clist, clist->columns - 1) +
clist->column[clist->columns - 1].area.width, y);
-
+
gdk_draw_line (clist->clist_window, clist->xor_gc,
0, y, COLUMN_LEFT_XPIXEL(clist, ctree->tree_column)
+ clist->column[ctree->tree_column].area.width -
@@ -868,7 +867,7 @@ draw_drag_highlight (GtkCList *clist,
break;
case GTK_CLIST_DRAG_INTO:
y = ROW_TOP_YPIXEL (clist, dest_row_number) + clist->row_height;
-
+
if (clist->column[ctree->tree_column].visible)
switch (clist->column[ctree->tree_column].justification)
{
@@ -884,12 +883,12 @@ draw_drag_highlight (GtkCList *clist,
points[1].y = points[0].y;
points[2].x = points[1].x;
points[2].y = points[3].y;
-
+
for (i = 0; i < 3; i++)
gdk_draw_line (clist->clist_window, clist->xor_gc,
points[i].x, points[i].y,
points[i+1].x, points[i+1].y);
-
+
if (ctree->tree_column > 0)
{
points[0].x = COLUMN_LEFT_XPIXEL(clist,
@@ -902,7 +901,7 @@ draw_drag_highlight (GtkCList *clist,
points[1].y = points[0].y;
points[2].x = 0;
points[2].y = points[3].y;
-
+
for (i = 0; i < 3; i++)
gdk_draw_line (clist->clist_window, clist->xor_gc,
points[i].x, points[i].y, points[i+1].x,
@@ -920,12 +919,12 @@ draw_drag_highlight (GtkCList *clist,
points[1].y = points[0].y;
points[2].x = 0;
points[2].y = points[3].y;
-
+
for (i = 0; i < 3; i++)
gdk_draw_line (clist->clist_window, clist->xor_gc,
points[i].x, points[i].y,
points[i+1].x, points[i+1].y);
-
+
if (ctree->tree_column < clist->columns - 1)
{
points[0].x = COLUMN_LEFT_XPIXEL(clist, ctree->tree_column +1);
@@ -936,7 +935,7 @@ draw_drag_highlight (GtkCList *clist,
points[1].y = points[0].y;
points[2].x = points[1].x;
points[2].y = points[3].y;
-
+
for (i = 0; i < 3; i++)
gdk_draw_line (clist->clist_window, clist->xor_gc,
points[i].x, points[i].y,
@@ -965,7 +964,7 @@ draw_cell_pixmap (GdkWindow *window,
{
gint xsrc = 0;
gint ysrc = 0;
-
+
if (mask)
{
gdk_gc_set_clip_mask (fg_gc, mask);
@@ -979,7 +978,7 @@ draw_cell_pixmap (GdkWindow *window,
}
if (x + width > clip_rectangle->x + clip_rectangle->width)
width = clip_rectangle->x + clip_rectangle->width - x;
-
+
if (y < clip_rectangle->y)
{
ysrc = clip_rectangle->y - y;
@@ -988,16 +987,16 @@ draw_cell_pixmap (GdkWindow *window,
}
if (y + height > clip_rectangle->y + clip_rectangle->height)
height = clip_rectangle->y + clip_rectangle->height - y;
-
+
if (width > 0 && height > 0)
gdk_draw_pixmap (window, fg_gc, pixmap, xsrc, ysrc, x, y, width, height);
-
+
if (mask)
{
gdk_gc_set_clip_rectangle (fg_gc, NULL);
gdk_gc_set_clip_origin (fg_gc, 0, 0);
}
-
+
return x + MAX (width, 0);
}
@@ -1011,13 +1010,13 @@ get_cell_style (GtkCList *clist,
GdkGC **bg_gc)
{
gint fg_state;
-
+
if ((state == GTK_STATE_NORMAL) &&
(GTK_WIDGET (clist)->state == GTK_STATE_INSENSITIVE))
fg_state = GTK_STATE_INSENSITIVE;
else
fg_state = state;
-
+
if (clist_row->cell[column].style)
{
if (style)
@@ -1056,7 +1055,7 @@ get_cell_style (GtkCList *clist,
else
*bg_gc = GTK_WIDGET (clist)->style->base_gc[state];
}
-
+
if (state != GTK_STATE_SELECTED)
{
if (fg_gc && clist_row->fg_set)
@@ -1078,10 +1077,10 @@ gtk_ctree_draw_expander (GtkCTree *ctree,
GdkPoint points[3];
gint justification_factor;
gint y;
-
- if (ctree->expander_style == GTK_CTREE_EXPANDER_NONE)
- return x;
-
+
+ if (ctree->expander_style == GTK_CTREE_EXPANDER_NONE)
+ return x;
+
clist = GTK_CLIST (ctree);
if (clist->column[ctree->tree_column].justification == GTK_JUSTIFY_RIGHT)
justification_factor = -1;
@@ -1089,7 +1088,7 @@ gtk_ctree_draw_expander (GtkCTree *ctree,
justification_factor = 1;
y = (clip_rectangle->y + (clip_rectangle->height - PM_SIZE) / 2 -
(clip_rectangle->height + 1) % 2);
-
+
if (!ctree_row->children)
{
switch (ctree->expander_style)
@@ -1103,10 +1102,10 @@ gtk_ctree_draw_expander (GtkCTree *ctree,
return x + justification_factor * (PM_SIZE + 1);
}
}
-
+
gdk_gc_set_clip_rectangle (style->fg_gc[GTK_STATE_NORMAL], clip_rectangle);
gdk_gc_set_clip_rectangle (style->base_gc[GTK_STATE_NORMAL], clip_rectangle);
-
+
switch (ctree->expander_style)
{
case GTK_CTREE_EXPANDER_NONE:
@@ -1132,19 +1131,19 @@ gtk_ctree_draw_expander (GtkCTree *ctree,
justification_factor * (2 * (PM_SIZE + 2) / 3 - 1));
points[2].y = points[0].y + (PM_SIZE + 2) / 2;
}
-
+
gdk_draw_polygon (clist->clist_window, style->base_gc[GTK_STATE_NORMAL],
TRUE, points, 3);
gdk_draw_polygon (clist->clist_window, style->fg_gc[GTK_STATE_NORMAL],
FALSE, points, 3);
-
+
x += justification_factor * (PM_SIZE + 3);
break;
case GTK_CTREE_EXPANDER_SQUARE:
case GTK_CTREE_EXPANDER_CIRCULAR:
if (justification_factor == -1)
x += justification_factor * (PM_SIZE + 1);
-
+
if (ctree->expander_style == GTK_CTREE_EXPANDER_CIRCULAR)
{
gdk_draw_arc (clist->clist_window, style->base_gc[GTK_STATE_NORMAL],
@@ -1161,23 +1160,23 @@ gtk_ctree_draw_expander (GtkCTree *ctree,
style->fg_gc[GTK_STATE_NORMAL], FALSE,
x, y, PM_SIZE, PM_SIZE);
}
-
+
gdk_draw_line (clist->clist_window, style->fg_gc[GTK_STATE_NORMAL],
x + 2, y + PM_SIZE / 2, x + PM_SIZE - 2, y + PM_SIZE / 2);
-
+
if (!ctree_row->expanded)
gdk_draw_line (clist->clist_window, style->fg_gc[GTK_STATE_NORMAL],
x + PM_SIZE / 2, y + 2,
x + PM_SIZE / 2, y + PM_SIZE - 2);
-
+
if (justification_factor == 1)
x += justification_factor * (PM_SIZE + 1);
break;
}
-
+
gdk_gc_set_clip_rectangle (style->fg_gc[GTK_STATE_NORMAL], NULL);
gdk_gc_set_clip_rectangle (style->base_gc[GTK_STATE_NORMAL], NULL);
-
+
return x;
}
@@ -1214,7 +1213,7 @@ gtk_ctree_draw_lines (GtkCTree *ctree,
clist = GTK_CLIST (ctree);
ycenter = clip_rectangle->y + (clip_rectangle->height / 2);
justify_right = (clist->column[column].justification == GTK_JUSTIFY_RIGHT);
-
+
if (justify_right)
{
offset = (clip_rectangle->x + clip_rectangle->width - 1 -
@@ -1226,25 +1225,25 @@ gtk_ctree_draw_lines (GtkCTree *ctree,
offset = clip_rectangle->x + ctree->tree_indent * (ctree_row->level - 1);
justification_factor = 1;
}
-
+
switch (ctree->line_style)
{
case GTK_CTREE_LINES_NONE:
break;
case GTK_CTREE_LINES_TABBED:
xcenter = offset + justification_factor * TAB_SIZE;
-
+
column_right = (COLUMN_LEFT_XPIXEL (clist, ctree->tree_column) +
clist->column[ctree->tree_column].area.width +
COLUMN_INSET);
column_left = (COLUMN_LEFT_XPIXEL (clist, ctree->tree_column) -
COLUMN_INSET - CELL_SPACING);
-
+
if (area)
{
tree_rectangle.y = crect->y;
tree_rectangle.height = crect->height;
-
+
if (justify_right)
{
tree_rectangle.x = xcenter;
@@ -1255,18 +1254,18 @@ gtk_ctree_draw_lines (GtkCTree *ctree,
tree_rectangle.x = column_left;
tree_rectangle.width = xcenter - column_left;
}
-
+
if (!gdk_rectangle_intersect (area, &tree_rectangle, &tc_rectangle))
{
offset += justification_factor * 3;
break;
}
}
-
+
gdk_gc_set_clip_rectangle (ctree->lines_gc, crect);
-
+
next_level = ctree_row->level;
-
+
if (!ctree_row->sibling || (ctree_row->children && ctree_row->expanded))
{
node = gtk_ctree_find_node_ptr (ctree, ctree_row);
@@ -1275,21 +1274,21 @@ gtk_ctree_draw_lines (GtkCTree *ctree,
else
next_level = 0;
}
-
+
if (ctree->tree_indent > 0)
{
node = ctree_row->parent;
while (node)
{
xcenter -= (justification_factor * ctree->tree_indent);
-
+
if ((justify_right && xcenter < column_left) ||
(!justify_right && xcenter > column_right))
{
node = GTK_CTREE_ROW (node)->parent;
continue;
}
-
+
tree_rectangle.y = cell_rectangle->y;
tree_rectangle.height = cell_rectangle->height;
if (justify_right)
@@ -1305,17 +1304,17 @@ gtk_ctree_draw_lines (GtkCTree *ctree,
tree_rectangle.width = MIN (column_right - xcenter,
ctree->tree_indent);
}
-
+
if (!area || gdk_rectangle_intersect (area, &tree_rectangle,
&tc_rectangle))
{
get_cell_style (clist, &GTK_CTREE_ROW (node)->row,
state, column, NULL, NULL, &bg_gc);
-
+
if (bg_gc == clist->bg_gc)
gdk_gc_set_foreground
(clist->bg_gc, &GTK_CTREE_ROW (node)->row.background);
-
+
if (!area)
gdk_draw_rectangle (clist->clist_window, bg_gc, TRUE,
tree_rectangle.x,
@@ -1336,16 +1335,16 @@ gtk_ctree_draw_lines (GtkCTree *ctree,
else
{
gint width;
-
+
offset_x = MIN (ctree->tree_indent, 2 * TAB_SIZE);
width = offset_x / 2 + offset_x % 2;
-
+
parent = GTK_CTREE_ROW (node)->parent;
-
+
tree_rectangle.y = ycenter;
tree_rectangle.height = (cell_rectangle->y - ycenter +
cell_rectangle->height);
-
+
if (justify_right)
{
tree_rectangle.x = MAX(xcenter + 1 - width, column_left);
@@ -1358,7 +1357,7 @@ gtk_ctree_draw_lines (GtkCTree *ctree,
tree_rectangle.width = MIN (column_right - xcenter,
width);
}
-
+
if (!area ||
gdk_rectangle_intersect (area, &tree_rectangle,
&tc_rectangle))
@@ -1376,7 +1375,7 @@ gtk_ctree_draw_lines (GtkCTree *ctree,
bg_gc = style->base_gc[state];
else
bg_gc = GTK_WIDGET (clist)->style->base_gc[state];
-
+
if (!area)
gdk_draw_rectangle (clist->clist_window, bg_gc, TRUE,
tree_rectangle.x,
@@ -1391,13 +1390,13 @@ gtk_ctree_draw_lines (GtkCTree *ctree,
tc_rectangle.width,
tc_rectangle.height);
}
-
+
get_cell_style (clist, &GTK_CTREE_ROW (node)->row,
state, column, NULL, NULL, &bg_gc);
if (bg_gc == clist->bg_gc)
gdk_gc_set_foreground
(clist->bg_gc, &GTK_CTREE_ROW (node)->row.background);
-
+
gdk_gc_set_clip_rectangle (bg_gc, crect);
gdk_draw_arc (clist->clist_window, bg_gc, TRUE,
xcenter - (justify_right * offset_x),
@@ -1405,10 +1404,10 @@ gtk_ctree_draw_lines (GtkCTree *ctree,
offset_x, clist->row_height,
(180 + (justify_right * 90)) * 64, 90 * 64);
gdk_gc_set_clip_rectangle (bg_gc, NULL);
-
+
gdk_draw_line (clist->clist_window, ctree->lines_gc,
xcenter, cell_rectangle->y, xcenter, ycenter);
-
+
if (justify_right)
gdk_draw_arc (clist->clist_window, ctree->lines_gc, FALSE,
xcenter - offset_x, cell_rectangle->y,
@@ -1423,7 +1422,7 @@ gtk_ctree_draw_lines (GtkCTree *ctree,
node = GTK_CTREE_ROW (node)->parent;
}
}
-
+
if (state != GTK_STATE_SELECTED)
{
tree_rectangle.y = clip_rectangle->y;
@@ -1431,12 +1430,12 @@ gtk_ctree_draw_lines (GtkCTree *ctree,
tree_rectangle.width = COLUMN_INSET + CELL_SPACING +
MIN (clist->column[ctree->tree_column].area.width + COLUMN_INSET,
TAB_SIZE);
-
+
if (justify_right)
tree_rectangle.x = MAX (xcenter + 1, column_left);
else
tree_rectangle.x = column_left;
-
+
if (!area)
gdk_draw_rectangle (clist->clist_window,
GTK_WIDGET
@@ -1457,37 +1456,37 @@ gtk_ctree_draw_lines (GtkCTree *ctree,
tc_rectangle.width,
tc_rectangle.height);
}
-
+
xcenter = offset + (justification_factor * ctree->tree_indent / 2);
-
+
get_cell_style (clist, &ctree_row->row, state, column, NULL, NULL,
&bg_gc);
if (bg_gc == clist->bg_gc)
gdk_gc_set_foreground (clist->bg_gc, &ctree_row->row.background);
-
+
gdk_gc_set_clip_rectangle (bg_gc, crect);
if (ctree_row->is_leaf)
{
GdkPoint points[6];
-
+
points[0].x = offset + justification_factor * TAB_SIZE;
points[0].y = cell_rectangle->y;
-
+
points[1].x = points[0].x - justification_factor * 4;
points[1].y = points[0].y;
-
+
points[2].x = points[1].x - justification_factor * 2;
points[2].y = points[1].y + 3;
-
+
points[3].x = points[2].x;
points[3].y = points[2].y + clist->row_height - 5;
-
+
points[4].x = points[3].x + justification_factor * 2;
points[4].y = points[3].y + 3;
-
+
points[5].x = points[4].x + justification_factor * 4;
points[5].y = points[4].y;
-
+
gdk_draw_polygon (clist->clist_window, bg_gc, TRUE, points, 6);
gdk_draw_lines (clist->clist_window, ctree->lines_gc, points, 6);
}
@@ -1506,17 +1505,17 @@ gtk_ctree_draw_lines (GtkCTree *ctree,
}
gdk_gc_set_clip_rectangle (bg_gc, NULL);
gdk_gc_set_clip_rectangle (ctree->lines_gc, NULL);
-
+
offset += justification_factor * 3;
break;
default:
xcenter = offset + justification_factor * PM_SIZE / 2;
-
+
if (area)
{
tree_rectangle.y = crect->y;
tree_rectangle.height = crect->height;
-
+
if (justify_right)
{
tree_rectangle.x = xcenter - PM_SIZE / 2 - 2;
@@ -1529,11 +1528,11 @@ gtk_ctree_draw_lines (GtkCTree *ctree,
tree_rectangle.width = (xcenter + PM_SIZE / 2 + 2 -
clip_rectangle->x);
}
-
+
if (!gdk_rectangle_intersect (area, &tree_rectangle, &tc_rectangle))
break;
}
-
+
offset_x = 1;
offset_y = 0;
if (ctree->line_style == GTK_CTREE_LINES_DOTTED)
@@ -1541,7 +1540,7 @@ gtk_ctree_draw_lines (GtkCTree *ctree,
offset_x += abs((clip_rectangle->x + clist->hoffset) % 2);
offset_y = abs((cell_rectangle->y + clist->voffset) % 2);
}
-
+
clip_rectangle->y--;
clip_rectangle->height++;
gdk_gc_set_clip_rectangle (ctree->lines_gc, clip_rectangle);
@@ -1551,17 +1550,17 @@ gtk_ctree_draw_lines (GtkCTree *ctree,
cell_rectangle->y + offset_y : ycenter,
xcenter,
(ctree_row->sibling) ? crect->y +crect->height : ycenter);
-
+
gdk_draw_line (clist->clist_window, ctree->lines_gc,
xcenter + (justification_factor * offset_x), ycenter,
xcenter + (justification_factor * (PM_SIZE / 2 + 2)),
ycenter);
-
+
node = ctree_row->parent;
while (node)
{
xcenter -= (justification_factor * ctree->tree_indent);
-
+
if (GTK_CTREE_ROW (node)->sibling)
gdk_draw_line (clist->clist_window, ctree->lines_gc,
xcenter, cell_rectangle->y + offset_y,
@@ -1596,40 +1595,40 @@ draw_row (GtkCList *clist,
gint offset = 0;
gint state;
gint i;
-
+
g_return_if_fail (clist != NULL);
-
+
/* bail now if we arn't drawable yet */
if (!GTK_WIDGET_DRAWABLE (clist) || row < 0 || row >= clist->rows)
return;
-
+
widget = GTK_WIDGET (clist);
ctree = GTK_CTREE (clist);
-
+
/* if the function is passed the pointer to the row instead of null,
* it avoids this expensive lookup */
if (!clist_row)
clist_row = (g_list_nth (clist->row_list, row))->data;
-
+
/* rectangle of the entire row */
row_rectangle.x = 0;
row_rectangle.y = ROW_TOP_YPIXEL (clist, row);
row_rectangle.width = clist->clist_window_width;
row_rectangle.height = clist->row_height;
-
+
/* rectangle of the cell spacing above the row */
cell_rectangle.x = 0;
cell_rectangle.y = row_rectangle.y - CELL_SPACING;
cell_rectangle.width = row_rectangle.width;
cell_rectangle.height = CELL_SPACING;
-
+
/* rectangle used to clip drawing operations, its y and height
* positions only need to be set once, so we set them once here.
* the x and width are set withing the drawing loop below once per
* column */
clip_rectangle.y = row_rectangle.y;
clip_rectangle.height = row_rectangle.height;
-
+
if (clist_row->state == GTK_STATE_NORMAL)
{
if (clist_row->fg_set)
@@ -1639,16 +1638,16 @@ draw_row (GtkCList *clist,
}
state = clist_row->state;
-
+
gdk_gc_set_foreground (ctree->lines_gc,
&widget->style->fg[clist_row->state]);
-
+
/* draw the cell borders */
if (area)
{
rect = &intersect_rectangle;
crect = &intersect_rectangle;
-
+
if (gdk_rectangle_intersect (area, &cell_rectangle, crect))
gdk_draw_rectangle (clist->clist_window,
widget->style->base_gc[GTK_STATE_ACTIVE], TRUE,
@@ -1658,22 +1657,22 @@ draw_row (GtkCList *clist,
{
rect = &clip_rectangle;
crect = &cell_rectangle;
-
+
gdk_draw_rectangle (clist->clist_window,
widget->style->base_gc[GTK_STATE_ACTIVE], TRUE,
crect->x, crect->y, crect->width, crect->height);
}
-
+
/* horizontal black lines */
if (ctree->line_style == GTK_CTREE_LINES_TABBED)
{
-
+
column_right = (COLUMN_LEFT_XPIXEL (clist, ctree->tree_column) +
clist->column[ctree->tree_column].area.width +
COLUMN_INSET);
column_left = (COLUMN_LEFT_XPIXEL (clist, ctree->tree_column) -
COLUMN_INSET - (ctree->tree_column != 0) * CELL_SPACING);
-
+
switch (clist->column[ctree->tree_column].justification)
{
case GTK_JUSTIFY_CENTER:
@@ -1681,7 +1680,7 @@ draw_row (GtkCList *clist,
case GTK_JUSTIFY_LEFT:
offset = (column_left + ctree->tree_indent *
(((GtkCTreeRow *)clist_row)->level - 1));
-
+
gdk_draw_line (clist->clist_window, ctree->lines_gc,
MIN (offset + TAB_SIZE, column_right),
cell_rectangle.y,
@@ -1690,7 +1689,7 @@ draw_row (GtkCList *clist,
case GTK_JUSTIFY_RIGHT:
offset = (column_right - 1 - ctree->tree_indent *
(((GtkCTreeRow *)clist_row)->level - 1));
-
+
gdk_draw_line (clist->clist_window, ctree->lines_gc,
-1, cell_rectangle.y,
MAX (offset - TAB_SIZE, column_left),
@@ -1698,18 +1697,18 @@ draw_row (GtkCList *clist,
break;
}
}
-
+
/* the last row has to clear its bottom cell spacing too */
if (clist_row == clist->row_list_end->data)
{
cell_rectangle.y += clist->row_height + CELL_SPACING;
-
+
if (!area || gdk_rectangle_intersect (area, &cell_rectangle, crect))
{
gdk_draw_rectangle (clist->clist_window,
widget->style->base_gc[GTK_STATE_ACTIVE], TRUE,
crect->x, crect->y, crect->width, crect->height);
-
+
/* horizontal black lines */
if (ctree->line_style == GTK_CTREE_LINES_TABBED)
{
@@ -1739,43 +1738,43 @@ draw_row (GtkCList *clist,
}
}
}
-
+
for (last_column = clist->columns - 1;
last_column >= 0 && !clist->column[last_column].visible; last_column--)
;
-
+
/* iterate and draw all the columns (row cells) and draw their contents */
for (i = 0; i < clist->columns; i++)
{
GtkStyle *style;
GdkGC *fg_gc;
GdkGC *bg_gc;
-
+
gint width;
gint height;
gint pixmap_width;
gint string_width;
gint old_offset;
gint row_center_offset;
-
+
if (!clist->column[i].visible)
continue;
-
+
get_cell_style (clist, clist_row, state, i, &style, &fg_gc, &bg_gc);
-
+
/* calculate clipping region */
clip_rectangle.x = clist->column[i].area.x + clist->hoffset;
clip_rectangle.width = clist->column[i].area.width;
-
+
cell_rectangle.x = clip_rectangle.x - COLUMN_INSET - CELL_SPACING;
cell_rectangle.width = (clip_rectangle.width + 2 * COLUMN_INSET +
(1 + (i == last_column)) * CELL_SPACING);
cell_rectangle.y = clip_rectangle.y;
cell_rectangle.height = clip_rectangle.height;
-
+
string_width = 0;
pixmap_width = 0;
-
+
if (area && !gdk_rectangle_intersect (area, &cell_rectangle,
&intersect_rectangle))
{
@@ -1786,7 +1785,7 @@ draw_row (GtkCList *clist,
{
gdk_draw_rectangle (clist->clist_window, bg_gc, TRUE,
crect->x, crect->y, crect->width, crect->height);
-
+
/* calculate real width for column justification */
switch (clist_row->cell[i].type)
{
@@ -1805,20 +1804,20 @@ draw_row (GtkCList *clist,
gdk_window_get_size
(GTK_CELL_PIXTEXT (clist_row->cell[i])->pixmap,
&pixmap_width, &height);
-
+
width = pixmap_width;
-
+
if (GTK_CELL_PIXTEXT (clist_row->cell[i])->text)
{
string_width = gdk_string_width
(style->font, GTK_CELL_PIXTEXT (clist_row->cell[i])->text);
width += string_width;
}
-
+
if (GTK_CELL_PIXTEXT (clist_row->cell[i])->text &&
GTK_CELL_PIXTEXT (clist_row->cell[i])->pixmap)
width += GTK_CELL_PIXTEXT (clist_row->cell[i])->spacing;
-
+
if (i == ctree->tree_column)
width += (ctree->tree_indent *
((GtkCTreeRow *)clist_row)->level);
@@ -1827,7 +1826,7 @@ draw_row (GtkCList *clist,
continue;
break;
}
-
+
switch (clist->column[i].justification)
{
case GTK_JUSTIFY_LEFT:
@@ -1843,7 +1842,7 @@ draw_row (GtkCList *clist,
(clip_rectangle.width / 2) - (width / 2));
break;
};
-
+
if (i != ctree->tree_column)
{
offset += clist_row->cell[i].horizontal;
@@ -1877,7 +1876,7 @@ draw_row (GtkCList *clist,
1.5 + style->font->ascent);
else
row_center_offset = clist->row_center_offset;
-
+
gdk_gc_set_clip_rectangle (fg_gc, &clip_rectangle);
gdk_draw_string
(clist->clist_window, style->font, fg_gc,
@@ -1895,37 +1894,37 @@ draw_row (GtkCList *clist,
continue;
}
}
-
+
if (bg_gc == clist->bg_gc)
gdk_gc_set_background (ctree->lines_gc, &clist_row->background);
-
+
/* draw ctree->tree_column */
cell_rectangle.y -= CELL_SPACING;
cell_rectangle.height += CELL_SPACING;
-
+
if (area && !gdk_rectangle_intersect (area, &cell_rectangle,
&intersect_rectangle))
continue;
-
+
/* draw lines */
offset = gtk_ctree_draw_lines (ctree, (GtkCTreeRow *)clist_row, row, i,
state, &clip_rectangle, &cell_rectangle,
crect, area, style);
-
+
/* draw expander */
offset = gtk_ctree_draw_expander (ctree, (GtkCTreeRow *)clist_row,
style, &clip_rectangle, offset);
-
+
if (clist->column[i].justification == GTK_JUSTIFY_RIGHT)
offset -= ctree->tree_spacing;
else
offset += ctree->tree_spacing;
-
+
if (clist->column[i].justification == GTK_JUSTIFY_RIGHT)
offset -= (pixmap_width + clist_row->cell[i].horizontal);
else
offset += clist_row->cell[i].horizontal;
-
+
old_offset = offset;
offset = draw_cell_pixmap (clist->clist_window, &clip_rectangle, fg_gc,
GTK_CELL_PIXTEXT (clist_row->cell[i])->pixmap,
@@ -1934,7 +1933,7 @@ draw_row (GtkCList *clist,
clip_rectangle.y + clist_row->cell[i].vertical
+ (clip_rectangle.height - height) / 2,
pixmap_width, height);
-
+
if (string_width)
{
if (clist->column[i].justification == GTK_JUSTIFY_RIGHT)
@@ -1948,7 +1947,7 @@ draw_row (GtkCList *clist,
if (GTK_CELL_PIXTEXT (clist_row->cell[i])->pixmap)
offset += GTK_CELL_PIXTEXT (clist_row->cell[i])->spacing;
}
-
+
if (style != GTK_WIDGET (clist)->style)
row_center_offset = (((clist->row_height - style->font->ascent -
style->font->descent - 1) / 2) +
@@ -1964,7 +1963,7 @@ draw_row (GtkCList *clist,
}
gdk_gc_set_clip_rectangle (fg_gc, NULL);
}
-
+
/* draw focus rectangle */
if (clist->focus_row == row &&
GTK_WIDGET_CAN_FOCUS (widget) && GTK_WIDGET_HAS_FOCUS (widget))
@@ -1993,7 +1992,7 @@ tree_draw_node (GtkCTree *ctree,
GtkCList *clist;
clist = GTK_CLIST (ctree);
-
+
if (CLIST_UNFROZEN (clist) && gtk_ctree_is_viewable (ctree, node))
{
GtkCTreeNode *work;
@@ -2006,7 +2005,7 @@ tree_draw_node (GtkCTree *ctree,
num++;
}
if (work && gtk_clist_row_is_visible (clist, num) != GTK_VISIBILITY_NONE)
- GTK_CLIST_CLASS_FW (clist)->draw_row
+ GTK_CLIST_GET_CLASS (clist)->draw_row
(clist, NULL, num, GTK_CLIST_ROW ((GList *) node));
}
}
@@ -2019,15 +2018,15 @@ gtk_ctree_last_visible (GtkCTree *ctree,
if (!node)
return NULL;
-
+
work = GTK_CTREE_ROW (node)->children;
-
+
if (!work || !GTK_CTREE_ROW (node)->expanded)
return node;
-
+
while (GTK_CTREE_ROW (work)->sibling)
work = GTK_CTREE_ROW (work)->sibling;
-
+
return gtk_ctree_last_visible (ctree, work);
}
@@ -2050,38 +2049,38 @@ gtk_ctree_link (GtkCTree *ctree,
g_return_if_fail (node != NULL);
g_return_if_fail (node != sibling);
g_return_if_fail (node != parent);
-
+
clist = GTK_CLIST (ctree);
-
+
if (update_focus_row && clist->selection_mode == GTK_SELECTION_EXTENDED)
{
- GTK_CLIST_CLASS_FW (clist)->resync_selection (clist, NULL);
+ GTK_CLIST_GET_CLASS (clist)->resync_selection (clist, NULL);
g_list_free (clist->undo_selection);
g_list_free (clist->undo_unselection);
clist->undo_selection = NULL;
clist->undo_unselection = NULL;
}
-
+
for (rows = 1, list_end = (GList *)node; list_end->next;
list_end = list_end->next)
rows++;
-
+
GTK_CTREE_ROW (node)->parent = parent;
GTK_CTREE_ROW (node)->sibling = sibling;
-
+
if (!parent || (parent && (gtk_ctree_is_viewable (ctree, parent) &&
GTK_CTREE_ROW (parent)->expanded)))
{
visible = TRUE;
clist->rows += rows;
}
-
+
if (parent)
work = (GList *)(GTK_CTREE_ROW (parent)->children);
else
work = clist->row_list;
-
+
if (sibling)
{
if (work != (GList *)sibling)
@@ -2090,7 +2089,7 @@ gtk_ctree_link (GtkCTree *ctree,
work = (GList *)(GTK_CTREE_ROW (work)->sibling);
GTK_CTREE_ROW (work)->sibling = node;
}
-
+
if (sibling == GTK_CTREE_NODE (clist->row_list))
clist->row_list = (GList *) node;
if (GTK_CTREE_NODE_PREV (sibling) &&
@@ -2158,19 +2157,19 @@ gtk_ctree_link (GtkCTree *ctree,
}
}
}
-
+
gtk_ctree_pre_recursive (ctree, node, tree_update_level, NULL);
-
+
if (clist->row_list_end == NULL ||
clist->row_list_end->next == (GList *)node)
clist->row_list_end = list_end;
-
+
if (visible && update_focus_row)
{
gint pos;
-
+
pos = g_list_position (clist->row_list, (GList *)node);
-
+
if (pos <= clist->focus_row)
{
clist->focus_row += rows;
@@ -2191,25 +2190,25 @@ gtk_ctree_unlink (GtkCTree *ctree,
GtkCTreeNode *work;
GtkCTreeNode *parent;
GList *list;
-
+
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
g_return_if_fail (node != NULL);
-
+
clist = GTK_CLIST (ctree);
if (update_focus_row && clist->selection_mode == GTK_SELECTION_EXTENDED)
{
- GTK_CLIST_CLASS_FW (clist)->resync_selection (clist, NULL);
+ GTK_CLIST_GET_CLASS (clist)->resync_selection (clist, NULL);
g_list_free (clist->undo_selection);
g_list_free (clist->undo_unselection);
clist->undo_selection = NULL;
clist->undo_unselection = NULL;
}
-
+
visible = gtk_ctree_is_viewable (ctree, node);
-
+
/* clist->row_list_end unlinked ? */
if (visible &&
(GTK_CTREE_NODE_NEXT (node) == NULL ||
@@ -2217,7 +2216,7 @@ gtk_ctree_unlink (GtkCTree *ctree,
gtk_ctree_is_ancestor (ctree, node,
GTK_CTREE_NODE (clist->row_list_end)))))
clist->row_list_end = (GList *) (GTK_CTREE_NODE_PREV (node));
-
+
/* update list */
rows = 0;
level = GTK_CTREE_ROW (node)->level;
@@ -2227,11 +2226,11 @@ gtk_ctree_unlink (GtkCTree *ctree,
work = GTK_CTREE_NODE_NEXT (work);
rows++;
}
-
+
if (visible)
{
clist->rows -= (rows + 1);
-
+
if (update_focus_row)
{
gint pos;
@@ -2251,7 +2250,7 @@ gtk_ctree_unlink (GtkCTree *ctree,
clist->undo_anchor = clist->focus_row;
}
}
-
+
if (work)
{
list = (GList *)GTK_CTREE_NODE_PREV (work);
@@ -2259,14 +2258,14 @@ gtk_ctree_unlink (GtkCTree *ctree,
list = (GList *)work;
list->prev = (GList *)GTK_CTREE_NODE_PREV (node);
}
-
+
if (GTK_CTREE_NODE_PREV (node) &&
GTK_CTREE_NODE_NEXT (GTK_CTREE_NODE_PREV (node)) == node)
{
list = (GList *)GTK_CTREE_NODE_PREV (node);
list->next = (GList *)work;
}
-
+
/* update tree */
parent = GTK_CTREE_ROW (node)->parent;
if (parent)
@@ -2280,7 +2279,7 @@ gtk_ctree_unlink (GtkCTree *ctree,
else
{
GtkCTreeNode *sibling;
-
+
sibling = GTK_CTREE_ROW (parent)->children;
while (GTK_CTREE_ROW (sibling)->sibling != node)
sibling = GTK_CTREE_ROW (sibling)->sibling;
@@ -2294,7 +2293,7 @@ gtk_ctree_unlink (GtkCTree *ctree,
else
{
GtkCTreeNode *sibling;
-
+
sibling = GTK_CTREE_NODE (clist->row_list);
while (GTK_CTREE_ROW (sibling)->sibling != node)
sibling = GTK_CTREE_ROW (sibling)->sibling;
@@ -2310,42 +2309,42 @@ real_row_move (GtkCList *clist,
{
GtkCTree *ctree;
GtkCTreeNode *node;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CTREE (clist));
-
+
if (GTK_CLIST_AUTO_SORT (clist))
return;
-
+
if (source_row < 0 || source_row >= clist->rows ||
dest_row < 0 || dest_row >= clist->rows ||
source_row == dest_row)
return;
-
+
ctree = GTK_CTREE (clist);
node = GTK_CTREE_NODE (g_list_nth (clist->row_list, source_row));
-
+
if (source_row < dest_row)
{
GtkCTreeNode *work;
-
+
dest_row++;
work = GTK_CTREE_ROW (node)->children;
-
+
while (work && GTK_CTREE_ROW (work)->level > GTK_CTREE_ROW (node)->level)
{
work = GTK_CTREE_NODE_NEXT (work);
dest_row++;
}
-
+
if (dest_row > clist->rows)
dest_row = clist->rows;
}
-
+
if (dest_row < clist->rows)
{
GtkCTreeNode *sibling;
-
+
sibling = GTK_CTREE_NODE (g_list_nth (clist->row_list, dest_row));
gtk_ctree_move (ctree, node, GTK_CTREE_ROW (sibling)->parent, sibling);
}
@@ -2362,34 +2361,34 @@ real_tree_move (GtkCTree *ctree,
GtkCList *clist;
GtkCTreeNode *work;
gboolean visible = FALSE;
-
+
g_return_if_fail (ctree != NULL);
g_return_if_fail (node != NULL);
g_return_if_fail (!new_sibling ||
GTK_CTREE_ROW (new_sibling)->parent == new_parent);
-
+
if (new_parent && GTK_CTREE_ROW (new_parent)->is_leaf)
return;
-
+
/* new_parent != child of child */
for (work = new_parent; work; work = GTK_CTREE_ROW (work)->parent)
if (work == node)
return;
-
+
clist = GTK_CLIST (ctree);
-
+
visible = gtk_ctree_is_viewable (ctree, node);
-
+
if (clist->selection_mode == GTK_SELECTION_EXTENDED)
{
- GTK_CLIST_CLASS_FW (clist)->resync_selection (clist, NULL);
+ GTK_CLIST_GET_CLASS (clist)->resync_selection (clist, NULL);
g_list_free (clist->undo_selection);
g_list_free (clist->undo_unselection);
clist->undo_selection = NULL;
clist->undo_unselection = NULL;
}
-
+
if (GTK_CLIST_AUTO_SORT (clist))
{
if (new_parent == GTK_CTREE_ROW (node)->parent)
@@ -2399,23 +2398,23 @@ real_tree_move (GtkCTree *ctree,
new_sibling = GTK_CTREE_ROW (new_parent)->children;
else
new_sibling = GTK_CTREE_NODE (clist->row_list);
-
+
while (new_sibling && clist->compare
(clist, GTK_CTREE_ROW (node), GTK_CTREE_ROW (new_sibling)) > 0)
new_sibling = GTK_CTREE_ROW (new_sibling)->sibling;
}
-
+
if (new_parent == GTK_CTREE_ROW (node)->parent &&
new_sibling == GTK_CTREE_ROW (node)->sibling)
return;
-
+
gtk_clist_freeze (clist);
-
+
work = NULL;
if (gtk_ctree_is_viewable (ctree, node) ||
gtk_ctree_is_viewable (ctree, new_sibling))
work = GTK_CTREE_NODE (g_list_nth (clist->row_list, clist->focus_row));
-
+
gtk_ctree_unlink (ctree, node, FALSE);
gtk_ctree_link (ctree, node, new_parent, new_sibling, FALSE);
@@ -2426,14 +2425,14 @@ real_tree_move (GtkCTree *ctree,
clist->focus_row = g_list_position (clist->row_list, (GList *)work);
clist->undo_anchor = clist->focus_row;
}
-
+
if (clist->column[ctree->tree_column].auto_resize &&
!GTK_CLIST_AUTO_RESIZE_BLOCKED (clist) &&
(visible || gtk_ctree_is_viewable (ctree, node)))
gtk_clist_set_column_width
(clist, ctree->tree_column,
gtk_clist_optimal_column_width (clist, ctree->tree_column));
-
+
gtk_clist_thaw (clist);
}
@@ -2443,12 +2442,12 @@ change_focus_row_expansion (GtkCTree *ctree,
{
GtkCList *clist;
GtkCTreeNode *node;
-
+
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
-
+
clist = GTK_CLIST (ctree);
-
+
if (gdk_pointer_is_grabbed () && GTK_WIDGET_HAS_GRAB (ctree))
return;
@@ -2456,7 +2455,7 @@ change_focus_row_expansion (GtkCTree *ctree,
GTK_CTREE_NODE (g_list_nth (clist->row_list, clist->focus_row))) ||
GTK_CTREE_ROW (node)->is_leaf || !(GTK_CTREE_ROW (node)->children))
return;
-
+
switch (action)
{
case GTK_CTREE_EXPANSION_EXPAND:
@@ -2489,27 +2488,27 @@ real_tree_expand (GtkCTree *ctree,
GtkRequisition requisition;
gboolean visible;
gint level;
-
+
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
-
+
if (!node || GTK_CTREE_ROW (node)->expanded || GTK_CTREE_ROW (node)->is_leaf)
return;
-
+
clist = GTK_CLIST (ctree);
- GTK_CLIST_CLASS_FW (clist)->resync_selection (clist, NULL);
-
+ GTK_CLIST_GET_CLASS (clist)->resync_selection (clist, NULL);
+
GTK_CTREE_ROW (node)->expanded = TRUE;
level = GTK_CTREE_ROW (node)->level;
-
+
visible = gtk_ctree_is_viewable (ctree, node);
/* get cell width if tree_column is auto resized */
if (visible && clist->column[ctree->tree_column].auto_resize &&
!GTK_CLIST_AUTO_RESIZE_BLOCKED (clist))
- GTK_CLIST_CLASS_FW (clist)->cell_size_request
+ GTK_CLIST_GET_CLASS (clist)->cell_size_request
(clist, &GTK_CTREE_ROW (node)->row, ctree->tree_column, &requisition);
-
+
/* unref/unset closed pixmap */
if (GTK_CELL_PIXTEXT
(GTK_CTREE_ROW (node)->row.cell[ctree->tree_column])->pixmap)
@@ -2531,21 +2530,21 @@ real_tree_expand (GtkCTree *ctree,
(GTK_CTREE_ROW (node)->row.cell[ctree->tree_column])->mask = NULL;
}
}
-
+
/* set/ref opened pixmap */
if (GTK_CTREE_ROW (node)->pixmap_opened)
{
GTK_CELL_PIXTEXT
(GTK_CTREE_ROW (node)->row.cell[ctree->tree_column])->pixmap =
gdk_pixmap_ref (GTK_CTREE_ROW (node)->pixmap_opened);
-
+
if (GTK_CTREE_ROW (node)->mask_opened)
GTK_CELL_PIXTEXT
(GTK_CTREE_ROW (node)->row.cell[ctree->tree_column])->mask =
gdk_pixmap_ref (GTK_CTREE_ROW (node)->mask_opened);
}
-
-
+
+
work = GTK_CTREE_ROW (node)->children;
if (work)
{
@@ -2559,19 +2558,19 @@ real_tree_expand (GtkCTree *ctree,
{
cell_width = g_new0 (gint, clist->columns);
if (clist->column[ctree->tree_column].auto_resize)
- cell_width[ctree->tree_column] = requisition.width;
-
+ cell_width[ctree->tree_column] = requisition.width;
+
while (work)
{
/* search maximum cell widths of auto_resize columns */
for (i = 0; i < clist->columns; i++)
if (clist->column[i].auto_resize)
{
- GTK_CLIST_CLASS_FW (clist)->cell_size_request
+ GTK_CLIST_GET_CLASS (clist)->cell_size_request
(clist, &GTK_CTREE_ROW (work)->row, i, &requisition);
cell_width[i] = MAX (requisition.width, cell_width[i]);
}
-
+
list = (GList *)work;
work = GTK_CTREE_NODE_NEXT (work);
tmp++;
@@ -2584,22 +2583,22 @@ real_tree_expand (GtkCTree *ctree,
work = GTK_CTREE_NODE_NEXT (work);
tmp++;
}
-
+
list->next = (GList *)GTK_CTREE_NODE_NEXT (node);
-
+
if (GTK_CTREE_NODE_NEXT (node))
{
GList *tmp_list;
-
+
tmp_list = (GList *)GTK_CTREE_NODE_NEXT (node);
tmp_list->prev = list;
}
else
clist->row_list_end = list;
-
+
list = (GList *)node;
list->next = (GList *)(GTK_CTREE_ROW (node)->children);
-
+
if (visible)
{
/* resize auto_resize columns if needed */
@@ -2608,12 +2607,12 @@ real_tree_expand (GtkCTree *ctree,
cell_width[i] > clist->column[i].width)
gtk_clist_set_column_width (clist, i, cell_width[i]);
g_free (cell_width);
-
+
/* update focus_row position */
row = g_list_position (clist->row_list, (GList *)node);
if (row < clist->focus_row)
clist->focus_row += tmp;
-
+
clist->rows += tmp;
CLIST_REFRESH (clist);
}
@@ -2633,28 +2632,28 @@ real_tree_collapse (GtkCTree *ctree,
GtkRequisition requisition;
gboolean visible;
gint level;
-
+
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
-
+
if (!node || !GTK_CTREE_ROW (node)->expanded ||
GTK_CTREE_ROW (node)->is_leaf)
return;
-
+
clist = GTK_CLIST (ctree);
-
- GTK_CLIST_CLASS_FW (clist)->resync_selection (clist, NULL);
+
+ GTK_CLIST_GET_CLASS (clist)->resync_selection (clist, NULL);
GTK_CTREE_ROW (node)->expanded = FALSE;
level = GTK_CTREE_ROW (node)->level;
-
+
visible = gtk_ctree_is_viewable (ctree, node);
/* get cell width if tree_column is auto resized */
if (visible && clist->column[ctree->tree_column].auto_resize &&
!GTK_CLIST_AUTO_RESIZE_BLOCKED (clist))
- GTK_CLIST_CLASS_FW (clist)->cell_size_request
+ GTK_CLIST_GET_CLASS (clist)->cell_size_request
(clist, &GTK_CTREE_ROW (node)->row, ctree->tree_column, &requisition);
-
+
/* unref/unset opened pixmap */
if (GTK_CELL_PIXTEXT
(GTK_CTREE_ROW (node)->row.cell[ctree->tree_column])->pixmap)
@@ -2676,33 +2675,33 @@ real_tree_collapse (GtkCTree *ctree,
(GTK_CTREE_ROW (node)->row.cell[ctree->tree_column])->mask = NULL;
}
}
-
+
/* set/ref closed pixmap */
if (GTK_CTREE_ROW (node)->pixmap_closed)
{
GTK_CELL_PIXTEXT
(GTK_CTREE_ROW (node)->row.cell[ctree->tree_column])->pixmap =
gdk_pixmap_ref (GTK_CTREE_ROW (node)->pixmap_closed);
-
+
if (GTK_CTREE_ROW (node)->mask_closed)
GTK_CELL_PIXTEXT
(GTK_CTREE_ROW (node)->row.cell[ctree->tree_column])->mask =
gdk_pixmap_ref (GTK_CTREE_ROW (node)->mask_closed);
}
-
+
work = GTK_CTREE_ROW (node)->children;
if (work)
{
gint tmp = 0;
gint row;
GList *list;
-
+
while (work && GTK_CTREE_ROW (work)->level > level)
{
work = GTK_CTREE_NODE_NEXT (work);
tmp++;
}
-
+
if (work)
{
list = (GList *)node;
@@ -2718,12 +2717,12 @@ real_tree_collapse (GtkCTree *ctree,
list->next = NULL;
clist->row_list_end = (GList *)node;
}
-
+
if (visible)
{
/* resize auto_resize columns if needed */
auto_resize_columns (clist);
-
+
row = g_list_position (clist->row_list, (GList *)node);
if (row < clist->focus_row)
clist->focus_row -= tmp;
@@ -2736,7 +2735,7 @@ real_tree_collapse (GtkCTree *ctree,
/* resize tree_column if needed */
column_auto_resize (clist, &GTK_CTREE_ROW (node)->row, ctree->tree_column,
requisition.width);
-
+
}
static void
@@ -2747,17 +2746,17 @@ column_auto_resize (GtkCList *clist,
{
/* resize column if needed for auto_resize */
GtkRequisition requisition;
-
+
if (!clist->column[column].auto_resize ||
GTK_CLIST_AUTO_RESIZE_BLOCKED (clist))
return;
-
+
if (clist_row)
- GTK_CLIST_CLASS_FW (clist)->cell_size_request (clist, clist_row,
- column, &requisition);
+ GTK_CLIST_GET_CLASS (clist)->cell_size_request (clist, clist_row,
+ column, &requisition);
else
requisition.width = 0;
-
+
if (requisition.width > clist->column[column].width)
gtk_clist_set_column_width (clist, column, requisition.width);
else if (requisition.width < old_width &&
@@ -2765,7 +2764,7 @@ column_auto_resize (GtkCList *clist,
{
GList *list;
gint new_width;
-
+
/* run a "gtk_clist_optimal_column_width" but break, if
* the column doesn't shrink */
if (GTK_CLIST_SHOW_TITLES (clist) && clist->column[column].button)
@@ -2773,10 +2772,10 @@ column_auto_resize (GtkCList *clist,
(CELL_SPACING + (2 * COLUMN_INSET)));
else
new_width = 0;
-
+
for (list = clist->row_list; list; list = list->next)
{
- GTK_CLIST_CLASS_FW (clist)->cell_size_request
+ GTK_CLIST_GET_CLASS (clist)->cell_size_request
(clist, GTK_CLIST_ROW (list), column, &requisition);
new_width = MAX (new_width, requisition.width);
if (new_width == clist->column[column].width)
@@ -2791,10 +2790,10 @@ static void
auto_resize_columns (GtkCList *clist)
{
gint i;
-
+
if (GTK_CLIST_AUTO_RESIZE_BLOCKED (clist))
return;
-
+
for (i = 0; i < clist->columns; i++)
column_auto_resize (clist, NULL, i, clist->column[i].width);
}
@@ -2809,16 +2808,16 @@ cell_size_request (GtkCList *clist,
GtkStyle *style;
gint width;
gint height;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CTREE (clist));
g_return_if_fail (requisition != NULL);
-
+
ctree = GTK_CTREE (clist);
-
+
get_cell_style (clist, clist_row, GTK_STATE_NORMAL, column, &style,
NULL, NULL);
-
+
switch (clist_row->cell[column].type)
{
case GTK_CELL_TEXT:
@@ -2837,11 +2836,11 @@ cell_size_request (GtkCList *clist,
}
else
width = height = 0;
-
+
requisition->width = width +
gdk_string_width (style->font,
GTK_CELL_TEXT (clist_row->cell[column])->text);
-
+
requisition->height = MAX (style->font->ascent + style->font->descent,
height);
if (column == ctree->tree_column)
@@ -2875,7 +2874,7 @@ cell_size_request (GtkCList *clist,
requisition->height = 0;
break;
}
-
+
requisition->width += clist_row->cell[column].horizontal;
requisition->height += clist_row->cell[column].vertical;
}
@@ -2893,28 +2892,28 @@ set_cell_contents (GtkCList *clist,
gboolean visible = FALSE;
GtkCTree *ctree;
GtkRequisition requisition;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CTREE (clist));
g_return_if_fail (clist_row != NULL);
-
+
ctree = GTK_CTREE (clist);
-
+
if (clist->column[column].auto_resize &&
!GTK_CLIST_AUTO_RESIZE_BLOCKED (clist))
{
GtkCTreeNode *parent;
-
+
parent = ((GtkCTreeRow *)clist_row)->parent;
if (!parent || (parent && GTK_CTREE_ROW (parent)->expanded &&
gtk_ctree_is_viewable (ctree, parent)))
{
visible = TRUE;
- GTK_CLIST_CLASS_FW (clist)->cell_size_request (clist, clist_row,
- column, &requisition);
+ GTK_CLIST_GET_CLASS (clist)->cell_size_request (clist, clist_row,
+ column, &requisition);
}
}
-
+
switch (clist_row->cell[column].type)
{
case GTK_CELL_EMPTY:
@@ -2947,11 +2946,11 @@ set_cell_contents (GtkCList *clist,
default:
break;
}
-
+
clist_row->cell[column].type = GTK_CELL_EMPTY;
if (column == ctree->tree_column && type != GTK_CELL_EMPTY)
type = GTK_CELL_PIXTEXT;
-
+
switch (type)
{
case GTK_CELL_TEXT:
@@ -3032,12 +3031,12 @@ set_node_info (GtkCTree *ctree,
if (GTK_CTREE_ROW (node)->mask_closed)
gdk_bitmap_unref (GTK_CTREE_ROW (node)->mask_closed);
}
-
+
GTK_CTREE_ROW (node)->pixmap_opened = NULL;
GTK_CTREE_ROW (node)->mask_opened = NULL;
GTK_CTREE_ROW (node)->pixmap_closed = NULL;
GTK_CTREE_ROW (node)->mask_closed = NULL;
-
+
if (pixmap_closed)
{
GTK_CTREE_ROW (node)->pixmap_closed = gdk_pixmap_ref (pixmap_closed);
@@ -3050,10 +3049,10 @@ set_node_info (GtkCTree *ctree,
if (mask_opened)
GTK_CTREE_ROW (node)->mask_opened = gdk_bitmap_ref (mask_opened);
}
-
+
GTK_CTREE_ROW (node)->is_leaf = is_leaf;
GTK_CTREE_ROW (node)->expanded = (is_leaf) ? FALSE : expanded;
-
+
if (GTK_CTREE_ROW (node)->expanded)
gtk_ctree_node_set_pixtext (ctree, node, ctree->tree_column,
text, spacing, pixmap_opened, mask_opened);
@@ -3088,12 +3087,12 @@ tree_update_level (GtkCTree *ctree,
{
if (!node)
return;
-
+
if (GTK_CTREE_ROW (node)->parent)
- GTK_CTREE_ROW (node)->level =
- GTK_CTREE_ROW (GTK_CTREE_ROW (node)->parent)->level + 1;
+ GTK_CTREE_ROW (node)->level =
+ GTK_CTREE_ROW (GTK_CTREE_ROW (node)->parent)->level + 1;
else
- GTK_CTREE_ROW (node)->level = 1;
+ GTK_CTREE_ROW (node)->level = 1;
}
static void
@@ -3151,7 +3150,7 @@ tree_toggle_expansion (GtkCTree *ctree,
{
if (!node)
return;
-
+
if (GTK_CTREE_ROW (node)->expanded)
gtk_signal_emit (GTK_OBJECT (ctree), ctree_signals[TREE_COLLAPSE], node);
else
@@ -3164,11 +3163,11 @@ row_new (GtkCTree *ctree)
GtkCList *clist;
GtkCTreeRow *ctree_row;
int i;
-
+
clist = GTK_CLIST (ctree);
ctree_row = g_chunk_new (GtkCTreeRow, clist->row_mem_chunk);
ctree_row->row.cell = g_chunk_new (GtkCell, clist->cell_mem_chunk);
-
+
for (i = 0; i < clist->columns; i++)
{
ctree_row->row.cell[i].type = GTK_CELL_EMPTY;
@@ -3176,9 +3175,9 @@ row_new (GtkCTree *ctree)
ctree_row->row.cell[i].horizontal = 0;
ctree_row->row.cell[i].style = NULL;
}
-
+
GTK_CELL_PIXTEXT (ctree_row->row.cell[ctree->tree_column])->text = NULL;
-
+
ctree_row->row.fg_set = FALSE;
ctree_row->row.bg_set = FALSE;
ctree_row->row.style = NULL;
@@ -3186,7 +3185,7 @@ row_new (GtkCTree *ctree)
ctree_row->row.state = GTK_STATE_NORMAL;
ctree_row->row.data = NULL;
ctree_row->row.destroy = NULL;
-
+
ctree_row->level = 0;
ctree_row->expanded = FALSE;
ctree_row->parent = NULL;
@@ -3206,12 +3205,12 @@ row_delete (GtkCTree *ctree,
{
GtkCList *clist;
gint i;
-
+
clist = GTK_CLIST (ctree);
-
+
for (i = 0; i < clist->columns; i++)
{
- GTK_CLIST_CLASS_FW (clist)->set_cell_contents
+ GTK_CLIST_GET_CLASS (clist)->set_cell_contents
(clist, &(ctree_row->row), i, GTK_CELL_EMPTY, NULL, 0, NULL, NULL);
if (ctree_row->row.cell[i].style)
{
@@ -3220,39 +3219,39 @@ row_delete (GtkCTree *ctree,
gtk_style_unref (ctree_row->row.cell[i].style);
}
}
-
+
if (ctree_row->row.style)
{
if (GTK_WIDGET_REALIZED (ctree))
gtk_style_detach (ctree_row->row.style);
gtk_style_unref (ctree_row->row.style);
}
-
+
if (ctree_row->pixmap_closed)
{
gdk_pixmap_unref (ctree_row->pixmap_closed);
if (ctree_row->mask_closed)
gdk_bitmap_unref (ctree_row->mask_closed);
}
-
+
if (ctree_row->pixmap_opened)
{
gdk_pixmap_unref (ctree_row->pixmap_opened);
if (ctree_row->mask_opened)
gdk_bitmap_unref (ctree_row->mask_opened);
}
-
+
if (ctree_row->row.destroy)
{
GtkDestroyNotify dnotify = ctree_row->row.destroy;
gpointer ddata = ctree_row->row.data;
-
+
ctree_row->row.destroy = NULL;
ctree_row->row.data = NULL;
-
+
dnotify (ddata);
}
-
+
g_mem_chunk_free (clist->cell_mem_chunk, ctree_row->row.cell);
g_mem_chunk_free (clist->row_mem_chunk, ctree_row);
}
@@ -3264,7 +3263,7 @@ real_select_row (GtkCList *clist,
GdkEvent *event)
{
GList *node;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CTREE (clist));
@@ -3281,10 +3280,10 @@ real_unselect_row (GtkCList *clist,
GdkEvent *event)
{
GList *node;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CTREE (clist));
-
+
if ((node = g_list_nth (clist->row_list, row)))
gtk_signal_emit (GTK_OBJECT (clist), ctree_signals[TREE_UNSELECT_ROW],
node, column);
@@ -3299,24 +3298,24 @@ real_tree_select (GtkCTree *ctree,
GList *list;
GtkCTreeNode *sel_row;
gboolean node_selected;
-
+
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
-
+
if (!node || GTK_CTREE_ROW (node)->row.state == GTK_STATE_SELECTED ||
!GTK_CTREE_ROW (node)->row.selectable)
return;
-
+
clist = GTK_CLIST (ctree);
-
+
switch (clist->selection_mode)
{
case GTK_SELECTION_SINGLE:
case GTK_SELECTION_BROWSE:
-
+
node_selected = FALSE;
list = clist->selection;
-
+
while (list)
{
sel_row = list->data;
@@ -3328,16 +3327,16 @@ real_tree_select (GtkCTree *ctree,
gtk_signal_emit (GTK_OBJECT (ctree),
ctree_signals[TREE_UNSELECT_ROW], sel_row, column);
}
-
+
if (node_selected)
return;
-
+
default:
break;
}
-
+
GTK_CTREE_ROW (node)->row.state = GTK_STATE_SELECTED;
-
+
if (!clist->selection)
{
clist->selection = g_list_append (clist->selection, node);
@@ -3345,7 +3344,7 @@ real_tree_select (GtkCTree *ctree,
}
else
clist->selection_end = g_list_append (clist->selection_end, node)->next;
-
+
tree_draw_node (ctree, node);
}
@@ -3355,22 +3354,22 @@ real_tree_unselect (GtkCTree *ctree,
gint column)
{
GtkCList *clist;
-
+
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
-
+
if (!node || GTK_CTREE_ROW (node)->row.state != GTK_STATE_SELECTED)
return;
-
+
clist = GTK_CLIST (ctree);
-
+
if (clist->selection_end && clist->selection_end->data == node)
clist->selection_end = clist->selection_end->prev;
-
+
clist->selection = g_list_remove (clist->selection, node);
GTK_CTREE_ROW (node)->row.state = GTK_STATE_NORMAL;
-
+
tree_draw_node (ctree, node);
}
@@ -3382,7 +3381,7 @@ select_row_recursive (GtkCTree *ctree,
if (!node || GTK_CTREE_ROW (node)->row.state == GTK_STATE_SELECTED ||
!GTK_CTREE_ROW (node)->row.selectable)
return;
-
+
GTK_CLIST (ctree)->undo_unselection =
g_list_prepend (GTK_CLIST (ctree)->undo_unselection, node);
gtk_ctree_select (ctree, node);
@@ -3396,40 +3395,40 @@ real_select_all (GtkCList *clist)
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CTREE (clist));
-
+
ctree = GTK_CTREE (clist);
-
+
switch (clist->selection_mode)
{
case GTK_SELECTION_SINGLE:
case GTK_SELECTION_BROWSE:
return;
-
+
case GTK_SELECTION_EXTENDED:
-
+
gtk_clist_freeze (clist);
-
+
g_list_free (clist->undo_selection);
g_list_free (clist->undo_unselection);
clist->undo_selection = NULL;
clist->undo_unselection = NULL;
-
+
clist->anchor_state = GTK_STATE_SELECTED;
clist->anchor = -1;
clist->drag_pos = -1;
clist->undo_anchor = clist->focus_row;
-
+
for (node = GTK_CTREE_NODE (clist->row_list); node;
node = GTK_CTREE_NODE_NEXT (node))
gtk_ctree_pre_recursive (ctree, node, select_row_recursive, NULL);
-
+
gtk_clist_thaw (clist);
break;
-
+
case GTK_SELECTION_MULTIPLE:
gtk_ctree_select_recursive (ctree, NULL);
break;
-
+
default:
/* do nothing */
break;
@@ -3442,12 +3441,12 @@ real_unselect_all (GtkCList *clist)
GtkCTree *ctree;
GtkCTreeNode *node;
GList *list;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CTREE (clist));
ctree = GTK_CTREE (clist);
-
+
switch (clist->selection_mode)
{
case GTK_SELECTION_BROWSE:
@@ -3459,24 +3458,24 @@ real_unselect_all (GtkCList *clist)
return;
}
break;
-
+
case GTK_SELECTION_EXTENDED:
g_list_free (clist->undo_selection);
g_list_free (clist->undo_unselection);
clist->undo_selection = NULL;
clist->undo_unselection = NULL;
-
+
clist->anchor = -1;
clist->drag_pos = -1;
clist->undo_anchor = clist->focus_row;
break;
-
+
default:
break;
}
-
+
list = clist->selection;
-
+
while (list)
{
node = list->data;
@@ -3501,20 +3500,20 @@ ctree_is_hot_spot (GtkCTree *ctree,
g_return_val_if_fail (ctree != NULL, FALSE);
g_return_val_if_fail (GTK_IS_CTREE (ctree), FALSE);
g_return_val_if_fail (node != NULL, FALSE);
-
+
clist = GTK_CLIST (ctree);
-
+
if (!clist->column[ctree->tree_column].visible ||
ctree->expander_style == GTK_CTREE_EXPANDER_NONE)
return FALSE;
-
+
tree_row = GTK_CTREE_ROW (node);
-
+
cell = GTK_CELL_PIXTEXT(tree_row->row.cell[ctree->tree_column]);
-
+
yu = (ROW_TOP_YPIXEL (clist, row) + (clist->row_height - PM_SIZE) / 2 -
(clist->row_height - 1) % 2);
-
+
if (clist->column[ctree->tree_column].justification == GTK_JUSTIFY_RIGHT)
xl = (clist->column[ctree->tree_column].area.x +
clist->column[ctree->tree_column].area.width - 1 + clist->hoffset -
@@ -3524,7 +3523,7 @@ ctree_is_hot_spot (GtkCTree *ctree,
xl = (clist->column[ctree->tree_column].area.x + clist->hoffset +
(tree_row->level - 1) * ctree->tree_indent +
(ctree->line_style == GTK_CTREE_LINES_TABBED) * 3);
-
+
return (x >= xl && x <= xl + PM_SIZE && y >= yu && y <= yu + PM_SIZE);
}
@@ -3546,27 +3545,27 @@ gtk_ctree_construct (GtkCTree *ctree,
gchar *titles[])
{
GtkCList *clist;
-
+
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
g_return_if_fail (GTK_OBJECT_CONSTRUCTED (ctree) == FALSE);
-
+
clist = GTK_CLIST (ctree);
-
+
clist->row_mem_chunk = g_mem_chunk_new ("ctree row mem chunk",
sizeof (GtkCTreeRow),
sizeof (GtkCTreeRow)
* CLIST_OPTIMUM_SIZE,
G_ALLOC_AND_FREE);
-
+
clist->cell_mem_chunk = g_mem_chunk_new ("ctree cell mem chunk",
sizeof (GtkCell) * columns,
sizeof (GtkCell) * columns
* CLIST_OPTIMUM_SIZE,
G_ALLOC_AND_FREE);
-
+
ctree->tree_column = tree_column;
-
+
gtk_clist_construct (clist, columns, titles);
}
@@ -3576,13 +3575,13 @@ gtk_ctree_new_with_titles (gint columns,
gchar *titles[])
{
GtkWidget *widget;
-
+
g_return_val_if_fail (columns > 0, NULL);
g_return_val_if_fail (tree_column >= 0 && tree_column < columns, NULL);
-
+
widget = gtk_type_new (GTK_TYPE_CTREE);
gtk_ctree_construct (GTK_CTREE (widget), columns, tree_column, titles);
-
+
return widget;
}
@@ -3601,17 +3600,17 @@ real_insert_row (GtkCList *clist,
GtkCTreeNode *parent = NULL;
GtkCTreeNode *sibling;
GtkCTreeNode *node;
-
+
g_return_val_if_fail (clist != NULL, -1);
g_return_val_if_fail (GTK_IS_CTREE (clist), -1);
-
+
sibling = GTK_CTREE_NODE (g_list_nth (clist->row_list, row));
if (sibling)
parent = GTK_CTREE_ROW (sibling)->parent;
-
+
node = gtk_ctree_insert_node (GTK_CTREE (clist), parent, sibling, text, 5,
NULL, NULL, NULL, NULL, TRUE, FALSE);
-
+
if (GTK_CLIST_AUTO_SORT (clist) || !sibling)
return g_list_position (clist->row_list, (GList *) node);
@@ -3636,33 +3635,33 @@ gtk_ctree_insert_node (GtkCTree *ctree,
GtkCTreeNode *node;
GList *list;
gint i;
-
+
g_return_val_if_fail (ctree != NULL, NULL);
g_return_val_if_fail (GTK_IS_CTREE (ctree), NULL);
if (sibling)
g_return_val_if_fail (GTK_CTREE_ROW (sibling)->parent == parent, NULL);
-
+
if (parent && GTK_CTREE_ROW (parent)->is_leaf)
return NULL;
-
+
clist = GTK_CLIST (ctree);
-
+
/* create the row */
new_row = row_new (ctree);
list = g_list_alloc ();
list->data = new_row;
node = GTK_CTREE_NODE (list);
-
+
if (text)
for (i = 0; i < clist->columns; i++)
if (text[i] && i != ctree->tree_column)
- GTK_CLIST_CLASS_FW (clist)->set_cell_contents
+ GTK_CLIST_GET_CLASS (clist)->set_cell_contents
(clist, &(new_row->row), i, GTK_CELL_TEXT, text[i], 0, NULL, NULL);
-
+
set_node_info (ctree, node, text ?
text[ctree->tree_column] : NULL, spacing, pixmap_closed,
mask_closed, pixmap_opened, mask_opened, is_leaf, expanded);
-
+
/* sorted insertion */
if (GTK_CLIST_AUTO_SORT (clist))
{
@@ -3670,14 +3669,14 @@ gtk_ctree_insert_node (GtkCTree *ctree,
sibling = GTK_CTREE_ROW (parent)->children;
else
sibling = GTK_CTREE_NODE (clist->row_list);
-
+
while (sibling && clist->compare
(clist, GTK_CTREE_ROW (node), GTK_CTREE_ROW (sibling)) > 0)
sibling = GTK_CTREE_ROW (sibling)->sibling;
}
-
+
gtk_ctree_link (ctree, node, parent, sibling, TRUE);
-
+
if (text && !GTK_CLIST_AUTO_RESIZE_BLOCKED (clist) &&
gtk_ctree_is_viewable (ctree, node))
{
@@ -3685,17 +3684,17 @@ gtk_ctree_insert_node (GtkCTree *ctree,
if (clist->column[i].auto_resize)
column_auto_resize (clist, &(new_row->row), i, 0);
}
-
+
if (clist->rows == 1)
{
clist->focus_row = 0;
if (clist->selection_mode == GTK_SELECTION_BROWSE)
gtk_ctree_select (ctree, node);
}
-
-
+
+
CLIST_REFRESH (clist);
-
+
return node;
}
@@ -3714,7 +3713,7 @@ gtk_ctree_insert_gnode (GtkCTree *ctree,
GList *list;
GNode *work;
guint depth = 1;
-
+
g_return_val_if_fail (ctree != NULL, NULL);
g_return_val_if_fail (GTK_IS_CTREE (ctree), NULL);
g_return_val_if_fail (gnode != NULL, NULL);
@@ -3723,38 +3722,38 @@ gtk_ctree_insert_gnode (GtkCTree *ctree,
g_return_val_if_fail (GTK_CTREE_ROW (sibling)->parent == parent, NULL);
clist = GTK_CLIST (ctree);
-
+
if (parent)
depth = GTK_CTREE_ROW (parent)->level + 1;
-
+
list = g_list_alloc ();
list->data = row_new (ctree);
cnode = GTK_CTREE_NODE (list);
-
+
gtk_clist_freeze (clist);
-
+
set_node_info (ctree, cnode, "", 0, NULL, NULL, NULL, NULL, TRUE, FALSE);
-
+
if (!func (ctree, depth, gnode, cnode, data))
{
tree_delete_row (ctree, cnode, NULL);
return NULL;
}
-
+
if (GTK_CLIST_AUTO_SORT (clist))
{
if (parent)
sibling = GTK_CTREE_ROW (parent)->children;
else
sibling = GTK_CTREE_NODE (clist->row_list);
-
+
while (sibling && clist->compare
(clist, GTK_CTREE_ROW (cnode), GTK_CTREE_ROW (sibling)) > 0)
sibling = GTK_CTREE_ROW (sibling)->sibling;
}
-
+
gtk_ctree_link (ctree, cnode, parent, sibling, TRUE);
-
+
for (work = g_node_last_child (gnode); work; work = work->prev)
{
new_child = gtk_ctree_insert_gnode (ctree, cnode, child,
@@ -3764,7 +3763,7 @@ gtk_ctree_insert_gnode (GtkCTree *ctree,
}
gtk_clist_thaw (clist);
-
+
return cnode;
}
@@ -3779,7 +3778,7 @@ gtk_ctree_export_to_gnode (GtkCTree *ctree,
GtkCTreeNode *work;
GNode *gnode;
gint depth;
-
+
g_return_val_if_fail (ctree != NULL, NULL);
g_return_val_if_fail (GTK_IS_CTREE (ctree), NULL);
g_return_val_if_fail (node != NULL, NULL);
@@ -3789,7 +3788,7 @@ gtk_ctree_export_to_gnode (GtkCTree *ctree,
g_return_val_if_fail (parent != NULL, NULL);
g_return_val_if_fail (sibling->parent == parent, NULL);
}
-
+
gnode = g_node_new (NULL);
depth = g_node_depth (parent) + 1;
@@ -3798,36 +3797,36 @@ gtk_ctree_export_to_gnode (GtkCTree *ctree,
g_node_destroy (gnode);
return NULL;
}
-
+
if (parent)
g_node_insert_before (parent, sibling, gnode);
-
+
if (!GTK_CTREE_ROW (node)->is_leaf)
{
GNode *new_sibling = NULL;
-
+
for (work = GTK_CTREE_ROW (node)->children; work;
work = GTK_CTREE_ROW (work)->sibling)
new_sibling = gtk_ctree_export_to_gnode (ctree, gnode, new_sibling,
work, func, data);
-
+
g_node_reverse_children (gnode);
}
-
+
return gnode;
}
-
+
static void
real_remove_row (GtkCList *clist,
gint row)
{
GtkCTreeNode *node;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CTREE (clist));
-
+
node = GTK_CTREE_NODE (g_list_nth (clist->row_list, row));
-
+
if (node)
gtk_ctree_remove_node (GTK_CTREE (clist), node);
}
@@ -3837,18 +3836,18 @@ gtk_ctree_remove_node (GtkCTree *ctree,
GtkCTreeNode *node)
{
GtkCList *clist;
-
+
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
-
+
clist = GTK_CLIST (ctree);
-
+
gtk_clist_freeze (clist);
-
+
if (node)
{
gboolean visible;
-
+
visible = gtk_ctree_is_viewable (ctree, node);
gtk_ctree_unlink (ctree, node, TRUE);
gtk_ctree_post_recursive (ctree, node, GTK_CTREE_FUNC (tree_delete),
@@ -3856,12 +3855,12 @@ gtk_ctree_remove_node (GtkCTree *ctree,
if (clist->selection_mode == GTK_SELECTION_BROWSE && !clist->selection &&
clist->focus_row >= 0)
gtk_clist_select_row (clist, clist->focus_row, -1);
-
+
auto_resize_columns (clist);
}
else
gtk_clist_clear (clist);
-
+
gtk_clist_thaw (clist);
}
@@ -3871,17 +3870,17 @@ real_clear (GtkCList *clist)
GtkCTree *ctree;
GtkCTreeNode *work;
GtkCTreeNode *ptr;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CTREE (clist));
-
+
ctree = GTK_CTREE (clist);
-
+
/* remove all rows */
work = GTK_CTREE_NODE (clist->row_list);
clist->row_list = NULL;
clist->row_list_end = NULL;
-
+
GTK_CLIST_SET_FLAG (clist, CLIST_AUTO_RESIZE_BLOCKED);
while (work)
{
@@ -3891,7 +3890,7 @@ real_clear (GtkCList *clist)
NULL);
}
GTK_CLIST_UNSET_FLAG (clist, CLIST_AUTO_RESIZE_BLOCKED);
-
+
parent_class->clear (clist);
}
@@ -3910,23 +3909,23 @@ gtk_ctree_post_recursive (GtkCTree *ctree,
{
GtkCTreeNode *work;
GtkCTreeNode *tmp;
-
+
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
g_return_if_fail (func != NULL);
-
+
if (node)
work = GTK_CTREE_ROW (node)->children;
else
work = GTK_CTREE_NODE (GTK_CLIST (ctree)->row_list);
-
+
while (work)
{
tmp = GTK_CTREE_ROW (work)->sibling;
gtk_ctree_post_recursive (ctree, work, func, data);
work = tmp;
}
-
+
if (node)
func (ctree, node, data);
}
@@ -3940,22 +3939,22 @@ gtk_ctree_post_recursive_to_depth (GtkCTree *ctree,
{
GtkCTreeNode *work;
GtkCTreeNode *tmp;
-
+
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
g_return_if_fail (func != NULL);
-
+
if (depth < 0)
{
gtk_ctree_post_recursive (ctree, node, func, data);
return;
}
-
+
if (node)
work = GTK_CTREE_ROW (node)->children;
else
work = GTK_CTREE_NODE (GTK_CLIST (ctree)->row_list);
-
+
if (work && GTK_CTREE_ROW (work)->level <= depth)
{
while (work)
@@ -3965,7 +3964,7 @@ gtk_ctree_post_recursive_to_depth (GtkCTree *ctree,
work = tmp;
}
}
-
+
if (node && GTK_CTREE_ROW (node)->level <= depth)
func (ctree, node, data);
}
@@ -3978,11 +3977,11 @@ gtk_ctree_pre_recursive (GtkCTree *ctree,
{
GtkCTreeNode *work;
GtkCTreeNode *tmp;
-
+
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
g_return_if_fail (func != NULL);
-
+
if (node)
{
work = GTK_CTREE_ROW (node)->children;
@@ -3990,7 +3989,7 @@ gtk_ctree_pre_recursive (GtkCTree *ctree,
}
else
work = GTK_CTREE_NODE (GTK_CLIST (ctree)->row_list);
-
+
while (work)
{
tmp = GTK_CTREE_ROW (work)->sibling;
@@ -4008,17 +4007,17 @@ gtk_ctree_pre_recursive_to_depth (GtkCTree *ctree,
{
GtkCTreeNode *work;
GtkCTreeNode *tmp;
-
+
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
g_return_if_fail (func != NULL);
-
+
if (depth < 0)
{
gtk_ctree_pre_recursive (ctree, node, func, data);
return;
}
-
+
if (node)
{
work = GTK_CTREE_ROW (node)->children;
@@ -4027,7 +4026,7 @@ gtk_ctree_pre_recursive_to_depth (GtkCTree *ctree,
}
else
work = GTK_CTREE_NODE (GTK_CLIST (ctree)->row_list);
-
+
if (work && GTK_CTREE_ROW (work)->level <= depth)
{
while (work)
@@ -4044,19 +4043,19 @@ gtk_ctree_is_viewable (GtkCTree *ctree,
GtkCTreeNode *node)
{
GtkCTreeRow *work;
-
+
g_return_val_if_fail (ctree != NULL, FALSE);
g_return_val_if_fail (GTK_IS_CTREE (ctree), FALSE);
g_return_val_if_fail (node != NULL, FALSE);
-
+
work = GTK_CTREE_ROW (node);
-
+
while (work->parent && GTK_CTREE_ROW (work->parent)->expanded)
work = GTK_CTREE_ROW (work->parent);
-
+
if (!work->parent)
return TRUE;
-
+
return FALSE;
}
@@ -4066,10 +4065,10 @@ gtk_ctree_last (GtkCTree *ctree,
{
g_return_val_if_fail (ctree != NULL, NULL);
g_return_val_if_fail (GTK_IS_CTREE (ctree), NULL);
-
+
if (!node)
return NULL;
-
+
while (GTK_CTREE_ROW (node)->sibling)
node = GTK_CTREE_ROW (node)->sibling;
@@ -4093,7 +4092,7 @@ gtk_ctree_find_node_ptr (GtkCTree *ctree,
node = GTK_CTREE_ROW(ctree_row->parent)->children;
else
node = GTK_CTREE_NODE (GTK_CLIST (ctree)->row_list);
-
+
while (GTK_CTREE_ROW (node) != ctree_row)
node = GTK_CTREE_ROW (node)->sibling;
@@ -4106,10 +4105,10 @@ gtk_ctree_node_nth (GtkCTree *ctree,
{
g_return_val_if_fail (ctree != NULL, NULL);
g_return_val_if_fail (GTK_IS_CTREE (ctree), NULL);
-
+
if ((row < 0) || (row >= GTK_CLIST(ctree)->rows))
return NULL;
-
+
return GTK_CTREE_NODE (g_list_nth (GTK_CLIST (ctree)->row_list, row));
}
@@ -4120,10 +4119,10 @@ gtk_ctree_find (GtkCTree *ctree,
{
if (!child)
return FALSE;
-
+
if (!node)
node = GTK_CTREE_NODE (GTK_CLIST (ctree)->row_list);
-
+
while (node)
{
if (node == child)
@@ -4145,10 +4144,10 @@ gtk_ctree_is_ancestor (GtkCTree *ctree,
{
g_return_val_if_fail (GTK_IS_CTREE (ctree), FALSE);
g_return_val_if_fail (node != NULL, FALSE);
-
+
if (GTK_CTREE_ROW (node)->children)
return gtk_ctree_find (ctree, GTK_CTREE_ROW (node)->children, child);
-
+
return FALSE;
}
@@ -4181,23 +4180,23 @@ gtk_ctree_find_all_by_row_data (GtkCTree *ctree,
gpointer data)
{
GList *list = NULL;
-
+
g_return_val_if_fail (ctree != NULL, NULL);
g_return_val_if_fail (GTK_IS_CTREE (ctree), NULL);
-
+
/* if node == NULL then look in the whole tree */
if (!node)
node = GTK_CTREE_NODE (GTK_CLIST (ctree)->row_list);
-
+
while (node)
{
if (GTK_CTREE_ROW (node)->row.data == data)
list = g_list_append (list, node);
-
+
if (GTK_CTREE_ROW (node)->children)
{
GList *sub_list;
-
+
sub_list = gtk_ctree_find_all_by_row_data (ctree,
GTK_CTREE_ROW
(node)->children,
@@ -4216,12 +4215,12 @@ gtk_ctree_find_by_row_data_custom (GtkCTree *ctree,
GCompareFunc func)
{
GtkCTreeNode *work;
-
+
g_return_val_if_fail (func != NULL, NULL);
-
+
if (!node)
node = GTK_CTREE_NODE (GTK_CLIST (ctree)->row_list);
-
+
while (node)
{
if (!func (GTK_CTREE_ROW (node)->row.data, data))
@@ -4242,24 +4241,24 @@ gtk_ctree_find_all_by_row_data_custom (GtkCTree *ctree,
GCompareFunc func)
{
GList *list = NULL;
-
+
g_return_val_if_fail (ctree != NULL, NULL);
g_return_val_if_fail (GTK_IS_CTREE (ctree), NULL);
g_return_val_if_fail (func != NULL, NULL);
-
+
/* if node == NULL then look in the whole tree */
if (!node)
node = GTK_CTREE_NODE (GTK_CLIST (ctree)->row_list);
-
+
while (node)
{
if (!func (GTK_CTREE_ROW (node)->row.data, data))
list = g_list_append (list, node);
-
+
if (GTK_CTREE_ROW (node)->children)
{
GList *sub_list;
-
+
sub_list = gtk_ctree_find_all_by_row_data_custom (ctree,
GTK_CTREE_ROW
(node)->children,
@@ -4283,11 +4282,11 @@ gtk_ctree_is_hot_spot (GtkCTree *ctree,
g_return_val_if_fail (ctree != NULL, FALSE);
g_return_val_if_fail (GTK_IS_CTREE (ctree), FALSE);
-
+
if (gtk_clist_get_selection_info (GTK_CLIST (ctree), x, y, &row, &column))
if ((node = GTK_CTREE_NODE(g_list_nth (GTK_CLIST (ctree)->row_list, row))))
return ctree_is_hot_spot (ctree, node, row, x, y);
-
+
return FALSE;
}
@@ -4321,7 +4320,7 @@ gtk_ctree_expand (GtkCTree *ctree,
if (GTK_CTREE_ROW (node)->is_leaf)
return;
-
+
gtk_signal_emit (GTK_OBJECT (ctree), ctree_signals[TREE_EXPAND], node);
}
@@ -4331,23 +4330,23 @@ gtk_ctree_expand_recursive (GtkCTree *ctree,
{
GtkCList *clist;
gboolean thaw = FALSE;
-
+
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
-
+
clist = GTK_CLIST (ctree);
-
+
if (node && GTK_CTREE_ROW (node)->is_leaf)
return;
-
+
if (CLIST_UNFROZEN (clist) && (!node || gtk_ctree_is_viewable (ctree, node)))
{
gtk_clist_freeze (clist);
thaw = TRUE;
}
-
+
gtk_ctree_post_recursive (ctree, node, GTK_CTREE_FUNC (tree_expand), NULL);
-
+
if (thaw)
gtk_clist_thaw (clist);
}
@@ -4359,24 +4358,24 @@ gtk_ctree_expand_to_depth (GtkCTree *ctree,
{
GtkCList *clist;
gboolean thaw = FALSE;
-
+
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
-
+
clist = GTK_CLIST (ctree);
-
+
if (node && GTK_CTREE_ROW (node)->is_leaf)
return;
-
+
if (CLIST_UNFROZEN (clist) && (!node || gtk_ctree_is_viewable (ctree, node)))
{
gtk_clist_freeze (clist);
thaw = TRUE;
}
-
+
gtk_ctree_post_recursive_to_depth (ctree, node, depth,
GTK_CTREE_FUNC (tree_expand), NULL);
-
+
if (thaw)
gtk_clist_thaw (clist);
}
@@ -4391,7 +4390,7 @@ gtk_ctree_collapse (GtkCTree *ctree,
if (GTK_CTREE_ROW (node)->is_leaf)
return;
-
+
gtk_signal_emit (GTK_OBJECT (ctree), ctree_signals[TREE_COLLAPSE], node);
}
@@ -4402,21 +4401,21 @@ gtk_ctree_collapse_recursive (GtkCTree *ctree,
GtkCList *clist;
gboolean thaw = FALSE;
gint i;
-
+
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
-
+
if (node && GTK_CTREE_ROW (node)->is_leaf)
return;
-
+
clist = GTK_CLIST (ctree);
-
+
if (CLIST_UNFROZEN (clist) && (!node || gtk_ctree_is_viewable (ctree, node)))
{
gtk_clist_freeze (clist);
thaw = TRUE;
}
-
+
GTK_CLIST_SET_FLAG (clist, CLIST_AUTO_RESIZE_BLOCKED);
gtk_ctree_post_recursive (ctree, node, GTK_CTREE_FUNC (tree_collapse), NULL);
GTK_CLIST_UNSET_FLAG (clist, CLIST_AUTO_RESIZE_BLOCKED);
@@ -4424,7 +4423,7 @@ gtk_ctree_collapse_recursive (GtkCTree *ctree,
if (clist->column[i].auto_resize)
gtk_clist_set_column_width (clist, i,
gtk_clist_optimal_column_width (clist, i));
-
+
if (thaw)
gtk_clist_thaw (clist);
}
@@ -4437,21 +4436,21 @@ gtk_ctree_collapse_to_depth (GtkCTree *ctree,
GtkCList *clist;
gboolean thaw = FALSE;
gint i;
-
+
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
-
+
if (node && GTK_CTREE_ROW (node)->is_leaf)
return;
-
+
clist = GTK_CLIST (ctree);
-
+
if (CLIST_UNFROZEN (clist) && (!node || gtk_ctree_is_viewable (ctree, node)))
{
gtk_clist_freeze (clist);
thaw = TRUE;
}
-
+
GTK_CLIST_SET_FLAG (clist, CLIST_AUTO_RESIZE_BLOCKED);
gtk_ctree_post_recursive_to_depth (ctree, node, depth,
GTK_CTREE_FUNC (tree_collapse_to_depth),
@@ -4461,7 +4460,7 @@ gtk_ctree_collapse_to_depth (GtkCTree *ctree,
if (clist->column[i].auto_resize)
gtk_clist_set_column_width (clist, i,
gtk_clist_optimal_column_width (clist, i));
-
+
if (thaw)
gtk_clist_thaw (clist);
}
@@ -4476,7 +4475,7 @@ gtk_ctree_toggle_expansion (GtkCTree *ctree,
if (GTK_CTREE_ROW (node)->is_leaf)
return;
-
+
tree_toggle_expansion (ctree, node, NULL);
}
@@ -4486,15 +4485,15 @@ gtk_ctree_toggle_expansion_recursive (GtkCTree *ctree,
{
GtkCList *clist;
gboolean thaw = FALSE;
-
+
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
if (node && GTK_CTREE_ROW (node)->is_leaf)
return;
-
+
clist = GTK_CLIST (ctree);
-
+
if (CLIST_UNFROZEN (clist) && (!node || gtk_ctree_is_viewable (ctree, node)))
{
gtk_clist_freeze (clist);
@@ -4503,7 +4502,7 @@ gtk_ctree_toggle_expansion_recursive (GtkCTree *ctree,
gtk_ctree_post_recursive (ctree, node,
GTK_CTREE_FUNC (tree_toggle_expansion), NULL);
-
+
if (thaw)
gtk_clist_thaw (clist);
}
@@ -4515,7 +4514,7 @@ gtk_ctree_select (GtkCTree *ctree,
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
g_return_if_fail (node != NULL);
-
+
if (GTK_CTREE_ROW (node)->row.selectable)
gtk_signal_emit (GTK_OBJECT (ctree), ctree_signals[TREE_SELECT_ROW],
node, -1);
@@ -4528,7 +4527,7 @@ gtk_ctree_unselect (GtkCTree *ctree,
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
g_return_if_fail (node != NULL);
-
+
gtk_signal_emit (GTK_OBJECT (ctree), ctree_signals[TREE_UNSELECT_ROW],
node, -1);
}
@@ -4554,34 +4553,34 @@ gtk_ctree_real_select_recursive (GtkCTree *ctree,
{
GtkCList *clist;
gboolean thaw = FALSE;
-
+
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
-
+
clist = GTK_CLIST (ctree);
-
+
if ((state &&
(clist->selection_mode == GTK_SELECTION_BROWSE ||
clist->selection_mode == GTK_SELECTION_SINGLE)) ||
(!state && clist->selection_mode == GTK_SELECTION_BROWSE))
return;
-
+
if (CLIST_UNFROZEN (clist) && (!node || gtk_ctree_is_viewable (ctree, node)))
{
gtk_clist_freeze (clist);
thaw = TRUE;
}
-
+
if (clist->selection_mode == GTK_SELECTION_EXTENDED)
{
- GTK_CLIST_CLASS_FW (clist)->resync_selection (clist, NULL);
+ GTK_CLIST_GET_CLASS (clist)->resync_selection (clist, NULL);
g_list_free (clist->undo_selection);
g_list_free (clist->undo_unselection);
clist->undo_selection = NULL;
clist->undo_unselection = NULL;
}
-
+
if (state)
gtk_ctree_post_recursive (ctree, node,
GTK_CTREE_FUNC (tree_select), NULL);
@@ -4606,20 +4605,20 @@ gtk_ctree_node_set_text (GtkCTree *ctree,
const gchar *text)
{
GtkCList *clist;
-
+
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
g_return_if_fail (node != NULL);
-
+
if (column < 0 || column >= GTK_CLIST (ctree)->columns)
return;
clist = GTK_CLIST (ctree);
-
- GTK_CLIST_CLASS_FW (clist)->set_cell_contents
+
+ GTK_CLIST_GET_CLASS (clist)->set_cell_contents
(clist, &(GTK_CTREE_ROW(node)->row), column, GTK_CELL_TEXT,
text, 0, NULL, NULL);
-
+
tree_draw_node (ctree, node);
}
@@ -4631,25 +4630,25 @@ gtk_ctree_node_set_pixmap (GtkCTree *ctree,
GdkBitmap *mask)
{
GtkCList *clist;
-
+
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
g_return_if_fail (node != NULL);
g_return_if_fail (pixmap != NULL);
-
+
if (column < 0 || column >= GTK_CLIST (ctree)->columns)
return;
-
+
gdk_pixmap_ref (pixmap);
if (mask)
gdk_pixmap_ref (mask);
-
+
clist = GTK_CLIST (ctree);
-
- GTK_CLIST_CLASS_FW (clist)->set_cell_contents
+
+ GTK_CLIST_GET_CLASS (clist)->set_cell_contents
(clist, &(GTK_CTREE_ROW (node)->row), column, GTK_CELL_PIXMAP,
NULL, 0, pixmap, mask);
-
+
tree_draw_node (ctree, node);
}
@@ -4663,7 +4662,7 @@ gtk_ctree_node_set_pixtext (GtkCTree *ctree,
GdkBitmap *mask)
{
GtkCList *clist;
-
+
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
g_return_if_fail (node != NULL);
@@ -4671,20 +4670,20 @@ gtk_ctree_node_set_pixtext (GtkCTree *ctree,
g_return_if_fail (pixmap != NULL);
if (column < 0 || column >= GTK_CLIST (ctree)->columns)
return;
-
+
clist = GTK_CLIST (ctree);
-
+
if (pixmap)
{
gdk_pixmap_ref (pixmap);
if (mask)
gdk_pixmap_ref (mask);
}
-
- GTK_CLIST_CLASS_FW (clist)->set_cell_contents
+
+ GTK_CLIST_GET_CLASS (clist)->set_cell_contents
(clist, &(GTK_CTREE_ROW (node)->row), column, GTK_CELL_PIXTEXT,
text, spacing, pixmap, mask);
-
+
tree_draw_node (ctree, node);
}
@@ -4702,14 +4701,14 @@ gtk_ctree_set_node_info (GtkCTree *ctree,
{
gboolean old_leaf;
gboolean old_expanded;
-
+
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
g_return_if_fail (node != NULL);
-
+
old_leaf = GTK_CTREE_ROW (node)->is_leaf;
old_expanded = GTK_CTREE_ROW (node)->expanded;
-
+
if (is_leaf && GTK_CTREE_ROW (node)->children)
{
GtkCTreeNode *work;
@@ -4723,10 +4722,10 @@ gtk_ctree_set_node_info (GtkCTree *ctree,
gtk_ctree_remove_node (ctree, ptr);
}
}
-
+
set_node_info (ctree, node, text, spacing, pixmap_closed, mask_closed,
pixmap_opened, mask_opened, is_leaf, expanded);
-
+
if (!is_leaf && !old_leaf)
{
GTK_CTREE_ROW (node)->expanded = old_expanded;
@@ -4735,7 +4734,7 @@ gtk_ctree_set_node_info (GtkCTree *ctree,
else if (!expanded && old_expanded)
gtk_ctree_collapse (ctree, node);
}
-
+
GTK_CTREE_ROW (node)->expanded = (is_leaf) ? FALSE : expanded;
tree_draw_node (ctree, node);
@@ -4751,32 +4750,32 @@ gtk_ctree_node_set_shift (GtkCTree *ctree,
GtkCList *clist;
GtkRequisition requisition;
gboolean visible = FALSE;
-
+
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
g_return_if_fail (node != NULL);
-
+
if (column < 0 || column >= GTK_CLIST (ctree)->columns)
return;
-
+
clist = GTK_CLIST (ctree);
-
+
if (clist->column[column].auto_resize &&
!GTK_CLIST_AUTO_RESIZE_BLOCKED (clist))
{
visible = gtk_ctree_is_viewable (ctree, node);
if (visible)
- GTK_CLIST_CLASS_FW (clist)->cell_size_request
+ GTK_CLIST_GET_CLASS (clist)->cell_size_request
(clist, &GTK_CTREE_ROW (node)->row, column, &requisition);
}
-
+
GTK_CTREE_ROW (node)->row.cell[column].vertical = vertical;
GTK_CTREE_ROW (node)->row.cell[column].horizontal = horizontal;
-
+
if (visible)
column_auto_resize (clist, &GTK_CTREE_ROW (node)->row,
column, requisition.width);
-
+
tree_draw_node (ctree, node);
}
@@ -4788,13 +4787,13 @@ remove_grab (GtkCList *clist)
gtk_grab_remove (GTK_WIDGET (clist));
gdk_pointer_ungrab (GDK_CURRENT_TIME);
}
-
+
if (clist->htimer)
{
gtk_timeout_remove (clist->htimer);
clist->htimer = 0;
}
-
+
if (clist->vtimer)
{
gtk_timeout_remove (clist->vtimer);
@@ -4810,25 +4809,25 @@ gtk_ctree_node_set_selectable (GtkCTree *ctree,
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
g_return_if_fail (node != NULL);
-
+
if (selectable == GTK_CTREE_ROW (node)->row.selectable)
return;
-
+
GTK_CTREE_ROW (node)->row.selectable = selectable;
-
+
if (!selectable && GTK_CTREE_ROW (node)->row.state == GTK_STATE_SELECTED)
{
GtkCList *clist;
-
+
clist = GTK_CLIST (ctree);
-
+
if (clist->anchor >= 0 &&
clist->selection_mode == GTK_SELECTION_EXTENDED)
{
clist->drag_button = 0;
remove_grab (clist);
-
- GTK_CLIST_CLASS_FW (clist)->resync_selection (clist, NULL);
+
+ GTK_CLIST_GET_CLASS (clist)->resync_selection (clist, NULL);
}
gtk_ctree_unselect (ctree, node);
}
@@ -4839,7 +4838,7 @@ gtk_ctree_node_get_selectable (GtkCTree *ctree,
GtkCTreeNode *node)
{
g_return_val_if_fail (node != NULL, FALSE);
-
+
return GTK_CTREE_ROW (node)->row.selectable;
}
@@ -4851,10 +4850,10 @@ gtk_ctree_node_get_cell_type (GtkCTree *ctree,
g_return_val_if_fail (ctree != NULL, -1);
g_return_val_if_fail (GTK_IS_CTREE (ctree), -1);
g_return_val_if_fail (node != NULL, -1);
-
+
if (column < 0 || column >= GTK_CLIST (ctree)->columns)
return -1;
-
+
return GTK_CTREE_ROW (node)->row.cell[column].type;
}
@@ -4867,16 +4866,16 @@ gtk_ctree_node_get_text (GtkCTree *ctree,
g_return_val_if_fail (ctree != NULL, 0);
g_return_val_if_fail (GTK_IS_CTREE (ctree), 0);
g_return_val_if_fail (node != NULL, 0);
-
+
if (column < 0 || column >= GTK_CLIST (ctree)->columns)
return 0;
-
+
if (GTK_CTREE_ROW (node)->row.cell[column].type != GTK_CELL_TEXT)
return 0;
-
+
if (text)
*text = GTK_CELL_TEXT (GTK_CTREE_ROW (node)->row.cell[column])->text;
-
+
return 1;
}
@@ -4890,18 +4889,18 @@ gtk_ctree_node_get_pixmap (GtkCTree *ctree,
g_return_val_if_fail (ctree != NULL, 0);
g_return_val_if_fail (GTK_IS_CTREE (ctree), 0);
g_return_val_if_fail (node != NULL, 0);
-
+
if (column < 0 || column >= GTK_CLIST (ctree)->columns)
return 0;
-
+
if (GTK_CTREE_ROW (node)->row.cell[column].type != GTK_CELL_PIXMAP)
return 0;
-
+
if (pixmap)
*pixmap = GTK_CELL_PIXMAP (GTK_CTREE_ROW(node)->row.cell[column])->pixmap;
if (mask)
*mask = GTK_CELL_PIXMAP (GTK_CTREE_ROW (node)->row.cell[column])->mask;
-
+
return 1;
}
@@ -4985,37 +4984,37 @@ gtk_ctree_node_set_cell_style (GtkCTree *ctree,
GtkCList *clist;
GtkRequisition requisition;
gboolean visible = FALSE;
-
+
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
g_return_if_fail (node != NULL);
-
+
clist = GTK_CLIST (ctree);
-
+
if (column < 0 || column >= clist->columns)
return;
-
+
if (GTK_CTREE_ROW (node)->row.cell[column].style == style)
return;
-
+
if (clist->column[column].auto_resize &&
!GTK_CLIST_AUTO_RESIZE_BLOCKED (clist))
{
visible = gtk_ctree_is_viewable (ctree, node);
if (visible)
- GTK_CLIST_CLASS_FW (clist)->cell_size_request
+ GTK_CLIST_GET_CLASS (clist)->cell_size_request
(clist, &GTK_CTREE_ROW (node)->row, column, &requisition);
}
-
+
if (GTK_CTREE_ROW (node)->row.cell[column].style)
{
if (GTK_WIDGET_REALIZED (ctree))
gtk_style_detach (GTK_CTREE_ROW (node)->row.cell[column].style);
gtk_style_unref (GTK_CTREE_ROW (node)->row.cell[column].style);
}
-
+
GTK_CTREE_ROW (node)->row.cell[column].style = style;
-
+
if (GTK_CTREE_ROW (node)->row.cell[column].style)
{
gtk_style_ref (GTK_CTREE_ROW (node)->row.cell[column].style);
@@ -5025,11 +5024,11 @@ gtk_ctree_node_set_cell_style (GtkCTree *ctree,
gtk_style_attach (GTK_CTREE_ROW (node)->row.cell[column].style,
clist->clist_window);
}
-
+
if (visible)
column_auto_resize (clist, &GTK_CTREE_ROW (node)->row, column,
requisition.width);
-
+
tree_draw_node (ctree, node);
}
@@ -5041,10 +5040,10 @@ gtk_ctree_node_get_cell_style (GtkCTree *ctree,
g_return_val_if_fail (ctree != NULL, NULL);
g_return_val_if_fail (GTK_IS_CTREE (ctree), NULL);
g_return_val_if_fail (node != NULL, NULL);
-
+
if (column < 0 || column >= GTK_CLIST (ctree)->columns)
return NULL;
-
+
return GTK_CTREE_ROW (node)->row.cell[column].style;
}
@@ -5058,13 +5057,13 @@ gtk_ctree_node_set_row_style (GtkCTree *ctree,
gboolean visible;
gint *old_width = NULL;
gint i;
-
+
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
g_return_if_fail (node != NULL);
-
+
clist = GTK_CLIST (ctree);
-
+
if (GTK_CTREE_ROW (node)->row.style == style)
return;
@@ -5075,21 +5074,21 @@ gtk_ctree_node_set_row_style (GtkCTree *ctree,
for (i = 0; i < clist->columns; i++)
if (clist->column[i].auto_resize)
{
- GTK_CLIST_CLASS_FW (clist)->cell_size_request
+ GTK_CLIST_GET_CLASS (clist)->cell_size_request
(clist, &GTK_CTREE_ROW (node)->row, i, &requisition);
old_width[i] = requisition.width;
}
}
-
+
if (GTK_CTREE_ROW (node)->row.style)
{
if (GTK_WIDGET_REALIZED (ctree))
gtk_style_detach (GTK_CTREE_ROW (node)->row.style);
gtk_style_unref (GTK_CTREE_ROW (node)->row.style);
}
-
+
GTK_CTREE_ROW (node)->row.style = style;
-
+
if (GTK_CTREE_ROW (node)->row.style)
{
gtk_style_ref (GTK_CTREE_ROW (node)->row.style);
@@ -5099,7 +5098,7 @@ gtk_ctree_node_set_row_style (GtkCTree *ctree,
gtk_style_attach (GTK_CTREE_ROW (node)->row.style,
clist->clist_window);
}
-
+
if (visible && !GTK_CLIST_AUTO_RESIZE_BLOCKED (clist))
{
for (i = 0; i < clist->columns; i++)
@@ -5118,7 +5117,7 @@ gtk_ctree_node_get_row_style (GtkCTree *ctree,
g_return_val_if_fail (ctree != NULL, NULL);
g_return_val_if_fail (GTK_IS_CTREE (ctree), NULL);
g_return_val_if_fail (node != NULL, NULL);
-
+
return GTK_CTREE_ROW (node)->row.style;
}
@@ -5130,7 +5129,7 @@ gtk_ctree_node_set_foreground (GtkCTree *ctree,
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
g_return_if_fail (node != NULL);
-
+
if (color)
{
GTK_CTREE_ROW (node)->row.foreground = *color;
@@ -5141,7 +5140,7 @@ gtk_ctree_node_set_foreground (GtkCTree *ctree,
}
else
GTK_CTREE_ROW (node)->row.fg_set = FALSE;
-
+
tree_draw_node (ctree, node);
}
@@ -5153,7 +5152,7 @@ gtk_ctree_node_set_background (GtkCTree *ctree,
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
g_return_if_fail (node != NULL);
-
+
if (color)
{
GTK_CTREE_ROW (node)->row.background = *color;
@@ -5164,7 +5163,7 @@ gtk_ctree_node_set_background (GtkCTree *ctree,
}
else
GTK_CTREE_ROW (node)->row.bg_set = FALSE;
-
+
tree_draw_node (ctree, node);
}
@@ -5188,13 +5187,13 @@ gtk_ctree_node_set_row_data_full (GtkCTree *ctree,
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
g_return_if_fail (node != NULL);
-
+
dnotify = GTK_CTREE_ROW (node)->row.destroy;
ddata = GTK_CTREE_ROW (node)->row.data;
GTK_CTREE_ROW (node)->row.data = data;
GTK_CTREE_ROW (node)->row.destroy = destroy;
-
+
if (dnotify)
dnotify (ddata);
}
@@ -5205,7 +5204,7 @@ gtk_ctree_node_get_row_data (GtkCTree *ctree,
{
g_return_val_if_fail (ctree != NULL, NULL);
g_return_val_if_fail (GTK_IS_CTREE (ctree), NULL);
-
+
return node ? GTK_CTREE_ROW (node)->row.data : NULL;
}
@@ -5218,15 +5217,15 @@ gtk_ctree_node_moveto (GtkCTree *ctree,
{
gint row = -1;
GtkCList *clist;
-
+
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
-
+
clist = GTK_CLIST (ctree);
-
+
while (node && !gtk_ctree_is_viewable (ctree, node))
node = GTK_CTREE_ROW (node)->parent;
-
+
if (node)
row = g_list_position (clist->row_list, (GList *)node);
@@ -5255,17 +5254,17 @@ gtk_ctree_set_indent (GtkCTree *ctree,
gint indent)
{
GtkCList *clist;
-
+
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
g_return_if_fail (indent >= 0);
-
+
if (indent == ctree->tree_indent)
return;
-
+
clist = GTK_CLIST (ctree);
ctree->tree_indent = indent;
-
+
if (clist->column[ctree->tree_column].auto_resize &&
!GTK_CLIST_AUTO_RESIZE_BLOCKED (clist))
gtk_clist_set_column_width
@@ -5281,19 +5280,19 @@ gtk_ctree_set_spacing (GtkCTree *ctree,
{
GtkCList *clist;
gint old_spacing;
-
+
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
g_return_if_fail (spacing >= 0);
-
+
if (spacing == ctree->tree_spacing)
return;
-
+
clist = GTK_CLIST (ctree);
-
+
old_spacing = ctree->tree_spacing;
ctree->tree_spacing = spacing;
-
+
if (clist->column[ctree->tree_column].auto_resize &&
!GTK_CLIST_AUTO_RESIZE_BLOCKED (clist))
gtk_clist_set_column_width (clist, ctree->tree_column,
@@ -5309,19 +5308,19 @@ gtk_ctree_set_show_stub (GtkCTree *ctree,
{
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
-
+
show_stub = show_stub != FALSE;
-
+
if (show_stub != ctree->show_stub)
{
GtkCList *clist;
-
+
clist = GTK_CLIST (ctree);
ctree->show_stub = show_stub;
-
+
if (CLIST_UNFROZEN (clist) && clist->rows &&
gtk_clist_row_is_visible (clist, 0) != GTK_VISIBILITY_NONE)
- GTK_CLIST_CLASS_FW (clist)->draw_row
+ GTK_CLIST_GET_CLASS (clist)->draw_row
(clist, NULL, 0, GTK_CLIST_ROW (clist->row_list));
}
}
@@ -5332,18 +5331,18 @@ gtk_ctree_set_line_style (GtkCTree *ctree,
{
GtkCList *clist;
GtkCTreeLineStyle old_style;
-
+
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
-
+
if (line_style == ctree->line_style)
return;
-
+
clist = GTK_CLIST (ctree);
-
+
old_style = ctree->line_style;
ctree->line_style = line_style;
-
+
if (clist->column[ctree->tree_column].auto_resize &&
!GTK_CLIST_AUTO_RESIZE_BLOCKED (clist))
{
@@ -5356,7 +5355,7 @@ gtk_ctree_set_line_style (GtkCTree *ctree,
(clist, ctree->tree_column,
clist->column[ctree->tree_column].width + 3);
}
-
+
if (GTK_WIDGET_REALIZED (ctree))
{
switch (line_style)
@@ -5392,23 +5391,23 @@ gtk_ctree_set_expander_style (GtkCTree *ctree,
{
GtkCList *clist;
GtkCTreeExpanderStyle old_style;
-
+
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
-
+
if (expander_style == ctree->expander_style)
return;
-
+
clist = GTK_CLIST (ctree);
-
+
old_style = ctree->expander_style;
ctree->expander_style = expander_style;
-
+
if (clist->column[ctree->tree_column].auto_resize &&
!GTK_CLIST_AUTO_RESIZE_BLOCKED (clist))
{
gint new_width;
-
+
new_width = clist->column[ctree->tree_column].width;
switch (old_style)
{
@@ -5422,7 +5421,7 @@ gtk_ctree_set_expander_style (GtkCTree *ctree,
new_width -= PM_SIZE + 1;
break;
}
-
+
switch (expander_style)
{
case GTK_CTREE_EXPANDER_NONE:
@@ -5435,10 +5434,10 @@ gtk_ctree_set_expander_style (GtkCTree *ctree,
new_width += PM_SIZE + 1;
break;
}
-
+
gtk_clist_set_column_width (clist, ctree->tree_column, new_width);
}
-
+
if (GTK_WIDGET_DRAWABLE (clist))
CLIST_REFRESH (clist);
}
@@ -5458,14 +5457,14 @@ tree_sort (GtkCTree *ctree,
GtkCTreeNode *cmp;
GtkCTreeNode *work;
GtkCList *clist;
-
+
clist = GTK_CLIST (ctree);
-
+
if (node)
list_start = GTK_CTREE_ROW (node)->children;
else
list_start = GTK_CTREE_NODE (clist->row_list);
-
+
while (list_start)
{
cmp = list_start;
@@ -5502,39 +5501,39 @@ gtk_ctree_sort_recursive (GtkCTree *ctree,
{
GtkCList *clist;
GtkCTreeNode *focus_node = NULL;
-
+
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
-
+
clist = GTK_CLIST (ctree);
-
+
gtk_clist_freeze (clist);
-
+
if (clist->selection_mode == GTK_SELECTION_EXTENDED)
{
- GTK_CLIST_CLASS_FW (clist)->resync_selection (clist, NULL);
+ GTK_CLIST_GET_CLASS (clist)->resync_selection (clist, NULL);
g_list_free (clist->undo_selection);
g_list_free (clist->undo_unselection);
clist->undo_selection = NULL;
clist->undo_unselection = NULL;
}
-
+
if (!node || (node && gtk_ctree_is_viewable (ctree, node)))
focus_node =
GTK_CTREE_NODE (g_list_nth (clist->row_list, clist->focus_row));
-
+
gtk_ctree_post_recursive (ctree, node, GTK_CTREE_FUNC (tree_sort), NULL);
-
+
if (!node)
tree_sort (ctree, NULL, NULL);
-
+
if (focus_node)
{
clist->focus_row = g_list_position (clist->row_list,(GList *)focus_node);
clist->undo_anchor = clist->focus_row;
}
-
+
gtk_clist_thaw (clist);
}
@@ -5550,36 +5549,36 @@ gtk_ctree_sort_node (GtkCTree *ctree,
{
GtkCList *clist;
GtkCTreeNode *focus_node = NULL;
-
+
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
-
+
clist = GTK_CLIST (ctree);
-
+
gtk_clist_freeze (clist);
-
+
if (clist->selection_mode == GTK_SELECTION_EXTENDED)
{
- GTK_CLIST_CLASS_FW (clist)->resync_selection (clist, NULL);
+ GTK_CLIST_GET_CLASS (clist)->resync_selection (clist, NULL);
g_list_free (clist->undo_selection);
g_list_free (clist->undo_unselection);
clist->undo_selection = NULL;
clist->undo_unselection = NULL;
}
-
+
if (!node || (node && gtk_ctree_is_viewable (ctree, node)))
focus_node = GTK_CTREE_NODE
(g_list_nth (clist->row_list, clist->focus_row));
-
+
tree_sort (ctree, node, NULL);
-
+
if (focus_node)
{
clist->focus_row = g_list_position (clist->row_list,(GList *)focus_node);
clist->undo_anchor = clist->focus_row;
}
-
+
gtk_clist_thaw (clist);
}
@@ -5591,7 +5590,7 @@ fake_unselect_all (GtkCList *clist,
{
GList *list;
GList *focus_node = NULL;
-
+
if (row >= 0 && (focus_node = g_list_nth (clist->row_list, row)))
{
if (GTK_CTREE_ROW (focus_node)->row.state == GTK_STATE_NORMAL &&
@@ -5601,11 +5600,11 @@ fake_unselect_all (GtkCList *clist,
if (CLIST_UNFROZEN (clist) &&
gtk_clist_row_is_visible (clist, row) != GTK_VISIBILITY_NONE)
- GTK_CLIST_CLASS_FW (clist)->draw_row (clist, NULL, row,
- GTK_CLIST_ROW (focus_node));
+ GTK_CLIST_GET_CLASS (clist)->draw_row (clist, NULL, row,
+ GTK_CLIST_ROW (focus_node));
}
}
-
+
clist->undo_selection = clist->selection;
clist->selection = NULL;
clist->selection_end = NULL;
@@ -5614,7 +5613,7 @@ fake_unselect_all (GtkCList *clist,
{
if (list->data == focus_node)
continue;
-
+
GTK_CTREE_ROW ((GList *)(list->data))->row.state = GTK_STATE_NORMAL;
tree_draw_node (GTK_CTREE (clist), GTK_CTREE_NODE (list->data));
}
@@ -5638,23 +5637,23 @@ resync_selection (GtkCList *clist, GdkEvent *event)
gint e;
gint row;
gboolean unselect;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CTREE (clist));
-
+
if (clist->selection_mode != GTK_SELECTION_EXTENDED)
return;
-
+
if (clist->anchor < 0 || clist->drag_pos < 0)
return;
-
+
ctree = GTK_CTREE (clist);
clist->freeze_count++;
-
+
i = MIN (clist->anchor, clist->drag_pos);
e = MAX (clist->anchor, clist->drag_pos);
-
+
if (clist->undo_selection)
{
list = clist->selection;
@@ -5662,14 +5661,14 @@ resync_selection (GtkCList *clist, GdkEvent *event)
clist->selection_end = g_list_last (clist->selection);
clist->undo_selection = list;
list = clist->selection;
-
+
while (list)
{
node = list->data;
list = list->next;
unselect = TRUE;
-
+
if (gtk_ctree_is_viewable (ctree, node))
{
row = g_list_position (clist->row_list, (GList *)node);
@@ -5685,7 +5684,7 @@ resync_selection (GtkCList *clist, GdkEvent *event)
}
}
}
-
+
if (clist->anchor < clist->drag_pos)
{
for (node = GTK_CTREE_NODE (g_list_nth (clist->row_list, i)); i <= e;
@@ -5734,14 +5733,14 @@ resync_selection (GtkCList *clist, GdkEvent *event)
}
}
}
-
+
clist->undo_unselection = g_list_reverse (clist->undo_unselection);
for (list = clist->undo_unselection; list; list = list->next)
gtk_ctree_select (ctree, list->data);
-
+
clist->anchor = -1;
clist->drag_pos = -1;
-
+
if (!CLIST_UNFROZEN (clist))
clist->freeze_count--;
}
@@ -5751,29 +5750,29 @@ real_undo_selection (GtkCList *clist)
{
GtkCTree *ctree;
GList *work;
-
+
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CTREE (clist));
-
+
if (clist->selection_mode != GTK_SELECTION_EXTENDED)
return;
-
+
if (!(clist->undo_selection || clist->undo_unselection))
{
gtk_clist_unselect_all (clist);
return;
}
-
+
ctree = GTK_CTREE (clist);
-
+
for (work = clist->undo_selection; work; work = work->next)
if (GTK_CTREE_ROW (work->data)->row.selectable)
gtk_ctree_select (ctree, GTK_CTREE_NODE (work->data));
-
+
for (work = clist->undo_unselection; work; work = work->next)
if (GTK_CTREE_ROW (work->data)->row.selectable)
gtk_ctree_unselect (ctree, GTK_CTREE_NODE (work->data));
-
+
if (GTK_WIDGET_HAS_FOCUS (clist) && clist->focus_row != clist->undo_anchor)
{
gtk_widget_draw_focus (GTK_WIDGET (clist));
@@ -5784,18 +5783,18 @@ real_undo_selection (GtkCList *clist)
clist->focus_row = clist->undo_anchor;
clist->undo_anchor = -1;
-
+
g_list_free (clist->undo_selection);
g_list_free (clist->undo_unselection);
clist->undo_selection = NULL;
clist->undo_unselection = NULL;
-
+
if (ROW_TOP_YPIXEL (clist, clist->focus_row) + clist->row_height >
clist->clist_window_height)
gtk_clist_moveto (clist, clist->focus_row, -1, 1, 0);
else if (ROW_TOP_YPIXEL (clist, clist->focus_row) < 0)
gtk_clist_moveto (clist, clist->focus_row, -1, 0, 0);
-
+
}
void
@@ -5804,7 +5803,7 @@ gtk_ctree_set_drag_compare_func (GtkCTree *ctree,
{
g_return_if_fail (ctree != NULL);
g_return_if_fail (GTK_IS_CTREE (ctree));
-
+
ctree->drag_compare = cmp_func;
}
@@ -5816,7 +5815,7 @@ check_drag (GtkCTree *ctree,
{
g_return_val_if_fail (ctree != NULL, FALSE);
g_return_val_if_fail (GTK_IS_CTREE (ctree), FALSE);
-
+
if (drag_source && drag_source != drag_target &&
(!GTK_CTREE_ROW (drag_source)->children ||
!gtk_ctree_is_ancestor (ctree, drag_source, drag_target)))
@@ -5862,7 +5861,7 @@ static void
drag_dest_info_destroy (gpointer data)
{
GtkCListDestInfo *info = data;
-
+
g_free (info);
}
@@ -5873,15 +5872,15 @@ drag_dest_cell (GtkCList *clist,
GtkCListDestInfo *dest_info)
{
GtkWidget *widget;
-
+
widget = GTK_WIDGET (clist);
-
+
dest_info->insert_pos = GTK_CLIST_DRAG_NONE;
-
+
y -= (GTK_CONTAINER (widget)->border_width +
widget->style->klass->ythickness + clist->column_title_area.height);
dest_info->cell.row = ROW_FROM_YPIXEL (clist, y);
-
+
if (dest_info->cell.row >= clist->rows)
{
dest_info->cell.row = clist->rows - 1;
@@ -5889,15 +5888,15 @@ drag_dest_cell (GtkCList *clist,
}
if (dest_info->cell.row < -1)
dest_info->cell.row = -1;
-
+
x -= GTK_CONTAINER (widget)->border_width + widget->style->klass->xthickness;
dest_info->cell.column = COLUMN_FROM_XPIXEL (clist, x);
-
+
if (dest_info->cell.row >= 0)
{
gint y_delta;
gint h = 0;
-
+
y_delta = y - ROW_TOP_YPIXEL (clist, dest_info->cell.row);
if (GTK_CLIST_DRAW_DRAG_RECT(clist) &&
@@ -5912,7 +5911,7 @@ drag_dest_cell (GtkCList *clist,
dest_info->insert_pos = GTK_CLIST_DRAG_BEFORE;
h = clist->row_height / 2;
}
-
+
if (GTK_CLIST_DRAW_DRAG_LINE(clist))
{
if (y_delta < h)
@@ -5930,22 +5929,22 @@ gtk_ctree_drag_begin (GtkWidget *widget,
GtkCList *clist;
GtkCTree *ctree;
gboolean use_icons;
-
+
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_CTREE (widget));
g_return_if_fail (context != NULL);
-
+
clist = GTK_CLIST (widget);
ctree = GTK_CTREE (widget);
-
+
use_icons = GTK_CLIST_USE_DRAG_ICONS (clist);
GTK_CLIST_UNSET_FLAG (clist, CLIST_USE_DRAG_ICONS);
GTK_WIDGET_CLASS (parent_class)->drag_begin (widget, context);
-
+
if (use_icons)
{
GtkCTreeNode *node;
-
+
GTK_CLIST_SET_FLAG (clist, CLIST_USE_DRAG_ICONS);
node = GTK_CTREE_NODE (g_list_nth (clist->row_list,
clist->click_cell.row));
@@ -5980,34 +5979,34 @@ gtk_ctree_drag_motion (GtkWidget *widget,
GtkCTree *ctree;
GtkCListDestInfo new_info;
GtkCListDestInfo *dest_info;
-
+
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_CTREE (widget), FALSE);
-
+
clist = GTK_CLIST (widget);
ctree = GTK_CTREE (widget);
-
+
dest_info = g_dataset_get_data (context, "gtk-clist-drag-dest");
-
+
if (!dest_info)
{
dest_info = g_new (GtkCListDestInfo, 1);
-
+
dest_info->cell.row = -1;
dest_info->cell.column = -1;
dest_info->insert_pos = GTK_CLIST_DRAG_NONE;
-
+
g_dataset_set_data_full (context, "gtk-clist-drag-dest", dest_info,
drag_dest_info_destroy);
}
-
+
drag_dest_cell (clist, x, y, &new_info);
-
+
if (GTK_CLIST_REORDERABLE (clist))
{
GList *list;
GdkAtom atom = gdk_atom_intern ("gtk-clist-drag-reorder", FALSE);
-
+
list = context->targets;
while (list)
{
@@ -6015,17 +6014,17 @@ gtk_ctree_drag_motion (GtkWidget *widget,
break;
list = list->next;
}
-
+
if (list)
{
GtkCTreeNode *drag_source;
GtkCTreeNode *drag_target;
-
+
drag_source = GTK_CTREE_NODE (g_list_nth (clist->row_list,
clist->click_cell.row));
drag_target = GTK_CTREE_NODE (g_list_nth (clist->row_list,
new_info.cell.row));
-
+
if (gtk_drag_get_source_widget (context) != widget ||
!check_drag (ctree, drag_source, drag_target,
new_info.insert_pos))
@@ -6037,32 +6036,32 @@ gtk_ctree_drag_motion (GtkWidget *widget,
}
return TRUE;
}
-
+
if (new_info.cell.row != dest_info->cell.row ||
(new_info.cell.row == dest_info->cell.row &&
dest_info->insert_pos != new_info.insert_pos))
{
if (dest_info->cell.row >= 0)
- GTK_CLIST_CLASS_FW (clist)->draw_drag_highlight
+ GTK_CLIST_GET_CLASS (clist)->draw_drag_highlight
(clist,
g_list_nth (clist->row_list, dest_info->cell.row)->data,
dest_info->cell.row, dest_info->insert_pos);
-
+
dest_info->insert_pos = new_info.insert_pos;
dest_info->cell.row = new_info.cell.row;
dest_info->cell.column = new_info.cell.column;
-
- GTK_CLIST_CLASS_FW (clist)->draw_drag_highlight
+
+ GTK_CLIST_GET_CLASS (clist)->draw_drag_highlight
(clist,
g_list_nth (clist->row_list, dest_info->cell.row)->data,
dest_info->cell.row, dest_info->insert_pos);
-
+
gdk_drag_status (context, context->suggested_action, time);
}
return TRUE;
}
}
-
+
dest_info->insert_pos = new_info.insert_pos;
dest_info->cell.row = new_info.cell.row;
dest_info->cell.column = new_info.cell.column;
@@ -6080,15 +6079,15 @@ gtk_ctree_drag_data_received (GtkWidget *widget,
{
GtkCTree *ctree;
GtkCList *clist;
-
+
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_CTREE (widget));
g_return_if_fail (context != NULL);
g_return_if_fail (selection_data != NULL);
-
+
ctree = GTK_CTREE (widget);
clist = GTK_CLIST (widget);
-
+
if (GTK_CLIST_REORDERABLE (clist) &&
gtk_drag_get_source_widget (context) == widget &&
selection_data->target ==
@@ -6097,24 +6096,24 @@ gtk_ctree_drag_data_received (GtkWidget *widget,
selection_data->length == sizeof (GtkCListCellInfo))
{
GtkCListCellInfo *source_info;
-
+
source_info = (GtkCListCellInfo *)(selection_data->data);
if (source_info)
{
GtkCListDestInfo dest_info;
GtkCTreeNode *source_node;
GtkCTreeNode *dest_node;
-
+
drag_dest_cell (clist, x, y, &dest_info);
source_node = GTK_CTREE_NODE (g_list_nth (clist->row_list,
source_info->row));
dest_node = GTK_CTREE_NODE (g_list_nth (clist->row_list,
dest_info.cell.row));
-
+
if (!source_node || !dest_node)
return;
-
+
switch (dest_info.insert_pos)
{
case GTK_CLIST_DRAG_NONE:
diff --git a/gtk/gtkcurve.c b/gtk/gtkcurve.c
index 2e19e0a900..f2622a3241 100644
--- a/gtk/gtkcurve.c
+++ b/gtk/gtkcurve.c
@@ -68,7 +68,7 @@ static void gtk_curve_set_arg (GtkObject *object,
static void gtk_curve_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
-static void gtk_curve_finalize (GtkObject *object);
+static void gtk_curve_finalize (GObject *object);
static gint gtk_curve_graph_events (GtkWidget *widget,
GdkEvent *event,
GtkCurve *c);
@@ -101,18 +101,18 @@ gtk_curve_get_type (void)
static void
gtk_curve_class_init (GtkCurveClass *class)
{
- GtkObjectClass *object_class;
+ GObjectClass *gobject_class = G_OBJECT_CLASS (class);
+ GtkObjectClass *object_class = GTK_OBJECT_CLASS (class);
parent_class = gtk_type_class (GTK_TYPE_DRAWING_AREA);
- object_class = (GtkObjectClass *) class;
-
+ gobject_class->finalize = gtk_curve_finalize;
+
object_class->set_arg = gtk_curve_set_arg;
object_class->get_arg = gtk_curve_get_arg;
- object_class->finalize = gtk_curve_finalize;
curve_type_changed_signal =
- gtk_signal_new ("curve_type_changed", GTK_RUN_FIRST, object_class->type,
+ gtk_signal_new ("curve_type_changed", GTK_RUN_FIRST, GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkCurveClass, curve_type_changed),
gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0);
gtk_object_class_add_signals (object_class, &curve_type_changed_signal, 1);
@@ -942,7 +942,7 @@ gtk_curve_new (void)
}
static void
-gtk_curve_finalize (GtkObject *object)
+gtk_curve_finalize (GObject *object)
{
GtkCurve *curve;
@@ -957,5 +957,5 @@ gtk_curve_finalize (GtkObject *object)
if (curve->ctlpoint)
g_free (curve->ctlpoint);
- (*GTK_OBJECT_CLASS (parent_class)->finalize) (object);
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
diff --git a/gtk/gtkdata.c b/gtk/gtkdata.c
index b285d42a4d..c2dcf6383b 100644
--- a/gtk/gtkdata.c
+++ b/gtk/gtkdata.c
@@ -75,7 +75,7 @@ gtk_data_class_init (GtkDataClass *class)
data_signals[DISCONNECT] =
gtk_signal_new ("disconnect",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkDataClass, disconnect),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
diff --git a/gtk/gtkeditable.c b/gtk/gtkeditable.c
index 04d64a50a6..87bfe85fb4 100644
--- a/gtk/gtkeditable.c
+++ b/gtk/gtkeditable.c
@@ -148,7 +148,7 @@ gtk_editable_class_init (GtkEditableClass *class)
editable_signals[CHANGED] =
gtk_signal_new ("changed",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkEditableClass, changed),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
@@ -156,7 +156,7 @@ gtk_editable_class_init (GtkEditableClass *class)
editable_signals[INSERT_TEXT] =
gtk_signal_new ("insert_text",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkEditableClass, insert_text),
gtk_marshal_NONE__POINTER_INT_POINTER,
GTK_TYPE_NONE,
@@ -168,7 +168,7 @@ gtk_editable_class_init (GtkEditableClass *class)
editable_signals[DELETE_TEXT] =
gtk_signal_new ("delete_text",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkEditableClass, delete_text),
gtk_marshal_NONE__INT_INT,
GTK_TYPE_NONE,
@@ -179,7 +179,7 @@ gtk_editable_class_init (GtkEditableClass *class)
editable_signals[ACTIVATE] =
gtk_signal_new ("activate",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkEditableClass, activate),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
@@ -188,7 +188,7 @@ gtk_editable_class_init (GtkEditableClass *class)
editable_signals[SET_EDITABLE] =
gtk_signal_new ("set-editable",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkEditableClass, set_editable),
gtk_marshal_NONE__BOOL,
GTK_TYPE_NONE, 1,
@@ -197,7 +197,7 @@ gtk_editable_class_init (GtkEditableClass *class)
editable_signals[MOVE_CURSOR] =
gtk_signal_new ("move_cursor",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkEditableClass, move_cursor),
gtk_marshal_NONE__INT_INT,
GTK_TYPE_NONE, 2,
@@ -207,7 +207,7 @@ gtk_editable_class_init (GtkEditableClass *class)
editable_signals[MOVE_WORD] =
gtk_signal_new ("move_word",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkEditableClass, move_word),
gtk_marshal_NONE__INT,
GTK_TYPE_NONE, 1,
@@ -216,7 +216,7 @@ gtk_editable_class_init (GtkEditableClass *class)
editable_signals[MOVE_PAGE] =
gtk_signal_new ("move_page",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkEditableClass, move_page),
gtk_marshal_NONE__INT_INT,
GTK_TYPE_NONE, 2,
@@ -226,7 +226,7 @@ gtk_editable_class_init (GtkEditableClass *class)
editable_signals[MOVE_TO_ROW] =
gtk_signal_new ("move_to_row",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkEditableClass, move_to_row),
gtk_marshal_NONE__INT,
GTK_TYPE_NONE, 1,
@@ -235,7 +235,7 @@ gtk_editable_class_init (GtkEditableClass *class)
editable_signals[MOVE_TO_COLUMN] =
gtk_signal_new ("move_to_column",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkEditableClass, move_to_column),
gtk_marshal_NONE__INT,
GTK_TYPE_NONE, 1,
@@ -244,7 +244,7 @@ gtk_editable_class_init (GtkEditableClass *class)
editable_signals[KILL_CHAR] =
gtk_signal_new ("kill_char",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkEditableClass, kill_char),
gtk_marshal_NONE__INT,
GTK_TYPE_NONE, 1,
@@ -253,7 +253,7 @@ gtk_editable_class_init (GtkEditableClass *class)
editable_signals[KILL_WORD] =
gtk_signal_new ("kill_word",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkEditableClass, kill_word),
gtk_marshal_NONE__INT,
GTK_TYPE_NONE, 1,
@@ -262,7 +262,7 @@ gtk_editable_class_init (GtkEditableClass *class)
editable_signals[KILL_LINE] =
gtk_signal_new ("kill_line",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkEditableClass, kill_line),
gtk_marshal_NONE__INT,
GTK_TYPE_NONE, 1,
@@ -271,7 +271,7 @@ gtk_editable_class_init (GtkEditableClass *class)
editable_signals[CUT_CLIPBOARD] =
gtk_signal_new ("cut_clipboard",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkEditableClass, cut_clipboard),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
@@ -279,7 +279,7 @@ gtk_editable_class_init (GtkEditableClass *class)
editable_signals[COPY_CLIPBOARD] =
gtk_signal_new ("copy_clipboard",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkEditableClass, copy_clipboard),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
@@ -287,7 +287,7 @@ gtk_editable_class_init (GtkEditableClass *class)
editable_signals[PASTE_CLIPBOARD] =
gtk_signal_new ("paste_clipboard",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkEditableClass, paste_clipboard),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
@@ -422,7 +422,7 @@ gtk_editable_insert_text (GtkEditable *editable,
gtk_widget_ref (GTK_WIDGET (editable));
- klass = GTK_EDITABLE_CLASS (GTK_OBJECT (editable)->klass);
+ klass = GTK_EDITABLE_GET_CLASS (editable);
if (new_text_length <= 64)
text = buf;
@@ -452,7 +452,7 @@ gtk_editable_delete_text (GtkEditable *editable,
gtk_widget_ref (GTK_WIDGET (editable));
- klass = GTK_EDITABLE_CLASS (GTK_OBJECT (editable)->klass);
+ klass = GTK_EDITABLE_GET_CLASS (editable);
gtk_signal_emit (GTK_OBJECT (editable), editable_signals[DELETE_TEXT], start_pos, end_pos);
gtk_signal_emit (GTK_OBJECT (editable), editable_signals[CHANGED]);
@@ -470,7 +470,7 @@ gtk_editable_update_text (GtkEditable *editable,
g_return_if_fail (editable != NULL);
g_return_if_fail (GTK_IS_EDITABLE (editable));
- klass = GTK_EDITABLE_CLASS (GTK_OBJECT (editable)->klass);
+ klass = GTK_EDITABLE_GET_CLASS (editable);
klass->update_text (editable, start_pos, end_pos);
}
@@ -485,7 +485,7 @@ gtk_editable_get_chars (GtkEditable *editable,
g_return_val_if_fail (editable != NULL, NULL);
g_return_val_if_fail (GTK_IS_EDITABLE (editable), NULL);
- klass = GTK_EDITABLE_CLASS (GTK_OBJECT (editable)->klass);
+ klass = GTK_EDITABLE_GET_CLASS (editable);
return klass->get_chars (editable, start, end);
}
@@ -529,7 +529,7 @@ gtk_editable_set_selection (GtkEditable *editable,
g_return_if_fail (editable != NULL);
g_return_if_fail (GTK_IS_EDITABLE (editable));
- klass = GTK_EDITABLE_CLASS (GTK_OBJECT (editable)->klass);
+ klass = GTK_EDITABLE_GET_CLASS (editable);
klass->set_selection (editable, start_pos, end_pos);
}
@@ -543,7 +543,7 @@ gtk_editable_set_position (GtkEditable *editable,
g_return_if_fail (editable != NULL);
g_return_if_fail (GTK_IS_EDITABLE (editable));
- klass = GTK_EDITABLE_CLASS (GTK_OBJECT (editable)->klass);
+ klass = GTK_EDITABLE_GET_CLASS (editable);
klass->set_position (editable, position);
}
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index 50db536b07..3f9eec91b2 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -55,7 +55,7 @@ static void gtk_entry_set_arg (GtkObject *object,
static void gtk_entry_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
-static void gtk_entry_finalize (GtkObject *object);
+static void gtk_entry_finalize (GObject *object);
static void gtk_entry_realize (GtkWidget *widget);
static void gtk_entry_unrealize (GtkWidget *widget);
static void gtk_entry_draw_focus (GtkWidget *widget);
@@ -249,6 +249,7 @@ gtk_entry_get_type (void)
static void
gtk_entry_class_init (GtkEntryClass *class)
{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (class);
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
GtkEditableClass *editable_class;
@@ -258,12 +259,13 @@ gtk_entry_class_init (GtkEntryClass *class)
editable_class = (GtkEditableClass*) class;
parent_class = gtk_type_class (GTK_TYPE_EDITABLE);
+ gobject_class->finalize = gtk_entry_finalize;
+
gtk_object_add_arg_type ("GtkEntry::max_length", GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_MAX_LENGTH);
gtk_object_add_arg_type ("GtkEntry::visibility", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_VISIBILITY);
object_class->set_arg = gtk_entry_set_arg;
object_class->get_arg = gtk_entry_get_arg;
- object_class->finalize = gtk_entry_finalize;
widget_class->realize = gtk_entry_realize;
widget_class->unrealize = gtk_entry_unrealize;
@@ -513,11 +515,10 @@ gtk_entry_get_text (GtkEntry *entry)
}
static void
-gtk_entry_finalize (GtkObject *object)
+gtk_entry_finalize (GObject *object)
{
GtkEntry *entry;
- g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_ENTRY (object));
entry = GTK_ENTRY (object);
@@ -540,7 +541,7 @@ gtk_entry_finalize (GtkObject *object)
if (entry->backing_pixmap)
gdk_pixmap_unref (entry->backing_pixmap);
- (* GTK_OBJECT_CLASS (parent_class)->finalize) (object);
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
diff --git a/gtk/gtkfilesel.c b/gtk/gtkfilesel.c
index 11d85c3f04..1a656256c3 100644
--- a/gtk/gtkfilesel.c
+++ b/gtk/gtkfilesel.c
@@ -673,10 +673,7 @@ gtk_file_selection_hide_fileop_buttons (GtkFileSelection *filesel)
g_return_if_fail (GTK_IS_FILE_SELECTION (filesel));
if (filesel->fileop_ren_file)
- {
- gtk_widget_destroy (filesel->fileop_ren_file);
- filesel->fileop_ren_file = NULL;
- }
+ gtk_widget_destroy (filesel->fileop_ren_file);
if (filesel->fileop_del_file)
{
@@ -770,14 +767,16 @@ gtk_file_selection_destroy (GtkObject *object)
GtkFileSelection *filesel;
GList *list;
HistoryCallbackArg *callback_arg;
-
- g_return_if_fail (object != NULL);
+
g_return_if_fail (GTK_IS_FILE_SELECTION (object));
-
+
filesel = GTK_FILE_SELECTION (object);
if (filesel->fileop_dialog)
- gtk_widget_destroy (filesel->fileop_dialog);
+ {
+ gtk_widget_destroy (filesel->fileop_dialog);
+ filesel->fileop_dialog = NULL;
+ }
if (filesel->history_list)
{
@@ -792,12 +791,14 @@ gtk_file_selection_destroy (GtkObject *object)
g_list_free (filesel->history_list);
filesel->history_list = NULL;
}
-
- cmpl_free_state (filesel->cmpl_state);
- filesel->cmpl_state = NULL;
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+ if (filesel->cmpl_state)
+ {
+ cmpl_free_state (filesel->cmpl_state);
+ filesel->cmpl_state = NULL;
+ }
+
+ GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
/* Begin file operations callbacks */
@@ -910,10 +911,11 @@ gtk_file_selection_create_dir (GtkWidget *widget, gpointer data)
g_return_if_fail (GTK_IS_FILE_SELECTION (fs));
if (fs->fileop_dialog)
- return;
+ return;
/* main dialog */
- fs->fileop_dialog = dialog = gtk_dialog_new ();
+ dialog = gtk_dialog_new ();
+ fs->fileop_dialog = dialog;
gtk_signal_connect (GTK_OBJECT (dialog), "destroy",
(GtkSignalFunc) gtk_file_selection_fileop_destroy,
(gpointer) fs);
@@ -1818,6 +1820,8 @@ cmpl_free_dir_sent_list(GList* dp0)
static void
cmpl_free_state (CompletionState* cmpl_state)
{
+ g_return_if_fail (cmpl_state != NULL);
+
cmpl_free_dir_list (cmpl_state->directory_storage);
cmpl_free_dir_sent_list (cmpl_state->directory_sent_storage);
diff --git a/gtk/gtkframe.c b/gtk/gtkframe.c
index dc3ca9788f..453519efaf 100644
--- a/gtk/gtkframe.c
+++ b/gtk/gtkframe.c
@@ -44,7 +44,7 @@ static void gtk_frame_set_arg (GtkObject *object,
static void gtk_frame_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
-static void gtk_frame_finalize (GtkObject *object);
+static void gtk_frame_finalize (GObject *object);
static void gtk_frame_paint (GtkWidget *widget,
GdkRectangle *area);
static void gtk_frame_draw (GtkWidget *widget,
@@ -90,6 +90,7 @@ gtk_frame_get_type (void)
static void
gtk_frame_class_init (GtkFrameClass *class)
{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (class);
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
@@ -98,6 +99,8 @@ gtk_frame_class_init (GtkFrameClass *class)
parent_class = gtk_type_class (gtk_bin_get_type ());
+ gobject_class->finalize = gtk_frame_finalize;
+
gtk_object_add_arg_type ("GtkFrame::label", GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_LABEL);
gtk_object_add_arg_type ("GtkFrame::label_xalign", GTK_TYPE_FLOAT, GTK_ARG_READWRITE, ARG_LABEL_XALIGN);
gtk_object_add_arg_type ("GtkFrame::label_yalign", GTK_TYPE_FLOAT, GTK_ARG_READWRITE, ARG_LABEL_YALIGN);
@@ -105,7 +108,6 @@ gtk_frame_class_init (GtkFrameClass *class)
object_class->set_arg = gtk_frame_set_arg;
object_class->get_arg = gtk_frame_get_arg;
- object_class->finalize = gtk_frame_finalize;
widget_class->draw = gtk_frame_draw;
widget_class->expose_event = gtk_frame_expose;
@@ -314,11 +316,10 @@ gtk_frame_set_shadow_type (GtkFrame *frame,
static void
-gtk_frame_finalize (GtkObject *object)
+gtk_frame_finalize (GObject *object)
{
GtkFrame *frame;
- g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_FRAME (object));
frame = GTK_FRAME (object);
@@ -326,7 +327,7 @@ gtk_frame_finalize (GtkObject *object)
if (frame->label)
g_free (frame->label);
- (* GTK_OBJECT_CLASS (parent_class)->finalize) (object);
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
diff --git a/gtk/gtkhandlebox.c b/gtk/gtkhandlebox.c
index e35ca99627..ef2d7ad0c2 100644
--- a/gtk/gtkhandlebox.c
+++ b/gtk/gtkhandlebox.c
@@ -181,7 +181,7 @@ gtk_handle_box_class_init (GtkHandleBoxClass *class)
handle_box_signals[SIGNAL_CHILD_ATTACHED] =
gtk_signal_new ("child_attached",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkHandleBoxClass, child_attached),
gtk_marshal_NONE__POINTER,
GTK_TYPE_NONE, 1,
@@ -189,7 +189,7 @@ gtk_handle_box_class_init (GtkHandleBoxClass *class)
handle_box_signals[SIGNAL_CHILD_DETACHED] =
gtk_signal_new ("child_detached",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkHandleBoxClass, child_detached),
gtk_marshal_NONE__POINTER,
GTK_TYPE_NONE, 1,
diff --git a/gtk/gtkhscale.c b/gtk/gtkhscale.c
index 51037cb579..94ba294b03 100644
--- a/gtk/gtkhscale.c
+++ b/gtk/gtkhscale.c
@@ -30,8 +30,8 @@
#include "gdk/gdkkeysyms.h"
-#define SCALE_CLASS(w) GTK_SCALE_CLASS (GTK_OBJECT (w)->klass)
-#define RANGE_CLASS(w) GTK_RANGE_CLASS (GTK_OBJECT (w)->klass)
+#define SCALE_CLASS(w) GTK_SCALE_GET_CLASS (w)
+#define RANGE_CLASS(w) GTK_RANGE_GET_CLASS (w)
enum {
ARG_0,
@@ -111,7 +111,7 @@ gtk_hscale_class_init (GtkHScaleClass *class)
gtk_object_add_arg_type ("GtkHScale::adjustment",
GTK_TYPE_ADJUSTMENT,
- GTK_ARG_READWRITE | GTK_ARG_CONSTRUCT,
+ GTK_ARG_READWRITE,
ARG_ADJUSTMENT);
object_class->set_arg = gtk_hscale_set_arg;
diff --git a/gtk/gtkhscrollbar.c b/gtk/gtkhscrollbar.c
index 9ab5fa875d..e506ff0ae7 100644
--- a/gtk/gtkhscrollbar.c
+++ b/gtk/gtkhscrollbar.c
@@ -31,7 +31,7 @@
#define EPSILON 0.01
-#define RANGE_CLASS(w) GTK_RANGE_CLASS (GTK_OBJECT (w)->klass)
+#define RANGE_CLASS(w) GTK_RANGE_GET_CLASS (w)
enum {
ARG_0,
@@ -97,7 +97,7 @@ gtk_hscrollbar_class_init (GtkHScrollbarClass *class)
gtk_object_add_arg_type ("GtkHScrollbar::adjustment",
GTK_TYPE_ADJUSTMENT,
- GTK_ARG_READWRITE | GTK_ARG_CONSTRUCT,
+ GTK_ARG_READWRITE,
ARG_ADJUSTMENT);
object_class->set_arg = gtk_hscrollbar_set_arg;
diff --git a/gtk/gtkhsv.c b/gtk/gtkhsv.c
index 568a140892..8ca57b66f7 100644
--- a/gtk/gtkhsv.c
+++ b/gtk/gtkhsv.c
@@ -26,7 +26,12 @@
#include "gtksignal.h"
#include "gtkhsv.h"
-
+/*
+ * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
+ * file for a list of people on the GTK+ Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
/* Default width/height */
#define DEFAULT_SIZE 100
@@ -34,34 +39,33 @@
/* Default ring width */
#define DEFAULT_RING_WIDTH 10
-
/* Dragging modes */
typedef enum {
- DRAG_NONE,
- DRAG_H,
- DRAG_SV
+ DRAG_NONE,
+ DRAG_H,
+ DRAG_SV
} DragMode;
/* Private part of the GtkHSV structure */
typedef struct {
- /* Color value */
- double h;
- double s;
- double v;
-
- /* Size and ring width */
- int size;
- int ring_width;
-
- /* Window for capturing events */
- GdkWindow *window;
-
- /* GC for drawing */
- GdkGC *gc;
-
- /* Dragging mode */
- DragMode mode;
+ /* Color value */
+ double h;
+ double s;
+ double v;
+
+ /* Size and ring width */
+ int size;
+ int ring_width;
+
+ /* Window for capturing events */
+ GdkWindow *window;
+
+ /* GC for drawing */
+ GdkGC *gc;
+
+ /* Dragging mode */
+ DragMode mode;
} HSVPrivate;
@@ -69,30 +73,33 @@ typedef struct {
/* Signal IDs */
enum {
- CHANGED,
- LAST_SIGNAL
+ CHANGED,
+ LAST_SIGNAL
};
-static void gtk_hsv_class_init (GtkHSVClass *class);
-static void gtk_hsv_init (GtkHSV *hsv);
-static void gtk_hsv_destroy (GtkObject *object);
-
-static void gtk_hsv_map (GtkWidget *widget);
-static void gtk_hsv_unmap (GtkWidget *widget);
-static void gtk_hsv_realize (GtkWidget *widget);
-static void gtk_hsv_unrealize (GtkWidget *widget);
-static void gtk_hsv_size_request (GtkWidget *widget, GtkRequisition *requisition);
-static void gtk_hsv_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
-static gint gtk_hsv_button_press (GtkWidget *widget, GdkEventButton *event);
-static gint gtk_hsv_button_release (GtkWidget *widget, GdkEventButton *event);
-static gint gtk_hsv_motion (GtkWidget *widget, GdkEventMotion *event);
-static gint gtk_hsv_expose (GtkWidget *widget, GdkEventExpose *event);
+static void gtk_hsv_class_init (GtkHSVClass *class);
+static void gtk_hsv_init (GtkHSV *hsv);
+static void gtk_hsv_destroy (GtkObject *object);
+static void gtk_hsv_map (GtkWidget *widget);
+static void gtk_hsv_unmap (GtkWidget *widget);
+static void gtk_hsv_realize (GtkWidget *widget);
+static void gtk_hsv_unrealize (GtkWidget *widget);
+static void gtk_hsv_size_request (GtkWidget *widget,
+ GtkRequisition *requisition);
+static void gtk_hsv_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation);
+static gint gtk_hsv_button_press (GtkWidget *widget,
+ GdkEventButton *event);
+static gint gtk_hsv_button_release (GtkWidget *widget,
+ GdkEventButton *event);
+static gint gtk_hsv_motion (GtkWidget *widget,
+ GdkEventMotion *event);
+static gint gtk_hsv_expose (GtkWidget *widget,
+ GdkEventExpose *event);
static guint hsv_signals[LAST_SIGNAL];
-
static GtkWidgetClass *parent_class;
-
/**
* gtk_hsv_get_type:
@@ -106,241 +113,239 @@ static GtkWidgetClass *parent_class;
GtkType
gtk_hsv_get_type (void)
{
- static GtkType hsv_type = 0;
-
- if (!hsv_type) {
- static const GtkTypeInfo hsv_info = {
- "GtkHSV",
- sizeof (GtkHSV),
- sizeof (GtkHSVClass),
- (GtkClassInitFunc) gtk_hsv_class_init,
- (GtkObjectInitFunc) gtk_hsv_init,
- NULL, /* reserved_1 */
- NULL, /* reserved_2 */
- (GtkClassInitFunc) NULL
- };
-
- hsv_type = gtk_type_unique (gtk_widget_get_type (), &hsv_info);
- }
-
- return hsv_type;
+ static GtkType hsv_type = 0;
+
+ if (!hsv_type) {
+ static const GtkTypeInfo hsv_info = {
+ "GtkHSV",
+ sizeof (GtkHSV),
+ sizeof (GtkHSVClass),
+ (GtkClassInitFunc) gtk_hsv_class_init,
+ (GtkObjectInitFunc) gtk_hsv_init,
+ NULL, /* reserved_1 */
+ NULL, /* reserved_2 */
+ (GtkClassInitFunc) NULL
+ };
+
+ hsv_type = gtk_type_unique (GTK_TYPE_WIDGET, &hsv_info);
+ }
+
+ return hsv_type;
}
/* Class initialization function for the HSV color selector */
static void
gtk_hsv_class_init (GtkHSVClass *class)
{
- GtkObjectClass *object_class;
- GtkWidgetClass *widget_class;
-
- object_class = (GtkObjectClass *) class;
- widget_class = (GtkWidgetClass *) class;
-
- parent_class = gtk_type_class (gtk_widget_get_type ());
-
- hsv_signals[CHANGED] =
- gtk_signal_new ("changed",
- GTK_RUN_FIRST,
- object_class->type,
- GTK_SIGNAL_OFFSET (GtkHSVClass, changed),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
-
- gtk_object_class_add_signals (object_class, hsv_signals, LAST_SIGNAL);
-
- object_class->destroy = gtk_hsv_destroy;
-
- widget_class->map = gtk_hsv_map;
- widget_class->unmap = gtk_hsv_unmap;
- widget_class->realize = gtk_hsv_realize;
- widget_class->unrealize = gtk_hsv_unrealize;
- widget_class->size_request = gtk_hsv_size_request;
- widget_class->size_allocate = gtk_hsv_size_allocate;
- widget_class->button_press_event = gtk_hsv_button_press;
- widget_class->button_release_event = gtk_hsv_button_release;
- widget_class->motion_notify_event = gtk_hsv_motion;
- widget_class->expose_event = gtk_hsv_expose;
+ GtkObjectClass *object_class;
+ GtkWidgetClass *widget_class;
+
+ object_class = (GtkObjectClass *) class;
+ widget_class = (GtkWidgetClass *) class;
+
+ parent_class = gtk_type_class (GTK_TYPE_WIDGET);
+
+ hsv_signals[CHANGED] =
+ gtk_signal_new ("changed",
+ GTK_RUN_FIRST,
+ GTK_CLASS_TYPE (object_class),
+ GTK_SIGNAL_OFFSET (GtkHSVClass, changed),
+ gtk_marshal_NONE__NONE,
+ GTK_TYPE_NONE, 0);
+ gtk_object_class_add_signals (object_class, hsv_signals, LAST_SIGNAL);
+
+ object_class->destroy = gtk_hsv_destroy;
+
+ widget_class->map = gtk_hsv_map;
+ widget_class->unmap = gtk_hsv_unmap;
+ widget_class->realize = gtk_hsv_realize;
+ widget_class->unrealize = gtk_hsv_unrealize;
+ widget_class->size_request = gtk_hsv_size_request;
+ widget_class->size_allocate = gtk_hsv_size_allocate;
+ widget_class->button_press_event = gtk_hsv_button_press;
+ widget_class->button_release_event = gtk_hsv_button_release;
+ widget_class->motion_notify_event = gtk_hsv_motion;
+ widget_class->expose_event = gtk_hsv_expose;
}
/* Object initialization function for the HSV color selector */
static void
gtk_hsv_init (GtkHSV *hsv)
{
- HSVPrivate *priv;
-
- priv = g_new0 (HSVPrivate, 1);
- hsv->priv = priv;
-
- GTK_WIDGET_SET_FLAGS (hsv, GTK_NO_WINDOW);
-
- priv->h = 0.0;
- priv->s = 0.0;
- priv->v = 0.0;
-
- priv->size = DEFAULT_SIZE;
- priv->ring_width = DEFAULT_RING_WIDTH;
+ HSVPrivate *priv;
+
+ priv = g_new0 (HSVPrivate, 1);
+ hsv->priv = priv;
+
+ GTK_WIDGET_SET_FLAGS (hsv, GTK_NO_WINDOW);
+
+ priv->h = 0.0;
+ priv->s = 0.0;
+ priv->v = 0.0;
+
+ priv->size = DEFAULT_SIZE;
+ priv->ring_width = DEFAULT_RING_WIDTH;
}
/* Destroy handler for the HSV color selector */
static void
gtk_hsv_destroy (GtkObject *object)
{
- GtkHSV *hsv;
- HSVPrivate *priv;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (GTK_IS_HSV (object));
-
- hsv = GTK_HSV (object);
- priv = hsv->priv;
-
- g_free (priv);
-
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+ GtkHSV *hsv;
+
+ g_return_if_fail (GTK_IS_HSV (object));
+
+ hsv = GTK_HSV (object);
+
+ if (hsv->priv)
+ {
+ g_free (hsv->priv);
+ hsv->priv = NULL;
+ }
+
+ GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
-
-
/* Default signal handlers */
/* Map handler for the HSV color selector */
static void
gtk_hsv_map (GtkWidget *widget)
{
- GtkHSV *hsv;
- HSVPrivate *priv;
-
- hsv = GTK_HSV (widget);
- priv = hsv->priv;
-
- if (GTK_WIDGET_MAPPED (widget))
- return;
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
-
- gdk_window_show (priv->window);
+ GtkHSV *hsv;
+ HSVPrivate *priv;
+
+ hsv = GTK_HSV (widget);
+ priv = hsv->priv;
+
+ if (GTK_WIDGET_MAPPED (widget))
+ return;
+
+ GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
+
+ gdk_window_show (priv->window);
}
/* Unmap handler for the HSV color selector */
static void
gtk_hsv_unmap (GtkWidget *widget)
{
- GtkHSV *hsv;
- HSVPrivate *priv;
-
- hsv = GTK_HSV (widget);
- priv = hsv->priv;
-
- if (!GTK_WIDGET_MAPPED (widget))
- return;
-
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
-
- gdk_window_hide (priv->window);
+ GtkHSV *hsv;
+ HSVPrivate *priv;
+
+ hsv = GTK_HSV (widget);
+ priv = hsv->priv;
+
+ if (!GTK_WIDGET_MAPPED (widget))
+ return;
+
+ GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
+
+ gdk_window_hide (priv->window);
}
/* Realize handler for the HSV color selector */
static void
gtk_hsv_realize (GtkWidget *widget)
{
- GtkHSV *hsv;
- HSVPrivate *priv;
- GdkWindowAttr attr;
- int attr_mask;
- GdkWindow *parent_window;
-
- hsv = GTK_HSV (widget);
- priv = hsv->priv;
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
-
- /* Create window */
-
- attr.window_type = GDK_WINDOW_CHILD;
- attr.x = widget->allocation.x;
- attr.y = widget->allocation.y;
- attr.width = widget->allocation.width;
- attr.height = widget->allocation.height;
- attr.wclass = GDK_INPUT_ONLY;
- attr.event_mask = gtk_widget_get_events (widget);
- attr.event_mask |= (GDK_BUTTON_PRESS_MASK
- | GDK_BUTTON_RELEASE_MASK
- | GDK_POINTER_MOTION_MASK);
-
- attr_mask = GDK_WA_X | GDK_WA_Y;
-
- parent_window = gtk_widget_get_parent_window (widget);
-
- widget->window = parent_window;
- gdk_window_ref (widget->window);
-
- priv->window = gdk_window_new (parent_window, &attr, attr_mask);
- gdk_window_set_user_data (priv->window, hsv);
-
- widget->style = gtk_style_attach (widget->style, widget->window);
-
- /* Create GC */
-
- priv->gc = gdk_gc_new (parent_window);
+ GtkHSV *hsv;
+ HSVPrivate *priv;
+ GdkWindowAttr attr;
+ int attr_mask;
+ GdkWindow *parent_window;
+
+ hsv = GTK_HSV (widget);
+ priv = hsv->priv;
+
+ GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
+
+ /* Create window */
+
+ attr.window_type = GDK_WINDOW_CHILD;
+ attr.x = widget->allocation.x;
+ attr.y = widget->allocation.y;
+ attr.width = widget->allocation.width;
+ attr.height = widget->allocation.height;
+ attr.wclass = GDK_INPUT_ONLY;
+ attr.event_mask = gtk_widget_get_events (widget);
+ attr.event_mask |= (GDK_BUTTON_PRESS_MASK
+ | GDK_BUTTON_RELEASE_MASK
+ | GDK_POINTER_MOTION_MASK);
+
+ attr_mask = GDK_WA_X | GDK_WA_Y;
+
+ parent_window = gtk_widget_get_parent_window (widget);
+
+ widget->window = parent_window;
+ gdk_window_ref (widget->window);
+
+ priv->window = gdk_window_new (parent_window, &attr, attr_mask);
+ gdk_window_set_user_data (priv->window, hsv);
+
+ widget->style = gtk_style_attach (widget->style, widget->window);
+
+ /* Create GC */
+
+ priv->gc = gdk_gc_new (parent_window);
}
/* Unrealize handler for the HSV color selector */
static void
gtk_hsv_unrealize (GtkWidget *widget)
{
- GtkHSV *hsv;
- HSVPrivate *priv;
-
- hsv = GTK_HSV (widget);
- priv = hsv->priv;
-
- gdk_window_set_user_data (priv->window, NULL);
- gdk_window_destroy (priv->window);
- priv->window = NULL;
-
- gdk_gc_unref (priv->gc);
- priv->gc = NULL;
-
- if (GTK_WIDGET_CLASS (parent_class)->unrealize)
- (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
+ GtkHSV *hsv;
+ HSVPrivate *priv;
+
+ hsv = GTK_HSV (widget);
+ priv = hsv->priv;
+
+ gdk_window_set_user_data (priv->window, NULL);
+ gdk_window_destroy (priv->window);
+ priv->window = NULL;
+
+ gdk_gc_unref (priv->gc);
+ priv->gc = NULL;
+
+ if (GTK_WIDGET_CLASS (parent_class)->unrealize)
+ GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
}
/* Size_request handler for the HSV color selector */
static void
-gtk_hsv_size_request (GtkWidget *widget, GtkRequisition *requisition)
+gtk_hsv_size_request (GtkWidget *widget,
+ GtkRequisition *requisition)
{
- GtkHSV *hsv;
- HSVPrivate *priv;
-
- hsv = GTK_HSV (widget);
- priv = hsv->priv;
-
- requisition->width = priv->size;
- requisition->height = priv->size;
+ GtkHSV *hsv;
+ HSVPrivate *priv;
+
+ hsv = GTK_HSV (widget);
+ priv = hsv->priv;
+
+ requisition->width = priv->size;
+ requisition->height = priv->size;
}
/* Size_allocate handler for the HSV color selector */
static void
-gtk_hsv_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
+gtk_hsv_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation)
{
- GtkHSV *hsv;
- HSVPrivate *priv;
-
- hsv = GTK_HSV (widget);
- priv = hsv->priv;
-
- widget->allocation = *allocation;
-
- if (GTK_WIDGET_REALIZED (widget))
- gdk_window_move_resize (priv->window,
- allocation->x,
- allocation->y,
- allocation->width,
- allocation->height);
+ GtkHSV *hsv;
+ HSVPrivate *priv;
+
+ hsv = GTK_HSV (widget);
+ priv = hsv->priv;
+
+ widget->allocation = *allocation;
+
+ if (GTK_WIDGET_REALIZED (widget))
+ gdk_window_move_resize (priv->window,
+ allocation->x,
+ allocation->y,
+ allocation->width,
+ allocation->height);
}
-
/* Utility functions */
@@ -348,588 +353,647 @@ gtk_hsv_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
/* Converts from HSV to RGB */
static void
-hsv_to_rgb (double *h, double *s, double *v)
+hsv_to_rgb (gdouble *h,
+ gdouble *s,
+ gdouble *v)
{
- double hue, saturation, value;
- double f, p, q, t;
-
- if (*s == 0.0) {
- *h = *v;
- *s = *v;
- *v = *v; /* heh */
- } else {
- hue = *h * 6.0;
- saturation = *s;
- value = *v;
-
- if (hue == 6.0)
- hue = 0.0;
-
- f = hue - (int) hue;
- p = value * (1.0 - saturation);
- q = value * (1.0 - saturation * f);
- t = value * (1.0 - saturation * (1.0 - f));
-
- switch ((int) hue) {
- case 0:
- *h = value;
- *s = t;
- *v = p;
- break;
-
- case 1:
- *h = q;
- *s = value;
- *v = p;
- break;
-
- case 2:
- *h = p;
- *s = value;
- *v = t;
- break;
-
- case 3:
- *h = p;
- *s = q;
- *v = value;
- break;
-
- case 4:
- *h = t;
- *s = p;
- *v = value;
- break;
-
- case 5:
- *h = value;
- *s = p;
- *v = q;
- break;
-
- default:
- g_assert_not_reached ();
- }
+ gdouble hue, saturation, value;
+ gdouble f, p, q, t;
+
+ if (*s == 0.0)
+ {
+ *h = *v;
+ *s = *v;
+ *v = *v; /* heh */
+ }
+ else
+ {
+ hue = *h * 6.0;
+ saturation = *s;
+ value = *v;
+
+ if (hue == 6.0)
+ hue = 0.0;
+
+ f = hue - (int) hue;
+ p = value * (1.0 - saturation);
+ q = value * (1.0 - saturation * f);
+ t = value * (1.0 - saturation * (1.0 - f));
+
+ switch ((int) hue)
+ {
+ case 0:
+ *h = value;
+ *s = t;
+ *v = p;
+ break;
+
+ case 1:
+ *h = q;
+ *s = value;
+ *v = p;
+ break;
+
+ case 2:
+ *h = p;
+ *s = value;
+ *v = t;
+ break;
+
+ case 3:
+ *h = p;
+ *s = q;
+ *v = value;
+ break;
+
+ case 4:
+ *h = t;
+ *s = p;
+ *v = value;
+ break;
+
+ case 5:
+ *h = value;
+ *s = p;
+ *v = q;
+ break;
+
+ default:
+ g_assert_not_reached ();
}
+ }
}
/* Converts from RGB to HSV */
static void
-rgb_to_hsv (double *r, double *g, double *b)
+rgb_to_hsv (gdouble *r,
+ gdouble *g,
+ gdouble *b)
{
- double red, green, blue;
- double h, s, v;
- double min, max;
- double delta;
-
- red = *r;
- green = *g;
- blue = *b;
-
- h = 0.0;
-
- if (red > green) {
- if (red > blue)
- max = red;
- else
- max = blue;
-
- if (green < blue)
- min = green;
- else
- min = blue;
- } else {
- if (green > blue)
- max = green;
- else
- max = blue;
-
- if (red < blue)
- min = red;
- else
- min = blue;
- }
-
- v = max;
-
- if (max != 0.0)
- s = (max - min) / max;
- else
- s = 0.0;
-
- if (s == 0.0)
- h = 0.0;
- else {
- delta = max - min;
-
- if (red == max)
- h = (green - blue) / delta;
- else if (green == max)
- h = 2 + (blue - red) / delta;
- else if (blue == max)
- h = 4 + (red - green) / delta;
-
- h /= 6.0;
-
- if (h < 0.0)
- h += 1.0;
- else if (h > 1.0)
- h -= 1.0;
- }
-
- *r = h;
- *g = s;
- *b = v;
+ gdouble red, green, blue;
+ gdouble h, s, v;
+ gdouble min, max;
+ gdouble delta;
+
+ red = *r;
+ green = *g;
+ blue = *b;
+
+ h = 0.0;
+
+ if (red > green)
+ {
+ if (red > blue)
+ max = red;
+ else
+ max = blue;
+
+ if (green < blue)
+ min = green;
+ else
+ min = blue;
+ }
+ else
+ {
+ if (green > blue)
+ max = green;
+ else
+ max = blue;
+
+ if (red < blue)
+ min = red;
+ else
+ min = blue;
+ }
+
+ v = max;
+
+ if (max != 0.0)
+ s = (max - min) / max;
+ else
+ s = 0.0;
+
+ if (s == 0.0)
+ h = 0.0;
+ else
+ {
+ delta = max - min;
+
+ if (red == max)
+ h = (green - blue) / delta;
+ else if (green == max)
+ h = 2 + (blue - red) / delta;
+ else if (blue == max)
+ h = 4 + (red - green) / delta;
+
+ h /= 6.0;
+
+ if (h < 0.0)
+ h += 1.0;
+ else if (h > 1.0)
+ h -= 1.0;
+ }
+
+ *r = h;
+ *g = s;
+ *b = v;
}
/* Computes the vertices of the saturation/value triangle */
static void
-compute_triangle (GtkHSV *hsv, int *hx, int *hy, int *sx, int *sy, int *vx, int *vy)
+compute_triangle (GtkHSV *hsv,
+ gint *hx,
+ gint *hy,
+ gint *sx,
+ gint *sy,
+ gint *vx,
+ gint *vy)
{
- HSVPrivate *priv;
- double center;
- double inner, outer;
- double angle;
-
- priv = hsv->priv;
-
- center = priv->size / 2.0;
- outer = priv->size / 2.0;
- inner = outer - priv->ring_width;
- angle = priv->h * 2.0 * M_PI;
-
- *hx = floor (center + cos (angle) * inner + 0.5);
- *hy = floor (center - sin (angle) * inner + 0.5);
- *sx = floor (center + cos (angle + 2.0 * M_PI / 3.0) * inner + 0.5);
- *sy = floor (center - sin (angle + 2.0 * M_PI / 3.0) * inner + 0.5);
- *vx = floor (center + cos (angle + 4.0 * M_PI / 3.0) * inner + 0.5);
- *vy = floor (center - sin (angle + 4.0 * M_PI / 3.0) * inner + 0.5);
+ HSVPrivate *priv;
+ gdouble center;
+ gdouble inner, outer;
+ gdouble angle;
+
+ priv = hsv->priv;
+
+ center = priv->size / 2.0;
+ outer = priv->size / 2.0;
+ inner = outer - priv->ring_width;
+ angle = priv->h * 2.0 * M_PI;
+
+ *hx = floor (center + cos (angle) * inner + 0.5);
+ *hy = floor (center - sin (angle) * inner + 0.5);
+ *sx = floor (center + cos (angle + 2.0 * M_PI / 3.0) * inner + 0.5);
+ *sy = floor (center - sin (angle + 2.0 * M_PI / 3.0) * inner + 0.5);
+ *vx = floor (center + cos (angle + 4.0 * M_PI / 3.0) * inner + 0.5);
+ *vy = floor (center - sin (angle + 4.0 * M_PI / 3.0) * inner + 0.5);
}
/* Computes whether a point is inside the hue ring */
static gboolean
-is_in_ring (GtkHSV *hsv, double x, double y)
+is_in_ring (GtkHSV *hsv,
+ gdouble x,
+ gdouble y)
{
- HSVPrivate *priv;
- double dx, dy, dist;
- double center, inner, outer;
-
- priv = hsv->priv;
-
- center = priv->size / 2.0;
- outer = priv->size / 2.0;
- inner = outer - priv->ring_width;
-
- dx = x - center;
- dy = center - y;
- dist = dx * dx + dy * dy;
-
- return (dist >= inner * inner && dist <= outer * outer);
+ HSVPrivate *priv;
+ gdouble dx, dy, dist;
+ gdouble center, inner, outer;
+
+ priv = hsv->priv;
+
+ center = priv->size / 2.0;
+ outer = priv->size / 2.0;
+ inner = outer - priv->ring_width;
+
+ dx = x - center;
+ dy = center - y;
+ dist = dx * dx + dy * dy;
+
+ return (dist >= inner * inner && dist <= outer * outer);
}
/* Computes a saturation/value pair based on the mouse coordinates */
static void
-compute_sv (GtkHSV *hsv, double x, double y, double *s, double *v)
+compute_sv (GtkHSV *hsv,
+ gdouble x,
+ gdouble y,
+ gdouble *s,
+ gdouble *v)
{
- HSVPrivate *priv;
- int ihx, ihy, isx, isy, ivx, ivy;
- double hx, hy, sx, sy, vx, vy;
- double center;
-
- priv = hsv->priv;
-
- compute_triangle (hsv, &ihx, &ihy, &isx, &isy, &ivx, &ivy);
- center = priv->size / 2.0;
- hx = ihx - center;
- hy = center - ihy;
- sx = isx - center;
- sy = center - isy;
- vx = ivx - center;
- vy = center - ivy;
- x -= center;
- y = center - y;
-
- if (vx * (x - sx) + vy * (y - sy) < 0.0) {
- *s = 1.0;
- *v = (((x - sx) * (hx - sx) + (y - sy) * (hy-sy))
- / ((hx - sx) * (hx - sx) + (hy - sy) * (hy - sy)));
-
- if (*v < 0.0)
- *v = 0.0;
- else if (*v > 1.0)
- *v = 1.0;
- } else if (hx * (x - sx) + hy * (y - sy) < 0.0) {
- *s = 0.0;
- *v = (((x - sx) * (vx - sx) + (y - sy) * (vy - sy))
- / ((vx - sx) * (vx - sx) + (vy - sy) * (vy - sy)));
-
- if (*v < 0.0)
- *v = 0.0;
- else if (*v > 1.0)
- *v = 1.0;
- } else if (sx * (x - hx) + sy * (y - hy) < 0.0) {
- *v = 1.0;
- *s = (((x - vx) * (hx - vx) + (y - vy) * (hy - vy)) /
- ((hx - vx) * (hx - vx) + (hy - vy) * (hy - vy)));
-
- if (*s < 0.0)
- *s = 0.0;
- else if (*s > 1.0)
- *s = 1.0;
- } else {
- *v = (((x - sx) * (hy - vy) - (y - sy) * (hx - vx))
- / ((vx - sx) * (hy - vy) - (vy - sy) * (hx - vx)));
-
- if (*v<= 0.0) {
- *v = 0.0;
- *s = 0.0;
- } else {
- if (*v > 1.0)
- *v = 1.0;
-
- *s = (y - sy - *v * (vy - sy)) / (*v * (hy - vy));
- if (*s < 0.0)
- *s = 0.0;
- else if (*s > 1.0)
- *s = 1.0;
- }
+ HSVPrivate *priv;
+ int ihx, ihy, isx, isy, ivx, ivy;
+ double hx, hy, sx, sy, vx, vy;
+ double center;
+
+ priv = hsv->priv;
+
+ compute_triangle (hsv, &ihx, &ihy, &isx, &isy, &ivx, &ivy);
+ center = priv->size / 2.0;
+ hx = ihx - center;
+ hy = center - ihy;
+ sx = isx - center;
+ sy = center - isy;
+ vx = ivx - center;
+ vy = center - ivy;
+ x -= center;
+ y = center - y;
+
+ if (vx * (x - sx) + vy * (y - sy) < 0.0)
+ {
+ *s = 1.0;
+ *v = (((x - sx) * (hx - sx) + (y - sy) * (hy-sy))
+ / ((hx - sx) * (hx - sx) + (hy - sy) * (hy - sy)));
+
+ if (*v < 0.0)
+ *v = 0.0;
+ else if (*v > 1.0)
+ *v = 1.0;
+ }
+ else if (hx * (x - sx) + hy * (y - sy) < 0.0)
+ {
+ *s = 0.0;
+ *v = (((x - sx) * (vx - sx) + (y - sy) * (vy - sy))
+ / ((vx - sx) * (vx - sx) + (vy - sy) * (vy - sy)));
+
+ if (*v < 0.0)
+ *v = 0.0;
+ else if (*v > 1.0)
+ *v = 1.0;
+ }
+ else if (sx * (x - hx) + sy * (y - hy) < 0.0)
+ {
+ *v = 1.0;
+ *s = (((x - vx) * (hx - vx) + (y - vy) * (hy - vy)) /
+ ((hx - vx) * (hx - vx) + (hy - vy) * (hy - vy)));
+
+ if (*s < 0.0)
+ *s = 0.0;
+ else if (*s > 1.0)
+ *s = 1.0;
+ }
+ else
+ {
+ *v = (((x - sx) * (hy - vy) - (y - sy) * (hx - vx))
+ / ((vx - sx) * (hy - vy) - (vy - sy) * (hx - vx)));
+
+ if (*v<= 0.0)
+ {
+ *v = 0.0;
+ *s = 0.0;
+ }
+ else
+ {
+ if (*v > 1.0)
+ *v = 1.0;
+
+ *s = (y - sy - *v * (vy - sy)) / (*v * (hy - vy));
+ if (*s < 0.0)
+ *s = 0.0;
+ else if (*s > 1.0)
+ *s = 1.0;
}
+ }
}
/* Computes whether a point is inside the saturation/value triangle */
static gboolean
-is_in_triangle (GtkHSV *hsv, double x, double y)
+is_in_triangle (GtkHSV *hsv,
+ gdouble x,
+ gdouble y)
{
- int hx, hy, sx, sy, vx, vy;
- double det, s, v;
-
- compute_triangle (hsv, &hx, &hy, &sx, &sy, &vx, &vy);
-
- det = (vx - sx) * (hy - sy) - (vy - sy) * (hx - sx);
-
- s = ((x - sx) * (hy - sy) - (y - sy) * (hx - sx)) / det;
- v = ((vx - sx) * (y - sy) - (vy - sy) * (x - sx)) / det;
-
- return (s >= 0.0 && v >= 0.0 && s + v <= 1.0);
+ int hx, hy, sx, sy, vx, vy;
+ double det, s, v;
+
+ compute_triangle (hsv, &hx, &hy, &sx, &sy, &vx, &vy);
+
+ det = (vx - sx) * (hy - sy) - (vy - sy) * (hx - sx);
+
+ s = ((x - sx) * (hy - sy) - (y - sy) * (hx - sx)) / det;
+ v = ((vx - sx) * (y - sy) - (vy - sy) * (x - sx)) / det;
+
+ return (s >= 0.0 && v >= 0.0 && s + v <= 1.0);
}
/* Computes a value based on the mouse coordinates */
static double
-compute_v (GtkHSV *hsv, double x, double y)
+compute_v (GtkHSV *hsv,
+ gdouble x,
+ gdouble y)
{
- HSVPrivate *priv;
- double center;
- double dx, dy;
- double angle;
-
- priv = hsv->priv;
-
- center = priv->size / 2.0;
- dx = x - center;
- dy = center - y;
-
- angle = atan2 (dy, dx);
- if (angle < 0.0)
- angle += 2.0 * M_PI;
-
- return angle / (2.0 * M_PI);
+ HSVPrivate *priv;
+ double center;
+ double dx, dy;
+ double angle;
+
+ priv = hsv->priv;
+
+ center = priv->size / 2.0;
+ dx = x - center;
+ dy = center - y;
+
+ angle = atan2 (dy, dx);
+ if (angle < 0.0)
+ angle += 2.0 * M_PI;
+
+ return angle / (2.0 * M_PI);
}
-
-
/* Event handlers */
static void
-set_cross_grab (GtkHSV *hsv, guint32 time)
+set_cross_grab (GtkHSV *hsv,
+ guint32 time)
{
- HSVPrivate *priv;
- GdkCursor *cursor;
-
- priv = hsv->priv;
-
- cursor = gdk_cursor_new (GDK_CROSSHAIR);
- gdk_pointer_grab (priv->window, FALSE,
- (GDK_POINTER_MOTION_MASK
- | GDK_POINTER_MOTION_HINT_MASK
- | GDK_BUTTON_RELEASE_MASK),
- NULL,
- cursor,
- time);
- gdk_cursor_destroy (cursor);
-
+ HSVPrivate *priv;
+ GdkCursor *cursor;
+
+ priv = hsv->priv;
+
+ cursor = gdk_cursor_new (GDK_CROSSHAIR);
+ gdk_pointer_grab (priv->window, FALSE,
+ (GDK_POINTER_MOTION_MASK
+ | GDK_POINTER_MOTION_HINT_MASK
+ | GDK_BUTTON_RELEASE_MASK),
+ NULL,
+ cursor,
+ time);
+ gdk_cursor_destroy (cursor);
}
/* Button_press_event handler for the HSV color selector */
static gint
-gtk_hsv_button_press (GtkWidget *widget, GdkEventButton *event)
+gtk_hsv_button_press (GtkWidget *widget,
+ GdkEventButton *event)
{
- GtkHSV *hsv;
- HSVPrivate *priv;
- double x, y;
-
- hsv = GTK_HSV (widget);
- priv = hsv->priv;
-
- if (priv->mode != DRAG_NONE || event->button != 1)
- return FALSE;
-
- x = event->x;
- y = event->y;
-
- if (is_in_ring (hsv, x, y)) {
- priv->mode = DRAG_H;
- set_cross_grab (hsv, event->time);
-
- gtk_hsv_set_color (hsv,
- compute_v (hsv, x, y),
- priv->s,
- priv->v);
-
- return TRUE;
- }
-
- if (is_in_triangle (hsv, x, y)) {
- double s, v;
-
- priv->mode = DRAG_SV;
- set_cross_grab (hsv, event->time);
-
- compute_sv (hsv, x, y, &s, &v);
- gtk_hsv_set_color (hsv, priv->h, s, v);
- return TRUE;
- }
-
- return FALSE;
+ GtkHSV *hsv;
+ HSVPrivate *priv;
+ double x, y;
+
+ hsv = GTK_HSV (widget);
+ priv = hsv->priv;
+
+ if (priv->mode != DRAG_NONE || event->button != 1)
+ return FALSE;
+
+ x = event->x;
+ y = event->y;
+
+ if (is_in_ring (hsv, x, y))
+ {
+ priv->mode = DRAG_H;
+ set_cross_grab (hsv, event->time);
+
+ gtk_hsv_set_color (hsv,
+ compute_v (hsv, x, y),
+ priv->s,
+ priv->v);
+
+ return TRUE;
+ }
+
+ if (is_in_triangle (hsv, x, y))
+ {
+ gdouble s, v;
+
+ priv->mode = DRAG_SV;
+ set_cross_grab (hsv, event->time);
+
+ compute_sv (hsv, x, y, &s, &v);
+ gtk_hsv_set_color (hsv, priv->h, s, v);
+ return TRUE;
+ }
+
+ return FALSE;
}
/* Button_release_event handler for the HSV color selector */
static gint
-gtk_hsv_button_release (GtkWidget *widget, GdkEventButton *event)
+gtk_hsv_button_release (GtkWidget *widget,
+ GdkEventButton *event)
{
- GtkHSV *hsv;
- HSVPrivate *priv;
- DragMode mode;
- double x, y;
-
- hsv = GTK_HSV (widget);
- priv = hsv->priv;
-
- if (priv->mode == DRAG_NONE || event->button != 1)
- return FALSE;
-
- /* Set the drag mode to DRAG_NONE so that signal handlers for "catched"
- * can see that this is the final color state.
- */
-
- mode = priv->mode;
- priv->mode = DRAG_NONE;
-
- x = event->x;
- y = event->y;
-
- if (mode == DRAG_H)
- gtk_hsv_set_color (hsv, compute_v (hsv, x, y), priv->s, priv->v);
- else if (mode == DRAG_SV) {
- double s, v;
-
- compute_sv (hsv, x, y, &s, &v);
- gtk_hsv_set_color (hsv, priv->h, s, v);
- } else
- g_assert_not_reached ();
-
- gdk_pointer_ungrab (event->time);
-
- return TRUE;
+ GtkHSV *hsv;
+ HSVPrivate *priv;
+ DragMode mode;
+ gdouble x, y;
+
+ hsv = GTK_HSV (widget);
+ priv = hsv->priv;
+
+ if (priv->mode == DRAG_NONE || event->button != 1)
+ return FALSE;
+
+ /* Set the drag mode to DRAG_NONE so that signal handlers for "catched"
+ * can see that this is the final color state.
+ */
+
+ mode = priv->mode;
+ priv->mode = DRAG_NONE;
+
+ x = event->x;
+ y = event->y;
+
+ if (mode == DRAG_H)
+ gtk_hsv_set_color (hsv, compute_v (hsv, x, y), priv->s, priv->v);
+ else if (mode == DRAG_SV) {
+ double s, v;
+
+ compute_sv (hsv, x, y, &s, &v);
+ gtk_hsv_set_color (hsv, priv->h, s, v);
+ } else
+ g_assert_not_reached ();
+
+ gdk_pointer_ungrab (event->time);
+
+ return TRUE;
}
/* Motion_notify_event handler for the HSV color selector */
static gint
-gtk_hsv_motion (GtkWidget *widget, GdkEventMotion *event)
+gtk_hsv_motion (GtkWidget *widget,
+ GdkEventMotion *event)
{
- GtkHSV *hsv;
- HSVPrivate *priv;
- double x, y;
- gint ix, iy;
- GdkModifierType mods;
-
- hsv = GTK_HSV (widget);
- priv = hsv->priv;
-
- if (priv->mode == DRAG_NONE)
- return FALSE;
-
- if (event->is_hint) {
- gdk_window_get_pointer (priv->window, &ix, &iy, &mods);
- x = ix;
- y = iy;
- } else {
- x = event->x;
- y = event->y;
- }
-
- if (priv->mode == DRAG_H) {
- gtk_hsv_set_color (hsv, compute_v (hsv, x, y), priv->s, priv->v);
- return TRUE;
- } else if (priv->mode == DRAG_SV) {
- double s, v;
-
- compute_sv (hsv, x, y, &s, &v);
- gtk_hsv_set_color (hsv, priv->h, s, v);
- return TRUE;
- }
-
- g_assert_not_reached ();
- return FALSE;
+ GtkHSV *hsv;
+ HSVPrivate *priv;
+ double x, y;
+ gint ix, iy;
+ GdkModifierType mods;
+
+ hsv = GTK_HSV (widget);
+ priv = hsv->priv;
+
+ if (priv->mode == DRAG_NONE)
+ return FALSE;
+
+ if (event->is_hint)
+ {
+ gdk_window_get_pointer (priv->window, &ix, &iy, &mods);
+ x = ix;
+ y = iy;
+ }
+ else
+ {
+ x = event->x;
+ y = event->y;
+ }
+
+ if (priv->mode == DRAG_H)
+ {
+ gtk_hsv_set_color (hsv, compute_v (hsv, x, y), priv->s, priv->v);
+ return TRUE;
+ }
+ else if (priv->mode == DRAG_SV)
+ {
+ double s, v;
+
+ compute_sv (hsv, x, y, &s, &v);
+ gtk_hsv_set_color (hsv, priv->h, s, v);
+ return TRUE;
+ }
+
+ g_assert_not_reached ();
+ return FALSE;
}
-
/* Redrawing */
/* Paints the hue ring */
static void
-paint_ring (GtkHSV *hsv, GdkDrawable *drawable, int x, int y, int width, int height)
+paint_ring (GtkHSV *hsv,
+ GdkDrawable *drawable,
+ gint x,
+ gint y,
+ gint width,
+ gint height)
{
- HSVPrivate *priv;
- int xx, yy;
- double dx, dy, dist;
- double center;
- double inner, outer;
- guchar *buf, *p;
- double angle;
- double hue;
- double r, g, b;
- GdkBitmap *mask;
- GdkGC *gc;
- GdkColor color;
-
- priv = hsv->priv;
-
- center = priv->size / 2.0;
-
- outer = priv->size / 2.0;
- inner = outer - priv->ring_width;
-
- /* Paint the ring */
-
- buf = g_new (guchar, width * height * 3);
-
- for (yy = 0; yy < height; yy++) {
- p = buf + yy * width * 3;
-
- dy = -(yy + y - center);
-
- for (xx = 0; xx < width; xx++) {
- dx = xx + x - center;
-
- dist = dx * dx + dy * dy;
- if (dist < (inner * inner) || dist > (outer * outer)) {
- *p++ = 0;
- *p++ = 0;
- *p++ = 0;
- continue;
- }
-
- angle = atan2 (dy, dx);
- if (angle < 0.0)
- angle += 2.0 * M_PI;
-
- hue = angle / (2.0 * M_PI);
-
- r = hue;
- g = 1.0;
- b = 1.0;
- hsv_to_rgb (&r, &g, &b);
-
- *p++ = floor (r * 255 + 0.5);
- *p++ = floor (g * 255 + 0.5);
- *p++ = floor (b * 255 + 0.5);
- }
+ HSVPrivate *priv;
+ int xx, yy;
+ gdouble dx, dy, dist;
+ gdouble center;
+ gdouble inner, outer;
+ guchar *buf, *p;
+ gdouble angle;
+ gdouble hue;
+ gdouble r, g, b;
+ GdkBitmap *mask;
+ GdkGC *gc;
+ GdkColor color;
+
+ priv = hsv->priv;
+
+ center = priv->size / 2.0;
+
+ outer = priv->size / 2.0;
+ inner = outer - priv->ring_width;
+
+ /* Paint the ring */
+
+ buf = g_new (guchar, width * height * 3);
+
+ for (yy = 0; yy < height; yy++)
+ {
+ p = buf + yy * width * 3;
+
+ dy = -(yy + y - center);
+
+ for (xx = 0; xx < width; xx++)
+ {
+ dx = xx + x - center;
+
+ dist = dx * dx + dy * dy;
+ if (dist < (inner * inner) || dist > (outer * outer))
+ {
+ *p++ = 0;
+ *p++ = 0;
+ *p++ = 0;
+ continue;
+ }
+
+ angle = atan2 (dy, dx);
+ if (angle < 0.0)
+ angle += 2.0 * M_PI;
+
+ hue = angle / (2.0 * M_PI);
+
+ r = hue;
+ g = 1.0;
+ b = 1.0;
+ hsv_to_rgb (&r, &g, &b);
+
+ *p++ = floor (r * 255 + 0.5);
+ *p++ = floor (g * 255 + 0.5);
+ *p++ = floor (b * 255 + 0.5);
}
-
- /* Create clipping mask */
-
- mask = gdk_pixmap_new (NULL, width, height, 1);
- gc = gdk_gc_new (mask);
-
- color.pixel = 0;
- gdk_gc_set_foreground (gc, &color);
- gdk_draw_rectangle (mask, gc, TRUE,
- 0, 0, width, height);
-
-
- color.pixel = 1;
- gdk_gc_set_foreground (gc, &color);
- gdk_draw_arc (mask, gc, TRUE,
- -x, -y,
- priv->size - 1, priv->size - 1,
- 0, 360 * 64);
-
- color.pixel = 0;
- gdk_gc_set_foreground (gc, &color);
- gdk_draw_arc (mask, gc, TRUE,
- -x + priv->ring_width - 1, -y + priv->ring_width - 1,
- priv->size - 2 * priv->ring_width + 1, priv->size - 2 * priv->ring_width + 1,
- 0, 360 * 64);
-
- gdk_gc_unref (gc);
-
- gdk_gc_set_clip_mask (priv->gc, mask);
- gdk_gc_set_clip_origin (priv->gc, 0, 0);
-
- /* Draw ring */
-
- gdk_draw_rgb_image_dithalign (drawable, priv->gc, 0, 0, width, height,
- GDK_RGB_DITHER_MAX,
- buf,
- width * 3,
- x, y);
-
- /* Draw value marker */
-
- r = priv->h;
- g = 1.0;
- b = 1.0;
- hsv_to_rgb (&r, &g, &b);
-
- if (INTENSITY (r, g, b) > 0.5)
- gdk_rgb_gc_set_foreground (priv->gc, 0x000000);
- else
- gdk_rgb_gc_set_foreground (priv->gc, 0xffffff);
-
- gdk_draw_line (drawable, priv->gc,
- -x + center, -y + center,
- -x + center + cos (priv->h * 2.0 * M_PI) * center,
- -y + center - sin (priv->h * 2.0 * M_PI) * center);
-
- gdk_gc_set_clip_mask (priv->gc, NULL);
- gdk_bitmap_unref (mask);
-
- g_free (buf);
-
- /* Draw ring outline */
-
- gdk_rgb_gc_set_foreground (priv->gc, 0x000000);
-
- gdk_draw_arc (drawable, priv->gc, FALSE,
- -x, -y,
- priv->size - 1, priv->size - 1,
- 0, 360 * 64);
- gdk_draw_arc (drawable, priv->gc, FALSE,
- -x + priv->ring_width - 1, -y + priv->ring_width - 1,
- priv->size - 2 * priv->ring_width + 1, priv->size - 2 * priv->ring_width + 1,
- 0, 360 * 64);
+ }
+
+ /* Create clipping mask */
+
+ mask = gdk_pixmap_new (NULL, width, height, 1);
+ gc = gdk_gc_new (mask);
+
+ color.pixel = 0;
+ gdk_gc_set_foreground (gc, &color);
+ gdk_draw_rectangle (mask, gc, TRUE,
+ 0, 0, width, height);
+
+
+ color.pixel = 1;
+ gdk_gc_set_foreground (gc, &color);
+ gdk_draw_arc (mask, gc, TRUE,
+ -x, -y,
+ priv->size - 1, priv->size - 1,
+ 0, 360 * 64);
+
+ color.pixel = 0;
+ gdk_gc_set_foreground (gc, &color);
+ gdk_draw_arc (mask, gc, TRUE,
+ -x + priv->ring_width - 1, -y + priv->ring_width - 1,
+ priv->size - 2 * priv->ring_width + 1, priv->size - 2 * priv->ring_width + 1,
+ 0, 360 * 64);
+
+ gdk_gc_unref (gc);
+
+ gdk_gc_set_clip_mask (priv->gc, mask);
+ gdk_gc_set_clip_origin (priv->gc, 0, 0);
+
+ /* Draw ring */
+
+ gdk_draw_rgb_image_dithalign (drawable, priv->gc, 0, 0, width, height,
+ GDK_RGB_DITHER_MAX,
+ buf,
+ width * 3,
+ x, y);
+
+ /* Draw value marker */
+
+ r = priv->h;
+ g = 1.0;
+ b = 1.0;
+ hsv_to_rgb (&r, &g, &b);
+
+ if (INTENSITY (r, g, b) > 0.5)
+ gdk_rgb_gc_set_foreground (priv->gc, 0x000000);
+ else
+ gdk_rgb_gc_set_foreground (priv->gc, 0xffffff);
+
+ gdk_draw_line (drawable, priv->gc,
+ -x + center, -y + center,
+ -x + center + cos (priv->h * 2.0 * M_PI) * center,
+ -y + center - sin (priv->h * 2.0 * M_PI) * center);
+
+ gdk_gc_set_clip_mask (priv->gc, NULL);
+ gdk_bitmap_unref (mask);
+
+ g_free (buf);
+
+ /* Draw ring outline */
+
+ gdk_rgb_gc_set_foreground (priv->gc, 0x000000);
+
+ gdk_draw_arc (drawable, priv->gc, FALSE,
+ -x, -y,
+ priv->size - 1, priv->size - 1,
+ 0, 360 * 64);
+ gdk_draw_arc (drawable, priv->gc, FALSE,
+ -x + priv->ring_width - 1, -y + priv->ring_width - 1,
+ priv->size - 2 * priv->ring_width + 1, priv->size - 2 * priv->ring_width + 1,
+ 0, 360 * 64);
}
/* Converts an HSV triplet to an integer RGB triplet */
static void
-get_color (double h, double s, double v, int *r, int *g, int *b)
+get_color (gdouble h,
+ gdouble s,
+ gdouble v,
+ gint *r,
+ gint *g,
+ gint *b)
{
- hsv_to_rgb (&h, &s, &v);
-
- *r = floor (h * 255 + 0.5);
- *g = floor (s * 255 + 0.5);
- *b = floor (v * 255 + 0.5);
+ hsv_to_rgb (&h, &s, &v);
+
+ *r = floor (h * 255 + 0.5);
+ *g = floor (s * 255 + 0.5);
+ *b = floor (v * 255 + 0.5);
}
#define SWAP(a, b, t) ((t) = (a), (a) = (b), (b) = (t))
@@ -940,250 +1004,273 @@ get_color (double h, double s, double v, int *r, int *g, int *b)
/* Paints the HSV triangle */
static void
-paint_triangle (GtkHSV *hsv, GdkDrawable *drawable, int x, int y, int width, int height)
+paint_triangle (GtkHSV *hsv,
+ GdkDrawable *drawable,
+ gint x,
+ gint y,
+ gint width,
+ gint height)
{
- HSVPrivate *priv;
- int hx, hy, sx, sy, vx, vy; /* HSV vertices */
- int x1, y1, r1, g1, b1; /* First vertex in scanline order */
- int x2, y2, r2, g2, b2; /* Second vertex */
- int x3, y3, r3, g3, b3; /* Third vertex */
- int t;
- guchar *buf, *p;
- int xl, xr, rl, rr, gl, gr, bl, br; /* Scanline data */
- int xx, yy;
- GdkBitmap *mask;
- GdkGC *gc;
- GdkColor color;
- GdkPoint points[3];
- double r, g, b;
-
- priv = hsv->priv;
-
- /* Compute triangle's vertices */
-
- compute_triangle (hsv, &hx, &hy, &sx, &sy, &vx, &vy);
-
- x1 = hx;
- y1 = hy;
- get_color (priv->h, 1.0, 1.0, &r1, &g1, &b1);
-
- x2 = sx;
- y2 = sy;
- get_color (priv->h, 1.0, 0.0, &r2, &g2, &b2);
-
- x3 = vx;
- y3 = vy;
- get_color (priv->h, 0.0, 1.0, &r3, &g3, &b3);
-
- if (y2 > y3) {
- SWAP (x2, x3, t);
- SWAP (y2, y3, t);
- SWAP (r2, r3, t);
- SWAP (g2, g3, t);
- SWAP (b2, b3, t);
- }
-
- if (y1 > y3) {
- SWAP (x1, x3, t);
- SWAP (y1, y3, t);
- SWAP (r1, r3, t);
- SWAP (g1, g3, t);
- SWAP (b1, b3, t);
- }
-
- if (y1 > y2) {
- SWAP (x1, x2, t);
- SWAP (y1, y2, t);
- SWAP (r1, r2, t);
- SWAP (g1, g2, t);
- SWAP (b1, b2, t);
- }
-
- /* Shade the triangle */
-
- buf = g_new (guchar, width * height * 3);
-
- for (yy = 0; yy < height; yy++) {
- p = buf + yy * width * 3;
-
- if (yy + y < y1 || yy + y > y3)
- for (xx = 0; xx < width; xx++) {
- *p++ = 0;
- *p++ = 0;
- *p++ = 0;
- }
- else {
- if (yy + y < y2) {
- xl = LERP (x1, x2, y1, y2, yy + y);
-
- rl = LERP (r1, r2, y1, y2, yy + y);
- gl = LERP (g1, g2, y1, y2, yy + y);
- bl = LERP (b1, b2, y1, y2, yy + y);
- } else {
- xl = LERP (x2, x3, y2, y3, yy + y);
-
- rl = LERP (r2, r3, y2, y3, yy + y);
- gl = LERP (g2, g3, y2, y3, yy + y);
- bl = LERP (b2, b3, y2, y3, yy + y);
- }
-
- xr = LERP (x1, x3, y1, y3, yy + y);
-
- rr = LERP (r1, r3, y1, y3, yy + y);
- gr = LERP (g1, g3, y1, y3, yy + y);
- br = LERP (b1, b3, y1, y3, yy + y);
-
- if (xl > xr) {
- SWAP (xl, xr, t);
- SWAP (rl, rr, t);
- SWAP (gl, gr, t);
- SWAP (bl, br, t);
- }
-
- for (xx = 0; xx < width; xx++) {
- if (xx + x < xl || xx + x > xr) {
- *p++ = 0;
- *p++ = 0;
- *p++ = 0;
- } else {
- *p++ = LERP (rl, rr, xl, xr, xx + x);
- *p++ = LERP (gl, gr, xl, xr, xx + x);
- *p++ = LERP (bl, br, xl, xr, xx + x);
- }
- }
- }
- }
-
- /* Create clipping mask */
-
- mask = gdk_pixmap_new (NULL, width, height, 1);
- gc = gdk_gc_new (mask);
-
- color.pixel = 0;
- gdk_gc_set_foreground (gc, &color);
- gdk_draw_rectangle (mask, gc, TRUE,
- 0, 0, width, height);
-
- color.pixel = 1;
- gdk_gc_set_foreground (gc, &color);
-
- points[0].x = x1 - x;
- points[0].y = y1 - y;
- points[1].x = x2 - x;
- points[1].y = y2 - y;
- points[2].x = x3 - x;
- points[2].y = y3 - y;
- gdk_draw_polygon (mask, gc, TRUE, points, 3);
-
- gdk_gc_unref (gc);
-
- gdk_gc_set_clip_mask (priv->gc, mask);
- gdk_gc_set_clip_origin (priv->gc, 0, 0);
-
- /* Draw triangle */
-
- gdk_draw_rgb_image_dithalign (drawable, priv->gc, 0, 0, width, height,
- GDK_RGB_DITHER_MAX,
- buf,
- width * 3,
- x, y);
-
- gdk_gc_set_clip_mask (priv->gc, NULL);
- gdk_bitmap_unref (mask);
-
- g_free (buf);
-
- /* Draw triangle outline */
-
- gdk_rgb_gc_set_foreground (priv->gc, 0x000000);
-
- gdk_draw_polygon (drawable, priv->gc, FALSE, points, 3);
-
- /* Draw value marker */
-
- xx = floor (sx + (vx - sx) * priv->v + (hx - vx) * priv->s * priv->v + 0.5);
- yy = floor (sy + (vy - sy) * priv->v + (hy - vy) * priv->s * priv->v + 0.5);
-
- r = priv->h;
- g = priv->s;
- b = priv->v;
- hsv_to_rgb (&r, &g, &b);
-
- if (INTENSITY (r, g, b) > 0.5)
- gdk_rgb_gc_set_foreground (priv->gc, 0x000000);
+ HSVPrivate *priv;
+ gint hx, hy, sx, sy, vx, vy; /* HSV vertices */
+ gint x1, y1, r1, g1, b1; /* First vertex in scanline order */
+ gint x2, y2, r2, g2, b2; /* Second vertex */
+ gint x3, y3, r3, g3, b3; /* Third vertex */
+ gint t;
+ guchar *buf, *p;
+ gint xl, xr, rl, rr, gl, gr, bl, br; /* Scanline data */
+ gint xx, yy;
+ GdkBitmap *mask;
+ GdkGC *gc;
+ GdkColor color;
+ GdkPoint points[3];
+ gdouble r, g, b;
+
+ priv = hsv->priv;
+
+ /* Compute triangle's vertices */
+
+ compute_triangle (hsv, &hx, &hy, &sx, &sy, &vx, &vy);
+
+ x1 = hx;
+ y1 = hy;
+ get_color (priv->h, 1.0, 1.0, &r1, &g1, &b1);
+
+ x2 = sx;
+ y2 = sy;
+ get_color (priv->h, 1.0, 0.0, &r2, &g2, &b2);
+
+ x3 = vx;
+ y3 = vy;
+ get_color (priv->h, 0.0, 1.0, &r3, &g3, &b3);
+
+ if (y2 > y3)
+ {
+ SWAP (x2, x3, t);
+ SWAP (y2, y3, t);
+ SWAP (r2, r3, t);
+ SWAP (g2, g3, t);
+ SWAP (b2, b3, t);
+ }
+
+ if (y1 > y3)
+ {
+ SWAP (x1, x3, t);
+ SWAP (y1, y3, t);
+ SWAP (r1, r3, t);
+ SWAP (g1, g3, t);
+ SWAP (b1, b3, t);
+ }
+
+ if (y1 > y2)
+ {
+ SWAP (x1, x2, t);
+ SWAP (y1, y2, t);
+ SWAP (r1, r2, t);
+ SWAP (g1, g2, t);
+ SWAP (b1, b2, t);
+ }
+
+ /* Shade the triangle */
+
+ buf = g_new (guchar, width * height * 3);
+
+ for (yy = 0; yy < height; yy++)
+ {
+ p = buf + yy * width * 3;
+
+ if (yy + y < y1 || yy + y > y3)
+ for (xx = 0; xx < width; xx++)
+ {
+ *p++ = 0;
+ *p++ = 0;
+ *p++ = 0;
+ }
+ else {
+ if (yy + y < y2)
+ {
+ xl = LERP (x1, x2, y1, y2, yy + y);
+
+ rl = LERP (r1, r2, y1, y2, yy + y);
+ gl = LERP (g1, g2, y1, y2, yy + y);
+ bl = LERP (b1, b2, y1, y2, yy + y);
+ }
else
- gdk_rgb_gc_set_foreground (priv->gc, 0xffffff);
-
- gdk_draw_arc (drawable, priv->gc, FALSE,
- xx - 3, yy - 3,
- 6, 6,
- 0, 360 * 64);
- gdk_draw_arc (drawable, priv->gc, FALSE,
- xx - 2, yy - 2,
- 4, 4,
- 0, 360 * 64);
+ {
+ xl = LERP (x2, x3, y2, y3, yy + y);
+
+ rl = LERP (r2, r3, y2, y3, yy + y);
+ gl = LERP (g2, g3, y2, y3, yy + y);
+ bl = LERP (b2, b3, y2, y3, yy + y);
+ }
+
+ xr = LERP (x1, x3, y1, y3, yy + y);
+
+ rr = LERP (r1, r3, y1, y3, yy + y);
+ gr = LERP (g1, g3, y1, y3, yy + y);
+ br = LERP (b1, b3, y1, y3, yy + y);
+
+ if (xl > xr)
+ {
+ SWAP (xl, xr, t);
+ SWAP (rl, rr, t);
+ SWAP (gl, gr, t);
+ SWAP (bl, br, t);
+ }
+
+ for (xx = 0; xx < width; xx++)
+ {
+ if (xx + x < xl || xx + x > xr)
+ {
+ *p++ = 0;
+ *p++ = 0;
+ *p++ = 0;
+ }
+ else
+ {
+ *p++ = LERP (rl, rr, xl, xr, xx + x);
+ *p++ = LERP (gl, gr, xl, xr, xx + x);
+ *p++ = LERP (bl, br, xl, xr, xx + x);
+ }
+ }
+ }
+ }
+
+ /* Create clipping mask */
+
+ mask = gdk_pixmap_new (NULL, width, height, 1);
+ gc = gdk_gc_new (mask);
+
+ color.pixel = 0;
+ gdk_gc_set_foreground (gc, &color);
+ gdk_draw_rectangle (mask, gc, TRUE,
+ 0, 0, width, height);
+
+ color.pixel = 1;
+ gdk_gc_set_foreground (gc, &color);
+
+ points[0].x = x1 - x;
+ points[0].y = y1 - y;
+ points[1].x = x2 - x;
+ points[1].y = y2 - y;
+ points[2].x = x3 - x;
+ points[2].y = y3 - y;
+ gdk_draw_polygon (mask, gc, TRUE, points, 3);
+
+ gdk_gc_unref (gc);
+
+ gdk_gc_set_clip_mask (priv->gc, mask);
+ gdk_gc_set_clip_origin (priv->gc, 0, 0);
+
+ /* Draw triangle */
+
+ gdk_draw_rgb_image_dithalign (drawable, priv->gc, 0, 0, width, height,
+ GDK_RGB_DITHER_MAX,
+ buf,
+ width * 3,
+ x, y);
+
+ gdk_gc_set_clip_mask (priv->gc, NULL);
+ gdk_bitmap_unref (mask);
+
+ g_free (buf);
+
+ /* Draw triangle outline */
+
+ gdk_rgb_gc_set_foreground (priv->gc, 0x000000);
+
+ gdk_draw_polygon (drawable, priv->gc, FALSE, points, 3);
+
+ /* Draw value marker */
+
+ xx = floor (sx + (vx - sx) * priv->v + (hx - vx) * priv->s * priv->v + 0.5);
+ yy = floor (sy + (vy - sy) * priv->v + (hy - vy) * priv->s * priv->v + 0.5);
+
+ r = priv->h;
+ g = priv->s;
+ b = priv->v;
+ hsv_to_rgb (&r, &g, &b);
+
+ if (INTENSITY (r, g, b) > 0.5)
+ gdk_rgb_gc_set_foreground (priv->gc, 0x000000);
+ else
+ gdk_rgb_gc_set_foreground (priv->gc, 0xffffff);
+
+ gdk_draw_arc (drawable, priv->gc, FALSE,
+ xx - 3, yy - 3,
+ 6, 6,
+ 0, 360 * 64);
+ gdk_draw_arc (drawable, priv->gc, FALSE,
+ xx - 2, yy - 2,
+ 4, 4,
+ 0, 360 * 64);
}
/* Paints the contents of the HSV color selector */
static void
-paint (GtkHSV *hsv, GdkDrawable *drawable, int x, int y, int width, int height)
+paint (GtkHSV *hsv,
+ GdkDrawable *drawable,
+ gint x,
+ gint y,
+ gint width,
+ gint height)
{
- paint_ring (hsv, drawable, x, y, width, height);
- paint_triangle (hsv, drawable, x, y, width, height);
+ paint_ring (hsv, drawable, x, y, width, height);
+ paint_triangle (hsv, drawable, x, y, width, height);
}
/* Expose_event handler for the HSV color selector */
static gint
-gtk_hsv_expose (GtkWidget *widget, GdkEventExpose *event)
+gtk_hsv_expose (GtkWidget *widget,
+ GdkEventExpose *event)
{
- GtkHSV *hsv;
- HSVPrivate *priv;
- GdkRectangle rect, dest;
- GdkPixmap *pixmap;
-
- hsv = GTK_HSV (widget);
- priv = hsv->priv;
-
- if (!(GTK_WIDGET_DRAWABLE (widget) && event->window == widget->window))
- return FALSE;
-
- rect.x = widget->allocation.x;
- rect.y = widget->allocation.y;
- rect.width = widget->allocation.width;
- rect.height = widget->allocation.height;
-
- if (!gdk_rectangle_intersect (&event->area, &rect, &dest))
- return FALSE;
-
- pixmap = gdk_pixmap_new (widget->window, dest.width, dest.height,
- gtk_widget_get_visual (widget)->depth);
-
- rect = dest;
- rect.x = 0;
- rect.y = 0;
-
- gdk_draw_rectangle (pixmap,
- widget->style->bg_gc[GTK_WIDGET_STATE (widget)],
- TRUE,
- 0, 0, dest.width, dest.height);
- paint (hsv, pixmap,
- dest.x - widget->allocation.x, dest.y - widget->allocation.y,
- dest.width, dest.height);
-
- gdk_draw_pixmap (widget->window,
- priv->gc,
- pixmap,
- 0, 0,
- dest.x,
- dest.y,
- event->area.width, event->area.height);
-
- gdk_pixmap_unref (pixmap);
-
- return FALSE;
+ GtkHSV *hsv;
+ HSVPrivate *priv;
+ GdkRectangle rect, dest;
+ GdkPixmap *pixmap;
+
+ hsv = GTK_HSV (widget);
+ priv = hsv->priv;
+
+ if (!(GTK_WIDGET_DRAWABLE (widget) && event->window == widget->window))
+ return FALSE;
+
+ rect.x = widget->allocation.x;
+ rect.y = widget->allocation.y;
+ rect.width = widget->allocation.width;
+ rect.height = widget->allocation.height;
+
+ if (!gdk_rectangle_intersect (&event->area, &rect, &dest))
+ return FALSE;
+
+ pixmap = gdk_pixmap_new (widget->window, dest.width, dest.height,
+ gtk_widget_get_visual (widget)->depth);
+
+ rect = dest;
+ rect.x = 0;
+ rect.y = 0;
+
+ gdk_draw_rectangle (pixmap,
+ widget->style->bg_gc[GTK_WIDGET_STATE (widget)],
+ TRUE,
+ 0, 0, dest.width, dest.height);
+ paint (hsv, pixmap,
+ dest.x - widget->allocation.x, dest.y - widget->allocation.y,
+ dest.width, dest.height);
+
+ gdk_draw_pixmap (widget->window,
+ priv->gc,
+ pixmap,
+ 0, 0,
+ dest.x,
+ dest.y,
+ event->area.width, event->area.height);
+
+ gdk_pixmap_unref (pixmap);
+
+ return FALSE;
}
-
/**
* gtk_hsv_new:
@@ -1193,10 +1280,10 @@ gtk_hsv_expose (GtkWidget *widget, GdkEventExpose *event)
*
* Return value: A newly-created HSV color selector.
**/
-GtkWidget *
+GtkWidget*
gtk_hsv_new (void)
{
- return GTK_WIDGET (gtk_type_new (gtk_hsv_get_type ()));
+ return GTK_WIDGET (gtk_type_new (GTK_TYPE_HSV));
}
/**
@@ -1210,25 +1297,28 @@ gtk_hsv_new (void)
* be in the [0.0, 1.0] range.
**/
void
-gtk_hsv_set_color (GtkHSV *hsv, double h, double s, double v)
+gtk_hsv_set_color (GtkHSV *hsv,
+ gdouble h,
+ gdouble s,
+ gdouble v)
{
- HSVPrivate *priv;
-
- g_return_if_fail (hsv != NULL);
- g_return_if_fail (GTK_IS_HSV (hsv));
- g_return_if_fail (h >= 0.0 && h <= 1.0);
- g_return_if_fail (s >= 0.0 && s <= 1.0);
- g_return_if_fail (v >= 0.0 && v <= 1.0);
-
- priv = hsv->priv;
-
- priv->h = h;
- priv->s = s;
- priv->v = v;
-
- gtk_signal_emit (GTK_OBJECT (hsv), hsv_signals[CHANGED]);
-
- gtk_widget_queue_draw (GTK_WIDGET (hsv));
+ HSVPrivate *priv;
+
+ g_return_if_fail (hsv != NULL);
+ g_return_if_fail (GTK_IS_HSV (hsv));
+ g_return_if_fail (h >= 0.0 && h <= 1.0);
+ g_return_if_fail (s >= 0.0 && s <= 1.0);
+ g_return_if_fail (v >= 0.0 && v <= 1.0);
+
+ priv = hsv->priv;
+
+ priv->h = h;
+ priv->s = s;
+ priv->v = v;
+
+ gtk_signal_emit (GTK_OBJECT (hsv), hsv_signals[CHANGED]);
+
+ gtk_widget_queue_draw (GTK_WIDGET (hsv));
}
/**
@@ -1244,21 +1334,21 @@ gtk_hsv_set_color (GtkHSV *hsv, double h, double s, double v)
void
gtk_hsv_get_color (GtkHSV *hsv, double *h, double *s, double *v)
{
- HSVPrivate *priv;
-
- g_return_if_fail (hsv != NULL);
- g_return_if_fail (GTK_IS_HSV (hsv));
-
- priv = hsv->priv;
-
- if (h)
- *h = priv->h;
-
- if (s)
- *s = priv->s;
-
- if (v)
- *v = priv->v;
+ HSVPrivate *priv;
+
+ g_return_if_fail (hsv != NULL);
+ g_return_if_fail (GTK_IS_HSV (hsv));
+
+ priv = hsv->priv;
+
+ if (h)
+ *h = priv->h;
+
+ if (s)
+ *s = priv->s;
+
+ if (v)
+ *v = priv->v;
}
/**
@@ -1270,28 +1360,30 @@ gtk_hsv_get_color (GtkHSV *hsv, double *h, double *s, double *v)
* Sets the size and ring width of an HSV color selector.
**/
void
-gtk_hsv_set_metrics (GtkHSV *hsv, int size, int ring_width)
+gtk_hsv_set_metrics (GtkHSV *hsv,
+ gint size,
+ gint ring_width)
{
- HSVPrivate *priv;
- int same_size;
-
- g_return_if_fail (hsv != NULL);
- g_return_if_fail (GTK_IS_HSV (hsv));
- g_return_if_fail (size > 0);
- g_return_if_fail (ring_width > 0);
- g_return_if_fail (2 * ring_width + 1 <= size);
-
- priv = hsv->priv;
-
- same_size = (priv->size == size);
-
- priv->size = size;
- priv->ring_width = ring_width;
-
- if (same_size)
- gtk_widget_queue_draw (GTK_WIDGET (hsv));
- else
- gtk_widget_queue_resize (GTK_WIDGET (hsv));
+ HSVPrivate *priv;
+ int same_size;
+
+ g_return_if_fail (hsv != NULL);
+ g_return_if_fail (GTK_IS_HSV (hsv));
+ g_return_if_fail (size > 0);
+ g_return_if_fail (ring_width > 0);
+ g_return_if_fail (2 * ring_width + 1 <= size);
+
+ priv = hsv->priv;
+
+ same_size = (priv->size == size);
+
+ priv->size = size;
+ priv->ring_width = ring_width;
+
+ if (same_size)
+ gtk_widget_queue_draw (GTK_WIDGET (hsv));
+ else
+ gtk_widget_queue_resize (GTK_WIDGET (hsv));
}
/**
@@ -1303,20 +1395,22 @@ gtk_hsv_set_metrics (GtkHSV *hsv, int size, int ring_width)
* Queries the size and ring width of an HSV color selector.
**/
void
-gtk_hsv_get_metrics (GtkHSV *hsv, int *size, int *ring_width)
+gtk_hsv_get_metrics (GtkHSV *hsv,
+ gint *size,
+ gint *ring_width)
{
- HSVPrivate *priv;
-
- g_return_if_fail (hsv != NULL);
- g_return_if_fail (GTK_IS_HSV (hsv));
-
- priv = hsv->priv;
-
- if (size)
- *size = priv->size;
-
- if (ring_width)
- *ring_width = priv->ring_width;
+ HSVPrivate *priv;
+
+ g_return_if_fail (hsv != NULL);
+ g_return_if_fail (GTK_IS_HSV (hsv));
+
+ priv = hsv->priv;
+
+ if (size)
+ *size = priv->size;
+
+ if (ring_width)
+ *ring_width = priv->ring_width;
}
/**
@@ -1335,13 +1429,14 @@ gtk_hsv_get_metrics (GtkHSV *hsv, int *size, int *ring_width)
gboolean
gtk_hsv_is_adjusting (GtkHSV *hsv)
{
- HSVPrivate *priv;
-
- g_return_val_if_fail (hsv != NULL, FALSE);
- g_return_val_if_fail (GTK_IS_HSV (hsv), FALSE);
-
- priv = hsv->priv;
- return (priv->mode != DRAG_NONE);
+ HSVPrivate *priv;
+
+ g_return_val_if_fail (hsv != NULL, FALSE);
+ g_return_val_if_fail (GTK_IS_HSV (hsv), FALSE);
+
+ priv = hsv->priv;
+
+ return priv->mode != DRAG_NONE;
}
/**
@@ -1357,22 +1452,27 @@ gtk_hsv_is_adjusting (GtkHSV *hsv)
* [0.0, 1.0] range; output values will be in the same range.
**/
void
-gtk_hsv_to_rgb (double h, double s, double v, double *r, double *g, double *b)
+gtk_hsv_to_rgb (gdouble h,
+ gdouble s,
+ gdouble v,
+ gdouble *r,
+ gdouble *g,
+ gdouble *b)
{
- g_return_if_fail (h >= 0.0 && h <= 1.0);
- g_return_if_fail (s >= 0.0 && s <= 1.0);
- g_return_if_fail (v >= 0.0 && v <= 1.0);
-
- hsv_to_rgb (&h, &s, &v);
-
- if (r)
- *r = h;
-
- if (g)
- *g = s;
-
- if (b)
- *b = v;
+ g_return_if_fail (h >= 0.0 && h <= 1.0);
+ g_return_if_fail (s >= 0.0 && s <= 1.0);
+ g_return_if_fail (v >= 0.0 && v <= 1.0);
+
+ hsv_to_rgb (&h, &s, &v);
+
+ if (r)
+ *r = h;
+
+ if (g)
+ *g = s;
+
+ if (b)
+ *b = v;
}
/**
@@ -1388,20 +1488,25 @@ gtk_hsv_to_rgb (double h, double s, double v, double *r, double *g, double *b)
* [0.0, 1.0] range; output values will be in the same range.
**/
void
-gtk_rgb_to_hsv (double r, double g, double b, double *h, double *s, double *v)
+gtk_rgb_to_hsv (gdouble r,
+ gdouble g,
+ gdouble b,
+ gdouble *h,
+ gdouble *s,
+ gdouble *v)
{
- g_return_if_fail (r >= 0.0 && r <= 1.0);
- g_return_if_fail (g >= 0.0 && g <= 1.0);
- g_return_if_fail (b >= 0.0 && b <= 1.0);
-
- rgb_to_hsv (&r, &g, &b);
-
- if (h)
- *h = r;
-
- if (s)
- *s = g;
-
- if (v)
- *v = b;
+ g_return_if_fail (r >= 0.0 && r <= 1.0);
+ g_return_if_fail (g >= 0.0 && g <= 1.0);
+ g_return_if_fail (b >= 0.0 && b <= 1.0);
+
+ rgb_to_hsv (&r, &g, &b);
+
+ if (h)
+ *h = r;
+
+ if (s)
+ *s = g;
+
+ if (v)
+ *v = b;
}
diff --git a/gtk/gtkhsv.h b/gtk/gtkhsv.h
index ffe6ff7fc0..396821bed3 100644
--- a/gtk/gtkhsv.h
+++ b/gtk/gtkhsv.h
@@ -21,63 +21,86 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
-
#ifndef __GTK_HSV_H__
#define __GTK_HSV_H__
+/*
+ * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
+ * file for a list of people on the GTK+ Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+
#ifdef __cplusplus
extern "C" {
#endif
#include <gtk/gtkwidget.h>
-
#define GTK_TYPE_HSV (gtk_hsv_get_type ())
#define GTK_HSV(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_HSV, GtkHSV))
#define GTK_HSV_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_HSV, GtkHSV))
#define GTK_IS_HSV(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_HSV))
#define GTK_IS_HSV_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_HSV))
+#define GTK_HSV_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_HSV, GtkHSVClass))
-typedef struct _GtkHSV GtkHSV;
+typedef struct _GtkHSV GtkHSV;
typedef struct _GtkHSVClass GtkHSVClass;
-struct _GtkHSV {
- GtkWidget widget;
-
- /* Private data */
- gpointer priv;
+struct _GtkHSV
+{
+ GtkWidget parent_instance;
+
+ /* Private data */
+ gpointer priv;
};
-struct _GtkHSVClass {
- GtkWidgetClass parent_class;
-
- /* Notification signals */
-
- void (* changed) (GtkHSV *hsv);
+struct _GtkHSVClass
+{
+ GtkWidgetClass parent_class;
+
+ /* Notification signals */
+
+ void (*changed) (GtkHSV *hsv);
};
-GtkType gtk_hsv_get_type (void);
+GtkType gtk_hsv_get_type (void);
+GtkWidget* gtk_hsv_new (void);
+void gtk_hsv_set_color (GtkHSV *hsv,
+ double h,
+ double s,
+ double v);
+void gtk_hsv_get_color (GtkHSV *hsv,
+ gdouble *h,
+ gdouble *s,
+ gdouble *v);
+void gtk_hsv_set_metrics (GtkHSV *hsv,
+ gint size,
+ gint ring_width);
+void gtk_hsv_get_metrics (GtkHSV *hsv,
+ gint *size,
+ gint *ring_width);
+gboolean gtk_hsv_is_adjusting (GtkHSV *hsv);
+void gtk_hsv_to_rgb (gdouble h,
+ gdouble s,
+ gdouble v,
+ gdouble *r,
+ gdouble *g,
+ gdouble *b);
+void gtk_rgb_to_hsv (gdouble r,
+ gdouble g,
+ gdouble b,
+ gdouble *h,
+ gdouble *s,
+ gdouble *v);
-GtkWidget *gtk_hsv_new (void);
-
-void gtk_hsv_set_color (GtkHSV *hsv, double h, double s, double v);
-void gtk_hsv_get_color (GtkHSV *hsv, double *h, double *s, double *v);
-
-void gtk_hsv_set_metrics (GtkHSV *hsv, int size, int ring_width);
-void gtk_hsv_get_metrics (GtkHSV *hsv, int *size, int *ring_width);
-
-gboolean gtk_hsv_is_adjusting (GtkHSV *hsv);
-
-void gtk_hsv_to_rgb (double h, double s, double v, double *r, double *g, double *b);
-void gtk_rgb_to_hsv (double r, double g, double b, double *h, double *s, double *v);
-
-
#ifdef __cplusplus
}
#endif
-#endif
+#endif /* __GTK_HSV_H__ */
diff --git a/gtk/gtkinputdialog.c b/gtk/gtkinputdialog.c
index 263729b6c4..aca1170558 100644
--- a/gtk/gtkinputdialog.c
+++ b/gtk/gtkinputdialog.c
@@ -81,7 +81,6 @@ static void gtk_input_dialog_class_init (GtkInputDialogClass *klass);
static void gtk_input_dialog_init (GtkInputDialog *inputd);
static GdkDeviceInfo *gtk_input_dialog_get_device_info(guint32 deviceid);
static void gtk_input_dialog_set_device(GtkWidget *widget, gpointer data);
-static void gtk_input_dialog_finalize (GtkObject *object);
static void gtk_input_dialog_set_mapping_mode(GtkWidget *w,
gpointer data);
static void gtk_input_dialog_set_axis(GtkWidget *widget, gpointer data);
@@ -155,7 +154,7 @@ gtk_input_dialog_class_init (GtkInputDialogClass *klass)
input_dialog_signals[ENABLE_DEVICE] =
gtk_signal_new ("enable_device",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkInputDialogClass, enable_device),
gtk_marshal_NONE__INT,
GTK_TYPE_NONE, 1, GTK_TYPE_INT);
@@ -163,7 +162,7 @@ gtk_input_dialog_class_init (GtkInputDialogClass *klass)
input_dialog_signals[DISABLE_DEVICE] =
gtk_signal_new ("disable_device",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkInputDialogClass, disable_device),
gtk_marshal_NONE__INT,
GTK_TYPE_NONE, 1, GTK_TYPE_INT);
@@ -172,7 +171,6 @@ gtk_input_dialog_class_init (GtkInputDialogClass *klass)
LAST_SIGNAL);
- object_class->finalize = gtk_input_dialog_finalize;
klass->enable_device = NULL;
klass->disable_device = NULL;
}
@@ -393,16 +391,6 @@ gtk_input_dialog_set_device(GtkWidget *widget, gpointer data)
}
static void
-gtk_input_dialog_finalize (GtkObject *object)
-{
- /* GtkInputDialog *inputd = GTK_INPUT_DIALOG (object); */
-
- /* Clean up ? */
-
- (* GTK_OBJECT_CLASS (parent_class)->finalize) (object);
-}
-
-static void
gtk_input_dialog_set_mapping_mode(GtkWidget *w,
gpointer data)
{
diff --git a/gtk/gtkitem.c b/gtk/gtkitem.c
index d9df4607fe..0dae0e2b1f 100644
--- a/gtk/gtkitem.c
+++ b/gtk/gtkitem.c
@@ -87,21 +87,21 @@ gtk_item_class_init (GtkItemClass *class)
item_signals[SELECT] =
gtk_signal_new ("select",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkItemClass, select),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
item_signals[DESELECT] =
gtk_signal_new ("deselect",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkItemClass, deselect),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
item_signals[TOGGLE] =
gtk_signal_new ("toggle",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkItemClass, toggle),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
diff --git a/gtk/gtkitemfactory.c b/gtk/gtkitemfactory.c
index 82a849e17c..329f0cf882 100644
--- a/gtk/gtkitemfactory.c
+++ b/gtk/gtkitemfactory.c
@@ -85,12 +85,12 @@ struct _GtkIFDumpData
static void gtk_item_factory_class_init (GtkItemFactoryClass *klass);
static void gtk_item_factory_init (GtkItemFactory *ifactory);
static void gtk_item_factory_destroy (GtkObject *object);
-static void gtk_item_factory_finalize (GtkObject *object);
+static void gtk_item_factory_finalize (GObject *object);
/* --- static variables --- */
static GtkItemFactoryClass *gtk_item_factory_class = NULL;
-static GtkObjectClass *parent_class = NULL;
+static gpointer parent_class = NULL;
static const gchar *item_factory_string = "Gtk-<ItemFactory>";
static GMemChunk *ifactory_item_chunks = NULL;
static GMemChunk *ifactory_cb_data_chunks = NULL;
@@ -181,6 +181,7 @@ gtk_item_factory_get_type (void)
static void
gtk_item_factory_class_init (GtkItemFactoryClass *class)
{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (class);
GtkObjectClass *object_class;
gtk_item_factory_class = class;
@@ -189,8 +190,9 @@ gtk_item_factory_class_init (GtkItemFactoryClass *class)
object_class = (GtkObjectClass*) class;
+ gobject_class->finalize = gtk_item_factory_finalize;
+
object_class->destroy = gtk_item_factory_destroy;
- object_class->finalize = gtk_item_factory_finalize;
class->cpair_comment_single = g_strdup (";\n");
@@ -511,7 +513,7 @@ gtk_item_factory_add_item (GtkItemFactory *ifactory,
g_return_if_fail (widget != NULL);
g_return_if_fail (item_type != NULL);
- class = GTK_ITEM_FACTORY_CLASS (GTK_OBJECT (ifactory)->klass);
+ class = GTK_ITEM_FACTORY_GET_CLASS (ifactory);
/* set accelerator group on menu widgets
*/
@@ -681,11 +683,11 @@ gtk_item_factory_destroy (GtkObject *object)
g_slist_free (ifactory->items);
ifactory->items = NULL;
- parent_class->destroy (object);
+ GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
static void
-gtk_item_factory_finalize (GtkObject *object)
+gtk_item_factory_finalize (GObject *object)
{
GtkItemFactory *ifactory;
@@ -701,7 +703,7 @@ gtk_item_factory_finalize (GtkObject *object)
if (ifactory->translate_notify)
ifactory->translate_notify (ifactory->translate_data);
- parent_class->finalize (object);
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
GtkItemFactory*
@@ -859,7 +861,7 @@ gtk_item_factory_get_widget (GtkItemFactory *ifactory,
g_return_val_if_fail (GTK_IS_ITEM_FACTORY (ifactory), NULL);
g_return_val_if_fail (path != NULL, NULL);
- class = GTK_ITEM_FACTORY_CLASS (GTK_OBJECT (ifactory)->klass);
+ class = GTK_ITEM_FACTORY_GET_CLASS (ifactory);
if (path[0] == '<')
item = g_hash_table_lookup (class->item_ht, (gpointer) path);
@@ -1323,7 +1325,7 @@ gtk_item_factory_delete_item (GtkItemFactory *ifactory,
g_return_if_fail (GTK_IS_ITEM_FACTORY (ifactory));
g_return_if_fail (path != NULL);
- class = GTK_ITEM_FACTORY_CLASS (GTK_OBJECT (ifactory)->klass);
+ class = GTK_ITEM_FACTORY_GET_CLASS (ifactory);
fpath = g_strconcat (ifactory->path, path, NULL);
item = g_hash_table_lookup (class->item_ht, fpath);
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 0f16212b04..d6b64572c5 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -74,7 +74,7 @@ static void gtk_label_set_arg (GtkObject *object,
static void gtk_label_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
-static void gtk_label_finalize (GtkObject *object);
+static void gtk_label_finalize (GObject *object);
static void gtk_label_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void gtk_label_style_set (GtkWidget *widget,
@@ -101,20 +101,20 @@ gtk_label_get_type (void)
if (!label_type)
{
- static const GtkTypeInfo label_info =
+ static const GTypeInfo label_info =
{
- "GtkLabel",
- sizeof (GtkLabel),
sizeof (GtkLabelClass),
- (GtkClassInitFunc) gtk_label_class_init,
- (GtkObjectInitFunc) gtk_label_init,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) gtk_label_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (GtkLabel),
+ 32, /* n_preallocs */
+ (GInstanceInitFunc) gtk_label_init,
};
-
- label_type = gtk_type_unique (GTK_TYPE_MISC, &label_info);
- gtk_type_set_chunk_alloc (label_type, 32);
+
+ label_type = g_type_register_static (GTK_TYPE_MISC, "GtkLabel", &label_info);
}
return label_type;
@@ -123,6 +123,7 @@ gtk_label_get_type (void)
static void
gtk_label_class_init (GtkLabelClass *class)
{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (class);
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
@@ -136,9 +137,10 @@ gtk_label_class_init (GtkLabelClass *class)
gtk_object_add_arg_type ("GtkLabel::justify", GTK_TYPE_JUSTIFICATION, GTK_ARG_READWRITE, ARG_JUSTIFY);
gtk_object_add_arg_type ("GtkLabel::wrap", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_WRAP);
+ gobject_class->finalize = gtk_label_finalize;
+
object_class->set_arg = gtk_label_set_arg;
object_class->get_arg = gtk_label_get_arg;
- object_class->finalize = gtk_label_finalize;
widget_class->size_request = gtk_label_size_request;
widget_class->style_set = gtk_label_style_set;
@@ -347,11 +349,10 @@ gtk_label_get_text (GtkLabel *label)
}
static void
-gtk_label_finalize (GtkObject *object)
+gtk_label_finalize (GObject *object)
{
GtkLabel *label;
- g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_LABEL (object));
label = GTK_LABEL (object);
@@ -362,7 +363,7 @@ gtk_label_finalize (GtkObject *object)
gtk_label_free_words (label);
- GTK_OBJECT_CLASS (parent_class)->finalize (object);
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static GtkLabelULine*
diff --git a/gtk/gtklayout.c b/gtk/gtklayout.c
index a57e52df1d..f551a80bfb 100644
--- a/gtk/gtklayout.c
+++ b/gtk/gtklayout.c
@@ -45,7 +45,7 @@ struct _GtkLayoutChild {
static void gtk_layout_class_init (GtkLayoutClass *class);
static void gtk_layout_init (GtkLayout *layout);
-static void gtk_layout_finalize (GtkObject *object);
+static void gtk_layout_finalize (GObject *object);
static void gtk_layout_realize (GtkWidget *widget);
static void gtk_layout_unrealize (GtkWidget *widget);
static void gtk_layout_map (GtkWidget *widget);
@@ -170,14 +170,14 @@ gtk_layout_set_adjustments (GtkLayout *layout,
}
static void
-gtk_layout_finalize (GtkObject *object)
+gtk_layout_finalize (GObject *object)
{
GtkLayout *layout = GTK_LAYOUT (object);
gtk_object_unref (GTK_OBJECT (layout->hadjustment));
gtk_object_unref (GTK_OBJECT (layout->vadjustment));
- GTK_OBJECT_CLASS (parent_class)->finalize (object);
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
void
@@ -320,18 +320,20 @@ gtk_layout_get_type (void)
if (!layout_type)
{
- static const GtkTypeInfo layout_info =
+ static const GTypeInfo layout_info =
{
- "GtkLayout",
- sizeof (GtkLayout),
sizeof (GtkLayoutClass),
- (GtkClassInitFunc) gtk_layout_class_init,
- (GtkObjectInitFunc) gtk_layout_init,
- (GtkArgSetFunc) NULL,
- (GtkArgGetFunc) NULL,
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) gtk_layout_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (GtkLayout),
+ 16, /* n_preallocs */
+ (GInstanceInitFunc) gtk_layout_init,
};
- layout_type = gtk_type_unique (GTK_TYPE_CONTAINER, &layout_info);
+ layout_type = g_type_register_static (GTK_TYPE_CONTAINER, "GtkLayout", &layout_info);
}
return layout_type;
@@ -340,6 +342,7 @@ gtk_layout_get_type (void)
static void
gtk_layout_class_init (GtkLayoutClass *class)
{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (class);
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
GtkContainerClass *container_class;
@@ -350,7 +353,7 @@ gtk_layout_class_init (GtkLayoutClass *class)
parent_class = gtk_type_class (GTK_TYPE_CONTAINER);
- object_class->finalize = gtk_layout_finalize;
+ gobject_class->finalize = gtk_layout_finalize;
widget_class->realize = gtk_layout_realize;
widget_class->unrealize = gtk_layout_unrealize;
@@ -368,7 +371,7 @@ gtk_layout_class_init (GtkLayoutClass *class)
widget_class->set_scroll_adjustments_signal =
gtk_signal_new ("set_scroll_adjustments",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkLayoutClass, set_scroll_adjustments),
gtk_marshal_NONE__POINTER_POINTER,
GTK_TYPE_NONE, 2, GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT);
diff --git a/gtk/gtklist.c b/gtk/gtklist.c
index a114dcad75..0c532b4ed8 100644
--- a/gtk/gtklist.c
+++ b/gtk/gtklist.c
@@ -54,7 +54,7 @@ static void gtk_list_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
/** GtkObject Methods **/
-static void gtk_list_shutdown (GtkObject *object);
+static void gtk_list_shutdown (GObject *object);
/** GtkWidget Methods **/
static void gtk_list_size_request (GtkWidget *widget,
@@ -200,6 +200,7 @@ gtk_list_get_type (void)
static void
gtk_list_class_init (GtkListClass *class)
{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (class);
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
GtkContainerClass *container_class;
@@ -213,17 +214,19 @@ gtk_list_class_init (GtkListClass *class)
vadjustment_key_id = g_quark_from_static_string (vadjustment_key);
hadjustment_key_id = g_quark_from_static_string (hadjustment_key);
+ gobject_class->shutdown = gtk_list_shutdown;
+
list_signals[SELECTION_CHANGED] =
gtk_signal_new ("selection_changed",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkListClass, selection_changed),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
list_signals[SELECT_CHILD] =
gtk_signal_new ("select_child",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkListClass, select_child),
gtk_marshal_NONE__POINTER,
GTK_TYPE_NONE, 1,
@@ -231,7 +234,7 @@ gtk_list_class_init (GtkListClass *class)
list_signals[UNSELECT_CHILD] =
gtk_signal_new ("unselect_child",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkListClass, unselect_child),
gtk_marshal_NONE__POINTER,
GTK_TYPE_NONE, 1,
@@ -239,7 +242,6 @@ gtk_list_class_init (GtkListClass *class)
gtk_object_class_add_signals (object_class, list_signals, LAST_SIGNAL);
- object_class->shutdown = gtk_list_shutdown;
object_class->set_arg = gtk_list_set_arg;
object_class->get_arg = gtk_list_get_arg;
@@ -341,10 +343,11 @@ gtk_list_new (void)
* gtk_list_shutdown
*/
static void
-gtk_list_shutdown (GtkObject *object)
+gtk_list_shutdown (GObject *object)
{
gtk_list_clear_items (GTK_LIST (object), 0, -1);
- GTK_OBJECT_CLASS (parent_class)->shutdown (object);
+
+ G_OBJECT_CLASS (parent_class)->shutdown (object);
}
diff --git a/gtk/gtklistitem.c b/gtk/gtklistitem.c
index 4c215e5d26..8482cde215 100644
--- a/gtk/gtklistitem.c
+++ b/gtk/gtklistitem.c
@@ -118,56 +118,56 @@ gtk_list_item_class_init (GtkListItemClass *class)
list_item_signals[TOGGLE_FOCUS_ROW] =
gtk_signal_new ("toggle_focus_row",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkListItemClass, toggle_focus_row),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
list_item_signals[SELECT_ALL] =
gtk_signal_new ("select_all",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkListItemClass, select_all),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
list_item_signals[UNSELECT_ALL] =
gtk_signal_new ("unselect_all",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkListItemClass, unselect_all),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
list_item_signals[UNDO_SELECTION] =
gtk_signal_new ("undo_selection",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkListItemClass, undo_selection),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
list_item_signals[START_SELECTION] =
gtk_signal_new ("start_selection",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkListItemClass, start_selection),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
list_item_signals[END_SELECTION] =
gtk_signal_new ("end_selection",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkListItemClass, end_selection),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
list_item_signals[TOGGLE_ADD_MODE] =
gtk_signal_new ("toggle_add_mode",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkListItemClass, toggle_add_mode),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
list_item_signals[EXTEND_SELECTION] =
gtk_signal_new ("extend_selection",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkListItemClass, extend_selection),
gtk_marshal_NONE__ENUM_FLOAT_BOOL,
GTK_TYPE_NONE, 3,
@@ -175,14 +175,14 @@ gtk_list_item_class_init (GtkListItemClass *class)
list_item_signals[SCROLL_VERTICAL] =
gtk_signal_new ("scroll_vertical",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkListItemClass, scroll_vertical),
gtk_marshal_NONE__ENUM_FLOAT,
GTK_TYPE_NONE, 2, GTK_TYPE_ENUM, GTK_TYPE_FLOAT);
list_item_signals[SCROLL_HORIZONTAL] =
gtk_signal_new ("scroll_horizontal",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkListItemClass, scroll_horizontal),
gtk_marshal_NONE__ENUM_FLOAT,
GTK_TYPE_NONE, 2, GTK_TYPE_ENUM, GTK_TYPE_FLOAT);
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index d80dfb24c3..5eca47c7b8 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -197,7 +197,6 @@ gboolean
gtk_init_check (int *argc,
char ***argv)
{
- extern void gtk_object_post_arg_parsing_init (void);
GSList *gtk_modules = NULL;
GSList *slist;
gchar *env_string = NULL;
@@ -422,7 +421,6 @@ gtk_init_check (int *argc,
gtk_colormap = gdk_colormap_get_system ();
gtk_type_init ();
- gtk_object_post_arg_parsing_init ();
gtk_signal_init ();
gtk_rc_init ();
diff --git a/gtk/gtkmarshal.list b/gtk/gtkmarshal.list
index 92a110a033..a016dffc6d 100644
--- a/gtk/gtkmarshal.list
+++ b/gtk/gtkmarshal.list
@@ -9,8 +9,6 @@ INT:POINTER
INT:POINTER,CHAR,CHAR
NONE:BOOL
NONE:BOXED
-NONE:C_CALLBACK
-NONE:C_CALLBACK,C_CALLBACK
NONE:ENUM
NONE:ENUM,FLOAT
NONE:ENUM,FLOAT,BOOL
diff --git a/gtk/gtkmarshalers.list b/gtk/gtkmarshalers.list
index 92a110a033..a016dffc6d 100644
--- a/gtk/gtkmarshalers.list
+++ b/gtk/gtkmarshalers.list
@@ -9,8 +9,6 @@ INT:POINTER
INT:POINTER,CHAR,CHAR
NONE:BOOL
NONE:BOXED
-NONE:C_CALLBACK
-NONE:C_CALLBACK,C_CALLBACK
NONE:ENUM
NONE:ENUM,FLOAT
NONE:ENUM,FLOAT,BOOL
diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
index 15ac8813e3..f74a3255cb 100644
--- a/gtk/gtkmenu.c
+++ b/gtk/gtkmenu.c
@@ -35,7 +35,7 @@
#include "gtkwindow.h"
-#define MENU_ITEM_CLASS(w) GTK_MENU_ITEM_CLASS (GTK_OBJECT (w)->klass)
+#define MENU_ITEM_CLASS(w) GTK_MENU_ITEM_GET_CLASS (w)
#define MENU_NEEDS_RESIZE(m) GTK_MENU_SHELL (m)->menu_flag
typedef struct _GtkMenuAttachData GtkMenuAttachData;
@@ -192,20 +192,20 @@ gtk_menu_init (GtkMenu *menu)
menu->position_func = NULL;
menu->position_func_data = NULL;
- menu->toplevel = gtk_window_new (GTK_WINDOW_POPUP);
- gtk_signal_connect (GTK_OBJECT (menu->toplevel),
- "event",
- GTK_SIGNAL_FUNC (gtk_menu_window_event),
- GTK_OBJECT (menu));
+ menu->toplevel = gtk_widget_new (GTK_TYPE_WINDOW,
+ "type", GTK_WINDOW_POPUP,
+ "signal::event", gtk_menu_window_event, menu,
+ "signal::destroy", gtk_widget_destroyed, &menu->toplevel,
+ "child", menu,
+ NULL);
gtk_window_set_policy (GTK_WINDOW (menu->toplevel),
FALSE, FALSE, TRUE);
- gtk_container_add (GTK_CONTAINER (menu->toplevel), GTK_WIDGET (menu));
-
/* Refloat the menu, so that reference counting for the menu isn't
* affected by it being a child of the toplevel
*/
GTK_WIDGET_SET_FLAGS (menu, GTK_FLOATING);
+ menu->needs_destruction_ref_count = TRUE;
menu->tearoff_window = NULL;
menu->torn_off = FALSE;
@@ -214,18 +214,15 @@ gtk_menu_init (GtkMenu *menu)
}
static void
-gtk_menu_destroy (GtkObject *object)
+gtk_menu_destroy (GtkObject *object)
{
GtkMenu *menu;
GtkMenuAttachData *data;
- g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_MENU (object));
menu = GTK_MENU (object);
- gtk_object_ref (object);
-
data = gtk_object_get_data (object, attach_data_key);
if (data)
gtk_menu_detach (menu);
@@ -239,16 +236,18 @@ gtk_menu_destroy (GtkObject *object)
}
/* Add back the reference count for being a child */
- gtk_object_ref (object);
+ if (menu->needs_destruction_ref_count)
+ {
+ menu->needs_destruction_ref_count = FALSE;
+ gtk_object_ref (object);
+ }
- gtk_widget_destroy (menu->toplevel);
+ if (menu->toplevel)
+ gtk_widget_destroy (menu->toplevel);
if (menu->tearoff_window)
gtk_widget_destroy (menu->tearoff_window);
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
-
- gtk_object_unref (object);
+ GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
@@ -293,7 +292,7 @@ gtk_menu_attach_to_widget (GtkMenu *menu,
}
GtkWidget*
-gtk_menu_get_attach_widget (GtkMenu *menu)
+gtk_menu_get_attach_widget (GtkMenu *menu)
{
GtkMenuAttachData *data;
@@ -307,7 +306,7 @@ gtk_menu_get_attach_widget (GtkMenu *menu)
}
void
-gtk_menu_detach (GtkMenu *menu)
+gtk_menu_detach (GtkMenu *menu)
{
GtkMenuAttachData *data;
@@ -708,7 +707,10 @@ gtk_menu_set_tearoff_state (GtkMenu *menu,
GtkWidget *attach_widget;
gchar *title;
- menu->tearoff_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ menu->tearoff_window = gtk_widget_new (GTK_TYPE_WINDOW,
+ "type", GTK_WINDOW_TOPLEVEL,
+ "signal::destroy", gtk_widget_destroyed, &menu->tearoff_window,
+ NULL);
gtk_widget_set_app_paintable (menu->tearoff_window, TRUE);
gtk_signal_connect (GTK_OBJECT (menu->tearoff_window),
"event",
diff --git a/gtk/gtkmenu.h b/gtk/gtkmenu.h
index cd51c1e551..3a393473d3 100644
--- a/gtk/gtkmenu.h
+++ b/gtk/gtkmenu.h
@@ -74,6 +74,7 @@ struct _GtkMenu
GtkWidget *toplevel;
GtkWidget *tearoff_window;
+ guint needs_destruction_ref_count : 1;
guint torn_off : 1;
};
diff --git a/gtk/gtkmenuitem.c b/gtk/gtkmenuitem.c
index ec7efd62aa..c8e0cfd2f0 100644
--- a/gtk/gtkmenuitem.c
+++ b/gtk/gtkmenuitem.c
@@ -88,20 +88,20 @@ gtk_menu_item_get_type (void)
if (!menu_item_type)
{
- static const GtkTypeInfo menu_item_info =
+ static const GTypeInfo menu_item_info =
{
- "GtkMenuItem",
- sizeof (GtkMenuItem),
sizeof (GtkMenuItemClass),
- (GtkClassInitFunc) gtk_menu_item_class_init,
- (GtkObjectInitFunc) gtk_menu_item_init,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) gtk_menu_item_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (GtkMenuItem),
+ 16, /* n_preallocs */
+ (GInstanceInitFunc) gtk_menu_item_init,
};
- menu_item_type = gtk_type_unique (gtk_item_get_type (), &menu_item_info);
- gtk_type_set_chunk_alloc (menu_item_type, 16);
+ menu_item_type = g_type_register_static (GTK_TYPE_ITEM, "GtkMenuItem", &menu_item_info);
}
return menu_item_type;
@@ -125,7 +125,7 @@ gtk_menu_item_class_init (GtkMenuItemClass *klass)
menu_item_signals[ACTIVATE] =
gtk_signal_new ("activate",
GTK_RUN_FIRST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkMenuItemClass, activate),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
@@ -133,7 +133,7 @@ gtk_menu_item_class_init (GtkMenuItemClass *klass)
menu_item_signals[ACTIVATE_ITEM] =
gtk_signal_new ("activate_item",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkMenuItemClass, activate_item),
gtk_signal_default_marshaller,
GTK_TYPE_NONE, 0);
diff --git a/gtk/gtkmenushell.c b/gtk/gtkmenushell.c
index e60f73b4c8..b76ccf6812 100644
--- a/gtk/gtkmenushell.c
+++ b/gtk/gtkmenushell.c
@@ -34,7 +34,6 @@
#define MENU_SHELL_TIMEOUT 500
-#define MENU_SHELL_CLASS(w) GTK_MENU_SHELL_CLASS (GTK_OBJECT (w)->klass)
enum {
@@ -191,21 +190,21 @@ gtk_menu_shell_class_init (GtkMenuShellClass *klass)
menu_shell_signals[DEACTIVATE] =
gtk_signal_new ("deactivate",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkMenuShellClass, deactivate),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
menu_shell_signals[SELECTION_DONE] =
gtk_signal_new ("selection-done",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkMenuShellClass, selection_done),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
menu_shell_signals[MOVE_CURRENT] =
gtk_signal_new ("move_current",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkMenuShellClass, move_current),
gtk_marshal_NONE__ENUM,
GTK_TYPE_NONE, 1,
@@ -213,7 +212,7 @@ gtk_menu_shell_class_init (GtkMenuShellClass *klass)
menu_shell_signals[ACTIVATE_CURRENT] =
gtk_signal_new ("activate_current",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkMenuShellClass, activate_current),
gtk_marshal_NONE__BOOL,
GTK_TYPE_NONE, 1,
@@ -221,7 +220,7 @@ gtk_menu_shell_class_init (GtkMenuShellClass *klass)
menu_shell_signals[CANCEL] =
gtk_signal_new ("cancel",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkMenuShellClass, cancel),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
@@ -786,7 +785,7 @@ gtk_menu_shell_select_item (GtkMenuShell *menu_shell,
menu_shell->active_menu_item = menu_item;
gtk_menu_item_set_placement (GTK_MENU_ITEM (menu_shell->active_menu_item),
- MENU_SHELL_CLASS (menu_shell)->submenu_placement);
+ GTK_MENU_SHELL_GET_CLASS (menu_shell)->submenu_placement);
gtk_menu_item_select (GTK_MENU_ITEM (menu_shell->active_menu_item));
/* This allows the bizarre radio buttons-with-submenus-display-history
@@ -822,7 +821,7 @@ gtk_menu_shell_activate_item (GtkMenuShell *menu_shell,
g_return_if_fail (GTK_IS_MENU_ITEM (menu_item));
if (!deactivate)
- deactivate = GTK_MENU_ITEM_CLASS (GTK_OBJECT (menu_item)->klass)->hide_on_activate;
+ deactivate = GTK_MENU_ITEM_GET_CLASS (menu_item)->hide_on_activate;
gtk_widget_ref (GTK_WIDGET (menu_shell));
@@ -936,8 +935,8 @@ gtk_real_menu_shell_move_current (GtkMenuShell *menu_shell,
case GTK_MENU_DIR_PARENT:
if (parent_menu_shell)
{
- if (GTK_MENU_SHELL_CLASS (GTK_OBJECT (parent_menu_shell)->klass)->submenu_placement ==
- GTK_MENU_SHELL_CLASS (GTK_OBJECT (menu_shell)->klass)->submenu_placement)
+ if (GTK_MENU_SHELL_GET_CLASS (parent_menu_shell)->submenu_placement ==
+ GTK_MENU_SHELL_GET_CLASS (menu_shell)->submenu_placement)
gtk_menu_shell_deselect (menu_shell);
else
{
@@ -960,8 +959,8 @@ gtk_real_menu_shell_move_current (GtkMenuShell *menu_shell,
{
/* Try to find a menu running the opposite direction */
while (parent_menu_shell &&
- (GTK_MENU_SHELL_CLASS (GTK_OBJECT (parent_menu_shell)->klass)->submenu_placement ==
- GTK_MENU_SHELL_CLASS (GTK_OBJECT (menu_shell)->klass)->submenu_placement))
+ (GTK_MENU_SHELL_GET_CLASS (parent_menu_shell)->submenu_placement ==
+ GTK_MENU_SHELL_GET_CLASS (menu_shell)->submenu_placement))
parent_menu_shell = GTK_MENU_SHELL (parent_menu_shell->parent_menu_shell);
if (parent_menu_shell)
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index 676cade045..be49dc6ea2 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -271,7 +271,7 @@ gtk_notebook_class_init (GtkNotebookClass *class)
notebook_signals[SWITCH_PAGE] =
gtk_signal_new ("switch_page",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkNotebookClass, switch_page),
gtk_marshal_NONE__POINTER_UINT,
GTK_TYPE_NONE, 2,
diff --git a/gtk/gtkobject.c b/gtk/gtkobject.c
index c043561a86..887036537b 100644
--- a/gtk/gtkobject.c
+++ b/gtk/gtkobject.c
@@ -45,95 +45,60 @@ enum {
};
-void gtk_object_init_type (void);
-static void gtk_object_base_class_init (GtkObjectClass *klass);
-static void gtk_object_class_init (GtkObjectClass *klass);
-static void gtk_object_init (GtkObject *object,
+extern void gtk_object_init_type (void); /* for gtktypeutils.h */
+static void gtk_object_base_class_init (GtkObjectClass *class);
+static void gtk_object_base_class_finalize (GtkObjectClass *class);
+static void gtk_object_class_init (GtkObjectClass *klass);
+static void gtk_object_init (GtkObject *object,
GtkObjectClass *klass);
-static void gtk_object_set_arg (GtkObject *object,
+static void gtk_object_set_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
-static void gtk_object_get_arg (GtkObject *object,
+static void gtk_object_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
-static void gtk_object_shutdown (GtkObject *object);
-static void gtk_object_real_destroy (GtkObject *object);
-static void gtk_object_finalize (GtkObject *object);
-static void gtk_object_notify_weaks (GtkObject *object);
-
-static guint object_signals[LAST_SIGNAL] = { 0 };
+static void gtk_object_shutdown (GObject *object);
+static void gtk_object_real_destroy (GtkObject *object);
+static void gtk_object_finalize (GObject *object);
+static void gtk_object_notify_weaks (GtkObject *object);
+static gpointer parent_class = NULL;
+static guint object_signals[LAST_SIGNAL] = { 0 };
static GHashTable *object_arg_info_ht = NULL;
+static GQuark quark_user_data = 0;
+static GQuark quark_weakrefs = 0;
+static GQuark quark_carg_history = 0;
-static GQuark quark_user_data = 0;
-static GQuark quark_weakrefs = 0;
-static GQuark quark_carg_history = 0;
-
-
-#ifdef G_ENABLE_DEBUG
-static guint obj_count = 0;
-static GHashTable *living_objs_ht = NULL;
-static void
-gtk_object_debug_foreach (gpointer key, gpointer value, gpointer user_data)
-{
- GtkObject *object;
-
- object = (GtkObject*) value;
- g_message ("[%p] %s\tref_count=%d%s%s",
- object,
- gtk_type_name (GTK_OBJECT_TYPE (object)),
- object->ref_count,
- GTK_OBJECT_FLOATING (object) ? " (floating)" : "",
- GTK_OBJECT_DESTROYED (object) ? " (destroyed)" : "");
-}
-static void
-gtk_object_debug (void)
-{
- if (living_objs_ht)
- g_hash_table_foreach (living_objs_ht, gtk_object_debug_foreach, NULL);
-
- g_message ("living objects count = %d", obj_count);
-}
-#endif /* G_ENABLE_DEBUG */
-
-void
-gtk_object_post_arg_parsing_init (void)
-{
-#ifdef G_ENABLE_DEBUG
- if (gtk_debug_flags & GTK_DEBUG_OBJECTS)
- g_atexit (gtk_object_debug);
-#endif /* G_ENABLE_DEBUG */
-}
/****************************************************
* GtkObject type, class and instance initialization
*
****************************************************/
-void
-gtk_object_init_type (void)
-{
- static const GtkTypeInfo object_info =
- {
- "GtkObject",
- sizeof (GtkObject),
- sizeof (GtkObjectClass),
- (GtkClassInitFunc) gtk_object_class_init,
- (GtkObjectInitFunc) gtk_object_init,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) gtk_object_base_class_init,
- };
- GtkType object_type;
-
- object_type = gtk_type_unique (0, &object_info);
- g_assert (object_type == GTK_TYPE_OBJECT);
-}
-
GtkType
gtk_object_get_type (void)
{
- return GTK_TYPE_OBJECT;
+ static GtkType object_type = 0;
+
+ if (!object_type)
+ {
+ static const GTypeInfo object_info =
+ {
+ sizeof (GtkObjectClass),
+ (GBaseInitFunc) gtk_object_base_class_init,
+ (GBaseFinalizeFunc) gtk_object_base_class_finalize,
+ (GClassInitFunc) gtk_object_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (GtkObject),
+ 16, /* n_preallocs */
+ (GInstanceInitFunc) gtk_object_init,
+ };
+
+ object_type = g_type_register_static (G_TYPE_OBJECT, "GtkObject", &object_info);
+ }
+
+ return object_type;
}
static void
@@ -151,8 +116,26 @@ gtk_object_base_class_init (GtkObjectClass *class)
}
static void
+gtk_object_base_class_finalize (GtkObjectClass *class)
+{
+ g_free (class->signals);
+ g_return_if_fail (class->construct_args == NULL);
+}
+
+static void
gtk_object_class_init (GtkObjectClass *class)
{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (class);
+
+ parent_class = g_type_class_ref (G_TYPE_OBJECT);
+
+ gobject_class->shutdown = gtk_object_shutdown;
+ gobject_class->finalize = gtk_object_finalize;
+
+ class->get_arg = gtk_object_get_arg;
+ class->set_arg = gtk_object_set_arg;
+ class->destroy = gtk_object_real_destroy;
+
quark_carg_history = g_quark_from_static_string ("gtk-construct-arg-history");
gtk_object_add_arg_type ("GtkObject::user_data",
@@ -179,18 +162,12 @@ gtk_object_class_init (GtkObjectClass *class)
object_signals[DESTROY] =
gtk_signal_new ("destroy",
GTK_RUN_LAST | GTK_RUN_NO_HOOKS,
- class->type,
+ GTK_CLASS_TYPE (class),
GTK_SIGNAL_OFFSET (GtkObjectClass, destroy),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
gtk_object_class_add_signals (class, object_signals, LAST_SIGNAL);
-
- class->get_arg = gtk_object_get_arg;
- class->set_arg = gtk_object_set_arg;
- class->shutdown = gtk_object_shutdown;
- class->destroy = gtk_object_real_destroy;
- class->finalize = gtk_object_finalize;
}
static void
@@ -203,26 +180,11 @@ gtk_object_init (GtkObject *object,
do
{
needs_construction |= klass->construct_args != NULL;
- klass = gtk_type_parent_class (klass->type);
+ klass = g_type_class_peek_parent (klass);
}
while (klass && !needs_construction);
if (!needs_construction)
GTK_OBJECT_FLAGS (object) |= GTK_CONSTRUCTED;
-
- object->ref_count = 1;
- g_datalist_init (&object->object_data);
-
-#ifdef G_ENABLE_DEBUG
- if (gtk_debug_flags & GTK_DEBUG_OBJECTS)
- {
- obj_count++;
-
- if (!living_objs_ht)
- living_objs_ht = g_hash_table_new (g_direct_hash, NULL);
-
- g_hash_table_insert (living_objs_ht, object, object);
- }
-#endif /* G_ENABLE_DEBUG */
}
/********************************************
@@ -238,21 +200,26 @@ gtk_object_destroy (GtkObject *object)
if (!GTK_OBJECT_DESTROYED (object))
{
- /* we will hold a reference on the object in this place, so
- * to ease all classes shutdown and destroy implementations.
- * i.e. they don't have to bother about referencing at all.
+ /* need to hold a reference count around all class method
+ * invocations. we guard against reinvocations during
+ * destruction with the GTK_DESTROYED flag.
*/
gtk_object_ref (object);
- object->klass->shutdown (object);
+ GTK_OBJECT_SET_FLAGS (object, GTK_DESTROYED);
+ G_OBJECT_GET_CLASS (object)->shutdown (G_OBJECT (object));
+ GTK_OBJECT_UNSET_FLAGS (object, GTK_DESTROYED);
gtk_object_unref (object);
}
}
static void
-gtk_object_shutdown (GtkObject *object)
+gtk_object_shutdown (GObject *gobject)
{
- GTK_OBJECT_SET_FLAGS (object, GTK_DESTROYED);
+ GtkObject *object = GTK_OBJECT (gobject);
+
gtk_signal_emit (object, object_signals[DESTROY]);
+
+ G_OBJECT_CLASS (parent_class)->shutdown (gobject);
}
static void
@@ -263,13 +230,13 @@ gtk_object_real_destroy (GtkObject *object)
}
static void
-gtk_object_finalize (GtkObject *object)
+gtk_object_finalize (GObject *gobject)
{
- gtk_object_notify_weaks (object);
+ GtkObject *object = GTK_OBJECT (gobject);
- g_datalist_clear (&object->object_data);
+ gtk_object_notify_weaks (object);
- gtk_type_free (GTK_OBJECT_TYPE (object), object);
+ G_OBJECT_CLASS (parent_class)->finalize (gobject);
}
/*****************************************
@@ -396,7 +363,7 @@ gtk_object_class_user_signal_new (GtkObjectClass *class,
signal_id = gtk_signal_newv (name,
signal_flags,
- class->type,
+ GTK_CLASS_TYPE (class),
0,
marshaller,
return_val,
@@ -429,7 +396,7 @@ gtk_object_class_user_signal_newv (GtkObjectClass *class,
signal_id = gtk_signal_newv (name,
signal_flags,
- class->type,
+ GTK_CLASS_TYPE (class),
0,
marshaller,
return_val,
@@ -576,7 +543,7 @@ gtk_object_new (GtkType object_type,
GSList *info_list = NULL;
gchar *error;
- g_return_val_if_fail (GTK_FUNDAMENTAL_TYPE (object_type) == GTK_TYPE_OBJECT, NULL);
+ g_return_val_if_fail (GTK_TYPE_IS_OBJECT (object_type), NULL);
object = gtk_type_new (object_type);
@@ -623,7 +590,7 @@ gtk_object_newv (GtkType object_type,
GtkObject *object;
GtkArg *max_args;
- g_return_val_if_fail (GTK_FUNDAMENTAL_TYPE (object_type) == GTK_TYPE_OBJECT, NULL);
+ g_return_val_if_fail (GTK_TYPE_IS_OBJECT (object_type), NULL);
if (n_args)
g_return_val_if_fail (args != NULL, NULL);
@@ -872,7 +839,7 @@ gtk_object_default_construct (GtkObject *object)
if (!GTK_OBJECT_CONSTRUCTED (object))
{
- for (slist = object->klass->construct_args;
+ for (slist = GTK_OBJECT_GET_CLASS (object)->construct_args;
slist && !GTK_OBJECT_CONSTRUCTED (object);
slist = slist->next)
{
@@ -888,7 +855,7 @@ gtk_object_default_construct (GtkObject *object)
/* default application */
arg.type = info->type;
arg.name = info->name;
- switch (gtk_type_get_varargs_type (arg.type))
+ switch (G_TYPE_FUNDAMENTAL (arg.type))
{
case GTK_TYPE_FLOAT:
GTK_VALUE_FLOAT (arg) = 0.0;
@@ -899,7 +866,7 @@ gtk_object_default_construct (GtkObject *object)
case GTK_TYPE_BOXED:
case GTK_TYPE_STRING:
case GTK_TYPE_POINTER:
- case GTK_TYPE_OBJECT:
+ case G_TYPE_OBJECT:
GTK_VALUE_POINTER (arg) = NULL;
break;
default:
@@ -1004,7 +971,7 @@ gtk_object_query_args (GtkType class_type,
{
g_return_val_if_fail (n_args != NULL, NULL);
*n_args = 0;
- g_return_val_if_fail (GTK_FUNDAMENTAL_TYPE (class_type) == GTK_TYPE_OBJECT, NULL);
+ g_return_val_if_fail (GTK_TYPE_IS_OBJECT (class_type), NULL);
return gtk_args_query (class_type, object_arg_info_ht, arg_flags, n_args);
}
@@ -1019,10 +986,9 @@ gtk_object_set_data_by_id (GtkObject *object,
GQuark data_id,
gpointer data)
{
- g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_OBJECT (object));
- g_datalist_id_set_data (&object->object_data, data_id, data);
+ g_datalist_id_set_data (&G_OBJECT (object)->qdata, data_id, data);
}
void
@@ -1030,11 +996,10 @@ gtk_object_set_data (GtkObject *object,
const gchar *key,
gpointer data)
{
- g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_OBJECT (object));
g_return_if_fail (key != NULL);
- g_datalist_set_data (&object->object_data, key, data);
+ g_datalist_set_data (&G_OBJECT (object)->qdata, key, data);
}
void
@@ -1043,10 +1008,9 @@ gtk_object_set_data_by_id_full (GtkObject *object,
gpointer data,
GtkDestroyNotify destroy)
{
- g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_OBJECT (object));
- g_datalist_id_set_data_full (&object->object_data, data_id, data, destroy);
+ g_datalist_id_set_data_full (&G_OBJECT (object)->qdata, data_id, data, destroy);
}
void
@@ -1055,186 +1019,101 @@ gtk_object_set_data_full (GtkObject *object,
gpointer data,
GtkDestroyNotify destroy)
{
- g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_OBJECT (object));
g_return_if_fail (key != NULL);
- g_datalist_set_data_full (&object->object_data, key, data, destroy);
+ g_datalist_set_data_full (&G_OBJECT (object)->qdata, key, data, destroy);
}
gpointer
gtk_object_get_data_by_id (GtkObject *object,
GQuark data_id)
{
- g_return_val_if_fail (object != NULL, NULL);
g_return_val_if_fail (GTK_IS_OBJECT (object), NULL);
- return g_datalist_id_get_data (&object->object_data, data_id);
+ return g_datalist_id_get_data (&G_OBJECT (object)->qdata, data_id);
}
gpointer
gtk_object_get_data (GtkObject *object,
const gchar *key)
{
- g_return_val_if_fail (object != NULL, NULL);
g_return_val_if_fail (GTK_IS_OBJECT (object), NULL);
g_return_val_if_fail (key != NULL, NULL);
- return g_datalist_get_data (&object->object_data, key);
+ return g_datalist_get_data (&G_OBJECT (object)->qdata, key);
}
void
gtk_object_remove_data_by_id (GtkObject *object,
GQuark data_id)
{
- g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_OBJECT (object));
- g_datalist_id_remove_data (&object->object_data, data_id);
+ g_datalist_id_remove_data (&G_OBJECT (object)->qdata, data_id);
}
void
gtk_object_remove_data (GtkObject *object,
const gchar *key)
{
- g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_OBJECT (object));
g_return_if_fail (key != NULL);
- g_datalist_remove_data (&object->object_data, key);
+ g_datalist_remove_data (&G_OBJECT (object)->qdata, key);
}
void
gtk_object_remove_no_notify_by_id (GtkObject *object,
GQuark key_id)
{
- g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_OBJECT (object));
- g_datalist_id_remove_no_notify (&object->object_data, key_id);
+ g_datalist_id_remove_no_notify (&G_OBJECT (object)->qdata, key_id);
}
void
gtk_object_remove_no_notify (GtkObject *object,
const gchar *key)
{
- g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_OBJECT (object));
g_return_if_fail (key != NULL);
- g_datalist_remove_no_notify (&object->object_data, key);
+ g_datalist_remove_no_notify (&G_OBJECT (object)->qdata, key);
}
void
gtk_object_set_user_data (GtkObject *object,
gpointer data)
{
- g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_OBJECT (object));
if (!quark_user_data)
quark_user_data = g_quark_from_static_string ("user_data");
- g_datalist_id_set_data (&object->object_data, quark_user_data, data);
+ g_datalist_id_set_data (&G_OBJECT (object)->qdata, quark_user_data, data);
}
gpointer
gtk_object_get_user_data (GtkObject *object)
{
- g_return_val_if_fail (object != NULL, NULL);
g_return_val_if_fail (GTK_IS_OBJECT (object), NULL);
- return g_datalist_id_get_data (&object->object_data, quark_user_data);
+ return g_datalist_id_get_data (&G_OBJECT (object)->qdata, quark_user_data);
}
-/*******************************************
- * GtkObject referencing and unreferencing
- *
- *******************************************/
-
-#undef gtk_object_ref
-#undef gtk_object_unref
-
-void
+GtkObject*
gtk_object_ref (GtkObject *object)
{
- g_return_if_fail (object != NULL);
- g_return_if_fail (GTK_IS_OBJECT (object));
- g_return_if_fail (object->ref_count > 0);
+ g_return_val_if_fail (GTK_IS_OBJECT (object), NULL);
- object->ref_count += 1;
+ return (GtkObject*) g_object_ref ((GObject*) object);
}
void
gtk_object_unref (GtkObject *object)
{
- g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_OBJECT (object));
- g_return_if_fail (object->ref_count > 0);
-
- if (object->ref_count == 1)
- {
- gtk_object_destroy (object);
-
- g_return_if_fail (object->ref_count > 0);
- }
-
- object->ref_count -= 1;
-
- if (object->ref_count == 0)
- {
-#ifdef G_ENABLE_DEBUG
- if (gtk_debug_flags & GTK_DEBUG_OBJECTS)
- {
- g_assert (g_hash_table_lookup (living_objs_ht, object) == object);
- g_hash_table_remove (living_objs_ht, object);
- obj_count--;
- }
-#endif /* G_ENABLE_DEBUG */
- object->klass->finalize (object);
- }
-}
-
-static GtkObject *gtk_trace_object = NULL;
-void
-gtk_trace_referencing (GtkObject *object,
- const gchar *func,
- guint dummy,
- guint line,
- gboolean do_ref)
-{
- if (gtk_debug_flags & GTK_DEBUG_OBJECTS)
- {
- gboolean exists = TRUE;
- g_return_if_fail (object != NULL);
- g_return_if_fail (GTK_IS_OBJECT (object));
-
-#ifdef G_ENABLE_DEBUG
- exists = g_hash_table_lookup (living_objs_ht, object) != NULL;
-#endif /* G_ENABLE_DEBUG */
-
- if (exists &&
- (object == gtk_trace_object ||
- gtk_trace_object == (void*)42))
- fprintf (stdout, "trace: object_%s: (%s:%p)->ref_count=%d %s (%s:%d)\n",
- do_ref ? "ref" : "unref",
- gtk_type_name (GTK_OBJECT_TYPE (object)),
- object,
- object->ref_count,
- do_ref ? "+ 1" : "- 1",
- func,
- line);
- else if (!exists)
- fprintf (stdout, "trace: object_%s(%p): no such object! (%s:%d)\n",
- do_ref ? "ref" : "unref",
- object,
- func,
- line);
- }
-
- if (do_ref)
- gtk_object_ref (object);
- else
- gtk_object_unref (object);
+ g_object_unref ((GObject*) object);
}
diff --git a/gtk/gtkobject.h b/gtk/gtkobject.h
index b2515cd32e..f1af29d662 100644
--- a/gtk/gtkobject.h
+++ b/gtk/gtkobject.h
@@ -39,38 +39,21 @@ extern "C" {
#endif /* __cplusplus */
-
-/* Macro for casting a pointer to a GtkObject or GtkObjectClass pointer.
- * The second portion of the ?: statments are just in place to offer
- * descriptive warning message.
- */
-#define GTK_OBJECT(object) ( \
- GTK_IS_OBJECT (object) ? \
- (GtkObject*) (object) : \
- (GtkObject*) gtk_type_check_object_cast ((GtkTypeObject*) (object), GTK_TYPE_OBJECT) \
-)
-#define GTK_OBJECT_CLASS(klass) ( \
- GTK_IS_OBJECT_CLASS (klass) ? \
- (GtkObjectClass*) (klass) : \
- (GtkObjectClass*) gtk_type_check_class_cast ((GtkTypeClass*) (klass), GTK_TYPE_OBJECT) \
-)
-
-/* Macro for testing whether `object' and `klass' are of type GTK_TYPE_OBJECT.
+/* macros for casting a pointer to a GtkObject or GtkObjectClass pointer,
+ * and to test whether `object' and `klass' are of type GTK_TYPE_OBJECT.
+ * these are the standard macros for all GtkObject-derived classes.
*/
-#define GTK_IS_OBJECT(object) ( \
- (object) != NULL && \
- GTK_IS_OBJECT_CLASS (((GtkObject*) (object))->klass) \
-)
-#define GTK_IS_OBJECT_CLASS(klass) ( \
- (klass) != NULL && \
- GTK_FUNDAMENTAL_TYPE (((GtkObjectClass*) (klass))->type) == GTK_TYPE_OBJECT \
-)
+#define GTK_TYPE_OBJECT (gtk_object_get_type ())
+#define GTK_OBJECT(object) (GTK_CHECK_CAST ((object), GTK_TYPE_OBJECT, GtkObject))
+#define GTK_OBJECT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_OBJECT, GtkObjectClass))
+#define GTK_IS_OBJECT(object) (GTK_CHECK_TYPE ((object), GTK_TYPE_OBJECT))
+#define GTK_IS_OBJECT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_OBJECT))
+#define GTK_OBJECT_GET_CLASS(object) (GTK_CHECK_GET_CLASS ((object), GTK_TYPE_OBJECT, GtkObjectClass))
/* Macros for extracting various fields from GtkObject and 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)
+#define GTK_OBJECT_TYPE(object) (G_TYPE_FROM_INSTANCE (object))
+#define GTK_OBJECT_TYPE_NAME(object) (g_type_name (GTK_OBJECT_TYPE (object)))
/* GtkObject only uses the first 4 bits of the flags field.
* Derived objects may use the remaining bits. Though this
@@ -124,9 +107,7 @@ typedef struct _GtkObjectClass GtkObjectClass;
*/
struct _GtkObject
{
- /* GtkTypeObject related fields: */
- GtkObjectClass *klass;
-
+ GObject parent_instance;
/* 32 bits of flags. GtkObject only uses 4 of these bits and
* GtkWidget uses the rest. This is done because structs are
@@ -134,16 +115,6 @@ struct _GtkObject
* used in GtkWidget much space would be wasted.
*/
guint32 flags;
-
- /* reference count.
- * refer to the file docs/refcounting.txt on this issue.
- */
- guint ref_count;
-
- /* A list of keyed data pointers, used for e.g. the list of signal
- * handlers or an object's user_data.
- */
- GData *object_data;
};
/* The GtkObjectClass is the base of the Gtk+ objects classes hierarchy,
@@ -155,9 +126,7 @@ struct _GtkObject
*/
struct _GtkObjectClass
{
- /* GtkTypeClass fields: */
- GtkType type;
-
+ GObjectClass parent_class;
/* The signals this object class handles. "signals" is an
* array of signal ID's.
@@ -181,7 +150,7 @@ struct _GtkObjectClass
GtkArg *arg,
guint arg_id);
- /* The functions that will end an objects life time. In one way ore
+ /* The function that will end an objects life time. In one way ore
* another all three of them are defined for all objects. If an
* object class overrides one of the methods in order to perform class
* specific destruction then it must still invoke its superclass'
@@ -189,10 +158,7 @@ struct _GtkObjectClass
* own cleanup. (See the destroy function for GtkWidget for
* an example of how to do this).
*/
- void (* shutdown) (GtkObject *object);
void (* destroy) (GtkObject *object);
-
- void (* finalize) (GtkObject *object);
};
@@ -222,11 +188,11 @@ GtkObject* gtk_object_new (GtkType type,
GtkObject* gtk_object_newv (GtkType object_type,
guint n_args,
GtkArg *args);
+GtkObject* gtk_object_ref (GtkObject *object);
+void gtk_object_unref (GtkObject *object);
void gtk_object_default_construct (GtkObject *object);
void gtk_object_constructed (GtkObject *object);
void gtk_object_sink (GtkObject *object);
-void gtk_object_ref (GtkObject *object);
-void gtk_object_unref (GtkObject *object);
void gtk_object_weakref (GtkObject *object,
GtkDestroyNotify notify,
gpointer data);
@@ -358,16 +324,6 @@ gchar* gtk_object_args_collect (GtkType object_type,
gchar* gtk_object_arg_get_info (GtkType object_type,
const gchar *arg_name,
GtkArgInfo **info_p);
-void gtk_trace_referencing (GtkObject *object,
- const gchar *func,
- guint dummy,
- guint line,
- gboolean do_ref);
-#if G_ENABLE_DEBUG
-# define gtk_object_ref(o) G_STMT_START{gtk_trace_referencing((o),G_GNUC_PRETTY_FUNCTION,0,__LINE__,1);}G_STMT_END
-# define gtk_object_unref(o) G_STMT_START{gtk_trace_referencing((o),G_GNUC_PRETTY_FUNCTION,0,__LINE__,0);}G_STMT_END
-#endif /* G_ENABLE_DEBUG */
-
diff --git a/gtk/gtkpixmap.c b/gtk/gtkpixmap.c
index f095454d37..94605e707d 100644
--- a/gtk/gtkpixmap.c
+++ b/gtk/gtkpixmap.c
@@ -35,7 +35,7 @@ static void gtk_pixmap_class_init (GtkPixmapClass *klass);
static void gtk_pixmap_init (GtkPixmap *pixmap);
static gint gtk_pixmap_expose (GtkWidget *widget,
GdkEventExpose *event);
-static void gtk_pixmap_finalize (GtkObject *object);
+static void gtk_pixmap_finalize (GObject *object);
static void build_insensitive_pixmap (GtkPixmap *gtkpixmap);
static GtkWidgetClass *parent_class;
@@ -68,6 +68,7 @@ gtk_pixmap_get_type (void)
static void
gtk_pixmap_class_init (GtkPixmapClass *class)
{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (class);
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
@@ -75,7 +76,8 @@ gtk_pixmap_class_init (GtkPixmapClass *class)
widget_class = (GtkWidgetClass*) class;
parent_class = gtk_type_class (gtk_widget_get_type ());
- object_class->finalize = gtk_pixmap_finalize;
+ gobject_class->finalize = gtk_pixmap_finalize;
+
widget_class->expose_event = gtk_pixmap_expose;
}
@@ -105,10 +107,11 @@ gtk_pixmap_new (GdkPixmap *val,
}
static void
-gtk_pixmap_finalize (GtkObject *object)
+gtk_pixmap_finalize (GObject *object)
{
gtk_pixmap_set (GTK_PIXMAP (object), NULL, NULL);
- (* GTK_OBJECT_CLASS (parent_class)->finalize) (object);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
void
diff --git a/gtk/gtkplug.c b/gtk/gtkplug.c
index 116e8e35fa..3329218f6e 100644
--- a/gtk/gtkplug.c
+++ b/gtk/gtkplug.c
@@ -64,18 +64,20 @@ gtk_plug_get_type ()
if (!plug_type)
{
- static const GtkTypeInfo plug_info =
+ static const GTypeInfo plug_info =
{
- "GtkPlug",
- sizeof (GtkPlug),
sizeof (GtkPlugClass),
- (GtkClassInitFunc) gtk_plug_class_init,
- (GtkObjectInitFunc) gtk_plug_init,
- (GtkArgSetFunc) NULL,
- (GtkArgGetFunc) NULL
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) gtk_plug_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (GtkPlug),
+ 16, /* n_preallocs */
+ (GInstanceInitFunc) gtk_plug_init,
};
- plug_type = gtk_type_unique (GTK_TYPE_WINDOW, &plug_info);
+ plug_type = g_type_register_static (GTK_TYPE_WINDOW, "GtkPlug", &plug_info);
}
return plug_type;
diff --git a/gtk/gtkpreview.c b/gtk/gtkpreview.c
index 39d2618a0f..0d323c475a 100644
--- a/gtk/gtkpreview.c
+++ b/gtk/gtkpreview.c
@@ -53,7 +53,7 @@ static void gtk_preview_set_arg (GtkObject *object,
static void gtk_preview_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
-static void gtk_preview_finalize (GtkObject *object);
+static void gtk_preview_finalize (GObject *object);
static void gtk_preview_realize (GtkWidget *widget);
static void gtk_preview_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
@@ -95,6 +95,7 @@ gtk_preview_get_type (void)
static void
gtk_preview_class_init (GtkPreviewClass *klass)
{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
@@ -104,9 +105,10 @@ gtk_preview_class_init (GtkPreviewClass *klass)
parent_class = gtk_type_class (GTK_TYPE_WIDGET);
preview_class = klass;
+ gobject_class->finalize = gtk_preview_finalize;
+
object_class->set_arg = gtk_preview_set_arg;
object_class->get_arg = gtk_preview_get_arg;
- object_class->finalize = gtk_preview_finalize;
widget_class->realize = gtk_preview_realize;
widget_class->size_allocate = gtk_preview_size_allocate;
@@ -438,11 +440,10 @@ gtk_preview_get_info (void)
static void
-gtk_preview_finalize (GtkObject *object)
+gtk_preview_finalize (GObject *object)
{
GtkPreview *preview;
- g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_PREVIEW (object));
preview = GTK_PREVIEW (object);
@@ -450,7 +451,7 @@ gtk_preview_finalize (GtkObject *object)
g_free (preview->buffer);
preview->type = (GtkPreviewType) -1;
- (* GTK_OBJECT_CLASS (parent_class)->finalize) (object);
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
diff --git a/gtk/gtkprogress.c b/gtk/gtkprogress.c
index 8129bb41ce..44ed4f4e89 100644
--- a/gtk/gtkprogress.c
+++ b/gtk/gtkprogress.c
@@ -50,7 +50,7 @@ static void gtk_progress_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void gtk_progress_destroy (GtkObject *object);
-static void gtk_progress_finalize (GtkObject *object);
+static void gtk_progress_finalize (GObject *object);
static void gtk_progress_realize (GtkWidget *widget);
static gint gtk_progress_expose (GtkWidget *widget,
GdkEventExpose *event);
@@ -90,6 +90,7 @@ gtk_progress_get_type (void)
static void
gtk_progress_class_init (GtkProgressClass *class)
{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (class);
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
@@ -97,6 +98,21 @@ gtk_progress_class_init (GtkProgressClass *class)
widget_class = (GtkWidgetClass *) class;
parent_class = gtk_type_class (GTK_TYPE_WIDGET);
+ gobject_class->finalize = gtk_progress_finalize;
+
+ object_class->set_arg = gtk_progress_set_arg;
+ object_class->get_arg = gtk_progress_get_arg;
+ object_class->destroy = gtk_progress_destroy;
+
+ widget_class->realize = gtk_progress_realize;
+ widget_class->expose_event = gtk_progress_expose;
+ widget_class->size_allocate = gtk_progress_size_allocate;
+
+ /* to be overridden */
+ class->paint = NULL;
+ class->update = NULL;
+ class->act_mode_enter = NULL;
+
gtk_object_add_arg_type ("GtkProgress::activity_mode",
GTK_TYPE_BOOL,
GTK_ARG_READWRITE,
@@ -113,20 +129,6 @@ gtk_progress_class_init (GtkProgressClass *class)
GTK_TYPE_FLOAT,
GTK_ARG_READWRITE,
ARG_TEXT_YALIGN);
-
- object_class->set_arg = gtk_progress_set_arg;
- object_class->get_arg = gtk_progress_get_arg;
- object_class->destroy = gtk_progress_destroy;
- object_class->finalize = gtk_progress_finalize;
-
- widget_class->realize = gtk_progress_realize;
- widget_class->expose_event = gtk_progress_expose;
- widget_class->size_allocate = gtk_progress_size_allocate;
-
- /* to be overridden */
- class->paint = NULL;
- class->update = NULL;
- class->act_mode_enter = NULL;
}
static void
@@ -245,32 +247,32 @@ gtk_progress_destroy (GtkObject *object)
progress = GTK_PROGRESS (object);
if (progress->adjustment)
- gtk_signal_disconnect_by_data (GTK_OBJECT (progress->adjustment),
- progress);
+ {
+ gtk_signal_disconnect_by_data (GTK_OBJECT (progress->adjustment),
+ progress);
+ gtk_object_unref (GTK_OBJECT (progress->adjustment));
+ progress->adjustment = NULL;
+ }
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
static void
-gtk_progress_finalize (GtkObject *object)
+gtk_progress_finalize (GObject *object)
{
GtkProgress *progress;
- g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_PROGRESS (object));
progress = GTK_PROGRESS (object);
- if (progress->adjustment)
- gtk_object_unref (GTK_OBJECT (GTK_PROGRESS (object)->adjustment));
-
if (progress->offscreen_pixmap)
gdk_pixmap_unref (progress->offscreen_pixmap);
if (progress->format)
g_free (progress->format);
- GTK_OBJECT_CLASS (parent_class)->finalize (object);
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static gint
@@ -332,7 +334,7 @@ gtk_progress_create_pixmap (GtkProgress *progress)
widget->allocation.width,
widget->allocation.height,
-1);
- GTK_PROGRESS_CLASS (GTK_OBJECT (progress)->klass)->paint (progress);
+ GTK_PROGRESS_GET_CLASS (progress)->paint (progress);
}
}
@@ -340,7 +342,7 @@ static void
gtk_progress_value_changed (GtkAdjustment *adjustment,
GtkProgress *progress)
{
- GTK_PROGRESS_CLASS (GTK_OBJECT (progress)->klass)->update (progress);
+ GTK_PROGRESS_GET_CLASS (progress)->update (progress);
}
static gchar *
@@ -495,6 +497,8 @@ gtk_progress_configure (GtkProgress *progress,
g_return_if_fail (min <= max);
g_return_if_fail (value >= min && value <= max);
+ if (!progress->adjustment)
+ gtk_progress_set_adjustment (progress, NULL);
adj = progress->adjustment;
if (fabs (adj->lower - min) > EPSILON || fabs (adj->upper - max) > EPSILON)
@@ -517,6 +521,8 @@ gtk_progress_set_percentage (GtkProgress *progress,
g_return_if_fail (GTK_IS_PROGRESS (progress));
g_return_if_fail (percentage >= 0 && percentage <= 1.0);
+ if (!progress->adjustment)
+ gtk_progress_set_adjustment (progress, NULL);
gtk_progress_set_value (progress, progress->adjustment->lower + percentage *
(progress->adjustment->upper - progress->adjustment->lower));
}
@@ -527,8 +533,11 @@ gtk_progress_get_current_percentage (GtkProgress *progress)
g_return_val_if_fail (progress != NULL, 0);
g_return_val_if_fail (GTK_IS_PROGRESS (progress), 0);
- return (progress->adjustment->value - progress->adjustment->lower) /
- (progress->adjustment->upper - progress->adjustment->lower);
+ if (!progress->adjustment)
+ gtk_progress_set_adjustment (progress, NULL);
+
+ return ((progress->adjustment->value - progress->adjustment->lower) /
+ (progress->adjustment->upper - progress->adjustment->lower));
}
gfloat
@@ -538,6 +547,9 @@ gtk_progress_get_percentage_from_value (GtkProgress *progress,
g_return_val_if_fail (progress != NULL, 0);
g_return_val_if_fail (GTK_IS_PROGRESS (progress), 0);
+ if (!progress->adjustment)
+ gtk_progress_set_adjustment (progress, NULL);
+
if (value >= progress->adjustment->lower &&
value <= progress->adjustment->upper)
return (value - progress->adjustment->lower) /
@@ -553,6 +565,9 @@ gtk_progress_set_value (GtkProgress *progress,
g_return_if_fail (progress != NULL);
g_return_if_fail (GTK_IS_PROGRESS (progress));
+ if (!progress->adjustment)
+ gtk_progress_set_adjustment (progress, NULL);
+
if (fabs (progress->adjustment->value - value) > EPSILON)
gtk_adjustment_set_value (progress->adjustment, value);
}
@@ -563,7 +578,7 @@ gtk_progress_get_value (GtkProgress *progress)
g_return_val_if_fail (progress != NULL, 0);
g_return_val_if_fail (GTK_IS_PROGRESS (progress), 0);
- return progress->adjustment->value;
+ return progress->adjustment ? progress->adjustment->value : 0;
}
void
@@ -626,8 +641,11 @@ gtk_progress_get_current_text (GtkProgress *progress)
g_return_val_if_fail (progress != NULL, 0);
g_return_val_if_fail (GTK_IS_PROGRESS (progress), 0);
+ if (!progress->adjustment)
+ gtk_progress_set_adjustment (progress, NULL);
+
return gtk_progress_build_string (progress, progress->adjustment->value,
- gtk_progress_get_current_percentage (progress));
+ gtk_progress_get_current_percentage (progress));
}
gchar *
@@ -637,8 +655,11 @@ gtk_progress_get_text_from_value (GtkProgress *progress,
g_return_val_if_fail (progress != NULL, 0);
g_return_val_if_fail (GTK_IS_PROGRESS (progress), 0);
+ if (!progress->adjustment)
+ gtk_progress_set_adjustment (progress, NULL);
+
return gtk_progress_build_string (progress, value,
- gtk_progress_get_percentage_from_value (progress, value));
+ gtk_progress_get_percentage_from_value (progress, value));
}
void
@@ -653,8 +674,7 @@ gtk_progress_set_activity_mode (GtkProgress *progress,
progress->activity_mode = (activity_mode != 0);
if (progress->activity_mode)
- GTK_PROGRESS_CLASS
- (GTK_OBJECT (progress)->klass)->act_mode_enter (progress);
+ GTK_PROGRESS_GET_CLASS (progress)->act_mode_enter (progress);
if (GTK_WIDGET_DRAWABLE (GTK_WIDGET (progress)))
gtk_widget_queue_resize (GTK_WIDGET (progress));
diff --git a/gtk/gtkprogressbar.c b/gtk/gtkprogressbar.c
index 1905f31a86..c0e9af2028 100644
--- a/gtk/gtkprogressbar.c
+++ b/gtk/gtkprogressbar.c
@@ -108,7 +108,7 @@ gtk_progress_bar_class_init (GtkProgressBarClass *class)
gtk_object_add_arg_type ("GtkProgressBar::adjustment",
GTK_TYPE_ADJUSTMENT,
- GTK_ARG_READWRITE | GTK_ARG_CONSTRUCT,
+ GTK_ARG_READWRITE,
ARG_ADJUSTMENT);
gtk_object_add_arg_type ("GtkProgressBar::orientation",
GTK_TYPE_PROGRESS_BAR_ORIENTATION,
diff --git a/gtk/gtkradiobutton.c b/gtk/gtkradiobutton.c
index 1c8ffc5112..04da03fd07 100644
--- a/gtk/gtkradiobutton.c
+++ b/gtk/gtkradiobutton.c
@@ -34,8 +34,6 @@ enum {
ARG_GROUP
};
-#define CHECK_BUTTON_CLASS(w) GTK_CHECK_BUTTON_CLASS (GTK_OBJECT (w)->klass)
-
static void gtk_radio_button_class_init (GtkRadioButtonClass *klass);
static void gtk_radio_button_init (GtkRadioButton *radio_button);
@@ -409,10 +407,10 @@ gtk_radio_button_draw_indicator (GtkCheckButton *check_button,
new_area.width, new_area.height);
}
- x = widget->allocation.x + CHECK_BUTTON_CLASS (widget)->indicator_spacing + GTK_CONTAINER (widget)->border_width;
- y = widget->allocation.y + (widget->allocation.height - CHECK_BUTTON_CLASS (widget)->indicator_size) / 2;
- width = CHECK_BUTTON_CLASS (widget)->indicator_size;
- height = CHECK_BUTTON_CLASS (widget)->indicator_size;
+ x = widget->allocation.x + GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_spacing + GTK_CONTAINER (widget)->border_width;
+ y = widget->allocation.y + (widget->allocation.height - GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size) / 2;
+ width = GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size;
+ height = GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size;
if (GTK_TOGGLE_BUTTON (widget)->active)
shadow_type = GTK_SHADOW_IN;
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index 1805629111..92f49210c4 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -34,7 +34,7 @@
#define SCROLL_INITIAL_DELAY 100
#define SCROLL_DELAY_LENGTH 300
-#define RANGE_CLASS(w) GTK_RANGE_CLASS (GTK_OBJECT (w)->klass)
+#define RANGE_CLASS(w) GTK_RANGE_GET_CLASS (w)
enum {
ARG_0,
@@ -50,7 +50,6 @@ static void gtk_range_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void gtk_range_destroy (GtkObject *object);
-static void gtk_range_finalize (GtkObject *object);
static void gtk_range_draw (GtkWidget *widget,
GdkRectangle *area);
static void gtk_range_draw_focus (GtkWidget *widget);
@@ -138,15 +137,9 @@ gtk_range_class_init (GtkRangeClass *class)
parent_class = gtk_type_class (GTK_TYPE_WIDGET);
- gtk_object_add_arg_type ("GtkRange::update_policy",
- GTK_TYPE_UPDATE_TYPE,
- GTK_ARG_READWRITE,
- ARG_UPDATE_POLICY);
-
object_class->set_arg = gtk_range_set_arg;
object_class->get_arg = gtk_range_get_arg;
object_class->destroy = gtk_range_destroy;
- object_class->finalize = gtk_range_finalize;
widget_class->draw = gtk_range_draw;
widget_class->draw_focus = gtk_range_draw_focus;
@@ -181,6 +174,11 @@ gtk_range_class_init (GtkRangeClass *class)
class->trough_keys = NULL;
class->motion = NULL;
class->timer = gtk_real_range_timer;
+
+ gtk_object_add_arg_type ("GtkRange::update_policy",
+ GTK_TYPE_UPDATE_TYPE,
+ GTK_ARG_READWRITE,
+ ARG_UPDATE_POLICY);
}
static void
@@ -253,6 +251,9 @@ gtk_range_get_adjustment (GtkRange *range)
g_return_val_if_fail (range != NULL, NULL);
g_return_val_if_fail (GTK_IS_RANGE (range), NULL);
+ if (!range->adjustment)
+ gtk_range_set_adjustment (range, NULL);
+
return range->adjustment;
}
@@ -573,8 +574,8 @@ gtk_range_default_hmotion (GtkRange *range,
gint slider_x, slider_y;
gint new_pos;
- g_return_if_fail (range != NULL);
g_return_if_fail (GTK_IS_RANGE (range));
+ g_return_if_fail (GTK_WIDGET_REALIZED (range));
range = GTK_RANGE (range);
@@ -638,8 +639,8 @@ gtk_range_default_vmotion (GtkRange *range,
gint slider_x, slider_y;
gint new_pos;
- g_return_if_fail (range != NULL);
g_return_if_fail (GTK_IS_RANGE (range));
+ g_return_if_fail (GTK_WIDGET_REALIZED (range));
range = GTK_RANGE (range);
@@ -704,30 +705,20 @@ gtk_range_destroy (GtkObject *object)
range = GTK_RANGE (object);
+ gtk_range_remove_timer (range);
if (range->adjustment)
- gtk_signal_disconnect_by_data (GTK_OBJECT (range->adjustment),
- (gpointer) range);
+ {
+ if (range->adjustment)
+ gtk_signal_disconnect_by_data (GTK_OBJECT (range->adjustment),
+ (gpointer) range);
+ gtk_object_unref (GTK_OBJECT (range->adjustment));
+ range->adjustment = NULL;
+ }
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
static void
-gtk_range_finalize (GtkObject *object)
-{
- GtkRange *range;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (GTK_IS_RANGE (object));
-
- range = GTK_RANGE (object);
-
- if (range->adjustment)
- gtk_object_unref (GTK_OBJECT (range->adjustment));
-
- (* GTK_OBJECT_CLASS (parent_class)->finalize) (object);
-}
-
-static void
gtk_range_draw (GtkWidget *widget,
GdkRectangle *area)
{
@@ -737,7 +728,7 @@ gtk_range_draw (GtkWidget *widget,
g_return_if_fail (GTK_IS_RANGE (widget));
g_return_if_fail (area != NULL);
- if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_MAPPED (widget))
+ if (GTK_WIDGET_DRAWABLE (widget))
{
range = GTK_RANGE (widget);
@@ -844,7 +835,6 @@ gtk_range_button_press (GtkWidget *widget,
gint trough_part;
gfloat jump_perc;
- g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_RANGE (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
@@ -919,7 +909,6 @@ gtk_range_button_release (GtkWidget *widget,
{
GtkRange *range;
- g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_RANGE (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
@@ -976,20 +965,20 @@ gtk_range_scroll_event (GtkWidget *widget,
{
GtkRange *range;
- g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_RANGE (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
range = GTK_RANGE (widget);
- if (GTK_WIDGET_VISIBLE (range)) {
- GtkAdjustment *adj = GTK_RANGE (range)->adjustment;
- gfloat new_value = adj->value + ((event->direction == GDK_SCROLL_UP) ?
- -adj->page_increment / 2:
- adj->page_increment / 2);
- new_value = CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
- gtk_adjustment_set_value (adj, new_value);
- }
+ if (GTK_WIDGET_REALIZED (range))
+ {
+ GtkAdjustment *adj = GTK_RANGE (range)->adjustment;
+ gfloat new_value = adj->value + ((event->direction == GDK_SCROLL_UP) ?
+ -adj->page_increment / 2:
+ adj->page_increment / 2);
+ new_value = CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
+ gtk_adjustment_set_value (adj, new_value);
+ }
return TRUE;
}
@@ -1002,7 +991,6 @@ gtk_range_motion_notify (GtkWidget *widget,
GdkModifierType mods;
gint x, y, mask;
- g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_RANGE (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
@@ -1053,7 +1041,6 @@ gtk_range_key_press (GtkWidget *widget,
GtkScrollType scroll = GTK_SCROLL_NONE;
GtkTroughType pos = GTK_TROUGH_NONE;
- g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_RANGE (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
@@ -1110,7 +1097,6 @@ gtk_range_enter_notify (GtkWidget *widget,
{
GtkRange *range;
- g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_RANGE (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
@@ -1154,7 +1140,6 @@ gtk_range_leave_notify (GtkWidget *widget,
{
GtkRange *range;
- g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_RANGE (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
@@ -1191,7 +1176,6 @@ static gint
gtk_range_focus_in (GtkWidget *widget,
GdkEventFocus *event)
{
- g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_RANGE (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
@@ -1205,7 +1189,6 @@ static gint
gtk_range_focus_out (GtkWidget *widget,
GdkEventFocus *event)
{
- g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_RANGE (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
@@ -1218,7 +1201,6 @@ gtk_range_focus_out (GtkWidget *widget,
static void
gtk_real_range_draw_trough (GtkRange *range)
{
- g_return_if_fail (range != NULL);
g_return_if_fail (GTK_IS_RANGE (range));
if (range->trough)
@@ -1240,7 +1222,6 @@ gtk_real_range_draw_slider (GtkRange *range)
{
GtkStateType state_type;
- g_return_if_fail (range != NULL);
g_return_if_fail (GTK_IS_RANGE (range));
if (range->slider)
@@ -1324,7 +1305,6 @@ gtk_range_scroll (GtkRange *range,
gfloat new_value;
gint return_val;
- g_return_val_if_fail (range != NULL, FALSE);
g_return_val_if_fail (GTK_IS_RANGE (range), FALSE);
new_value = range->adjustment->value;
@@ -1408,7 +1388,6 @@ gtk_range_scroll (GtkRange *range,
static void
gtk_range_add_timer (GtkRange *range)
{
- g_return_if_fail (range != NULL);
g_return_if_fail (GTK_IS_RANGE (range));
if (!range->timer)
@@ -1423,7 +1402,6 @@ gtk_range_add_timer (GtkRange *range)
static void
gtk_range_remove_timer (GtkRange *range)
{
- g_return_if_fail (range != NULL);
g_return_if_fail (GTK_IS_RANGE (range));
if (range->timer)
diff --git a/gtk/gtkruler.c b/gtk/gtkruler.c
index e9481a921e..221b4fffc2 100644
--- a/gtk/gtkruler.c
+++ b/gtk/gtkruler.c
@@ -226,8 +226,8 @@ gtk_ruler_draw_ticks (GtkRuler *ruler)
g_return_if_fail (ruler != NULL);
g_return_if_fail (GTK_IS_RULER (ruler));
- if (GTK_RULER_CLASS (GTK_OBJECT (ruler)->klass)->draw_ticks)
- (* GTK_RULER_CLASS (GTK_OBJECT (ruler)->klass)->draw_ticks) (ruler);
+ if (GTK_RULER_GET_CLASS (ruler)->draw_ticks)
+ GTK_RULER_GET_CLASS (ruler)->draw_ticks (ruler);
}
void
@@ -236,8 +236,8 @@ gtk_ruler_draw_pos (GtkRuler *ruler)
g_return_if_fail (ruler != NULL);
g_return_if_fail (GTK_IS_RULER (ruler));
- if (GTK_RULER_CLASS (GTK_OBJECT (ruler)->klass)->draw_pos)
- (* GTK_RULER_CLASS (GTK_OBJECT (ruler)->klass)->draw_pos) (ruler);
+ if (GTK_RULER_GET_CLASS (ruler)->draw_pos)
+ GTK_RULER_GET_CLASS (ruler)->draw_pos (ruler);
}
diff --git a/gtk/gtkscale.c b/gtk/gtkscale.c
index e4cc0aada3..34e3127412 100644
--- a/gtk/gtkscale.c
+++ b/gtk/gtkscale.c
@@ -29,8 +29,6 @@
#include "gtkscale.h"
-#define SCALE_CLASS(w) GTK_SCALE_CLASS (GTK_OBJECT (w)->klass)
-
enum {
ARG_0,
ARG_DIGITS,
@@ -330,8 +328,8 @@ gtk_scale_draw_value (GtkScale *scale)
g_return_if_fail (scale != NULL);
g_return_if_fail (GTK_IS_SCALE (scale));
- if (SCALE_CLASS (scale)->draw_value)
- (* SCALE_CLASS (scale)->draw_value) (scale);
+ if (GTK_SCALE_GET_CLASS (scale)->draw_value)
+ GTK_SCALE_GET_CLASS (scale)->draw_value (scale);
}
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index a4529521fd..934e712c58 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -63,7 +63,7 @@
* under A) at least correspond to the space taken up by its scrollbars.
*/
-#define SCROLLBAR_SPACING(w) (GTK_SCROLLED_WINDOW_CLASS (GTK_OBJECT (w)->klass)->scrollbar_spacing)
+#define SCROLLBAR_SPACING(w) (GTK_SCROLLED_WINDOW_GET_CLASS (w)->scrollbar_spacing)
#define DEFAULT_SCROLLBAR_SPACING 3
@@ -86,7 +86,7 @@ static void gtk_scrolled_window_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void gtk_scrolled_window_destroy (GtkObject *object);
-static void gtk_scrolled_window_finalize (GtkObject *object);
+static void gtk_scrolled_window_finalize (GObject *object);
static void gtk_scrolled_window_map (GtkWidget *widget);
static void gtk_scrolled_window_unmap (GtkWidget *widget);
static void gtk_scrolled_window_draw (GtkWidget *widget,
@@ -141,6 +141,7 @@ gtk_scrolled_window_get_type (void)
static void
gtk_scrolled_window_class_init (GtkScrolledWindowClass *class)
{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (class);
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
GtkContainerClass *container_class;
@@ -150,6 +151,25 @@ gtk_scrolled_window_class_init (GtkScrolledWindowClass *class)
container_class = (GtkContainerClass*) class;
parent_class = gtk_type_class (GTK_TYPE_BIN);
+ gobject_class->finalize = gtk_scrolled_window_finalize;
+
+ object_class->set_arg = gtk_scrolled_window_set_arg;
+ object_class->get_arg = gtk_scrolled_window_get_arg;
+ object_class->destroy = gtk_scrolled_window_destroy;
+
+ widget_class->map = gtk_scrolled_window_map;
+ widget_class->unmap = gtk_scrolled_window_unmap;
+ widget_class->draw = gtk_scrolled_window_draw;
+ widget_class->size_request = gtk_scrolled_window_size_request;
+ widget_class->size_allocate = gtk_scrolled_window_size_allocate;
+ widget_class->scroll_event = gtk_scrolled_window_scroll_event;
+
+ container_class->add = gtk_scrolled_window_add;
+ container_class->remove = gtk_scrolled_window_remove;
+ container_class->forall = gtk_scrolled_window_forall;
+
+ class->scrollbar_spacing = DEFAULT_SCROLLBAR_SPACING;
+
gtk_object_add_arg_type ("GtkScrolledWindow::hadjustment",
GTK_TYPE_ADJUSTMENT,
GTK_ARG_READWRITE | GTK_ARG_CONSTRUCT,
@@ -170,24 +190,6 @@ gtk_scrolled_window_class_init (GtkScrolledWindowClass *class)
GTK_TYPE_CORNER_TYPE,
GTK_ARG_READWRITE,
ARG_WINDOW_PLACEMENT);
-
- object_class->set_arg = gtk_scrolled_window_set_arg;
- object_class->get_arg = gtk_scrolled_window_get_arg;
- object_class->destroy = gtk_scrolled_window_destroy;
- object_class->finalize = gtk_scrolled_window_finalize;
-
- widget_class->map = gtk_scrolled_window_map;
- widget_class->unmap = gtk_scrolled_window_unmap;
- widget_class->draw = gtk_scrolled_window_draw;
- widget_class->size_request = gtk_scrolled_window_size_request;
- widget_class->size_allocate = gtk_scrolled_window_size_allocate;
- widget_class->scroll_event = gtk_scrolled_window_scroll_event;
-
- container_class->add = gtk_scrolled_window_add;
- container_class->remove = gtk_scrolled_window_remove;
- container_class->forall = gtk_scrolled_window_forall;
-
- class->scrollbar_spacing = DEFAULT_SCROLLBAR_SPACING;
}
static void
@@ -475,16 +477,14 @@ gtk_scrolled_window_destroy (GtkObject *object)
}
static void
-gtk_scrolled_window_finalize (GtkObject *object)
+gtk_scrolled_window_finalize (GObject *object)
{
- GtkScrolledWindow *scrolled_window;
-
- scrolled_window = GTK_SCROLLED_WINDOW (object);
+ GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW (object);
gtk_widget_unref (scrolled_window->hscrollbar);
gtk_widget_unref (scrolled_window->vscrollbar);
- GTK_OBJECT_CLASS (parent_class)->finalize (object);
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
diff --git a/gtk/gtksignal.c b/gtk/gtksignal.c
index 00326f483d..da6cedd6fa 100644
--- a/gtk/gtksignal.c
+++ b/gtk/gtksignal.c
@@ -435,7 +435,7 @@ gtk_signal_lookup (const gchar *name,
gpointer class = NULL;
g_return_val_if_fail (name != NULL, 0);
- g_return_val_if_fail (gtk_type_is_a (object_type, GTK_TYPE_OBJECT), 0);
+ g_return_val_if_fail (GTK_TYPE_IS_OBJECT (object_type), 0);
relookup:
@@ -1393,7 +1393,7 @@ gtk_signal_real_emit (GtkObject *object,
*/
signal = *LOOKUP_SIGNAL_ID (signal_id);
if (signal.function_offset)
- signal_func = G_STRUCT_MEMBER (GtkSignalFunc, object->klass, signal.function_offset);
+ signal_func = G_STRUCT_MEMBER (GtkSignalFunc, ((GTypeInstance*) object)->g_class, signal.function_offset);
else
signal_func = NULL;
@@ -1723,8 +1723,7 @@ gtk_signal_connect_by_type (GtkObject *object,
gint found_it;
GtkSignal *signal;
- g_return_val_if_fail (object != NULL, 0);
- g_return_val_if_fail (object->klass != NULL, 0);
+ g_return_val_if_fail (GTK_IS_OBJECT (object), 0);
signal = LOOKUP_SIGNAL_ID (signal_id);
@@ -1737,7 +1736,7 @@ gtk_signal_connect_by_type (GtkObject *object,
* return correct signal ids per class-branch.
*/
found_it = FALSE;
- class = object->klass;
+ class = GTK_OBJECT_GET_CLASS (object);
while (class)
{
GtkType parent;
@@ -1755,9 +1754,9 @@ gtk_signal_connect_by_type (GtkObject *object,
break;
}
- parent = gtk_type_parent (class->type);
- if (parent)
- class = gtk_type_class (parent);
+ parent = g_type_parent (GTK_CLASS_TYPE (class));
+ if (GTK_TYPE_IS_OBJECT (parent))
+ class = g_type_class_peek (parent);
else
class = NULL;
}
@@ -1766,7 +1765,7 @@ gtk_signal_connect_by_type (GtkObject *object,
{
g_warning ("gtk_signal_connect_by_type(): could not find signal id (%u) in the `%s' class ancestry",
signal_id,
- gtk_type_name (object->klass->type));
+ GTK_OBJECT_TYPE_NAME (object));
return 0;
}
@@ -1987,9 +1986,7 @@ gtk_signal_collect_params (GtkArg *params,
return_type = GTK_FUNDAMENTAL_TYPE (return_type);
if (return_type != GTK_TYPE_NONE)
{
- if ((return_type >= GTK_TYPE_FLAT_FIRST &&
- return_type <= GTK_TYPE_FLAT_LAST) ||
- (return_type == GTK_TYPE_OBJECT))
+ if (return_type != 0) // FIXME: check for IS_PARAM
{
GTK_VALUE_POINTER (*params) = va_arg (var_args, gpointer);
diff --git a/gtk/gtksocket.c b/gtk/gtksocket.c
index 6be2af88e4..860e06817f 100644
--- a/gtk/gtksocket.c
+++ b/gtk/gtksocket.c
@@ -77,18 +77,20 @@ gtk_socket_get_type (void)
if (!socket_type)
{
- static const GtkTypeInfo socket_info =
+ static const GTypeInfo socket_info =
{
- "GtkSocket",
- sizeof (GtkSocket),
sizeof (GtkSocketClass),
- (GtkClassInitFunc) gtk_socket_class_init,
- (GtkObjectInitFunc) gtk_socket_init,
- (GtkArgSetFunc) NULL,
- (GtkArgGetFunc) NULL
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) gtk_socket_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (GtkSocket),
+ 16, /* n_preallocs */
+ (GInstanceInitFunc) gtk_socket_init,
};
- socket_type = gtk_type_unique (GTK_TYPE_CONTAINER, &socket_info);
+ socket_type = g_type_register_static (GTK_TYPE_CONTAINER, "GtkSocket", &socket_info);
}
return socket_type;
diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c
index 15f7555dc2..47fccb3a51 100644
--- a/gtk/gtkspinbutton.c
+++ b/gtk/gtkspinbutton.c
@@ -69,7 +69,7 @@ enum
static void gtk_spin_button_class_init (GtkSpinButtonClass *klass);
static void gtk_spin_button_init (GtkSpinButton *spin_button);
-static void gtk_spin_button_finalize (GtkObject *object);
+static void gtk_spin_button_finalize (GObject *object);
static void gtk_spin_button_set_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
@@ -158,6 +158,7 @@ gtk_spin_button_get_type (void)
static void
gtk_spin_button_class_init (GtkSpinButtonClass *class)
{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (class);
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
GtkEditableClass *editable_class;
@@ -168,6 +169,35 @@ gtk_spin_button_class_init (GtkSpinButtonClass *class)
parent_class = gtk_type_class (GTK_TYPE_ENTRY);
+ gobject_class->finalize = gtk_spin_button_finalize;
+
+ object_class->set_arg = gtk_spin_button_set_arg;
+ object_class->get_arg = gtk_spin_button_get_arg;
+
+ widget_class->map = gtk_spin_button_map;
+ widget_class->unmap = gtk_spin_button_unmap;
+ widget_class->realize = gtk_spin_button_realize;
+ widget_class->unrealize = gtk_spin_button_unrealize;
+ widget_class->size_request = gtk_spin_button_size_request;
+ widget_class->size_allocate = gtk_spin_button_size_allocate;
+ widget_class->draw = gtk_spin_button_draw;
+ widget_class->expose_event = gtk_spin_button_expose;
+ widget_class->scroll_event = gtk_spin_button_scroll;
+ widget_class->button_press_event = gtk_spin_button_button_press;
+ widget_class->button_release_event = gtk_spin_button_button_release;
+ widget_class->motion_notify_event = gtk_spin_button_motion_notify;
+ widget_class->key_press_event = gtk_spin_button_key_press;
+ widget_class->key_release_event = gtk_spin_button_key_release;
+ widget_class->enter_notify_event = gtk_spin_button_enter_notify;
+ widget_class->leave_notify_event = gtk_spin_button_leave_notify;
+ widget_class->focus_out_event = gtk_spin_button_focus_out;
+
+ editable_class->insert_text = gtk_spin_button_insert_text;
+ editable_class->activate = gtk_spin_button_activate;
+
+ class->input = NULL;
+ class->output = NULL;
+
gtk_object_add_arg_type ("GtkSpinButton::adjustment",
GTK_TYPE_ADJUSTMENT,
GTK_ARG_READWRITE,
@@ -205,14 +235,10 @@ gtk_spin_button_class_init (GtkSpinButtonClass *class)
GTK_ARG_READWRITE,
ARG_VALUE);
- object_class->set_arg = gtk_spin_button_set_arg;
- object_class->get_arg = gtk_spin_button_get_arg;
- object_class->finalize = gtk_spin_button_finalize;
-
spinbutton_signals[INPUT] =
gtk_signal_new ("input",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkSpinButtonClass, input),
gtk_marshal_INT__POINTER,
GTK_TYPE_INT, 1, GTK_TYPE_POINTER);
@@ -220,36 +246,12 @@ gtk_spin_button_class_init (GtkSpinButtonClass *class)
spinbutton_signals[OUTPUT] =
gtk_signal_new ("output",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkSpinButtonClass, output),
gtk_marshal_BOOL__NONE,
GTK_TYPE_BOOL, 0);
gtk_object_class_add_signals (object_class, spinbutton_signals, LAST_SIGNAL);
-
- widget_class->map = gtk_spin_button_map;
- widget_class->unmap = gtk_spin_button_unmap;
- widget_class->realize = gtk_spin_button_realize;
- widget_class->unrealize = gtk_spin_button_unrealize;
- widget_class->size_request = gtk_spin_button_size_request;
- widget_class->size_allocate = gtk_spin_button_size_allocate;
- widget_class->draw = gtk_spin_button_draw;
- widget_class->expose_event = gtk_spin_button_expose;
- widget_class->scroll_event = gtk_spin_button_scroll;
- widget_class->button_press_event = gtk_spin_button_button_press;
- widget_class->button_release_event = gtk_spin_button_button_release;
- widget_class->motion_notify_event = gtk_spin_button_motion_notify;
- widget_class->key_press_event = gtk_spin_button_key_press;
- widget_class->key_release_event = gtk_spin_button_key_release;
- widget_class->enter_notify_event = gtk_spin_button_enter_notify;
- widget_class->leave_notify_event = gtk_spin_button_leave_notify;
- widget_class->focus_out_event = gtk_spin_button_focus_out;
-
- editable_class->insert_text = gtk_spin_button_insert_text;
- editable_class->activate = gtk_spin_button_activate;
-
- class->input = NULL;
- class->output = NULL;
}
static void
@@ -375,14 +377,13 @@ gtk_spin_button_init (GtkSpinButton *spin_button)
}
static void
-gtk_spin_button_finalize (GtkObject *object)
+gtk_spin_button_finalize (GObject *object)
{
- g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_SPIN_BUTTON (object));
gtk_object_unref (GTK_OBJECT (GTK_SPIN_BUTTON (object)->adjustment));
- GTK_OBJECT_CLASS (parent_class)->finalize (object);
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
@@ -1408,7 +1409,6 @@ void
gtk_spin_button_set_adjustment (GtkSpinButton *spin_button,
GtkAdjustment *adjustment)
{
- g_return_if_fail (spin_button != NULL);
g_return_if_fail (GTK_IS_SPIN_BUTTON (spin_button));
if (spin_button->adjustment != adjustment)
diff --git a/gtk/gtkstatusbar.c b/gtk/gtkstatusbar.c
index 34603573fb..f0826a7d8b 100644
--- a/gtk/gtkstatusbar.c
+++ b/gtk/gtkstatusbar.c
@@ -41,7 +41,6 @@ enum
static void gtk_statusbar_class_init (GtkStatusbarClass *class);
static void gtk_statusbar_init (GtkStatusbar *statusbar);
static void gtk_statusbar_destroy (GtkObject *object);
-static void gtk_statusbar_finalize (GtkObject *object);
static void gtk_statusbar_update (GtkStatusbar *statusbar,
guint context_id,
const gchar *text);
@@ -86,11 +85,21 @@ gtk_statusbar_class_init (GtkStatusbarClass *class)
container_class = (GtkContainerClass *) class;
parent_class = gtk_type_class (GTK_TYPE_HBOX);
+
+ object_class->destroy = gtk_statusbar_destroy;
+
+ class->messages_mem_chunk = g_mem_chunk_new ("GtkStatusBar messages mem chunk",
+ sizeof (GtkStatusbarMsg),
+ sizeof (GtkStatusbarMsg) * 64,
+ G_ALLOC_AND_FREE);
+
+ class->text_pushed = gtk_statusbar_update;
+ class->text_popped = gtk_statusbar_update;
statusbar_signals[SIGNAL_TEXT_PUSHED] =
gtk_signal_new ("text_pushed",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkStatusbarClass, text_pushed),
gtk_marshal_NONE__UINT_STRING,
GTK_TYPE_NONE, 2,
@@ -99,24 +108,13 @@ gtk_statusbar_class_init (GtkStatusbarClass *class)
statusbar_signals[SIGNAL_TEXT_POPPED] =
gtk_signal_new ("text_popped",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkStatusbarClass, text_popped),
gtk_marshal_NONE__UINT_STRING,
GTK_TYPE_NONE, 2,
GTK_TYPE_UINT,
GTK_TYPE_STRING);
gtk_object_class_add_signals (object_class, statusbar_signals, SIGNAL_LAST);
-
- object_class->destroy = gtk_statusbar_destroy;
- object_class->finalize = gtk_statusbar_finalize;
-
- class->messages_mem_chunk = g_mem_chunk_new ("GtkStatusBar messages mem chunk",
- sizeof (GtkStatusbarMsg),
- sizeof (GtkStatusbarMsg) * 64,
- G_ALLOC_AND_FREE);
-
- class->text_pushed = gtk_statusbar_update;
- class->text_popped = gtk_statusbar_update;
}
static void
@@ -206,7 +204,7 @@ gtk_statusbar_push (GtkStatusbar *statusbar,
g_return_val_if_fail (text != NULL, 0);
g_return_val_if_fail (context_id > 0, 0);
- class = GTK_STATUSBAR_CLASS (GTK_OBJECT (statusbar)->klass);
+ class = GTK_STATUSBAR_GET_CLASS (statusbar);
msg = g_chunk_new (GtkStatusbarMsg, class->messages_mem_chunk);
msg->text = g_strdup (text);
msg->context_id = context_id;
@@ -244,7 +242,7 @@ gtk_statusbar_pop (GtkStatusbar *statusbar,
{
GtkStatusbarClass *class;
- class = GTK_STATUSBAR_CLASS (GTK_OBJECT (statusbar)->klass);
+ class = GTK_STATUSBAR_GET_CLASS (statusbar);
statusbar->messages = g_slist_remove_link (statusbar->messages,
list);
@@ -298,7 +296,7 @@ gtk_statusbar_remove (GtkStatusbar *statusbar,
{
GtkStatusbarClass *class;
- class = GTK_STATUSBAR_CLASS (GTK_OBJECT (statusbar)->klass);
+ class = GTK_STATUSBAR_GET_CLASS (statusbar);
statusbar->messages = g_slist_remove_link (statusbar->messages, list);
g_free (msg->text);
g_mem_chunk_free (class->messages_mem_chunk, msg);
@@ -321,7 +319,7 @@ gtk_statusbar_destroy (GtkObject *object)
g_return_if_fail (GTK_IS_STATUSBAR (object));
statusbar = GTK_STATUSBAR (object);
- class = GTK_STATUSBAR_CLASS (GTK_OBJECT (statusbar)->klass);
+ class = GTK_STATUSBAR_GET_CLASS (statusbar);
for (list = statusbar->messages; list; list = list->next)
{
@@ -341,16 +339,3 @@ gtk_statusbar_destroy (GtkObject *object)
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
-
-static void
-gtk_statusbar_finalize (GtkObject *object)
-{
- GtkStatusbar *statusbar;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (GTK_IS_STATUSBAR (object));
-
- statusbar = GTK_STATUSBAR (object);
-
- GTK_OBJECT_CLASS (parent_class)->finalize (object);
-}
diff --git a/gtk/gtktable.c b/gtk/gtktable.c
index e484479c88..c224276377 100644
--- a/gtk/gtktable.c
+++ b/gtk/gtktable.c
@@ -52,7 +52,7 @@ enum
static void gtk_table_class_init (GtkTableClass *klass);
static void gtk_table_init (GtkTable *table);
-static void gtk_table_finalize (GtkObject *object);
+static void gtk_table_finalize (GObject *object);
static void gtk_table_map (GtkWidget *widget);
static void gtk_table_unmap (GtkWidget *widget);
static void gtk_table_draw (GtkWidget *widget,
@@ -129,6 +129,7 @@ gtk_table_get_type (void)
static void
gtk_table_class_init (GtkTableClass *class)
{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (class);
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
GtkContainerClass *container_class;
@@ -138,24 +139,11 @@ gtk_table_class_init (GtkTableClass *class)
container_class = (GtkContainerClass*) class;
parent_class = gtk_type_class (gtk_container_get_type ());
-
- gtk_object_add_arg_type ("GtkTable::n_rows", GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_N_ROWS);
- gtk_object_add_arg_type ("GtkTable::n_columns", GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_N_COLUMNS);
- gtk_object_add_arg_type ("GtkTable::row_spacing", GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_ROW_SPACING);
- gtk_object_add_arg_type ("GtkTable::column_spacing", GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_COLUMN_SPACING);
- gtk_object_add_arg_type ("GtkTable::homogeneous", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_HOMOGENEOUS);
- gtk_container_add_child_arg_type ("GtkTable::left_attach", GTK_TYPE_UINT, GTK_ARG_READWRITE, CHILD_ARG_LEFT_ATTACH);
- gtk_container_add_child_arg_type ("GtkTable::right_attach", GTK_TYPE_UINT, GTK_ARG_READWRITE, CHILD_ARG_RIGHT_ATTACH);
- gtk_container_add_child_arg_type ("GtkTable::top_attach", GTK_TYPE_UINT, GTK_ARG_READWRITE, CHILD_ARG_TOP_ATTACH);
- gtk_container_add_child_arg_type ("GtkTable::bottom_attach", GTK_TYPE_UINT, GTK_ARG_READWRITE, CHILD_ARG_BOTTOM_ATTACH);
- gtk_container_add_child_arg_type ("GtkTable::x_options", GTK_TYPE_ATTACH_OPTIONS, GTK_ARG_READWRITE, CHILD_ARG_X_OPTIONS);
- gtk_container_add_child_arg_type ("GtkTable::y_options", GTK_TYPE_ATTACH_OPTIONS, GTK_ARG_READWRITE, CHILD_ARG_Y_OPTIONS);
- gtk_container_add_child_arg_type ("GtkTable::x_padding", GTK_TYPE_UINT, GTK_ARG_READWRITE, CHILD_ARG_X_PADDING);
- gtk_container_add_child_arg_type ("GtkTable::y_padding", GTK_TYPE_UINT, GTK_ARG_READWRITE, CHILD_ARG_Y_PADDING);
+
+ gobject_class->finalize = gtk_table_finalize;
object_class->get_arg = gtk_table_get_arg;
object_class->set_arg = gtk_table_set_arg;
- object_class->finalize = gtk_table_finalize;
widget_class->map = gtk_table_map;
widget_class->unmap = gtk_table_unmap;
@@ -170,6 +158,20 @@ gtk_table_class_init (GtkTableClass *class)
container_class->child_type = gtk_table_child_type;
container_class->set_child_arg = gtk_table_set_child_arg;
container_class->get_child_arg = gtk_table_get_child_arg;
+
+ gtk_object_add_arg_type ("GtkTable::n_rows", GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_N_ROWS);
+ gtk_object_add_arg_type ("GtkTable::n_columns", GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_N_COLUMNS);
+ gtk_object_add_arg_type ("GtkTable::row_spacing", GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_ROW_SPACING);
+ gtk_object_add_arg_type ("GtkTable::column_spacing", GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_COLUMN_SPACING);
+ gtk_object_add_arg_type ("GtkTable::homogeneous", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_HOMOGENEOUS);
+ gtk_container_add_child_arg_type ("GtkTable::left_attach", GTK_TYPE_UINT, GTK_ARG_READWRITE, CHILD_ARG_LEFT_ATTACH);
+ gtk_container_add_child_arg_type ("GtkTable::right_attach", GTK_TYPE_UINT, GTK_ARG_READWRITE, CHILD_ARG_RIGHT_ATTACH);
+ gtk_container_add_child_arg_type ("GtkTable::top_attach", GTK_TYPE_UINT, GTK_ARG_READWRITE, CHILD_ARG_TOP_ATTACH);
+ gtk_container_add_child_arg_type ("GtkTable::bottom_attach", GTK_TYPE_UINT, GTK_ARG_READWRITE, CHILD_ARG_BOTTOM_ATTACH);
+ gtk_container_add_child_arg_type ("GtkTable::x_options", GTK_TYPE_ATTACH_OPTIONS, GTK_ARG_READWRITE, CHILD_ARG_X_OPTIONS);
+ gtk_container_add_child_arg_type ("GtkTable::y_options", GTK_TYPE_ATTACH_OPTIONS, GTK_ARG_READWRITE, CHILD_ARG_Y_OPTIONS);
+ gtk_container_add_child_arg_type ("GtkTable::x_padding", GTK_TYPE_UINT, GTK_ARG_READWRITE, CHILD_ARG_X_PADDING);
+ gtk_container_add_child_arg_type ("GtkTable::y_padding", GTK_TYPE_UINT, GTK_ARG_READWRITE, CHILD_ARG_Y_PADDING);
}
static GtkType
@@ -655,11 +657,10 @@ gtk_table_set_homogeneous (GtkTable *table,
}
static void
-gtk_table_finalize (GtkObject *object)
+gtk_table_finalize (GObject *object)
{
GtkTable *table;
- g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_TABLE (object));
table = GTK_TABLE (object);
@@ -667,7 +668,7 @@ gtk_table_finalize (GtkObject *object)
g_free (table->rows);
g_free (table->cols);
- (* GTK_OBJECT_CLASS (parent_class)->finalize) (object);
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index 1da7b514dd..3b6bfd2aef 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -202,7 +202,7 @@ static void gtk_text_get_arg (GtkObject *object,
guint arg_id);
static void gtk_text_init (GtkText *text);
static void gtk_text_destroy (GtkObject *object);
-static void gtk_text_finalize (GtkObject *object);
+static void gtk_text_finalize (GObject *object);
static void gtk_text_realize (GtkWidget *widget);
static void gtk_text_unrealize (GtkWidget *widget);
static void gtk_text_style_set (GtkWidget *widget,
@@ -534,6 +534,7 @@ gtk_text_get_type (void)
static void
gtk_text_class_init (GtkTextClass *class)
{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (class);
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
GtkEditableClass *editable_class;
@@ -543,27 +544,11 @@ gtk_text_class_init (GtkTextClass *class)
editable_class = (GtkEditableClass*) class;
parent_class = gtk_type_class (GTK_TYPE_EDITABLE);
- gtk_object_add_arg_type ("GtkText::hadjustment",
- GTK_TYPE_ADJUSTMENT,
- GTK_ARG_READWRITE | GTK_ARG_CONSTRUCT,
- ARG_HADJUSTMENT);
- gtk_object_add_arg_type ("GtkText::vadjustment",
- GTK_TYPE_ADJUSTMENT,
- GTK_ARG_READWRITE | GTK_ARG_CONSTRUCT,
- ARG_VADJUSTMENT);
- gtk_object_add_arg_type ("GtkText::line_wrap",
- GTK_TYPE_BOOL,
- GTK_ARG_READWRITE,
- ARG_LINE_WRAP);
- gtk_object_add_arg_type ("GtkText::word_wrap",
- GTK_TYPE_BOOL,
- GTK_ARG_READWRITE,
- ARG_WORD_WRAP);
+ gobject_class->finalize = gtk_text_finalize;
object_class->set_arg = gtk_text_set_arg;
object_class->get_arg = gtk_text_get_arg;
object_class->destroy = gtk_text_destroy;
- object_class->finalize = gtk_text_finalize;
widget_class->realize = gtk_text_realize;
widget_class->unrealize = gtk_text_unrealize;
@@ -580,14 +565,6 @@ gtk_text_class_init (GtkTextClass *class)
widget_class->key_press_event = gtk_text_key_press;
widget_class->focus_in_event = gtk_text_focus_in;
widget_class->focus_out_event = gtk_text_focus_out;
-
- widget_class->set_scroll_adjustments_signal =
- gtk_signal_new ("set_scroll_adjustments",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (GtkTextClass, set_scroll_adjustments),
- gtk_marshal_NONE__POINTER_POINTER,
- GTK_TYPE_NONE, 2, GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT);
editable_class->set_editable = gtk_text_real_set_editable;
editable_class->insert_text = gtk_text_insert_text;
@@ -609,6 +586,31 @@ gtk_text_class_init (GtkTextClass *class)
editable_class->set_position = gtk_text_set_position;
class->set_scroll_adjustments = gtk_text_set_adjustments;
+
+ gtk_object_add_arg_type ("GtkText::hadjustment",
+ GTK_TYPE_ADJUSTMENT,
+ GTK_ARG_READWRITE,
+ ARG_HADJUSTMENT);
+ gtk_object_add_arg_type ("GtkText::vadjustment",
+ GTK_TYPE_ADJUSTMENT,
+ GTK_ARG_READWRITE,
+ ARG_VADJUSTMENT);
+ gtk_object_add_arg_type ("GtkText::line_wrap",
+ GTK_TYPE_BOOL,
+ GTK_ARG_READWRITE,
+ ARG_LINE_WRAP);
+ gtk_object_add_arg_type ("GtkText::word_wrap",
+ GTK_TYPE_BOOL,
+ GTK_ARG_READWRITE,
+ ARG_WORD_WRAP);
+
+ widget_class->set_scroll_adjustments_signal =
+ gtk_signal_new ("set_scroll_adjustments",
+ GTK_RUN_LAST,
+ GTK_CLASS_TYPE (object_class),
+ GTK_SIGNAL_OFFSET (GtkTextClass, set_scroll_adjustments),
+ gtk_marshal_NONE__POINTER_POINTER,
+ GTK_TYPE_NONE, 2, GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT);
}
static void
@@ -721,6 +723,7 @@ gtk_text_init (GtkText *text)
GTK_EDITABLE (text)->editable = FALSE;
+ gtk_text_set_adjustments (text, NULL, NULL);
gtk_editable_set_position (GTK_EDITABLE (text), 0);
}
@@ -1200,13 +1203,22 @@ gtk_text_destroy (GtkObject *object)
{
GtkText *text;
- g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_TEXT (object));
- text = (GtkText*) object;
+ text = GTK_TEXT (object);
- gtk_signal_disconnect_by_data (GTK_OBJECT (text->hadj), text);
- gtk_signal_disconnect_by_data (GTK_OBJECT (text->vadj), text);
+ if (text->hadj)
+ {
+ gtk_signal_disconnect_by_data (GTK_OBJECT (text->hadj), text);
+ gtk_object_unref (GTK_OBJECT (text->hadj));
+ text->hadj = NULL;
+ }
+ if (text->vadj)
+ {
+ gtk_signal_disconnect_by_data (GTK_OBJECT (text->vadj), text);
+ gtk_object_unref (GTK_OBJECT (text->vadj));
+ text->vadj = NULL;
+ }
if (text->timer)
{
@@ -1218,18 +1230,14 @@ gtk_text_destroy (GtkObject *object)
}
static void
-gtk_text_finalize (GtkObject *object)
+gtk_text_finalize (GObject *object)
{
GtkText *text;
GList *tmp_list;
- g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_TEXT (object));
- text = (GtkText *)object;
-
- gtk_object_unref (GTK_OBJECT (text->hadj));
- gtk_object_unref (GTK_OBJECT (text->vadj));
+ text = GTK_TEXT (object);
/* Clean up the internal structures */
if (text->use_wchar)
@@ -1262,7 +1270,7 @@ gtk_text_finalize (GtkObject *object)
g_list_free (text->tab_stops);
- GTK_OBJECT_CLASS(parent_class)->finalize (object);
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
diff --git a/gtk/gtktipsquery.c b/gtk/gtktipsquery.c
index aed085d9bd..2468e9a788 100644
--- a/gtk/gtktipsquery.c
+++ b/gtk/gtktipsquery.c
@@ -125,21 +125,21 @@ gtk_tips_query_class_init (GtkTipsQueryClass *class)
tips_query_signals[SIGNAL_START_QUERY] =
gtk_signal_new ("start_query",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkTipsQueryClass, start_query),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
tips_query_signals[SIGNAL_STOP_QUERY] =
gtk_signal_new ("stop_query",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkTipsQueryClass, stop_query),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
tips_query_signals[SIGNAL_WIDGET_ENTERED] =
gtk_signal_new ("widget_entered",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkTipsQueryClass, widget_entered),
gtk_marshal_NONE__POINTER_STRING_STRING,
GTK_TYPE_NONE, 3,
@@ -149,7 +149,7 @@ gtk_tips_query_class_init (GtkTipsQueryClass *class)
tips_query_signals[SIGNAL_WIDGET_SELECTED] =
gtk_signal_new ("widget_selected",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkTipsQueryClass, widget_selected),
gtk_marshal_BOOL__POINTER_STRING_STRING_POINTER,
GTK_TYPE_BOOL, 4,
diff --git a/gtk/gtktogglebutton.c b/gtk/gtktogglebutton.c
index 4c4c8431ef..788ac67009 100644
--- a/gtk/gtktogglebutton.c
+++ b/gtk/gtktogglebutton.c
@@ -122,7 +122,7 @@ gtk_toggle_button_class_init (GtkToggleButtonClass *class)
toggle_button_signals[TOGGLED] =
gtk_signal_new ("toggled",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkToggleButtonClass, toggled),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
diff --git a/gtk/gtktoolbar.c b/gtk/gtktoolbar.c
index f66f181631..9aa8d7d17b 100644
--- a/gtk/gtktoolbar.c
+++ b/gtk/gtktoolbar.c
@@ -143,7 +143,7 @@ gtk_toolbar_class_init (GtkToolbarClass *class)
toolbar_signals[ORIENTATION_CHANGED] =
gtk_signal_new ("orientation_changed",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkToolbarClass, orientation_changed),
gtk_marshal_NONE__INT,
GTK_TYPE_NONE, 1,
@@ -151,7 +151,7 @@ gtk_toolbar_class_init (GtkToolbarClass *class)
toolbar_signals[STYLE_CHANGED] =
gtk_signal_new ("style_changed",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkToolbarClass, style_changed),
gtk_marshal_NONE__INT,
GTK_TYPE_NONE, 1,
@@ -290,8 +290,11 @@ gtk_toolbar_destroy (GtkObject *object)
toolbar = GTK_TOOLBAR (object);
- gtk_object_unref (GTK_OBJECT (toolbar->tooltips));
- toolbar->tooltips = NULL;
+ if (toolbar->tooltips)
+ {
+ gtk_object_unref (GTK_OBJECT (toolbar->tooltips));
+ toolbar->tooltips = NULL;
+ }
for (children = toolbar->children; children; children = children->next)
{
@@ -309,12 +312,10 @@ gtk_toolbar_destroy (GtkObject *object)
g_free (child);
}
-
g_list_free (toolbar->children);
toolbar->children = NULL;
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+ GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
static void
diff --git a/gtk/gtktree.c b/gtk/gtktree.c
index b3765f561e..40c9fd79e2 100644
--- a/gtk/gtktree.c
+++ b/gtk/gtktree.c
@@ -115,14 +115,14 @@ gtk_tree_class_init (GtkTreeClass *class)
tree_signals[SELECTION_CHANGED] =
gtk_signal_new ("selection_changed",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkTreeClass, selection_changed),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
tree_signals[SELECT_CHILD] =
gtk_signal_new ("select_child",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkTreeClass, select_child),
gtk_marshal_NONE__POINTER,
GTK_TYPE_NONE, 1,
@@ -130,7 +130,7 @@ gtk_tree_class_init (GtkTreeClass *class)
tree_signals[UNSELECT_CHILD] =
gtk_signal_new ("unselect_child",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkTreeClass, unselect_child),
gtk_marshal_NONE__POINTER,
GTK_TYPE_NONE, 1,
diff --git a/gtk/gtktreeitem.c b/gtk/gtktreeitem.c
index e174d6fb13..63e2d77203 100644
--- a/gtk/gtktreeitem.c
+++ b/gtk/gtktreeitem.c
@@ -145,14 +145,14 @@ gtk_tree_item_class_init (GtkTreeItemClass *class)
tree_item_signals[EXPAND_TREE] =
gtk_signal_new ("expand",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkTreeItemClass, expand),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
tree_item_signals[COLLAPSE_TREE] =
gtk_signal_new ("collapse",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkTreeItemClass, collapse),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
diff --git a/gtk/gtktypeutils.c b/gtk/gtktypeutils.c
index a2c15e6aa3..b4cb223a34 100644
--- a/gtk/gtktypeutils.c
+++ b/gtk/gtktypeutils.c
@@ -18,984 +18,244 @@
*/
/*
- * Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
+ * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
-#include <string.h>
#include "gtktypeutils.h"
+#include "gtkobject.h"
-#define TYPE_NODES_BLOCK_SIZE (35) /* needs to be > GTK_TYPE_FUNDAMENTAL_MAX */
-
-typedef struct _GtkTypeNode GtkTypeNode;
-
-struct _GtkTypeNode
+/* --- functions --- */
+GtkType
+gtk_type_unique (GtkType parent_type,
+ const GtkTypeInfo *gtkinfo)
{
- GtkType type;
- GtkTypeInfo type_info;
- guint n_supers : 24;
- guint chunk_alloc_locked : 1;
- GtkType *supers;
- GtkType parent_type;
- gpointer klass;
- GList *children_types;
- GMemChunk *mem_chunk;
-};
-
-#define LOOKUP_TYPE_NODE(node_var, type) { \
- GtkTypeNode *__node = NULL; \
- GtkType sqn = GTK_TYPE_SEQNO (type); \
- if (sqn > 0) \
- { \
- sqn--; \
- if (sqn < GTK_TYPE_FUNDAMENTAL_MAX) \
- { \
- if (sqn < n_ftype_nodes) \
- __node = type_nodes + sqn; \
- } \
- else if (sqn < n_type_nodes) \
- __node = type_nodes + sqn; \
- } \
- node_var = __node; \
-}
-
-static void gtk_type_class_init (GtkType node_type);
-static void gtk_type_init_builtin_types (void);
+ GTypeInfo tinfo = { 0, };
-static GtkTypeNode *type_nodes = NULL;
-static guint n_type_nodes = 0;
-static guint n_ftype_nodes = 0;
-static GHashTable *type_name_2_type_ht = NULL;
+ g_return_val_if_fail (GTK_TYPE_IS_OBJECT (parent_type), 0);
+ g_return_val_if_fail (gtkinfo != NULL, 0);
+ g_return_val_if_fail (gtkinfo->type_name != NULL, 0);
+ g_return_val_if_fail (g_type_from_name (gtkinfo->type_name) == 0, 0);
+ tinfo.class_size = gtkinfo->class_size;
+ tinfo.base_init = gtkinfo->base_class_init_func;
+ tinfo.base_finalize = NULL;
+ tinfo.class_init = (GClassInitFunc) gtkinfo->class_init_func;
+ tinfo.class_finalize = NULL;
+ tinfo.class_data = NULL;
+ tinfo.instance_size = gtkinfo->object_size;
+ tinfo.n_preallocs = 0;
+ tinfo.instance_init = gtkinfo->object_init_func;
-static GtkTypeNode*
-gtk_type_node_next_and_invalidate (GtkType parent_type)
-{
- static guint n_free_type_nodes = 0;
- GtkTypeNode *node;
-
- /* don't keep *any* GtkTypeNode pointers across invokation of this function!!!
- */
-
- if (n_free_type_nodes == 0)
- {
- guint i;
- guint size;
-
- /* nearest pow
- */
- size = n_type_nodes + TYPE_NODES_BLOCK_SIZE;
- size *= sizeof (GtkTypeNode);
- i = 1;
- while (i < size)
- i <<= 1;
- size = i;
-
- type_nodes = g_realloc (type_nodes, size);
-
- n_free_type_nodes = size / sizeof (GtkTypeNode) - n_type_nodes;
-
- memset (type_nodes + n_type_nodes, 0, n_free_type_nodes * sizeof (GtkTypeNode));
- if (!n_type_nodes)
- {
- n_type_nodes = GTK_TYPE_FUNDAMENTAL_MAX;
- n_free_type_nodes -= GTK_TYPE_FUNDAMENTAL_MAX;
- }
- }
-
- if (!parent_type)
- {
- g_assert (n_ftype_nodes < GTK_TYPE_FUNDAMENTAL_MAX); /* paranoid */
-
- node = type_nodes + n_ftype_nodes;
- n_ftype_nodes++;
- node->type = n_ftype_nodes;
- }
- else
- {
- node = type_nodes + n_type_nodes;
- n_type_nodes++;
- n_free_type_nodes--;
- node->type = GTK_TYPE_MAKE (parent_type, n_type_nodes);
- }
-
- return node;
-}
-
-void
-gtk_type_init (void)
-{
- if (n_type_nodes == 0)
- {
- g_assert (sizeof (GtkType) >= 4);
- g_assert (TYPE_NODES_BLOCK_SIZE > GTK_TYPE_FUNDAMENTAL_MAX);
-
- type_name_2_type_ht = g_hash_table_new (g_str_hash, g_str_equal);
-
- gtk_type_init_builtin_types ();
- }
+ return g_type_register_static (parent_type, gtkinfo->type_name, &tinfo);
}
-void
-gtk_type_set_chunk_alloc (GtkType type,
- guint n_chunks)
-{
- GtkTypeNode *node;
-
- LOOKUP_TYPE_NODE (node, type);
- g_return_if_fail (node != NULL);
- g_return_if_fail (node->chunk_alloc_locked == FALSE);
-
- if (node->mem_chunk)
- {
- g_mem_chunk_destroy (node->mem_chunk);
- node->mem_chunk = NULL;
- }
-
- if (n_chunks)
- node->mem_chunk = g_mem_chunk_new (node->type_info.type_name,
- node->type_info.object_size,
- node->type_info.object_size * n_chunks,
- G_ALLOC_AND_FREE);
-}
-
-static GtkType
-gtk_type_create (GtkType parent_type,
- gchar *type_name,
- const GtkTypeInfo *type_info)
+gpointer
+gtk_type_class (GtkType type)
{
- GtkTypeNode *new_node;
- GtkTypeNode *parent;
- guint i;
-
- if (g_hash_table_lookup (type_name_2_type_ht, type_name))
- {
- g_warning ("gtk_type_create(): type `%s' already exists.", type_name);
- return 0;
- }
-
- if (parent_type)
- {
- GtkTypeNode *tmp_node;
-
- LOOKUP_TYPE_NODE (tmp_node, parent_type);
- if (!tmp_node)
- {
- g_warning ("gtk_type_create(): unknown parent type `%u'.", parent_type);
- return 0;
- }
- }
-
- /* relookup pointers afterwards.
+ static GQuark quark_static_class = 0;
+ gpointer class;
+
+ if (!G_TYPE_IS_ENUM (type) && !G_TYPE_IS_FLAGS (type))
+ g_return_val_if_fail (GTK_TYPE_IS_OBJECT (type), NULL);
+
+ /* ok, this is a bit ugly, GLib reference counts classes,
+ * and gtk_type_class() used to always return static classes.
+ * while we coud be faster with just peeking the glib class
+ * for the normal code path, we can't be sure that that
+ * class stays around (someone else might be holding the
+ * reference count and is going to drop it later). so to
+ * ensure that Gtk actually holds a static reference count
+ * on the class, we use GType qdata to store referenced
+ * classes, and only return those.
*/
- new_node = gtk_type_node_next_and_invalidate (parent_type);
-
- if (parent_type)
- {
- g_assert (GTK_TYPE_SEQNO (new_node->type) > GTK_TYPE_FUNDAMENTAL_MAX);
- LOOKUP_TYPE_NODE (parent, parent_type);
- }
- else
- {
- g_assert (new_node->type <= GTK_TYPE_FUNDAMENTAL_MAX);
- parent = NULL;
- }
-
- new_node->type_info = *type_info;
- new_node->type_info.type_name = type_name;
- /* new_node->type_info.reserved_1 = NULL; */
- new_node->type_info.reserved_2 = NULL;
- new_node->n_supers = parent ? parent->n_supers + 1 : 0;
- new_node->chunk_alloc_locked = FALSE;
- new_node->supers = g_new0 (GtkType, new_node->n_supers + 1);
- new_node->parent_type = parent_type;
- new_node->klass = NULL;
- new_node->children_types = NULL;
- new_node->mem_chunk = NULL;
-
- if (parent)
- parent->children_types = g_list_append (parent->children_types, GUINT_TO_POINTER (new_node->type));
-
- parent = new_node;
- for (i = 0; i < new_node->n_supers + 1; i++)
- {
- new_node->supers[i] = parent->type;
- LOOKUP_TYPE_NODE (parent, parent->parent_type);
- }
-
- g_hash_table_insert (type_name_2_type_ht, new_node->type_info.type_name, GUINT_TO_POINTER (new_node->type));
-
- return new_node->type;
-}
-GtkType
-gtk_type_unique (GtkType parent_type,
- const GtkTypeInfo *type_info)
-{
- GtkType new_type;
- gchar *type_name;
-
- g_return_val_if_fail (type_info != NULL, 0);
- g_return_val_if_fail (type_info->type_name != NULL, 0);
-
- if (!parent_type && n_ftype_nodes >= GTK_TYPE_FUNDAMENTAL_MAX)
+ class = g_type_get_qdata (type, quark_static_class);
+ if (!class)
{
- g_warning ("gtk_type_unique(): maximum amount of fundamental types reached, "
- "try increasing GTK_TYPE_FUNDAMENTAL_MAX");
- return 0;
- }
-
- type_name = g_strdup (type_info->type_name);
-
- /* relookup pointers afterwards.
- */
- new_type = gtk_type_create (parent_type, type_name, type_info);
-
- if (!new_type)
- g_free (type_name);
+ if (!quark_static_class)
+ quark_static_class = g_quark_from_static_string ("GtkStaticTypeClass");
- return new_type;
-}
-
-gchar*
-gtk_type_name (GtkType type)
-{
- GtkTypeNode *node;
-
- LOOKUP_TYPE_NODE (node, type);
-
- if (node)
- return node->type_info.type_name;
-
- return NULL;
-}
-
-GtkType
-gtk_type_from_name (const gchar *name)
-{
- if (type_name_2_type_ht)
- {
- GtkType type;
-
- type = GPOINTER_TO_UINT (g_hash_table_lookup (type_name_2_type_ht, (gpointer) name));
-
- return type;
- }
-
- return 0;
-}
-
-GtkType
-gtk_type_parent (GtkType type)
-{
- GtkTypeNode *node;
-
- LOOKUP_TYPE_NODE (node, type);
- if (node)
- return node->parent_type;
-
- return 0;
-}
-
-gpointer
-gtk_type_parent_class (GtkType type)
-{
- GtkTypeNode *node;
-
- LOOKUP_TYPE_NODE (node, type);
- g_return_val_if_fail (node != NULL, NULL);
-
- if (node)
- {
- LOOKUP_TYPE_NODE (node, node->parent_type);
-
- if (node)
- {
- if (!node->klass)
- {
- type = node->type;
- gtk_type_class_init (type);
- LOOKUP_TYPE_NODE (node, type);
- }
-
- return node->klass;
- }
+ class = g_type_class_ref (type);
+ g_assert (class != NULL);
+ g_type_set_qdata (type, quark_static_class, class);
}
-
- return NULL;
-}
-gpointer
-gtk_type_class (GtkType type)
-{
- GtkTypeNode *node;
-
- LOOKUP_TYPE_NODE (node, type);
- g_return_val_if_fail (node != NULL, NULL);
-
- if (!node->klass)
- {
- type = node->type;
- gtk_type_class_init (type);
- LOOKUP_TYPE_NODE (node, type);
- }
-
- return node->klass;
+ return class;
}
gpointer
gtk_type_new (GtkType type)
{
- GtkTypeNode *node;
- GtkTypeObject *tobject;
- gpointer klass;
-
- LOOKUP_TYPE_NODE (node, type);
- g_return_val_if_fail (node != NULL, NULL);
-
- klass = node->klass;
- if (!klass)
- {
- klass = gtk_type_class (type);
- LOOKUP_TYPE_NODE (node, type);
- }
- node->chunk_alloc_locked = TRUE;
-
- if (node->mem_chunk)
- tobject = g_mem_chunk_alloc0 (node->mem_chunk);
- else
- tobject = g_malloc0 (node->type_info.object_size);
-
- /* we need to call the base classes' object_init_func for derived
- * objects with the object's ->klass field still pointing to the
- * corresponding base class, otherwise overridden class functions
- * could get called with partly-initialized objects. the real object
- * class is passed as second argment to the initializers.
- */
- if (node->n_supers)
- {
- guint i;
- GtkType *supers;
- GtkTypeNode *pnode;
+ gpointer object;
- supers = node->supers;
- for (i = node->n_supers; i > 0; i--)
- {
- LOOKUP_TYPE_NODE (pnode, supers[i]);
- if (pnode->type_info.object_init_func)
- {
- tobject->klass = pnode->klass;
- pnode->type_info.object_init_func (tobject, klass);
- }
- }
- LOOKUP_TYPE_NODE (node, type);
- }
- tobject->klass = klass;
- if (node->type_info.object_init_func)
- {
- node->type_info.object_init_func (tobject, klass);
- tobject->klass = klass;
- }
-
- return tobject;
-}
+ g_return_val_if_fail (GTK_TYPE_IS_OBJECT (type), NULL);
-void
-gtk_type_free (GtkType type,
- gpointer mem)
-{
- GtkTypeNode *node;
-
- g_return_if_fail (mem != NULL);
- LOOKUP_TYPE_NODE (node, type);
- g_return_if_fail (node != NULL);
-
- if (node->mem_chunk)
- g_mem_chunk_free (node->mem_chunk, mem);
- else
- g_free (mem);
-}
+ object = g_type_create_instance (type);
-GList*
-gtk_type_children_types (GtkType type)
-{
- GtkTypeNode *node;
-
- LOOKUP_TYPE_NODE (node, type);
- if (node)
- return node->children_types;
-
- return NULL;
+ return object;
}
-void
-gtk_type_describe_heritage (GtkType type)
-{
- GtkTypeNode *node;
- gchar *is_a = "";
-
- LOOKUP_TYPE_NODE (node, type);
-
- while (node)
- {
- if (node->type_info.type_name)
- g_message ("%s%s",
- is_a,
- node->type_info.type_name);
- else
- g_message ("%s<unnamed type>",
- is_a);
- is_a = "is a ";
-
- LOOKUP_TYPE_NODE (node, node->parent_type);
- }
-}
+/* includes for various places
+ * with enum definitions
+ */
+#include "makeenums.h"
+/* type variable declarations
+ */
+#include "gtktypebuiltins_vars.c"
+GType GTK_TYPE_IDENTIFIER = 0;
+#include "gtktypebuiltins_evals.c" /* enum value definition arrays */
void
-gtk_type_describe_tree (GtkType type,
- gboolean show_size)
+gtk_type_init (void)
{
- GtkTypeNode *node;
-
- LOOKUP_TYPE_NODE (node, type);
-
- if (node)
- {
- static gint indent = 0;
- GList *list;
- guint old_indent;
+ static gboolean initialized = FALSE;
+
+ if (!initialized)
+ {
+ static const struct {
+ GtkType type_id;
+ gchar *name;
+ } fundamental_info[] = {
+ { GTK_TYPE_CHAR, "gchar" },
+ { GTK_TYPE_UCHAR, "guchar" },
+ { GTK_TYPE_BOOL, "gboolean" },
+ { GTK_TYPE_INT, "gint" },
+ { GTK_TYPE_UINT, "guint" },
+ { GTK_TYPE_LONG, "glong" },
+ { GTK_TYPE_ULONG, "gulong" },
+ { GTK_TYPE_FLOAT, "gfloat" },
+ { GTK_TYPE_DOUBLE, "gdouble" },
+ { GTK_TYPE_POINTER, "gpointer" },
+ { GTK_TYPE_SIGNAL, "GtkSignal" },
+ };
+ static struct {
+ gchar *type_name;
+ GtkType *type_id;
+ GtkType parent;
+ const GtkEnumValue *values;
+ } builtin_info[GTK_TYPE_N_BUILTINS + 1] = {
+#include "gtktypebuiltins_ids.c" /* type entries */
+ { NULL }
+ };
+ GTypeFundamentalInfo finfo = { 0, };
+ GTypeInfo tinfo = { 0, };
+ GtkType type_id;
guint i;
- GString *gstring;
- gstring = g_string_new ("");
-
- for (i = 0; i < indent; i++)
- g_string_append_c (gstring, ' ');
-
- if (node->type_info.type_name)
- g_string_append (gstring, node->type_info.type_name);
- else
- g_string_append (gstring, "<unnamed type>");
-
- if (show_size)
- g_string_sprintfa (gstring, " (%d bytes)", node->type_info.object_size);
+ initialized = TRUE;
- g_message ("%s", gstring->str);
- g_string_free (gstring, TRUE);
-
- old_indent = indent;
- indent += 4;
-
- for (list = node->children_types; list; list = list->next)
- gtk_type_describe_tree (GPOINTER_TO_UINT (list->data), show_size);
+ /* initialize GLib type system
+ */
+ g_type_init ();
- indent = old_indent;
- }
-}
+ /* GTK_TYPE_OBJECT
+ */
+ gtk_object_get_type ();
-gboolean
-gtk_type_is_a (GtkType type,
- GtkType is_a_type)
-{
- if (type == is_a_type)
- return TRUE;
- else
- {
- GtkTypeNode *node;
-
- LOOKUP_TYPE_NODE (node, type);
- if (node)
+ /* compatibility fundamentals
+ */
+ for (i = 0; i < sizeof (fundamental_info) / sizeof (fundamental_info[0]); i++)
{
- GtkTypeNode *a_node;
-
- LOOKUP_TYPE_NODE (a_node, is_a_type);
- if (a_node)
- {
- if (a_node->n_supers <= node->n_supers)
- return node->supers[node->n_supers - a_node->n_supers] == is_a_type;
- }
+ type_id = g_type_register_fundamental (fundamental_info[i].type_id,
+ fundamental_info[i].name,
+ &finfo,
+ &tinfo);
+ g_assert (type_id == fundamental_info[i].type_id);
}
- }
-
- return FALSE;
-}
-static void
-gtk_type_class_init (GtkType type)
-{
- GtkTypeNode *node;
+ /* GTK_TYPE_STRING & GTK_TYPE_IDENTIFIER
+ */
+ finfo.type_flags = G_TYPE_FLAG_DERIVABLE;
+ type_id = g_type_register_fundamental (GTK_TYPE_STRING, "GtkString", &finfo, &tinfo);
+ g_assert (type_id == GTK_TYPE_STRING);
+ GTK_TYPE_IDENTIFIER = g_type_register_static (GTK_TYPE_STRING, "GtkIdentifier", &tinfo);
- /* we need to relookup nodes everytime we called an external function */
- LOOKUP_TYPE_NODE (node, type);
-
- if (!node->klass && node->type_info.class_size)
- {
- GtkTypeClass *type_class;
- GtkTypeNode *base_node;
- GSList *slist;
-
- if (node->type_info.class_size < sizeof (GtkTypeClass))
- g_warning ("The `%s' class is too small to inherit from GtkTypeClass",
- node->type_info.type_name);
-
- node->klass = g_malloc0 (node->type_info.class_size);
-
- if (node->parent_type)
- {
- GtkTypeNode *parent;
-
- LOOKUP_TYPE_NODE (parent, node->parent_type);
-
- if (node->type_info.class_size < parent->type_info.class_size)
- g_warning ("The `%s' class is smaller than its parent class `%s'",
- node->type_info.type_name,
- parent->type_info.type_name);
-
- if (!parent->klass)
- {
- gtk_type_class_init (parent->type);
- LOOKUP_TYPE_NODE (node, type);
- LOOKUP_TYPE_NODE (parent, node->parent_type);
- }
-
- if (parent->klass)
- memcpy (node->klass, parent->klass, parent->type_info.class_size);
- }
-
- type_class = node->klass;
- type_class->type = node->type;
-
- /* stack all base class initialization functions, so we
- * call them in ascending order.
+ /* GTK_TYPE_BOXED
*/
- base_node = node;
- slist = NULL;
- while (base_node)
- {
- if (base_node->type_info.base_class_init_func)
- slist = g_slist_prepend (slist, base_node->type_info.base_class_init_func);
- LOOKUP_TYPE_NODE (base_node, base_node->parent_type);
- }
- if (slist)
+ finfo.type_flags = G_TYPE_FLAG_DERIVABLE;
+ type_id = g_type_register_fundamental (GTK_TYPE_BOXED, "GtkBoxed", &finfo, &tinfo);
+ g_assert (type_id == GTK_TYPE_BOXED);
+
+ /* enums and flags
+ */
+ for (i = 0; i < GTK_TYPE_N_BUILTINS; i++)
{
- GSList *walk;
-
- for (walk = slist; walk; walk = walk->next)
- {
- GtkClassInitFunc base_class_init;
-
- base_class_init = walk->data;
- base_class_init (node->klass);
- LOOKUP_TYPE_NODE (node, type);
- }
- g_slist_free (slist);
+ GtkType type_id = 0;
+
+ if (builtin_info[i].parent == G_TYPE_ENUM)
+ type_id = g_enum_register_static (builtin_info[i].type_name, builtin_info[i].values);
+ else if (builtin_info[i].parent == G_TYPE_FLAGS)
+ type_id = g_flags_register_static (builtin_info[i].type_name, builtin_info[i].values);
+ else if (builtin_info[i].parent == GTK_TYPE_BOXED)
+ type_id = g_type_register_static (GTK_TYPE_BOXED, builtin_info[i].type_name, &tinfo);
+ else
+ g_assert_not_reached ();
+
+ *builtin_info[i].type_id = type_id;
}
-
- if (node->type_info.class_init_func)
- node->type_info.class_init_func (node->klass);
- }
-}
-
-static inline gchar*
-gtk_type_descriptive_name (GtkType type)
-{
- gchar *name;
-
- name = gtk_type_name (type);
- if (!name)
- name = "(unknown)";
-
- return name;
-}
-
-GtkTypeObject*
-gtk_type_check_object_cast (GtkTypeObject *type_object,
- GtkType cast_type)
-{
- if (!type_object)
- {
- g_warning ("invalid cast from (NULL) pointer to `%s'",
- gtk_type_descriptive_name (cast_type));
- return type_object;
}
- if (!type_object->klass)
- {
- g_warning ("invalid unclassed pointer in cast to `%s'",
- gtk_type_descriptive_name (cast_type));
- return type_object;
- }
- /* currently, GTK_TYPE_OBJECT is the lowest fundamental type
- * dominator for types that introduce classes.
- */
- if (type_object->klass->type < GTK_TYPE_OBJECT)
- {
- g_warning ("invalid class type `%s' in cast to `%s'",
- gtk_type_descriptive_name (type_object->klass->type),
- gtk_type_descriptive_name (cast_type));
- return type_object;
- }
- if (!gtk_type_is_a (type_object->klass->type, cast_type))
- {
- g_warning ("invalid cast from `%s' to `%s'",
- gtk_type_descriptive_name (type_object->klass->type),
- gtk_type_descriptive_name (cast_type));
- return type_object;
- }
-
- return type_object;
-}
-
-GtkTypeClass*
-gtk_type_check_class_cast (GtkTypeClass *klass,
- GtkType cast_type)
-{
- if (!klass)
- {
- g_warning ("invalid class cast from (NULL) pointer to `%s'",
- gtk_type_descriptive_name (cast_type));
- return klass;
- }
- /* currently, GTK_TYPE_OBJECT is the lowest fundamental type
- * dominator for types that introduce classes.
- */
- if (klass->type < GTK_TYPE_OBJECT)
- {
- g_warning ("invalid class type `%s' in class cast to `%s'",
- gtk_type_descriptive_name (klass->type),
- gtk_type_descriptive_name (cast_type));
- return klass;
- }
- if (!gtk_type_is_a (klass->type, cast_type))
- {
- g_warning ("invalid class cast from `%s' to `%s'",
- gtk_type_descriptive_name (klass->type),
- gtk_type_descriptive_name (cast_type));
- return klass;
- }
-
- return klass;
}
GtkEnumValue*
-gtk_type_enum_get_values (GtkType enum_type)
-{
- if (GTK_FUNDAMENTAL_TYPE (enum_type) == GTK_TYPE_ENUM ||
- GTK_FUNDAMENTAL_TYPE (enum_type) == GTK_TYPE_FLAGS)
- {
- GtkTypeNode *node;
-
- LOOKUP_TYPE_NODE (node, enum_type);
- if (node)
- return (GtkEnumValue*) node->type_info.reserved_1;
- }
-
- g_warning ("gtk_type_enum_get_values(): type `%s' is not derived from `GtkEnum' or `GtkFlags'",
- gtk_type_name (enum_type));
-
- return NULL;
-}
-
-GtkFlagValue*
-gtk_type_flags_get_values (GtkType flags_type)
+gtk_type_enum_get_values (GtkType enum_type)
{
- return gtk_type_enum_get_values (flags_type);
-}
+ GEnumClass *class;
-GtkEnumValue*
-gtk_type_enum_find_value (GtkType enum_type,
- const gchar *value_name)
-{
- g_return_val_if_fail (value_name != NULL, NULL);
+ g_return_val_if_fail (G_TYPE_IS_ENUM (enum_type), NULL);
- if (GTK_FUNDAMENTAL_TYPE (enum_type) == GTK_TYPE_ENUM ||
- GTK_FUNDAMENTAL_TYPE (enum_type) == GTK_TYPE_FLAGS)
- {
- GtkEnumValue *vals;
-
- vals = gtk_type_enum_get_values (enum_type);
- if (vals)
- while (vals->value_name)
- {
- if (strcmp (vals->value_name, value_name) == 0 ||
- strcmp (vals->value_nick, value_name) == 0)
- return vals;
- vals++;
- }
- }
- else
- g_warning ("gtk_type_enum_find_value(): type `%s' is not derived from `GtkEnum' or `GtkFlags'",
- gtk_type_name (enum_type));
+ class = gtk_type_class (enum_type);
- return NULL;
+ return class->values;
}
GtkFlagValue*
-gtk_type_flags_find_value (GtkType flag_type,
- const gchar *value_name)
-{
- g_return_val_if_fail (value_name != NULL, NULL);
-
- return gtk_type_enum_find_value (flag_type, value_name);
-}
-
-typedef struct _GtkTypeVarargType GtkTypeVarargType;
-struct _GtkTypeVarargType
+gtk_type_flags_get_values (GtkType flags_type)
{
- GtkType foreign_type;
- GtkType varargs_type;
-};
-
-static GtkTypeVarargType *vararg_types = NULL;
-static guint n_vararg_types = 0;
+ GFlagsClass *class;
-void
-gtk_type_set_varargs_type (GtkType foreign_type,
- GtkType varargs_type)
-{
- g_return_if_fail (foreign_type == GTK_FUNDAMENTAL_TYPE (foreign_type));
- g_return_if_fail (foreign_type > GTK_TYPE_FUNDAMENTAL_LAST);
-
- if (!((varargs_type >= GTK_TYPE_STRUCTURED_FIRST &&
- varargs_type <= GTK_TYPE_STRUCTURED_LAST) ||
- (varargs_type >= GTK_TYPE_FLAT_FIRST &&
- varargs_type <= GTK_TYPE_FLAT_LAST) ||
- varargs_type == GTK_TYPE_NONE))
- {
- g_warning ("invalid varargs type `%s' for fundamental type `%s'",
- gtk_type_name (varargs_type),
- gtk_type_name (foreign_type));
- return;
- }
- if (gtk_type_get_varargs_type (foreign_type))
- {
- g_warning ("varargs type is already registered for fundamental type `%s'",
- gtk_type_name (foreign_type));
- return;
- }
+ g_return_val_if_fail (G_TYPE_IS_FLAGS (flags_type), NULL);
- n_vararg_types++;
- vararg_types = g_realloc (vararg_types, sizeof (GtkTypeVarargType) * n_vararg_types);
+ class = gtk_type_class (flags_type);
- vararg_types[n_vararg_types - 1].foreign_type = foreign_type;
- vararg_types[n_vararg_types - 1].varargs_type = varargs_type;
+ return class->values;
}
-GtkType
-gtk_type_get_varargs_type (GtkType foreign_type)
+GtkEnumValue*
+gtk_type_enum_find_value (GtkType enum_type,
+ const gchar *value_name)
{
- GtkType type;
- guint i;
-
- type = GTK_FUNDAMENTAL_TYPE (foreign_type);
- if (type <= GTK_TYPE_FUNDAMENTAL_LAST)
- return type;
-
- for (i = 0; i < n_vararg_types; i++)
- if (vararg_types[i].foreign_type == type)
- return vararg_types[i].varargs_type;
+ GtkEnumValue *value;
+ GEnumClass *class;
- return 0;
-}
-
-static inline GtkType
-gtk_type_register_intern (gchar *name,
- GtkType parent,
- const GtkEnumValue *values)
-{
- GtkType type_id;
- GtkTypeInfo info;
-
- info.type_name = name;
- info.object_size = 0;
- info.class_size = 0;
- info.class_init_func = NULL;
- info.object_init_func = NULL;
- info.reserved_1 = (gpointer) values;
- info.reserved_2 = NULL;
-
- /* relookup pointers afterwards.
- */
- type_id = gtk_type_create (parent, name, &info);
-
- if (type_id && values)
- {
- guint i;
-
- /* check for proper type consistency and NULL termination
- * of value array
- */
- g_assert (GTK_FUNDAMENTAL_TYPE (type_id) == GTK_TYPE_ENUM ||
- GTK_FUNDAMENTAL_TYPE (type_id) == GTK_TYPE_FLAGS);
-
- i = 0;
- while (values[i].value_name)
- i++;
-
- g_assert (values[i].value_name == NULL && values[i].value_nick == NULL);
- }
-
- return type_id;
-}
+ g_return_val_if_fail (G_TYPE_IS_ENUM (enum_type), NULL);
+ g_return_val_if_fail (value_name != NULL, NULL);
-GtkType
-gtk_type_register_enum (const gchar *type_name,
- GtkEnumValue *values)
-{
- GtkType type_id;
- gchar *name;
-
- g_return_val_if_fail (type_name != NULL, 0);
-
- name = g_strdup (type_name);
-
- /* relookup pointers afterwards.
- */
- type_id = gtk_type_register_intern (name, GTK_TYPE_ENUM, values);
-
- if (!type_id)
- g_free (name);
-
- return type_id;
-}
+ class = gtk_type_class (enum_type);
+ value = g_enum_get_value_by_name (class, value_name);
+ if (!value)
+ value = g_enum_get_value_by_nick (class, value_name);
-GtkType
-gtk_type_register_flags (const gchar *type_name,
- GtkFlagValue *values)
-{
- GtkType type_id;
- gchar *name;
-
- g_return_val_if_fail (type_name != NULL, 0);
-
- name = g_strdup (type_name);
-
- /* relookup pointers afterwards.
- */
- type_id = gtk_type_register_intern (name, GTK_TYPE_FLAGS, values);
-
- if (!type_id)
- g_free (name);
-
- return type_id;
+ return value;
}
-GtkTypeQuery*
-gtk_type_query (GtkType type)
+GtkFlagValue*
+gtk_type_flags_find_value (GtkType flags_type,
+ const gchar *value_name)
{
- GtkTypeNode *node;
-
- LOOKUP_TYPE_NODE (node, type);
- if (node)
- {
- GtkTypeQuery *query;
-
- query = g_new0 (GtkTypeQuery, 1);
- query->type = type;
- query->type_name = node->type_info.type_name;
- query->object_size = node->type_info.object_size;
- query->class_size = node->type_info.class_size;
-
- return query;
- }
-
- return NULL;
-}
-
-extern void gtk_object_init_type (void);
+ GtkFlagValue *value;
+ GFlagsClass *class;
-#include "makeenums.h" /* include for various places
- * with enum definitions
- */
-#include "gtktypebuiltins_vars.c" /* type variable declarations
- */
-#include "gtktypebuiltins_evals.c" /* enum value definition arrays
- */
+ g_return_val_if_fail (G_TYPE_IS_FLAGS (flags_type), NULL);
+ g_return_val_if_fail (value_name != NULL, NULL);
-static void
-gtk_type_init_builtin_types (void)
-{
- /* GTK_TYPE_INVALID has typeid 0. The first type id returned by
- * gtk_type_unique is 1, which is GTK_TYPE_NONE. And so on.
- */
-
- static const struct {
- GtkType type_id;
- gchar *name;
- } fundamental_info[] = {
- { GTK_TYPE_NONE, "void" },
- { GTK_TYPE_CHAR, "gchar" },
- { GTK_TYPE_UCHAR, "guchar" },
- { GTK_TYPE_BOOL, "gboolean" },
- { GTK_TYPE_INT, "gint" },
- { GTK_TYPE_UINT, "guint" },
- { GTK_TYPE_LONG, "glong" },
- { GTK_TYPE_ULONG, "gulong" },
- { GTK_TYPE_FLOAT, "gfloat" },
- { GTK_TYPE_DOUBLE, "gdouble" },
- { GTK_TYPE_STRING, "GtkString" },
- { GTK_TYPE_ENUM, "GtkEnum" },
- { GTK_TYPE_FLAGS, "GtkFlags" },
- { GTK_TYPE_BOXED, "GtkBoxed" },
- { GTK_TYPE_POINTER, "gpointer" },
-
- { GTK_TYPE_SIGNAL, "GtkSignal" },
- { GTK_TYPE_ARGS, "GtkArgs" },
- { GTK_TYPE_CALLBACK, "GtkCallback" },
- { GTK_TYPE_C_CALLBACK, "GtkCCallback" },
- { GTK_TYPE_FOREIGN, "GtkForeign" },
- };
- static struct {
- gchar *type_name;
- GtkType *type_id;
- GtkType parent;
- const GtkEnumValue *values;
- } builtin_info[GTK_TYPE_NUM_BUILTINS + 1] = {
-#include "gtktypebuiltins_ids.c" /* type entries */
- { NULL }
- };
- guint i;
-
- for (i = 0; i < sizeof (fundamental_info) / sizeof (fundamental_info[0]); i++)
- {
- GtkType type_id;
-
- /* relookup pointers afterwards.
- */
- type_id = gtk_type_register_intern (fundamental_info[i].name, 0, NULL);
-
- g_assert (type_id == fundamental_info[i].type_id);
- }
-
- gtk_object_init_type ();
-
- for (i = 0; i < GTK_TYPE_NUM_BUILTINS; i++)
- {
- GtkType type_id;
-
- g_assert (builtin_info[i].type_name != NULL);
-
- /* relookup pointers afterwards.
- */
- type_id = gtk_type_register_intern (builtin_info[i].type_name,
- builtin_info[i].parent,
- builtin_info[i].values);
-
- g_assert (GTK_TYPE_SEQNO (type_id) > GTK_TYPE_FUNDAMENTAL_MAX);
-
- (*builtin_info[i].type_id) = type_id;
- }
-}
+ class = gtk_type_class (flags_type);
+ value = g_flags_get_value_by_name (class, value_name);
+ if (!value)
+ value = g_flags_get_value_by_nick (class, value_name);
-GtkType
-gtk_identifier_get_type (void)
-{
- static GtkType identifier_type = 0;
-
- if (!identifier_type)
- identifier_type = gtk_type_register_intern ("GtkIdentifier", GTK_TYPE_STRING, NULL);
-
- return identifier_type;
+ return value;
}
diff --git a/gtk/gtktypeutils.h b/gtk/gtktypeutils.h
index ee5d50b05f..30f1bc0e81 100644
--- a/gtk/gtktypeutils.h
+++ b/gtk/gtktypeutils.h
@@ -18,7 +18,7 @@
*/
/*
- * Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
+ * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
@@ -28,7 +28,7 @@
#define __GTK_TYPE_UTILS_H__
-#include <glib.h>
+#include <glib-object.h>
#ifdef __cplusplus
@@ -37,168 +37,91 @@ extern "C" {
/* Fundamental Types
+ * many of these are just aliases for GLib types to maintain
+ * compatibility
*/
-typedef enum
+typedef enum /*< skip >*/
{
- GTK_TYPE_INVALID,
- GTK_TYPE_NONE,
-
- /* flat types */
- GTK_TYPE_CHAR,
- GTK_TYPE_UCHAR,
- GTK_TYPE_BOOL,
- GTK_TYPE_INT,
- GTK_TYPE_UINT,
- GTK_TYPE_LONG,
- GTK_TYPE_ULONG,
- GTK_TYPE_FLOAT,
- GTK_TYPE_DOUBLE,
- GTK_TYPE_STRING,
- GTK_TYPE_ENUM,
- GTK_TYPE_FLAGS,
- GTK_TYPE_BOXED,
- GTK_TYPE_POINTER,
-
- /* structured types */
- GTK_TYPE_SIGNAL,
- GTK_TYPE_ARGS,
- GTK_TYPE_CALLBACK,
- GTK_TYPE_C_CALLBACK,
- GTK_TYPE_FOREIGN,
-
- /* base type node of the object system */
- GTK_TYPE_OBJECT
+ GTK_TYPE_INVALID = G_TYPE_INVALID,
+ GTK_TYPE_NONE = G_TYPE_NONE,
+ GTK_TYPE_ENUM = G_TYPE_ENUM,
+ GTK_TYPE_FLAGS = G_TYPE_FLAGS,
+
+ /* GtkArg types */
+ GTK_TYPE_CHAR = G_TYPE_GTK_CHAR,
+ GTK_TYPE_UCHAR = G_TYPE_GTK_UCHAR,
+ GTK_TYPE_BOOL = G_TYPE_GTK_BOOL,
+ GTK_TYPE_INT = G_TYPE_GTK_INT,
+ GTK_TYPE_UINT = G_TYPE_GTK_UINT,
+ GTK_TYPE_LONG = G_TYPE_GTK_LONG,
+ GTK_TYPE_ULONG = G_TYPE_GTK_ULONG,
+ GTK_TYPE_FLOAT = G_TYPE_GTK_FLOAT,
+ GTK_TYPE_DOUBLE = G_TYPE_GTK_DOUBLE,
+ GTK_TYPE_STRING = G_TYPE_GTK_STRING,
+ GTK_TYPE_BOXED = G_TYPE_GTK_BOXED,
+ GTK_TYPE_POINTER = G_TYPE_GTK_POINTER,
+ GTK_TYPE_SIGNAL = G_TYPE_GTK_SIGNAL
} GtkFundamentalType;
-/* bounds definitions for type sets, these are provided to distinct
- * between fundamental types with if() statements, and to build
- * up foreign fundamentals
- */
-#define GTK_TYPE_FLAT_FIRST GTK_TYPE_CHAR
-#define GTK_TYPE_FLAT_LAST GTK_TYPE_POINTER
-#define GTK_TYPE_STRUCTURED_FIRST GTK_TYPE_SIGNAL
-#define GTK_TYPE_STRUCTURED_LAST GTK_TYPE_FOREIGN
-#define GTK_TYPE_FUNDAMENTAL_LAST GTK_TYPE_OBJECT
-#define GTK_TYPE_FUNDAMENTAL_MAX (32)
+/* --- type macros --- */
+#define GTK_CLASS_NAME(class) (g_type_name (G_TYPE_FROM_CLASS (class)))
+#define GTK_CLASS_TYPE(class) (G_TYPE_FROM_CLASS (class))
+#define GTK_TYPE_IS_OBJECT(type) (g_type_is_a ((type), GTK_TYPE_OBJECT))
-/* retrive a structure offset */
-#ifdef offsetof
-#define GTK_STRUCT_OFFSET(struct, field) ((gint) offsetof (struct, field))
-#else /* !offsetof */
-#define GTK_STRUCT_OFFSET(struct, field) ((gint) ((gchar*) &((struct*) 0)->field))
-#endif /* !offsetof */
-
-/* The debugging versions of the casting macros make sure the cast is "ok"
- * before proceeding, but they are definately slower than their less
- * careful counterparts as they involve extra ``is a'' checks.
- */
-#ifdef GTK_NO_CHECK_CASTS
-# define GTK_CHECK_CAST(tobj, cast_type, cast) ((cast*) (tobj))
-# define GTK_CHECK_CLASS_CAST(tclass,cast_type,cast) ((cast*) (tclass))
-#else /* !GTK_NO_CHECK_CASTS */
-# define GTK_CHECK_CAST(tobj, cast_type, cast) \
- ((cast*) gtk_type_check_object_cast ((GtkTypeObject*) (tobj), (cast_type)))
-# define GTK_CHECK_CLASS_CAST(tclass,cast_type,cast) \
- ((cast*) gtk_type_check_class_cast ((GtkTypeClass*) (tclass), (cast_type)))
-#endif /* GTK_NO_CHECK_CASTS */
-#define GTK_CHECK_GET_CLASS(obj,type,klass) ((klass*) (((GtkTypeObject*) (obj))->klass))
-
-/* Determines whether `type_object' and `type_class' are a type of `otype'.
+/* outdated macros that really shouldn't e used anymore,
+ * use the GLib type system instead
*/
-#define GTK_CHECK_TYPE(type_object, otype) ( \
- ((GtkTypeObject*) (type_object)) != NULL && \
- GTK_CHECK_CLASS_TYPE (((GtkTypeObject*) (type_object))->klass, (otype)) \
-)
-#define GTK_CHECK_CLASS_TYPE(type_class, otype) ( \
- ((GtkTypeClass*) (type_class)) != NULL && \
- gtk_type_is_a (((GtkTypeClass*) (type_class))->type, (otype)) \
-)
-
-
-
-
-/* A GtkType holds a unique type id
- */
-typedef guint GtkType;
-
-typedef struct _GtkTypeObject GtkTypeObject;
-typedef struct _GtkTypeClass GtkTypeClass;
+#ifndef GTK_DISABLE_COMPAT_H
+#define GTK_TYPE_FUNDAMENTAL_LAST (G_TYPE_LAST_RESERVED_FUNDAMENTAL - 1)
+#define GTK_TYPE_FUNDAMENTAL_MAX (G_TYPE_FUNDAMENTAL_MAX)
+#endif /* GTK_DISABLE_COMPAT_H */
+
+/* glib macro wrappers (compatibility) */
+#define GTK_STRUCT_OFFSET G_STRUCT_OFFSET
+#define GTK_CHECK_CAST G_TYPE_CHECK_INSTANCE_CAST
+#define GTK_CHECK_CLASS_CAST G_TYPE_CHECK_CLASS_CAST
+#define GTK_CHECK_GET_CLASS G_TYPE_INSTANCE_GET_CLASS
+#define GTK_CHECK_TYPE G_TYPE_CHECK_INSTANCE_TYPE
+#define GTK_CHECK_CLASS_TYPE G_TYPE_CHECK_CLASS_TYPE
+#define GTK_FUNDAMENTAL_TYPE G_TYPE_FUNDAMENTAL
+
+/* glib type wrappers (compatibility) */
+typedef GType GtkType;
+typedef GTypeInstance GtkTypeObject;
+typedef GTypeClass GtkTypeClass;
+typedef GBaseInitFunc GtkClassInitFunc;
+typedef GInstanceInitFunc GtkObjectInitFunc;
/* Builtin Types
*/
#include <gtk/gtktypebuiltins.h>
-#define GTK_TYPE_IDENTIFIER (gtk_identifier_get_type ())
-GtkType gtk_identifier_get_type (void);
-/* Macros
- */
-#define GTK_TYPE_MAKE(parent_t, seqno) (((seqno) << 8) | GTK_FUNDAMENTAL_TYPE (parent_t))
-#define GTK_FUNDAMENTAL_TYPE(type) ((GtkFundamentalType) ((type) & 0xFF))
-#define GTK_TYPE_SEQNO(type) ((type) > 0xFF ? (type) >> 8 : (type))
-
-typedef struct _GtkArg GtkArg;
-typedef struct _GtkObject GtkObject; /* forward declaration of object type */
-typedef struct _GtkTypeInfo GtkTypeInfo;
-typedef struct _GtkTypeQuery GtkTypeQuery;
-typedef struct _GtkEnumValue GtkEnumValue;
-typedef struct _GtkEnumValue GtkFlagValue;
-
-
-#define GTK_SIGNAL_FUNC(f) ((GtkSignalFunc) f)
-
-typedef void (*GtkClassInitFunc) (gpointer klass);
-typedef void (*GtkObjectInitFunc) (gpointer object,
- gpointer klass);
-typedef void (*GtkSignalFunc) ();
-typedef gint (*GtkFunction) (gpointer data);
-typedef void (*GtkDestroyNotify) (gpointer data);
-typedef void (*GtkCallbackMarshal) (GtkObject *object,
- gpointer data,
- guint n_args,
- GtkArg *args);
-typedef void (*GtkSignalMarshaller) (GtkObject *object,
- GtkSignalFunc func,
- gpointer func_data,
- GtkArg *args);
-
-/* deprecated */
-typedef void (*GtkArgGetFunc) (GtkObject*, GtkArg*, guint);
-typedef void (*GtkArgSetFunc) (GtkObject*, GtkArg*, guint);
-
-
-/* A GtkTypeObject defines the minimum structure requirements
- * for type instances. Type instances returned from gtk_type_new ()
- * and initialized through a GtkObjectInitFunc need to directly inherit
- * from this structure or at least copy its fields one by one.
+/* --- typedefs --- */
+/* here we come with some necessary forward declarations for structures and
+ * provide some fundamental function signatures
*/
-struct _GtkTypeObject
-{
- /* A pointer to the objects class. This will actually point to
- * the derived objects class struct (which will be derived from
- * GtkTypeClass).
- */
- GtkTypeClass *klass;
-};
-
-
-/* A GtkTypeClass defines the minimum structure requirements for
- * a types class. Classes returned from gtk_type_class () and
- * initialized through a GtkClassInitFunc need to directly inherit
- * from this structure or at least copy its fields one by one.
- */
-struct _GtkTypeClass
-{
- /* The type identifier for the objects class. There is
- * one unique identifier per class.
- */
- GtkType type;
-};
-
-
+typedef struct _GtkArg GtkArg;
+typedef struct _GtkObject GtkObject; /* object forward declaration */
+typedef struct _GtkTypeInfo GtkTypeInfo;
+typedef gint (*GtkFunction) (gpointer data);
+typedef void (*GtkDestroyNotify) (gpointer data);
+typedef void (*GtkCallbackMarshal) (GtkObject *object,
+ gpointer data,
+ guint n_args,
+ GtkArg *args);
+typedef void (*GtkSignalFunc) ();
+typedef void (*GtkSignalMarshaller) (GtkObject *object,
+ GtkSignalFunc func,
+ gpointer func_data,
+ GtkArg *args);
+#define GTK_SIGNAL_FUNC(f) ((GtkSignalFunc) (f))
+
+
+/* GtkArg, used to hold differently typed values */
struct _GtkArg
{
GtkType type;
@@ -222,31 +145,14 @@ struct _GtkArg
gfloat float_data;
gdouble double_data;
gchar *string_data;
- gpointer pointer_data;
GtkObject *object_data;
+ gpointer pointer_data;
/* structured values */
struct {
GtkSignalFunc f;
gpointer d;
} signal_data;
- struct {
- gint n_args;
- GtkArg *args;
- } args_data;
- struct {
- GtkCallbackMarshal marshal;
- gpointer data;
- GtkDestroyNotify notify;
- } callback_data;
- struct {
- GtkFunction func;
- gpointer func_data;
- } c_callback_data;
- struct {
- gpointer data;
- GtkDestroyNotify notify;
- } foreign_data;
} d;
};
@@ -254,8 +160,6 @@ struct _GtkArg
* to allow the usage of these macros in combination with the
* adress operator, e.g. &GTK_VALUE_CHAR (*arg)
*/
-
-/* flat values */
#define GTK_VALUE_CHAR(a) ((a).d.char_data)
#define GTK_VALUE_UCHAR(a) ((a).d.uchar_data)
#define GTK_VALUE_BOOL(a) ((a).d.bool_data)
@@ -269,22 +173,14 @@ struct _GtkArg
#define GTK_VALUE_ENUM(a) ((a).d.int_data)
#define GTK_VALUE_FLAGS(a) ((a).d.uint_data)
#define GTK_VALUE_BOXED(a) ((a).d.pointer_data)
-#define GTK_VALUE_POINTER(a) ((a).d.pointer_data)
#define GTK_VALUE_OBJECT(a) ((a).d.object_data)
-
-/* structured values */
+#define GTK_VALUE_POINTER(a) ((a).d.pointer_data)
#define GTK_VALUE_SIGNAL(a) ((a).d.signal_data)
-#define GTK_VALUE_ARGS(a) ((a).d.args_data)
-#define GTK_VALUE_CALLBACK(a) ((a).d.callback_data)
-#define GTK_VALUE_C_CALLBACK(a) ((a).d.c_callback_data)
-#define GTK_VALUE_FOREIGN(a) ((a).d.foreign_data)
/* return location macros, these all narow down to
* pointer types, because return values need to be
* passed by reference
*/
-
-/* flat values */
#define GTK_RETLOC_CHAR(a) ((gchar*) (a).d.pointer_data)
#define GTK_RETLOC_UCHAR(a) ((guchar*) (a).d.pointer_data)
#define GTK_RETLOC_BOOL(a) ((gboolean*) (a).d.pointer_data)
@@ -298,9 +194,14 @@ struct _GtkArg
#define GTK_RETLOC_ENUM(a) ((gint*) (a).d.pointer_data)
#define GTK_RETLOC_FLAGS(a) ((guint*) (a).d.pointer_data)
#define GTK_RETLOC_BOXED(a) ((gpointer*) (a).d.pointer_data)
-#define GTK_RETLOC_POINTER(a) ((gpointer*) (a).d.pointer_data)
#define GTK_RETLOC_OBJECT(a) ((GtkObject**) (a).d.pointer_data)
+#define GTK_RETLOC_POINTER(a) ((gpointer*) (a).d.pointer_data)
+/* GTK_RETLOC_SIGNAL() - no such thing */
+/* type registration, it is recommended to use
+ * g_type_register_static() or
+ * g_type_register_dynamic() instead
+ */
struct _GtkTypeInfo
{
gchar *type_name;
@@ -312,66 +213,37 @@ struct _GtkTypeInfo
gpointer reserved_2;
GtkClassInitFunc base_class_init_func;
};
+GtkType gtk_type_unique (GtkType parent_type,
+ const GtkTypeInfo *gtkinfo);
+gpointer gtk_type_class (GtkType type);
+gpointer gtk_type_new (GtkType type);
-struct _GtkTypeQuery
-{
- GtkType type;
- const gchar *type_name;
- guint object_size;
- guint class_size;
-};
-struct _GtkEnumValue
-{
- guint value;
- gchar *value_name;
- gchar *value_nick;
-};
+/* --- initialize the type system --- */
+void gtk_type_init (void);
+
+/* --- compatibility defines --- */
+#define gtk_type_name g_type_name
+#define gtk_type_from_name g_type_from_name
+#define gtk_type_parent g_type_parent
+#define gtk_type_is_a g_type_is_a
-void gtk_type_init (void);
-GtkType gtk_type_unique (GtkType parent_type,
- const GtkTypeInfo *type_info);
-void gtk_type_set_chunk_alloc (GtkType type,
- guint n_chunks);
-gchar* gtk_type_name (GtkType type);
-GtkType gtk_type_from_name (const gchar *name);
-GtkType gtk_type_parent (GtkType type);
-gpointer gtk_type_class (GtkType type);
-gpointer gtk_type_parent_class (GtkType type);
-GList* gtk_type_children_types (GtkType type);
-gpointer gtk_type_new (GtkType type);
-void gtk_type_free (GtkType type,
- gpointer mem);
-void gtk_type_describe_heritage (GtkType type);
-void gtk_type_describe_tree (GtkType type,
- gboolean show_size);
-gboolean gtk_type_is_a (GtkType type,
- GtkType is_a_type);
-GtkTypeObject* gtk_type_check_object_cast (GtkTypeObject *type_object,
- GtkType cast_type);
-GtkTypeClass* gtk_type_check_class_cast (GtkTypeClass *klass,
- GtkType cast_type);
-GtkType gtk_type_register_enum (const gchar *type_name,
- GtkEnumValue *values);
-GtkType gtk_type_register_flags (const gchar *type_name,
- GtkFlagValue *values);
+
+/* enum/flags compatibility functions, we strongly
+ * recommend to use the glib enum/flags classes directly
+ */
+typedef GEnumValue GtkEnumValue;
+typedef GFlagsValue GtkFlagValue;
GtkEnumValue* gtk_type_enum_get_values (GtkType enum_type);
GtkFlagValue* gtk_type_flags_get_values (GtkType flags_type);
GtkEnumValue* gtk_type_enum_find_value (GtkType enum_type,
const gchar *value_name);
-GtkFlagValue* gtk_type_flags_find_value (GtkType flag_type,
+GtkFlagValue* gtk_type_flags_find_value (GtkType flags_type,
const gchar *value_name);
-/* set the argument collector alias for foreign fundamentals */
-void gtk_type_set_varargs_type (GtkType foreign_type,
- GtkType varargs_type);
-GtkType gtk_type_get_varargs_type (GtkType foreign_type);
-/* Report internal information about a type. The caller has the
- * responsibility to invoke a subsequent g_free (returned_data); but
- * must not modify data pointed to by the members of GtkTypeQuery
- */
-GtkTypeQuery* gtk_type_query (GtkType type);
+/* urg */
+extern GType GTK_TYPE_IDENTIFIER;
#ifdef __cplusplus
diff --git a/gtk/gtkviewport.c b/gtk/gtkviewport.c
index f602e92247..481f59425a 100644
--- a/gtk/gtkviewport.c
+++ b/gtk/gtkviewport.c
@@ -38,7 +38,6 @@ enum {
static void gtk_viewport_class_init (GtkViewportClass *klass);
static void gtk_viewport_init (GtkViewport *viewport);
static void gtk_viewport_destroy (GtkObject *object);
-static void gtk_viewport_finalize (GtkObject *object);
static void gtk_viewport_set_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
@@ -110,23 +109,9 @@ gtk_viewport_class_init (GtkViewportClass *class)
container_class = (GtkContainerClass*) class;
parent_class = (GtkBinClass*) gtk_type_class (GTK_TYPE_BIN);
- gtk_object_add_arg_type ("GtkViewport::hadjustment",
- GTK_TYPE_ADJUSTMENT,
- GTK_ARG_READWRITE | GTK_ARG_CONSTRUCT,
- ARG_HADJUSTMENT);
- gtk_object_add_arg_type ("GtkViewport::vadjustment",
- GTK_TYPE_ADJUSTMENT,
- GTK_ARG_READWRITE | GTK_ARG_CONSTRUCT,
- ARG_VADJUSTMENT);
- gtk_object_add_arg_type ("GtkViewport::shadow_type",
- GTK_TYPE_SHADOW_TYPE,
- GTK_ARG_READWRITE,
- ARG_SHADOW_TYPE);
-
object_class->set_arg = gtk_viewport_set_arg;
object_class->get_arg = gtk_viewport_get_arg;
object_class->destroy = gtk_viewport_destroy;
- object_class->finalize = gtk_viewport_finalize;
widget_class->map = gtk_viewport_map;
widget_class->unmap = gtk_viewport_unmap;
@@ -137,18 +122,31 @@ gtk_viewport_class_init (GtkViewportClass *class)
widget_class->size_request = gtk_viewport_size_request;
widget_class->size_allocate = gtk_viewport_size_allocate;
widget_class->style_set = gtk_viewport_style_set;
+
+ container_class->add = gtk_viewport_add;
+
+ class->set_scroll_adjustments = gtk_viewport_set_scroll_adjustments;
+
+ gtk_object_add_arg_type ("GtkViewport::hadjustment",
+ GTK_TYPE_ADJUSTMENT,
+ GTK_ARG_READWRITE,
+ ARG_HADJUSTMENT);
+ gtk_object_add_arg_type ("GtkViewport::vadjustment",
+ GTK_TYPE_ADJUSTMENT,
+ GTK_ARG_READWRITE,
+ ARG_VADJUSTMENT);
+ gtk_object_add_arg_type ("GtkViewport::shadow_type",
+ GTK_TYPE_SHADOW_TYPE,
+ GTK_ARG_READWRITE,
+ ARG_SHADOW_TYPE);
widget_class->set_scroll_adjustments_signal =
gtk_signal_new ("set_scroll_adjustments",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkViewportClass, set_scroll_adjustments),
gtk_marshal_NONE__POINTER_POINTER,
GTK_TYPE_NONE, 2, GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT);
-
- container_class->add = gtk_viewport_add;
-
- class->set_scroll_adjustments = gtk_viewport_set_scroll_adjustments;
}
static void
@@ -236,24 +234,19 @@ gtk_viewport_destroy (GtkObject *object)
GtkViewport *viewport = GTK_VIEWPORT (object);
if (viewport->hadjustment)
- gtk_signal_disconnect_by_data (GTK_OBJECT (viewport->hadjustment),
- viewport);
+ {
+ gtk_signal_disconnect_by_data (GTK_OBJECT (viewport->hadjustment), viewport);
+ gtk_object_unref (GTK_OBJECT (viewport->hadjustment));
+ viewport->hadjustment = NULL;
+ }
if (viewport->vadjustment)
- gtk_signal_disconnect_by_data (GTK_OBJECT (viewport->vadjustment),
- viewport);
-
- GTK_OBJECT_CLASS(parent_class)->destroy (object);
-}
-
-static void
-gtk_viewport_finalize (GtkObject *object)
-{
- GtkViewport *viewport = GTK_VIEWPORT (object);
-
- gtk_object_unref (GTK_OBJECT (viewport->hadjustment));
- gtk_object_unref (GTK_OBJECT (viewport->vadjustment));
+ {
+ gtk_signal_disconnect_by_data (GTK_OBJECT (viewport->vadjustment), viewport);
+ gtk_object_unref (GTK_OBJECT (viewport->vadjustment));
+ viewport->vadjustment = NULL;
+ }
- GTK_OBJECT_CLASS(parent_class)->finalize (object);
+ GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
GtkAdjustment*
@@ -262,6 +255,9 @@ gtk_viewport_get_hadjustment (GtkViewport *viewport)
g_return_val_if_fail (viewport != NULL, NULL);
g_return_val_if_fail (GTK_IS_VIEWPORT (viewport), NULL);
+ if (!viewport->hadjustment)
+ gtk_viewport_set_hadjustment (viewport, NULL);
+
return viewport->hadjustment;
}
@@ -271,6 +267,9 @@ gtk_viewport_get_vadjustment (GtkViewport *viewport)
g_return_val_if_fail (viewport != NULL, NULL);
g_return_val_if_fail (GTK_IS_VIEWPORT (viewport), NULL);
+ if (!viewport->vadjustment)
+ gtk_viewport_set_vadjustment (viewport, NULL);
+
return viewport->vadjustment;
}
@@ -285,9 +284,9 @@ gtk_viewport_set_hadjustment (GtkViewport *viewport,
if (viewport->hadjustment && viewport->hadjustment != adjustment)
{
- gtk_signal_disconnect_by_data (GTK_OBJECT (viewport->hadjustment),
- (gpointer) viewport);
+ gtk_signal_disconnect_by_data (GTK_OBJECT (viewport->hadjustment), viewport);
gtk_object_unref (GTK_OBJECT (viewport->hadjustment));
+ viewport->hadjustment = NULL;
}
if (!adjustment)
@@ -322,9 +321,9 @@ gtk_viewport_set_vadjustment (GtkViewport *viewport,
if (viewport->vadjustment && viewport->vadjustment != adjustment)
{
- gtk_signal_disconnect_by_data (GTK_OBJECT (viewport->vadjustment),
- (gpointer) viewport);
+ gtk_signal_disconnect_by_data (GTK_OBJECT (viewport->vadjustment), viewport);
gtk_object_unref (GTK_OBJECT (viewport->vadjustment));
+ viewport->vadjustment = NULL;
}
if (!adjustment)
@@ -686,6 +685,12 @@ gtk_viewport_size_allocate (GtkWidget *widget,
viewport = GTK_VIEWPORT (widget);
bin = GTK_BIN (widget);
+ /* demand creation */
+ if (!viewport->hadjustment)
+ gtk_viewport_set_hadjustment (viewport, NULL);
+ if (!viewport->vadjustment)
+ gtk_viewport_set_hadjustment (viewport, NULL);
+
border_width = GTK_CONTAINER (widget)->border_width;
child_allocation.x = 0;
diff --git a/gtk/gtkvscale.c b/gtk/gtkvscale.c
index a27e0ae4b5..003760cbab 100644
--- a/gtk/gtkvscale.c
+++ b/gtk/gtkvscale.c
@@ -30,8 +30,8 @@
#include "gdk/gdkkeysyms.h"
-#define SCALE_CLASS(w) GTK_SCALE_CLASS (GTK_OBJECT (w)->klass)
-#define RANGE_CLASS(w) GTK_RANGE_CLASS (GTK_OBJECT (w)->klass)
+#define SCALE_CLASS(w) GTK_SCALE_GET_CLASS (w)
+#define RANGE_CLASS(w) GTK_RANGE_GET_CLASS (w)
enum {
ARG_0,
@@ -111,7 +111,7 @@ gtk_vscale_class_init (GtkVScaleClass *class)
gtk_object_add_arg_type ("GtkVScale::adjustment",
GTK_TYPE_ADJUSTMENT,
- GTK_ARG_READWRITE | GTK_ARG_CONSTRUCT,
+ GTK_ARG_READWRITE,
ARG_ADJUSTMENT);
object_class->set_arg = gtk_vscale_set_arg;
diff --git a/gtk/gtkvscrollbar.c b/gtk/gtkvscrollbar.c
index 082fb746ba..833f003a6f 100644
--- a/gtk/gtkvscrollbar.c
+++ b/gtk/gtkvscrollbar.c
@@ -31,7 +31,7 @@
#define EPSILON 0.01
-#define RANGE_CLASS(w) GTK_RANGE_CLASS (GTK_OBJECT (w)->klass)
+#define RANGE_CLASS(w) GTK_RANGE_GET_CLASS (w)
enum {
ARG_0,
@@ -97,7 +97,7 @@ gtk_vscrollbar_class_init (GtkVScrollbarClass *class)
gtk_object_add_arg_type ("GtkVScrollbar::adjustment",
GTK_TYPE_ADJUSTMENT,
- GTK_ARG_READWRITE | GTK_ARG_CONSTRUCT,
+ GTK_ARG_READWRITE,
ARG_ADJUSTMENT);
object_class->set_arg = gtk_vscrollbar_set_arg;
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 62127f727c..c09e605e50 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -39,7 +39,7 @@
#include "gdk/gdkprivate.h" /* Used in gtk_reset_shapes_recurse to avoid copy */
-#define WIDGET_CLASS(w) GTK_WIDGET_CLASS (GTK_OBJECT (w)->klass)
+#define WIDGET_CLASS(w) GTK_WIDGET_GET_CLASS (w)
#define INIT_PATH_SIZE (512)
@@ -141,9 +141,9 @@ static void gtk_widget_set_arg (GtkObject *object,
static void gtk_widget_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
-static void gtk_widget_shutdown (GtkObject *object);
+static void gtk_widget_shutdown (GObject *object);
static void gtk_widget_real_destroy (GtkObject *object);
-static void gtk_widget_finalize (GtkObject *object);
+static void gtk_widget_finalize (GObject *object);
static void gtk_widget_real_show (GtkWidget *widget);
static void gtk_widget_real_hide (GtkWidget *widget);
static void gtk_widget_real_map (GtkWidget *widget);
@@ -183,7 +183,7 @@ static gboolean gtk_widget_is_offscreen (GtkWidget *widget);
static GtkWidgetAuxInfo* gtk_widget_aux_info_new (void);
static void gtk_widget_aux_info_destroy (GtkWidgetAuxInfo *aux_info);
-static GtkObjectClass *parent_class = NULL;
+static gpointer parent_class = NULL;
static guint widget_signals[LAST_SIGNAL] = { 0 };
static GMemChunk *aux_info_mem_chunk = NULL;
@@ -241,7 +241,7 @@ gtk_widget_get_type (void)
(GtkClassInitFunc) NULL,
};
- widget_type = gtk_type_unique (gtk_object_get_type (), &widget_info);
+ widget_type = gtk_type_unique (GTK_TYPE_OBJECT, &widget_info);
}
return widget_type;
@@ -265,11 +265,72 @@ gtk_widget_debug_msg (GtkWidget *widget,
static void
gtk_widget_class_init (GtkWidgetClass *klass)
{
- GtkObjectClass *object_class;
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
- object_class = (GtkObjectClass*) klass;
+ parent_class = gtk_type_class (GTK_TYPE_OBJECT);
+
+ gobject_class->shutdown = gtk_widget_shutdown;
+ gobject_class->finalize = gtk_widget_finalize;
+
+ object_class->set_arg = gtk_widget_set_arg;
+ object_class->get_arg = gtk_widget_get_arg;
+ object_class->destroy = gtk_widget_real_destroy;
- parent_class = gtk_type_class (gtk_object_get_type ());
+ klass->activate_signal = 0;
+ klass->set_scroll_adjustments_signal = 0;
+ klass->show = gtk_widget_real_show;
+ klass->show_all = gtk_widget_show;
+ klass->hide = gtk_widget_real_hide;
+ klass->hide_all = gtk_widget_hide;
+ klass->map = gtk_widget_real_map;
+ klass->unmap = gtk_widget_real_unmap;
+ klass->realize = gtk_widget_real_realize;
+ klass->unrealize = gtk_widget_real_unrealize;
+ klass->draw = gtk_widget_real_draw;
+ klass->draw_focus = NULL;
+ klass->size_request = gtk_widget_real_size_request;
+ klass->size_allocate = gtk_widget_real_size_allocate;
+ klass->state_changed = NULL;
+ klass->parent_set = NULL;
+ klass->style_set = gtk_widget_style_set;
+ klass->add_accelerator = (void*) gtk_accel_group_handle_add;
+ klass->remove_accelerator = (void*) gtk_accel_group_handle_remove;
+ klass->grab_focus = gtk_widget_real_grab_focus;
+ klass->event = NULL;
+ klass->button_press_event = NULL;
+ klass->button_release_event = NULL;
+ klass->motion_notify_event = NULL;
+ klass->delete_event = NULL;
+ klass->destroy_event = NULL;
+ klass->expose_event = NULL;
+ klass->key_press_event = gtk_widget_real_key_press_event;
+ klass->key_release_event = gtk_widget_real_key_release_event;
+ klass->enter_notify_event = NULL;
+ klass->leave_notify_event = NULL;
+ klass->configure_event = NULL;
+ klass->focus_in_event = NULL;
+ klass->focus_out_event = NULL;
+ klass->map_event = NULL;
+ klass->unmap_event = NULL;
+ klass->property_notify_event = gtk_selection_property_notify;
+ klass->selection_clear_event = gtk_selection_clear;
+ klass->selection_request_event = gtk_selection_request;
+ klass->selection_notify_event = gtk_selection_notify;
+ klass->selection_received = NULL;
+ klass->proximity_in_event = NULL;
+ klass->proximity_out_event = NULL;
+ klass->drag_begin = NULL;
+ klass->drag_end = NULL;
+ klass->drag_data_delete = NULL;
+ klass->drag_leave = NULL;
+ klass->drag_motion = NULL;
+ klass->drag_drop = NULL;
+ klass->drag_data_received = NULL;
+
+ klass->no_expose_event = NULL;
+
+ klass->debug_msg = gtk_widget_debug_msg;
gtk_object_add_arg_type ("GtkWidget::name", GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_NAME);
gtk_object_add_arg_type ("GtkWidget::parent", GTK_TYPE_CONTAINER, GTK_ARG_READWRITE, ARG_PARENT);
@@ -293,49 +354,49 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[SHOW] =
gtk_signal_new ("show",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, show),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
widget_signals[HIDE] =
gtk_signal_new ("hide",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, hide),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
widget_signals[MAP] =
gtk_signal_new ("map",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, map),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
widget_signals[UNMAP] =
gtk_signal_new ("unmap",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, unmap),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
widget_signals[REALIZE] =
gtk_signal_new ("realize",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, realize),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
widget_signals[UNREALIZE] =
gtk_signal_new ("unrealize",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, unrealize),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
widget_signals[DRAW] =
gtk_signal_new ("draw",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, draw),
gtk_marshal_NONE__POINTER,
GTK_TYPE_NONE, 1,
@@ -343,21 +404,21 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[DRAW_FOCUS] =
gtk_signal_new ("draw_focus",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, draw_focus),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
widget_signals[DRAW_DEFAULT] =
gtk_signal_new ("draw_default",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, draw_default),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
widget_signals[SIZE_REQUEST] =
gtk_signal_new ("size_request",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, size_request),
gtk_marshal_NONE__POINTER,
GTK_TYPE_NONE, 1,
@@ -365,7 +426,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[SIZE_ALLOCATE] =
gtk_signal_new ("size_allocate",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, size_allocate),
gtk_marshal_NONE__POINTER,
GTK_TYPE_NONE, 1,
@@ -373,7 +434,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[STATE_CHANGED] =
gtk_signal_new ("state_changed",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, state_changed),
gtk_marshal_NONE__UINT,
GTK_TYPE_NONE, 1,
@@ -381,7 +442,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[PARENT_SET] =
gtk_signal_new ("parent_set",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, parent_set),
gtk_marshal_NONE__OBJECT,
GTK_TYPE_NONE, 1,
@@ -389,28 +450,28 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[STYLE_SET] =
gtk_signal_new ("style_set",
GTK_RUN_FIRST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, style_set),
gtk_marshal_NONE__POINTER,
GTK_TYPE_NONE, 1,
GTK_TYPE_STYLE);
widget_signals[ADD_ACCELERATOR] =
- gtk_accel_group_create_add (object_class->type, GTK_RUN_LAST,
+ gtk_accel_group_create_add (GTK_CLASS_TYPE (object_class), GTK_RUN_LAST,
GTK_SIGNAL_OFFSET (GtkWidgetClass, add_accelerator));
widget_signals[REMOVE_ACCELERATOR] =
- gtk_accel_group_create_remove (object_class->type, GTK_RUN_LAST,
+ gtk_accel_group_create_remove (GTK_CLASS_TYPE (object_class), GTK_RUN_LAST,
GTK_SIGNAL_OFFSET (GtkWidgetClass, remove_accelerator));
widget_signals[GRAB_FOCUS] =
gtk_signal_new ("grab_focus",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, grab_focus),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
widget_signals[EVENT] =
gtk_signal_new ("event",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, event),
gtk_marshal_BOOL__POINTER,
GTK_TYPE_BOOL, 1,
@@ -418,7 +479,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[BUTTON_PRESS_EVENT] =
gtk_signal_new ("button_press_event",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, button_press_event),
gtk_marshal_BOOL__POINTER,
GTK_TYPE_BOOL, 1,
@@ -426,7 +487,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[BUTTON_RELEASE_EVENT] =
gtk_signal_new ("button_release_event",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, button_release_event),
gtk_marshal_BOOL__POINTER,
GTK_TYPE_BOOL, 1,
@@ -434,7 +495,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[SCROLL_EVENT] =
gtk_signal_new ("scroll_event",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, scroll_event),
gtk_marshal_BOOL__POINTER,
GTK_TYPE_BOOL, 1,
@@ -442,7 +503,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[MOTION_NOTIFY_EVENT] =
gtk_signal_new ("motion_notify_event",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, motion_notify_event),
gtk_marshal_BOOL__POINTER,
GTK_TYPE_BOOL, 1,
@@ -450,7 +511,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[DELETE_EVENT] =
gtk_signal_new ("delete_event",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, delete_event),
gtk_marshal_BOOL__POINTER,
GTK_TYPE_BOOL, 1,
@@ -458,7 +519,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[DESTROY_EVENT] =
gtk_signal_new ("destroy_event",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, destroy_event),
gtk_marshal_BOOL__POINTER,
GTK_TYPE_BOOL, 1,
@@ -466,7 +527,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[EXPOSE_EVENT] =
gtk_signal_new ("expose_event",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, expose_event),
gtk_marshal_BOOL__POINTER,
GTK_TYPE_BOOL, 1,
@@ -474,7 +535,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[KEY_PRESS_EVENT] =
gtk_signal_new ("key_press_event",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, key_press_event),
gtk_marshal_BOOL__POINTER,
GTK_TYPE_BOOL, 1,
@@ -482,7 +543,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[KEY_RELEASE_EVENT] =
gtk_signal_new ("key_release_event",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, key_release_event),
gtk_marshal_BOOL__POINTER,
GTK_TYPE_BOOL, 1,
@@ -490,7 +551,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[ENTER_NOTIFY_EVENT] =
gtk_signal_new ("enter_notify_event",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, enter_notify_event),
gtk_marshal_BOOL__POINTER,
GTK_TYPE_BOOL, 1,
@@ -498,7 +559,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[LEAVE_NOTIFY_EVENT] =
gtk_signal_new ("leave_notify_event",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, leave_notify_event),
gtk_marshal_BOOL__POINTER,
GTK_TYPE_BOOL, 1,
@@ -506,7 +567,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[CONFIGURE_EVENT] =
gtk_signal_new ("configure_event",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, configure_event),
gtk_marshal_BOOL__POINTER,
GTK_TYPE_BOOL, 1,
@@ -514,7 +575,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[FOCUS_IN_EVENT] =
gtk_signal_new ("focus_in_event",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, focus_in_event),
gtk_marshal_BOOL__POINTER,
GTK_TYPE_BOOL, 1,
@@ -522,7 +583,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[FOCUS_OUT_EVENT] =
gtk_signal_new ("focus_out_event",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, focus_out_event),
gtk_marshal_BOOL__POINTER,
GTK_TYPE_BOOL, 1,
@@ -530,7 +591,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[MAP_EVENT] =
gtk_signal_new ("map_event",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, map_event),
gtk_marshal_BOOL__POINTER,
GTK_TYPE_BOOL, 1,
@@ -538,7 +599,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[UNMAP_EVENT] =
gtk_signal_new ("unmap_event",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, unmap_event),
gtk_marshal_BOOL__POINTER,
GTK_TYPE_BOOL, 1,
@@ -546,7 +607,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[PROPERTY_NOTIFY_EVENT] =
gtk_signal_new ("property_notify_event",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, property_notify_event),
gtk_marshal_BOOL__POINTER,
GTK_TYPE_BOOL, 1,
@@ -554,7 +615,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[SELECTION_CLEAR_EVENT] =
gtk_signal_new ("selection_clear_event",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, selection_clear_event),
gtk_marshal_BOOL__POINTER,
GTK_TYPE_BOOL, 1,
@@ -562,7 +623,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[SELECTION_REQUEST_EVENT] =
gtk_signal_new ("selection_request_event",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, selection_request_event),
gtk_marshal_BOOL__POINTER,
GTK_TYPE_BOOL, 1,
@@ -570,7 +631,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[SELECTION_NOTIFY_EVENT] =
gtk_signal_new ("selection_notify_event",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, selection_notify_event),
gtk_marshal_BOOL__POINTER,
GTK_TYPE_BOOL, 1,
@@ -578,7 +639,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[SELECTION_RECEIVED] =
gtk_signal_new ("selection_received",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, selection_received),
gtk_marshal_NONE__POINTER_UINT,
GTK_TYPE_NONE, 2,
@@ -587,7 +648,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[SELECTION_GET] =
gtk_signal_new ("selection_get",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, selection_get),
gtk_marshal_NONE__POINTER_UINT_UINT,
GTK_TYPE_NONE, 3,
@@ -597,7 +658,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[PROXIMITY_IN_EVENT] =
gtk_signal_new ("proximity_in_event",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, proximity_in_event),
gtk_marshal_BOOL__POINTER,
GTK_TYPE_BOOL, 1,
@@ -605,7 +666,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[PROXIMITY_OUT_EVENT] =
gtk_signal_new ("proximity_out_event",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, proximity_out_event),
gtk_marshal_BOOL__POINTER,
GTK_TYPE_BOOL, 1,
@@ -613,7 +674,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[DRAG_LEAVE] =
gtk_signal_new ("drag_leave",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, drag_leave),
gtk_marshal_NONE__POINTER_UINT,
GTK_TYPE_NONE, 2,
@@ -622,7 +683,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[DRAG_BEGIN] =
gtk_signal_new ("drag_begin",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, drag_begin),
gtk_marshal_NONE__POINTER,
GTK_TYPE_NONE, 1,
@@ -630,7 +691,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[DRAG_END] =
gtk_signal_new ("drag_end",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, drag_end),
gtk_marshal_NONE__POINTER,
GTK_TYPE_NONE, 1,
@@ -638,7 +699,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[DRAG_DATA_DELETE] =
gtk_signal_new ("drag_data_delete",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, drag_data_delete),
gtk_marshal_NONE__POINTER,
GTK_TYPE_NONE, 1,
@@ -646,7 +707,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[DRAG_MOTION] =
gtk_signal_new ("drag_motion",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, drag_motion),
gtk_marshal_BOOL__POINTER_INT_INT_UINT,
GTK_TYPE_BOOL, 4,
@@ -657,7 +718,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[DRAG_DROP] =
gtk_signal_new ("drag_drop",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, drag_drop),
gtk_marshal_BOOL__POINTER_INT_INT_UINT,
GTK_TYPE_BOOL, 4,
@@ -668,7 +729,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[DRAG_DATA_GET] =
gtk_signal_new ("drag_data_get",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, drag_data_get),
gtk_marshal_NONE__POINTER_POINTER_UINT_UINT,
GTK_TYPE_NONE, 4,
@@ -679,7 +740,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[DRAG_DATA_RECEIVED] =
gtk_signal_new ("drag_data_received",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, drag_data_received),
gtk_marshal_NONE__POINTER_INT_INT_POINTER_UINT_UINT,
GTK_TYPE_NONE, 6,
@@ -692,7 +753,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[VISIBILITY_NOTIFY_EVENT] =
gtk_signal_new ("visibility_notify_event",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, visibility_notify_event),
gtk_marshal_BOOL__POINTER,
GTK_TYPE_BOOL, 1,
@@ -700,7 +761,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[CLIENT_EVENT] =
gtk_signal_new ("client_event",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, client_event),
gtk_marshal_BOOL__POINTER,
GTK_TYPE_BOOL, 1,
@@ -708,7 +769,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[NO_EXPOSE_EVENT] =
gtk_signal_new ("no_expose_event",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, no_expose_event),
gtk_marshal_BOOL__POINTER,
GTK_TYPE_BOOL, 1,
@@ -716,74 +777,13 @@ gtk_widget_class_init (GtkWidgetClass *klass)
widget_signals[DEBUG_MSG] =
gtk_signal_new ("debug_msg",
GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, debug_msg),
gtk_marshal_NONE__STRING,
GTK_TYPE_NONE, 1,
GTK_TYPE_STRING);
gtk_object_class_add_signals (object_class, widget_signals, LAST_SIGNAL);
-
- object_class->set_arg = gtk_widget_set_arg;
- object_class->get_arg = gtk_widget_get_arg;
- object_class->shutdown = gtk_widget_shutdown;
- object_class->destroy = gtk_widget_real_destroy;
- object_class->finalize = gtk_widget_finalize;
-
- klass->activate_signal = 0;
- klass->set_scroll_adjustments_signal = 0;
- klass->show = gtk_widget_real_show;
- klass->show_all = gtk_widget_show;
- klass->hide = gtk_widget_real_hide;
- klass->hide_all = gtk_widget_hide;
- klass->map = gtk_widget_real_map;
- klass->unmap = gtk_widget_real_unmap;
- klass->realize = gtk_widget_real_realize;
- klass->unrealize = gtk_widget_real_unrealize;
- klass->draw = gtk_widget_real_draw;
- klass->draw_focus = NULL;
- klass->size_request = gtk_widget_real_size_request;
- klass->size_allocate = gtk_widget_real_size_allocate;
- klass->state_changed = NULL;
- klass->parent_set = NULL;
- klass->style_set = gtk_widget_style_set;
- klass->add_accelerator = (void*) gtk_accel_group_handle_add;
- klass->remove_accelerator = (void*) gtk_accel_group_handle_remove;
- klass->grab_focus = gtk_widget_real_grab_focus;
- klass->event = NULL;
- klass->button_press_event = NULL;
- klass->button_release_event = NULL;
- klass->motion_notify_event = NULL;
- klass->delete_event = NULL;
- klass->destroy_event = NULL;
- klass->expose_event = NULL;
- klass->key_press_event = gtk_widget_real_key_press_event;
- klass->key_release_event = gtk_widget_real_key_release_event;
- klass->enter_notify_event = NULL;
- klass->leave_notify_event = NULL;
- klass->configure_event = NULL;
- klass->focus_in_event = NULL;
- klass->focus_out_event = NULL;
- klass->map_event = NULL;
- klass->unmap_event = NULL;
- klass->property_notify_event = gtk_selection_property_notify;
- klass->selection_clear_event = gtk_selection_clear;
- klass->selection_request_event = gtk_selection_request;
- klass->selection_notify_event = gtk_selection_notify;
- klass->selection_received = NULL;
- klass->proximity_in_event = NULL;
- klass->proximity_out_event = NULL;
- klass->drag_begin = NULL;
- klass->drag_end = NULL;
- klass->drag_data_delete = NULL;
- klass->drag_leave = NULL;
- klass->drag_motion = NULL;
- klass->drag_drop = NULL;
- klass->drag_data_received = NULL;
-
- klass->no_expose_event = NULL;
-
- klass->debug_msg = gtk_widget_debug_msg;
}
static void
@@ -1553,7 +1553,7 @@ gtk_widget_show_all (GtkWidget *widget)
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_WIDGET (widget));
- class = GTK_WIDGET_CLASS (GTK_OBJECT (widget)->klass);
+ class = GTK_WIDGET_GET_CLASS (widget);
if (class->show_all)
class->show_all (widget);
@@ -1567,7 +1567,7 @@ gtk_widget_hide_all (GtkWidget *widget)
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_WIDGET (widget));
- class = GTK_WIDGET_CLASS (GTK_OBJECT (widget)->klass);
+ class = GTK_WIDGET_GET_CLASS (widget);
if (class->hide_all)
class->hide_all (widget);
@@ -2691,7 +2691,7 @@ gtk_widget_grab_default (GtkWidget *widget)
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (GTK_WIDGET_CAN_DEFAULT (widget));
- window_type = gtk_window_get_type ();
+ window_type = GTK_TYPE_WINDOW;
window = widget->parent;
while (window && !gtk_type_is_a (GTK_WIDGET_TYPE (window), window_type))
@@ -3888,13 +3888,9 @@ gtk_widget_get_default_visual (void)
}
static void
-gtk_widget_shutdown (GtkObject *object)
+gtk_widget_shutdown (GObject *object)
{
- GtkWidget *widget;
-
- /* gtk_object_destroy() will already hold a refcount on object
- */
- widget = GTK_WIDGET (object);
+ GtkWidget *widget = GTK_WIDGET (object);
if (widget->parent)
gtk_container_remove (GTK_CONTAINER (widget->parent), widget);
@@ -3903,7 +3899,7 @@ gtk_widget_shutdown (GtkObject *object)
if (GTK_WIDGET_REALIZED (widget))
gtk_widget_unrealize (widget);
- parent_class->shutdown (object);
+ G_OBJECT_CLASS (parent_class)->shutdown (object);
}
static void
@@ -3927,21 +3923,34 @@ gtk_widget_real_destroy (GtkObject *object)
}
gtk_style_unref (widget->style);
- widget->style = NULL;
+ widget->style = gtk_widget_peek_style ();
+ gtk_style_ref (widget->style);
- parent_class->destroy (object);
+ GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
static void
-gtk_widget_finalize (GtkObject *object)
+gtk_widget_finalize (GObject *object)
{
- GtkWidget *widget;
+ GtkWidget *widget = GTK_WIDGET (object);
GtkWidgetAuxInfo *aux_info;
gint *events;
GdkExtensionMode *mode;
+ GtkStyle *saved_style;
- widget = GTK_WIDGET (object);
-
+ gtk_grab_remove (widget);
+ gtk_selection_remove_all (widget);
+
+ saved_style = gtk_object_get_data_by_id (GTK_OBJECT (widget), saved_default_style_key_id);
+ if (saved_style)
+ {
+ gtk_style_unref (saved_style);
+ gtk_object_remove_data_by_id (GTK_OBJECT (widget), saved_default_style_key_id);
+ }
+
+ gtk_style_unref (widget->style);
+ widget->style = NULL;
+
if (widget->name)
g_free (widget->name);
@@ -3957,7 +3966,7 @@ gtk_widget_finalize (GtkObject *object)
if (mode)
g_free (mode);
- parent_class->finalize (object);
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
/*****************************************
@@ -4194,7 +4203,7 @@ gtk_widget_propagate_state (GtkWidget *widget,
{
GtkWidget *window;
- window = gtk_widget_get_ancestor (widget, gtk_window_get_type ());
+ window = gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW);
if (window)
gtk_window_set_focus (GTK_WINDOW (window), NULL);
}
@@ -4375,22 +4384,20 @@ gtk_widget_reset_shapes (GtkWidget *widget)
gtk_reset_shapes_recurse (widget, widget->window);
}
-void
+GtkWidget*
gtk_widget_ref (GtkWidget *widget)
{
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
- gtk_object_ref ((GtkObject*) widget);
+ return (GtkWidget*) g_object_ref ((GObject*) widget);
}
void
gtk_widget_unref (GtkWidget *widget)
{
- g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_WIDGET (widget));
- gtk_object_unref ((GtkObject*) widget);
+ g_object_unref ((GObject*) widget);
}
void
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
index 66568b4228..2b2579ddb7 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -409,7 +409,7 @@ GtkWidget* gtk_widget_new (GtkType type,
GtkWidget* gtk_widget_newv (GtkType type,
guint nargs,
GtkArg *args);
-void gtk_widget_ref (GtkWidget *widget);
+GtkWidget* gtk_widget_ref (GtkWidget *widget);
void gtk_widget_unref (GtkWidget *widget);
void gtk_widget_destroy (GtkWidget *widget);
void gtk_widget_destroyed (GtkWidget *widget,
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index b738142296..2cfc579cc9 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -93,9 +93,9 @@ static void gtk_window_set_arg (GtkObject *object,
static void gtk_window_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
-static void gtk_window_shutdown (GtkObject *object);
+static void gtk_window_shutdown (GObject *object);
static void gtk_window_destroy (GtkObject *object);
-static void gtk_window_finalize (GtkObject *object);
+static void gtk_window_finalize (GObject *object);
static void gtk_window_show (GtkWidget *widget);
static void gtk_window_hide (GtkWidget *widget);
static void gtk_window_map (GtkWidget *widget);
@@ -167,8 +167,9 @@ static GtkWindowGeometryInfo* gtk_window_get_geometry_info (GtkWindow *window,
gboolean create);
static void gtk_window_geometry_destroy (GtkWindowGeometryInfo *info);
+static GSList *toplevel_list = NULL;
static GtkBinClass *parent_class = NULL;
-static guint window_signals[LAST_SIGNAL] = { 0 };
+static guint window_signals[LAST_SIGNAL] = { 0 };
GtkType
@@ -199,6 +200,7 @@ gtk_window_get_type (void)
static void
gtk_window_class_init (GtkWindowClass *klass)
{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
GtkContainerClass *container_class;
@@ -209,6 +211,9 @@ gtk_window_class_init (GtkWindowClass *klass)
parent_class = gtk_type_class (gtk_bin_get_type ());
+ gobject_class->shutdown = gtk_window_shutdown;
+ gobject_class->finalize = gtk_window_finalize;
+
gtk_object_add_arg_type ("GtkWindow::type", GTK_TYPE_WINDOW_TYPE, GTK_ARG_READWRITE, ARG_TYPE);
gtk_object_add_arg_type ("GtkWindow::title", GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_TITLE);
gtk_object_add_arg_type ("GtkWindow::auto_shrink", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_AUTO_SHRINK);
@@ -222,7 +227,7 @@ gtk_window_class_init (GtkWindowClass *klass)
window_signals[SET_FOCUS] =
gtk_signal_new ("set_focus",
GTK_RUN_LAST,
- object_class->type,
+ GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWindowClass, set_focus),
gtk_marshal_NONE__POINTER,
GTK_TYPE_NONE, 1,
@@ -232,9 +237,7 @@ gtk_window_class_init (GtkWindowClass *klass)
object_class->set_arg = gtk_window_set_arg;
object_class->get_arg = gtk_window_get_arg;
- object_class->shutdown = gtk_window_shutdown;
object_class->destroy = gtk_window_destroy;
- object_class->finalize = gtk_window_finalize;
widget_class->show = gtk_window_show;
widget_class->hide = gtk_window_hide;
@@ -282,8 +285,11 @@ gtk_window_init (GtkWindow *window)
window->position = GTK_WIN_POS_NONE;
window->use_uposition = TRUE;
window->modal = FALSE;
-
- gtk_container_register_toplevel (GTK_CONTAINER (window));
+
+ gtk_widget_ref (GTK_WIDGET (window));
+ gtk_object_sink (GTK_OBJECT (window));
+ window->has_user_ref_count = TRUE;
+ toplevel_list = g_slist_prepend (toplevel_list, window);
}
static void
@@ -572,6 +578,18 @@ gtk_window_set_modal (GtkWindow *window,
gtk_grab_remove (GTK_WIDGET (window));
}
+GList*
+gtk_window_list_toplevels (void)
+{
+ GList *list = NULL;
+ GSList *slist;
+
+ for (slist = toplevel_list; slist; slist = slist->next)
+ list = g_list_prepend (list, gtk_widget_ref (slist->data));
+
+ return list;
+}
+
void
gtk_window_add_embedded_xid (GtkWindow *window, guint xid)
{
@@ -649,11 +667,10 @@ gtk_window_reposition (GtkWindow *window,
}
static void
-gtk_window_shutdown (GtkObject *object)
+gtk_window_shutdown (GObject *object)
{
GtkWindow *window;
- g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_WINDOW (object));
window = GTK_WINDOW (object);
@@ -661,7 +678,7 @@ gtk_window_shutdown (GtkObject *object)
gtk_window_set_focus (window, NULL);
gtk_window_set_default (window, NULL);
- GTK_OBJECT_CLASS (parent_class)->shutdown (object);
+ G_OBJECT_CLASS (parent_class)->shutdown (object);
}
static void
@@ -831,33 +848,38 @@ gtk_window_destroy (GtkObject *object)
{
GtkWindow *window;
- g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_WINDOW (object));
window = GTK_WINDOW (object);
-
- gtk_container_unregister_toplevel (GTK_CONTAINER (object));
if (window->transient_parent)
gtk_window_unset_transient_for (window);
+ if (window->has_user_ref_count)
+ {
+ window->has_user_ref_count = FALSE;
+ gtk_widget_unref (GTK_WIDGET (window));
+ }
+
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
static void
-gtk_window_finalize (GtkObject *object)
+gtk_window_finalize (GObject *object)
{
GtkWindow *window;
- g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_WINDOW (object));
window = GTK_WINDOW (object);
+
+ toplevel_list = g_slist_remove (toplevel_list, window);
+
g_free (window->title);
g_free (window->wmclass_name);
g_free (window->wmclass_class);
- GTK_OBJECT_CLASS(parent_class)->finalize (object);
+ G_OBJECT_CLASS(parent_class)->finalize (object);
}
static void
@@ -1406,14 +1428,14 @@ gtk_window_read_rcfiles (GtkWidget *widget,
* then, the RC file will up to date, so we have to tell
* them now.
*/
- GList *toplevels;
-
- toplevels = gtk_container_get_toplevels();
- while (toplevels)
+ GList *list, *toplevels = gtk_window_list_toplevels ();
+
+ for (list = toplevels; list; list = list->next)
{
- gtk_widget_reset_rc_styles (toplevels->data);
- toplevels = toplevels->next;
+ gtk_widget_reset_rc_styles (list->data);
+ gtk_widget_unref (list->data);
}
+ g_list_free (toplevels);
}
}
diff --git a/gtk/gtkwindow.h b/gtk/gtkwindow.h
index 1bf69438f6..219f4497dc 100644
--- a/gtk/gtkwindow.h
+++ b/gtk/gtkwindow.h
@@ -64,6 +64,7 @@ struct _GtkWindow
GtkWindow *transient_parent;
gushort resize_count;
+ guint has_user_ref_count : 1;
guint allow_shrink : 1;
guint allow_grow : 1;
guint auto_shrink : 1;
@@ -126,6 +127,8 @@ void gtk_window_set_default_size (GtkWindow *window,
/* If window is set modal, input will be grabbed when show and released when hide */
void gtk_window_set_modal (GtkWindow *window,
gboolean modal);
+GList* gtk_window_list_toplevels (void);
+
/* --- internal functions --- */
void gtk_window_set_focus (GtkWindow *window,
diff --git a/gtk/maketypes.awk b/gtk/maketypes.awk
index 33faec7941..0c82cf3a2d 100644
--- a/gtk/maketypes.awk
+++ b/gtk/maketypes.awk
@@ -124,5 +124,5 @@ function generate (generate_1)
END {
if (gen_macros)
- printf("\n#define\tGTK_TYPE_NUM_BUILTINS\t(%u)\n", type_counter);
+ printf("\n#define\tGTK_TYPE_N_BUILTINS\t(%u)\n", type_counter);
}
diff --git a/gtk/testdnd.c b/gtk/testdnd.c
index f258c1b978..203272996d 100644
--- a/gtk/testdnd.c
+++ b/gtk/testdnd.c
@@ -311,9 +311,9 @@ target_drag_motion (GtkWidget *widget,
}
source_widget = gtk_drag_get_source_widget (context);
- g_print("motion, source %s\n", source_widget ?
- gtk_type_name (GTK_OBJECT (source_widget)->klass->type) :
- "unknown");
+ g_print ("motion, source %s\n", source_widget ?
+ GTK_OBJECT_TYPE_NAME (source_widget) :
+ "NULL");
gdk_drag_status (context, context->suggested_action, time);
return TRUE;
diff --git a/gtk/testgtk.c b/gtk/testgtk.c
index 7a431e9d95..56dc6cb136 100644
--- a/gtk/testgtk.c
+++ b/gtk/testgtk.c
@@ -3290,7 +3290,7 @@ set_cursor (GtkWidget *spinner,
guint c;
GdkCursor *cursor;
GtkWidget *label;
- GtkFlagValue *vals;
+ GtkEnumValue *vals;
c = CLAMP (gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spinner)), 0, 152);
c &= 0xfe;
@@ -5660,13 +5660,11 @@ create_rulers (void)
gtk_ruler_set_metric (GTK_RULER (ruler), GTK_CENTIMETERS);
gtk_ruler_set_range (GTK_RULER (ruler), 100, 0, 0, 20);
- gtk_signal_connect_object (
- GTK_OBJECT (window),
- "motion_notify_event",
- GTK_SIGNAL_FUNC(
- GTK_WIDGET_CLASS (GTK_OBJECT (ruler)->klass)->motion_notify_event),
- GTK_OBJECT (ruler));
-
+ gtk_signal_connect_object (GTK_OBJECT (window),
+ "motion_notify_event",
+ GTK_SIGNAL_FUNC (GTK_WIDGET_GET_CLASS (ruler)->motion_notify_event),
+ GTK_OBJECT (ruler));
+
gtk_table_attach (GTK_TABLE (table), ruler, 1, 2, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (ruler);
@@ -5675,12 +5673,11 @@ create_rulers (void)
ruler = gtk_vruler_new ();
gtk_ruler_set_range (GTK_RULER (ruler), 5, 15, 0, 20);
- gtk_signal_connect_object (
- GTK_OBJECT (window),
- "motion_notify_event",
- GTK_SIGNAL_FUNC (GTK_WIDGET_CLASS (GTK_OBJECT (ruler)->klass)->motion_notify_event),
- GTK_OBJECT (ruler));
-
+ gtk_signal_connect_object (GTK_OBJECT (window),
+ "motion_notify_event",
+ GTK_SIGNAL_FUNC (GTK_WIDGET_GET_CLASS (ruler)->motion_notify_event),
+ GTK_OBJECT (ruler));
+
gtk_table_attach (GTK_TABLE (table), ruler, 0, 1, 1, 2,
GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_widget_show (ruler);