new function to set the adjustments value without causing a current

Sun May  3 19:45:09 1998  Tim Janik  <timj@gtk.org>

        * gtk/gtkadjustment.c (gtk_adjustment_assimilate_value): new function
                to set the adjustments value without causing a current emission of
                        "value_changed" to be restarted.

                                * gtk/gtksignal.c: added new functions to retrive the number of
                                        existing emissions for a certain signal.
                                                (gtk_signal_n_emissions): new function.
                                                        (gtk_signal_n_emissions_by_name): new function.
This commit is contained in:
Tim Janik 1998-05-03 19:13:24 +00:00 committed by Tim Janik
parent 19bbe0557f
commit 5c9af6b5aa
11 changed files with 188 additions and 37 deletions

View File

@ -1,3 +1,14 @@
Sun May 3 19:45:09 1998 Tim Janik <timj@gtk.org>
* gtk/gtkadjustment.c (gtk_adjustment_assimilate_value): new function
to set the adjustments value without causing a current emission of
"value_changed" to be restarted.
* gtk/gtksignal.c: added new functions to retrive the number of
existing emissions for a certain signal.
(gtk_signal_n_emissions): new function.
(gtk_signal_n_emissions_by_name): new function.
Sun May 3 16:55:43 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.c (gtk_container_set_focus_child): new function to

View File

@ -1,3 +1,14 @@
Sun May 3 19:45:09 1998 Tim Janik <timj@gtk.org>
* gtk/gtkadjustment.c (gtk_adjustment_assimilate_value): new function
to set the adjustments value without causing a current emission of
"value_changed" to be restarted.
* gtk/gtksignal.c: added new functions to retrive the number of
existing emissions for a certain signal.
(gtk_signal_n_emissions): new function.
(gtk_signal_n_emissions_by_name): new function.
Sun May 3 16:55:43 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.c (gtk_container_set_focus_child): new function to

View File

@ -1,3 +1,14 @@
Sun May 3 19:45:09 1998 Tim Janik <timj@gtk.org>
* gtk/gtkadjustment.c (gtk_adjustment_assimilate_value): new function
to set the adjustments value without causing a current emission of
"value_changed" to be restarted.
* gtk/gtksignal.c: added new functions to retrive the number of
existing emissions for a certain signal.
(gtk_signal_n_emissions): new function.
(gtk_signal_n_emissions_by_name): new function.
Sun May 3 16:55:43 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.c (gtk_container_set_focus_child): new function to

View File

@ -1,3 +1,14 @@
Sun May 3 19:45:09 1998 Tim Janik <timj@gtk.org>
* gtk/gtkadjustment.c (gtk_adjustment_assimilate_value): new function
to set the adjustments value without causing a current emission of
"value_changed" to be restarted.
* gtk/gtksignal.c: added new functions to retrive the number of
existing emissions for a certain signal.
(gtk_signal_n_emissions): new function.
(gtk_signal_n_emissions_by_name): new function.
Sun May 3 16:55:43 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.c (gtk_container_set_focus_child): new function to

View File

@ -1,3 +1,14 @@
Sun May 3 19:45:09 1998 Tim Janik <timj@gtk.org>
* gtk/gtkadjustment.c (gtk_adjustment_assimilate_value): new function
to set the adjustments value without causing a current emission of
"value_changed" to be restarted.
* gtk/gtksignal.c: added new functions to retrive the number of
existing emissions for a certain signal.
(gtk_signal_n_emissions): new function.
(gtk_signal_n_emissions_by_name): new function.
Sun May 3 16:55:43 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.c (gtk_container_set_focus_child): new function to

View File

@ -1,3 +1,14 @@
Sun May 3 19:45:09 1998 Tim Janik <timj@gtk.org>
* gtk/gtkadjustment.c (gtk_adjustment_assimilate_value): new function
to set the adjustments value without causing a current emission of
"value_changed" to be restarted.
* gtk/gtksignal.c: added new functions to retrive the number of
existing emissions for a certain signal.
(gtk_signal_n_emissions): new function.
(gtk_signal_n_emissions_by_name): new function.
Sun May 3 16:55:43 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.c (gtk_container_set_focus_child): new function to

View File

@ -1,3 +1,14 @@
Sun May 3 19:45:09 1998 Tim Janik <timj@gtk.org>
* gtk/gtkadjustment.c (gtk_adjustment_assimilate_value): new function
to set the adjustments value without causing a current emission of
"value_changed" to be restarted.
* gtk/gtksignal.c: added new functions to retrive the number of
existing emissions for a certain signal.
(gtk_signal_n_emissions): new function.
(gtk_signal_n_emissions_by_name): new function.
Sun May 3 16:55:43 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.c (gtk_container_set_focus_child): new function to

View File

@ -132,17 +132,31 @@ gtk_adjustment_set_value (GtkAdjustment *adjustment,
{
adjustment->value = value;
gtk_signal_emit_by_name (GTK_OBJECT (adjustment), "value_changed");
gtk_adjustment_value_changed (adjustment);
}
}
void
gtk_adjustment_assimilate_value (GtkAdjustment *adjustment,
gfloat value)
{
g_return_if_fail (adjustment != NULL);
g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
if (gtk_signal_n_emissions (GTK_OBJECT (adjustment),
adjustment_signals[VALUE_CHANGED]))
adjustment->value = CLAMP (value, adjustment->lower, adjustment->upper);
else
gtk_adjustment_set_value (adjustment, value);
}
void
gtk_adjustment_changed (GtkAdjustment *adjustment)
{
g_return_if_fail (adjustment != NULL);
g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
gtk_signal_emit_by_name (GTK_OBJECT (adjustment), "changed");
gtk_signal_emit (GTK_OBJECT (adjustment), adjustment_signals[CHANGED]);
}
void
@ -151,7 +165,7 @@ gtk_adjustment_value_changed (GtkAdjustment *adjustment)
g_return_if_fail (adjustment != NULL);
g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
gtk_signal_emit_by_name (GTK_OBJECT (adjustment), "value_changed");
gtk_signal_emit (GTK_OBJECT (adjustment), adjustment_signals[VALUE_CHANGED]);
}
void
@ -181,5 +195,5 @@ gtk_adjustment_clamp_page (GtkAdjustment *adjustment,
}
if (need_emission)
gtk_signal_emit_by_name (GTK_OBJECT (adjustment), "value_changed");
gtk_adjustment_value_changed (adjustment);
}

View File

@ -59,20 +59,22 @@ struct _GtkAdjustmentClass
};
GtkType gtk_adjustment_get_type (void);
GtkObject* gtk_adjustment_new (gfloat value,
gfloat lower,
gfloat upper,
gfloat step_increment,
gfloat page_increment,
gfloat page_size);
void gtk_adjustment_set_value (GtkAdjustment *adjustment,
gfloat value);
void gtk_adjustment_changed (GtkAdjustment *adjustment);
void gtk_adjustment_value_changed (GtkAdjustment *adjustment);
void gtk_adjustment_clamp_page (GtkAdjustment *adjustment,
gfloat lower,
gfloat upper);
GtkType gtk_adjustment_get_type (void);
GtkObject* gtk_adjustment_new (gfloat value,
gfloat lower,
gfloat upper,
gfloat step_increment,
gfloat page_increment,
gfloat page_size);
void gtk_adjustment_changed (GtkAdjustment *adjustment);
void gtk_adjustment_value_changed (GtkAdjustment *adjustment);
void gtk_adjustment_clamp_page (GtkAdjustment *adjustment,
gfloat lower,
gfloat upper);
void gtk_adjustment_set_value (GtkAdjustment *adjustment,
gfloat value);
void gtk_adjustment_assimilate_value (GtkAdjustment *adjustment,
gfloat value);

View File

@ -152,8 +152,8 @@ static GList *current_emissions = NULL;
static GList *stop_emissions = NULL;
static GList *restart_emissions = NULL;
static GtkSignalMarshal marshal = NULL;
static GtkSignalDestroy destroy = NULL;
static GtkSignalMarshal global_marshaller = NULL;
static GtkSignalDestroy global_destroy_notify = NULL;
guint
@ -422,6 +422,60 @@ gtk_signal_emit_stop_by_name (GtkObject *object,
name, gtk_type_name (GTK_OBJECT_TYPE (object)));
}
guint
gtk_signal_n_emissions (GtkObject *object,
guint signal_id)
{
GList *tmp;
guint n;
g_return_val_if_fail (object != NULL, 0);
g_return_val_if_fail (GTK_IS_OBJECT (object), 0);
tmp = current_emissions;
n = 0;
while (tmp)
{
GtkEmission *emission;
emission = tmp->data;
tmp = tmp->next;
if ((emission->object == object) &&
(emission->signal_type == signal_id))
n++;
}
return n;
}
guint
gtk_signal_n_emissions_by_name (GtkObject *object,
const gchar *name)
{
guint type;
guint n;
g_return_val_if_fail (object != NULL, 0);
g_return_val_if_fail (GTK_IS_OBJECT (object), 0);
g_return_val_if_fail (name != NULL, 0);
if (initialize)
gtk_signal_init ();
type = gtk_signal_lookup (name, GTK_OBJECT_TYPE (object));
if (type)
n = gtk_signal_n_emissions (object, type);
else
{
g_warning ("gtk_signal_n_emissions_by_name(): could not find signal \"%s\" in the `%s' class ancestry",
name, gtk_type_name (GTK_OBJECT_TYPE (object)));
n = 0;
}
return n;
}
guint
gtk_signal_connect (GtkObject *object,
const gchar *name,
@ -431,6 +485,7 @@ gtk_signal_connect (GtkObject *object,
guint type;
g_return_val_if_fail (object != NULL, 0);
g_return_val_if_fail (GTK_IS_OBJECT (object), 0);
if (initialize)
gtk_signal_init ();
@ -965,8 +1020,8 @@ void
gtk_signal_set_funcs (GtkSignalMarshal marshal_func,
GtkSignalDestroy destroy_func)
{
marshal = marshal_func;
destroy = destroy_func;
global_marshaller = marshal_func;
global_destroy_notify = destroy_func;
}
@ -1050,11 +1105,10 @@ gtk_signal_handler_unref (GtkHandler *handler,
handler->ref_count -= 1;
if (handler->ref_count == 0)
{
if (!handler->func && destroy)
(* destroy) (handler->func_data);
else if (handler->destroy_func)
if (handler->destroy_func)
(* handler->destroy_func) (handler->func_data);
else if (!handler->func && global_destroy_notify)
(* global_destroy_notify) (handler->func_data);
if (handler->prev)
handler->prev->next = handler->next;
@ -1421,10 +1475,10 @@ gtk_handlers_run (GtkHandler *handlers,
if (handlers->func)
{
if (handlers->no_marshal)
(* (GtkCallbackMarshal)handlers->func) (info->object,
handlers->func_data,
info->nparams,
info->params);
(* (GtkCallbackMarshal) handlers->func) (info->object,
handlers->func_data,
info->nparams,
info->params);
else if (handlers->object_signal)
(* info->marshaller) ((GtkObject*) handlers->func_data, /* don't GTK_OBJECT() cast */
handlers->func,
@ -1436,13 +1490,13 @@ gtk_handlers_run (GtkHandler *handlers,
handlers->func_data,
info->params);
}
else if (marshal)
(* marshal) (info->object,
handlers->func_data,
info->nparams,
info->params,
info->param_types,
info->return_val);
else if (global_marshaller)
(* global_marshaller) (info->object,
handlers->func_data,
info->nparams,
info->params,
info->param_types,
info->return_val);
if (gtk_emission_check (stop_emissions, info->object,
info->signal_type))

View File

@ -85,6 +85,10 @@ void gtk_signal_emit (GtkObject *object,
void gtk_signal_emit_by_name (GtkObject *object,
const gchar *name,
...);
guint gtk_signal_n_emissions (GtkObject *object,
guint signal_id);
guint gtk_signal_n_emissions_by_name (GtkObject *object,
const gchar *name);
void gtk_signal_emit_stop (GtkObject *object,
guint signal_id);
void gtk_signal_emit_stop_by_name (GtkObject *object,