Mercurial > projects > xwrited
annotate xwrited-unique.c @ 7:6f325e8e27f3 version-1
Add missing prototype
author | Guido Berhoerster <guido+xwrited@berhoerster.name> |
---|---|
date | Thu, 26 Jun 2014 13:00:26 +0200 |
parents | c53bcdabbba7 |
children | 4a5330979433 |
rev | line source |
---|---|
0
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
1 /* |
2
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
2 * Copyright (C) 2014 Guido Berhoerster <guido+xwrited@berhoerster.name> |
0
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
3 * |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
4 * Permission is hereby granted, free of charge, to any person obtaining |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
5 * a copy of this software and associated documentation files (the |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
6 * "Software"), to deal in the Software without restriction, including |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
7 * without limitation the rights to use, copy, modify, merge, publish, |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
8 * distribute, sublicense, and/or sell copies of the Software, and to |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
9 * permit persons to whom the Software is furnished to do so, subject to |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
10 * the following conditions: |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
11 * |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
12 * The above copyright notice and this permission notice shall be included |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
13 * in all copies or substantial portions of the Software. |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
14 * |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
22 */ |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
23 |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
24 #define _XOPEN_SOURCE 600 |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
25 |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
26 #include <glib.h> |
2
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
27 #ifdef HAVE_GLIB_GDBUS |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
28 #include <gio/gio.h> |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
29 #else |
0
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
30 #include <dbus/dbus-glib.h> |
2
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
31 #endif /* HAVE_GLIB_GDBUS */ |
0
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
32 #include <dbus/dbus.h> |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
33 |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
34 #include "xwrited-unique.h" |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
35 |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
36 G_DEFINE_TYPE(XWritedUnique, xwrited_unique, G_TYPE_OBJECT) |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
37 |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
38 #define XWRITED_UNIQUE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), \ |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
39 XWRITED_TYPE_UNIQUE, XWritedUniquePrivate)) |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
40 |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
41 struct _XWritedUniquePrivate { |
2
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
42 #ifdef HAVE_GLIB_GDBUS |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
43 GDBusProxy *session_bus_proxy; |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
44 #else |
0
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
45 DBusGConnection *session_bus; |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
46 DBusGProxy *session_bus_proxy; |
2
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
47 #endif /* HAVE_GLIB_GDBUS */ |
0
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
48 gchar *name; |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
49 gboolean is_unique; |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
50 }; |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
51 |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
52 enum { |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
53 PROP_0, |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
54 PROP_NAME, |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
55 PROP_IS_XWRITED_UNIQUE |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
56 }; |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
57 |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
58 static gboolean |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
59 request_name(XWritedUnique *self) |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
60 { |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
61 guint32 request_name_response; |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
62 GError *error = NULL; |
2
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
63 #ifdef HAVE_GLIB_GDBUS |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
64 GVariant *result; |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
65 |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
66 g_return_val_if_fail(self->priv->session_bus_proxy != NULL, FALSE); |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
67 |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
68 result = g_dbus_proxy_call_sync(self->priv->session_bus_proxy, |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
69 "RequestName", g_variant_new("(su)", self->priv->name, |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
70 DBUS_NAME_FLAG_DO_NOT_QUEUE), G_DBUS_CALL_FLAGS_NONE, -1, NULL, |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
71 &error); |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
72 if (result == NULL) { |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
73 g_warning("failed to acquire service name \"%s\": %s", |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
74 self->priv->name, error->message); |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
75 g_error_free(error); |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
76 return (FALSE); |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
77 } |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
78 |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
79 g_variant_get(result, "(u)", &request_name_response); |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
80 g_variant_unref(result); |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
81 #else |
0
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
82 |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
83 g_return_val_if_fail(self->priv->session_bus != NULL, FALSE); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
84 g_return_val_if_fail(self->priv->session_bus_proxy != NULL, FALSE); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
85 if (dbus_g_proxy_call(self->priv->session_bus_proxy, "RequestName", |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
86 &error, G_TYPE_STRING, self->priv->name, G_TYPE_UINT, |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
87 DBUS_NAME_FLAG_DO_NOT_QUEUE, G_TYPE_INVALID, G_TYPE_UINT, |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
88 &request_name_response, G_TYPE_INVALID) == 0) { |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
89 g_warning("failed to acquire service name \"%s\": %s", |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
90 self->priv->name, error->message); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
91 g_error_free(error); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
92 return (FALSE); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
93 } |
2
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
94 #endif /* HAVE_GLIB_GDBUS */ |
0
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
95 |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
96 switch (request_name_response) { |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
97 case DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER: |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
98 return (TRUE); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
99 case DBUS_REQUEST_NAME_REPLY_EXISTS: |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
100 break; |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
101 default: |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
102 g_warning("failed to acquire service name \"%s\"", |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
103 self->priv->name); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
104 } |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
105 |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
106 return (FALSE); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
107 } |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
108 |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
109 static void |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
110 xwrited_unique_get_property(GObject *gobject, guint property_id, GValue *value, |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
111 GParamSpec *pspec) |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
112 { |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
113 XWritedUnique *app = XWRITED_UNIQUE(gobject); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
114 |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
115 switch (property_id) { |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
116 case PROP_NAME: |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
117 g_value_set_string(value, app->priv->name); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
118 break; |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
119 case PROP_IS_XWRITED_UNIQUE: |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
120 g_value_set_boolean(value, app->priv->is_unique); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
121 break; |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
122 default: |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
123 G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, property_id, |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
124 pspec); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
125 } |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
126 } |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
127 |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
128 static void |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
129 xwrited_unique_set_property(GObject *gobject, guint property_id, |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
130 const GValue *value, GParamSpec *pspec) |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
131 { |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
132 XWritedUnique *app = XWRITED_UNIQUE(gobject); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
133 |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
134 switch (property_id) { |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
135 case PROP_NAME: |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
136 app->priv->name = g_strdup(g_value_get_string(value)); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
137 break; |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
138 default: |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
139 G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, property_id, |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
140 pspec); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
141 } |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
142 } |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
143 |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
144 static GObject * |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
145 xwrited_unique_constructor(GType gtype, guint n_params, |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
146 GObjectConstructParam *params) |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
147 { |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
148 GObjectClass *parent_class; |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
149 GObject *gobject; |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
150 XWritedUnique *app; |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
151 GError *error = NULL; |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
152 |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
153 parent_class = G_OBJECT_CLASS(xwrited_unique_parent_class); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
154 gobject = parent_class->constructor(gtype, n_params, params); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
155 app = XWRITED_UNIQUE(gobject); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
156 |
2
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
157 #ifdef HAVE_GLIB_GDBUS |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
158 app->priv->session_bus_proxy = |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
159 g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SESSION, |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
160 G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
161 G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, NULL, DBUS_SERVICE_DBUS, |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
162 DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS, NULL, &error); |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
163 if (app->priv->session_bus_proxy == NULL) { |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
164 g_warning("failed to create DBus proxy: %s", error->message); |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
165 g_error_free(error); |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
166 goto out; |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
167 } |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
168 #else |
0
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
169 app->priv->session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
170 if (app->priv->session_bus == NULL) { |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
171 g_warning("failed to connect to DBus session bus: %s", |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
172 error->message); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
173 g_error_free(error); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
174 goto out; |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
175 } |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
176 |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
177 app->priv->session_bus_proxy = |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
178 dbus_g_proxy_new_for_name(app->priv->session_bus, |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
179 DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
180 if (app->priv->session_bus_proxy == NULL) { |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
181 g_warning("failed to create DBus proxy"); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
182 goto out; |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
183 } |
2
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
184 #endif /* HAVE_GLIB_GDBUS */ |
0
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
185 |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
186 if (request_name(app)) { |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
187 app->priv->is_unique = TRUE; |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
188 } |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
189 |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
190 out: |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
191 return (gobject); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
192 } |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
193 |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
194 static void |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
195 xwrited_unique_dispose(GObject *gobject) |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
196 { |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
197 XWritedUnique *self = XWRITED_UNIQUE(gobject); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
198 |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
199 if (self->priv->session_bus_proxy != NULL) { |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
200 g_object_unref(self->priv->session_bus_proxy); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
201 self->priv->session_bus_proxy = NULL; |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
202 } |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
203 |
2
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
204 #ifndef HAVE_GLIB_GDBUS |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
205 if (self->priv->session_bus != NULL) { |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
206 dbus_g_connection_unref(self->priv->session_bus); |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
207 self->priv->session_bus = NULL; |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
208 } |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
209 |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
210 #endif /* !HAVE_GLIB_GDBUS */ |
0
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
211 G_OBJECT_CLASS(xwrited_unique_parent_class)->dispose(gobject); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
212 } |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
213 |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
214 static void |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
215 xwrited_unique_finalize(GObject *gobject) |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
216 { |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
217 XWritedUnique *self = XWRITED_UNIQUE(gobject); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
218 |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
219 g_free(self->priv->name); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
220 |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
221 G_OBJECT_CLASS(xwrited_unique_parent_class)->finalize(gobject); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
222 } |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
223 |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
224 static void |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
225 xwrited_unique_class_init(XWritedUniqueClass *klass) |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
226 { |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
227 GObjectClass *gobject_class = G_OBJECT_CLASS(klass); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
228 GParamSpec *pspec; |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
229 |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
230 gobject_class->constructor = xwrited_unique_constructor; |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
231 gobject_class->get_property = xwrited_unique_get_property; |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
232 gobject_class->set_property = xwrited_unique_set_property; |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
233 gobject_class->dispose = xwrited_unique_dispose; |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
234 gobject_class->finalize = xwrited_unique_finalize; |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
235 |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
236 pspec = g_param_spec_string("name", "Name", |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
237 "The unique name of the application", NULL, G_PARAM_READABLE | |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
238 G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_NAME | |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
239 G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
240 g_object_class_install_property(gobject_class, PROP_NAME, pspec); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
241 |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
242 pspec = g_param_spec_boolean("is-unique", "Is unique", |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
243 "Whether the current application instance is unique", FALSE, |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
244 G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
245 G_PARAM_STATIC_BLURB); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
246 g_object_class_install_property(gobject_class, PROP_IS_XWRITED_UNIQUE, |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
247 pspec); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
248 |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
249 g_type_class_add_private(klass, sizeof (XWritedUniquePrivate)); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
250 } |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
251 |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
252 static void |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
253 xwrited_unique_init(XWritedUnique *self) |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
254 { |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
255 self->priv = XWRITED_UNIQUE_GET_PRIVATE(self); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
256 |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
257 self->priv->is_unique = FALSE; |
2
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
258 #ifndef HAVE_GLIB_GDBUS |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
259 self->priv->session_bus = NULL; |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
260 #endif /* !HAVE_GLIB_GDBUS */ |
0
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
261 self->priv->session_bus_proxy = NULL; |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
262 } |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
263 |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
264 XWritedUnique * |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
265 xwrited_unique_new(const gchar *name) |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
266 { |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
267 XWritedUnique *app; |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
268 |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
269 g_return_val_if_fail(name != NULL, NULL); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
270 |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
271 app = g_object_new(XWRITED_TYPE_UNIQUE, "name", name, NULL); |
2
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
272 if ( |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
273 #ifndef HAVE_GLIB_GDBUS |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
274 app->priv->session_bus == NULL || |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
275 #endif /* !HAVE_GLIB_GDBUS */ |
c53bcdabbba7
Make use of GDBus for glib >= 2.25.5
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
0
diff
changeset
|
276 app->priv->session_bus_proxy == NULL) { |
0
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
277 g_object_unref(app); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
278 return (NULL); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
279 } |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
280 |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
281 return (app); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
282 } |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
283 |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
284 gboolean |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
285 xwrited_unique_is_unique(XWritedUnique *self) |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
286 { |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
287 g_return_val_if_fail(XWRITED_IS_UNIQUE(self), FALSE); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
288 |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
289 return (self->priv->is_unique); |
52694b49dcc4
Initial revision
Guido Berhoerster <guido+xwrited@berhoerster.name>
parents:
diff
changeset
|
290 } |