1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
/*
* Copyright (C) 2010-2011 Robert Ancell.
* Author: Robert Ancell <robert.ancell@canonical.com>
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version. See http://www.gnu.org/copyleft/gpl.html the full text of the
* license.
*/
#include <config.h>
#include "display-server.h"
enum {
READY,
STOPPED,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0 };
struct DisplayServerPrivate
{
/* Unique name for this display server */
gchar *name;
/* TRUE if sessions should be automatically started on this display server */
gboolean start_local_sessions;
};
G_DEFINE_TYPE (DisplayServer, display_server, G_TYPE_OBJECT);
void
display_server_set_name (DisplayServer *server, const gchar *name)
{
g_return_if_fail (server != NULL);
g_free (server->priv->name);
server->priv->name = g_strdup (name);
}
const gchar *
display_server_get_name (DisplayServer *server)
{
g_return_val_if_fail (server != NULL, NULL);
return server->priv->name;
}
void
display_server_set_start_local_sessions (DisplayServer *server, gboolean start_local_sessions)
{
g_return_if_fail (server != NULL);
server->priv->start_local_sessions = start_local_sessions;
}
gboolean
display_server_get_start_local_sessions (DisplayServer *server)
{
g_return_val_if_fail (server != NULL, FALSE);
return server->priv->start_local_sessions;
}
gboolean
display_server_start (DisplayServer *server)
{
g_return_val_if_fail (server != NULL, FALSE);
return DISPLAY_SERVER_GET_CLASS (server)->start (server);
}
static gboolean
display_server_real_start (DisplayServer *server)
{
g_signal_emit (server, signals[READY], 0);
return TRUE;
}
void
display_server_stop (DisplayServer *server)
{
g_return_if_fail (server != NULL);
DISPLAY_SERVER_GET_CLASS (server)->stop (server);
}
static void
display_server_real_stop (DisplayServer *server)
{
g_signal_emit (server, signals[STOPPED], 0);
}
static void
display_server_init (DisplayServer *server)
{
server->priv = G_TYPE_INSTANCE_GET_PRIVATE (server, DISPLAY_SERVER_TYPE, DisplayServerPrivate);
server->priv->start_local_sessions = TRUE;
}
static void
display_server_class_init (DisplayServerClass *klass)
{
klass->start = display_server_real_start;
klass->stop = display_server_real_stop;
g_type_class_add_private (klass, sizeof (DisplayServerPrivate));
signals[READY] =
g_signal_new ("ready",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (DisplayServerClass, ready),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
signals[STOPPED] =
g_signal_new ("stopped",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (DisplayServerClass, stopped),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
}
|