]> Pileus Git - ~andy/gtk/blob - gdk/gdk.c
Do not test the event mask of implicit grabs
[~andy/gtk] / gdk / gdk.c
1 /* GDK - The GIMP Drawing Kit
2  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 /*
21  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
22  * file for a list of people on the GTK+ Team.  See the ChangeLog
23  * files for a list of changes.  These files are distributed with
24  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
25  */
26
27 #include "config.h"
28
29 #include <string.h>
30 #include <stdlib.h>
31
32 #include "gdk.h"
33 #include "gdkinternals.h"
34 #include "gdkintl.h"
35
36 #ifndef HAVE_XCONVERTCASE
37 #include "gdkkeysyms.h"
38 #endif
39 #include "gdkalias.h"
40
41 typedef struct _GdkPredicate  GdkPredicate;
42
43 struct _GdkPredicate
44 {
45   GdkEventFunc func;
46   gpointer data;
47 };
48
49 typedef struct _GdkThreadsDispatch GdkThreadsDispatch;
50
51 struct _GdkThreadsDispatch
52 {
53   GSourceFunc func;
54   gpointer data;
55   GDestroyNotify destroy;
56 };
57
58
59 /* Private variable declarations
60  */
61 static int gdk_initialized = 0;                     /* 1 if the library is initialized,
62                                                      * 0 otherwise.
63                                                      */
64
65 static gchar  *gdk_progclass = NULL;
66
67 #ifdef G_ENABLE_DEBUG
68 static const GDebugKey gdk_debug_keys[] = {
69   {"events",        GDK_DEBUG_EVENTS},
70   {"misc",          GDK_DEBUG_MISC},
71   {"dnd",           GDK_DEBUG_DND},
72   {"xim",           GDK_DEBUG_XIM},
73   {"nograbs",       GDK_DEBUG_NOGRABS},
74   {"colormap",      GDK_DEBUG_COLORMAP},
75   {"gdkrgb",        GDK_DEBUG_GDKRGB},
76   {"gc",            GDK_DEBUG_GC},
77   {"pixmap",        GDK_DEBUG_PIXMAP},
78   {"image",         GDK_DEBUG_IMAGE},
79   {"input",         GDK_DEBUG_INPUT},
80   {"cursor",        GDK_DEBUG_CURSOR},
81   {"multihead",     GDK_DEBUG_MULTIHEAD},
82   {"xinerama",      GDK_DEBUG_XINERAMA},
83   {"draw",          GDK_DEBUG_DRAW},
84   {"eventloop",     GDK_DEBUG_EVENTLOOP}
85 };
86
87 static const int gdk_ndebug_keys = G_N_ELEMENTS (gdk_debug_keys);
88
89 #endif /* G_ENABLE_DEBUG */
90
91 #ifdef G_ENABLE_DEBUG
92 static gboolean
93 gdk_arg_debug_cb (const char *key, const char *value, gpointer user_data, GError **error)
94 {
95   guint debug_value = g_parse_debug_string (value,
96                                             (GDebugKey *) gdk_debug_keys,
97                                             gdk_ndebug_keys);
98
99   if (debug_value == 0 && value != NULL && strcmp (value, "") != 0)
100     {
101       g_set_error (error, 
102                    G_OPTION_ERROR, G_OPTION_ERROR_FAILED,
103                    _("Error parsing option --gdk-debug"));
104       return FALSE;
105     }
106
107   _gdk_debug_flags |= debug_value;
108
109   return TRUE;
110 }
111
112 static gboolean
113 gdk_arg_no_debug_cb (const char *key, const char *value, gpointer user_data, GError **error)
114 {
115   guint debug_value = g_parse_debug_string (value,
116                                             (GDebugKey *) gdk_debug_keys,
117                                             gdk_ndebug_keys);
118
119   if (debug_value == 0 && value != NULL && strcmp (value, "") != 0)
120     {
121       g_set_error (error, 
122                    G_OPTION_ERROR, G_OPTION_ERROR_FAILED,
123                    _("Error parsing option --gdk-no-debug"));
124       return FALSE;
125     }
126
127   _gdk_debug_flags &= ~debug_value;
128
129   return TRUE;
130 }
131 #endif /* G_ENABLE_DEBUG */
132
133 static gboolean
134 gdk_arg_class_cb (const char *key, const char *value, gpointer user_data, GError **error)
135 {
136   gdk_set_program_class (value);
137
138   return TRUE;
139 }
140
141 static gboolean
142 gdk_arg_name_cb (const char *key, const char *value, gpointer user_data, GError **error)
143 {
144   g_set_prgname (value);
145
146   return TRUE;
147 }
148
149 static const GOptionEntry gdk_args[] = {
150   { "class",        0, 0,                     G_OPTION_ARG_CALLBACK, gdk_arg_class_cb,
151     /* Description of --class=CLASS in --help output */        N_("Program class as used by the window manager"),
152     /* Placeholder in --class=CLASS in --help output */        N_("CLASS") },
153   { "name",         0, 0,                     G_OPTION_ARG_CALLBACK, gdk_arg_name_cb,
154     /* Description of --name=NAME in --help output */          N_("Program name as used by the window manager"),
155     /* Placeholder in --name=NAME in --help output */          N_("NAME") },
156   { "display",      0, G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING,   &_gdk_display_name,
157     /* Description of --display=DISPLAY in --help output */    N_("X display to use"),
158     /* Placeholder in --display=DISPLAY in --help output */    N_("DISPLAY") },
159   { "screen",       0, 0, G_OPTION_ARG_INT,      &_gdk_screen_number,
160     /* Description of --screen=SCREEN in --help output */      N_("X screen to use"),
161     /* Placeholder in --screen=SCREEN in --help output */      N_("SCREEN") },
162 #ifdef G_ENABLE_DEBUG
163   { "gdk-debug",    0, 0, G_OPTION_ARG_CALLBACK, gdk_arg_debug_cb,  
164     /* Description of --gdk-debug=FLAGS in --help output */    N_("Gdk debugging flags to set"),
165     /* Placeholder in --gdk-debug=FLAGS in --help output */    N_("FLAGS") },
166   { "gdk-no-debug", 0, 0, G_OPTION_ARG_CALLBACK, gdk_arg_no_debug_cb, 
167     /* Description of --gdk-no-debug=FLAGS in --help output */ N_("Gdk debugging flags to unset"), 
168     /* Placeholder in --gdk-no-debug=FLAGS in --help output */ N_("FLAGS") },
169 #endif 
170   { NULL }
171 };
172
173 /**
174  * gdk_add_option_entries_libgtk_only:
175  * @group: An option group.
176  * 
177  * Appends gdk option entries to the passed in option group. This is
178  * not public API and must not be used by applications.
179  **/
180 void
181 gdk_add_option_entries_libgtk_only (GOptionGroup *group)
182 {
183   g_option_group_add_entries (group, gdk_args);
184   g_option_group_add_entries (group, _gdk_windowing_args);
185 }
186
187 void
188 gdk_pre_parse_libgtk_only (void)
189 {
190   gdk_initialized = TRUE;
191
192   /* We set the fallback program class here, rather than lazily in
193    * gdk_get_program_class, since we don't want -name to override it.
194    */
195   gdk_progclass = g_strdup (g_get_prgname ());
196   if (gdk_progclass && gdk_progclass[0])
197     gdk_progclass[0] = g_ascii_toupper (gdk_progclass[0]);
198   
199 #ifdef G_ENABLE_DEBUG
200   {
201     gchar *debug_string = getenv("GDK_DEBUG");
202     if (debug_string != NULL)
203       _gdk_debug_flags = g_parse_debug_string (debug_string,
204                                               (GDebugKey *) gdk_debug_keys,
205                                               gdk_ndebug_keys);
206   }
207 #endif  /* G_ENABLE_DEBUG */
208
209   if (getenv ("GDK_NATIVE_WINDOWS"))
210     {
211       _gdk_native_windows = TRUE;
212       /* Ensure that this is not propagated
213          to spawned applications */
214       g_unsetenv ("GDK_NATIVE_WINDOWS");
215     }
216
217   g_type_init ();
218
219   /* Do any setup particular to the windowing system
220    */
221   _gdk_windowing_init ();  
222 }
223
224   
225 /**
226  * gdk_parse_args:
227  * @argc: the number of command line arguments.
228  * @argv: the array of command line arguments.
229  * 
230  * Parse command line arguments, and store for future
231  * use by calls to gdk_display_open().
232  *
233  * Any arguments used by GDK are removed from the array and @argc and @argv are
234  * updated accordingly.
235  *
236  * You shouldn't call this function explicitely if you are using
237  * gtk_init(), gtk_init_check(), gdk_init(), or gdk_init_check().
238  *
239  * Since: 2.2
240  **/
241 void
242 gdk_parse_args (int    *argc,
243                 char ***argv)
244 {
245   GOptionContext *option_context;
246   GOptionGroup *option_group;
247   GError *error = NULL;
248
249   if (gdk_initialized)
250     return;
251
252   gdk_pre_parse_libgtk_only ();
253   
254   option_context = g_option_context_new (NULL);
255   g_option_context_set_ignore_unknown_options (option_context, TRUE);
256   g_option_context_set_help_enabled (option_context, FALSE);
257   option_group = g_option_group_new (NULL, NULL, NULL, NULL, NULL);
258   g_option_context_set_main_group (option_context, option_group);
259   
260   g_option_group_add_entries (option_group, gdk_args);
261   g_option_group_add_entries (option_group, _gdk_windowing_args);
262
263   if (!g_option_context_parse (option_context, argc, argv, &error))
264     {
265       g_warning ("%s", error->message);
266       g_error_free (error);
267     }
268   g_option_context_free (option_context);
269
270   if (_gdk_debug_flags && GDK_DEBUG_GDKRGB)
271     gdk_rgb_set_verbose (TRUE);
272
273   GDK_NOTE (MISC, g_message ("progname: \"%s\"", g_get_prgname ()));
274 }
275
276 /** 
277  * gdk_get_display_arg_name:
278  *
279  * Gets the display name specified in the command line arguments passed
280  * to gdk_init() or gdk_parse_args(), if any.
281  *
282  * Returns: the display name, if specified explicitely, otherwise %NULL
283  *   this string is owned by GTK+ and must not be modified or freed.
284  *
285  * Since: 2.2
286  */
287 G_CONST_RETURN gchar *
288 gdk_get_display_arg_name (void)
289 {
290   if (!_gdk_display_arg_name)
291     {
292       if (_gdk_screen_number >= 0)
293         _gdk_display_arg_name = _gdk_windowing_substitute_screen_number (_gdk_display_name, _gdk_screen_number);
294       else
295         _gdk_display_arg_name = g_strdup (_gdk_display_name);
296    }
297
298    return _gdk_display_arg_name;
299 }
300
301 /**
302  * gdk_display_open_default_libgtk_only:
303  * 
304  * Opens the default display specified by command line arguments or
305  * environment variables, sets it as the default display, and returns
306  * it.  gdk_parse_args must have been called first. If the default
307  * display has previously been set, simply returns that. An internal
308  * function that should not be used by applications.
309  * 
310  * Return value: the default display, if it could be opened,
311  *   otherwise %NULL.
312  **/
313 GdkDisplay *
314 gdk_display_open_default_libgtk_only (void)
315 {
316   GdkDisplay *display;
317
318   g_return_val_if_fail (gdk_initialized, NULL);
319   
320   display = gdk_display_get_default ();
321   if (display)
322     return display;
323
324   display = gdk_display_open (gdk_get_display_arg_name ());
325
326   if (!display && _gdk_screen_number >= 0)
327     {
328       g_free (_gdk_display_arg_name);
329       _gdk_display_arg_name = g_strdup (_gdk_display_name);
330       
331       display = gdk_display_open (_gdk_display_name);
332     }
333   
334   if (display)
335     gdk_display_manager_set_default_display (gdk_display_manager_get (),
336                                              display);
337   
338   return display;
339 }
340
341 /*
342  *--------------------------------------------------------------
343  * gdk_init_check
344  *
345  *   Initialize the library for use.
346  *
347  * Arguments:
348  *   "argc" is the number of arguments.
349  *   "argv" is an array of strings.
350  *
351  * Results:
352  *   "argc" and "argv" are modified to reflect any arguments
353  *   which were not handled. (Such arguments should either
354  *   be handled by the application or dismissed). If initialization
355  *   fails, returns FALSE, otherwise TRUE.
356  *
357  * Side effects:
358  *   The library is initialized.
359  *
360  *--------------------------------------------------------------
361  */
362
363 gboolean
364 gdk_init_check (int    *argc,
365                 char ***argv)
366 {
367   gdk_parse_args (argc, argv);
368
369   return gdk_display_open_default_libgtk_only () != NULL;
370 }
371
372 void
373 gdk_init (int *argc, char ***argv)
374 {
375   if (!gdk_init_check (argc, argv))
376     {
377       const char *display_name = gdk_get_display_arg_name ();
378       g_warning ("cannot open display: %s", display_name ? display_name : "");
379       exit(1);
380     }
381 }
382
383 /*
384  *--------------------------------------------------------------
385  * gdk_exit
386  *
387  *   Restores the library to an un-itialized state and exits
388  *   the program using the "exit" system call.
389  *
390  * Arguments:
391  *   "errorcode" is the error value to pass to "exit".
392  *
393  * Results:
394  *   Allocated structures are freed and the program exits
395  *   cleanly.
396  *
397  * Side effects:
398  *
399  *--------------------------------------------------------------
400  */
401
402 void
403 gdk_exit (gint errorcode)
404 {
405   exit (errorcode);
406 }
407
408 void
409 gdk_threads_enter (void)
410 {
411   GDK_THREADS_ENTER ();
412 }
413
414 void
415 gdk_threads_leave (void)
416 {
417   GDK_THREADS_LEAVE ();
418 }
419
420 static void
421 gdk_threads_impl_lock (void)
422 {
423   if (gdk_threads_mutex)
424     g_mutex_lock (gdk_threads_mutex);
425 }
426
427 static void
428 gdk_threads_impl_unlock (void)
429 {
430   if (gdk_threads_mutex)
431     g_mutex_unlock (gdk_threads_mutex);
432 }
433
434 /**
435  * gdk_threads_init:
436  * 
437  * Initializes GDK so that it can be used from multiple threads
438  * in conjunction with gdk_threads_enter() and gdk_threads_leave().
439  * g_thread_init() must be called previous to this function.
440  *
441  * This call must be made before any use of the main loop from
442  * GTK+; to be safe, call it before gtk_init().
443  **/
444 void
445 gdk_threads_init (void)
446 {
447   if (!g_thread_supported ())
448     g_error ("g_thread_init() must be called before gdk_threads_init()");
449
450   gdk_threads_mutex = g_mutex_new ();
451   if (!gdk_threads_lock)
452     gdk_threads_lock = gdk_threads_impl_lock;
453   if (!gdk_threads_unlock)
454     gdk_threads_unlock = gdk_threads_impl_unlock;
455 }
456
457 /**
458  * gdk_threads_set_lock_functions:
459  * @enter_fn:   function called to guard GDK
460  * @leave_fn: function called to release the guard
461  *
462  * Allows the application to replace the standard method that
463  * GDK uses to protect its data structures. Normally, GDK
464  * creates a single #GMutex that is locked by gdk_threads_enter(),
465  * and released by gdk_threads_leave(); using this function an
466  * application provides, instead, a function @enter_fn that is
467  * called by gdk_threads_enter() and a function @leave_fn that is
468  * called by gdk_threads_leave().
469  *
470  * The functions must provide at least same locking functionality
471  * as the default implementation, but can also do extra application
472  * specific processing.
473  *
474  * As an example, consider an application that has its own recursive
475  * lock that when held, holds the GTK+ lock as well. When GTK+ unlocks
476  * the GTK+ lock when entering a recursive main loop, the application
477  * must temporarily release its lock as well.
478  *
479  * Most threaded GTK+ apps won't need to use this method.
480  *
481  * This method must be called before gdk_threads_init(), and cannot
482  * be called multiple times.
483  *
484  * Since: 2.4
485  **/
486 void
487 gdk_threads_set_lock_functions (GCallback enter_fn,
488                                 GCallback leave_fn)
489 {
490   g_return_if_fail (gdk_threads_lock == NULL &&
491                     gdk_threads_unlock == NULL);
492
493   gdk_threads_lock = enter_fn;
494   gdk_threads_unlock = leave_fn;
495 }
496
497 static gboolean
498 gdk_threads_dispatch (gpointer data)
499 {
500   GdkThreadsDispatch *dispatch = data;
501   gboolean ret = FALSE;
502
503   GDK_THREADS_ENTER ();
504
505   if (!g_source_is_destroyed (g_main_current_source ()))
506     ret = dispatch->func (dispatch->data);
507
508   GDK_THREADS_LEAVE ();
509
510   return ret;
511 }
512
513 static void
514 gdk_threads_dispatch_free (gpointer data)
515 {
516   GdkThreadsDispatch *dispatch = data;
517
518   if (dispatch->destroy && dispatch->data)
519     dispatch->destroy (dispatch->data);
520
521   g_slice_free (GdkThreadsDispatch, data);
522 }
523
524
525 /**
526  * gdk_threads_add_idle_full:
527  * @priority: the priority of the idle source. Typically this will be in the
528  *            range btweeen #G_PRIORITY_DEFAULT_IDLE and #G_PRIORITY_HIGH_IDLE
529  * @function: function to call
530  * @data:     data to pass to @function
531  * @notify:   function to call when the idle is removed, or %NULL
532  *
533  * Adds a function to be called whenever there are no higher priority
534  * events pending.  If the function returns %FALSE it is automatically
535  * removed from the list of event sources and will not be called again.
536  *
537  * This variant of g_idle_add_full() calls @function with the GDK lock
538  * held. It can be thought of a MT-safe version for GTK+ widgets for the 
539  * following use case, where you have to worry about idle_callback()
540  * running in thread A and accessing @self after it has been finalized
541  * in thread B:
542  *
543  * |[
544  * static gboolean
545  * idle_callback (gpointer data)
546  * {
547  *    /&ast; gdk_threads_enter(); would be needed for g_idle_add() &ast;/
548  *
549  *    SomeWidget *self = data;
550  *    /&ast; do stuff with self &ast;/
551  *
552  *    self->idle_id = 0;
553  *
554  *    /&ast; gdk_threads_leave(); would be needed for g_idle_add() &ast;/
555  *    return FALSE;
556  * }
557  *
558  * static void
559  * some_widget_do_stuff_later (SomeWidget *self)
560  * {
561  *    self->idle_id = gdk_threads_add_idle (idle_callback, self)
562  *    /&ast; using g_idle_add() here would require thread protection in the callback &ast;/
563  * }
564  *
565  * static void
566  * some_widget_finalize (GObject *object)
567  * {
568  *    SomeWidget *self = SOME_WIDGET (object);
569  *    if (self->idle_id)
570  *      g_source_remove (self->idle_id);
571  *    G_OBJECT_CLASS (parent_class)->finalize (object);
572  * }
573  * ]|
574  *
575  * Return value: the ID (greater than 0) of the event source.
576  *
577  * Since: 2.12
578  */
579 guint
580 gdk_threads_add_idle_full (gint           priority,
581                            GSourceFunc    function,
582                            gpointer       data,
583                            GDestroyNotify notify)
584 {
585   GdkThreadsDispatch *dispatch;
586
587   g_return_val_if_fail (function != NULL, 0);
588
589   dispatch = g_slice_new (GdkThreadsDispatch);
590   dispatch->func = function;
591   dispatch->data = data;
592   dispatch->destroy = notify;
593
594   return g_idle_add_full (priority,
595                           gdk_threads_dispatch,
596                           dispatch,
597                           gdk_threads_dispatch_free);
598 }
599
600 /**
601  * gdk_threads_add_idle:
602  * @function: function to call
603  * @data:     data to pass to @function
604  *
605  * A wrapper for the common usage of gdk_threads_add_idle_full() 
606  * assigning the default priority, #G_PRIORITY_DEFAULT_IDLE.
607  *
608  * See gdk_threads_add_idle_full().
609  *
610  * Return value: the ID (greater than 0) of the event source.
611  * 
612  * Since: 2.12
613  */
614 guint
615 gdk_threads_add_idle (GSourceFunc    function,
616                       gpointer       data)
617 {
618   return gdk_threads_add_idle_full (G_PRIORITY_DEFAULT_IDLE,
619                                     function, data, NULL);
620 }
621
622
623 /**
624  * gdk_threads_add_timeout_full:
625  * @priority: the priority of the timeout source. Typically this will be in the
626  *            range between #G_PRIORITY_DEFAULT_IDLE and #G_PRIORITY_HIGH_IDLE.
627  * @interval: the time between calls to the function, in milliseconds
628  *             (1/1000ths of a second)
629  * @function: function to call
630  * @data:     data to pass to @function
631  * @notify:   function to call when the timeout is removed, or %NULL
632  *
633  * Sets a function to be called at regular intervals holding the GDK lock,
634  * with the given priority.  The function is called repeatedly until it 
635  * returns %FALSE, at which point the timeout is automatically destroyed 
636  * and the function will not be called again.  The @notify function is
637  * called when the timeout is destroyed.  The first call to the
638  * function will be at the end of the first @interval.
639  *
640  * Note that timeout functions may be delayed, due to the processing of other
641  * event sources. Thus they should not be relied on for precise timing.
642  * After each call to the timeout function, the time of the next
643  * timeout is recalculated based on the current time and the given interval
644  * (it does not try to 'catch up' time lost in delays).
645  *
646  * This variant of g_timeout_add_full() can be thought of a MT-safe version 
647  * for GTK+ widgets for the following use case:
648  *
649  * |[
650  * static gboolean timeout_callback (gpointer data)
651  * {
652  *    SomeWidget *self = data;
653  *    
654  *    /&ast; do stuff with self &ast;/
655  *    
656  *    self->timeout_id = 0;
657  *    
658  *    return FALSE;
659  * }
660  *  
661  * static void some_widget_do_stuff_later (SomeWidget *self)
662  * {
663  *    self->timeout_id = g_timeout_add (timeout_callback, self)
664  * }
665  *  
666  * static void some_widget_finalize (GObject *object)
667  * {
668  *    SomeWidget *self = SOME_WIDGET (object);
669  *    
670  *    if (self->timeout_id)
671  *      g_source_remove (self->timeout_id);
672  *    
673  *    G_OBJECT_CLASS (parent_class)->finalize (object);
674  * }
675  * ]|
676  *
677  * Return value: the ID (greater than 0) of the event source.
678  * 
679  * Since: 2.12
680  */
681 guint
682 gdk_threads_add_timeout_full (gint           priority,
683                               guint          interval,
684                               GSourceFunc    function,
685                               gpointer       data,
686                               GDestroyNotify notify)
687 {
688   GdkThreadsDispatch *dispatch;
689
690   g_return_val_if_fail (function != NULL, 0);
691
692   dispatch = g_slice_new (GdkThreadsDispatch);
693   dispatch->func = function;
694   dispatch->data = data;
695   dispatch->destroy = notify;
696
697   return g_timeout_add_full (priority, 
698                              interval,
699                              gdk_threads_dispatch, 
700                              dispatch, 
701                              gdk_threads_dispatch_free);
702 }
703
704 /**
705  * gdk_threads_add_timeout:
706  * @interval: the time between calls to the function, in milliseconds
707  *             (1/1000ths of a second)
708  * @function: function to call
709  * @data:     data to pass to @function
710  *
711  * A wrapper for the common usage of gdk_threads_add_timeout_full() 
712  * assigning the default priority, #G_PRIORITY_DEFAULT.
713  *
714  * See gdk_threads_add_timeout_full().
715  * 
716  * Return value: the ID (greater than 0) of the event source.
717  *
718  * Since: 2.12
719  */
720 guint
721 gdk_threads_add_timeout (guint       interval,
722                          GSourceFunc function,
723                          gpointer    data)
724 {
725   return gdk_threads_add_timeout_full (G_PRIORITY_DEFAULT,
726                                        interval, function, data, NULL);
727 }
728
729
730 /**
731  * gdk_threads_add_timeout_seconds_full:
732  * @priority: the priority of the timeout source. Typically this will be in the
733  *            range between #G_PRIORITY_DEFAULT_IDLE and #G_PRIORITY_HIGH_IDLE.
734  * @interval: the time between calls to the function, in seconds
735  * @function: function to call
736  * @data:     data to pass to @function
737  * @notify:   function to call when the timeout is removed, or %NULL
738  *
739  * A variant of gdk_threads_add_timout_full() with second-granularity.
740  * See g_timeout_add_seconds_full() for a discussion of why it is
741  * a good idea to use this function if you don't need finer granularity.
742  *
743  *  Return value: the ID (greater than 0) of the event source.
744  * 
745  * Since: 2.14
746  */
747 guint
748 gdk_threads_add_timeout_seconds_full (gint           priority,
749                                       guint          interval,
750                                       GSourceFunc    function,
751                                       gpointer       data,
752                                       GDestroyNotify notify)
753 {
754   GdkThreadsDispatch *dispatch;
755
756   g_return_val_if_fail (function != NULL, 0);
757
758   dispatch = g_slice_new (GdkThreadsDispatch);
759   dispatch->func = function;
760   dispatch->data = data;
761   dispatch->destroy = notify;
762
763   return g_timeout_add_seconds_full (priority, 
764                                      interval,
765                                      gdk_threads_dispatch, 
766                                      dispatch, 
767                                      gdk_threads_dispatch_free);
768 }
769
770 /**
771  * gdk_threads_add_timeout_seconds:
772  * @interval: the time between calls to the function, in seconds
773  * @function: function to call
774  * @data:     data to pass to @function
775  *
776  * A wrapper for the common usage of gdk_threads_add_timeout_seconds_full() 
777  * assigning the default priority, #G_PRIORITY_DEFAULT.
778  *
779  * For details, see gdk_threads_add_timeout_full().
780  * 
781  * Return value: the ID (greater than 0) of the event source.
782  *
783  * Since: 2.14
784  */
785 guint
786 gdk_threads_add_timeout_seconds (guint       interval,
787                                  GSourceFunc function,
788                                  gpointer    data)
789 {
790   return gdk_threads_add_timeout_seconds_full (G_PRIORITY_DEFAULT,
791                                                interval, function, data, NULL);
792 }
793
794
795 G_CONST_RETURN char *
796 gdk_get_program_class (void)
797 {
798   return gdk_progclass;
799 }
800
801 void
802 gdk_set_program_class (const char *program_class)
803 {
804   g_free (gdk_progclass);
805
806   gdk_progclass = g_strdup (program_class);
807 }
808
809 #define __GDK_C__
810 #include "gdkaliasdef.c"