static void vlan_add_menu_item (NMDevice *device, gboolean multiple_devices, GSList *connections, NMConnection *active, GtkWidget *menu, NMApplet *applet) { char *text; GtkWidget *item; gboolean carrier = TRUE; text = nma_utils_get_connection_device_name (connections->data); item = applet_menu_item_create_device_item_helper (device, applet, text); g_free (text); /* If the VLAN device exists, check its carrier */ if (device && nm_device_get_capabilities (device) & NM_DEVICE_CAP_CARRIER_DETECT) carrier = nm_device_vlan_get_carrier (NM_DEVICE_VLAN (device)); else { NMDevice *parent; /* If we can find its parent, check the parent's carrier */ parent = find_vlan_parent (connections, applet); if (parent && nm_device_get_capabilities (parent) & NM_DEVICE_CAP_CARRIER_DETECT) g_object_get (G_OBJECT (parent), "carrier", &carrier, NULL); } /* else fall back to assuming carrier is present */ gtk_widget_set_sensitive (item, FALSE); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); if (g_slist_length (connections)) applet_add_connection_items (device, connections, carrier, active, NMA_ADD_ACTIVE, menu, applet); /* Notify user of unmanaged or unavailable device */ if (device) { item = nma_menu_device_get_menu_item (device, applet, carrier ? NULL : _("disconnected")); if (item) { gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); } } if (!device || !nma_menu_device_check_unusable (device)) { if ((!active && g_slist_length (connections)) || (active && g_slist_length (connections) > 1)) applet_menu_item_add_complex_separator_helper (menu, applet, _("Available")); if (g_slist_length (connections)) applet_add_connection_items (device, connections, carrier, active, NMA_ADD_INACTIVE, menu, applet); } }
static void bt_add_menu_item (NMDevice *device, guint32 n_devices, NMConnection *active, GtkWidget *menu, NMApplet *applet) { const char *text; GtkWidget *item; GSList *connections, *all; all = applet_get_all_connections (applet); connections = nm_device_filter_connections (device, all); g_slist_free (all); text = nm_device_bt_get_name (NM_DEVICE_BT (device)); if (!text) { text = utils_get_device_description (device); if (!text) text = nm_device_get_iface (device); g_assert (text); } item = applet_menu_item_create_device_item_helper (device, applet, text); gtk_widget_set_sensitive (item, FALSE); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); if (g_slist_length (connections)) add_connection_items (device, connections, active, ADD_ACTIVE, menu, applet); /* Notify user of unmanaged or unavailable device */ item = nma_menu_device_get_menu_item (device, applet, NULL); if (item) { gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); } if (!nma_menu_device_check_unusable (device)) { /* Add menu items for existing bluetooth connections for this device */ if (g_slist_length (connections)) { applet_menu_item_add_complex_separator_helper (menu, applet, _("Available"), -1); add_connection_items (device, connections, active, ADD_INACTIVE, menu, applet); } } g_slist_free (connections); }
static void bt_add_menu_item (NMDevice *device, gboolean multiple__devices, const GPtrArray *connections, NMConnection *active, GtkWidget *menu, NMApplet *applet) { const char *text; GtkWidget *item; text = nm_device_bt_get_name (NM_DEVICE_BT (device)); if (!text) text = nm_device_get_description (device); item = applet_menu_item_create_device_item_helper (device, applet, text); gtk_widget_set_sensitive (item, FALSE); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); if (connections->len) applet_add_connection_items (device, connections, TRUE, active, NMA_ADD_ACTIVE, menu, applet); /* Notify user of unmanaged or unavailable device */ item = nma_menu_device_get_menu_item (device, applet, NULL); if (item) { gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); } if (!nma_menu_device_check_unusable (device)) { /* Add menu items for existing bluetooth connections for this device */ if (connections->len) { applet_menu_item_add_complex_separator_helper (menu, applet, _("Available")); applet_add_connection_items (device, connections, TRUE, active, NMA_ADD_INACTIVE, menu, applet); } } }
static void bridge_add_menu_item (NMDevice *device, gboolean multiple_devices, GSList *connections, NMConnection *active, GtkWidget *menu, NMApplet *applet) { char *text; GtkWidget *item; text = nma_utils_get_connection_device_name (connections->data); item = applet_menu_item_create_device_item_helper (device, applet, text); g_free (text); gtk_widget_set_sensitive (item, FALSE); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); if (g_slist_length (connections)) applet_add_connection_items (device, connections, TRUE, active, NMA_ADD_ACTIVE, menu, applet); /* Notify user of unmanaged or unavailable device */ if (device) { item = nma_menu_device_get_menu_item (device, applet, NULL); if (item) { gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); } } if (!device || !nma_menu_device_check_unusable (device)) { if ((!active && g_slist_length (connections)) || (active && g_slist_length (connections) > 1)) applet_menu_item_add_complex_separator_helper (menu, applet, _("Available")); if (g_slist_length (connections)) applet_add_connection_items (device, connections, TRUE, active, NMA_ADD_INACTIVE, menu, applet); } }
static void add_menu_item (NMDevice *device, guint32 n_devices, NMConnection *active, GtkWidget *menu, NMApplet *applet) { BroadbandDeviceInfo *info; char *text; GtkWidget *item; GSList *connections, *all, *iter; info = g_object_get_data (G_OBJECT (device), "devinfo"); all = applet_get_all_connections (applet); connections = nm_device_filter_connections (device, all); g_slist_free (all); if (n_devices > 1) { const char *desc; desc = nma_utils_get_device_description (device); text = g_strdup_printf (_("Mobile Broadband (%s)"), desc); } else { text = g_strdup (_("Mobile Broadband")); } item = applet_menu_item_create_device_item_helper (device, applet, text); gtk_widget_set_sensitive (item, FALSE); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); g_free (text); /* Add the active connection */ if (active) { NMSettingConnection *s_con; s_con = nm_connection_get_setting_connection (active); g_assert (s_con); item = nm_mb_menu_item_new (nm_setting_connection_get_id (s_con), mm_modem_get_signal_quality (info->mm_modem, NULL), info->operator_name, TRUE, broadband_act_to_mb_act (info), broadband_state_to_mb_state (info), mm_modem_get_state (info->mm_modem) >= MM_MODEM_STATE_ENABLED, applet); gtk_widget_set_sensitive (GTK_WIDGET (item), TRUE); add_connection_item (device, active, item, menu, applet); } /* Notify user of unmanaged or unavailable device */ if (nm_device_get_state (device) > NM_DEVICE_STATE_DISCONNECTED) { item = nma_menu_device_get_menu_item (device, applet, NULL); if (item) { gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); } } else { /* Otherwise show idle registration state or disabled */ item = nm_mb_menu_item_new (NULL, mm_modem_get_signal_quality (info->mm_modem, NULL), info->operator_name, FALSE, broadband_act_to_mb_act (info), broadband_state_to_mb_state (info), mm_modem_get_state (info->mm_modem) >= MM_MODEM_STATE_ENABLED, applet); gtk_widget_set_sensitive (GTK_WIDGET (item), FALSE); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); } /* Add the default / inactive connection items */ if (!nma_menu_device_check_unusable (device)) { if ((!active && g_slist_length (connections)) || (active && g_slist_length (connections) > 1)) applet_menu_item_add_complex_separator_helper (menu, applet, _("Available"), -1); if (g_slist_length (connections)) { for (iter = connections; iter; iter = g_slist_next (iter)) { NMConnection *connection = NM_CONNECTION (iter->data); if (connection != active) { item = applet_new_menu_item_helper (connection, NULL, FALSE); add_connection_item (device, connection, item, menu, applet); } } } else { /* Default connection item */ item = gtk_check_menu_item_new_with_label (_("New Mobile Broadband connection...")); add_connection_item (device, NULL, item, menu, applet); } } g_slist_free (connections); }
static void wimax_add_menu_item (NMDevice *device, guint32 n_devices, NMConnection *active, GtkWidget *menu, NMApplet *applet) { NMDeviceWimax *wimax = NM_DEVICE_WIMAX (device); char *text; GtkWidget *item; GSList *connections, *all, *iter, *sorted = NULL; const GPtrArray *nsps; NMWimaxNsp *active_nsp = NULL; gboolean wimax_enabled, wimax_hw_enabled; int i; nsps = nm_device_wimax_get_nsps (wimax); if (n_devices > 1) { const char *desc; desc = nma_utils_get_device_description (device); text = g_strdup_printf (_("WiMAX Mobile Broadband (%s)"), desc); } else { text = g_strdup (_("WiMAX Mobile Broadband")); } item = applet_menu_item_create_device_item_helper (device, applet, text); gtk_widget_set_sensitive (item, FALSE); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); g_free (text); /* Add the active NSP if we're connected to something and the device is available */ if (!nma_menu_device_check_unusable (device)) { active_nsp = nm_device_wimax_get_active_nsp (wimax); if (active_nsp) { item = new_nsp_menu_item (wimax, active, TRUE, active_nsp, applet); if (item) { gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); } } } /* Notify user of unmanaged or unavailable device */ wimax_enabled = nm_client_wimax_get_enabled (applet->nm_client); wimax_hw_enabled = nm_client_wimax_hardware_get_enabled (applet->nm_client); item = nma_menu_device_get_menu_item (device, applet, wimax_hw_enabled ? (wimax_enabled ? NULL : _("WiMAX is disabled")) : _("WiMAX is disabled by hardware switch")); if (item) { gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); } /* If disabled or rfkilled or whatever, nothing left to do */ if (nma_menu_device_check_unusable (device)) return; /* Create a sorted list of NSPs */ for (i = 0; nsps && (i < nsps->len); i++) { NMWimaxNsp *nsp = g_ptr_array_index (nsps, i); if (nsp != active_nsp) sorted = g_slist_insert_sorted (sorted, nsp, sort_nsps); } if (g_slist_length (sorted)) { applet_menu_item_add_complex_separator_helper (menu, applet, _("Available"), -1); all = applet_get_all_connections (applet); connections = nm_device_filter_connections (device, all); g_slist_free (all); /* And add menu items for each NSP */ for (iter = sorted; iter; iter = g_slist_next (iter)) { NMWimaxNsp *nsp = NM_WIMAX_NSP (iter->data); NMConnection *connection = NULL; connection = get_connection_for_nsp (connections, nsp); item = new_nsp_menu_item (wimax, connection, FALSE, nsp, applet); if (item) { gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); } } g_slist_free (connections); } g_slist_free (sorted); }