|
Packit Service |
d328f3 |
// SPDX-License-Identifier: GPL-2.0+
|
|
Packit Service |
d328f3 |
/* NetworkManager Applet -- allow user control over networking
|
|
Packit Service |
d328f3 |
*
|
|
Packit Service |
d328f3 |
* Dan Williams <dcbw@redhat.com>
|
|
Packit Service |
d328f3 |
*
|
|
Packit Service |
d328f3 |
* Copyright 2008 - 2017 Red Hat, Inc.
|
|
Packit Service |
d328f3 |
*/
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
#include "nm-default.h"
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
#include <netinet/in.h>
|
|
Packit Service |
d328f3 |
#include <sys/socket.h>
|
|
Packit Service |
d328f3 |
#include <arpa/inet.h>
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
#include <NetworkManager.h>
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
#include "applet-dialogs.h"
|
|
Packit Service |
d328f3 |
#include "utils.h"
|
|
Packit Service |
d328f3 |
#include "nma-bar-code-widget.h"
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
static void
|
|
Packit Service |
d328f3 |
info_dialog_show_error (const char *err)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
GtkWidget *dialog;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
dialog = gtk_message_dialog_new_with_markup (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
|
|
Packit Service |
d328f3 |
"%s\n\n%s", _("Error displaying connection information:"), err);
|
|
Packit Service |
d328f3 |
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER_ALWAYS);
|
|
Packit Service |
d328f3 |
gtk_window_present (GTK_WINDOW (dialog));
|
|
Packit Service |
d328f3 |
g_signal_connect_swapped (dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog);
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
static char *
|
|
Packit Service |
d328f3 |
ip4_address_as_string (guint32 ip)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
char *ip_string;
|
|
Packit Service |
d328f3 |
struct in_addr tmp_addr;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
tmp_addr.s_addr = ip;
|
|
Packit Service |
d328f3 |
ip_string = g_malloc0 (INET_ADDRSTRLEN + 1);
|
|
Packit Service |
d328f3 |
if (!inet_ntop (AF_INET, &tmp_addr, ip_string, INET_ADDRSTRLEN))
|
|
Packit Service |
d328f3 |
strcpy (ip_string, "(none)");
|
|
Packit Service |
d328f3 |
return ip_string;
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
static char *
|
|
Packit Service |
d328f3 |
get_eap_label (NMSettingWirelessSecurity *sec,
|
|
Packit Service |
d328f3 |
NMSetting8021x *s_8021x)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
GString *str = NULL;
|
|
Packit Service |
d328f3 |
char *phase2_str = NULL;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
if (sec) {
|
|
Packit Service |
d328f3 |
const char *key_mgmt = nm_setting_wireless_security_get_key_mgmt (sec);
|
|
Packit Service |
d328f3 |
const char *auth_alg = nm_setting_wireless_security_get_auth_alg (sec);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
if (!strcmp (key_mgmt, "ieee8021x")) {
|
|
Packit Service |
d328f3 |
if (auth_alg && !strcmp (auth_alg, "leap"))
|
|
Packit Service |
d328f3 |
str = g_string_new (_("LEAP"));
|
|
Packit Service |
d328f3 |
else
|
|
Packit Service |
d328f3 |
str = g_string_new (_("Dynamic WEP"));
|
|
Packit Service |
d328f3 |
} else if (!strcmp (key_mgmt, "wpa-eap"))
|
|
Packit Service |
d328f3 |
str = g_string_new (_("WPA/WPA2"));
|
|
Packit Service |
d328f3 |
else
|
|
Packit Service |
d328f3 |
return NULL;
|
|
Packit Service |
d328f3 |
} else if (s_8021x)
|
|
Packit Service |
d328f3 |
str = g_string_new ("802.1x");
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
if (!s_8021x)
|
|
Packit Service |
d328f3 |
goto out;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
if (nm_setting_802_1x_get_num_eap_methods (s_8021x)) {
|
|
Packit Service |
d328f3 |
char *eap_str = g_ascii_strup (nm_setting_802_1x_get_eap_method (s_8021x, 0), -1);
|
|
Packit Service |
d328f3 |
g_string_append_printf (str, ", EAP-%s", eap_str);
|
|
Packit Service |
d328f3 |
g_free (eap_str);
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
if (nm_setting_802_1x_get_phase2_auth (s_8021x))
|
|
Packit Service |
d328f3 |
phase2_str = g_ascii_strup (nm_setting_802_1x_get_phase2_auth (s_8021x), -1);
|
|
Packit Service |
d328f3 |
else if (nm_setting_802_1x_get_phase2_autheap (s_8021x))
|
|
Packit Service |
d328f3 |
phase2_str = g_ascii_strup (nm_setting_802_1x_get_phase2_autheap (s_8021x), -1);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
if (phase2_str) {
|
|
Packit Service |
d328f3 |
g_string_append (str, ", ");
|
|
Packit Service |
d328f3 |
g_string_append (str, phase2_str);
|
|
Packit Service |
d328f3 |
g_free (phase2_str);
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
out:
|
|
Packit Service |
d328f3 |
return g_string_free (str, FALSE);
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
static NMConnection *
|
|
Packit Service |
d328f3 |
get_connection_for_active_path (NMApplet *applet, const char *active_path)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
NMActiveConnection *active = NULL;
|
|
Packit Service |
d328f3 |
const GPtrArray *connections;
|
|
Packit Service |
d328f3 |
int i;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
if (active_path == NULL)
|
|
Packit Service |
d328f3 |
return NULL;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
connections = nm_client_get_active_connections (applet->nm_client);
|
|
Packit Service |
d328f3 |
for (i = 0; connections && (i < connections->len); i++) {
|
|
Packit Service |
d328f3 |
NMActiveConnection *candidate = g_ptr_array_index (connections, i);
|
|
Packit Service |
d328f3 |
const char *ac_path = nm_object_get_path (NM_OBJECT (candidate));
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
if (g_strcmp0 (ac_path, active_path) == 0) {
|
|
Packit Service |
d328f3 |
active = candidate;
|
|
Packit Service |
d328f3 |
break;
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
return active ? (NMConnection *) nm_active_connection_get_connection (active) : NULL;
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
static GtkWidget *
|
|
Packit Service |
d328f3 |
create_info_label (const char *text)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
GtkWidget *label;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
label = gtk_label_new (text ? text : "");
|
|
Packit Service |
d328f3 |
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.0);
|
|
Packit Service |
d328f3 |
gtk_style_context_add_class (gtk_widget_get_style_context (label),
|
|
Packit Service |
d328f3 |
"dim-label");
|
|
Packit Service |
d328f3 |
return label;
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
static GtkWidget *
|
|
Packit Service |
d328f3 |
create_info_value (const char *text)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
GtkWidget *label;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
label = gtk_label_new (text ? text : "");
|
|
Packit Service |
d328f3 |
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
|
|
Packit Service |
d328f3 |
gtk_label_set_selectable (GTK_LABEL (label), TRUE);
|
|
Packit Service |
d328f3 |
return label;
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
static GtkWidget *
|
|
Packit Service |
d328f3 |
create_info_group_label (const char *text, gboolean selectable)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
GtkWidget *label;
|
|
Packit Service |
d328f3 |
char *markup;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
markup = g_markup_printf_escaped ("%s", text);
|
|
Packit Service |
d328f3 |
label = gtk_label_new (markup);
|
|
Packit Service |
d328f3 |
gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
|
|
Packit Service |
d328f3 |
g_free (markup);
|
|
Packit Service |
d328f3 |
return label;
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
static GtkWidget *
|
|
Packit Service |
d328f3 |
create_more_addresses_widget (const GPtrArray *addresses)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
GtkWidget *expander, *label, *text_view, *child;
|
|
Packit Service |
d328f3 |
GtkTextBuffer *buffer;
|
|
Packit Service |
d328f3 |
GtkWidget *scrolled_window;
|
|
Packit Service |
d328f3 |
int i;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* Create the expander */
|
|
Packit Service |
d328f3 |
expander = gtk_expander_new (_("More addresses"));
|
|
Packit Service |
d328f3 |
gtk_widget_set_halign (expander, GTK_ALIGN_START);
|
|
Packit Service |
d328f3 |
label = gtk_expander_get_label_widget (GTK_EXPANDER (expander));
|
|
Packit Service |
d328f3 |
gtk_widget_set_margin_top (label, 2);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* Create the text view widget and add additional addresses to it */
|
|
Packit Service |
d328f3 |
text_view = gtk_text_view_new ();
|
|
Packit Service |
d328f3 |
gtk_text_view_set_editable (GTK_TEXT_VIEW (text_view), FALSE);
|
|
Packit Service |
d328f3 |
gtk_text_view_set_left_margin (GTK_TEXT_VIEW (text_view), 20);
|
|
Packit Service |
d328f3 |
gtk_expander_set_spacing (GTK_EXPANDER (expander), 4);
|
|
Packit Service |
d328f3 |
child = text_view;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
|
|
Packit Service |
d328f3 |
for (i = 1; addresses && (i < addresses->len); i++) {
|
|
Packit Service |
d328f3 |
NMIPAddress *addr = (NMIPAddress *) g_ptr_array_index (addresses, i);
|
|
Packit Service |
d328f3 |
char *addr_text = g_strdup_printf ("%s / %d",
|
|
Packit Service |
d328f3 |
nm_ip_address_get_address (addr),
|
|
Packit Service |
d328f3 |
nm_ip_address_get_prefix (addr));
|
|
Packit Service |
d328f3 |
if (i != 1)
|
|
Packit Service |
d328f3 |
gtk_text_buffer_insert_at_cursor (buffer, "\n", -1);
|
|
Packit Service |
d328f3 |
gtk_text_buffer_insert_at_cursor (buffer, addr_text, -1);
|
|
Packit Service |
d328f3 |
g_free (addr_text);
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
if (addresses->len > 5) {
|
|
Packit Service |
d328f3 |
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
|
Packit Service |
d328f3 |
gtk_widget_set_size_request (scrolled_window, -1, 80);
|
|
Packit Service |
d328f3 |
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
|
|
Packit Service |
d328f3 |
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
|
|
Packit Service |
d328f3 |
gtk_container_add (GTK_CONTAINER (scrolled_window), text_view);
|
|
Packit Service |
d328f3 |
child = scrolled_window;
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
gtk_container_add (GTK_CONTAINER (expander), child);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
return expander;
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
static GtkWidget *
|
|
Packit Service |
d328f3 |
create_info_label_security (NMConnection *connection)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
NMSettingConnection *s_con;
|
|
Packit Service |
d328f3 |
char *label = NULL;
|
|
Packit Service |
d328f3 |
GtkWidget *w = NULL;
|
|
Packit Service |
d328f3 |
const char *connection_type;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
s_con = nm_connection_get_setting_connection (connection);
|
|
Packit Service |
d328f3 |
g_assert (s_con);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
connection_type = nm_setting_connection_get_connection_type (s_con);
|
|
Packit Service |
d328f3 |
if (!strcmp (connection_type, NM_SETTING_WIRELESS_SETTING_NAME)) {
|
|
Packit Service |
d328f3 |
NMSettingWirelessSecurity *s_wireless_sec;
|
|
Packit Service |
d328f3 |
NMSetting8021x *s_8021x;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
s_wireless_sec = nm_connection_get_setting_wireless_security (connection);
|
|
Packit Service |
d328f3 |
s_8021x = nm_connection_get_setting_802_1x (connection);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
if (s_wireless_sec) {
|
|
Packit Service |
d328f3 |
const char *key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wireless_sec);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
if (!strcmp (key_mgmt, "none"))
|
|
Packit Service |
d328f3 |
label = g_strdup (_("WEP"));
|
|
Packit Service |
d328f3 |
else if (!strcmp (key_mgmt, "wpa-none"))
|
|
Packit Service |
d328f3 |
label = g_strdup (_("WPA/WPA2"));
|
|
Packit Service |
d328f3 |
else if (!strcmp (key_mgmt, "wpa-psk"))
|
|
Packit Service |
d328f3 |
label = g_strdup (_("WPA/WPA2"));
|
|
Packit Service |
d328f3 |
else if (!strcmp (key_mgmt, "sae"))
|
|
Packit Service |
d328f3 |
label = g_strdup (_("WPA3"));
|
|
Packit Service |
d328f3 |
else
|
|
Packit Service |
d328f3 |
label = get_eap_label (s_wireless_sec, s_8021x);
|
|
Packit Service |
d328f3 |
} else {
|
|
Packit Service |
d328f3 |
label = g_strdup (C_("Wi-Fi/Ethernet security", "None"));
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
} else if (!strcmp (connection_type, NM_SETTING_WIRED_SETTING_NAME)) {
|
|
Packit Service |
d328f3 |
NMSetting8021x *s_8021x;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
s_8021x = nm_connection_get_setting_802_1x (connection);
|
|
Packit Service |
d328f3 |
if (s_8021x)
|
|
Packit Service |
d328f3 |
label = get_eap_label (NULL, s_8021x);
|
|
Packit Service |
d328f3 |
else
|
|
Packit Service |
d328f3 |
label = g_strdup (C_("Wi-Fi/Ethernet security", "None"));
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
if (label)
|
|
Packit Service |
d328f3 |
w = create_info_value (label);
|
|
Packit Service |
d328f3 |
g_free (label);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
return w;
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
typedef struct {
|
|
Packit Service |
d328f3 |
NMDevice *device;
|
|
Packit Service |
d328f3 |
GtkWidget *label;
|
|
Packit Service |
d328f3 |
guint32 id;
|
|
Packit Service |
d328f3 |
} LabelInfo;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
static void
|
|
Packit Service |
d328f3 |
device_destroyed (gpointer data, GObject *device_ptr)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
LabelInfo *info = data;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* Device is destroyed, notify handler won't fire
|
|
Packit Service |
d328f3 |
* anymore anyway. Let the label destroy handler
|
|
Packit Service |
d328f3 |
* know it doesn't have to disconnect the callback.
|
|
Packit Service |
d328f3 |
*/
|
|
Packit Service |
d328f3 |
info->device = NULL;
|
|
Packit Service |
d328f3 |
info->id = 0;
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
static void
|
|
Packit Service |
d328f3 |
label_destroyed (gpointer data, GObject *label_ptr)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
LabelInfo *info = data;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* Remove the notify handler from the device */
|
|
Packit Service |
d328f3 |
if (info->device) {
|
|
Packit Service |
d328f3 |
if (info->id)
|
|
Packit Service |
d328f3 |
g_signal_handler_disconnect (info->device, info->id);
|
|
Packit Service |
d328f3 |
/* destroy our info data */
|
|
Packit Service |
d328f3 |
g_object_weak_unref (G_OBJECT (info->device), device_destroyed, info);
|
|
Packit Service |
d328f3 |
memset (info, 0, sizeof (LabelInfo));
|
|
Packit Service |
d328f3 |
g_free (info);
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
static void
|
|
Packit Service |
d328f3 |
label_info_new (NMDevice *device,
|
|
Packit Service |
d328f3 |
GtkWidget *label,
|
|
Packit Service |
d328f3 |
const char *notify_prop,
|
|
Packit Service |
d328f3 |
GCallback callback)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
LabelInfo *info;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
info = g_malloc0 (sizeof (LabelInfo));
|
|
Packit Service |
d328f3 |
info->device = device;
|
|
Packit Service |
d328f3 |
info->label = label;
|
|
Packit Service |
d328f3 |
info->id = g_signal_connect (device, notify_prop, callback, label);
|
|
Packit Service |
d328f3 |
g_object_weak_ref (G_OBJECT (label), label_destroyed, info);
|
|
Packit Service |
d328f3 |
g_object_weak_ref (G_OBJECT (device), device_destroyed, info);
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
static void
|
|
Packit Service |
d328f3 |
bitrate_changed_cb (GObject *device, GParamSpec *pspec, gpointer user_data)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
GtkWidget *speed_label = GTK_WIDGET (user_data);
|
|
Packit Service |
d328f3 |
guint32 bitrate = 0;
|
|
Packit Service |
d328f3 |
char *str = NULL;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
bitrate = nm_device_wifi_get_bitrate (NM_DEVICE_WIFI (device)) / 1000;
|
|
Packit Service |
d328f3 |
if (bitrate)
|
|
Packit Service |
d328f3 |
str = g_strdup_printf (_("%u Mb/s"), bitrate);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
gtk_label_set_text (GTK_LABEL (speed_label), str ? str : C_("Speed", "Unknown"));
|
|
Packit Service |
d328f3 |
g_free (str);
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
static void
|
|
Packit Service |
d328f3 |
display_ip4_info (NMIPAddress *def_addr, const GPtrArray *addresses, GtkGrid *grid, int *row)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
GtkWidget *desc_widget, *data_widget = NULL;
|
|
Packit Service |
d328f3 |
AtkObject *desc_object, *data_object = NULL;
|
|
Packit Service |
d328f3 |
guint32 hostmask, network, bcast, netmask;
|
|
Packit Service |
d328f3 |
const char *addr;
|
|
Packit Service |
d328f3 |
char *str;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* Address */
|
|
Packit Service |
d328f3 |
addr = def_addr ? nm_ip_address_get_address (def_addr) : C_("Address", "Unknown");
|
|
Packit Service |
d328f3 |
desc_widget = create_info_label (_("IP Address"));
|
|
Packit Service |
d328f3 |
desc_object = gtk_widget_get_accessible (desc_widget);
|
|
Packit Service |
d328f3 |
data_widget = create_info_value (addr);
|
|
Packit Service |
d328f3 |
data_object = gtk_widget_get_accessible (data_widget);
|
|
Packit Service |
d328f3 |
atk_object_add_relationship (desc_object, ATK_RELATION_LABEL_FOR, data_object);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, desc_widget, 0, *row, 1, 1);
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, data_widget, 1, *row, 1, 1);
|
|
Packit Service |
d328f3 |
(*row)++;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* Broadcast */
|
|
Packit Service |
d328f3 |
if (def_addr) {
|
|
Packit Service |
d328f3 |
guint32 addr_bin;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
nm_ip_address_get_address_binary (def_addr, &addr_bin);
|
|
Packit Service |
d328f3 |
netmask = nm_utils_ip4_prefix_to_netmask (nm_ip_address_get_prefix (def_addr));
|
|
Packit Service |
d328f3 |
network = addr_bin & netmask;
|
|
Packit Service |
d328f3 |
hostmask = ~netmask;
|
|
Packit Service |
d328f3 |
bcast = network | hostmask;
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
str = def_addr ? ip4_address_as_string (bcast) : g_strdup (C_("Address", "Unknown"));
|
|
Packit Service |
d328f3 |
desc_widget = create_info_label (_("Broadcast Address"));
|
|
Packit Service |
d328f3 |
desc_object = gtk_widget_get_accessible (desc_widget);
|
|
Packit Service |
d328f3 |
data_widget = create_info_value (str);
|
|
Packit Service |
d328f3 |
data_object = gtk_widget_get_accessible (data_widget);
|
|
Packit Service |
d328f3 |
atk_object_add_relationship (desc_object, ATK_RELATION_LABEL_FOR, data_object);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, desc_widget, 0, *row, 1, 1);
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, data_widget, 1, *row, 1, 1);
|
|
Packit Service |
d328f3 |
g_free (str);
|
|
Packit Service |
d328f3 |
(*row)++;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* Prefix */
|
|
Packit Service |
d328f3 |
str = def_addr ? ip4_address_as_string (netmask) : g_strdup (C_("Subnet Mask", "Unknown"));
|
|
Packit Service |
d328f3 |
desc_widget = create_info_label (_("Subnet Mask"));
|
|
Packit Service |
d328f3 |
desc_object = gtk_widget_get_accessible (desc_widget);
|
|
Packit Service |
d328f3 |
data_widget = create_info_value (str);
|
|
Packit Service |
d328f3 |
data_object = gtk_widget_get_accessible (data_widget);
|
|
Packit Service |
d328f3 |
atk_object_add_relationship (desc_object, ATK_RELATION_LABEL_FOR, data_object);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, desc_widget, 0, *row, 1, 1);
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, data_widget, 1, *row, 1, 1);
|
|
Packit Service |
d328f3 |
g_free (str);
|
|
Packit Service |
d328f3 |
(*row)++;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* More Addresses */
|
|
Packit Service |
d328f3 |
if (addresses && addresses->len > 1) {
|
|
Packit Service |
d328f3 |
data_widget = create_more_addresses_widget (addresses);
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, data_widget, 1, *row, 1, 1);
|
|
Packit Service |
d328f3 |
(*row)++;
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
static void
|
|
Packit Service |
d328f3 |
display_ip6_info (NMIPAddress *def6_addr,
|
|
Packit Service |
d328f3 |
const GPtrArray *addresses,
|
|
Packit Service |
d328f3 |
const char *method,
|
|
Packit Service |
d328f3 |
GtkGrid *grid,
|
|
Packit Service |
d328f3 |
int *row)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
GtkWidget *desc_widget, *data_widget = NULL;
|
|
Packit Service |
d328f3 |
AtkObject *desc_object, *data_object = NULL;
|
|
Packit Service |
d328f3 |
char *str;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
if (!def6_addr)
|
|
Packit Service |
d328f3 |
return;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* Address */
|
|
Packit Service |
d328f3 |
str = g_strdup_printf ("%s/%d",
|
|
Packit Service |
d328f3 |
nm_ip_address_get_address (def6_addr),
|
|
Packit Service |
d328f3 |
nm_ip_address_get_prefix (def6_addr));
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
desc_widget = create_info_label (_("IP Address"));
|
|
Packit Service |
d328f3 |
desc_object = gtk_widget_get_accessible (desc_widget);
|
|
Packit Service |
d328f3 |
data_widget = create_info_value (str);
|
|
Packit Service |
d328f3 |
data_object = gtk_widget_get_accessible (data_widget);
|
|
Packit Service |
d328f3 |
atk_object_add_relationship (desc_object, ATK_RELATION_LABEL_FOR, data_object);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, desc_widget, 0, *row, 1, 1);
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, data_widget, 1, *row, 1, 1);
|
|
Packit Service |
d328f3 |
g_free (str);
|
|
Packit Service |
d328f3 |
(*row)++;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* More Addresses */
|
|
Packit Service |
d328f3 |
if (addresses && addresses->len > 1) {
|
|
Packit Service |
d328f3 |
data_widget = create_more_addresses_widget (addresses);
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, data_widget, 1, *row, 1, 1);
|
|
Packit Service |
d328f3 |
(*row)++;
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
static void
|
|
Packit Service |
d328f3 |
display_dns_info (const char * const *dns, GtkGrid *grid, int *row)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
GtkWidget *desc_widget, *data_widget = NULL;
|
|
Packit Service |
d328f3 |
AtkObject *desc_object, *data_object = NULL;
|
|
Packit Service |
d328f3 |
char *label[] = { N_("Primary DNS"), N_("Secondary DNS"), N_("Tertiary DNS") };
|
|
Packit Service |
d328f3 |
int i;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
for (i = 0; dns && dns[i] && i < 3; i++) {
|
|
Packit Service |
d328f3 |
desc_widget = create_info_label (_(label[i]));
|
|
Packit Service |
d328f3 |
desc_object = gtk_widget_get_accessible (desc_widget);
|
|
Packit Service |
d328f3 |
data_widget = create_info_value (dns[i]);
|
|
Packit Service |
d328f3 |
data_object = gtk_widget_get_accessible (data_widget);
|
|
Packit Service |
d328f3 |
atk_object_add_relationship (desc_object, ATK_RELATION_LABEL_FOR, data_object);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, desc_widget, 0, *row, 1, 1);
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, data_widget, 1, *row, 1, 1);
|
|
Packit Service |
d328f3 |
(*row)++;
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
static void
|
|
Packit Service |
d328f3 |
_got_wsec_secrets (GObject *source_object, GAsyncResult *res, gpointer user_data)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
NMRemoteConnection *connection = NM_REMOTE_CONNECTION (source_object);
|
|
Packit Service |
d328f3 |
gs_unref_object GtkWidget *data_widget = GTK_WIDGET (user_data);
|
|
Packit Service |
d328f3 |
gs_unref_variant GVariant *secrets = NULL;
|
|
Packit Service |
d328f3 |
NMSettingWirelessSecurity *s_wsec;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
secrets = nm_remote_connection_get_secrets_finish (connection, res, NULL);
|
|
Packit Service |
d328f3 |
if (!secrets)
|
|
Packit Service |
d328f3 |
return;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
if (!nm_connection_update_secrets (NM_CONNECTION (connection),
|
|
Packit Service |
d328f3 |
NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
|
|
Packit Service |
d328f3 |
secrets,
|
|
Packit Service |
d328f3 |
NULL)) {
|
|
Packit Service |
d328f3 |
return;
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
s_wsec = nm_connection_get_setting_wireless_security (NM_CONNECTION (connection));
|
|
Packit Service |
d328f3 |
if (!s_wsec)
|
|
Packit Service |
d328f3 |
return;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
gtk_label_set_text (GTK_LABEL (data_widget),
|
|
Packit Service |
d328f3 |
nm_setting_wireless_security_get_psk (s_wsec));
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
static void
|
|
Packit Service |
d328f3 |
info_dialog_add_page (GtkNotebook *notebook,
|
|
Packit Service |
d328f3 |
NMConnection *connection,
|
|
Packit Service |
d328f3 |
NMDevice *device)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
GtkGrid *grid;
|
|
Packit Service |
d328f3 |
guint32 speed = 0;
|
|
Packit Service |
d328f3 |
char *str;
|
|
Packit Service |
d328f3 |
const char *iface, *method = NULL;
|
|
Packit Service |
d328f3 |
NMIPConfig *ip4_config;
|
|
Packit Service |
d328f3 |
NMIPConfig *ip6_config = NULL;
|
|
Packit Service |
d328f3 |
const char * const *dns;
|
|
Packit Service |
d328f3 |
const char * const *dns6;
|
|
Packit Service |
d328f3 |
NMIPAddress *def_addr = NULL;
|
|
Packit Service |
d328f3 |
NMIPAddress *def6_addr = NULL;
|
|
Packit Service |
d328f3 |
const char *gateway;
|
|
Packit Service |
d328f3 |
NMSettingIPConfig *s_ip;
|
|
Packit Service |
d328f3 |
int row = 0;
|
|
Packit Service |
d328f3 |
GtkWidget* speed_label, *sec_label, *desc_widget, *data_widget = NULL;
|
|
Packit Service |
d328f3 |
GPtrArray *addresses;
|
|
Packit Service |
d328f3 |
gboolean show_security = FALSE;
|
|
Packit Service |
d328f3 |
gboolean is_hotspot = FALSE;
|
|
Packit Service |
d328f3 |
NMSettingWireless *s_wireless;
|
|
Packit Service |
d328f3 |
GBytes *ssid = NULL;
|
|
Packit Service |
d328f3 |
gs_free char *ssid_utf8 = NULL;
|
|
Packit Service |
d328f3 |
AtkObject *desc_object, *data_object = NULL;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
grid = GTK_GRID (gtk_grid_new ());
|
|
Packit Service |
d328f3 |
gtk_grid_set_column_spacing (grid, 12);
|
|
Packit Service |
d328f3 |
gtk_grid_set_row_spacing (grid, 6);
|
|
Packit Service |
d328f3 |
gtk_container_set_border_width (GTK_CONTAINER (grid), 12);
|
|
Packit Service |
d328f3 |
gtk_grid_set_column_homogeneous (grid, TRUE);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* Interface */
|
|
Packit Service |
d328f3 |
iface = nm_device_get_iface (device);
|
|
Packit Service |
d328f3 |
if (NM_IS_DEVICE_ETHERNET (device)) {
|
|
Packit Service |
d328f3 |
str = g_strdup_printf (_("Ethernet (%s)"), iface);
|
|
Packit Service |
d328f3 |
show_security = TRUE;
|
|
Packit Service |
d328f3 |
} else if (NM_IS_DEVICE_WIFI (device)) {
|
|
Packit Service |
d328f3 |
str = g_strdup_printf (_("802.11 Wi-Fi (%s)"), iface);
|
|
Packit Service |
d328f3 |
show_security = TRUE;
|
|
Packit Service |
d328f3 |
} else if (NM_IS_DEVICE_MODEM (device)) {
|
|
Packit Service |
d328f3 |
NMDeviceModemCapabilities caps;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device));
|
|
Packit Service |
d328f3 |
if (caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS)
|
|
Packit Service |
d328f3 |
str = g_strdup_printf (_("GSM (%s)"), iface);
|
|
Packit Service |
d328f3 |
else if (caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)
|
|
Packit Service |
d328f3 |
str = g_strdup_printf (_("CDMA (%s)"), iface);
|
|
Packit Service |
d328f3 |
else
|
|
Packit Service |
d328f3 |
str = g_strdup_printf (_("Mobile Broadband (%s)"), iface);
|
|
Packit Service |
d328f3 |
} else
|
|
Packit Service |
d328f3 |
str = g_strdup (iface);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/*--- General ---*/
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, create_info_group_label (_("General"), FALSE), 0, row, 2, 1);
|
|
Packit Service |
d328f3 |
row++;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
desc_widget = create_info_label (_("Interface"));
|
|
Packit Service |
d328f3 |
desc_object = gtk_widget_get_accessible (desc_widget);
|
|
Packit Service |
d328f3 |
data_widget = create_info_value (str);
|
|
Packit Service |
d328f3 |
data_object = gtk_widget_get_accessible (data_widget);
|
|
Packit Service |
d328f3 |
atk_object_add_relationship (desc_object, ATK_RELATION_LABEL_FOR, data_object);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, desc_widget, 0, row, 1, 1);
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, data_widget, 1, row, 1, 1);
|
|
Packit Service |
d328f3 |
g_free (str);
|
|
Packit Service |
d328f3 |
row++;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* Hardware address */
|
|
Packit Service |
d328f3 |
str = g_strdup (nm_device_get_hw_address (device));
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
if (str) {
|
|
Packit Service |
d328f3 |
desc_widget = create_info_label (_("Hardware Address"));
|
|
Packit Service |
d328f3 |
desc_object = gtk_widget_get_accessible (desc_widget);
|
|
Packit Service |
d328f3 |
data_widget = create_info_value (str);
|
|
Packit Service |
d328f3 |
data_object = gtk_widget_get_accessible (data_widget);
|
|
Packit Service |
d328f3 |
atk_object_add_relationship (desc_object, ATK_RELATION_LABEL_FOR, data_object);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, desc_widget, 0, row, 1, 1);
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, data_widget, 1, row, 1, 1);
|
|
Packit Service |
d328f3 |
g_free (str);
|
|
Packit Service |
d328f3 |
row++;
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* Driver */
|
|
Packit Service |
d328f3 |
desc_widget = create_info_label (_("Driver"));
|
|
Packit Service |
d328f3 |
desc_object = gtk_widget_get_accessible (desc_widget);
|
|
Packit Service |
d328f3 |
data_widget = create_info_value (nm_device_get_driver (device));
|
|
Packit Service |
d328f3 |
data_object = gtk_widget_get_accessible (data_widget);
|
|
Packit Service |
d328f3 |
atk_object_add_relationship (desc_object, ATK_RELATION_LABEL_FOR, data_object);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, desc_widget, 0, row, 1, 1);
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, data_widget, 1, row, 1, 1);
|
|
Packit Service |
d328f3 |
row++;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
speed_label = create_info_value ("");
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* Speed */
|
|
Packit Service |
d328f3 |
str = NULL;
|
|
Packit Service |
d328f3 |
if (NM_IS_DEVICE_ETHERNET (device)) {
|
|
Packit Service |
d328f3 |
/* Ethernet speed in Mb/s */
|
|
Packit Service |
d328f3 |
speed = nm_device_ethernet_get_speed (NM_DEVICE_ETHERNET (device));
|
|
Packit Service |
d328f3 |
} else if (NM_IS_DEVICE_WIFI (device)) {
|
|
Packit Service |
d328f3 |
/* Wi-Fi speed in Kb/s */
|
|
Packit Service |
d328f3 |
speed = nm_device_wifi_get_bitrate (NM_DEVICE_WIFI (device)) / 1000;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
label_info_new (device,
|
|
Packit Service |
d328f3 |
speed_label,
|
|
Packit Service |
d328f3 |
"notify::" NM_DEVICE_WIFI_BITRATE,
|
|
Packit Service |
d328f3 |
G_CALLBACK (bitrate_changed_cb));
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
if (speed)
|
|
Packit Service |
d328f3 |
str = g_strdup_printf (_("%u Mb/s"), speed);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
gtk_label_set_text (GTK_LABEL(speed_label), str ? str : C_("Speed", "Unknown"));
|
|
Packit Service |
d328f3 |
g_free (str);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
desc_widget = create_info_label (_("Speed"));
|
|
Packit Service |
d328f3 |
desc_object = gtk_widget_get_accessible (desc_widget);
|
|
Packit Service |
d328f3 |
data_object = gtk_widget_get_accessible (speed_label);
|
|
Packit Service |
d328f3 |
atk_object_add_relationship (desc_object, ATK_RELATION_LABEL_FOR, data_object);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, desc_widget, 0, row, 1, 1);
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, speed_label, 1, row, 1, 1);
|
|
Packit Service |
d328f3 |
row++;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* Security */
|
|
Packit Service |
d328f3 |
if (show_security) {
|
|
Packit Service |
d328f3 |
sec_label = create_info_label_security (connection);
|
|
Packit Service |
d328f3 |
if (sec_label) {
|
|
Packit Service |
d328f3 |
desc_widget = create_info_label (_("Security"));
|
|
Packit Service |
d328f3 |
desc_object = gtk_widget_get_accessible (desc_widget);
|
|
Packit Service |
d328f3 |
data_object = gtk_widget_get_accessible (sec_label);
|
|
Packit Service |
d328f3 |
atk_object_add_relationship (desc_object, ATK_RELATION_LABEL_FOR, data_object);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, desc_widget,
|
|
Packit Service |
d328f3 |
0, row, 1, 1);
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, sec_label,
|
|
Packit Service |
d328f3 |
1, row, 1, 1);
|
|
Packit Service |
d328f3 |
row++;
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* Empty line */
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, gtk_label_new (""), 0, row, 2, 1);
|
|
Packit Service |
d328f3 |
row++;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/*--- IPv4 ---*/
|
|
Packit Service |
d328f3 |
s_ip = nm_connection_get_setting_ip4_config (connection);
|
|
Packit Service |
d328f3 |
if (s_ip) {
|
|
Packit Service |
d328f3 |
method = nm_setting_ip_config_get_method (s_ip);
|
|
Packit Service |
d328f3 |
if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED) == 0)
|
|
Packit Service |
d328f3 |
is_hotspot = TRUE;
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, create_info_group_label (_("IPv4"), FALSE), 0, row, 2, 1);
|
|
Packit Service |
d328f3 |
row++;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
ip4_config = nm_device_get_ip4_config (device);
|
|
Packit Service |
d328f3 |
if (ip4_config) {
|
|
Packit Service |
d328f3 |
addresses = nm_ip_config_get_addresses (ip4_config);
|
|
Packit Service |
d328f3 |
gateway = nm_ip_config_get_gateway (ip4_config);
|
|
Packit Service |
d328f3 |
} else {
|
|
Packit Service |
d328f3 |
addresses = NULL;
|
|
Packit Service |
d328f3 |
gateway = NULL;
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
if (addresses && addresses->len > 0)
|
|
Packit Service |
d328f3 |
def_addr = (NMIPAddress *) g_ptr_array_index (addresses, 0);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
display_ip4_info (def_addr, addresses, grid, &row;;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* Gateway */
|
|
Packit Service |
d328f3 |
if (gateway && *gateway) {
|
|
Packit Service |
d328f3 |
desc_widget = create_info_label (_("Default Route"));
|
|
Packit Service |
d328f3 |
desc_object = gtk_widget_get_accessible (desc_widget);
|
|
Packit Service |
d328f3 |
data_widget = create_info_value (gateway);
|
|
Packit Service |
d328f3 |
data_object = gtk_widget_get_accessible (data_widget);
|
|
Packit Service |
d328f3 |
atk_object_add_relationship (desc_object, ATK_RELATION_LABEL_FOR, data_object);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, desc_widget, 0, row, 1, 1);
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, data_widget, 1, row, 1, 1);
|
|
Packit Service |
d328f3 |
row++;
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* DNS */
|
|
Packit Service |
d328f3 |
dns = def_addr ? nm_ip_config_get_nameservers (ip4_config) : NULL;
|
|
Packit Service |
d328f3 |
display_dns_info (dns, grid, &row;;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* Empty line */
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, gtk_label_new (""), 0, row, 2, 1);
|
|
Packit Service |
d328f3 |
row++;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/*--- IPv6 ---*/
|
|
Packit Service |
d328f3 |
s_ip = nm_connection_get_setting_ip6_config (connection);
|
|
Packit Service |
d328f3 |
if (s_ip) {
|
|
Packit Service |
d328f3 |
method = nm_setting_ip_config_get_method (s_ip);
|
|
Packit Service |
d328f3 |
if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_SHARED) == 0)
|
|
Packit Service |
d328f3 |
is_hotspot = TRUE;
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
if (method && strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE) != 0) {
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, create_info_group_label (_("IPv6"), FALSE), 0, row, 2, 1);
|
|
Packit Service |
d328f3 |
row++;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
ip6_config = nm_device_get_ip6_config (device);
|
|
Packit Service |
d328f3 |
if (ip6_config) {
|
|
Packit Service |
d328f3 |
addresses = nm_ip_config_get_addresses (ip6_config);
|
|
Packit Service |
d328f3 |
gateway = nm_ip_config_get_gateway (ip6_config);
|
|
Packit Service |
d328f3 |
} else {
|
|
Packit Service |
d328f3 |
addresses = NULL;
|
|
Packit Service |
d328f3 |
gateway = NULL;
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
if (addresses && addresses->len > 0)
|
|
Packit Service |
d328f3 |
def6_addr = (NMIPAddress *) g_ptr_array_index (addresses, 0);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
display_ip6_info (def6_addr, addresses, method, grid, &row;;
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* Gateway */
|
|
Packit Service |
d328f3 |
if (gateway && *gateway) {
|
|
Packit Service |
d328f3 |
desc_widget = create_info_label (_("Default Route"));
|
|
Packit Service |
d328f3 |
desc_object = gtk_widget_get_accessible (desc_widget);
|
|
Packit Service |
d328f3 |
data_widget = create_info_value (gateway);
|
|
Packit Service |
d328f3 |
data_object = gtk_widget_get_accessible (data_widget);
|
|
Packit Service |
d328f3 |
atk_object_add_relationship (desc_object, ATK_RELATION_LABEL_FOR, data_object);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, desc_widget, 0, row, 1, 1);
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, data_widget, 1, row, 1, 1);
|
|
Packit Service |
d328f3 |
row++;
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* DNS */
|
|
Packit Service |
d328f3 |
dns6 = def6_addr ? nm_ip_config_get_nameservers (ip6_config) : NULL;
|
|
Packit Service |
d328f3 |
display_dns_info (dns6, grid, &row;;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* Wi-Fi */
|
|
Packit Service |
d328f3 |
if (!NM_IS_DEVICE_WIFI (device))
|
|
Packit Service |
d328f3 |
is_hotspot = FALSE;
|
|
Packit Service |
d328f3 |
if (is_hotspot) {
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, gtk_label_new (""), 0, row, 2, 1);
|
|
Packit Service |
d328f3 |
row++;
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, create_info_group_label (_("Hotspot"), FALSE), 0, row, 2, 1);
|
|
Packit Service |
d328f3 |
row++;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
s_wireless = nm_connection_get_setting_wireless (connection);
|
|
Packit Service |
d328f3 |
ssid = nm_setting_wireless_get_ssid (s_wireless);
|
|
Packit Service |
d328f3 |
ssid_utf8 = nm_utils_ssid_to_utf8 (g_bytes_get_data (ssid, NULL), g_bytes_get_size (ssid));
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
desc_widget = create_info_label (_("Network"));
|
|
Packit Service |
d328f3 |
desc_object = gtk_widget_get_accessible (desc_widget);
|
|
Packit Service |
d328f3 |
data_widget = create_info_value (ssid_utf8);
|
|
Packit Service |
d328f3 |
data_object = gtk_widget_get_accessible (data_widget);
|
|
Packit Service |
d328f3 |
atk_object_add_relationship (desc_object, ATK_RELATION_LABEL_FOR, data_object);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, desc_widget, 0, row, 1, 1);
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, data_widget, 1, row, 1, 1);
|
|
Packit Service |
d328f3 |
row++;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
if (nm_connection_get_setting_wireless_security (connection)) {
|
|
Packit Service |
d328f3 |
desc_widget = create_info_label (_("Password"));
|
|
Packit Service |
d328f3 |
desc_object = gtk_widget_get_accessible (desc_widget);
|
|
Packit Service |
d328f3 |
data_widget = create_info_value ("\xe2\x80\x94" /* em dash */);
|
|
Packit Service |
d328f3 |
data_object = gtk_widget_get_accessible (data_widget);
|
|
Packit Service |
d328f3 |
atk_object_add_relationship (desc_object, ATK_RELATION_LABEL_FOR, data_object);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, desc_widget, 0, row, 1, 1);
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, data_widget, 1, row, 1, 1);
|
|
Packit Service |
d328f3 |
row++;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
nm_remote_connection_get_secrets_async (NM_REMOTE_CONNECTION (connection),
|
|
Packit Service |
d328f3 |
NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
|
|
Packit Service |
d328f3 |
NULL,
|
|
Packit Service |
d328f3 |
_got_wsec_secrets,
|
|
Packit Service |
d328f3 |
g_object_ref (data_widget));
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, nma_bar_code_widget_new (connection), 0, row, 2, 1);
|
|
Packit Service |
d328f3 |
row++;
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
desc_widget = NULL;
|
|
Packit Service |
d328f3 |
desc_object = NULL;
|
|
Packit Service |
d328f3 |
data_widget = NULL;
|
|
Packit Service |
d328f3 |
data_object = NULL;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
gtk_notebook_append_page (notebook, GTK_WIDGET (grid),
|
|
Packit Service |
d328f3 |
gtk_label_new (nm_connection_get_id (connection)));
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
gtk_widget_show_all (GTK_WIDGET (grid));
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
static char *
|
|
Packit Service |
d328f3 |
get_vpn_connection_type (NMConnection *connection)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
const char *type, *p;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* The service type is in format of "org.freedesktop.NetworkManager.vpnc".
|
|
Packit Service |
d328f3 |
* Extract end part after last dot, e.g. "vpnc" */
|
|
Packit Service |
d328f3 |
type = nm_setting_vpn_get_service_type (nm_connection_get_setting_vpn (connection));
|
|
Packit Service |
d328f3 |
p = strrchr (type, '.');
|
|
Packit Service |
d328f3 |
return g_strdup (p ? p + 1 : type);
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* VPN parameters can be found at:
|
|
Packit Service |
d328f3 |
* http://git.gnome.org/browse/network-manager-openvpn/tree/src/nm-openvpn-service.h
|
|
Packit Service |
d328f3 |
* http://git.gnome.org/browse/network-manager-vpnc/tree/src/nm-vpnc-service.h
|
|
Packit Service |
d328f3 |
* http://git.gnome.org/browse/network-manager-pptp/tree/src/nm-pptp-service.h
|
|
Packit Service |
d328f3 |
* http://git.gnome.org/browse/network-manager-openconnect/tree/src/nm-openconnect-service.h
|
|
Packit Service |
d328f3 |
* http://git.gnome.org/browse/network-manager-openswan/tree/src/nm-openswan-service.h
|
|
Packit Service |
d328f3 |
* See also 'properties' directory in these plugins.
|
|
Packit Service |
d328f3 |
*/
|
|
Packit Service |
d328f3 |
static const gchar *
|
|
Packit Service |
d328f3 |
find_vpn_gateway_key (const char *vpn_type)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
if (g_strcmp0 (vpn_type, "openvpn") == 0) return "remote";
|
|
Packit Service |
d328f3 |
if (g_strcmp0 (vpn_type, "vpnc") == 0) return "IPSec gateway";
|
|
Packit Service |
d328f3 |
if (g_strcmp0 (vpn_type, "pptp") == 0) return "gateway";
|
|
Packit Service |
d328f3 |
if (g_strcmp0 (vpn_type, "openconnect") == 0) return "gateway";
|
|
Packit Service |
d328f3 |
if (g_strcmp0 (vpn_type, "openswan") == 0) return "right";
|
|
Packit Service |
d328f3 |
return "";
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
static const gchar *
|
|
Packit Service |
d328f3 |
find_vpn_username_key (const char *vpn_type)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
if (g_strcmp0 (vpn_type, "openvpn") == 0) return "username";
|
|
Packit Service |
d328f3 |
if (g_strcmp0 (vpn_type, "vpnc") == 0) return "Xauth username";
|
|
Packit Service |
d328f3 |
if (g_strcmp0 (vpn_type, "pptp") == 0) return "user";
|
|
Packit Service |
d328f3 |
if (g_strcmp0 (vpn_type, "openconnect") == 0) return "username";
|
|
Packit Service |
d328f3 |
if (g_strcmp0 (vpn_type, "openswan") == 0) return "leftxauthusername";
|
|
Packit Service |
d328f3 |
return "";
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
enum VpnDataItem {
|
|
Packit Service |
d328f3 |
VPN_DATA_ITEM_GATEWAY,
|
|
Packit Service |
d328f3 |
VPN_DATA_ITEM_USERNAME
|
|
Packit Service |
d328f3 |
};
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
static const gchar *
|
|
Packit Service |
d328f3 |
get_vpn_data_item (NMConnection *connection, enum VpnDataItem vpn_data_item)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
const char *key;
|
|
Packit Service |
d328f3 |
char *type = get_vpn_connection_type (connection);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
switch (vpn_data_item) {
|
|
Packit Service |
d328f3 |
case VPN_DATA_ITEM_GATEWAY:
|
|
Packit Service |
d328f3 |
key = find_vpn_gateway_key (type);
|
|
Packit Service |
d328f3 |
break;
|
|
Packit Service |
d328f3 |
case VPN_DATA_ITEM_USERNAME:
|
|
Packit Service |
d328f3 |
key = find_vpn_username_key (type);
|
|
Packit Service |
d328f3 |
break;
|
|
Packit Service |
d328f3 |
default:
|
|
Packit Service |
d328f3 |
key = "";
|
|
Packit Service |
d328f3 |
break;
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
g_free (type);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
return nm_setting_vpn_get_data_item (nm_connection_get_setting_vpn (connection), key);
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
static void
|
|
Packit Service |
d328f3 |
info_dialog_add_page_for_vpn (GtkNotebook *notebook,
|
|
Packit Service |
d328f3 |
NMConnection *connection,
|
|
Packit Service |
d328f3 |
NMActiveConnection *active,
|
|
Packit Service |
d328f3 |
NMConnection *parent_con)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
GtkGrid *grid;
|
|
Packit Service |
d328f3 |
char *str;
|
|
Packit Service |
d328f3 |
int row = 0;
|
|
Packit Service |
d328f3 |
NMIPConfig *ip4_config;
|
|
Packit Service |
d328f3 |
NMIPConfig *ip6_config;
|
|
Packit Service |
d328f3 |
const char * const *dns;
|
|
Packit Service |
d328f3 |
const char * const *dns6;
|
|
Packit Service |
d328f3 |
NMIPAddress *def_addr = NULL;
|
|
Packit Service |
d328f3 |
NMIPAddress *def6_addr = NULL;
|
|
Packit Service |
d328f3 |
GPtrArray *addresses;
|
|
Packit Service |
d328f3 |
NMSettingIPConfig *s_ip6;
|
|
Packit Service |
d328f3 |
const char *method = NULL;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
grid = GTK_GRID (gtk_grid_new ());
|
|
Packit Service |
d328f3 |
gtk_grid_set_column_spacing (grid, 12);
|
|
Packit Service |
d328f3 |
gtk_grid_set_row_spacing (grid, 6);
|
|
Packit Service |
d328f3 |
gtk_container_set_border_width (GTK_CONTAINER (grid), 12);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/*--- General ---*/
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, create_info_group_label (_("General"), FALSE), 0, row, 2, 1);
|
|
Packit Service |
d328f3 |
row++;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
str = get_vpn_connection_type (connection);
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, create_info_label (_("VPN Type")), 0, row, 1, 1);
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, create_info_value (str), 1, row, 1, 1);
|
|
Packit Service |
d328f3 |
g_free (str);
|
|
Packit Service |
d328f3 |
row++;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, create_info_label (_("VPN Gateway")), 0, row, 1, 1);
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, create_info_value (get_vpn_data_item (connection, VPN_DATA_ITEM_GATEWAY)), 1, row, 1, 1);
|
|
Packit Service |
d328f3 |
row++;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, create_info_label (_("VPN Username")), 0, row, 1, 1);
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, create_info_value (get_vpn_data_item (connection, VPN_DATA_ITEM_USERNAME)), 1, row, 1, 1);
|
|
Packit Service |
d328f3 |
row++;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, create_info_label (_("VPN Banner")), 0, row, 1, 1);
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, create_info_value (nm_vpn_connection_get_banner (NM_VPN_CONNECTION (active))), 1, row, 1, 1);
|
|
Packit Service |
d328f3 |
row++;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, create_info_label (_("Base Connection")), 0, row, 1, 1);
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, create_info_value (parent_con ? nm_connection_get_id (parent_con) : _("Unknown")), 1, row, 1, 1);
|
|
Packit Service |
d328f3 |
row++;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* Empty line */
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, gtk_label_new (""), 0, row, 2, 1);
|
|
Packit Service |
d328f3 |
row++;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/*--- IPv4 ---*/
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, create_info_group_label (_("IPv4"), FALSE), 0, row, 2, 1);
|
|
Packit Service |
d328f3 |
row++;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
ip4_config = nm_active_connection_get_ip4_config (active);
|
|
Packit Service |
d328f3 |
addresses = nm_ip_config_get_addresses (ip4_config);
|
|
Packit Service |
d328f3 |
if (addresses && addresses->len > 0)
|
|
Packit Service |
d328f3 |
def_addr = (NMIPAddress *) g_ptr_array_index (addresses, 0);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
display_ip4_info (def_addr, addresses, grid, &row;;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* DNS */
|
|
Packit Service |
d328f3 |
dns = def_addr ? nm_ip_config_get_nameservers (ip4_config) : NULL;
|
|
Packit Service |
d328f3 |
display_dns_info (dns, grid, &row;;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* Empty line */
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, gtk_label_new (""), 0, row, 2, 1);
|
|
Packit Service |
d328f3 |
row++;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/*--- IPv6 ---*/
|
|
Packit Service |
d328f3 |
ip6_config = nm_active_connection_get_ip6_config (active);
|
|
Packit Service |
d328f3 |
if (ip6_config) {
|
|
Packit Service |
d328f3 |
s_ip6 = nm_connection_get_setting_ip6_config (connection);
|
|
Packit Service |
d328f3 |
if (s_ip6)
|
|
Packit Service |
d328f3 |
method = nm_setting_ip_config_get_method (s_ip6);
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
if (method && strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE) != 0) {
|
|
Packit Service |
d328f3 |
gtk_grid_attach (grid, create_info_group_label (_("IPv6"), FALSE), 0, row, 2, 1);
|
|
Packit Service |
d328f3 |
row++;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
addresses = nm_ip_config_get_addresses (ip6_config);
|
|
Packit Service |
d328f3 |
if (addresses && addresses->len > 0)
|
|
Packit Service |
d328f3 |
def6_addr = (NMIPAddress *) g_ptr_array_index (addresses, 0);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* IPv6 Address */
|
|
Packit Service |
d328f3 |
display_ip6_info (def6_addr, addresses, method, grid, &row;;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* DNS */
|
|
Packit Service |
d328f3 |
dns6 = def6_addr ? nm_ip_config_get_nameservers (ip6_config) : NULL;
|
|
Packit Service |
d328f3 |
display_dns_info (dns6, grid, &row;;
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
gtk_notebook_append_page (notebook, GTK_WIDGET (grid),
|
|
Packit Service |
d328f3 |
gtk_label_new (nm_connection_get_id (connection)));
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
gtk_widget_show_all (GTK_WIDGET (grid));
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
#ifndef NM_REMOTE_CONNECTION_FLAGS
|
|
Packit Service |
d328f3 |
/*
|
|
Packit Service |
d328f3 |
* NetworkManager < 1.12 compatibility.
|
|
Packit Service |
d328f3 |
* If you look outside and see flying cars, remove this.
|
|
Packit Service |
d328f3 |
*/
|
|
Packit Service |
d328f3 |
typedef enum {
|
|
Packit Service |
d328f3 |
NM_SETTINGS_CONNECTION_FLAG_NM_GENERATED = 2,
|
|
Packit Service |
d328f3 |
} NMSettingsConnectionFlags;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
static NMSettingsConnectionFlags
|
|
Packit Service |
d328f3 |
nm_remote_connection_get_flags (NMRemoteConnection *connection)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
NMSettingsConnectionFlags flags;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
if (!g_object_class_find_property (G_OBJECT_GET_CLASS (connection), "flags"))
|
|
Packit Service |
d328f3 |
return 0;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
g_object_get (connection, "flags", &flags, NULL);
|
|
Packit Service |
d328f3 |
return flags;
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
#else
|
|
Packit Service |
d328f3 |
#define nm_remote_connection_get_flags(conn) \
|
|
Packit Service |
d328f3 |
NM_LIBNM_COMPAT_UNDEPRECATE (nm_remote_connection_get_flags (conn))
|
|
Packit Service |
d328f3 |
#endif
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
static int
|
|
Packit Service |
d328f3 |
_compare_active_connections (gconstpointer a, gconstpointer b)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
NMActiveConnection *ac_a = NM_ACTIVE_CONNECTION(*(NMActiveConnection **)a);
|
|
Packit Service |
d328f3 |
NMActiveConnection *ac_b = NM_ACTIVE_CONNECTION(*(NMActiveConnection **)b);
|
|
Packit Service |
d328f3 |
NMRemoteConnection *con_a = nm_active_connection_get_connection (ac_a);
|
|
Packit Service |
d328f3 |
NMRemoteConnection *con_b = nm_active_connection_get_connection (ac_b);
|
|
Packit Service |
d328f3 |
NMSettingIPConfig *s_ip;
|
|
Packit Service |
d328f3 |
int cmp = 0;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
if (con_a && nm_remote_connection_get_visible (con_a))
|
|
Packit Service |
d328f3 |
cmp--;
|
|
Packit Service |
d328f3 |
if (con_b && nm_remote_connection_get_visible (con_b))
|
|
Packit Service |
d328f3 |
cmp++;
|
|
Packit Service |
d328f3 |
if (cmp || !con_a || !con_b)
|
|
Packit Service |
d328f3 |
return cmp;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
s_ip = nm_connection_get_setting_ip6_config (NM_CONNECTION (con_a));
|
|
Packit Service |
d328f3 |
if (s_ip && strcmp (nm_setting_ip_config_get_method (s_ip), NM_SETTING_IP6_CONFIG_METHOD_SHARED) == 0)
|
|
Packit Service |
d328f3 |
cmp--;
|
|
Packit Service |
d328f3 |
s_ip = nm_connection_get_setting_ip6_config (NM_CONNECTION (con_b));
|
|
Packit Service |
d328f3 |
if (s_ip && strcmp (nm_setting_ip_config_get_method (s_ip), NM_SETTING_IP6_CONFIG_METHOD_SHARED) == 0)
|
|
Packit Service |
d328f3 |
cmp++;
|
|
Packit Service |
d328f3 |
if (cmp)
|
|
Packit Service |
d328f3 |
return cmp;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
s_ip = nm_connection_get_setting_ip4_config (NM_CONNECTION (con_a));
|
|
Packit Service |
d328f3 |
if (s_ip && strcmp (nm_setting_ip_config_get_method (s_ip), NM_SETTING_IP4_CONFIG_METHOD_SHARED) == 0)
|
|
Packit Service |
d328f3 |
cmp--;
|
|
Packit Service |
d328f3 |
s_ip = nm_connection_get_setting_ip4_config (NM_CONNECTION (con_b));
|
|
Packit Service |
d328f3 |
if (s_ip && strcmp (nm_setting_ip_config_get_method (s_ip), NM_SETTING_IP4_CONFIG_METHOD_SHARED) == 0)
|
|
Packit Service |
d328f3 |
cmp++;
|
|
Packit Service |
d328f3 |
if (cmp)
|
|
Packit Service |
d328f3 |
return cmp;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
if (nm_active_connection_get_default (ac_a))
|
|
Packit Service |
d328f3 |
cmp--;
|
|
Packit Service |
d328f3 |
if (nm_active_connection_get_default (ac_b))
|
|
Packit Service |
d328f3 |
cmp++;
|
|
Packit Service |
d328f3 |
if (cmp)
|
|
Packit Service |
d328f3 |
return cmp;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
if (nm_active_connection_get_default6 (ac_a))
|
|
Packit Service |
d328f3 |
cmp--;
|
|
Packit Service |
d328f3 |
if (nm_active_connection_get_default6 (ac_b))
|
|
Packit Service |
d328f3 |
cmp++;
|
|
Packit Service |
d328f3 |
if (cmp)
|
|
Packit Service |
d328f3 |
return cmp;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
if (nm_remote_connection_get_flags (con_a) & NM_SETTINGS_CONNECTION_FLAG_NM_GENERATED)
|
|
Packit Service |
d328f3 |
cmp++;
|
|
Packit Service |
d328f3 |
if (nm_remote_connection_get_flags (con_b) & NM_SETTINGS_CONNECTION_FLAG_NM_GENERATED)
|
|
Packit Service |
d328f3 |
cmp--;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
return cmp;
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
static GtkWidget *
|
|
Packit Service |
d328f3 |
info_dialog_update (NMApplet *applet)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
GtkNotebook *notebook;
|
|
Packit Service |
d328f3 |
const GPtrArray *connections;
|
|
Packit Service |
d328f3 |
gs_unref_ptrarray GPtrArray *sorted_connections = NULL;
|
|
Packit Service |
d328f3 |
int i;
|
|
Packit Service |
d328f3 |
int pages = 0;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
notebook = GTK_NOTEBOOK (GTK_WIDGET (gtk_builder_get_object (applet->info_dialog_ui, "info_notebook")));
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* Remove old pages */
|
|
Packit Service |
d328f3 |
for (i = gtk_notebook_get_n_pages (notebook); i > 0; i--)
|
|
Packit Service |
d328f3 |
gtk_notebook_remove_page (notebook, -1);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* Add new pages */
|
|
Packit Service |
d328f3 |
connections = nm_client_get_active_connections (applet->nm_client);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
sorted_connections = g_ptr_array_new_full (connections->len, NULL);
|
|
Packit Service |
d328f3 |
memcpy (sorted_connections->pdata, connections->pdata,
|
|
Packit Service |
d328f3 |
sizeof (void *) * connections->len);
|
|
Packit Service |
d328f3 |
sorted_connections->len = connections->len;
|
|
Packit Service |
d328f3 |
g_ptr_array_sort (sorted_connections, _compare_active_connections);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
for (i = 0; i < sorted_connections->len; i++) {
|
|
Packit Service |
d328f3 |
NMActiveConnection *active_connection = g_ptr_array_index (sorted_connections, i);
|
|
Packit Service |
d328f3 |
NMConnection *connection;
|
|
Packit Service |
d328f3 |
const GPtrArray *devices;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
if (nm_active_connection_get_state (active_connection) != NM_ACTIVE_CONNECTION_STATE_ACTIVATED)
|
|
Packit Service |
d328f3 |
continue;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
connection = (NMConnection *) nm_active_connection_get_connection (active_connection);
|
|
Packit Service |
d328f3 |
if (!connection) {
|
|
Packit Service |
d328f3 |
g_warning ("%s: couldn't find the default active connection's NMConnection!", __func__);
|
|
Packit Service |
d328f3 |
continue;
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
devices = nm_active_connection_get_devices (active_connection);
|
|
Packit Service |
d328f3 |
if (NM_IS_VPN_CONNECTION (active_connection)) {
|
|
Packit Service |
d328f3 |
const char *spec_object = nm_active_connection_get_specific_object_path (active_connection);
|
|
Packit Service |
d328f3 |
NMConnection *parent_con = get_connection_for_active_path (applet, spec_object);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
info_dialog_add_page_for_vpn (notebook, connection, active_connection, parent_con);
|
|
Packit Service |
d328f3 |
} else if (devices && devices->len > 0) {
|
|
Packit Service |
d328f3 |
info_dialog_add_page (notebook,
|
|
Packit Service |
d328f3 |
connection,
|
|
Packit Service |
d328f3 |
g_ptr_array_index (devices, 0));
|
|
Packit Service |
d328f3 |
} else {
|
|
Packit Service |
d328f3 |
g_warning ("Active connection %s had no devices and was not a VPN!",
|
|
Packit Service |
d328f3 |
nm_object_get_path (NM_OBJECT (active_connection)));
|
|
Packit Service |
d328f3 |
continue;
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
pages++;
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
if (pages == 0) {
|
|
Packit Service |
d328f3 |
/* Shouldn't really happen but ... */
|
|
Packit Service |
d328f3 |
info_dialog_show_error (_("No valid active connections found!"));
|
|
Packit Service |
d328f3 |
return NULL;
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
return GTK_WIDGET (gtk_builder_get_object (applet->info_dialog_ui, "info_dialog"));
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
void
|
|
Packit Service |
d328f3 |
applet_info_dialog_show (NMApplet *applet)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
GtkWidget *dialog;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
dialog = info_dialog_update (applet);
|
|
Packit Service |
d328f3 |
if (!dialog)
|
|
Packit Service |
d328f3 |
return;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
g_signal_connect (dialog, "delete-event", G_CALLBACK (gtk_widget_hide_on_delete), dialog);
|
|
Packit Service |
d328f3 |
g_signal_connect_swapped (dialog, "response", G_CALLBACK (gtk_widget_hide), dialog);
|
|
Packit Service |
d328f3 |
gtk_widget_realize (dialog);
|
|
Packit Service |
d328f3 |
gtk_window_set_position (GTK_WINDOW(dialog), GTK_WIN_POS_CENTER_ALWAYS);
|
|
Packit Service |
d328f3 |
gtk_window_present (GTK_WINDOW (dialog));
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
void
|
|
Packit Service |
d328f3 |
applet_about_dialog_show (NMApplet *applet)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
const char *authors[] = {
|
|
Packit Service |
d328f3 |
"Michael Biebl <biebl@debian.org>",
|
|
Packit Service |
d328f3 |
"Matthias Clasen <mclasen@redhat.com>",
|
|
Packit Service |
d328f3 |
"Piotr DrÄ
g <piotrdrag@gmail.com>",
|
|
Packit Service |
d328f3 |
"Pavel Å imerda <psimerda@redhat.com>",
|
|
Packit Service |
d328f3 |
"Alexander Sack <asac@ubuntu.com>",
|
|
Packit Service |
d328f3 |
"Aleksander Morgado <aleksander@lanedo.com>",
|
|
Packit Service |
d328f3 |
"Christian Persch <chpe@gnome.org>",
|
|
Packit Service |
d328f3 |
"Tambet Ingo <tambet@gmail.com>",
|
|
Packit Service |
d328f3 |
"Beniamino Galvani <bgalvani@redhat.com>",
|
|
Packit Service |
d328f3 |
"Lubomir Rintel <lkundrak@v3.sk>",
|
|
Packit Service |
d328f3 |
"Dan Winship <danw@gnome.org>",
|
|
Packit Service |
d328f3 |
"Dan Williams <dcbw@src.gnome.org>",
|
|
Packit Service |
d328f3 |
"Thomas Haller <thaller@redhat.com>",
|
|
Packit Service |
d328f3 |
"JiÅĆ KlimeÅ” <jklimes@redhat.com>",
|
|
Packit Service |
d328f3 |
"Dan Williams <dcbw@redhat.com>",
|
|
Packit Service |
d328f3 |
NULL
|
|
Packit Service |
d328f3 |
};
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
gtk_show_about_dialog (NULL,
|
|
Packit Service |
d328f3 |
"version", VERSION,
|
|
Packit Service |
d328f3 |
"copyright", _("Copyright \xc2\xa9 2004-2017 Red Hat, Inc.\n"
|
|
Packit Service |
d328f3 |
"Copyright \xc2\xa9 2005-2008 Novell, Inc.\n"
|
|
Packit Service |
d328f3 |
"and many other community contributors and translators"),
|
|
Packit Service |
d328f3 |
"comments", _("Notification area applet for managing your network devices and connections."),
|
|
Packit Service |
d328f3 |
"website", "http://www.gnome.org/projects/NetworkManager/",
|
|
Packit Service |
d328f3 |
"website-label", _("NetworkManager Website"),
|
|
Packit Service |
d328f3 |
"logo-icon-name", "network-workgroup",
|
|
Packit Service |
d328f3 |
"license-type", GTK_LICENSE_GPL_2_0,
|
|
Packit Service |
d328f3 |
"authors", authors,
|
|
Packit Service |
d328f3 |
"translator-credits", _("translator-credits"),
|
|
Packit Service |
d328f3 |
NULL);
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
GtkWidget *
|
|
Packit Service |
d328f3 |
applet_missing_ui_warning_dialog_show (void)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
GtkWidget *dialog;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
|
|
Packit Service |
d328f3 |
_("The NetworkManager Applet could not find some required resources (the .ui file was not found)."));
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* Bash focus-stealing prevention in the face */
|
|
Packit Service |
d328f3 |
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER_ALWAYS);
|
|
Packit Service |
d328f3 |
gtk_window_set_icon_name (GTK_WINDOW (dialog), "dialog-error");
|
|
Packit Service |
d328f3 |
gtk_window_set_title (GTK_WINDOW (dialog), _("Missing resources"));
|
|
Packit Service |
d328f3 |
gtk_widget_realize (dialog);
|
|
Packit Service |
d328f3 |
gtk_widget_show (dialog);
|
|
Packit Service |
d328f3 |
gtk_window_present (GTK_WINDOW (dialog));
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
g_signal_connect_swapped (dialog, "response",
|
|
Packit Service |
d328f3 |
G_CALLBACK (gtk_widget_destroy),
|
|
Packit Service |
d328f3 |
dialog);
|
|
Packit Service |
d328f3 |
return dialog;
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
GtkWidget *
|
|
Packit Service |
d328f3 |
applet_mobile_password_dialog_new (NMConnection *connection,
|
|
Packit Service |
d328f3 |
GtkEntry **out_secret_entry)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
GtkDialog *dialog;
|
|
Packit Service |
d328f3 |
GtkWidget *w;
|
|
Packit Service |
d328f3 |
GtkBox *box = NULL, *vbox = NULL;
|
|
Packit Service |
d328f3 |
NMSettingConnection *s_con;
|
|
Packit Service |
d328f3 |
char *tmp;
|
|
Packit Service |
d328f3 |
const char *id;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
dialog = GTK_DIALOG (gtk_dialog_new ());
|
|
Packit Service |
d328f3 |
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
|
Packit Service |
d328f3 |
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER_ALWAYS);
|
|
Packit Service |
d328f3 |
gtk_window_set_title (GTK_WINDOW (dialog), _("Mobile broadband network password"));
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
gtk_dialog_add_button (dialog, _("_Cancel"), GTK_RESPONSE_REJECT);
|
|
Packit Service |
d328f3 |
w = gtk_dialog_add_button (dialog, _("_OK"), GTK_RESPONSE_OK);
|
|
Packit Service |
d328f3 |
gtk_window_set_default (GTK_WINDOW (dialog), w);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
s_con = nm_connection_get_setting_connection (connection);
|
|
Packit Service |
d328f3 |
id = nm_setting_connection_get_id (s_con);
|
|
Packit Service |
d328f3 |
g_assert (id);
|
|
Packit Service |
d328f3 |
tmp = g_strdup_printf (_("A password is required to connect to ā%sā."), id);
|
|
Packit Service |
d328f3 |
w = gtk_label_new (tmp);
|
|
Packit Service |
d328f3 |
g_free (tmp);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
vbox = GTK_BOX (gtk_dialog_get_content_area (dialog));
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
gtk_box_pack_start (vbox, w, TRUE, TRUE, 0);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
w = gtk_alignment_new (0.5, 0.5, 0, 1.0);
|
|
Packit Service |
d328f3 |
gtk_box_pack_start (vbox, w, TRUE, TRUE, 0);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6));
|
|
Packit Service |
d328f3 |
gtk_container_set_border_width (GTK_CONTAINER (box), 6);
|
|
Packit Service |
d328f3 |
gtk_container_add (GTK_CONTAINER (w), GTK_WIDGET (box));
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
gtk_box_pack_start (box, gtk_label_new (_("Password:")), FALSE, FALSE, 0);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
w = gtk_entry_new ();
|
|
Packit Service |
d328f3 |
*out_secret_entry = GTK_ENTRY (w);
|
|
Packit Service |
d328f3 |
gtk_entry_set_activates_default (GTK_ENTRY (w), TRUE);
|
|
Packit Service |
d328f3 |
gtk_box_pack_start (box, w, FALSE, FALSE, 0);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
gtk_widget_show_all (GTK_WIDGET (vbox));
|
|
Packit Service |
d328f3 |
return GTK_WIDGET (dialog);
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/**********************************************************************/
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
static void
|
|
Packit Service |
d328f3 |
mpd_entry_changed (GtkWidget *widget, gpointer user_data)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
GtkWidget *dialog = GTK_WIDGET (user_data);
|
|
Packit Service |
d328f3 |
GtkBuilder *builder = g_object_get_data (G_OBJECT (dialog), "builder");
|
|
Packit Service |
d328f3 |
GtkWidget *entry;
|
|
Packit Service |
d328f3 |
guint32 minlen;
|
|
Packit Service |
d328f3 |
gboolean valid = FALSE;
|
|
Packit Service |
d328f3 |
const char *text, *text2 = NULL, *text3 = NULL;
|
|
Packit Service |
d328f3 |
gboolean match23;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
g_return_if_fail (builder != NULL);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
entry = GTK_WIDGET (gtk_builder_get_object (builder, "code1_entry"));
|
|
Packit Service |
d328f3 |
if (g_object_get_data (G_OBJECT (entry), "active")) {
|
|
Packit Service |
d328f3 |
minlen = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (entry), "minlen"));
|
|
Packit Service |
d328f3 |
text = gtk_entry_get_text (GTK_ENTRY (entry));
|
|
Packit Service |
d328f3 |
if (text && (strlen (text) < minlen))
|
|
Packit Service |
d328f3 |
goto done;
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
entry = GTK_WIDGET (gtk_builder_get_object (builder, "code2_entry"));
|
|
Packit Service |
d328f3 |
if (g_object_get_data (G_OBJECT (entry), "active")) {
|
|
Packit Service |
d328f3 |
minlen = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (entry), "minlen"));
|
|
Packit Service |
d328f3 |
text2 = gtk_entry_get_text (GTK_ENTRY (entry));
|
|
Packit Service |
d328f3 |
if (text2 && (strlen (text2) < minlen))
|
|
Packit Service |
d328f3 |
goto done;
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
entry = GTK_WIDGET (gtk_builder_get_object (builder, "code3_entry"));
|
|
Packit Service |
d328f3 |
if (g_object_get_data (G_OBJECT (entry), "active")) {
|
|
Packit Service |
d328f3 |
minlen = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (entry), "minlen"));
|
|
Packit Service |
d328f3 |
text3 = gtk_entry_get_text (GTK_ENTRY (entry));
|
|
Packit Service |
d328f3 |
if (text3 && (strlen (text3) < minlen))
|
|
Packit Service |
d328f3 |
goto done;
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* Validate 2 & 3 if they are supposed to be the same */
|
|
Packit Service |
d328f3 |
match23 = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (dialog), "match23"));
|
|
Packit Service |
d328f3 |
if (match23) {
|
|
Packit Service |
d328f3 |
if (!text2 || !text3 || strcmp (text2, text3))
|
|
Packit Service |
d328f3 |
goto done;
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
valid = TRUE;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
done:
|
|
Packit Service |
d328f3 |
/* Clear any error text in the progress label now that the user has changed something */
|
|
Packit Service |
d328f3 |
widget = GTK_WIDGET (gtk_builder_get_object (builder, "progress_label"));
|
|
Packit Service |
d328f3 |
gtk_label_set_text (GTK_LABEL (widget), "");
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
widget = GTK_WIDGET (gtk_builder_get_object (builder, "unlock_button"));
|
|
Packit Service |
d328f3 |
g_warn_if_fail (widget != NULL);
|
|
Packit Service |
d328f3 |
gtk_widget_set_sensitive (widget, valid);
|
|
Packit Service |
d328f3 |
if (valid)
|
|
Packit Service |
d328f3 |
gtk_widget_grab_default (widget);
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
static void
|
|
Packit Service |
d328f3 |
mpd_cancel_dialog (GtkDialog *dialog)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
gtk_dialog_response (dialog, GTK_RESPONSE_CANCEL);
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
static void
|
|
Packit Service |
d328f3 |
show_toggled_cb (GtkWidget *button, gpointer user_data)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
GtkWidget *dialog = GTK_WIDGET (user_data);
|
|
Packit Service |
d328f3 |
gboolean show;
|
|
Packit Service |
d328f3 |
GtkWidget *widget;
|
|
Packit Service |
d328f3 |
GtkBuilder *builder;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
builder = g_object_get_data (G_OBJECT (dialog), "builder");
|
|
Packit Service |
d328f3 |
g_return_if_fail (builder != NULL);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
show = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
widget = GTK_WIDGET (gtk_builder_get_object (builder, "code1_entry"));
|
|
Packit Service |
d328f3 |
gtk_entry_set_visibility (GTK_ENTRY (widget), show);
|
|
Packit Service |
d328f3 |
widget = GTK_WIDGET (gtk_builder_get_object (builder, "code2_entry"));
|
|
Packit Service |
d328f3 |
gtk_entry_set_visibility (GTK_ENTRY (widget), show);
|
|
Packit Service |
d328f3 |
widget = GTK_WIDGET (gtk_builder_get_object (builder, "code3_entry"));
|
|
Packit Service |
d328f3 |
gtk_entry_set_visibility (GTK_ENTRY (widget), show);
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
static void
|
|
Packit Service |
d328f3 |
mpd_entry_filter (GtkEditable *editable,
|
|
Packit Service |
d328f3 |
gchar *text,
|
|
Packit Service |
d328f3 |
gint length,
|
|
Packit Service |
d328f3 |
gint *position,
|
|
Packit Service |
d328f3 |
gpointer user_data)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
utils_filter_editable_on_insert_text (editable,
|
|
Packit Service |
d328f3 |
text, length, position, user_data,
|
|
Packit Service |
d328f3 |
utils_char_is_ascii_digit,
|
|
Packit Service |
d328f3 |
mpd_entry_filter);
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
const char *
|
|
Packit Service |
d328f3 |
applet_mobile_pin_dialog_get_entry1 (GtkWidget *dialog)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
GtkBuilder *builder;
|
|
Packit Service |
d328f3 |
GtkWidget *widget;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
g_return_val_if_fail (dialog != NULL, NULL);
|
|
Packit Service |
d328f3 |
builder = g_object_get_data (G_OBJECT (dialog), "builder");
|
|
Packit Service |
d328f3 |
g_return_val_if_fail (builder != NULL, NULL);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
widget = GTK_WIDGET (gtk_builder_get_object (builder, "code1_entry"));
|
|
Packit Service |
d328f3 |
return gtk_entry_get_text (GTK_ENTRY (widget));
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
const char *
|
|
Packit Service |
d328f3 |
applet_mobile_pin_dialog_get_entry2 (GtkWidget *dialog)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
GtkBuilder *builder;
|
|
Packit Service |
d328f3 |
GtkWidget *widget;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
g_return_val_if_fail (dialog != NULL, NULL);
|
|
Packit Service |
d328f3 |
builder = g_object_get_data (G_OBJECT (dialog), "builder");
|
|
Packit Service |
d328f3 |
g_return_val_if_fail (builder != NULL, NULL);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
widget = GTK_WIDGET (gtk_builder_get_object (builder, "code2_entry"));
|
|
Packit Service |
d328f3 |
return gtk_entry_get_text (GTK_ENTRY (widget));
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
gboolean
|
|
Packit Service |
d328f3 |
applet_mobile_pin_dialog_get_auto_unlock (GtkWidget *dialog)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
GtkBuilder *builder;
|
|
Packit Service |
d328f3 |
GtkWidget *widget;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
g_return_val_if_fail (dialog != NULL, FALSE);
|
|
Packit Service |
d328f3 |
builder = g_object_get_data (G_OBJECT (dialog), "builder");
|
|
Packit Service |
d328f3 |
g_return_val_if_fail (builder != NULL, FALSE);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
widget = GTK_WIDGET (gtk_builder_get_object (builder, "save_checkbutton"));
|
|
Packit Service |
d328f3 |
return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
void
|
|
Packit Service |
d328f3 |
applet_mobile_pin_dialog_start_spinner (GtkWidget *dialog, const char *text)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
GtkBuilder *builder;
|
|
Packit Service |
d328f3 |
GtkWidget *spinner, *widget, *hbox, *vbox;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
g_return_if_fail (dialog != NULL);
|
|
Packit Service |
d328f3 |
g_return_if_fail (text != NULL);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
builder = g_object_get_data (G_OBJECT (dialog), "builder");
|
|
Packit Service |
d328f3 |
g_return_if_fail (builder != NULL);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
spinner = gtk_spinner_new ();
|
|
Packit Service |
d328f3 |
g_return_if_fail (spinner != NULL);
|
|
Packit Service |
d328f3 |
g_object_set_data (G_OBJECT (dialog), "spinner", spinner);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
vbox = GTK_WIDGET (gtk_builder_get_object (builder, "spinner_vbox"));
|
|
Packit Service |
d328f3 |
gtk_container_add (GTK_CONTAINER (vbox), spinner);
|
|
Packit Service |
d328f3 |
gtk_widget_set_halign (spinner, GTK_ALIGN_FILL);
|
|
Packit Service |
d328f3 |
gtk_spinner_start (GTK_SPINNER (spinner));
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
widget = GTK_WIDGET (gtk_builder_get_object (builder, "progress_label"));
|
|
Packit Service |
d328f3 |
gtk_label_set_text (GTK_LABEL (widget), text);
|
|
Packit Service |
d328f3 |
gtk_widget_show (widget);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
hbox = GTK_WIDGET (gtk_builder_get_object (builder, "progress_hbox"));
|
|
Packit Service |
d328f3 |
gtk_widget_show_all (hbox);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* Desensitize everything while spinning */
|
|
Packit Service |
d328f3 |
widget = GTK_WIDGET (gtk_builder_get_object (builder, "code1_entry"));
|
|
Packit Service |
d328f3 |
gtk_widget_set_sensitive (widget, FALSE);
|
|
Packit Service |
d328f3 |
widget = GTK_WIDGET (gtk_builder_get_object (builder, "code2_entry"));
|
|
Packit Service |
d328f3 |
gtk_widget_set_sensitive (widget, FALSE);
|
|
Packit Service |
d328f3 |
widget = GTK_WIDGET (gtk_builder_get_object (builder, "code3_entry"));
|
|
Packit Service |
d328f3 |
gtk_widget_set_sensitive (widget, FALSE);
|
|
Packit Service |
d328f3 |
widget = GTK_WIDGET (gtk_builder_get_object (builder, "unlock_button"));
|
|
Packit Service |
d328f3 |
gtk_widget_set_sensitive (widget, FALSE);
|
|
Packit Service |
d328f3 |
widget = GTK_WIDGET (gtk_builder_get_object (builder, "unlock_cancel_button"));
|
|
Packit Service |
d328f3 |
gtk_widget_set_sensitive (widget, FALSE);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
widget = GTK_WIDGET (gtk_builder_get_object (builder, "show_password_checkbutton"));
|
|
Packit Service |
d328f3 |
gtk_widget_set_sensitive (widget, FALSE);
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
void
|
|
Packit Service |
d328f3 |
applet_mobile_pin_dialog_stop_spinner (GtkWidget *dialog, const char *text)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
GtkBuilder *builder;
|
|
Packit Service |
d328f3 |
GtkWidget *spinner, *widget, *vbox;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
g_return_if_fail (dialog != NULL);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
builder = g_object_get_data (G_OBJECT (dialog), "builder");
|
|
Packit Service |
d328f3 |
g_return_if_fail (builder != NULL);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
spinner = g_object_get_data (G_OBJECT (dialog), "spinner");
|
|
Packit Service |
d328f3 |
g_return_if_fail (spinner != NULL);
|
|
Packit Service |
d328f3 |
gtk_spinner_stop (GTK_SPINNER (spinner));
|
|
Packit Service |
d328f3 |
g_object_set_data (G_OBJECT (dialog), "spinner", NULL);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* Remove it from the vbox */
|
|
Packit Service |
d328f3 |
vbox = GTK_WIDGET (gtk_builder_get_object (builder, "spinner_vbox"));
|
|
Packit Service |
d328f3 |
gtk_container_remove (GTK_CONTAINER (vbox), spinner);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
widget = GTK_WIDGET (gtk_builder_get_object (builder, "progress_label"));
|
|
Packit Service |
d328f3 |
if (text) {
|
|
Packit Service |
d328f3 |
gtk_label_set_text (GTK_LABEL (widget), text);
|
|
Packit Service |
d328f3 |
gtk_widget_show (widget);
|
|
Packit Service |
d328f3 |
} else
|
|
Packit Service |
d328f3 |
gtk_widget_hide (widget);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* Resensitize stuff */
|
|
Packit Service |
d328f3 |
widget = GTK_WIDGET (gtk_builder_get_object (builder, "code1_entry"));
|
|
Packit Service |
d328f3 |
gtk_widget_set_sensitive (widget, TRUE);
|
|
Packit Service |
d328f3 |
widget = GTK_WIDGET (gtk_builder_get_object (builder, "code2_entry"));
|
|
Packit Service |
d328f3 |
gtk_widget_set_sensitive (widget, TRUE);
|
|
Packit Service |
d328f3 |
widget = GTK_WIDGET (gtk_builder_get_object (builder, "code3_entry"));
|
|
Packit Service |
d328f3 |
gtk_widget_set_sensitive (widget, TRUE);
|
|
Packit Service |
d328f3 |
widget = GTK_WIDGET (gtk_builder_get_object (builder, "unlock_button"));
|
|
Packit Service |
d328f3 |
gtk_widget_set_sensitive (widget, TRUE);
|
|
Packit Service |
d328f3 |
widget = GTK_WIDGET (gtk_builder_get_object (builder, "unlock_cancel_button"));
|
|
Packit Service |
d328f3 |
gtk_widget_set_sensitive (widget, TRUE);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
widget = GTK_WIDGET (gtk_builder_get_object (builder, "show_password_checkbutton"));
|
|
Packit Service |
d328f3 |
gtk_widget_set_sensitive (widget, TRUE);
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
GtkWidget *
|
|
Packit Service |
d328f3 |
applet_mobile_pin_dialog_new (const char *unlock_required,
|
|
Packit Service |
d328f3 |
const char *device_description)
|
|
Packit Service |
d328f3 |
{
|
|
Packit Service |
d328f3 |
char *str;
|
|
Packit Service |
d328f3 |
GtkWidget *dialog;
|
|
Packit Service |
d328f3 |
GtkWidget *widget;
|
|
Packit Service |
d328f3 |
GtkWidget *label;
|
|
Packit Service |
d328f3 |
GError *error = NULL;
|
|
Packit Service |
d328f3 |
GtkBuilder *builder;
|
|
Packit Service |
d328f3 |
const char *header = NULL;
|
|
Packit Service |
d328f3 |
const char *title = NULL;
|
|
Packit Service |
d328f3 |
const char *show_password_label = NULL;
|
|
Packit Service |
d328f3 |
char *desc = NULL;
|
|
Packit Service |
d328f3 |
const char *label1 = NULL, *label2 = NULL, *label3 = NULL;
|
|
Packit Service |
d328f3 |
gboolean match23 = FALSE;
|
|
Packit Service |
d328f3 |
guint32 label1_min = 0, label2_min = 0, label3_min = 0;
|
|
Packit Service |
d328f3 |
guint32 label1_max = 0, label2_max = 0, label3_max = 0;
|
|
Packit Service |
d328f3 |
gboolean puk = FALSE;
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
g_return_val_if_fail (unlock_required != NULL, NULL);
|
|
Packit Service |
d328f3 |
g_return_val_if_fail (!strcmp (unlock_required, "sim-pin") || !strcmp (unlock_required, "sim-puk"), NULL);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
builder = gtk_builder_new ();
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
if (!gtk_builder_add_from_resource (builder, "/org/freedesktop/network-manager-applet/gsm-unlock.ui", &error)) {
|
|
Packit Service |
d328f3 |
g_warning ("Couldn't load builder resource: %s", error->message);
|
|
Packit Service |
d328f3 |
g_error_free (error);
|
|
Packit Service |
d328f3 |
g_object_unref (builder);
|
|
Packit Service |
d328f3 |
return NULL;
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "unlock_dialog"));
|
|
Packit Service |
d328f3 |
if (!dialog) {
|
|
Packit Service |
d328f3 |
g_object_unref (builder);
|
|
Packit Service |
d328f3 |
g_return_val_if_fail (dialog != NULL, NULL);
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
g_object_set_data_full (G_OBJECT (dialog), "builder", builder, (GDestroyNotify) g_object_unref);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* Figure out the dialog text based on the required unlock code */
|
|
Packit Service |
d328f3 |
if (!strcmp (unlock_required, "sim-pin")) {
|
|
Packit Service |
d328f3 |
title = _("SIM PIN unlock required");
|
|
Packit Service |
d328f3 |
header = _("SIM PIN Unlock Required");
|
|
Packit Service |
d328f3 |
/* FIXME: some warning about # of times you can enter incorrect PIN */
|
|
Packit Service |
d328f3 |
desc = g_strdup_printf (_("The mobile broadband device ā%sā requires a SIM PIN code before it can be used."), device_description);
|
|
Packit Service |
d328f3 |
/* Translators: PIN code entry label */
|
|
Packit Service |
d328f3 |
label1 = _("PIN code:");
|
|
Packit Service |
d328f3 |
label1_min = 4;
|
|
Packit Service |
d328f3 |
label1_max = 8;
|
|
Packit Service |
d328f3 |
/* Translators: Show/obscure PIN checkbox label */
|
|
Packit Service |
d328f3 |
show_password_label = _("Show PIN code");
|
|
Packit Service |
d328f3 |
} else if (!strcmp (unlock_required, "sim-puk")) {
|
|
Packit Service |
d328f3 |
title = _("SIM PUK unlock required");
|
|
Packit Service |
d328f3 |
header = _("SIM PUK Unlock Required");
|
|
Packit Service |
d328f3 |
/* FIXME: some warning about # of times you can enter incorrect PUK */
|
|
Packit Service |
d328f3 |
desc = g_strdup_printf (_("The mobile broadband device ā%sā requires a SIM PUK code before it can be used."), device_description);
|
|
Packit Service |
d328f3 |
/* Translators: PUK code entry label */
|
|
Packit Service |
d328f3 |
label1 = _("PUK code:");
|
|
Packit Service |
d328f3 |
label1_min = label1_max = 8;
|
|
Packit Service |
d328f3 |
/* Translators: New PIN entry label */
|
|
Packit Service |
d328f3 |
label2 = _("New PIN code:");
|
|
Packit Service |
d328f3 |
/* Translators: New PIN verification entry label */
|
|
Packit Service |
d328f3 |
label3 = _("Re-enter new PIN code:");
|
|
Packit Service |
d328f3 |
label2_min = label3_min = 4;
|
|
Packit Service |
d328f3 |
label2_max = label3_max = 8;
|
|
Packit Service |
d328f3 |
match23 = TRUE;
|
|
Packit Service |
d328f3 |
/* Translators: Show/obscure PIN/PUK checkbox label */
|
|
Packit Service |
d328f3 |
show_password_label = _("Show PIN/PUK codes");
|
|
Packit Service |
d328f3 |
puk = TRUE;
|
|
Packit Service |
d328f3 |
} else
|
|
Packit Service |
d328f3 |
g_assert_not_reached ();
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
gtk_window_set_position (GTK_WINDOW(dialog), GTK_WIN_POS_CENTER_ALWAYS);
|
|
Packit Service |
d328f3 |
gtk_window_set_title (GTK_WINDOW (dialog), title);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
widget = GTK_WIDGET (gtk_builder_get_object (builder, "header_label"));
|
|
Packit Service |
d328f3 |
str = g_strdup_printf ("%s", header);
|
|
Packit Service |
d328f3 |
gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
|
|
Packit Service |
d328f3 |
gtk_label_set_markup (GTK_LABEL (widget), str);
|
|
Packit Service |
d328f3 |
g_free (str);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
widget = GTK_WIDGET (gtk_builder_get_object (builder, "desc_label"));
|
|
Packit Service |
d328f3 |
gtk_label_set_text (GTK_LABEL (widget), desc);
|
|
Packit Service |
d328f3 |
g_free (desc);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
widget = GTK_WIDGET (gtk_builder_get_object (builder, "show_password_checkbutton"));
|
|
Packit Service |
d328f3 |
gtk_button_set_label (GTK_BUTTON (widget), show_password_label);
|
|
Packit Service |
d328f3 |
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
|
|
Packit Service |
d328f3 |
g_signal_connect (widget, "toggled", G_CALLBACK (show_toggled_cb), dialog);
|
|
Packit Service |
d328f3 |
show_toggled_cb (widget, dialog);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
g_signal_connect (dialog, "delete-event", G_CALLBACK (mpd_cancel_dialog), NULL);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
gtk_widget_show_all (dialog);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
widget = GTK_WIDGET (gtk_builder_get_object (builder, "save_checkbutton"));
|
|
Packit Service |
d328f3 |
if (!puk)
|
|
Packit Service |
d328f3 |
g_object_set_data (G_OBJECT (widget), "active", GUINT_TO_POINTER (TRUE));
|
|
Packit Service |
d328f3 |
else
|
|
Packit Service |
d328f3 |
gtk_widget_hide (widget);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* Set contents */
|
|
Packit Service |
d328f3 |
g_object_set_data (G_OBJECT (dialog), "match23", GUINT_TO_POINTER (match23));
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* code1_entry */
|
|
Packit Service |
d328f3 |
label = GTK_WIDGET (gtk_builder_get_object (builder, "code1_label"));
|
|
Packit Service |
d328f3 |
widget = GTK_WIDGET (gtk_builder_get_object (builder, "code1_entry"));
|
|
Packit Service |
d328f3 |
gtk_label_set_text (GTK_LABEL (label), label1);
|
|
Packit Service |
d328f3 |
g_signal_connect (widget, "changed", G_CALLBACK (mpd_entry_changed), dialog);
|
|
Packit Service |
d328f3 |
g_signal_connect (widget, "insert-text", G_CALLBACK (mpd_entry_filter), NULL);
|
|
Packit Service |
d328f3 |
if (label1_max)
|
|
Packit Service |
d328f3 |
gtk_entry_set_max_length (GTK_ENTRY (widget), label1_max);
|
|
Packit Service |
d328f3 |
g_object_set_data (G_OBJECT (widget), "minlen", GUINT_TO_POINTER (label1_min));
|
|
Packit Service |
d328f3 |
g_object_set_data (G_OBJECT (widget), "active", GUINT_TO_POINTER (1));
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* code2_entry */
|
|
Packit Service |
d328f3 |
label = GTK_WIDGET (gtk_builder_get_object (builder, "code2_label"));
|
|
Packit Service |
d328f3 |
widget = GTK_WIDGET (gtk_builder_get_object (builder, "code2_entry"));
|
|
Packit Service |
d328f3 |
if (label2) {
|
|
Packit Service |
d328f3 |
gtk_label_set_text (GTK_LABEL (label), label2);
|
|
Packit Service |
d328f3 |
g_signal_connect (widget, "changed", G_CALLBACK (mpd_entry_changed), dialog);
|
|
Packit Service |
d328f3 |
g_signal_connect (widget, "insert-text", G_CALLBACK (mpd_entry_filter), NULL);
|
|
Packit Service |
d328f3 |
if (label2_max)
|
|
Packit Service |
d328f3 |
gtk_entry_set_max_length (GTK_ENTRY (widget), label2_max);
|
|
Packit Service |
d328f3 |
g_object_set_data (G_OBJECT (widget), "minlen", GUINT_TO_POINTER (label2_min));
|
|
Packit Service |
d328f3 |
g_object_set_data (G_OBJECT (widget), "active", GUINT_TO_POINTER (1));
|
|
Packit Service |
d328f3 |
} else {
|
|
Packit Service |
d328f3 |
gtk_widget_hide (label);
|
|
Packit Service |
d328f3 |
gtk_widget_hide (widget);
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* code3_entry */
|
|
Packit Service |
d328f3 |
label = GTK_WIDGET (gtk_builder_get_object (builder, "code3_label"));
|
|
Packit Service |
d328f3 |
widget = GTK_WIDGET (gtk_builder_get_object (builder, "code3_entry"));
|
|
Packit Service |
d328f3 |
if (label3) {
|
|
Packit Service |
d328f3 |
gtk_label_set_text (GTK_LABEL (label), label3);
|
|
Packit Service |
d328f3 |
g_signal_connect (widget, "changed", G_CALLBACK (mpd_entry_changed), dialog);
|
|
Packit Service |
d328f3 |
g_signal_connect (widget, "insert-text", G_CALLBACK (mpd_entry_filter), NULL);
|
|
Packit Service |
d328f3 |
if (label3_max)
|
|
Packit Service |
d328f3 |
gtk_entry_set_max_length (GTK_ENTRY (widget), label3_max);
|
|
Packit Service |
d328f3 |
g_object_set_data (G_OBJECT (widget), "minlen", GUINT_TO_POINTER (label3_min));
|
|
Packit Service |
d328f3 |
g_object_set_data (G_OBJECT (widget), "active", GUINT_TO_POINTER (1));
|
|
Packit Service |
d328f3 |
} else {
|
|
Packit Service |
d328f3 |
gtk_widget_hide (label);
|
|
Packit Service |
d328f3 |
gtk_widget_hide (widget);
|
|
Packit Service |
d328f3 |
}
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
/* Make a single-entry dialog look better */
|
|
Packit Service |
d328f3 |
widget = GTK_WIDGET (gtk_builder_get_object (builder, "grid14"));
|
|
Packit Service |
d328f3 |
if (label2 || label3)
|
|
Packit Service |
d328f3 |
gtk_grid_set_row_spacing (GTK_GRID (widget), 6);
|
|
Packit Service |
d328f3 |
else
|
|
Packit Service |
d328f3 |
gtk_grid_set_row_spacing (GTK_GRID (widget), 0);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
widget = GTK_WIDGET (gtk_builder_get_object (builder, "progress_hbox"));
|
|
Packit Service |
d328f3 |
gtk_widget_hide (widget);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
mpd_entry_changed (NULL, dialog);
|
|
Packit Service |
d328f3 |
|
|
Packit Service |
d328f3 |
return dialog;
|
|
Packit Service |
d328f3 |
}
|