~khurshid-alam/unity-control-center/libnm-port-test

« back to all changes in this revision

Viewing changes to panels/network/connection-editor/net-connection-editor.c

  • Committer: Khurshid Alam
  • Date: 2018-06-05 14:47:56 UTC
  • Revision ID: khurshid.alam@linuxmail.org-20180605144756-or0tftb2kddhvhq2
Update connection editor pages and wireless security from Gnome-3.26

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
#include "ce-page-ip4.h"
35
35
#include "ce-page-ip6.h"
36
36
#include "ce-page-security.h"
37
 
#include "ce-page-reset.h"
38
37
#include "ce-page-ethernet.h"
39
38
#include "ce-page-8021x-security.h"
40
39
#include "ce-page-vpn.h"
53
52
static void page_changed (CEPage *page, gpointer user_data);
54
53
 
55
54
static void
56
 
selection_changed (GtkTreeSelection *selection, NetConnectionEditor *editor)
57
 
{
58
 
        GtkWidget *widget;
59
 
        GtkTreeModel *model;
60
 
        GtkTreeIter iter;
61
 
        gint page;
62
 
 
63
 
        if (!gtk_tree_selection_get_selected (selection, &model, &iter))
64
 
                return;
65
 
        gtk_tree_model_get (model, &iter, 1, &page, -1);
66
 
 
67
 
        widget = GTK_WIDGET (gtk_builder_get_object (editor->builder,
68
 
                                                     "details_notebook"));
69
 
        gtk_notebook_set_current_page (GTK_NOTEBOOK (widget), page);
70
 
}
71
 
 
72
 
static void
73
55
cancel_editing (NetConnectionEditor *editor)
74
56
{
75
57
        gtk_widget_hide (editor->window);
164
146
net_connection_editor_init (NetConnectionEditor *editor)
165
147
{
166
148
        GError *error = NULL;
167
 
        GtkTreeSelection *selection;
168
149
 
169
150
        editor->builder = gtk_builder_new ();
170
151
 
178
159
        }
179
160
 
180
161
        editor->window = GTK_WIDGET (gtk_builder_get_object (editor->builder, "details_dialog"));
181
 
        selection = GTK_TREE_SELECTION (gtk_builder_get_object (editor->builder,
182
 
                                                                "details_page_list_selection"));
183
 
        g_signal_connect (selection, "changed",
184
 
                          G_CALLBACK (selection_changed), editor);
185
162
}
186
163
 
187
164
void
431
408
{
432
409
        GtkNotebook *notebook;
433
410
        GtkWidget *widget;
 
411
        GtkWidget *label;
434
412
        gint position;
435
413
        GList *children, *l;
436
414
        gint i;
446
424
                        break;
447
425
        }
448
426
        g_list_free (children);
449
 
        gtk_notebook_insert_page (notebook, widget, NULL, i);
 
427
 
 
428
        label = gtk_label_new (ce_page_get_title (page));
 
429
 
 
430
        gtk_notebook_insert_page (notebook, widget, label, i);
450
431
 
451
432
        editor->initializing_pages = g_slist_remove (editor->initializing_pages, page);
452
433
        editor->pages = g_slist_append (editor->pages, page);
506
487
static void
507
488
add_page (NetConnectionEditor *editor, CEPage *page)
508
489
{
509
 
        GtkListStore *store;
510
 
        GtkTreeIter iter;
511
 
        const gchar *title;
512
490
        gint position;
513
491
 
514
 
        store = GTK_LIST_STORE (gtk_builder_get_object (editor->builder,
515
 
                                                "details_store"));
516
 
        title = ce_page_get_title (page);
517
492
        position = g_slist_length (editor->initializing_pages);
518
493
        g_object_set_data (G_OBJECT (page), "position", GINT_TO_POINTER (position));
519
 
        gtk_list_store_insert_with_values (store, &iter, -1,
520
 
                                           0, title,
521
 
                                           1, position,
522
 
                                           -1);
 
494
 
523
495
        editor->initializing_pages = g_slist_append (editor->initializing_pages, page);
524
496
 
525
497
        g_signal_connect (page, "changed", G_CALLBACK (page_changed), editor);
533
505
        GSList *pages, *l;
534
506
        NMSettingConnection *sc;
535
507
        const gchar *type;
536
 
        GtkTreeSelection *selection;
537
 
        GtkTreePath *path;
 
508
        gboolean is_wired;
 
509
        gboolean is_wifi;
 
510
        gboolean is_vpn;
538
511
 
539
512
        editor->is_new_connection = !nm_client_get_connection_by_uuid (editor->client,
540
513
                                                                       nm_connection_get_uuid (connection));
557
530
        sc = nm_connection_get_setting_connection (connection);
558
531
        type = nm_setting_connection_get_connection_type (sc);
559
532
 
 
533
        is_wired = g_str_equal (type, NM_SETTING_WIRED_SETTING_NAME);
 
534
        is_wifi = g_str_equal (type, NM_SETTING_WIRELESS_SETTING_NAME);
 
535
        is_vpn = g_str_equal (type, NM_SETTING_VPN_SETTING_NAME);
 
536
 
560
537
        if (!editor->is_new_connection)
561
 
                add_page (editor, ce_page_details_new (editor->connection, editor->client, editor->device, editor->ap));
562
 
 
563
 
        if (strcmp (type, NM_SETTING_WIRELESS_SETTING_NAME) == 0)
564
 
                add_page (editor, ce_page_security_new (editor->connection, editor->client));
565
 
        else if (strcmp (type, NM_SETTING_WIRED_SETTING_NAME) == 0)
566
 
                add_page (editor, ce_page_8021x_security_new (editor->connection, editor->client));
567
 
 
568
 
        if (strcmp (type, NM_SETTING_WIRELESS_SETTING_NAME) == 0)
 
538
                add_page (editor, ce_page_details_new (editor->connection, editor->client, editor->device, editor->ap, editor));
 
539
 
 
540
        if (is_wifi)
569
541
                add_page (editor, ce_page_wifi_new (editor->connection, editor->client));
570
 
        else if (strcmp (type, NM_SETTING_WIRED_SETTING_NAME) == 0)
 
542
        else if (is_wired)
571
543
                add_page (editor, ce_page_ethernet_new (editor->connection, editor->client));
572
 
        else if (strcmp (type, NM_SETTING_VPN_SETTING_NAME) == 0)
 
544
        else if (is_vpn)
573
545
                add_page (editor, ce_page_vpn_new (editor->connection, editor->client));
574
546
        else {
575
547
                /* Unsupported type */
580
552
        add_page (editor, ce_page_ip4_new (editor->connection, editor->client));
581
553
        add_page (editor, ce_page_ip6_new (editor->connection, editor->client));
582
554
 
583
 
        if (!editor->is_new_connection)
584
 
                add_page (editor, ce_page_reset_new (editor->connection, editor->client, editor));
 
555
        if (is_wifi)
 
556
                add_page (editor, ce_page_security_new (editor->connection, editor->client));
 
557
        else if (is_wired)
 
558
                add_page (editor, ce_page_8021x_security_new (editor->connection, editor->client));
585
559
 
586
560
        pages = g_slist_copy (editor->initializing_pages);
587
561
        for (l = pages; l; l = l->next) {
596
570
                }
597
571
        }
598
572
        g_slist_free (pages);
599
 
 
600
 
        selection = GTK_TREE_SELECTION (gtk_builder_get_object (editor->builder,
601
 
                                                                "details_page_list_selection"));
602
 
        path = gtk_tree_path_new_first ();
603
 
        gtk_tree_selection_select_path (selection, path);
604
 
        gtk_tree_path_free (path);
605
573
}
606
574
 
607
575
static NMConnection *
889
857
 
890
858
        if (!nm_remote_connection_delete_finish (connection, res, &error)) {
891
859
                if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
892
 
                        g_warning ("Failed to delete conneciton %s: %s",
 
860
                        g_warning ("Failed to delete connection %s: %s",
893
861
                                   nm_connection_get_id (NM_CONNECTION (connection)),
894
862
                                   error->message);
895
863
                g_error_free (error);