1 /* GDK - The GIMP Drawing Kit
2 * Copyright (C) 2000 Red Hat, Inc.
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.
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.
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.
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/.
29 #include "gdkdisplay.h"
30 #include "gdkdisplaymanager.h"
32 #include "gdkinternals.h"
33 #include "gdkmarshalers.h"
37 struct _GdkDisplayManager
39 GObject parent_instance;
53 static void gdk_display_manager_class_init (GdkDisplayManagerClass *klass);
54 static void gdk_display_manager_set_property (GObject *object,
58 static void gdk_display_manager_get_property (GObject *object,
63 static guint signals[LAST_SIGNAL] = { 0 };
65 static GdkDisplay *default_display = NULL;
68 gdk_display_manager_get_type (void)
70 static GType object_type = 0;
74 static const GTypeInfo object_info =
76 sizeof (GdkDisplayManagerClass),
78 (GBaseFinalizeFunc) NULL,
79 (GClassInitFunc) gdk_display_manager_class_init,
80 NULL, /* class_finalize */
81 NULL, /* class_data */
82 sizeof (GdkDisplayManager),
84 (GInstanceInitFunc) NULL,
87 object_type = g_type_register_static (G_TYPE_OBJECT,
96 gdk_display_manager_class_init (GdkDisplayManagerClass *klass)
98 GObjectClass *object_class = G_OBJECT_CLASS (klass);
100 object_class->set_property = gdk_display_manager_set_property;
101 object_class->get_property = gdk_display_manager_get_property;
104 * GdkDisplayManager::display-opened:
105 * @display_manager: the object on which the signal is emitted
106 * @display: the opened display
108 * The ::display_opened signal is emitted when a display is opened.
112 signals[DISPLAY_OPENED] =
113 g_signal_new ("display_opened",
114 G_OBJECT_CLASS_TYPE (object_class),
116 G_STRUCT_OFFSET (GdkDisplayManagerClass, display_opened),
118 gdk_marshal_VOID__OBJECT,
123 g_object_class_install_property (object_class,
124 PROP_DEFAULT_DISPLAY,
125 g_param_spec_object ("default-display",
126 _("Default Display"),
127 _("The default display for GDK"),
133 gdk_display_manager_set_property (GObject *object,
140 case PROP_DEFAULT_DISPLAY:
141 default_display = g_value_get_object (value);
144 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
150 gdk_display_manager_get_property (GObject *object,
157 case PROP_DEFAULT_DISPLAY:
158 g_value_set_object (value, default_display);
161 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
167 * gdk_display_manager_get:
168 * @returns: the singleton #GdkDisplayManager object.
170 * Returns the global #GdkDisplayManager singleton; gdk_parse_pargs(),
171 * gdk_init(), or gdk_init_check() must have been called first.
176 gdk_display_manager_get (void)
178 static GdkDisplayManager *display_manager = NULL;
180 if (!display_manager)
181 display_manager = g_object_new (GDK_TYPE_DISPLAY_MANAGER, NULL);
183 return display_manager;
187 * gdk_display_manager_get_default_display:
188 * @display_manager: a #GdkDisplayManager
190 * Gets the default #GdkDisplay.
192 * Returns: a #GdkDisplay, or %NULL if there is no default
198 gdk_display_manager_get_default_display (GdkDisplayManager *display_manager)
200 return default_display;
204 * gdk_display_get_default:
206 * Gets the default #GdkDisplay. This is a convenience
209 * gdk_display_manager_get_default_display (gdk_display_manager_get ())
212 * Returns: a #GdkDisplay, or %NULL if there is no default
218 gdk_display_get_default (void)
220 return default_display;
224 * gdk_screen_get_default:
226 * Gets the default screen for the default display. (See
227 * gdk_display_get_default ()).
229 * Returns: a #GdkScreen, or %NULL if there is no default display.
234 gdk_screen_get_default (void)
237 return gdk_display_get_default_screen (default_display);
243 * gdk_display_manager_set_default_display:
244 * @display_manager: a #GdkDisplayManager
245 * @display: a #GdkDisplay
247 * Sets @display as the default display.
252 gdk_display_manager_set_default_display (GdkDisplayManager *display_manager,
255 default_display = display;
257 _gdk_windowing_set_default_display (display);
259 g_object_notify (G_OBJECT (display_manager), "default_display");
263 * gdk_display_manager_list_displays:
264 * @display_manager: a #GdkDisplayManager
266 * List all currently open displays.
268 * Return value: a newly allocated #GSList of #GdkDisplay objects.
269 * Free this list with g_slist_free() when you are done with it.
274 gdk_display_manager_list_displays (GdkDisplayManager *display_manager)
276 return g_slist_copy (_gdk_displays);