diff options
author | Tim Janik <timj@src.gnome.org> | 1998-03-01 04:53:56 +0000 |
---|---|---|
committer | Tim Janik <timj@src.gnome.org> | 1998-03-01 04:53:56 +0000 |
commit | d491547e869c5b918e998e1c68449d2d0e742ada (patch) | |
tree | 6163c5a04b36762c460187347edc3d6bc5f2d460 | |
parent | 91c1c8dddb06e46ddd4b0eb9079afc0107d7fc90 (diff) | |
download | gdk-pixbuf-d491547e869c5b918e998e1c68449d2d0e742ada.tar.gz |
quit handlers and idle_remove_by_data fixups
-timj
-rw-r--r-- | NEWS | 16 | ||||
-rw-r--r-- | gtk/gtkmain.c | 179 | ||||
-rw-r--r-- | gtk/gtkmain.h | 11 |
3 files changed, 195 insertions, 11 deletions
@@ -2,13 +2,18 @@ Forthcoming Changes for GTK+ 0.99.4: * Reference counting revolution integrated. Refer to docs/refcounting.txt on this issue. -* Implementation of a decent debugging system, see docs/debugging.txt. +* Implementation of a decent debugging system, you would want + to export GTK_DEBUG=objects if you are going to develop gtk applications, + refer to docs/debugging.txt for further information. * Additions on the signal code for querying information about certain signals, and pending handlers of signals. * Support for user signals, and major changes to internal signal handler handling for proper signal removal and invokation of after signals. -* GtkTooltips became a true descendant of GtkObject and facilitates an - extra tip string which can be used as e.g. an index into context help. +* Additional signals for various widgets e.g, GtkHandleBox::child_attached, + GtkHandleBox::child_detached, GtkWidget::style_set, GtkWidget::parent_set. +* GtkTooltips became a true descendant of GtkObject via derivation from + GtkData and facilitates an extra tip string which can be used as e.g. an + index into context help. * Split up of the widget/object flags into a private and a public portion, consult docs/widget_system.txt on this. * Support for hot keys on gtk programs via gtk_key_snooper_install(). @@ -16,13 +21,18 @@ Forthcoming Changes for GTK+ 0.99.4: simple callback functions as well. * Idle functions are now prioritized. * Many enhancements to GtkNotebook. +* New widget GtkSpinButton, check out testgtk. * New widget GtkTipsQuery for letting the user query tooltips of widgets. +* Gdk now supports regions. * Access masks for widget arguments (GTK_ARG_READABLE/GTK_ARG_WRITABLE). * Function replacements: g_string_hash() -> g_str_hash() g_string_equal() -> g_str_equal() gtk_tooltips_set_tips() -> gtk_tooltips_set_tip() +* Support for quit handlers in gtk_main(). * Motif window mangaer hints support. +* Widget arguments are now flagged for readability/writability. +* Various FAQ updates. * Clean ups and many many bug fixes by a lot of people all over the place. * New, long and descriptive ChangeLog entries for bored readers ;) diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c index dedae054e..a3bf76a17 100644 --- a/gtk/gtkmain.c +++ b/gtk/gtkmain.c @@ -37,6 +37,7 @@ /* Private type definitions */ typedef struct _GtkInitFunction GtkInitFunction; +typedef struct _GtkQuitFunction GtkQuitFunction; typedef struct _GtkTimeoutFunction GtkTimeoutFunction; typedef struct _GtkIdleFunction GtkIdleFunction; typedef struct _GtkInputFunction GtkInputFunction; @@ -48,6 +49,16 @@ struct _GtkInitFunction gpointer data; }; +struct _GtkQuitFunction +{ + gint tag; + guint main_level; + GtkCallbackMarshal marshal; + GtkFunction function; + gpointer data; + GtkDestroyNotify destroy; +}; + struct _GtkTimeoutFunction { gint tag; @@ -85,6 +96,8 @@ struct _GtkKeySnooperData }; static void gtk_exit_func (void); +static gint gtk_quit_invoke_function (GtkQuitFunction *quitf); +static void gtk_quit_destroy (GtkQuitFunction *quitf); static void gtk_timeout_insert (GtkTimeoutFunction *timeoutf); static void gtk_handle_current_timeouts (guint32 the_time); static void gtk_handle_current_idles (void); @@ -117,6 +130,8 @@ static GSList *grabs = NULL; /* A stack of unique grabs. The grabbing */ static GList *init_functions = NULL; /* A list of init functions. */ +static GList *quit_functions = NULL; /* A list of quit functions. + */ static GList *timeout_functions = NULL; /* A list of timeout functions sorted by * when the length of the time interval * remaining. Therefore, the first timeout @@ -131,6 +146,7 @@ static GList *current_idles = NULL; static GList *current_timeouts = NULL; static GMemChunk *timeout_mem_chunk = NULL; static GMemChunk *idle_mem_chunk = NULL; +static GMemChunk *quit_mem_chunk = NULL; static GSList *key_snoopers = NULL; @@ -283,14 +299,48 @@ gtk_main () (* init->function) (init->data); g_free (init); } - g_list_free (functions); old_done = iteration_done; while (!gtk_main_iteration ()) ; iteration_done = old_done; - + + if (quit_functions) + { + GList *reinvoke_list = NULL; + GtkQuitFunction *quitf; + + while (quit_functions) + { + quitf = quit_functions->data; + + quit_functions = g_list_remove_link (quit_functions, quit_functions); + + if ((quitf->main_level && + quitf->main_level != main_level) || + gtk_quit_invoke_function (quitf) == FALSE) + { + g_list_free (tmp_list); + gtk_quit_destroy (quitf); + } + else + { + reinvoke_list = g_list_prepend (reinvoke_list, quitf); + } + } + if (reinvoke_list) + { + GList *tmp_list; + + tmp_list = g_list_last (reinvoke_list); + if (quit_functions) + quit_functions->prev = tmp_list; + tmp_list->next = quit_functions; + quit_functions = tmp_list; + } + } + main_level--; } @@ -796,6 +846,36 @@ gtk_idle_compare (gpointer a, gpointer b) } gint +gtk_quit_add_full (guint main_level, + GtkFunction function, + GtkCallbackMarshal marshal, + gpointer data, + GtkDestroyNotify destroy) +{ + static gint quit_tag = 1; + GtkQuitFunction *quitf; + + g_return_val_if_fail ((function != NULL) || (marshal != NULL), 0); + + if (!quit_mem_chunk) + quit_mem_chunk = g_mem_chunk_new ("quit mem chunk", sizeof (GtkQuitFunction), + 512, G_ALLOC_AND_FREE); + + quitf = g_chunk_new (GtkQuitFunction, quit_mem_chunk); + + quitf->tag = quit_tag++; + quitf->main_level = main_level; + quitf->function = function; + quitf->marshal = marshal; + quitf->data = data; + quitf->destroy = destroy; + + quit_functions = g_list_prepend (quit_functions, quitf); + + return quitf->tag; +} + +gint gtk_idle_add_full (gint priority, GtkFunction function, GtkCallbackMarshal marshal, @@ -841,6 +921,22 @@ gtk_idle_destroy (GtkIdleFunction *idlef) g_mem_chunk_free (idle_mem_chunk, idlef); } +static void +gtk_quit_destroy (GtkQuitFunction *quitf) +{ + if (quitf->destroy) + quitf->destroy (quitf->data); + g_mem_chunk_free (quit_mem_chunk, quitf); +} + +gint +gtk_quit_add (guint main_level, + GtkFunction function, + gpointer data) +{ + return gtk_quit_add_full (main_level, function, NULL, data, NULL); +} + gint gtk_idle_add (GtkFunction function, gpointer data) @@ -857,6 +953,54 @@ gtk_idle_add_priority (gint priority, } void +gtk_quit_remove (gint tag) +{ + GtkQuitFunction *quitf; + GList *tmp_list; + + tmp_list = quit_functions; + while (tmp_list) + { + quitf = tmp_list->data; + + if (quitf->tag == tag) + { + quit_functions = g_list_remove_link (quit_functions, tmp_list); + g_list_free (tmp_list); + gtk_quit_destroy (quitf); + + return; + } + + tmp_list = tmp_list->next; + } +} + +void +gtk_quit_remove_by_data (gpointer data) +{ + GtkQuitFunction *quitf; + GList *tmp_list; + + tmp_list = quit_functions; + while (tmp_list) + { + quitf = tmp_list->data; + + if (quitf->data == data) + { + quit_functions = g_list_remove_link (quit_functions, tmp_list); + g_list_free (tmp_list); + gtk_quit_destroy (quitf); + + return; + } + + tmp_list = tmp_list->next; + } +} + +void gtk_idle_remove (gint tag) { GtkIdleFunction *idlef; @@ -912,7 +1056,7 @@ gtk_idle_remove_by_data (gpointer data) { idle_functions = g_list_remove_link (idle_functions, tmp_list); g_list_free (tmp_list); - g_mem_chunk_free (idle_mem_chunk, idlef); + gtk_idle_destroy (idlef); return; } @@ -929,7 +1073,7 @@ gtk_idle_remove_by_data (gpointer data) { current_idles = g_list_remove_link (current_idles, tmp_list); g_list_free (tmp_list); - g_mem_chunk_free (idle_mem_chunk, idlef); + gtk_idle_destroy (idlef); return; } @@ -1150,6 +1294,26 @@ gtk_handle_timeouts () } static gint +gtk_quit_invoke_function (GtkQuitFunction *quitf) +{ + if (!quitf->marshal) + return quitf->function (quitf->data); + else + { + GtkArg args[1]; + gint ret_val = FALSE; + + args[0].name = NULL; + args[0].type = GTK_TYPE_BOOL; + args[0].d.pointer_data = &ret_val; + ((GtkCallbackMarshal) quitf->marshal) (NULL, + quitf->data, + 0, args); + return ret_val; + } +} + +static gint gtk_idle_invoke_function (GtkIdleFunction *idlef) { if (!idlef->marshal) @@ -1158,12 +1322,13 @@ gtk_idle_invoke_function (GtkIdleFunction *idlef) { GtkArg args[1]; gint ret_val = FALSE; + args[0].name = NULL; args[0].type = GTK_TYPE_BOOL; args[0].d.pointer_data = &ret_val; - ((GtkCallbackMarshal)idlef->marshal) (NULL, - idlef->data, - 0, args); + ((GtkCallbackMarshal) idlef->marshal) (NULL, + idlef->data, + 0, args); return ret_val; } } diff --git a/gtk/gtkmain.h b/gtk/gtkmain.h index 0dbd4cc43..ef8597c1d 100644 --- a/gtk/gtkmain.h +++ b/gtk/gtkmain.h @@ -60,7 +60,16 @@ void gtk_grab_remove (GtkWidget *widget); void gtk_init_add (GtkFunction function, gpointer data); - +gint gtk_quit_add (guint main_level, + GtkFunction function, + gpointer data); +gint gtk_quit_add_full (guint main_level, + GtkFunction function, + GtkCallbackMarshal marshal, + gpointer data, + GtkDestroyNotify destroy); +void gtk_quit_remove (gint tag); +void gtk_quit_remove_by_data (gpointer data); gint gtk_timeout_add_full (guint32 interval, GtkFunction function, GtkCallbackMarshal marshal, |