summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorTim Janik <timj@gtk.org>1998-05-03 19:13:24 +0000
committerTim Janik <timj@src.gnome.org>1998-05-03 19:13:24 +0000
commit5c9af6b5aa97417b6ec52018d30cf11790560110 (patch)
tree99053372cdbbb6940bc7f970d4337445e591181c /gtk
parent19bbe0557f255fe37c19666f434705295a71d750 (diff)
downloadgtk+-5c9af6b5aa97417b6ec52018d30cf11790560110.tar.gz
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.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkadjustment.c22
-rw-r--r--gtk/gtkadjustment.h30
-rw-r--r--gtk/gtksignal.c92
-rw-r--r--gtk/gtksignal.h4
4 files changed, 111 insertions, 37 deletions
diff --git a/gtk/gtkadjustment.c b/gtk/gtkadjustment.c
index b921cc146e..bcf2ff1b17 100644
--- a/gtk/gtkadjustment.c
+++ b/gtk/gtkadjustment.c
@@ -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);
}
diff --git a/gtk/gtkadjustment.h b/gtk/gtkadjustment.h
index e525fb7052..7a5e5810b5 100644
--- a/gtk/gtkadjustment.h
+++ b/gtk/gtkadjustment.h
@@ -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);
diff --git a/gtk/gtksignal.c b/gtk/gtksignal.c
index 32efd87c78..35c47fcc5d 100644
--- a/gtk/gtksignal.c
+++ b/gtk/gtksignal.c
@@ -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
@@ -423,6 +423,60 @@ gtk_signal_emit_stop_by_name (GtkObject *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,
GtkSignalFunc func,
@@ -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))
diff --git a/gtk/gtksignal.h b/gtk/gtksignal.h
index d11abf35ed..95961b6e09 100644
--- a/gtk/gtksignal.h
+++ b/gtk/gtksignal.h
@@ -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,