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/.
30 #include "gdkdisplay.h"
31 #include "gdkdisplaymanager.h"
33 #include "gdkinternals.h"
34 #include "gdkmarshalers.h"
38 struct _GdkDisplayManager
40 GObject parent_instance;
54 static void gdk_display_manager_class_init (GdkDisplayManagerClass *klass);
55 static void gdk_display_manager_set_property (GObject *object,
59 static void gdk_display_manager_get_property (GObject *object,
64 static guint signals[LAST_SIGNAL] = { 0 };
66 static GdkDisplay *default_display = NULL;
69 gdk_display_manager_get_type (void)
71 static GType object_type = 0;
75 static const GTypeInfo object_info =
77 sizeof (GdkDisplayManagerClass),
79 (GBaseFinalizeFunc) NULL,
80 (GClassInitFunc) gdk_display_manager_class_init,
81 NULL, /* class_finalize */
82 NULL, /* class_data */
83 sizeof (GdkDisplayManager),
85 (GInstanceInitFunc) NULL,
88 object_type = g_type_register_static (G_TYPE_OBJECT,
97 gdk_display_manager_class_init (GdkDisplayManagerClass *klass)
99 GObjectClass *object_class = G_OBJECT_CLASS (klass);
101 object_class->set_property = gdk_display_manager_set_property;
102 object_class->get_property = gdk_display_manager_get_property;
105 * GdkDisplayManager::display-opened:
106 * @display_manager: the object on which the signal is emitted
107 * @display: the opened display
109 * The ::display_opened signal is emitted when a display is opened.
113 signals[DISPLAY_OPENED] =
114 g_signal_new ("display_opened",
115 G_OBJECT_CLASS_TYPE (object_class),
117 G_STRUCT_OFFSET (GdkDisplayManagerClass, display_opened),
119 gdk_marshal_VOID__OBJECT,
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"),
134 gdk_display_manager_set_property (GObject *object,
141 case PROP_DEFAULT_DISPLAY:
142 default_display = g_value_get_object (value);
145 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
151 gdk_display_manager_get_property (GObject *object,
158 case PROP_DEFAULT_DISPLAY:
159 g_value_set_object (value, default_display);
162 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
168 * gdk_display_manager_get:
169 * @returns: the singleton #GdkDisplayManager object.
171 * Returns the global #GdkDisplayManager singleton; gdk_parse_pargs(),
172 * gdk_init(), or gdk_init_check() must have been called first.
177 gdk_display_manager_get (void)
179 static GdkDisplayManager *display_manager = NULL;
181 if (!display_manager)
182 display_manager = g_object_new (GDK_TYPE_DISPLAY_MANAGER, NULL);
184 return display_manager;
188 * gdk_display_manager_get_default_display:
189 * @display_manager: a #GdkDisplayManager
191 * Gets the default #GdkDisplay.
193 * Returns: a #GdkDisplay, or %NULL if there is no default
199 gdk_display_manager_get_default_display (GdkDisplayManager *display_manager)
201 return default_display;
205 * gdk_display_get_default:
207 * Gets the default #GdkDisplay. This is a convenience
210 * gdk_display_manager_get_default_display (gdk_display_manager_get ())
213 * Returns: a #GdkDisplay, or %NULL if there is no default
219 gdk_display_get_default (void)
221 return default_display;
225 * gdk_screen_get_default:
227 * Gets the default screen for the default display. (See
228 * gdk_display_get_default ()).
230 * Returns: a #GdkScreen, or %NULL if there is no default display.
235 gdk_screen_get_default (void)
238 return gdk_display_get_default_screen (default_display);
244 * gdk_display_manager_set_default_display:
245 * @display_manager: a #GdkDisplayManager
246 * @display: a #GdkDisplay
248 * Sets @display as the default display.
253 gdk_display_manager_set_default_display (GdkDisplayManager *display_manager,
256 default_display = display;
258 _gdk_windowing_set_default_display (display);
260 g_object_notify (G_OBJECT (display_manager), "default_display");
264 * gdk_display_manager_list_displays:
265 * @display_manager: a #GdkDisplayManager
267 * List all currently open displays.
269 * Return value: a newly allocated #GSList of #GdkDisplay objects.
270 * Free this list with g_slist_free() when you are done with it.
275 gdk_display_manager_list_displays (GdkDisplayManager *display_manager)
277 return g_slist_copy (_gdk_displays);