]> Pileus Git - ~andy/gtk/blob - gdk/gdk.c
A GOptionArgFunc should return gboolean and take also a GError pointer
[~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   g_type_init ();
210
211   /* Do any setup particular to the windowing system
212    */
213   _gdk_windowing_init ();  
214 }
215
216   
217 /**
218  * gdk_parse_args:
219  * @argc: the number of command line arguments.
220  * @argv: the array of command line arguments.
221  * 
222  * Parse command line arguments, and store for future
223  * use by calls to gdk_display_open().
224  *
225  * Any arguments used by GDK are removed from the array and @argc and @argv are
226  * updated accordingly.
227  *
228  * You shouldn't call this function explicitely if you are using
229  * gtk_init(), gtk_init_check(), gdk_init(), or gdk_init_check().
230  *
231  * Since: 2.2
232  **/
233 void
234 gdk_parse_args (int    *argc,
235                 char ***argv)
236 {
237   GOptionContext *option_context;
238   GOptionGroup *option_group;
239   GError *error = NULL;
240
241   if (gdk_initialized)
242     return;
243
244   gdk_pre_parse_libgtk_only ();
245   
246   option_context = g_option_context_new (NULL);
247   g_option_context_set_ignore_unknown_options (option_context, TRUE);
248   g_option_context_set_help_enabled (option_context, FALSE);
249   option_group = g_option_group_new (NULL, NULL, NULL, NULL, NULL);
250   g_option_context_set_main_group (option_context, option_group);
251   
252   g_option_group_add_entries (option_group, gdk_args);
253   g_option_group_add_entries (option_group, _gdk_windowing_args);
254
255   if (!g_option_context_parse (option_context, argc, argv, &error))
256     {
257       g_warning ("%s", error->message);
258       g_error_free (error);
259     }
260   g_option_context_free (option_context);
261
262   if (_gdk_debug_flags && GDK_DEBUG_GDKRGB)
263     gdk_rgb_set_verbose (TRUE);
264
265   GDK_NOTE (MISC, g_message ("progname: \"%s\"", g_get_prgname ()));
266 }
267
268 /** 
269  * gdk_get_display_arg_name:
270  *
271  * Gets the display name specified in the command line arguments passed
272  * to gdk_init() or gdk_parse_args(), if any.
273  *
274  * Returns: the display name, if specified explicitely, otherwise %NULL
275  *   this string is owned by GTK+ and must not be modified or freed.
276  *
277  * Since: 2.2
278  */
279 G_CONST_RETURN gchar *
280 gdk_get_display_arg_name (void)
281 {
282   if (!_gdk_display_arg_name)
283     {
284       if (_gdk_screen_number >= 0)
285         _gdk_display_arg_name = _gdk_windowing_substitute_screen_number (_gdk_display_name, _gdk_screen_number);
286       else
287         _gdk_display_arg_name = g_strdup (_gdk_display_name);
288    }
289
290    return _gdk_display_arg_name;
291 }
292
293 /**
294  * gdk_display_open_default_libgtk_only:
295  * 
296  * Opens the default display specified by command line arguments or
297  * environment variables, sets it as the default display, and returns
298  * it.  gdk_parse_args must have been called first. If the default
299  * display has previously been set, simply returns that. An internal
300  * function that should not be used by applications.
301  * 
302  * Return value: the default display, if it could be opened,
303  *   otherwise %NULL.
304  **/
305 GdkDisplay *
306 gdk_display_open_default_libgtk_only (void)
307 {
308   GdkDisplay *display;
309
310   g_return_val_if_fail (gdk_initialized, NULL);
311   
312   display = gdk_display_get_default ();
313   if (display)
314     return display;
315
316   display = gdk_display_open (gdk_get_display_arg_name ());
317
318   if (!display && _gdk_screen_number >= 0)
319     {
320       g_free (_gdk_display_arg_name);
321       _gdk_display_arg_name = g_strdup (_gdk_display_name);
322       
323       display = gdk_display_open (_gdk_display_name);
324     }
325   
326   if (display)
327     gdk_display_manager_set_default_display (gdk_display_manager_get (),
328                                              display);
329   
330   return display;
331 }
332
333 /*
334  *--------------------------------------------------------------
335  * gdk_init_check
336  *
337  *   Initialize the library for use.
338  *
339  * Arguments:
340  *   "argc" is the number of arguments.
341  *   "argv" is an array of strings.
342  *
343  * Results:
344  *   "argc" and "argv" are modified to reflect any arguments
345  *   which were not handled. (Such arguments should either
346  *   be handled by the application or dismissed). If initialization
347  *   fails, returns FALSE, otherwise TRUE.
348  *
349  * Side effects:
350  *   The library is initialized.
351  *
352  *--------------------------------------------------------------
353  */
354
355 gboolean
356 gdk_init_check (int    *argc,
357                 char ***argv)
358 {
359   gdk_parse_args (argc, argv);
360
361   return gdk_display_open_default_libgtk_only () != NULL;
362 }
363
364 void
365 gdk_init (int *argc, char ***argv)
366 {
367   if (!gdk_init_check (argc, argv))
368     {
369       const char *display_name = gdk_get_display_arg_name ();
370       g_warning ("cannot open display: %s", display_name ? display_name : "");
371       exit(1);
372     }
373 }
374
375 /*
376  *--------------------------------------------------------------
377  * gdk_exit
378  *
379  *   Restores the library to an un-itialized state and exits
380  *   the program using the "exit" system call.
381  *
382  * Arguments:
383  *   "errorcode" is the error value to pass to "exit".
384  *
385  * Results:
386  *   Allocated structures are freed and the program exits
387  *   cleanly.
388  *
389  * Side effects:
390  *
391  *--------------------------------------------------------------
392  */
393
394 void
395 gdk_exit (gint errorcode)
396 {
397   exit (errorcode);
398 }
399
400 void
401 gdk_threads_enter (void)
402 {
403   GDK_THREADS_ENTER ();
404 }
405
406 void
407 gdk_threads_leave (void)
408 {
409   GDK_THREADS_LEAVE ();
410 }
411
412 static void
413 gdk_threads_impl_lock (void)
414 {
415   if (gdk_threads_mutex)
416     g_mutex_lock (gdk_threads_mutex);
417 }
418
419 static void
420 gdk_threads_impl_unlock (void)
421 {
422   if (gdk_threads_mutex)
423     g_mutex_unlock (gdk_threads_mutex);
424 }
425
426 /**
427  * gdk_threads_init:
428  * 
429  * Initializes GDK so that it can be used from multiple threads
430  * in conjunction with gdk_threads_enter() and gdk_threads_leave().
431  * g_thread_init() must be called previous to this function.
432  *
433  * This call must be made before any use of the main loop from
434  * GTK+; to be safe, call it before gtk_init().
435  **/
436 void
437 gdk_threads_init (void)
438 {
439   if (!g_thread_supported ())
440     g_error ("g_thread_init() must be called before gdk_threads_init()");
441
442   gdk_threads_mutex = g_mutex_new ();
443   if (!gdk_threads_lock)
444     gdk_threads_lock = gdk_threads_impl_lock;
445   if (!gdk_threads_unlock)
446     gdk_threads_unlock = gdk_threads_impl_unlock;
447 }
448
449 /**
450  * gdk_threads_set_lock_functions:
451  * @enter_fn:   function called to guard GDK
452  * @leave_fn: function called to release the guard
453  *
454  * Allows the application to replace the standard method that
455  * GDK uses to protect its data structures. Normally, GDK
456  * creates a single #GMutex that is locked by gdk_threads_enter(),
457  * and released by gdk_threads_leave(); using this function an
458  * application provides, instead, a function @enter_fn that is
459  * called by gdk_threads_enter() and a function @leave_fn that is
460  * called by gdk_threads_leave().
461  *
462  * The functions must provide at least same locking functionality
463  * as the default implementation, but can also do extra application
464  * specific processing.
465  *
466  * As an example, consider an application that has its own recursive
467  * lock that when held, holds the GTK+ lock as well. When GTK+ unlocks
468  * the GTK+ lock when entering a recursive main loop, the application
469  * must temporarily release its lock as well.
470  *
471  * Most threaded GTK+ apps won't need to use this method.
472  *
473  * This method must be called before gdk_threads_init(), and cannot
474  * be called multiple times.
475  *
476  * Since: 2.4
477  **/
478 void
479 gdk_threads_set_lock_functions (GCallback enter_fn,
480                                 GCallback leave_fn)
481 {
482   g_return_if_fail (gdk_threads_lock == NULL &&
483                     gdk_threads_unlock == NULL);
484
485   gdk_threads_lock = enter_fn;
486   gdk_threads_unlock = leave_fn;
487 }
488
489 static gboolean
490 gdk_threads_dispatch (gpointer data)
491 {
492   GdkThreadsDispatch *dispatch = data;
493   gboolean ret = FALSE;
494
495   GDK_THREADS_ENTER ();
496
497   if (!g_source_is_destroyed (g_main_current_source ()))
498     ret = dispatch->func (dispatch->data);
499
500   GDK_THREADS_LEAVE ();
501
502   return ret;
503 }
504
505 static void
506 gdk_threads_dispatch_free (gpointer data)
507 {
508   GdkThreadsDispatch *dispatch = data;
509
510   if (dispatch->destroy && dispatch->data)
511     dispatch->destroy (dispatch->data);
512
513   g_slice_free (GdkThreadsDispatch, data);
514 }
515
516
517 /**
518  * gdk_threads_add_idle_full:
519  * @priority: the priority of the idle source. Typically this will be in the
520  *            range btweeen #G_PRIORITY_DEFAULT_IDLE and #G_PRIORITY_HIGH_IDLE
521  * @function: function to call
522  * @data:     data to pass to @function
523  * @notify:   function to call when the idle is removed, or %NULL
524  *
525  * Adds a function to be called whenever there are no higher priority
526  * events pending.  If the function returns %FALSE it is automatically
527  * removed from the list of event sources and will not be called again.
528  *
529  * This variant of g_idle_add_full() calls @function with the GDK lock
530  * held. It can be thought of a MT-safe version for GTK+ widgets for the 
531  * following use case, where you have to worry about idle_callback()
532  * running in thread A and accessing @self after it has been finalized
533  * in thread B:
534  *
535  * |[
536  * static gboolean
537  * idle_callback (gpointer data)
538  * {
539  *    /&ast; gdk_threads_enter(); would be needed for g_idle_add() &ast;/
540  *
541  *    SomeWidget *self = data;
542  *    /&ast; do stuff with self &ast;/
543  *
544  *    self->idle_id = 0;
545  *
546  *    /&ast; gdk_threads_leave(); would be needed for g_idle_add() &ast;/
547  *    return FALSE;
548  * }
549  *
550  * static void
551  * some_widget_do_stuff_later (SomeWidget *self)
552  * {
553  *    self->idle_id = gdk_threads_add_idle (idle_callback, self)
554  *    /&ast; using g_idle_add() here would require thread protection in the callback &ast;/
555  * }
556  *
557  * static void
558  * some_widget_finalize (GObject *object)
559  * {
560  *    SomeWidget *self = SOME_WIDGET (object);
561  *    if (self->idle_id)
562  *      g_source_remove (self->idle_id);
563  *    G_OBJECT_CLASS (parent_class)->finalize (object);
564  * }
565  * ]|
566  *
567  * Return value: the ID (greater than 0) of the event source.
568  *
569  * Since: 2.12
570  */
571 guint
572 gdk_threads_add_idle_full (gint           priority,
573                            GSourceFunc    function,
574                            gpointer       data,
575                            GDestroyNotify notify)
576 {
577   GdkThreadsDispatch *dispatch;
578
579   g_return_val_if_fail (function != NULL, 0);
580
581   dispatch = g_slice_new (GdkThreadsDispatch);
582   dispatch->func = function;
583   dispatch->data = data;
584   dispatch->destroy = notify;
585
586   return g_idle_add_full (priority,
587                           gdk_threads_dispatch,
588                           dispatch,
589                           gdk_threads_dispatch_free);
590 }
591
592 /**
593  * gdk_threads_add_idle:
594  * @function: function to call
595  * @data:     data to pass to @function
596  *
597  * A wrapper for the common usage of gdk_threads_add_idle_full() 
598  * assigning the default priority, #G_PRIORITY_DEFAULT_IDLE.
599  *
600  * See gdk_threads_add_idle_full().
601  *
602  * Return value: the ID (greater than 0) of the event source.
603  * 
604  * Since: 2.12
605  */
606 guint
607 gdk_threads_add_idle (GSourceFunc    function,
608                       gpointer       data)
609 {
610   return gdk_threads_add_idle_full (G_PRIORITY_DEFAULT_IDLE,
611                                     function, data, NULL);
612 }
613
614
615 /**
616  * gdk_threads_add_timeout_full:
617  * @priority: the priority of the timeout source. Typically this will be in the
618  *            range between #G_PRIORITY_DEFAULT_IDLE and #G_PRIORITY_HIGH_IDLE.
619  * @interval: the time between calls to the function, in milliseconds
620  *             (1/1000ths of a second)
621  * @function: function to call
622  * @data:     data to pass to @function
623  * @notify:   function to call when the timeout is removed, or %NULL
624  *
625  * Sets a function to be called at regular intervals holding the GDK lock,
626  * with the given priority.  The function is called repeatedly until it 
627  * returns %FALSE, at which point the timeout is automatically destroyed 
628  * and the function will not be called again.  The @notify function is
629  * called when the timeout is destroyed.  The first call to the
630  * function will be at the end of the first @interval.
631  *
632  * Note that timeout functions may be delayed, due to the processing of other
633  * event sources. Thus they should not be relied on for precise timing.
634  * After each call to the timeout function, the time of the next
635  * timeout is recalculated based on the current time and the given interval
636  * (it does not try to 'catch up' time lost in delays).
637  *
638  * This variant of g_timeout_add_full() can be thought of a MT-safe version 
639  * for GTK+ widgets for the following use case:
640  *
641  * |[
642  * static gboolean timeout_callback (gpointer data)
643  * {
644  *    SomeWidget *self = data;
645  *    
646  *    /&ast; do stuff with self &ast;/
647  *    
648  *    self->timeout_id = 0;
649  *    
650  *    return FALSE;
651  * }
652  *  
653  * static void some_widget_do_stuff_later (SomeWidget *self)
654  * {
655  *    self->timeout_id = g_timeout_add (timeout_callback, self)
656  * }
657  *  
658  * static void some_widget_finalize (GObject *object)
659  * {
660  *    SomeWidget *self = SOME_WIDGET (object);
661  *    
662  *    if (self->timeout_id)
663  *      g_source_remove (self->timeout_id);
664  *    
665  *    G_OBJECT_CLASS (parent_class)->finalize (object);
666  * }
667  * ]|
668  *
669  * Return value: the ID (greater than 0) of the event source.
670  * 
671  * Since: 2.12
672  */
673 guint
674 gdk_threads_add_timeout_full (gint           priority,
675                               guint          interval,
676                               GSourceFunc    function,
677                               gpointer       data,
678                               GDestroyNotify notify)
679 {
680   GdkThreadsDispatch *dispatch;
681
682   g_return_val_if_fail (function != NULL, 0);
683
684   dispatch = g_slice_new (GdkThreadsDispatch);
685   dispatch->func = function;
686   dispatch->data = data;
687   dispatch->destroy = notify;
688
689   return g_timeout_add_full (priority, 
690                              interval,
691                              gdk_threads_dispatch, 
692                              dispatch, 
693                              gdk_threads_dispatch_free);
694 }
695
696 /**
697  * gdk_threads_add_timeout:
698  * @interval: the time between calls to the function, in milliseconds
699  *             (1/1000ths of a second)
700  * @function: function to call
701  * @data:     data to pass to @function
702  *
703  * A wrapper for the common usage of gdk_threads_add_timeout_full() 
704  * assigning the default priority, #G_PRIORITY_DEFAULT.
705  *
706  * See gdk_threads_add_timeout_full().
707  * 
708  * Return value: the ID (greater than 0) of the event source.
709  *
710  * Since: 2.12
711  */
712 guint
713 gdk_threads_add_timeout (guint       interval,
714                          GSourceFunc function,
715                          gpointer    data)
716 {
717   return gdk_threads_add_timeout_full (G_PRIORITY_DEFAULT,
718                                        interval, function, data, NULL);
719 }
720
721
722 /**
723  * gdk_threads_add_timeout_seconds_full:
724  * @priority: the priority of the timeout source. Typically this will be in the
725  *            range between #G_PRIORITY_DEFAULT_IDLE and #G_PRIORITY_HIGH_IDLE.
726  * @interval: the time between calls to the function, in seconds
727  * @function: function to call
728  * @data:     data to pass to @function
729  * @notify:   function to call when the timeout is removed, or %NULL
730  *
731  * A variant of gdk_threads_add_timout_full() with second-granularity.
732  * See g_timeout_add_seconds_full() for a discussion of why it is
733  * a good idea to use this function if you don't need finer granularity.
734  *
735  *  Return value: the ID (greater than 0) of the event source.
736  * 
737  * Since: 2.14
738  */
739 guint
740 gdk_threads_add_timeout_seconds_full (gint           priority,
741                                       guint          interval,
742                                       GSourceFunc    function,
743                                       gpointer       data,
744                                       GDestroyNotify notify)
745 {
746   GdkThreadsDispatch *dispatch;
747
748   g_return_val_if_fail (function != NULL, 0);
749
750   dispatch = g_slice_new (GdkThreadsDispatch);
751   dispatch->func = function;
752   dispatch->data = data;
753   dispatch->destroy = notify;
754
755   return g_timeout_add_seconds_full (priority, 
756                                      interval,
757                                      gdk_threads_dispatch, 
758                                      dispatch, 
759                                      gdk_threads_dispatch_free);
760 }
761
762 /**
763  * gdk_threads_add_timeout_seconds:
764  * @interval: the time between calls to the function, in seconds
765  * @function: function to call
766  * @data:     data to pass to @function
767  *
768  * A wrapper for the common usage of gdk_threads_add_timeout_seconds_full() 
769  * assigning the default priority, #G_PRIORITY_DEFAULT.
770  *
771  * For details, see gdk_threads_add_timeout_full().
772  * 
773  * Return value: the ID (greater than 0) of the event source.
774  *
775  * Since: 2.14
776  */
777 guint
778 gdk_threads_add_timeout_seconds (guint       interval,
779                                  GSourceFunc function,
780                                  gpointer    data)
781 {
782   return gdk_threads_add_timeout_seconds_full (G_PRIORITY_DEFAULT,
783                                                interval, function, data, NULL);
784 }
785
786
787 G_CONST_RETURN char *
788 gdk_get_program_class (void)
789 {
790   return gdk_progclass;
791 }
792
793 void
794 gdk_set_program_class (const char *program_class)
795 {
796   g_free (gdk_progclass);
797
798   gdk_progclass = g_strdup (program_class);
799 }
800
801 #define __GDK_C__
802 #include "gdkaliasdef.c"