]> Pileus Git - ~andy/gtk/blob - gdk/gdkdisplaymanager.c
Add hidden aliases for exported symbols which are used internally in order
[~andy/gtk] / gdk / gdkdisplaymanager.c
1 /* GDK - The GIMP Drawing Kit
2  * Copyright (C) 2000 Red Hat, Inc.
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 "gdkalias.h"
30 #include "gdkdisplay.h"
31 #include "gdkdisplaymanager.h"
32
33 #include "gdkinternals.h"
34 #include "gdkmarshalers.h"
35
36 #include "gdkintl.h"
37
38 struct _GdkDisplayManager
39 {
40   GObject parent_instance;
41 };
42
43 enum {
44   PROP_0,
45
46   PROP_DEFAULT_DISPLAY
47 };
48
49 enum {
50   DISPLAY_OPENED,
51   LAST_SIGNAL
52 };
53
54 static void gdk_display_manager_class_init   (GdkDisplayManagerClass *klass);
55 static void gdk_display_manager_set_property (GObject                *object,
56                                               guint                   prop_id,
57                                               const GValue           *value,
58                                               GParamSpec             *pspec);
59 static void gdk_display_manager_get_property (GObject                *object,
60                                               guint                   prop_id,
61                                               GValue                 *value,
62                                               GParamSpec             *pspec);
63
64 static guint signals[LAST_SIGNAL] = { 0 };
65
66 static GdkDisplay *default_display = NULL;
67
68 GType
69 gdk_display_manager_get_type (void)
70 {
71   static GType object_type = 0;
72
73   if (!object_type)
74     {
75       static const GTypeInfo object_info =
76       {
77         sizeof (GdkDisplayManagerClass),
78         (GBaseInitFunc) NULL,
79         (GBaseFinalizeFunc) NULL,
80         (GClassInitFunc) gdk_display_manager_class_init,
81         NULL,           /* class_finalize */
82         NULL,           /* class_data */
83         sizeof (GdkDisplayManager),
84         0,              /* n_preallocs */
85         (GInstanceInitFunc) NULL,
86       };
87       
88       object_type = g_type_register_static (G_TYPE_OBJECT,
89                                             "GdkDisplayManager",
90                                             &object_info, 0);
91     }
92   
93   return object_type;
94 }
95
96 static void
97 gdk_display_manager_class_init (GdkDisplayManagerClass *klass)
98 {
99   GObjectClass *object_class = G_OBJECT_CLASS (klass);
100
101   object_class->set_property = gdk_display_manager_set_property;
102   object_class->get_property = gdk_display_manager_get_property;
103
104   /**
105    * GdkDisplayManager::display-opened:
106    * @display_manager: the object on which the signal is emitted
107    * @display: the opened display
108    *
109    * The ::display_opened signal is emitted when a display is opened.
110    *
111    * Since: 2.2
112    */
113   signals[DISPLAY_OPENED] =
114     g_signal_new ("display_opened",
115                   G_OBJECT_CLASS_TYPE (object_class),
116                   G_SIGNAL_RUN_LAST,
117                   G_STRUCT_OFFSET (GdkDisplayManagerClass, display_opened),
118                   NULL, NULL,
119                   gdk_marshal_VOID__OBJECT,
120                   G_TYPE_NONE,
121                   1,
122                   GDK_TYPE_DISPLAY);
123
124   g_object_class_install_property (object_class,
125                                    PROP_DEFAULT_DISPLAY,
126                                    g_param_spec_object ("default-display",
127                                                         P_("Default Display"),
128                                                         P_("The default display for GDK"),
129                                                         GDK_TYPE_DISPLAY,
130                                                         G_PARAM_READWRITE));
131 }
132
133 static void
134 gdk_display_manager_set_property (GObject      *object,
135                                   guint         prop_id,
136                                   const GValue *value,
137                                   GParamSpec   *pspec)
138 {
139   switch (prop_id)
140     {
141     case PROP_DEFAULT_DISPLAY:
142       default_display = g_value_get_object (value);
143       break;
144     default:
145       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
146       break;
147     }
148 }
149
150 static void
151 gdk_display_manager_get_property (GObject      *object,
152                                   guint         prop_id,
153                                   GValue       *value,
154                                   GParamSpec   *pspec)
155 {
156   switch (prop_id)
157     {
158     case PROP_DEFAULT_DISPLAY:
159       g_value_set_object (value, default_display);
160       break;
161     default:
162       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
163       break;
164     }
165 }
166
167 /** 
168  * gdk_display_manager_get:
169  * @returns: the singleton #GdkDisplayManager object.
170  *
171  * Returns the global #GdkDisplayManager singleton; gdk_parse_pargs(),
172  * gdk_init(), or gdk_init_check() must have been called first.
173  *
174  * Since: 2.2
175  **/
176 GdkDisplayManager*
177 gdk_display_manager_get (void)
178 {
179   static GdkDisplayManager *display_manager = NULL;
180
181   if (!display_manager)
182     display_manager = g_object_new (GDK_TYPE_DISPLAY_MANAGER, NULL);
183
184   return display_manager;
185 }
186
187 /**
188  * gdk_display_manager_get_default_display:
189  * @display_manager: a #GdkDisplayManager 
190  *
191  * Gets the default #GdkDisplay. 
192  * 
193  * Returns: a #GdkDisplay, or %NULL if there is no default
194  *   display.
195  *
196  * Since: 2.2
197  */
198 GdkDisplay *
199 gdk_display_manager_get_default_display (GdkDisplayManager *display_manager)
200 {
201   return default_display;
202 }
203
204 /**
205  * gdk_display_get_default:
206  *
207  * Gets the default #GdkDisplay. This is a convenience
208  * function for:
209  * <programlisting>
210  *   gdk_display_manager_get_default_display (gdk_display_manager_get ())
211  * </programlisting>
212  * 
213  * Returns: a #GdkDisplay, or %NULL if there is no default
214  *   display.
215  *
216  * Since: 2.2
217  */
218 GdkDisplay *
219 gdk_display_get_default (void)
220 {
221   return default_display;
222 }
223
224 /**
225  * gdk_screen_get_default:
226  *
227  * Gets the default screen for the default display. (See
228  * gdk_display_get_default ()).
229  * 
230  * Returns: a #GdkScreen, or %NULL if there is no default display.
231  *
232  * Since: 2.2
233  */
234 GdkScreen *
235 gdk_screen_get_default (void)
236 {
237   if (default_display)
238     return gdk_display_get_default_screen (default_display);
239   else
240     return NULL;
241 }
242
243 /**
244  * gdk_display_manager_set_default_display:
245  * @display_manager: a #GdkDisplayManager
246  * @display: a #GdkDisplay
247  * 
248  * Sets @display as the default display.
249  *
250  * Since: 2.2
251  **/
252 void
253 gdk_display_manager_set_default_display (GdkDisplayManager *display_manager,
254                                          GdkDisplay        *display)
255 {
256   default_display = display;
257
258   _gdk_windowing_set_default_display (display);
259
260   g_object_notify (G_OBJECT (display_manager), "default_display");
261 }
262
263 /**
264  * gdk_display_manager_list_displays:
265  * @display_manager: a #GdkDisplayManager 
266  *
267  * List all currently open displays.
268  * 
269  * Return value: a newly allocated #GSList of #GdkDisplay objects.
270  *  Free this list with g_slist_free() when you are done with it.
271  *
272  * Since: 2.2
273  **/
274 GSList *
275 gdk_display_manager_list_displays (GdkDisplayManager *display_manager)
276 {
277   return g_slist_copy (_gdk_displays);
278 }
279