Line |
Branch |
Exec |
Source |
1 |
|
|
/* |
2 |
|
|
* Copyright (C) 2014 Bastien Nocera <hadess@hadess.net> |
3 |
|
|
* |
4 |
|
|
* This program is free software; you can redistribute it and/or modify |
5 |
|
|
* it under the terms of the GNU General Public License as published by |
6 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
7 |
|
|
* (at your option) any later version. |
8 |
|
|
* |
9 |
|
|
* This program 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 |
12 |
|
|
* GNU General Public License for more details. |
13 |
|
|
* |
14 |
|
|
* You should have received a copy of the GNU General Public License |
15 |
|
|
* along with this program; if not, write to the Free Software |
16 |
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
17 |
|
|
* |
18 |
|
|
*/ |
19 |
|
|
|
20 |
|
|
#include "config.h" |
21 |
|
|
|
22 |
|
|
#include <adwaita.h> |
23 |
|
|
#include <gio/gio.h> |
24 |
|
|
#include <glib/gi18n.h> |
25 |
|
|
|
26 |
|
|
#include "cc-sharing-networks.h" |
27 |
|
|
#include "org.gnome.SettingsDaemon.Sharing.h" |
28 |
|
|
#include "gsd-sharing-enums.h" |
29 |
|
|
|
30 |
|
|
struct _CcSharingNetworks { |
31 |
|
|
GtkBox parent_instance; |
32 |
|
|
|
33 |
|
|
GtkWidget *listbox; |
34 |
|
|
|
35 |
|
|
GtkWidget *current_row; |
36 |
|
|
GtkWidget *current_icon; |
37 |
|
|
GtkWidget *current_switch; |
38 |
|
|
|
39 |
|
|
GtkWidget *no_network_row; |
40 |
|
|
|
41 |
|
|
char *service_name; |
42 |
|
|
GsdSharing *proxy; |
43 |
|
|
CcSharingStatus status; |
44 |
|
|
|
45 |
|
|
GList *networks; /* list of CcSharingNetwork */ |
46 |
|
|
}; |
47 |
|
|
|
48 |
|
|
|
49 |
|
✗ |
G_DEFINE_TYPE (CcSharingNetworks, cc_sharing_networks, GTK_TYPE_BOX) |
50 |
|
|
|
51 |
|
|
enum { |
52 |
|
|
PROP_0, |
53 |
|
|
PROP_PROXY, |
54 |
|
|
PROP_SERVICE_NAME, |
55 |
|
|
PROP_STATUS |
56 |
|
|
}; |
57 |
|
|
|
58 |
|
|
static void cc_sharing_networks_class_init (CcSharingNetworksClass *klass); |
59 |
|
|
static void cc_sharing_networks_init (CcSharingNetworks *self); |
60 |
|
|
static void cc_sharing_networks_finalize (GObject *object); |
61 |
|
|
|
62 |
|
|
static void cc_sharing_update_networks_box (CcSharingNetworks *self); |
63 |
|
|
|
64 |
|
|
typedef struct { |
65 |
|
|
char *uuid; |
66 |
|
|
char *network_name; |
67 |
|
|
char *carrier_type; |
68 |
|
|
} CcSharingNetwork; |
69 |
|
|
|
70 |
|
|
static void |
71 |
|
✗ |
cc_sharing_network_free (gpointer data) |
72 |
|
|
{ |
73 |
|
✗ |
CcSharingNetwork *net = data; |
74 |
|
|
|
75 |
|
✗ |
g_free (net->uuid); |
76 |
|
✗ |
g_free (net->network_name); |
77 |
|
✗ |
g_free (net->carrier_type); |
78 |
|
✗ |
g_free (net); |
79 |
|
✗ |
} |
80 |
|
|
|
81 |
|
|
static void |
82 |
|
✗ |
cc_sharing_networks_update_status (CcSharingNetworks *self) |
83 |
|
|
{ |
84 |
|
|
CcSharingStatus status; |
85 |
|
|
|
86 |
|
✗ |
if (self->networks == NULL) |
87 |
|
✗ |
status = CC_SHARING_STATUS_OFF; |
88 |
|
✗ |
else if (gtk_switch_get_active (GTK_SWITCH (self->current_switch))) |
89 |
|
✗ |
status = CC_SHARING_STATUS_ACTIVE; |
90 |
|
|
else |
91 |
|
✗ |
status = CC_SHARING_STATUS_ENABLED; |
92 |
|
|
|
93 |
|
✗ |
if (status != self->status) { |
94 |
|
✗ |
self->status = status; |
95 |
|
✗ |
g_object_notify (G_OBJECT (self), "status"); |
96 |
|
|
} |
97 |
|
✗ |
} |
98 |
|
|
|
99 |
|
|
static void |
100 |
|
✗ |
cc_sharing_update_networks (CcSharingNetworks *self) |
101 |
|
|
{ |
102 |
|
✗ |
g_autoptr(GVariant) networks = NULL; |
103 |
|
|
char *uuid, *network_name, *carrier_type; |
104 |
|
|
GVariantIter iter; |
105 |
|
✗ |
g_autoptr(GError) error = NULL; |
106 |
|
|
|
107 |
|
✗ |
g_list_free_full (self->networks, cc_sharing_network_free); |
108 |
|
✗ |
self->networks = NULL; |
109 |
|
|
|
110 |
|
✗ |
if (!gsd_sharing_call_list_networks_sync (self->proxy, self->service_name, &networks, NULL, &error)) { |
111 |
|
✗ |
g_warning ("couldn't list networks: %s", error->message); |
112 |
|
✗ |
g_dbus_proxy_set_cached_property (G_DBUS_PROXY (self->proxy), |
113 |
|
|
"SharingStatus", |
114 |
|
|
g_variant_new_uint32 (GSD_SHARING_STATUS_OFFLINE)); |
115 |
|
✗ |
return; |
116 |
|
|
} |
117 |
|
|
|
118 |
|
✗ |
g_variant_iter_init (&iter, networks); |
119 |
|
✗ |
while (g_variant_iter_next (&iter, "(sss)", &uuid, &network_name, &carrier_type)) { |
120 |
|
|
CcSharingNetwork *net; |
121 |
|
|
|
122 |
|
✗ |
net = g_new0 (CcSharingNetwork, 1); |
123 |
|
✗ |
net->uuid = uuid; |
124 |
|
✗ |
net->network_name = network_name; |
125 |
|
✗ |
net->carrier_type = carrier_type; |
126 |
|
✗ |
self->networks = g_list_prepend (self->networks, net); |
127 |
|
|
} |
128 |
|
✗ |
self->networks = g_list_reverse (self->networks); |
129 |
|
|
} |
130 |
|
|
|
131 |
|
|
static void |
132 |
|
✗ |
cc_sharing_networks_remove_network (CcSharingNetworks *self, |
133 |
|
|
GtkWidget *button) |
134 |
|
|
{ |
135 |
|
|
GtkWidget *row; |
136 |
|
✗ |
g_autoptr(GError) error = NULL; |
137 |
|
|
gboolean ret; |
138 |
|
|
const char *uuid; |
139 |
|
|
|
140 |
|
✗ |
row = g_object_get_data (G_OBJECT (button), "row"); |
141 |
|
✗ |
uuid = g_object_get_data (G_OBJECT (row), "uuid"); |
142 |
|
|
|
143 |
|
✗ |
ret = gsd_sharing_call_disable_service_sync (self->proxy, |
144 |
|
✗ |
self->service_name, |
145 |
|
|
uuid, |
146 |
|
|
NULL, |
147 |
|
|
&error); |
148 |
|
✗ |
if (!ret) |
149 |
|
✗ |
g_warning ("Failed to remove service %s: %s", |
150 |
|
|
self->service_name, error->message); |
151 |
|
|
|
152 |
|
✗ |
cc_sharing_update_networks (self); |
153 |
|
✗ |
cc_sharing_update_networks_box (self); |
154 |
|
✗ |
} |
155 |
|
|
|
156 |
|
|
static gboolean |
157 |
|
✗ |
cc_sharing_networks_enable_network (CcSharingNetworks *self, |
158 |
|
|
gboolean state, |
159 |
|
|
GtkSwitch *widget) |
160 |
|
|
{ |
161 |
|
✗ |
g_autoptr(GError) error = NULL; |
162 |
|
|
gboolean ret; |
163 |
|
|
|
164 |
|
✗ |
if (state) { |
165 |
|
✗ |
ret = gsd_sharing_call_enable_service_sync (self->proxy, |
166 |
|
✗ |
self->service_name, |
167 |
|
|
NULL, |
168 |
|
|
&error); |
169 |
|
|
} else { |
170 |
|
✗ |
ret = gsd_sharing_call_disable_service_sync (self->proxy, |
171 |
|
✗ |
self->service_name, |
172 |
|
|
gsd_sharing_get_current_network (self->proxy), |
173 |
|
|
NULL, |
174 |
|
|
&error); |
175 |
|
|
} |
176 |
|
|
|
177 |
|
✗ |
if (ret) { |
178 |
|
✗ |
gtk_switch_set_state (widget, state); |
179 |
|
|
} else { |
180 |
|
✗ |
g_warning ("Failed to %s service %s: %s", state ? "enable" : "disable", |
181 |
|
|
self->service_name, error->message); |
182 |
|
✗ |
g_signal_handlers_block_by_func (widget, |
183 |
|
|
cc_sharing_networks_enable_network, self); |
184 |
|
✗ |
gtk_switch_set_active (widget, !state); |
185 |
|
✗ |
g_signal_handlers_unblock_by_func (widget, |
186 |
|
|
cc_sharing_networks_enable_network, self); |
187 |
|
|
} |
188 |
|
|
|
189 |
|
✗ |
cc_sharing_update_networks (self); |
190 |
|
✗ |
cc_sharing_networks_update_status (self); |
191 |
|
|
|
192 |
|
✗ |
return TRUE; |
193 |
|
|
} |
194 |
|
|
|
195 |
|
|
static GtkWidget * |
196 |
|
✗ |
cc_sharing_networks_new_row (const char *uuid, |
197 |
|
|
const char *network_name, |
198 |
|
|
const char *carrier_type, |
199 |
|
|
CcSharingNetworks *self) |
200 |
|
|
{ |
201 |
|
|
GtkWidget *row, *w; |
202 |
|
|
const char *icon_name; |
203 |
|
|
|
204 |
|
✗ |
row = adw_action_row_new (); |
205 |
|
✗ |
adw_preferences_row_set_use_markup (ADW_PREFERENCES_ROW (row), FALSE); |
206 |
|
|
|
207 |
|
✗ |
if (g_strcmp0 (carrier_type, "802-11-wireless") == 0) { |
208 |
|
✗ |
icon_name = "network-wireless-offline-symbolic"; |
209 |
|
✗ |
} else if (g_strcmp0 (carrier_type, "802-3-ethernet") == 0) { |
210 |
|
✗ |
icon_name = "network-wired-disconnected-symbolic"; |
211 |
|
|
} else { |
212 |
|
✗ |
icon_name = "network-wired-symbolic"; |
213 |
|
|
} |
214 |
|
|
|
215 |
|
✗ |
adw_action_row_set_icon_name (ADW_ACTION_ROW (row), icon_name); |
216 |
|
✗ |
adw_preferences_row_set_title (ADW_PREFERENCES_ROW (row), network_name); |
217 |
|
|
|
218 |
|
|
/* Remove button */ |
219 |
|
✗ |
w = gtk_button_new_from_icon_name ("edit-delete-symbolic"); |
220 |
|
✗ |
gtk_widget_add_css_class (w, "flat"); |
221 |
|
✗ |
gtk_widget_set_valign (w, GTK_ALIGN_CENTER); |
222 |
|
✗ |
gtk_accessible_update_property (GTK_ACCESSIBLE (w), |
223 |
|
|
GTK_ACCESSIBLE_PROPERTY_LABEL, _("Remove"), |
224 |
|
|
-1); |
225 |
|
✗ |
adw_action_row_add_suffix (ADW_ACTION_ROW (row), w); |
226 |
|
✗ |
g_signal_connect_object (G_OBJECT (w), "clicked", |
227 |
|
|
G_CALLBACK (cc_sharing_networks_remove_network), self, G_CONNECT_SWAPPED); |
228 |
|
✗ |
g_object_set_data (G_OBJECT (w), "row", row); |
229 |
|
|
|
230 |
|
✗ |
g_object_set_data_full (G_OBJECT (row), "uuid", g_strdup (uuid), g_free); |
231 |
|
|
|
232 |
|
✗ |
return row; |
233 |
|
|
} |
234 |
|
|
|
235 |
|
|
static GtkWidget * |
236 |
|
✗ |
cc_sharing_networks_new_current_row (CcSharingNetworks *self) |
237 |
|
|
{ |
238 |
|
|
GtkWidget *row, *w; |
239 |
|
|
|
240 |
|
✗ |
row = adw_action_row_new (); |
241 |
|
✗ |
adw_preferences_row_set_use_markup (ADW_PREFERENCES_ROW (row), FALSE); |
242 |
|
|
|
243 |
|
|
/* Icon */ |
244 |
|
✗ |
w = gtk_image_new_from_icon_name ("image-missing"); |
245 |
|
✗ |
adw_action_row_add_prefix (ADW_ACTION_ROW (row), w); |
246 |
|
✗ |
self->current_icon = w; |
247 |
|
|
|
248 |
|
✗ |
w = gtk_switch_new (); |
249 |
|
✗ |
gtk_widget_set_valign (w, GTK_ALIGN_CENTER); |
250 |
|
✗ |
adw_action_row_add_suffix (ADW_ACTION_ROW (row), w); |
251 |
|
✗ |
adw_action_row_set_activatable_widget (ADW_ACTION_ROW (row), w); |
252 |
|
✗ |
g_signal_connect_object (G_OBJECT (w), "state-set", |
253 |
|
|
G_CALLBACK (cc_sharing_networks_enable_network), self, G_CONNECT_SWAPPED); |
254 |
|
✗ |
self->current_switch = w; |
255 |
|
✗ |
g_object_set_data (G_OBJECT (w), "row", row); |
256 |
|
|
|
257 |
|
✗ |
return row; |
258 |
|
|
} |
259 |
|
|
|
260 |
|
|
static GtkWidget * |
261 |
|
✗ |
cc_sharing_networks_new_no_network_row (CcSharingNetworks *self) |
262 |
|
|
{ |
263 |
|
|
GtkWidget *row, *box, *w; |
264 |
|
|
|
265 |
|
✗ |
row = gtk_list_box_row_new (); |
266 |
|
✗ |
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); |
267 |
|
✗ |
gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), box); |
268 |
|
|
|
269 |
|
|
/* Label */ |
270 |
|
✗ |
w = gtk_label_new (_("No networks selected for sharing")); |
271 |
|
✗ |
gtk_widget_set_hexpand (w, TRUE); |
272 |
|
✗ |
gtk_widget_set_halign (w, GTK_ALIGN_CENTER); |
273 |
|
✗ |
gtk_widget_add_css_class (w, "dim-label"); |
274 |
|
✗ |
gtk_box_append (GTK_BOX (box), w); |
275 |
|
|
|
276 |
|
✗ |
return row; |
277 |
|
|
} |
278 |
|
|
|
279 |
|
|
static void |
280 |
|
✗ |
cc_sharing_update_networks_box (CcSharingNetworks *self) |
281 |
|
|
{ |
282 |
|
|
GtkWidget *child; |
283 |
|
✗ |
gboolean current_visible, current_network_enabled = FALSE; |
284 |
|
|
const char *current_network; |
285 |
|
|
GList *l; |
286 |
|
|
|
287 |
|
✗ |
child = gtk_widget_get_first_child (self->listbox); |
288 |
|
✗ |
while (child) { |
289 |
|
✗ |
GtkWidget *next = gtk_widget_get_next_sibling (child); |
290 |
|
✗ |
if (child != self->current_row && child != self->no_network_row) |
291 |
|
✗ |
gtk_list_box_remove (GTK_LIST_BOX (self->listbox), child); |
292 |
|
✗ |
child = next; |
293 |
|
|
} |
294 |
|
|
|
295 |
|
✗ |
current_network = gsd_sharing_get_current_network (self->proxy); |
296 |
|
|
|
297 |
|
✗ |
if (current_network != NULL && |
298 |
|
✗ |
!g_str_equal (current_network, "")) { |
299 |
|
|
gboolean available; |
300 |
|
|
const char *carrier_type, *icon_name, *current_network_name; |
301 |
|
|
|
302 |
|
✗ |
gtk_widget_set_visible (self->current_row, TRUE); |
303 |
|
✗ |
current_visible = TRUE; |
304 |
|
|
|
305 |
|
|
/* Network name */ |
306 |
|
✗ |
g_object_set_data_full (G_OBJECT (self->current_row), |
307 |
|
✗ |
"uuid", g_strdup (current_network), g_free); |
308 |
|
✗ |
current_network_name = gsd_sharing_get_current_network_name (self->proxy); |
309 |
|
✗ |
if (ADW_IS_PREFERENCES_ROW (self->current_row)) |
310 |
|
✗ |
adw_preferences_row_set_title (ADW_PREFERENCES_ROW (self->current_row), current_network_name); |
311 |
|
|
|
312 |
|
|
/* Icon */ |
313 |
|
✗ |
carrier_type = gsd_sharing_get_carrier_type (self->proxy); |
314 |
|
✗ |
if (g_strcmp0 (carrier_type, "802-11-wireless") == 0) { |
315 |
|
✗ |
icon_name = "network-wireless-signal-excellent-symbolic"; |
316 |
|
✗ |
} else if (g_strcmp0 (carrier_type, "802-3-ethernet") == 0) { |
317 |
|
✗ |
icon_name = "network-wired-symbolic"; |
318 |
|
|
} else { |
319 |
|
✗ |
icon_name = "network-wired-symbolic"; |
320 |
|
|
} |
321 |
|
✗ |
gtk_image_set_from_icon_name (GTK_IMAGE (self->current_icon), icon_name); |
322 |
|
|
|
323 |
|
|
/* State */ |
324 |
|
✗ |
available = gsd_sharing_get_sharing_status (self->proxy) == GSD_SHARING_STATUS_AVAILABLE; |
325 |
|
✗ |
gtk_widget_set_sensitive (self->current_switch, available); |
326 |
|
|
//FIXME add a subtitle explaining why it's disabled |
327 |
|
|
} else { |
328 |
|
✗ |
gtk_widget_set_visible (self->current_row, FALSE); |
329 |
|
✗ |
current_visible = FALSE; |
330 |
|
|
} |
331 |
|
|
|
332 |
|
✗ |
for (l = self->networks; l != NULL; l = l->next) { |
333 |
|
✗ |
CcSharingNetwork *net = l->data; |
334 |
|
|
GtkWidget *row; |
335 |
|
|
|
336 |
|
✗ |
if (g_strcmp0 (net->uuid, current_network) == 0) { |
337 |
|
✗ |
current_network_enabled = TRUE; |
338 |
|
✗ |
continue; |
339 |
|
|
} |
340 |
|
|
|
341 |
|
✗ |
row = cc_sharing_networks_new_row (net->uuid, |
342 |
|
✗ |
net->network_name, |
343 |
|
✗ |
net->carrier_type, |
344 |
|
|
self); |
345 |
|
✗ |
gtk_widget_set_visible (row, TRUE); |
346 |
|
✗ |
gtk_list_box_insert (GTK_LIST_BOX (self->listbox), row, -1); |
347 |
|
|
} |
348 |
|
|
|
349 |
|
✗ |
g_signal_handlers_block_by_func (self->current_switch, |
350 |
|
|
cc_sharing_networks_enable_network, self); |
351 |
|
✗ |
gtk_switch_set_active (GTK_SWITCH (self->current_switch), current_network_enabled); |
352 |
|
✗ |
g_signal_handlers_unblock_by_func (self->current_switch, |
353 |
|
|
cc_sharing_networks_enable_network, self); |
354 |
|
|
|
355 |
|
✗ |
if (self->networks == NULL && |
356 |
|
|
!current_visible) { |
357 |
|
✗ |
gtk_widget_set_visible (self->no_network_row, TRUE); |
358 |
|
|
} else { |
359 |
|
✗ |
gtk_widget_set_visible (self->no_network_row, FALSE); |
360 |
|
|
} |
361 |
|
|
|
362 |
|
✗ |
cc_sharing_networks_update_status (self); |
363 |
|
✗ |
} |
364 |
|
|
|
365 |
|
|
static void |
366 |
|
✗ |
current_network_changed (CcSharingNetworks *self) |
367 |
|
|
{ |
368 |
|
✗ |
cc_sharing_update_networks (self); |
369 |
|
✗ |
cc_sharing_update_networks_box (self); |
370 |
|
✗ |
} |
371 |
|
|
|
372 |
|
|
static void |
373 |
|
✗ |
cc_sharing_networks_constructed (GObject *object) |
374 |
|
|
{ |
375 |
|
|
CcSharingNetworks *self; |
376 |
|
|
|
377 |
|
✗ |
G_OBJECT_CLASS (cc_sharing_networks_parent_class)->constructed (object); |
378 |
|
|
|
379 |
|
✗ |
self = CC_SHARING_NETWORKS (object); |
380 |
|
|
|
381 |
|
✗ |
self->current_row = cc_sharing_networks_new_current_row (self); |
382 |
|
✗ |
gtk_list_box_insert (GTK_LIST_BOX (self->listbox), self->current_row, -1); |
383 |
|
✗ |
g_object_set_data (G_OBJECT (self), "switch", self->current_switch); |
384 |
|
|
|
385 |
|
✗ |
self->no_network_row = cc_sharing_networks_new_no_network_row (self); |
386 |
|
✗ |
gtk_list_box_insert (GTK_LIST_BOX (self->listbox), self->no_network_row, -1); |
387 |
|
|
|
388 |
|
✗ |
cc_sharing_update_networks (self); |
389 |
|
✗ |
cc_sharing_update_networks_box (self); |
390 |
|
|
|
391 |
|
✗ |
g_signal_connect_object (self->proxy, "notify::current-network", |
392 |
|
|
G_CALLBACK (current_network_changed), self, G_CONNECT_SWAPPED); |
393 |
|
✗ |
} |
394 |
|
|
|
395 |
|
|
static void |
396 |
|
✗ |
cc_sharing_networks_init (CcSharingNetworks *self) |
397 |
|
|
{ |
398 |
|
✗ |
gtk_widget_init_template (GTK_WIDGET (self)); |
399 |
|
✗ |
} |
400 |
|
|
|
401 |
|
|
GtkWidget * |
402 |
|
✗ |
cc_sharing_networks_new (GDBusProxy *proxy, |
403 |
|
|
const char *service_name) |
404 |
|
|
{ |
405 |
|
✗ |
g_return_val_if_fail (GSD_IS_SHARING (proxy), NULL); |
406 |
|
✗ |
g_return_val_if_fail (service_name != NULL, NULL); |
407 |
|
|
|
408 |
|
✗ |
return GTK_WIDGET (g_object_new (CC_TYPE_SHARING_NETWORKS, |
409 |
|
|
"proxy", proxy, |
410 |
|
|
"service-name", service_name, |
411 |
|
|
NULL)); |
412 |
|
|
} |
413 |
|
|
|
414 |
|
|
static void |
415 |
|
✗ |
cc_sharing_networks_set_property (GObject *object, |
416 |
|
|
guint prop_id, |
417 |
|
|
const GValue *value, |
418 |
|
|
GParamSpec *pspec) |
419 |
|
|
{ |
420 |
|
|
CcSharingNetworks *self; |
421 |
|
|
|
422 |
|
✗ |
self = CC_SHARING_NETWORKS (object); |
423 |
|
|
|
424 |
|
✗ |
switch (prop_id) { |
425 |
|
✗ |
case PROP_SERVICE_NAME: |
426 |
|
✗ |
self->service_name = g_value_dup_string (value); |
427 |
|
✗ |
break; |
428 |
|
✗ |
case PROP_PROXY: |
429 |
|
✗ |
self->proxy = g_value_dup_object (value); |
430 |
|
✗ |
break; |
431 |
|
✗ |
default: |
432 |
|
✗ |
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
433 |
|
✗ |
break; |
434 |
|
|
} |
435 |
|
✗ |
} |
436 |
|
|
|
437 |
|
|
static void |
438 |
|
✗ |
cc_sharing_networks_get_property (GObject *object, |
439 |
|
|
guint prop_id, |
440 |
|
|
GValue *value, |
441 |
|
|
GParamSpec *pspec) |
442 |
|
|
{ |
443 |
|
|
CcSharingNetworks *self; |
444 |
|
|
|
445 |
|
✗ |
self = CC_SHARING_NETWORKS (object); |
446 |
|
|
|
447 |
|
✗ |
switch (prop_id) { |
448 |
|
✗ |
case PROP_STATUS: |
449 |
|
✗ |
g_value_set_uint (value, self->status); |
450 |
|
✗ |
break; |
451 |
|
✗ |
default: |
452 |
|
✗ |
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
453 |
|
✗ |
break; |
454 |
|
|
} |
455 |
|
✗ |
} |
456 |
|
|
|
457 |
|
|
static void |
458 |
|
✗ |
cc_sharing_networks_finalize (GObject *object) |
459 |
|
|
{ |
460 |
|
|
CcSharingNetworks *self; |
461 |
|
|
|
462 |
|
✗ |
g_return_if_fail (object != NULL); |
463 |
|
✗ |
g_return_if_fail (CC_IS_SHARING_NETWORKS (object)); |
464 |
|
|
|
465 |
|
✗ |
self = CC_SHARING_NETWORKS (object); |
466 |
|
|
|
467 |
|
✗ |
g_return_if_fail (self != NULL); |
468 |
|
|
|
469 |
|
✗ |
g_clear_object (&self->proxy); |
470 |
|
✗ |
g_clear_pointer (&self->service_name, g_free); |
471 |
|
|
|
472 |
|
✗ |
if (self->networks != NULL) { |
473 |
|
✗ |
g_list_free_full (self->networks, cc_sharing_network_free); |
474 |
|
✗ |
self->networks = NULL; |
475 |
|
|
} |
476 |
|
|
|
477 |
|
✗ |
G_OBJECT_CLASS (cc_sharing_networks_parent_class)->finalize (object); |
478 |
|
|
} |
479 |
|
|
|
480 |
|
|
|
481 |
|
|
static void |
482 |
|
✗ |
cc_sharing_networks_class_init (CcSharingNetworksClass *klass) |
483 |
|
|
{ |
484 |
|
✗ |
GObjectClass *object_class = G_OBJECT_CLASS (klass); |
485 |
|
✗ |
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); |
486 |
|
|
|
487 |
|
✗ |
object_class->set_property = cc_sharing_networks_set_property; |
488 |
|
✗ |
object_class->get_property = cc_sharing_networks_get_property; |
489 |
|
✗ |
object_class->finalize = cc_sharing_networks_finalize; |
490 |
|
✗ |
object_class->constructed = cc_sharing_networks_constructed; |
491 |
|
|
|
492 |
|
✗ |
g_object_class_install_property (object_class, |
493 |
|
|
PROP_PROXY, |
494 |
|
|
g_param_spec_object ("proxy", |
495 |
|
|
"proxy", |
496 |
|
|
"proxy", |
497 |
|
|
GSD_TYPE_SHARING_PROXY, |
498 |
|
|
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); |
499 |
|
|
|
500 |
|
✗ |
g_object_class_install_property (object_class, |
501 |
|
|
PROP_SERVICE_NAME, |
502 |
|
|
g_param_spec_string ("service-name", |
503 |
|
|
"service-name", |
504 |
|
|
"service-name", |
505 |
|
|
NULL, |
506 |
|
|
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); |
507 |
|
|
|
508 |
|
✗ |
g_object_class_install_property (object_class, |
509 |
|
|
PROP_STATUS, |
510 |
|
|
g_param_spec_uint ("status", |
511 |
|
|
"status", |
512 |
|
|
"status", |
513 |
|
|
CC_SHARING_STATUS_UNSET, CC_SHARING_STATUS_ACTIVE + 1, CC_SHARING_STATUS_OFF, |
514 |
|
|
G_PARAM_READABLE)); |
515 |
|
|
|
516 |
|
✗ |
gtk_widget_class_set_template_from_resource (widget_class, |
517 |
|
|
"/org/gnome/control-center/sharing/cc-sharing-networks.ui"); |
518 |
|
|
|
519 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, CcSharingNetworks, listbox); |
520 |
|
✗ |
} |
521 |
|
|
|
522 |
|
|
/* |
523 |
|
|
* vim: sw=2 ts=8 cindent noai bs=2 |
524 |
|
|
*/ |
525 |
|
|
|