network: Use self variable name consistently
This commit is contained in:
parent
8b6e3fb736
commit
708b1fdaf7
34 changed files with 2375 additions and 2378 deletions
|
@ -49,42 +49,42 @@ static guint signals[LAST_SIGNAL] = { 0 };
|
|||
|
||||
G_DEFINE_TYPE (NetConnectionEditor, net_connection_editor, GTK_TYPE_DIALOG)
|
||||
|
||||
static void page_changed (NetConnectionEditor *editor);
|
||||
static void page_changed (NetConnectionEditor *self);
|
||||
|
||||
static void
|
||||
cancel_editing (NetConnectionEditor *editor)
|
||||
cancel_editing (NetConnectionEditor *self)
|
||||
{
|
||||
gtk_widget_hide (GTK_WIDGET (editor));
|
||||
g_signal_emit (editor, signals[DONE], 0, FALSE);
|
||||
gtk_widget_hide (GTK_WIDGET (self));
|
||||
g_signal_emit (self, signals[DONE], 0, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
delete_event_cb (NetConnectionEditor *editor)
|
||||
delete_event_cb (NetConnectionEditor *self)
|
||||
{
|
||||
cancel_editing (editor);
|
||||
cancel_editing (self);
|
||||
}
|
||||
|
||||
static void
|
||||
cancel_clicked_cb (NetConnectionEditor *editor)
|
||||
cancel_clicked_cb (NetConnectionEditor *self)
|
||||
{
|
||||
cancel_editing (editor);
|
||||
cancel_editing (self);
|
||||
}
|
||||
|
||||
static void
|
||||
update_connection (NetConnectionEditor *editor)
|
||||
update_connection (NetConnectionEditor *self)
|
||||
{
|
||||
g_autoptr(GVariant) settings = NULL;
|
||||
|
||||
settings = nm_connection_to_dbus (editor->connection, NM_CONNECTION_SERIALIZE_ALL);
|
||||
nm_connection_replace_settings (editor->orig_connection, settings, NULL);
|
||||
settings = nm_connection_to_dbus (self->connection, NM_CONNECTION_SERIALIZE_ALL);
|
||||
nm_connection_replace_settings (self->orig_connection, settings, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
update_complete (NetConnectionEditor *editor,
|
||||
update_complete (NetConnectionEditor *self,
|
||||
gboolean success)
|
||||
{
|
||||
gtk_widget_hide (GTK_WIDGET (editor));
|
||||
g_signal_emit (editor, signals[DONE], 0, success);
|
||||
gtk_widget_hide (GTK_WIDGET (self));
|
||||
g_signal_emit (self, signals[DONE], 0, success);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -92,7 +92,7 @@ updated_connection_cb (GObject *source_object,
|
|||
GAsyncResult *res,
|
||||
gpointer user_data)
|
||||
{
|
||||
NetConnectionEditor *editor;
|
||||
NetConnectionEditor *self;
|
||||
g_autoptr(GError) error = NULL;
|
||||
gboolean success = TRUE;
|
||||
|
||||
|
@ -105,8 +105,8 @@ updated_connection_cb (GObject *source_object,
|
|||
|
||||
nm_connection_clear_secrets (NM_CONNECTION (source_object));
|
||||
|
||||
editor = user_data;
|
||||
update_complete (editor, success);
|
||||
self = user_data;
|
||||
update_complete (self, success);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -114,7 +114,7 @@ added_connection_cb (GObject *source_object,
|
|||
GAsyncResult *res,
|
||||
gpointer user_data)
|
||||
{
|
||||
NetConnectionEditor *editor;
|
||||
NetConnectionEditor *self;
|
||||
g_autoptr(GError) error = NULL;
|
||||
gboolean success = TRUE;
|
||||
|
||||
|
@ -125,55 +125,55 @@ added_connection_cb (GObject *source_object,
|
|||
// return; FIXME return if cancelled
|
||||
}
|
||||
|
||||
editor = user_data;
|
||||
update_complete (editor, success);
|
||||
self = user_data;
|
||||
update_complete (self, success);
|
||||
}
|
||||
|
||||
static void
|
||||
apply_clicked_cb (NetConnectionEditor *editor)
|
||||
apply_clicked_cb (NetConnectionEditor *self)
|
||||
{
|
||||
update_connection (editor);
|
||||
update_connection (self);
|
||||
|
||||
eap_method_ca_cert_ignore_save (editor->connection);
|
||||
eap_method_ca_cert_ignore_save (self->connection);
|
||||
|
||||
if (editor->is_new_connection) {
|
||||
nm_client_add_connection_async (editor->client,
|
||||
editor->orig_connection,
|
||||
if (self->is_new_connection) {
|
||||
nm_client_add_connection_async (self->client,
|
||||
self->orig_connection,
|
||||
TRUE,
|
||||
NULL,
|
||||
added_connection_cb,
|
||||
editor);
|
||||
self);
|
||||
} else {
|
||||
nm_remote_connection_commit_changes_async (NM_REMOTE_CONNECTION (editor->orig_connection),
|
||||
nm_remote_connection_commit_changes_async (NM_REMOTE_CONNECTION (self->orig_connection),
|
||||
TRUE,
|
||||
NULL,
|
||||
updated_connection_cb, editor);
|
||||
updated_connection_cb, self);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
net_connection_editor_init (NetConnectionEditor *editor)
|
||||
net_connection_editor_init (NetConnectionEditor *self)
|
||||
{
|
||||
gtk_widget_init_template (GTK_WIDGET (editor));
|
||||
gtk_widget_init_template (GTK_WIDGET (self));
|
||||
}
|
||||
|
||||
static void
|
||||
net_connection_editor_finalize (GObject *object)
|
||||
{
|
||||
NetConnectionEditor *editor = NET_CONNECTION_EDITOR (object);
|
||||
NetConnectionEditor *self = NET_CONNECTION_EDITOR (object);
|
||||
GSList *l;
|
||||
|
||||
for (l = editor->pages; l != NULL; l = l->next)
|
||||
g_signal_handlers_disconnect_by_func (l->data, page_changed, editor);
|
||||
for (l = self->pages; l != NULL; l = l->next)
|
||||
g_signal_handlers_disconnect_by_func (l->data, page_changed, self);
|
||||
|
||||
if (editor->permission_id > 0 && editor->client)
|
||||
g_signal_handler_disconnect (editor->client, editor->permission_id);
|
||||
g_clear_object (&editor->connection);
|
||||
g_clear_object (&editor->orig_connection);
|
||||
g_clear_object (&editor->parent_window);
|
||||
g_clear_object (&editor->device);
|
||||
g_clear_object (&editor->client);
|
||||
g_clear_object (&editor->ap);
|
||||
if (self->permission_id > 0 && self->client)
|
||||
g_signal_handler_disconnect (self->client, self->permission_id);
|
||||
g_clear_object (&self->connection);
|
||||
g_clear_object (&self->orig_connection);
|
||||
g_clear_object (&self->parent_window);
|
||||
g_clear_object (&self->device);
|
||||
g_clear_object (&self->client);
|
||||
g_clear_object (&self->ap);
|
||||
|
||||
G_OBJECT_CLASS (net_connection_editor_parent_class)->finalize (object);
|
||||
}
|
||||
|
@ -209,17 +209,17 @@ net_connection_editor_class_init (NetConnectionEditorClass *class)
|
|||
}
|
||||
|
||||
static void
|
||||
net_connection_editor_error_dialog (NetConnectionEditor *editor,
|
||||
net_connection_editor_error_dialog (NetConnectionEditor *self,
|
||||
const char *primary_text,
|
||||
const char *secondary_text)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkWindow *parent;
|
||||
|
||||
if (gtk_widget_is_visible (GTK_WIDGET (editor)))
|
||||
parent = GTK_WINDOW (editor);
|
||||
if (gtk_widget_is_visible (GTK_WIDGET (self)))
|
||||
parent = GTK_WINDOW (self);
|
||||
else
|
||||
parent = GTK_WINDOW (editor->parent_window);
|
||||
parent = GTK_WINDOW (self->parent_window);
|
||||
|
||||
dialog = gtk_message_dialog_new (parent,
|
||||
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
|
@ -238,38 +238,38 @@ net_connection_editor_error_dialog (NetConnectionEditor *editor,
|
|||
}
|
||||
|
||||
static void
|
||||
net_connection_editor_do_fallback (NetConnectionEditor *editor, const gchar *type)
|
||||
net_connection_editor_do_fallback (NetConnectionEditor *self, const gchar *type)
|
||||
{
|
||||
g_autofree gchar *cmdline = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
if (editor->is_new_connection) {
|
||||
if (self->is_new_connection) {
|
||||
cmdline = g_strdup_printf ("nm-connection-editor --type='%s' --create", type);
|
||||
} else {
|
||||
cmdline = g_strdup_printf ("nm-connection-editor --edit='%s'",
|
||||
nm_connection_get_uuid (editor->connection));
|
||||
nm_connection_get_uuid (self->connection));
|
||||
}
|
||||
|
||||
g_spawn_command_line_async (cmdline, &error);
|
||||
|
||||
if (error)
|
||||
net_connection_editor_error_dialog (editor,
|
||||
net_connection_editor_error_dialog (self,
|
||||
_("Unable to open connection editor"),
|
||||
error->message);
|
||||
|
||||
g_signal_emit (editor, signals[DONE], 0, FALSE);
|
||||
g_signal_emit (self, signals[DONE], 0, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
net_connection_editor_update_title (NetConnectionEditor *editor)
|
||||
net_connection_editor_update_title (NetConnectionEditor *self)
|
||||
{
|
||||
g_autofree gchar *id = NULL;
|
||||
|
||||
if (editor->title_set)
|
||||
if (self->title_set)
|
||||
return;
|
||||
|
||||
if (editor->is_new_connection) {
|
||||
if (editor->device) {
|
||||
if (self->is_new_connection) {
|
||||
if (self->device) {
|
||||
id = g_strdup (_("New Profile"));
|
||||
} else {
|
||||
/* Leave it set to "Add New Connection" */
|
||||
|
@ -277,63 +277,63 @@ net_connection_editor_update_title (NetConnectionEditor *editor)
|
|||
}
|
||||
} else {
|
||||
NMSettingWireless *sw;
|
||||
sw = nm_connection_get_setting_wireless (editor->connection);
|
||||
sw = nm_connection_get_setting_wireless (self->connection);
|
||||
if (sw) {
|
||||
GBytes *ssid;
|
||||
ssid = nm_setting_wireless_get_ssid (sw);
|
||||
id = nm_utils_ssid_to_utf8 (g_bytes_get_data (ssid, NULL), g_bytes_get_size (ssid));
|
||||
} else {
|
||||
id = g_strdup (nm_connection_get_id (editor->connection));
|
||||
id = g_strdup (nm_connection_get_id (self->connection));
|
||||
}
|
||||
}
|
||||
gtk_window_set_title (GTK_WINDOW (editor), id);
|
||||
gtk_window_set_title (GTK_WINDOW (self), id);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
editor_is_initialized (NetConnectionEditor *editor)
|
||||
editor_is_initialized (NetConnectionEditor *self)
|
||||
{
|
||||
return editor->initializing_pages == NULL;
|
||||
return self->initializing_pages == NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
update_sensitivity (NetConnectionEditor *editor)
|
||||
update_sensitivity (NetConnectionEditor *self)
|
||||
{
|
||||
NMSettingConnection *sc;
|
||||
gboolean sensitive;
|
||||
GtkWidget *widget;
|
||||
GSList *l;
|
||||
|
||||
if (!editor_is_initialized (editor))
|
||||
if (!editor_is_initialized (self))
|
||||
return;
|
||||
|
||||
sc = nm_connection_get_setting_connection (editor->connection);
|
||||
sc = nm_connection_get_setting_connection (self->connection);
|
||||
|
||||
if (nm_setting_connection_get_read_only (sc)) {
|
||||
sensitive = FALSE;
|
||||
} else {
|
||||
sensitive = editor->can_modify;
|
||||
sensitive = self->can_modify;
|
||||
}
|
||||
|
||||
for (l = editor->pages; l; l = l->next) {
|
||||
for (l = self->pages; l; l = l->next) {
|
||||
widget = ce_page_get_page (CE_PAGE (l->data));
|
||||
gtk_widget_set_sensitive (widget, sensitive);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
validate (NetConnectionEditor *editor)
|
||||
validate (NetConnectionEditor *self)
|
||||
{
|
||||
gboolean valid = FALSE;
|
||||
GSList *l;
|
||||
|
||||
if (!editor_is_initialized (editor))
|
||||
if (!editor_is_initialized (self))
|
||||
goto done;
|
||||
|
||||
valid = TRUE;
|
||||
for (l = editor->pages; l; l = l->next) {
|
||||
for (l = self->pages; l; l = l->next) {
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
if (!ce_page_validate (CE_PAGE (l->data), editor->connection, &error)) {
|
||||
if (!ce_page_validate (CE_PAGE (l->data), self->connection, &error)) {
|
||||
valid = FALSE;
|
||||
if (error) {
|
||||
g_debug ("Invalid setting %s: %s", ce_page_get_title (CE_PAGE (l->data)), error->message);
|
||||
|
@ -343,17 +343,17 @@ validate (NetConnectionEditor *editor)
|
|||
}
|
||||
}
|
||||
|
||||
update_sensitivity (editor);
|
||||
update_sensitivity (self);
|
||||
done:
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (editor->apply_button), valid && editor->is_changed);
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (self->apply_button), valid && self->is_changed);
|
||||
}
|
||||
|
||||
static void
|
||||
page_changed (NetConnectionEditor *editor)
|
||||
page_changed (NetConnectionEditor *self)
|
||||
{
|
||||
if (editor_is_initialized (editor))
|
||||
editor->is_changed = TRUE;
|
||||
validate (editor);
|
||||
if (editor_is_initialized (self))
|
||||
self->is_changed = TRUE;
|
||||
validate (self);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -365,21 +365,21 @@ idle_validate (gpointer user_data)
|
|||
}
|
||||
|
||||
static void
|
||||
recheck_initialization (NetConnectionEditor *editor)
|
||||
recheck_initialization (NetConnectionEditor *self)
|
||||
{
|
||||
if (!editor_is_initialized (editor))
|
||||
if (!editor_is_initialized (self))
|
||||
return;
|
||||
|
||||
gtk_notebook_set_current_page (editor->notebook, 0);
|
||||
gtk_notebook_set_current_page (self->notebook, 0);
|
||||
|
||||
if (editor->show_when_initialized)
|
||||
gtk_window_present (GTK_WINDOW (editor));
|
||||
if (self->show_when_initialized)
|
||||
gtk_window_present (GTK_WINDOW (self));
|
||||
|
||||
g_idle_add (idle_validate, editor);
|
||||
g_idle_add (idle_validate, self);
|
||||
}
|
||||
|
||||
static void
|
||||
page_initialized (NetConnectionEditor *editor, GError *error, CEPage *page)
|
||||
page_initialized (NetConnectionEditor *self, GError *error, CEPage *page)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GtkWidget *label;
|
||||
|
@ -390,7 +390,7 @@ page_initialized (NetConnectionEditor *editor, GError *error, CEPage *page)
|
|||
widget = ce_page_get_page (page);
|
||||
position = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (page), "position"));
|
||||
g_object_set_data (G_OBJECT (widget), "position", GINT_TO_POINTER (position));
|
||||
children = gtk_container_get_children (GTK_CONTAINER (editor->notebook));
|
||||
children = gtk_container_get_children (GTK_CONTAINER (self->notebook));
|
||||
for (l = children, i = 0; l; l = l->next, i++) {
|
||||
gint pos = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (l->data), "position"));
|
||||
if (pos > position)
|
||||
|
@ -400,12 +400,12 @@ page_initialized (NetConnectionEditor *editor, GError *error, CEPage *page)
|
|||
|
||||
label = gtk_label_new (ce_page_get_title (page));
|
||||
|
||||
gtk_notebook_insert_page (editor->notebook, widget, label, i);
|
||||
gtk_notebook_insert_page (self->notebook, widget, label, i);
|
||||
|
||||
editor->initializing_pages = g_slist_remove (editor->initializing_pages, page);
|
||||
editor->pages = g_slist_append (editor->pages, page);
|
||||
self->initializing_pages = g_slist_remove (self->initializing_pages, page);
|
||||
self->pages = g_slist_append (self->pages, page);
|
||||
|
||||
recheck_initialization (editor);
|
||||
recheck_initialization (self);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
|
@ -437,18 +437,18 @@ get_secrets_cb (GObject *source_object,
|
|||
}
|
||||
|
||||
static void
|
||||
get_secrets_for_page (NetConnectionEditor *editor,
|
||||
get_secrets_for_page (NetConnectionEditor *self,
|
||||
CEPage *page,
|
||||
const gchar *setting_name)
|
||||
{
|
||||
GetSecretsInfo *info;
|
||||
|
||||
info = g_new0 (GetSecretsInfo, 1);
|
||||
info->editor = editor;
|
||||
info->editor = self;
|
||||
info->page = page;
|
||||
info->setting_name = setting_name;
|
||||
|
||||
nm_remote_connection_get_secrets_async (NM_REMOTE_CONNECTION (editor->orig_connection),
|
||||
nm_remote_connection_get_secrets_async (NM_REMOTE_CONNECTION (self->orig_connection),
|
||||
setting_name,
|
||||
NULL, //FIXME
|
||||
get_secrets_cb,
|
||||
|
@ -456,21 +456,21 @@ get_secrets_for_page (NetConnectionEditor *editor,
|
|||
}
|
||||
|
||||
static void
|
||||
add_page (NetConnectionEditor *editor, CEPage *page)
|
||||
add_page (NetConnectionEditor *self, CEPage *page)
|
||||
{
|
||||
gint position;
|
||||
|
||||
position = g_slist_length (editor->initializing_pages);
|
||||
position = g_slist_length (self->initializing_pages);
|
||||
g_object_set_data (G_OBJECT (page), "position", GINT_TO_POINTER (position));
|
||||
|
||||
editor->initializing_pages = g_slist_append (editor->initializing_pages, page);
|
||||
self->initializing_pages = g_slist_append (self->initializing_pages, page);
|
||||
|
||||
g_signal_connect_swapped (page, "changed", G_CALLBACK (page_changed), editor);
|
||||
g_signal_connect_swapped (page, "initialized", G_CALLBACK (page_initialized), editor);
|
||||
g_signal_connect_swapped (page, "changed", G_CALLBACK (page_changed), self);
|
||||
g_signal_connect_swapped (page, "initialized", G_CALLBACK (page_initialized), self);
|
||||
}
|
||||
|
||||
static void
|
||||
net_connection_editor_set_connection (NetConnectionEditor *editor,
|
||||
net_connection_editor_set_connection (NetConnectionEditor *self,
|
||||
NMConnection *connection)
|
||||
{
|
||||
GSList *pages, *l;
|
||||
|
@ -480,20 +480,20 @@ net_connection_editor_set_connection (NetConnectionEditor *editor,
|
|||
gboolean is_wifi;
|
||||
gboolean is_vpn;
|
||||
|
||||
editor->is_new_connection = !nm_client_get_connection_by_uuid (editor->client,
|
||||
self->is_new_connection = !nm_client_get_connection_by_uuid (self->client,
|
||||
nm_connection_get_uuid (connection));
|
||||
|
||||
if (editor->is_new_connection) {
|
||||
gtk_button_set_label (editor->apply_button, _("_Add"));
|
||||
editor->is_changed = TRUE;
|
||||
if (self->is_new_connection) {
|
||||
gtk_button_set_label (self->apply_button, _("_Add"));
|
||||
self->is_changed = TRUE;
|
||||
}
|
||||
|
||||
editor->connection = nm_simple_connection_new_clone (connection);
|
||||
editor->orig_connection = g_object_ref (connection);
|
||||
self->connection = nm_simple_connection_new_clone (connection);
|
||||
self->orig_connection = g_object_ref (connection);
|
||||
|
||||
net_connection_editor_update_title (editor);
|
||||
net_connection_editor_update_title (self);
|
||||
|
||||
eap_method_ca_cert_ignore_load (editor->connection);
|
||||
eap_method_ca_cert_ignore_load (self->connection);
|
||||
|
||||
sc = nm_connection_get_setting_connection (connection);
|
||||
type = nm_setting_connection_get_connection_type (sc);
|
||||
|
@ -502,46 +502,46 @@ net_connection_editor_set_connection (NetConnectionEditor *editor,
|
|||
is_wifi = g_str_equal (type, NM_SETTING_WIRELESS_SETTING_NAME);
|
||||
is_vpn = g_str_equal (type, NM_SETTING_VPN_SETTING_NAME);
|
||||
|
||||
if (!editor->is_new_connection)
|
||||
add_page (editor, ce_page_details_new (editor->connection, editor->client, editor->device, editor->ap, editor));
|
||||
if (!self->is_new_connection)
|
||||
add_page (self, ce_page_details_new (self->connection, self->client, self->device, self->ap, self));
|
||||
|
||||
if (is_wifi)
|
||||
add_page (editor, ce_page_wifi_new (editor->connection, editor->client));
|
||||
add_page (self, ce_page_wifi_new (self->connection, self->client));
|
||||
else if (is_wired)
|
||||
add_page (editor, ce_page_ethernet_new (editor->connection, editor->client));
|
||||
add_page (self, ce_page_ethernet_new (self->connection, self->client));
|
||||
else if (is_vpn)
|
||||
add_page (editor, ce_page_vpn_new (editor->connection, editor->client));
|
||||
add_page (self, ce_page_vpn_new (self->connection, self->client));
|
||||
else {
|
||||
/* Unsupported type */
|
||||
net_connection_editor_do_fallback (editor, type);
|
||||
net_connection_editor_do_fallback (self, type);
|
||||
return;
|
||||
}
|
||||
|
||||
add_page (editor, ce_page_ip4_new (editor->connection, editor->client));
|
||||
add_page (editor, ce_page_ip6_new (editor->connection, editor->client));
|
||||
add_page (self, ce_page_ip4_new (self->connection, self->client));
|
||||
add_page (self, ce_page_ip6_new (self->connection, self->client));
|
||||
|
||||
if (is_wifi)
|
||||
add_page (editor, ce_page_security_new (editor->connection, editor->client));
|
||||
add_page (self, ce_page_security_new (self->connection, self->client));
|
||||
else if (is_wired)
|
||||
add_page (editor, ce_page_8021x_security_new (editor->connection, editor->client));
|
||||
add_page (self, ce_page_8021x_security_new (self->connection, self->client));
|
||||
|
||||
pages = g_slist_copy (editor->initializing_pages);
|
||||
pages = g_slist_copy (self->initializing_pages);
|
||||
for (l = pages; l; l = l->next) {
|
||||
CEPage *page = l->data;
|
||||
const gchar *security_setting;
|
||||
|
||||
security_setting = ce_page_get_security_setting (page);
|
||||
if (!security_setting || editor->is_new_connection) {
|
||||
if (!security_setting || self->is_new_connection) {
|
||||
ce_page_complete_init (page, NULL, NULL, NULL);
|
||||
} else {
|
||||
get_secrets_for_page (editor, page, security_setting);
|
||||
get_secrets_for_page (self, page, security_setting);
|
||||
}
|
||||
}
|
||||
g_slist_free (pages);
|
||||
}
|
||||
|
||||
static NMConnection *
|
||||
complete_vpn_connection (NetConnectionEditor *editor, NMConnection *connection)
|
||||
complete_vpn_connection (NetConnectionEditor *self, NMConnection *connection)
|
||||
{
|
||||
NMSettingConnection *s_con;
|
||||
NMSetting *s_type;
|
||||
|
@ -566,7 +566,7 @@ complete_vpn_connection (NetConnectionEditor *editor, NMConnection *connection)
|
|||
const GPtrArray *connections;
|
||||
g_autofree gchar *id = NULL;
|
||||
|
||||
connections = nm_client_get_connections (editor->client);
|
||||
connections = nm_client_get_connections (self->client);
|
||||
id = ce_page_get_next_available_name (connections, NAME_FORMAT_TYPE, _("VPN"));
|
||||
g_object_set (s_con,
|
||||
NM_SETTING_CONNECTION_ID, id,
|
||||
|
@ -589,37 +589,37 @@ complete_vpn_connection (NetConnectionEditor *editor, NMConnection *connection)
|
|||
}
|
||||
|
||||
static void
|
||||
finish_add_connection (NetConnectionEditor *editor, NMConnection *connection)
|
||||
finish_add_connection (NetConnectionEditor *self, NMConnection *connection)
|
||||
{
|
||||
GtkBin *frame;
|
||||
|
||||
frame = GTK_BIN (editor->add_connection_frame);
|
||||
frame = GTK_BIN (self->add_connection_frame);
|
||||
gtk_widget_destroy (gtk_bin_get_child (frame));
|
||||
|
||||
gtk_notebook_set_current_page (editor->toplevel_notebook, 0);
|
||||
gtk_widget_show (GTK_WIDGET (editor->apply_button));
|
||||
gtk_notebook_set_current_page (self->toplevel_notebook, 0);
|
||||
gtk_widget_show (GTK_WIDGET (self->apply_button));
|
||||
|
||||
if (connection)
|
||||
net_connection_editor_set_connection (editor, connection);
|
||||
net_connection_editor_set_connection (self, connection);
|
||||
}
|
||||
|
||||
static void
|
||||
vpn_import_complete (NMConnection *connection, gpointer user_data)
|
||||
{
|
||||
NetConnectionEditor *editor = user_data;
|
||||
NetConnectionEditor *self = user_data;
|
||||
|
||||
if (!connection) {
|
||||
/* The import code shows its own error dialogs. */
|
||||
g_signal_emit (editor, signals[DONE], 0, FALSE);
|
||||
g_signal_emit (self, signals[DONE], 0, FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
complete_vpn_connection (editor, connection);
|
||||
finish_add_connection (editor, connection);
|
||||
complete_vpn_connection (self, connection);
|
||||
finish_add_connection (self, connection);
|
||||
}
|
||||
|
||||
static void
|
||||
vpn_type_activated (GtkListBox *list, GtkWidget *row, NetConnectionEditor *editor)
|
||||
vpn_type_activated (GtkListBox *list, GtkWidget *row, NetConnectionEditor *self)
|
||||
{
|
||||
const char *service_name = g_object_get_data (G_OBJECT (row), "service_name");
|
||||
NMConnection *connection;
|
||||
|
@ -627,11 +627,11 @@ vpn_type_activated (GtkListBox *list, GtkWidget *row, NetConnectionEditor *edito
|
|||
NMSettingConnection *s_con;
|
||||
|
||||
if (!strcmp (service_name, "import")) {
|
||||
vpn_import (GTK_WINDOW (editor), vpn_import_complete, editor);
|
||||
vpn_import (GTK_WINDOW (self), vpn_import_complete, self);
|
||||
return;
|
||||
}
|
||||
|
||||
connection = complete_vpn_connection (editor, NULL);
|
||||
connection = complete_vpn_connection (self, NULL);
|
||||
s_vpn = nm_connection_get_setting_vpn (connection);
|
||||
g_object_set (s_vpn, NM_SETTING_VPN_SERVICE_TYPE, service_name, NULL);
|
||||
|
||||
|
@ -640,11 +640,11 @@ vpn_type_activated (GtkListBox *list, GtkWidget *row, NetConnectionEditor *edito
|
|||
g_object_set (s_con, NM_SETTING_CONNECTION_AUTOCONNECT, FALSE, NULL);
|
||||
nm_setting_connection_add_permission (s_con, "user", g_get_user_name (), NULL);
|
||||
|
||||
finish_add_connection (editor, connection);
|
||||
finish_add_connection (self, connection);
|
||||
}
|
||||
|
||||
static void
|
||||
select_vpn_type (NetConnectionEditor *editor, GtkListBox *list)
|
||||
select_vpn_type (NetConnectionEditor *self, GtkListBox *list)
|
||||
{
|
||||
GSList *vpn_plugins, *iter;
|
||||
GList *l;
|
||||
|
@ -721,46 +721,46 @@ select_vpn_type (NetConnectionEditor *editor, GtkListBox *list)
|
|||
gtk_container_add (GTK_CONTAINER (list), row);
|
||||
|
||||
g_signal_connect (list, "row-activated",
|
||||
G_CALLBACK (vpn_type_activated), editor);
|
||||
G_CALLBACK (vpn_type_activated), self);
|
||||
}
|
||||
|
||||
static void
|
||||
net_connection_editor_add_connection (NetConnectionEditor *editor)
|
||||
net_connection_editor_add_connection (NetConnectionEditor *self)
|
||||
{
|
||||
GtkContainer *frame;
|
||||
GtkListBox *list;
|
||||
|
||||
frame = GTK_CONTAINER (editor->add_connection_frame);
|
||||
frame = GTK_CONTAINER (self->add_connection_frame);
|
||||
|
||||
list = GTK_LIST_BOX (gtk_list_box_new ());
|
||||
gtk_list_box_set_selection_mode (list, GTK_SELECTION_NONE);
|
||||
gtk_list_box_set_header_func (list, cc_list_box_update_header_func, NULL, NULL);
|
||||
|
||||
select_vpn_type (editor, list);
|
||||
select_vpn_type (self, list);
|
||||
|
||||
gtk_widget_show_all (GTK_WIDGET (list));
|
||||
gtk_container_add (frame, GTK_WIDGET (list));
|
||||
|
||||
gtk_notebook_set_current_page (editor->toplevel_notebook, 1);
|
||||
gtk_widget_hide (GTK_WIDGET (editor->apply_button));
|
||||
gtk_window_set_title (GTK_WINDOW (editor), _("Add VPN"));
|
||||
gtk_notebook_set_current_page (self->toplevel_notebook, 1);
|
||||
gtk_widget_hide (GTK_WIDGET (self->apply_button));
|
||||
gtk_window_set_title (GTK_WINDOW (self), _("Add VPN"));
|
||||
}
|
||||
|
||||
static void
|
||||
permission_changed (NMClient *client,
|
||||
NMClientPermission permission,
|
||||
NMClientPermissionResult result,
|
||||
NetConnectionEditor *editor)
|
||||
NetConnectionEditor *self)
|
||||
{
|
||||
if (permission != NM_CLIENT_PERMISSION_SETTINGS_MODIFY_SYSTEM)
|
||||
return;
|
||||
|
||||
if (result == NM_CLIENT_PERMISSION_RESULT_YES || result == NM_CLIENT_PERMISSION_RESULT_AUTH)
|
||||
editor->can_modify = TRUE;
|
||||
self->can_modify = TRUE;
|
||||
else
|
||||
editor->can_modify = FALSE;
|
||||
self->can_modify = FALSE;
|
||||
|
||||
validate (editor);
|
||||
validate (self);
|
||||
}
|
||||
|
||||
NetConnectionEditor *
|
||||
|
@ -770,44 +770,44 @@ net_connection_editor_new (GtkWindow *parent_window,
|
|||
NMAccessPoint *ap,
|
||||
NMClient *client)
|
||||
{
|
||||
NetConnectionEditor *editor;
|
||||
NetConnectionEditor *self;
|
||||
|
||||
editor = g_object_new (NET_TYPE_CONNECTION_EDITOR,
|
||||
/* This doesn't seem to work for a template, so it is also hardcoded. */
|
||||
"use-header-bar", 1,
|
||||
NULL);
|
||||
self = g_object_new (NET_TYPE_CONNECTION_EDITOR,
|
||||
/* This doesn't seem to work for a template, so it is also hardcoded. */
|
||||
"use-header-bar", 1,
|
||||
NULL);
|
||||
|
||||
if (parent_window) {
|
||||
editor->parent_window = GTK_WIDGET (g_object_ref (parent_window));
|
||||
gtk_window_set_transient_for (GTK_WINDOW (editor),
|
||||
self->parent_window = GTK_WIDGET (g_object_ref (parent_window));
|
||||
gtk_window_set_transient_for (GTK_WINDOW (self),
|
||||
parent_window);
|
||||
}
|
||||
if (ap)
|
||||
editor->ap = g_object_ref (ap);
|
||||
self->ap = g_object_ref (ap);
|
||||
if (device)
|
||||
editor->device = g_object_ref (device);
|
||||
editor->client = g_object_ref (client);
|
||||
self->device = g_object_ref (device);
|
||||
self->client = g_object_ref (client);
|
||||
|
||||
editor->can_modify = nm_client_get_permission_result (client, NM_CLIENT_PERMISSION_SETTINGS_MODIFY_SYSTEM);
|
||||
editor->permission_id = g_signal_connect (editor->client, "permission-changed",
|
||||
G_CALLBACK (permission_changed), editor);
|
||||
self->can_modify = nm_client_get_permission_result (client, NM_CLIENT_PERMISSION_SETTINGS_MODIFY_SYSTEM);
|
||||
self->permission_id = g_signal_connect (self->client, "permission-changed",
|
||||
G_CALLBACK (permission_changed), self);
|
||||
|
||||
if (connection)
|
||||
net_connection_editor_set_connection (editor, connection);
|
||||
net_connection_editor_set_connection (self, connection);
|
||||
else
|
||||
net_connection_editor_add_connection (editor);
|
||||
net_connection_editor_add_connection (self);
|
||||
|
||||
return editor;
|
||||
return self;
|
||||
}
|
||||
|
||||
void
|
||||
net_connection_editor_run (NetConnectionEditor *editor)
|
||||
net_connection_editor_run (NetConnectionEditor *self)
|
||||
{
|
||||
if (!editor_is_initialized (editor)) {
|
||||
editor->show_when_initialized = TRUE;
|
||||
if (!editor_is_initialized (self)) {
|
||||
self->show_when_initialized = TRUE;
|
||||
return;
|
||||
}
|
||||
gtk_window_present (GTK_WINDOW (editor));
|
||||
gtk_window_present (GTK_WINDOW (self));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -816,7 +816,7 @@ forgotten_cb (GObject *source_object,
|
|||
gpointer user_data)
|
||||
{
|
||||
NMRemoteConnection *connection = NM_REMOTE_CONNECTION (source_object);
|
||||
NetConnectionEditor *editor = user_data;
|
||||
NetConnectionEditor *self = user_data;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
if (!nm_remote_connection_delete_finish (connection, res, &error)) {
|
||||
|
@ -827,29 +827,29 @@ forgotten_cb (GObject *source_object,
|
|||
return;
|
||||
}
|
||||
|
||||
cancel_editing (editor);
|
||||
cancel_editing (self);
|
||||
}
|
||||
|
||||
void
|
||||
net_connection_editor_forget (NetConnectionEditor *editor)
|
||||
net_connection_editor_forget (NetConnectionEditor *self)
|
||||
{
|
||||
nm_remote_connection_delete_async (NM_REMOTE_CONNECTION (editor->orig_connection),
|
||||
NULL, forgotten_cb, editor);
|
||||
nm_remote_connection_delete_async (NM_REMOTE_CONNECTION (self->orig_connection),
|
||||
NULL, forgotten_cb, self);
|
||||
}
|
||||
|
||||
void
|
||||
net_connection_editor_reset (NetConnectionEditor *editor)
|
||||
net_connection_editor_reset (NetConnectionEditor *self)
|
||||
{
|
||||
g_autoptr(GVariant) settings = NULL;
|
||||
|
||||
settings = nm_connection_to_dbus (editor->orig_connection, NM_CONNECTION_SERIALIZE_ALL);
|
||||
nm_connection_replace_settings (editor->connection, settings, NULL);
|
||||
settings = nm_connection_to_dbus (self->orig_connection, NM_CONNECTION_SERIALIZE_ALL);
|
||||
nm_connection_replace_settings (self->connection, settings, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
net_connection_editor_set_title (NetConnectionEditor *editor,
|
||||
net_connection_editor_set_title (NetConnectionEditor *self,
|
||||
const gchar *title)
|
||||
{
|
||||
gtk_window_set_title (GTK_WINDOW (editor), title);
|
||||
editor->title_set = TRUE;
|
||||
gtk_window_set_title (GTK_WINDOW (self), title);
|
||||
self->title_set = TRUE;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue