~shnatsel/ubuntu/precise/gnome-control-center/fix-939882

« back to all changes in this revision

Viewing changes to .pc/50_ubuntu_systemwide_prefs.patch/panels/network/cc-network-panel.c

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher, Jeremy Bicha, Ken VanDine
  • Date: 2012-02-15 23:16:31 UTC
  • mfrom: (1.1.56)
  • Revision ID: package-import@ubuntu.com-20120215231631-vk7me0mhofpsq0hp
Tags: 1:3.3.5-0ubuntu1
* Upload the new serie, that will bring in quite some fixes, we revert
  some problematic or risky changes as well
* The new version includes those fixes:
  - "Change Password in User Accounts panel focuses "New password" field, 
     skipping "Current password"" (lp: #821759)
  - The dialog to add online accounts should have a title 
    (lp: #822380)
  - "Remove Profile" button clickable in Color panel when 
     no profile selected (lp: #869603)
  - Move Removable Media into System Info (lp: #835880)
  - Sound preferences: mouse scrolling balance only works for right.
    (lp: #918017)
  - gnome-control-center SIGSEGV in actualize_printers_list() 
    (lp: #903009)
  - selecting preffered applications is not an info (lp: #890143)
  - Add a keyboard shortcut by default for take screenshot of a selection"
    (lp: #625518)
* debian/patches/revert_git_datetime_port.patch:
  - revert use of datetimed, we don't use systemd and ubuntu-system-service 
    doesn't support it yet
* debian/patches/revert_git_drop_library.patch:
  - consolidate "01_allow_external_panels.patch", don't drop the library
    we use it from other components on ubuntu, the patch will be improved
    later to not use a copy of files like it does in that version
* debian/patches/revert_git_stop_using_gconf.patch,
  debian/patches/revert_ua_gsettings.patch,
  debian/patches/revert_git_keyboard_gsettings.patch:
  - revert keyboard porting to gsettings, compiz still use gconf and we
    didn't update gnome-shell to the new serie (yet)

[ Jeremy Bicha ]
* New upstream release (Thanks Rico Tzchichholz!)
* debian/control.in:
  - Bump minimum dependency versions and add libwacom dependency
* debian/rules: Build without -Wl,-z,defs
* debian/watch: Watch for unstable releases
* Refreshed patches:
  - 01_allow_external_panels.patch
  - 04_add_theme_selection.patch
  - 50_ubuntu_systemwide_prefs.patch
  - 58_ubuntu_icon_views_redesign.patch
  - 59_install_gcm_components_on_demand.patch
  - 91_configure_cheese.patch
* Dropped upstream patches:
  - 00git_handle_media_dialog_close.patch
  - 03_show_wacom_under_unity.patch
  - 90_git_sound_tab_order.patch
  - 91_git_build_use_fontconfig.patch
  - 92_git_minimal_output_height.patch
  - 93_change_window_role_on_panel_change.patch
  - 94_git_adding_shortcuts.patch
  - 95_git_ctrlw_shortcut.patch
  - git_extra_keywords.patch

[ Ken VanDine ]
* debian/patches/96_sound_nua_panel.patch
  - refreshed with latest changes from ronoc

Show diffs side-by-side

added added

removed removed

Lines of Context:
76
76
        NMRemoteSettings *remote_settings;
77
77
        gboolean          updating_device;
78
78
        guint             refresh_idle;
 
79
        GtkWidget        *kill_switch_header;
79
80
 
80
81
        /* wireless dialog stuff */
81
82
        CmdlineOperation  arg_operation;
205
206
                g_object_unref (priv->remote_settings);
206
207
                priv->remote_settings = NULL;
207
208
        }
 
209
        if (priv->kill_switch_header != NULL) {
 
210
                g_clear_object (&priv->kill_switch_header);
 
211
        }
208
212
 
209
213
        G_OBJECT_CLASS (cc_network_panel_parent_class)->dispose (object);
210
214
}
626
630
                          panel);
627
631
}
628
632
 
 
633
static void
 
634
panel_refresh_killswitch_visibility (CcNetworkPanel *panel)
 
635
{
 
636
        gboolean ret;
 
637
        gboolean show_flight_toggle = FALSE;
 
638
        GtkTreeIter iter;
 
639
        GtkTreeModel *model;
 
640
        NetObject *object_tmp;
 
641
        NMDeviceModemCapabilities caps;
 
642
        NMDevice *nm_device;
 
643
 
 
644
        /* find any wireless devices in model */
 
645
        model = GTK_TREE_MODEL (gtk_builder_get_object (panel->priv->builder,
 
646
                                                        "liststore_devices"));
 
647
        ret = gtk_tree_model_get_iter_first (model, &iter);
 
648
        if (!ret)
 
649
                return;
 
650
        do {
 
651
                gtk_tree_model_get (model, &iter,
 
652
                                    PANEL_DEVICES_COLUMN_OBJECT, &object_tmp,
 
653
                                    -1);
 
654
                if (NET_IS_DEVICE (object_tmp)) {
 
655
                        nm_device = net_device_get_nm_device (NET_DEVICE (object_tmp));
 
656
                        switch (nm_device_get_device_type (nm_device)) {
 
657
                        case NM_DEVICE_TYPE_WIFI:
 
658
                        case NM_DEVICE_TYPE_WIMAX:
 
659
                                show_flight_toggle = TRUE;
 
660
                                break;
 
661
                        case NM_DEVICE_TYPE_MODEM:
 
662
                                {
 
663
                                caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (nm_device));
 
664
                                if ((caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) ||
 
665
                                    (caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO))
 
666
                                        show_flight_toggle = TRUE;
 
667
                                }
 
668
                                break;
 
669
                        default:
 
670
                                break;
 
671
                        }
 
672
                }
 
673
                g_object_unref (object_tmp);
 
674
        } while (!show_flight_toggle && gtk_tree_model_iter_next (model, &iter));
 
675
 
 
676
        /* only show toggle if there are wireless devices */
 
677
        gtk_widget_set_visible (panel->priv->kill_switch_header,
 
678
                                show_flight_toggle);
 
679
}
 
680
 
629
681
static gboolean
630
682
panel_add_device (CcNetworkPanel *panel, NMDevice *device)
631
683
{
1545
1597
{
1546
1598
        GtkWidget *widget;
1547
1599
        char *wid_name;
1548
 
        const char *str;
 
1600
        GString *str;
1549
1601
        NMDeviceState state;
1550
1602
        NMDeviceType type;
1551
1603
        gboolean is_hotspot;
 
1604
        guint speed = 0;
1552
1605
 
1553
1606
        type = nm_device_get_device_type (device);
1554
1607
        state = nm_device_get_state (device);
1569
1622
        gtk_label_set_label (GTK_LABEL (widget),
1570
1623
                             panel_device_to_localized_string (device));
1571
1624
 
1572
 
        /* set device state */
1573
 
        wid_name = g_strdup_printf ("label_%s_status", page_name);
1574
 
        widget = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder, wid_name));
1575
 
        g_free (wid_name);
1576
 
        if (is_hotspot) {
1577
 
                str = _("Hotspot");
1578
 
        } else {
1579
 
                str = panel_device_state_to_localized_string (device);
1580
 
        }
1581
 
        gtk_label_set_label (GTK_LABEL (widget), str);
1582
 
 
1583
 
 
1584
1625
        /* set up the device on/off switch */
1585
1626
        wid_name = g_strdup_printf ("device_%s_off_switch", page_name);
1586
1627
        widget = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder, wid_name));
1593
1634
                                        state != NM_DEVICE_STATE_UNAVAILABLE
1594
1635
                                        && state != NM_DEVICE_STATE_UNMANAGED);
1595
1636
                update_off_switch_from_device_state (GTK_SWITCH (widget), state, panel);
 
1637
                if (state != NM_DEVICE_STATE_UNAVAILABLE)
 
1638
                        speed = nm_device_ethernet_get_speed (NM_DEVICE_ETHERNET (device));
1596
1639
                break;
1597
1640
        case NM_DEVICE_TYPE_WIFI:
1598
1641
                gtk_widget_show (widget);
1599
1642
                wireless_enabled_toggled (panel->priv->client, NULL, panel);
 
1643
                if (state != NM_DEVICE_STATE_UNAVAILABLE)
 
1644
                        speed = nm_device_wifi_get_bitrate (NM_DEVICE_WIFI (device));
 
1645
                speed /= 1000;
1600
1646
                break;
1601
1647
        case NM_DEVICE_TYPE_WIMAX:
1602
1648
                gtk_widget_show (widget);
1611
1657
                break;
1612
1658
        }
1613
1659
 
 
1660
        /* set device state, with status and optionally speed */
 
1661
        wid_name = g_strdup_printf ("label_%s_status", page_name);
 
1662
        widget = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder, wid_name));
 
1663
        g_free (wid_name);
 
1664
        if (is_hotspot) {
 
1665
                str = g_string_new (_("Hotspot"));
 
1666
        } else {
 
1667
                str = g_string_new (panel_device_state_to_localized_string (device));
 
1668
        }
 
1669
        if (speed  > 0) {
 
1670
                g_string_append (str, " - ");
 
1671
                /* Translators: network device speed */
 
1672
                g_string_append_printf (str, _("%d Mb/s"), speed);
 
1673
        }
 
1674
        gtk_label_set_label (GTK_LABEL (widget), str->str);
 
1675
 
1614
1676
        /* set up options button */
1615
1677
        wid_name = g_strdup_printf ("button_%s_options", page_name);
1616
1678
        widget = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder, wid_name));
1618
1680
        if (widget != NULL) {
1619
1681
                gtk_widget_set_sensitive (widget, find_connection_for_device (panel, device) != NULL);
1620
1682
        }
 
1683
        g_string_free (str, TRUE);
1621
1684
}
1622
1685
 
1623
1686
static void
1624
1687
device_refresh_ethernet_ui (CcNetworkPanel *panel, NetDevice *device)
1625
1688
{
1626
 
        guint speed;
1627
 
        NMDeviceState state;
1628
1689
        const char *str;
1629
 
        gchar *str_tmp;
1630
1690
        NMDevice *nm_device;
1631
1691
 
1632
1692
        nm_device = net_device_get_nm_device (device);
1633
 
        state = nm_device_get_state (nm_device);
1634
1693
 
1635
1694
        refresh_header_ui (panel, nm_device, "wired");
1636
1695
 
1637
 
        /* speed */
1638
 
        speed = nm_device_ethernet_get_speed (NM_DEVICE_ETHERNET (nm_device));
1639
 
        if (state == NM_DEVICE_STATE_UNAVAILABLE)
1640
 
                str_tmp = NULL;
1641
 
        else if (speed  > 0)
1642
 
                /* Translators: network device speed */
1643
 
                str_tmp = g_strdup_printf (_("%d Mb/s"), speed);
1644
 
        else
1645
 
                str_tmp = g_strdup ("");
1646
 
        panel_set_widget_data (panel,
1647
 
                               "wired",
1648
 
                               "speed",
1649
 
                               str_tmp);
1650
 
        g_free (str_tmp);
1651
 
 
1652
1696
        /* device MAC */
1653
1697
        str = nm_device_ethernet_get_hw_address (NM_DEVICE_ETHERNET (nm_device));
1654
1698
        panel_set_widget_data (panel,
1663
1707
{
1664
1708
        GtkWidget *widget;
1665
1709
        GtkWidget *sw;
1666
 
        guint speed;
1667
1710
        const GPtrArray *aps;
1668
1711
        GPtrArray *aps_unique = NULL;
1669
1712
        GtkWidget *heading;
1723
1766
        panel_set_widget_data (panel, "hotspot", "security_key", hotspot_secret);
1724
1767
        g_free (hotspot_secret);
1725
1768
 
1726
 
        /* speed */
1727
 
        speed = nm_device_wifi_get_bitrate (NM_DEVICE_WIFI (nm_device));
1728
 
        if (state == NM_DEVICE_STATE_UNAVAILABLE)
1729
 
                str_tmp = NULL;
1730
 
        else if (speed > 0)
1731
 
                str_tmp = g_strdup_printf (_("%d Mb/s"),
1732
 
                                           speed / 1000);
1733
 
        else
1734
 
                str_tmp = g_strdup ("");
1735
 
        panel_set_widget_data (panel,
1736
 
                               "wireless",
1737
 
                               "speed",
1738
 
                               str_tmp);
1739
 
        g_free (str_tmp);
1740
 
 
1741
1769
        /* device MAC */
1742
1770
        str = nm_device_wifi_get_hw_address (NM_DEVICE_WIFI (nm_device));
1743
1771
        panel_set_widget_data (panel,
2286
2314
{
2287
2315
        g_debug ("New device added");
2288
2316
        panel_add_device (panel, device);
 
2317
        panel_refresh_killswitch_visibility (panel);
2289
2318
}
2290
2319
 
2291
2320
static void
2293
2322
{
2294
2323
        g_debug ("Device removed");
2295
2324
        panel_remove_device (panel, device);
 
2325
        panel_refresh_killswitch_visibility (panel);
2296
2326
}
2297
2327
 
2298
2328
static void
3202
3232
        gtk_window_present (GTK_WINDOW (dialog));
3203
3233
}
3204
3234
 
 
3235
static gboolean
 
3236
network_add_shell_header_widgets_cb (gpointer user_data)
 
3237
{
 
3238
        CcNetworkPanel *panel = CC_NETWORK_PANEL (user_data);
 
3239
        gboolean ret;
 
3240
        GtkWidget *box;
 
3241
        GtkWidget *widget;
 
3242
 
 
3243
        box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 3);
 
3244
        /* TRANSLATORS: this is to disable the radio hardware in the
 
3245
         * network panel */
 
3246
        widget = gtk_label_new (_("Airplane Mode"));
 
3247
        gtk_box_pack_start (GTK_BOX (box), widget, FALSE, FALSE, 0);
 
3248
        gtk_widget_set_visible (widget, TRUE);
 
3249
        widget = gtk_switch_new ();
 
3250
        gtk_box_pack_start (GTK_BOX (box), widget, FALSE, FALSE, 0);
 
3251
        gtk_widget_set_visible (widget, TRUE);
 
3252
        cc_shell_embed_widget_in_header (cc_panel_get_shell (CC_PANEL (panel)), box);
 
3253
        panel->priv->kill_switch_header = g_object_ref (box);
 
3254
 
 
3255
        ret = nm_client_wireless_get_enabled (panel->priv->client);
 
3256
        gtk_switch_set_active (GTK_SWITCH (widget), !ret);
 
3257
        g_signal_connect (GTK_SWITCH (widget), "notify::active",
 
3258
                          G_CALLBACK (cc_network_panel_notify_enable_active_cb),
 
3259
                          panel);
 
3260
        panel_refresh_killswitch_visibility (panel);
 
3261
 
 
3262
        return FALSE;
 
3263
}
 
3264
 
3205
3265
static void
3206
3266
cc_network_panel_init (CcNetworkPanel *panel)
3207
3267
{
3208
3268
        DBusGConnection *bus = NULL;
3209
 
        gboolean ret;
3210
3269
        GError *error = NULL;
3211
3270
        gint value;
3212
3271
        GSettings *settings_tmp;
3469
3528
                                                     "button_unlock"));
3470
3529
        gtk_widget_set_sensitive (widget, FALSE);
3471
3530
 
3472
 
        widget = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder,
3473
 
                                                     "switch_flight_mode"));
3474
 
        ret = nm_client_wireless_get_enabled (panel->priv->client);
3475
 
        gtk_switch_set_active (GTK_SWITCH (widget), !ret);
3476
 
        g_signal_connect (GTK_SWITCH (widget), "notify::active",
3477
 
                          G_CALLBACK (cc_network_panel_notify_enable_active_cb),
3478
 
                          panel);
3479
 
 
3480
3531
        /* add remote settings such as VPN settings as virtual devices */
3481
3532
        bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
3482
3533
        if (bus == NULL) {
3506
3557
        widget = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder,
3507
3558
                                                     "vbox1"));
3508
3559
        gtk_widget_reparent (widget, (GtkWidget *) panel);
 
3560
 
 
3561
        /* add kill switch widgets when dialog activated */
 
3562
        g_idle_add (network_add_shell_header_widgets_cb, panel);
3509
3563
}
3510
3564
 
3511
3565
void