Line |
Branch |
Exec |
Source |
1 |
|
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- |
2 |
|
|
* |
3 |
|
|
* Copyright (C) 2023 Red Hat, Inc |
4 |
|
|
* |
5 |
|
|
* Licensed under the GNU General Public License Version 2 |
6 |
|
|
* |
7 |
|
|
* This program is free software; you can redistribute it and/or modify |
8 |
|
|
* it under the terms of the GNU General Public License as published by |
9 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
10 |
|
|
* (at your option) any later version. |
11 |
|
|
* |
12 |
|
|
* This program is distributed in the hope that it will be useful, |
13 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
|
|
* GNU General Public License for more details. |
16 |
|
|
* |
17 |
|
|
* You should have received a copy of the GNU General Public License |
18 |
|
|
* along with this program; if not, write to the Free Software |
19 |
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
20 |
|
|
*/ |
21 |
|
|
|
22 |
|
|
#include "config.h" |
23 |
|
|
|
24 |
|
|
#include <glib/gi18n.h> |
25 |
|
|
#include <NetworkManager.h> |
26 |
|
|
|
27 |
|
|
#include "ce-page.h" |
28 |
|
|
#include "ce-page-bluetooth.h" |
29 |
|
|
#include "ui-helpers.h" |
30 |
|
|
|
31 |
|
|
struct _CEPageBluetooth |
32 |
|
|
{ |
33 |
|
|
GtkGrid parent; |
34 |
|
|
|
35 |
|
|
GtkEntry *name_entry; |
36 |
|
|
|
37 |
|
|
NMSettingConnection *setting_connection; |
38 |
|
|
}; |
39 |
|
|
|
40 |
|
|
static void ce_page_iface_init (CEPageInterface *); |
41 |
|
|
|
42 |
|
✗ |
G_DEFINE_TYPE_WITH_CODE (CEPageBluetooth, ce_page_bluetooth, GTK_TYPE_GRID, |
43 |
|
|
G_IMPLEMENT_INTERFACE (ce_page_get_type (), ce_page_iface_init)) |
44 |
|
|
|
45 |
|
|
static void |
46 |
|
✗ |
connect_bluetooth_page (CEPageBluetooth *self) |
47 |
|
|
{ |
48 |
|
|
const gchar *name; |
49 |
|
|
|
50 |
|
✗ |
name = nm_setting_connection_get_id (self->setting_connection); |
51 |
|
✗ |
gtk_editable_set_text (GTK_EDITABLE (self->name_entry), name); |
52 |
|
|
|
53 |
|
✗ |
g_signal_connect_object (self->name_entry, "changed", G_CALLBACK (ce_page_changed), self, G_CONNECT_SWAPPED); |
54 |
|
✗ |
} |
55 |
|
|
|
56 |
|
|
static const gchar * |
57 |
|
✗ |
ce_page_bluetooth_get_title (CEPage *page) |
58 |
|
|
{ |
59 |
|
✗ |
return _("Identity"); |
60 |
|
|
} |
61 |
|
|
|
62 |
|
|
static gboolean |
63 |
|
✗ |
ce_page_bluetooth_validate (CEPage *page, |
64 |
|
|
NMConnection *connection, |
65 |
|
|
GError **error) |
66 |
|
|
{ |
67 |
|
✗ |
CEPageBluetooth *self = CE_PAGE_BLUETOOTH (page); |
68 |
|
|
|
69 |
|
✗ |
g_object_set (self->setting_connection, |
70 |
|
✗ |
NM_SETTING_CONNECTION_ID, gtk_editable_get_text (GTK_EDITABLE (self->name_entry)), |
71 |
|
|
NULL); |
72 |
|
|
|
73 |
|
✗ |
return nm_setting_verify (NM_SETTING (self->setting_connection), NULL, error); |
74 |
|
|
} |
75 |
|
|
|
76 |
|
|
static void |
77 |
|
✗ |
ce_page_bluetooth_init (CEPageBluetooth *self) |
78 |
|
|
{ |
79 |
|
✗ |
gtk_widget_init_template (GTK_WIDGET (self)); |
80 |
|
✗ |
} |
81 |
|
|
|
82 |
|
|
static void |
83 |
|
✗ |
ce_page_bluetooth_class_init (CEPageBluetoothClass *klass) |
84 |
|
|
{ |
85 |
|
✗ |
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); |
86 |
|
|
|
87 |
|
✗ |
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/network/bluetooth-page.ui"); |
88 |
|
|
|
89 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, CEPageBluetooth, name_entry); |
90 |
|
✗ |
} |
91 |
|
|
|
92 |
|
|
static void |
93 |
|
✗ |
ce_page_iface_init (CEPageInterface *iface) |
94 |
|
|
{ |
95 |
|
✗ |
iface->get_title = ce_page_bluetooth_get_title; |
96 |
|
✗ |
iface->validate = ce_page_bluetooth_validate; |
97 |
|
✗ |
} |
98 |
|
|
|
99 |
|
|
CEPageBluetooth * |
100 |
|
✗ |
ce_page_bluetooth_new (NMConnection *connection) |
101 |
|
|
{ |
102 |
|
|
CEPageBluetooth *self; |
103 |
|
|
|
104 |
|
✗ |
self = CE_PAGE_BLUETOOTH (g_object_new (ce_page_bluetooth_get_type (), NULL)); |
105 |
|
|
|
106 |
|
✗ |
self->setting_connection = nm_connection_get_setting_connection (connection); |
107 |
|
|
|
108 |
|
✗ |
connect_bluetooth_page (self); |
109 |
|
|
|
110 |
|
✗ |
return self; |
111 |
|
|
} |
112 |
|
|
|