summaryrefslogtreecommitdiff
path: root/gtk/gtksignal.c
diff options
context:
space:
mode:
authorTim Janik <timj@gimp.org>1998-02-02 04:54:25 +0000
committerTim Janik <timj@src.gnome.org>1998-02-02 04:54:25 +0000
commiteef38289b2379669784be1b030b1c803ebc7ee69 (patch)
treebbd108413216f18474aac3af49605a79a1264a10 /gtk/gtksignal.c
parent81fe36047e9bfbf27b224cd35cc869ca6082bf38 (diff)
downloadgtk+-eef38289b2379669784be1b030b1c803ebc7ee69.tar.gz
GTK_RESIZE_NEEDED is a private flag now.
Mon Feb 2 04:15:08 1998 Tim Janik <timj@gimp.org> * gtk/gtkcontainer.h: * gtk/gtkcontainer.c: GTK_RESIZE_NEEDED is a private flag now. (gtk_container_register_toplevel): new function. (gtk_container_unregister_toplevel): new function. * gtk/gtkmain.c: GTK_LEAVE_PENDING is a private flag now. * gtk/gtkmenu.c: call gtk_container_register_toplevel in gtk_menu_class_init instead of this dirty gtk_widget_set_parent(,NULL) hack. new default handler gtk_menu_destroy for calling gtk_container_unregister_toplevel. removed GTK_ANCHORED, GTK_UNMAPPED. * gtk/gtkobject.h: macro cleanups, added GTK_DESTROYED flag. * gtk/gtkobject.c: only emit DESTROY signal if !GTK_OBJECT_DESTROYED (object). * gtk/gtkprivate.h: new file that will not be automatically included. it holds the private flags for GtkWidget along with it's SET/UNSET and examination macros. * gtk/gtkwidget.c: private flags: GTK_RESIZE_NEEDED, GTK_REDRAW_PENDING, GTK_RESIZE_PENDING, GTK_IN_REPARENT, GTK_USER_STYLE. GTK_ANCHORED is replaced by GTK_TOPLEVEL. added missing UNSET for GTK_IN_REPARENT. removed the gtk_widget_set_parent(, NULL) hack for toplevels. upon destroy free memory for widgets with GTK_WIDGET_HAS_SHAPE_MASK. * gtk/gtkwidget.h: split up the widget flags into a public and a private portion. added an extra field private_flags to GtkWidget without making it bigger by using an alignment gap of 16 bit. macro cleanups. * gtk/gtkwindow.c: removed GTK_ANCHORED. new function gtk_window_destroy for calling gtk_container_unregister_toplevel. removed the gtk_widget_set_parent(,NULL), call gtk_container_register_toplevel instead. remove GTK_UNMAPPED. GTK_RESIZE_NEEDED is private now. * gtk/gtksignal.c (gtk_signal_disconnect): removed a bug on removal that cut off the handler list -> living_objects == 0 with testgtk. made some warnings more descriptive. new function gtk_signal_connect_object_while_alive, which will automatically destroy the connection once one of the objects is destroyed. didn't include this before removal of the above mentioned bug. * reflected refcounting revolution in ChangeLog
Diffstat (limited to 'gtk/gtksignal.c')
-rw-r--r--gtk/gtksignal.c70
1 files changed, 61 insertions, 9 deletions
diff --git a/gtk/gtksignal.c b/gtk/gtksignal.c
index 4996ebf15b..55cca56917 100644
--- a/gtk/gtksignal.c
+++ b/gtk/gtksignal.c
@@ -140,7 +140,7 @@ static GHashTable *signal_info_hash_table = NULL;
static gint next_signal = 1;
static gint next_handler_id = 1;
-static const char *handler_key = "signal_handlers";
+static const gchar *handler_key = "gtk-signal-handlers";
static GMemChunk *handler_mem_chunk = NULL;
static GMemChunk *emission_mem_chunk = NULL;
@@ -532,6 +532,59 @@ gtk_signal_connect_object_after (GtkObject *object,
TRUE, FALSE);
}
+typedef struct _GtkDisconnectInfo GtkDisconnectInfo;
+struct _GtkDisconnectInfo
+{
+ GtkObject *object1;
+ gint disconnect_handler1;
+ gint signal_handler;
+ GtkObject *object2;
+ gint disconnect_handler2;
+};
+
+static gint
+gtk_alive_disconnecter (GtkDisconnectInfo *info)
+{
+ g_return_val_if_fail (info != NULL, 0);
+
+ gtk_signal_disconnect (info->object1, info->disconnect_handler1);
+ gtk_signal_disconnect (info->object1, info->signal_handler);
+ gtk_signal_disconnect (info->object2, info->disconnect_handler2);
+ g_free (info);
+
+ return 0;
+}
+
+void
+gtk_signal_connect_object_while_alive (GtkObject *object,
+ const gchar *signal,
+ GtkSignalFunc func,
+ GtkObject *alive_object)
+{
+ GtkDisconnectInfo *info;
+
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GTK_IS_OBJECT (object));
+ g_return_if_fail (signal != NULL);
+ g_return_if_fail (func != NULL);
+ g_return_if_fail (alive_object != NULL);
+ g_return_if_fail (GTK_IS_OBJECT (alive_object));
+
+ info = g_new (GtkDisconnectInfo, 1);
+ info->object1 = object;
+ info->object2 = alive_object;
+
+ info->signal_handler = gtk_signal_connect_object (object, signal, func, alive_object);
+ info->disconnect_handler1 = gtk_signal_connect_object (info->object1,
+ "destroy",
+ GTK_SIGNAL_FUNC (gtk_alive_disconnecter),
+ (GtkObject*) info);
+ info->disconnect_handler2 = gtk_signal_connect_object (info->object2,
+ "destroy",
+ GTK_SIGNAL_FUNC (gtk_alive_disconnecter),
+ (GtkObject*) info);
+}
+
void
gtk_signal_disconnect (GtkObject *object,
gint anid)
@@ -554,8 +607,7 @@ gtk_signal_disconnect (GtkObject *object,
if (prev)
prev->next = tmp->next;
else
- gtk_object_set_data (object, handler_key, tmp->next);
- gtk_signal_handler_unref (tmp, object);
+ gtk_signal_handler_unref (tmp, object);
return;
}
@@ -563,7 +615,7 @@ gtk_signal_disconnect (GtkObject *object,
tmp = tmp->next;
}
- g_warning ("could not find handler (%d)", anid);
+ g_warning ("gtk_signal_disconnect(): could not find handler (%d)", anid);
}
void
@@ -594,7 +646,7 @@ gtk_signal_disconnect_by_data (GtkObject *object,
}
if (!found_one)
- g_warning ("could not find handler containing data (0x%0lX)", (long) data);
+ g_warning ("gtk_signal_disconnect_by_data(): could not find handler containing data (0x%0lX)", (long) data);
}
void
@@ -621,7 +673,7 @@ gtk_signal_handler_block (GtkObject *object,
tmp = tmp->next;
}
- g_warning ("could not find handler (%d)", anid);
+ g_warning ("gtk_signal_handler_block(): could not find handler (%d)", anid);
}
void
@@ -651,7 +703,7 @@ gtk_signal_handler_block_by_data (GtkObject *object,
}
if (!found_one)
- g_warning ("could not find handler containing data (0x%0lX)", (long) data);
+ g_warning ("gtk_signal_handler_block_by_data(): could not find handler containing data (0x%0lX)", (long) data);
}
void
@@ -678,7 +730,7 @@ gtk_signal_handler_unblock (GtkObject *object,
tmp = tmp->next;
}
- g_warning ("could not find handler (%d)", anid);
+ g_warning ("gtk_signal_handler_unblock(): could not find handler (%d)", anid);
}
void
@@ -708,7 +760,7 @@ gtk_signal_handler_unblock_by_data (GtkObject *object,
}
if (!found_one)
- g_warning ("could not find handler containing data (0x%0lX)", (long) data);
+ g_warning ("gtk_signal_handler_unblock_by_data(): could not find handler containing data (0x%0lX)", (long) data);
}
void