static void nmt_page_team_port_constructed (GObject *object) { NmtPageTeamPort *team = NMT_PAGE_TEAM_PORT (object); NmtPageTeamPortPrivate *priv = NMT_PAGE_TEAM_PORT_GET_PRIVATE (team); NmtNewtGrid *grid; NMSettingTeamPort *s_port; NmtNewtWidget *widget; NMConnection *conn; conn = nmt_editor_page_get_connection (NMT_EDITOR_PAGE (team)); s_port = nm_connection_get_setting_team_port (conn); if (!s_port) { nm_connection_add_setting (conn, nm_setting_team_port_new ()); s_port = nm_connection_get_setting_team_port (conn); } priv->s_port = s_port; widget = nmt_newt_grid_new (); nmt_page_grid_append (NMT_PAGE_GRID (team), NULL, widget, NULL); grid = NMT_NEWT_GRID (widget); widget = nmt_newt_label_new (_("JSON configuration")); nmt_newt_grid_add (grid, widget, 0, 2); widget = nmt_newt_textbox_new (NMT_NEWT_TEXTBOX_SCROLLABLE | NMT_NEWT_TEXTBOX_SET_BACKGROUND, 60); g_object_bind_property (s_port, NM_SETTING_TEAM_PORT_CONFIG, widget, "text", G_BINDING_SYNC_CREATE); nmt_newt_grid_add (grid, widget, 0, 3); nmt_newt_widget_set_padding (widget, 2, 0, 2, 1); widget = nmt_newt_button_new (_("Edit...")); g_signal_connect (widget, "clicked", G_CALLBACK (edit_clicked), team); nmt_newt_grid_add (grid, widget, 0, 4); G_OBJECT_CLASS (nmt_page_team_port_parent_class)->constructed (object); }
static NmtNewtForm * nmt_connect_connection_list (void) { int screen_width, screen_height; NmtNewtForm *form; NmtNewtWidget *list, *activate, *quit, *bbox, *grid; newtGetScreenSize (&screen_width, &screen_height); form = g_object_new (NMT_TYPE_NEWT_FORM, "y", 2, "height", screen_height - 4, "escape-exits", TRUE, NULL); grid = nmt_newt_grid_new (); list = nmt_connect_connection_list_new (); nmt_newt_grid_add (NMT_NEWT_GRID (grid), list, 0, 0); nmt_newt_grid_set_flags (NMT_NEWT_GRID (grid), list, NMT_NEWT_GRID_FILL_X | NMT_NEWT_GRID_FILL_Y | NMT_NEWT_GRID_EXPAND_X | NMT_NEWT_GRID_EXPAND_Y); g_signal_connect (list, "activated", G_CALLBACK (listbox_activated), NULL); bbox = nmt_newt_button_box_new (NMT_NEWT_BUTTON_BOX_VERTICAL); nmt_newt_grid_add (NMT_NEWT_GRID (grid), bbox, 1, 0); nmt_newt_widget_set_padding (bbox, 1, 1, 0, 1); activate = nmt_newt_button_box_add_start (NMT_NEWT_BUTTON_BOX (bbox), _("Activate")); g_signal_connect (list, "notify::active", G_CALLBACK (listbox_active_changed), activate); listbox_active_changed (G_OBJECT (list), NULL, activate); g_signal_connect (activate, "clicked", G_CALLBACK (activate_clicked), list); quit = nmt_newt_button_box_add_end (NMT_NEWT_BUTTON_BOX (bbox), _("Quit")); nmt_newt_widget_set_exit_on_activate (quit, TRUE); nmt_newt_form_set_content (form, grid); return form; }
static void nmt_newt_section_init (NmtNewtSection *section) { NmtNewtSectionPrivate *priv = NMT_NEWT_SECTION_GET_PRIVATE (section); NmtNewtContainerClass *parent_class = NMT_NEWT_CONTAINER_CLASS (nmt_newt_section_parent_class); priv->show_border = TRUE; priv->border_grid = nmt_newt_grid_new (); parent_class->add (NMT_NEWT_CONTAINER (section), priv->border_grid); priv->border_open_label = nmt_newt_label_new (open_glyph); nmt_newt_widget_set_visible (priv->border_open_label, FALSE); nmt_newt_grid_add (NMT_NEWT_GRID (priv->border_grid), priv->border_open_label, 0, 0); priv->border_closed_label = nmt_newt_label_new (closed_glyph); nmt_newt_grid_add (NMT_NEWT_GRID (priv->border_grid), priv->border_closed_label, 0, 0); priv->border_end_label = nmt_newt_label_new (end_glyph); nmt_newt_widget_set_visible (priv->border_open_label, FALSE); nmt_newt_grid_add (NMT_NEWT_GRID (priv->border_grid), priv->border_end_label, 0, 1); priv->border_line_labels = g_ptr_array_new (); }
static void nmt_password_dialog_constructed (GObject *object) { NmtPasswordDialog *dialog = NMT_PASSWORD_DIALOG (object); NmtPasswordDialogPrivate *priv = NMT_PASSWORD_DIALOG_GET_PRIVATE (dialog); NmtNewtWidget *widget; NmtNewtGrid *grid, *secret_grid; NmtNewtButtonBox *bbox; int i; widget = nmt_newt_grid_new (); nmt_newt_form_set_content (NMT_NEWT_FORM (dialog), widget); grid = NMT_NEWT_GRID (widget); widget = nmt_newt_textbox_new (0, 60); nmt_newt_textbox_set_text (NMT_NEWT_TEXTBOX (widget), priv->prompt); nmt_newt_grid_add (grid, widget, 0, 0); widget = nmt_newt_grid_new (); nmt_newt_grid_add (grid, widget, 0, 1); nmt_newt_widget_set_padding (widget, 0, 1, 0, 1); priv->secret_grid = widget; secret_grid = NMT_NEWT_GRID (widget); for (i = 0; i < priv->secrets->len; i++) { NMSecretAgentSimpleSecret *secret = priv->secrets->pdata[i]; NmtNewtEntryFlags flags; widget = nmt_newt_label_new (secret->name); nmt_newt_grid_add (secret_grid, widget, 0, i); nmt_newt_widget_set_padding (widget, 4, 0, 1, 0); flags = NMT_NEWT_ENTRY_NONEMPTY; if (secret->password) flags |= NMT_NEWT_ENTRY_PASSWORD; widget = nmt_newt_entry_new (30, flags); nmt_newt_grid_add (secret_grid, widget, 1, i); g_ptr_array_add (priv->entries, widget); if (i == priv->secrets->len - 1) { priv->last_entry = widget; g_signal_connect (widget, "activated", G_CALLBACK (maybe_save_input_and_exit), dialog); } } widget = nmt_newt_button_box_new (NMT_NEWT_BUTTON_BOX_HORIZONTAL); nmt_newt_grid_add (grid, widget, 0, 2); bbox = NMT_NEWT_BUTTON_BOX (widget); priv->cancel = nmt_newt_button_box_add_end (NMT_NEWT_BUTTON_BOX (bbox), _("Cancel")); nmt_newt_widget_set_exit_on_activate (priv->cancel, TRUE); priv->ok = nmt_newt_button_box_add_end (NMT_NEWT_BUTTON_BOX (bbox), _("OK")); g_signal_connect (priv->ok, "activated", G_CALLBACK (maybe_save_input_and_exit), dialog); g_object_bind_property (priv->secret_grid, "valid", priv->ok, "sensitive", G_BINDING_SYNC_CREATE); G_OBJECT_CLASS (nmt_password_dialog_parent_class)->constructed (object); }
static void nmt_page_ppp_constructed (GObject *object) { NmtPagePpp *ppp = NMT_PAGE_PPP (object); NmtPagePppPrivate *priv = NMT_PAGE_PPP_GET_PRIVATE (ppp); NmtEditorSection *section; NmtEditorGrid *grid; NMSettingPpp *s_ppp; NmtNewtWidget *widget, *use_mppe; NmtNewtGrid *auth_grid, *mppe_grid; NmtNewtSection *auth_section, *mppe_section; NMConnection *conn; conn = nmt_editor_page_get_connection (NMT_EDITOR_PAGE (ppp)); s_ppp = nm_connection_get_setting_ppp (conn); if (s_ppp) { priv->lcp_echo_interval = nm_setting_ppp_get_lcp_echo_interval (s_ppp); priv->lcp_echo_failure = nm_setting_ppp_get_lcp_echo_failure (s_ppp); } else { s_ppp = (NMSettingPpp *) nm_setting_ppp_new (); nm_connection_add_setting (conn, (NMSetting *) s_ppp); priv->lcp_echo_interval = 30; priv->lcp_echo_failure = 5; } section = nmt_editor_section_new (_("PPP CONFIGURATION"), NULL, TRUE); grid = nmt_editor_section_get_body (section); /* Auth methods */ widget = nmt_newt_section_new (FALSE); auth_section = NMT_NEWT_SECTION (widget); g_object_set (auth_section, "open", TRUE, NULL); nmt_editor_grid_append (grid, NULL, widget, NULL); widget = nmt_newt_label_new (_("Allowed authentication methods:")); nmt_newt_section_set_header (auth_section, widget); widget = nmt_newt_grid_new (); auth_grid = NMT_NEWT_GRID (widget); nmt_newt_section_set_body (auth_section, widget); widget = nmt_newt_checkbox_new (_("EAP")); g_object_bind_property (s_ppp, NM_SETTING_PPP_REFUSE_EAP, widget, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_INVERT_BOOLEAN | G_BINDING_SYNC_CREATE); nmt_newt_grid_add (auth_grid, widget, 0, 0); widget = nmt_newt_checkbox_new (_("PAP")); g_object_bind_property (s_ppp, NM_SETTING_PPP_REFUSE_PAP, widget, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_INVERT_BOOLEAN | G_BINDING_SYNC_CREATE); nmt_newt_grid_add (auth_grid, widget, 0, 1); widget = nmt_newt_checkbox_new (_("CHAP")); g_object_bind_property (s_ppp, NM_SETTING_PPP_REFUSE_CHAP, widget, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_INVERT_BOOLEAN | G_BINDING_SYNC_CREATE); nmt_newt_grid_add (auth_grid, widget, 0, 2); widget = nmt_newt_checkbox_new (_("MSCHAPv2")); g_object_bind_property (s_ppp, NM_SETTING_PPP_REFUSE_MSCHAPV2, widget, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_INVERT_BOOLEAN | G_BINDING_SYNC_CREATE); nmt_newt_grid_add (auth_grid, widget, 0, 3); widget = nmt_newt_checkbox_new (_("MSCHAP")); g_object_bind_property (s_ppp, NM_SETTING_PPP_REFUSE_MSCHAP, widget, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_INVERT_BOOLEAN | G_BINDING_SYNC_CREATE); nmt_newt_grid_add (auth_grid, widget, 0, 4); nmt_editor_grid_append (grid, NULL, nmt_newt_separator_new (), NULL); /* MPPE */ widget = nmt_newt_section_new (FALSE); mppe_section = NMT_NEWT_SECTION (widget); g_object_set (mppe_section, "open", TRUE, NULL); nmt_editor_grid_append (grid, NULL, widget, NULL); widget = nmt_newt_checkbox_new (_("Use point-to-point encryption (MPPE)")); g_object_bind_property (s_ppp, NM_SETTING_PPP_REQUIRE_MPPE, widget, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); use_mppe = widget; nmt_newt_section_set_header (mppe_section, widget); widget = nmt_newt_grid_new (); mppe_grid = NMT_NEWT_GRID (widget); nmt_newt_section_set_body (mppe_section, widget); widget = nmt_newt_checkbox_new (_("Require 128-bit encryption")); g_object_bind_property (use_mppe, "active", widget, "sensitive", G_BINDING_SYNC_CREATE); g_object_bind_property (s_ppp, NM_SETTING_PPP_REQUIRE_MPPE_128, widget, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); nmt_newt_grid_add (mppe_grid, widget, 0, 0); widget = nmt_newt_checkbox_new (_("Use stateful MPPE")); g_object_bind_property (use_mppe, "active", widget, "sensitive", G_BINDING_SYNC_CREATE); g_object_bind_property (s_ppp, NM_SETTING_PPP_MPPE_STATEFUL, widget, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); nmt_newt_grid_add (mppe_grid, widget, 0, 1); nmt_editor_grid_append (grid, NULL, nmt_newt_separator_new (), NULL); widget = nmt_newt_checkbox_new (_("Allow BSD data compression")); g_object_bind_property (s_ppp, NM_SETTING_PPP_NOBSDCOMP, widget, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_INVERT_BOOLEAN | G_BINDING_SYNC_CREATE); nmt_editor_grid_append (grid, NULL, widget, NULL); widget = nmt_newt_checkbox_new (_("Allow Deflate data compression")); g_object_bind_property (s_ppp, NM_SETTING_PPP_NODEFLATE, widget, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_INVERT_BOOLEAN | G_BINDING_SYNC_CREATE); nmt_editor_grid_append (grid, NULL, widget, NULL); widget = nmt_newt_checkbox_new (_("Use TCP header compression")); g_object_bind_property (s_ppp, NM_SETTING_PPP_NO_VJ_COMP, widget, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_INVERT_BOOLEAN | G_BINDING_SYNC_CREATE); nmt_editor_grid_append (grid, NULL, widget, NULL); nmt_editor_grid_append (grid, NULL, nmt_newt_separator_new (), NULL); widget = nmt_newt_checkbox_new (_("Send PPP echo packets")); g_object_bind_property_full (s_ppp, NM_SETTING_PPP_LCP_ECHO_INTERVAL, widget, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE, transform_lcp_echo_properties_to_checkbox, transform_checkbox_to_lcp_echo_interval, ppp, NULL); g_object_bind_property_full (s_ppp, NM_SETTING_PPP_LCP_ECHO_FAILURE, widget, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE, transform_lcp_echo_properties_to_checkbox, transform_checkbox_to_lcp_echo_failure, ppp, NULL); nmt_editor_grid_append (grid, NULL, widget, NULL); nmt_editor_page_add_section (NMT_EDITOR_PAGE (ppp), section); G_OBJECT_CLASS (nmt_page_ppp_parent_class)->constructed (object); }
static void nmt_page_wifi_constructed (GObject *object) { NmtPageWifiPrivate *priv = NMT_PAGE_WIFI_GET_PRIVATE (object); NmtPageWifi *wifi = NMT_PAGE_WIFI (object); NmtDeviceEntry *deventry; NmtEditorSection *section; NmtEditorGrid *grid; NMSettingWireless *s_wireless; NMSettingWirelessSecurity *s_wsec; NmtNewtWidget *widget, *hbox, *subgrid; NmtNewtWidget *mode, *band, *security, *entry; NmtNewtStack *stack; NMConnection *conn; conn = nmt_editor_page_get_connection (NMT_EDITOR_PAGE (wifi)); s_wireless = nm_connection_get_setting_wireless (conn); if (!s_wireless) { nm_connection_add_setting (conn, nm_setting_wireless_new ()); s_wireless = nm_connection_get_setting_wireless (conn); } s_wsec = nm_connection_get_setting_wireless_security (conn); if (!s_wsec) { /* It makes things simpler if we always have a * NMSettingWirelessSecurity; we'll hold a ref on one, and add * it to and remove it from the connection as needed. */ s_wsec = NM_SETTING_WIRELESS_SECURITY (nm_setting_wireless_security_new ()); } priv->s_wsec = g_object_ref_sink (s_wsec); deventry = nmt_editor_page_device_get_device_entry (NMT_EDITOR_PAGE_DEVICE (object)); g_object_bind_property (s_wireless, NM_SETTING_WIRELESS_MAC_ADDRESS, deventry, "mac-address", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); section = nmt_editor_section_new (_("WI-FI"), NULL, TRUE); grid = nmt_editor_section_get_body (section); widget = nmt_newt_entry_new (40, NMT_NEWT_ENTRY_NONEMPTY); g_object_bind_property_full (s_wireless, NM_SETTING_WIRELESS_SSID, widget, "text", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE, ssid_transform_to_entry, ssid_transform_from_entry, s_wireless, NULL); nmt_editor_grid_append (grid, _("SSID"), widget, NULL); widget = nmt_newt_popup_new (wifi_mode); g_object_bind_property (s_wireless, NM_SETTING_WIRELESS_MODE, widget, "active-id", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); nmt_editor_grid_append (grid, _("Mode"), widget, NULL); mode = widget; hbox = nmt_newt_grid_new (); widget = nmt_newt_popup_new (wifi_band); g_object_bind_property (s_wireless, NM_SETTING_WIRELESS_BAND, widget, "active-id", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); nmt_newt_grid_add (NMT_NEWT_GRID (hbox), widget, 0, 0); band = widget; widget = nmt_newt_entry_numeric_new (10, 0, 255); g_object_bind_property (s_wireless, NM_SETTING_WIRELESS_CHANNEL, widget, "text", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); nmt_newt_grid_add (NMT_NEWT_GRID (hbox), widget, 1, 0); nmt_newt_widget_set_padding (widget, 1, 0, 0, 0); g_object_bind_property_full (band, "active-id", widget, "visible", G_BINDING_SYNC_CREATE, band_transform_to_channel_visibility, NULL, NULL, NULL); g_object_bind_property_full (mode, "active-id", hbox, "visible", G_BINDING_SYNC_CREATE, mode_transform_to_band_visibility, NULL, NULL, NULL); nmt_editor_grid_append (grid, _("Channel"), hbox, NULL); nmt_editor_grid_append (grid, NULL, nmt_newt_separator_new (), NULL); widget = nmt_newt_popup_new (wifi_security); nmt_editor_grid_append (grid, _("Security"), widget, NULL); security = widget; widget = nmt_newt_stack_new (); stack = NMT_NEWT_STACK (widget); /* none */ subgrid = nmt_editor_grid_new (); nmt_newt_stack_add (stack, "none", subgrid); /* wpa-personal */ subgrid = nmt_editor_grid_new (); widget = nmt_password_fields_new (40, NMT_PASSWORD_FIELDS_SHOW_PASSWORD); g_object_bind_property (s_wsec, NM_SETTING_WIRELESS_SECURITY_PSK, widget, "password", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL); nmt_editor_grid_append (NMT_EDITOR_GRID (subgrid), _("Password"), widget, NULL); nmt_newt_stack_add (stack, "wpa-personal", subgrid); /* "wpa-enterprise" */ // FIXME widget = nmt_newt_label_new (_("(No support for wpa-enterprise yet...)")); nmt_newt_stack_add (stack, "wpa-enterprise", widget); /* wep-key */ subgrid = nmt_editor_grid_new (); widget = entry = nmt_password_fields_new (40, NMT_PASSWORD_FIELDS_SHOW_PASSWORD); nmt_editor_grid_append (NMT_EDITOR_GRID (subgrid), _("Key"), widget, NULL); widget = nmt_newt_popup_new (wep_index); nmt_editor_grid_append (NMT_EDITOR_GRID (subgrid), _("WEP index"), widget, NULL); nm_editor_bind_wireless_security_wep_key (s_wsec, entry, "password", widget, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); widget = nmt_newt_popup_new (wep_auth); nmt_editor_grid_append (NMT_EDITOR_GRID (subgrid), _("Authentication"), widget, NULL); nmt_newt_stack_add (stack, "wep-key", subgrid); /* wep-passphrase */ subgrid = nmt_editor_grid_new (); widget = entry = nmt_password_fields_new (40, NMT_PASSWORD_FIELDS_SHOW_PASSWORD); nmt_editor_grid_append (NMT_EDITOR_GRID (subgrid), _("Password"), widget, NULL); widget = nmt_newt_popup_new (wep_index); nmt_editor_grid_append (NMT_EDITOR_GRID (subgrid), _("WEP index"), widget, NULL); nm_editor_bind_wireless_security_wep_key (s_wsec, entry, "password", widget, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); widget = nmt_newt_popup_new (wep_auth); nmt_editor_grid_append (NMT_EDITOR_GRID (subgrid), _("Authentication"), widget, NULL); nmt_newt_stack_add (stack, "wep-passphrase", subgrid); /* "dynamic-wep" */ // FIXME widget = nmt_newt_label_new (_("(No support for dynamic-wep yet...)")); nmt_newt_stack_add (stack, "dynamic-wep", widget); /* leap */ subgrid = nmt_editor_grid_new (); widget = nmt_newt_entry_new (40, NMT_NEWT_ENTRY_NONEMPTY); nmt_editor_grid_append (NMT_EDITOR_GRID (subgrid), _("Username"), widget, NULL); g_object_bind_property (s_wsec, NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME, widget, "text", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL); widget = nmt_password_fields_new (40, NMT_PASSWORD_FIELDS_SHOW_PASSWORD); g_object_bind_property (s_wsec, NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD, widget, "password", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL); nmt_editor_grid_append (NMT_EDITOR_GRID (subgrid), _("Password"), widget, NULL); nmt_newt_stack_add (stack, "leap", subgrid); nmt_editor_grid_append (grid, NULL, NMT_NEWT_WIDGET (stack), NULL); g_object_bind_property (security, "active-id", stack, "active-id", G_BINDING_SYNC_CREATE); nm_editor_bind_wireless_security_method (conn, s_wsec, security, "active-id", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); nmt_editor_grid_append (grid, NULL, nmt_newt_separator_new (), NULL); widget = nmt_mac_entry_new (40, ETH_ALEN); g_object_bind_property (s_wireless, NM_SETTING_WIRELESS_BSSID, widget, "mac-address", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); nmt_editor_grid_append (grid, _("BSSID"), widget, NULL); widget = nmt_mac_entry_new (40, ETH_ALEN); g_object_bind_property (s_wireless, NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS, widget, "mac-address", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); nmt_editor_grid_append (grid, _("Cloned MAC address"), widget, NULL); widget = nmt_mtu_entry_new (); g_object_bind_property (s_wireless, NM_SETTING_WIRELESS_MTU, widget, "mtu", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); nmt_editor_grid_append (grid, _("MTU"), widget, NULL); nmt_editor_page_add_section (NMT_EDITOR_PAGE (wifi), section); G_OBJECT_CLASS (nmt_page_wifi_parent_class)->constructed (object); }