[network-manager-applet/danw/virtual-devs: 3/5] applet: remove duplicated menu item creation code
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet/danw/virtual-devs: 3/5] applet: remove duplicated menu item creation code
- Date: Fri, 17 May 2013 13:54:28 +0000 (UTC)
commit cb9dc82ba4e641663b7d87f32971d536913cbffb
Author: Dan Winship <danw gnome org>
Date: Fri May 17 07:21:16 2013 -0400
applet: remove duplicated menu item creation code
Several device types had basically identical menu item creation code
(originally copied from applet-device-ethernet.c). Move that into
applet.c.
src/applet-device-bond.c | 106 +----------------------------------------
src/applet-device-bridge.c | 106 +----------------------------------------
src/applet-device-bt.c | 79 +------------------------------
src/applet-device-ethernet.c | 108 +----------------------------------------
src/applet-device-vlan.c | 108 +----------------------------------------
src/applet.c | 96 +++++++++++++++++++++++++++++++++++++
src/applet.h | 18 +++++++
7 files changed, 128 insertions(+), 493 deletions(-)
---
diff --git a/src/applet-device-bond.c b/src/applet-device-bond.c
index 210e46a..18ad3b1 100644
--- a/src/applet-device-bond.c
+++ b/src/applet-device-bond.c
@@ -39,106 +39,6 @@
#include "applet-device-bond.h"
#include "utils.h"
-typedef struct {
- NMApplet *applet;
- NMDevice *device;
- NMConnection *connection;
-} BondMenuItemInfo;
-
-static void
-bond_menu_item_info_destroy (gpointer data)
-{
- BondMenuItemInfo *info = (BondMenuItemInfo *) data;
-
- g_object_unref (G_OBJECT (info->device));
- if (info->connection)
- g_object_unref (G_OBJECT (info->connection));
-
- g_slice_free (BondMenuItemInfo, data);
-}
-
-static void
-bond_menu_item_activate (GtkMenuItem *item, gpointer user_data)
-{
- BondMenuItemInfo *info = (BondMenuItemInfo *) user_data;
-
- applet_menu_item_activate_helper (info->device,
- info->connection,
- "/",
- info->applet,
- user_data);
-}
-
-
-typedef enum {
- ADD_ACTIVE = 1,
- ADD_INACTIVE = 2,
-} AddActiveInactiveEnum;
-
-static void
-add_connection_items (NMDevice *device,
- GSList *connections,
- NMConnection *active,
- AddActiveInactiveEnum flag,
- GtkWidget *menu,
- NMApplet *applet)
-{
- GSList *iter;
- BondMenuItemInfo *info;
-
- for (iter = connections; iter; iter = g_slist_next (iter)) {
- NMConnection *connection = NM_CONNECTION (iter->data);
- GtkWidget *item;
-
- if (active == connection) {
- if ((flag & ADD_ACTIVE) == 0)
- continue;
- } else {
- if ((flag & ADD_INACTIVE) == 0)
- continue;
- }
-
- item = applet_new_menu_item_helper (connection, active, (flag & ADD_ACTIVE));
- gtk_widget_set_sensitive (item, TRUE);
-
- info = g_slice_new0 (BondMenuItemInfo);
- info->applet = applet;
- info->device = g_object_ref (G_OBJECT (device));
- info->connection = g_object_ref (connection);
-
- g_signal_connect_data (item, "activate",
- G_CALLBACK (bond_menu_item_activate),
- info,
- (GClosureNotify) bond_menu_item_info_destroy, 0);
-
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- }
-}
-
-static void
-add_default_connection_item (NMDevice *device,
- GtkWidget *menu,
- NMApplet *applet)
-{
- BondMenuItemInfo *info;
- GtkWidget *item;
-
- item = gtk_check_menu_item_new_with_label (_("Configure bond connections..."));
- gtk_widget_set_sensitive (GTK_WIDGET (item), TRUE);
- gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (item), TRUE);
-
- info = g_slice_new0 (BondMenuItemInfo);
- info->applet = applet;
- info->device = g_object_ref (G_OBJECT (device));
-
- g_signal_connect_data (item, "activate",
- G_CALLBACK (bond_menu_item_activate),
- info,
- (GClosureNotify) bond_menu_item_info_destroy, 0);
-
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-}
-
static void
bond_add_menu_item (NMDevice *device,
guint32 n_devices,
@@ -163,7 +63,7 @@ bond_add_menu_item (NMDevice *device,
gtk_widget_show (item);
if (g_slist_length (connections))
- add_connection_items (device, connections, active, ADD_ACTIVE, menu, applet);
+ 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);
@@ -177,9 +77,9 @@ bond_add_menu_item (NMDevice *device,
applet_menu_item_add_complex_separator_helper (menu, applet, _("Available"), -1);
if (g_slist_length (connections))
- add_connection_items (device, connections, active, ADD_INACTIVE, menu, applet);
+ applet_add_connection_items (device, connections, TRUE, active, NMA_ADD_INACTIVE,
menu, applet);
else
- add_default_connection_item (device, menu, applet);
+ applet_add_default_connection_item (device, _("Configure bond connections..."), TRUE,
menu, applet);
}
g_slist_free (connections);
diff --git a/src/applet-device-bridge.c b/src/applet-device-bridge.c
index 656a4f2..4cf0c44 100644
--- a/src/applet-device-bridge.c
+++ b/src/applet-device-bridge.c
@@ -39,106 +39,6 @@
#include "applet-device-bridge.h"
#include "utils.h"
-typedef struct {
- NMApplet *applet;
- NMDevice *device;
- NMConnection *connection;
-} BridgeMenuItemInfo;
-
-static void
-bridge_menu_item_info_destroy (gpointer data)
-{
- BridgeMenuItemInfo *info = (BridgeMenuItemInfo *) data;
-
- g_object_unref (G_OBJECT (info->device));
- if (info->connection)
- g_object_unref (G_OBJECT (info->connection));
-
- g_slice_free (BridgeMenuItemInfo, data);
-}
-
-static void
-bridge_menu_item_activate (GtkMenuItem *item, gpointer user_data)
-{
- BridgeMenuItemInfo *info = (BridgeMenuItemInfo *) user_data;
-
- applet_menu_item_activate_helper (info->device,
- info->connection,
- "/",
- info->applet,
- user_data);
-}
-
-
-typedef enum {
- ADD_ACTIVE = 1,
- ADD_INACTIVE = 2,
-} AddActiveInactiveEnum;
-
-static void
-add_connection_items (NMDevice *device,
- GSList *connections,
- NMConnection *active,
- AddActiveInactiveEnum flag,
- GtkWidget *menu,
- NMApplet *applet)
-{
- GSList *iter;
- BridgeMenuItemInfo *info;
-
- for (iter = connections; iter; iter = g_slist_next (iter)) {
- NMConnection *connection = NM_CONNECTION (iter->data);
- GtkWidget *item;
-
- if (active == connection) {
- if ((flag & ADD_ACTIVE) == 0)
- continue;
- } else {
- if ((flag & ADD_INACTIVE) == 0)
- continue;
- }
-
- item = applet_new_menu_item_helper (connection, active, (flag & ADD_ACTIVE));
- gtk_widget_set_sensitive (item, TRUE);
-
- info = g_slice_new0 (BridgeMenuItemInfo);
- info->applet = applet;
- info->device = g_object_ref (G_OBJECT (device));
- info->connection = g_object_ref (connection);
-
- g_signal_connect_data (item, "activate",
- G_CALLBACK (bridge_menu_item_activate),
- info,
- (GClosureNotify) bridge_menu_item_info_destroy, 0);
-
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- }
-}
-
-static void
-add_default_connection_item (NMDevice *device,
- GtkWidget *menu,
- NMApplet *applet)
-{
- BridgeMenuItemInfo *info;
- GtkWidget *item;
-
- item = gtk_check_menu_item_new_with_label (_("Configure bridge connections..."));
- gtk_widget_set_sensitive (GTK_WIDGET (item), TRUE);
- gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (item), TRUE);
-
- info = g_slice_new0 (BridgeMenuItemInfo);
- info->applet = applet;
- info->device = g_object_ref (G_OBJECT (device));
-
- g_signal_connect_data (item, "activate",
- G_CALLBACK (bridge_menu_item_activate),
- info,
- (GClosureNotify) bridge_menu_item_info_destroy, 0);
-
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-}
-
static void
bridge_add_menu_item (NMDevice *device,
guint32 n_devices,
@@ -163,7 +63,7 @@ bridge_add_menu_item (NMDevice *device,
gtk_widget_show (item);
if (g_slist_length (connections))
- add_connection_items (device, connections, active, ADD_ACTIVE, menu, applet);
+ 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);
@@ -177,9 +77,9 @@ bridge_add_menu_item (NMDevice *device,
applet_menu_item_add_complex_separator_helper (menu, applet, _("Available"), -1);
if (g_slist_length (connections))
- add_connection_items (device, connections, active, ADD_INACTIVE, menu, applet);
+ applet_add_connection_items (device, connections, TRUE, active, NMA_ADD_INACTIVE,
menu, applet);
else
- add_default_connection_item (device, menu, applet);
+ applet_add_default_connection_item (device, _("Configure bridge connections..."),
TRUE, menu, applet);
}
g_slist_free (connections);
diff --git a/src/applet-device-bt.c b/src/applet-device-bt.c
index 811a637..d6d864d 100644
--- a/src/applet-device-bt.c
+++ b/src/applet-device-bt.c
@@ -42,24 +42,6 @@
#include "applet-dialogs.h"
#include "nm-ui-utils.h"
-typedef struct {
- NMApplet *applet;
- NMDevice *device;
- NMConnection *connection;
-} BtMenuItemInfo;
-
-static void
-bt_menu_item_info_destroy (gpointer data)
-{
- BtMenuItemInfo *info = data;
-
- g_object_unref (G_OBJECT (info->device));
- if (info->connection)
- g_object_unref (G_OBJECT (info->connection));
-
- g_slice_free (BtMenuItemInfo, data);
-}
-
static gboolean
bt_new_auto_connection (NMDevice *device,
gpointer dclass_data,
@@ -72,63 +54,6 @@ bt_new_auto_connection (NMDevice *device,
}
static void
-bt_menu_item_activate (GtkMenuItem *item, gpointer user_data)
-{
- BtMenuItemInfo *info = user_data;
-
- applet_menu_item_activate_helper (info->device,
- info->connection,
- "/",
- info->applet,
- user_data);
-}
-
-
-typedef enum {
- ADD_ACTIVE = 1,
- ADD_INACTIVE = 2,
-} AddActiveInactiveEnum;
-
-static void
-add_connection_items (NMDevice *device,
- GSList *connections,
- NMConnection *active,
- AddActiveInactiveEnum flag,
- GtkWidget *menu,
- NMApplet *applet)
-{
- GSList *iter;
- BtMenuItemInfo *info;
-
- for (iter = connections; iter; iter = g_slist_next (iter)) {
- NMConnection *connection = NM_CONNECTION (iter->data);
- GtkWidget *item;
-
- if (active == connection) {
- if ((flag & ADD_ACTIVE) == 0)
- continue;
- } else {
- if ((flag & ADD_INACTIVE) == 0)
- continue;
- }
-
- item = applet_new_menu_item_helper (connection, active, (flag & ADD_ACTIVE));
-
- info = g_slice_new0 (BtMenuItemInfo);
- info->applet = applet;
- info->device = g_object_ref (G_OBJECT (device));
- info->connection = g_object_ref (connection);
-
- g_signal_connect_data (item, "activate",
- G_CALLBACK (bt_menu_item_activate),
- info,
- (GClosureNotify) bt_menu_item_info_destroy, 0);
-
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- }
-}
-
-static void
bt_add_menu_item (NMDevice *device,
guint32 n_devices,
NMConnection *active,
@@ -154,7 +79,7 @@ bt_add_menu_item (NMDevice *device,
gtk_widget_show (item);
if (g_slist_length (connections))
- add_connection_items (device, connections, active, ADD_ACTIVE, menu, applet);
+ 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);
@@ -167,7 +92,7 @@ bt_add_menu_item (NMDevice *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);
+ applet_add_connection_items (device, connections, TRUE, active, NMA_ADD_INACTIVE,
menu, applet);
}
}
diff --git a/src/applet-device-ethernet.c b/src/applet-device-ethernet.c
index fecad17..b06c06f 100644
--- a/src/applet-device-ethernet.c
+++ b/src/applet-device-ethernet.c
@@ -41,24 +41,6 @@
#include "ethernet-dialog.h"
#include "nm-ui-utils.h"
-typedef struct {
- NMApplet *applet;
- NMDevice *device;
- NMConnection *connection;
-} EthernetMenuItemInfo;
-
-static void
-ethernet_menu_item_info_destroy (gpointer data)
-{
- EthernetMenuItemInfo *info = (EthernetMenuItemInfo *) data;
-
- g_object_unref (G_OBJECT (info->device));
- if (info->connection)
- g_object_unref (G_OBJECT (info->connection));
-
- g_slice_free (EthernetMenuItemInfo, data);
-}
-
#define DEFAULT_ETHERNET_NAME _("Auto Ethernet")
static gboolean
@@ -94,90 +76,6 @@ ethernet_new_auto_connection (NMDevice *device,
}
static void
-ethernet_menu_item_activate (GtkMenuItem *item, gpointer user_data)
-{
- EthernetMenuItemInfo *info = (EthernetMenuItemInfo *) user_data;
-
- applet_menu_item_activate_helper (info->device,
- info->connection,
- "/",
- info->applet,
- user_data);
-}
-
-
-typedef enum {
- ADD_ACTIVE = 1,
- ADD_INACTIVE = 2,
-} AddActiveInactiveEnum;
-
-static void
-add_connection_items (NMDevice *device,
- GSList *connections,
- gboolean carrier,
- NMConnection *active,
- AddActiveInactiveEnum flag,
- GtkWidget *menu,
- NMApplet *applet)
-{
- GSList *iter;
- EthernetMenuItemInfo *info;
-
- for (iter = connections; iter; iter = g_slist_next (iter)) {
- NMConnection *connection = NM_CONNECTION (iter->data);
- GtkWidget *item;
-
- if (active == connection) {
- if ((flag & ADD_ACTIVE) == 0)
- continue;
- } else {
- if ((flag & ADD_INACTIVE) == 0)
- continue;
- }
-
- item = applet_new_menu_item_helper (connection, active, (flag & ADD_ACTIVE));
- gtk_widget_set_sensitive (item, carrier);
-
- info = g_slice_new0 (EthernetMenuItemInfo);
- info->applet = applet;
- info->device = g_object_ref (G_OBJECT (device));
- info->connection = g_object_ref (connection);
-
- g_signal_connect_data (item, "activate",
- G_CALLBACK (ethernet_menu_item_activate),
- info,
- (GClosureNotify) ethernet_menu_item_info_destroy, 0);
-
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- }
-}
-
-static void
-add_default_connection_item (NMDevice *device,
- gboolean carrier,
- GtkWidget *menu,
- NMApplet *applet)
-{
- EthernetMenuItemInfo *info;
- GtkWidget *item;
-
- item = gtk_check_menu_item_new_with_label (DEFAULT_ETHERNET_NAME);
- gtk_widget_set_sensitive (GTK_WIDGET (item), carrier);
- gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (item), TRUE);
-
- info = g_slice_new0 (EthernetMenuItemInfo);
- info->applet = applet;
- info->device = g_object_ref (G_OBJECT (device));
-
- g_signal_connect_data (item, "activate",
- G_CALLBACK (ethernet_menu_item_activate),
- info,
- (GClosureNotify) ethernet_menu_item_info_destroy, 0);
-
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-}
-
-static void
ethernet_add_menu_item (NMDevice *device,
guint32 n_devices,
NMConnection *active,
@@ -223,7 +121,7 @@ ethernet_add_menu_item (NMDevice *device,
gtk_widget_show (item);
if (g_slist_length (connections))
- add_connection_items (device, connections, carrier, active, ADD_ACTIVE, menu, applet);
+ applet_add_connection_items (device, connections, carrier, active, NMA_ADD_ACTIVE, menu,
applet);
/* Notify user of unmanaged or unavailable device */
item = nma_menu_device_get_menu_item (device, applet, carrier ? NULL : _("disconnected"));
@@ -237,9 +135,9 @@ ethernet_add_menu_item (NMDevice *device,
applet_menu_item_add_complex_separator_helper (menu, applet, _("Available"), -1);
if (g_slist_length (connections))
- add_connection_items (device, connections, carrier, active, ADD_INACTIVE, menu,
applet);
+ applet_add_connection_items (device, connections, carrier, active, NMA_ADD_INACTIVE,
menu, applet);
else
- add_default_connection_item (device, carrier, menu, applet);
+ applet_add_default_connection_item (device, DEFAULT_ETHERNET_NAME, carrier, menu,
applet);
}
g_slist_free (connections);
diff --git a/src/applet-device-vlan.c b/src/applet-device-vlan.c
index a01358d..6010620 100644
--- a/src/applet-device-vlan.c
+++ b/src/applet-device-vlan.c
@@ -39,108 +39,6 @@
#include "applet-device-vlan.h"
#include "nm-ui-utils.h"
-typedef struct {
- NMApplet *applet;
- NMDevice *device;
- NMConnection *connection;
-} VlanMenuItemInfo;
-
-static void
-vlan_menu_item_info_destroy (gpointer data)
-{
- VlanMenuItemInfo *info = (VlanMenuItemInfo *) data;
-
- g_object_unref (G_OBJECT (info->device));
- if (info->connection)
- g_object_unref (G_OBJECT (info->connection));
-
- g_slice_free (VlanMenuItemInfo, data);
-}
-
-static void
-vlan_menu_item_activate (GtkMenuItem *item, gpointer user_data)
-{
- VlanMenuItemInfo *info = (VlanMenuItemInfo *) user_data;
-
- applet_menu_item_activate_helper (info->device,
- info->connection,
- "/",
- info->applet,
- user_data);
-}
-
-
-typedef enum {
- ADD_ACTIVE = 1,
- ADD_INACTIVE = 2,
-} AddActiveInactiveEnum;
-
-static void
-add_connection_items (NMDevice *device,
- GSList *connections,
- gboolean carrier,
- NMConnection *active,
- AddActiveInactiveEnum flag,
- GtkWidget *menu,
- NMApplet *applet)
-{
- GSList *iter;
- VlanMenuItemInfo *info;
-
- for (iter = connections; iter; iter = g_slist_next (iter)) {
- NMConnection *connection = NM_CONNECTION (iter->data);
- GtkWidget *item;
-
- if (active == connection) {
- if ((flag & ADD_ACTIVE) == 0)
- continue;
- } else {
- if ((flag & ADD_INACTIVE) == 0)
- continue;
- }
-
- item = applet_new_menu_item_helper (connection, active, (flag & ADD_ACTIVE));
- gtk_widget_set_sensitive (item, carrier);
-
- info = g_slice_new0 (VlanMenuItemInfo);
- info->applet = applet;
- info->device = g_object_ref (G_OBJECT (device));
- info->connection = g_object_ref (connection);
-
- g_signal_connect_data (item, "activate",
- G_CALLBACK (vlan_menu_item_activate),
- info,
- (GClosureNotify) vlan_menu_item_info_destroy, 0);
-
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- }
-}
-
-static void
-add_default_connection_item (NMDevice *device,
- gboolean carrier,
- GtkWidget *menu,
- NMApplet *applet)
-{
- VlanMenuItemInfo *info;
- GtkWidget *item;
-
- item = gtk_check_menu_item_new_with_label (_("Configure VLAN connections..."));
- gtk_widget_set_sensitive (GTK_WIDGET (item), carrier);
- gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (item), TRUE);
-
- info = g_slice_new0 (VlanMenuItemInfo);
- info->applet = applet;
- info->device = g_object_ref (G_OBJECT (device));
-
- g_signal_connect_data (item, "activate",
- G_CALLBACK (vlan_menu_item_activate),
- info,
- (GClosureNotify) vlan_menu_item_info_destroy, 0);
-
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-}
-
static void
vlan_add_menu_item (NMDevice *device,
guint32 n_devices,
@@ -187,7 +85,7 @@ vlan_add_menu_item (NMDevice *device,
gtk_widget_show (item);
if (g_slist_length (connections))
- add_connection_items (device, connections, carrier, active, ADD_ACTIVE, menu, applet);
+ applet_add_connection_items (device, connections, carrier, active, NMA_ADD_ACTIVE, menu,
applet);
/* Notify user of unmanaged or unavailable device */
item = nma_menu_device_get_menu_item (device, applet, carrier ? NULL : _("disconnected"));
@@ -201,9 +99,9 @@ vlan_add_menu_item (NMDevice *device,
applet_menu_item_add_complex_separator_helper (menu, applet, _("Available"), -1);
if (g_slist_length (connections))
- add_connection_items (device, connections, carrier, active, ADD_INACTIVE, menu,
applet);
+ applet_add_connection_items (device, connections, carrier, active, NMA_ADD_INACTIVE,
menu, applet);
else
- add_default_connection_item (device, carrier, menu, applet);
+ applet_add_default_connection_item (device, _("Configure VLAN connections..."),
carrier, menu, applet);
}
g_slist_free (connections);
diff --git a/src/applet.c b/src/applet.c
index ba7364c..ccbdc18 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -2156,6 +2156,102 @@ static GtkWidget *nma_context_menu_create (NMApplet *applet)
return GTK_WIDGET (menu);
}
+typedef struct {
+ NMApplet *applet;
+ NMDevice *device;
+ NMConnection *connection;
+} AppletMenuItemInfo;
+
+static void
+applet_menu_item_info_destroy (gpointer data, GClosure *closure)
+{
+ AppletMenuItemInfo *info = data;
+
+ g_clear_object (&info->device);
+ g_clear_object (&info->connection);
+
+ g_slice_free (AppletMenuItemInfo, data);
+}
+
+static void
+applet_menu_item_activate (GtkMenuItem *item, gpointer user_data)
+{
+ AppletMenuItemInfo *info = user_data;
+
+ applet_menu_item_activate_helper (info->device,
+ info->connection,
+ "/",
+ info->applet,
+ user_data);
+}
+
+void
+applet_add_connection_items (NMDevice *device,
+ GSList *connections,
+ gboolean sensitive,
+ NMConnection *active,
+ NMAAddActiveInactiveEnum flag,
+ GtkWidget *menu,
+ NMApplet *applet)
+{
+ GSList *iter;
+ AppletMenuItemInfo *info;
+
+ for (iter = connections; iter; iter = iter->next) {
+ NMConnection *connection = NM_CONNECTION (iter->data);
+ GtkWidget *item;
+
+ if (active == connection) {
+ if ((flag & NMA_ADD_ACTIVE) == 0)
+ continue;
+ } else {
+ if ((flag & NMA_ADD_INACTIVE) == 0)
+ continue;
+ }
+
+ item = applet_new_menu_item_helper (connection, active, (flag & NMA_ADD_ACTIVE));
+ gtk_widget_set_sensitive (item, sensitive);
+
+ info = g_slice_new0 (AppletMenuItemInfo);
+ info->applet = applet;
+ info->device = g_object_ref (device);
+ info->connection = g_object_ref (connection);
+
+ g_signal_connect_data (item, "activate",
+ G_CALLBACK (applet_menu_item_activate),
+ info,
+ applet_menu_item_info_destroy, 0);
+
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+ }
+}
+
+void
+applet_add_default_connection_item (NMDevice *device,
+ const char *label,
+ gboolean sensitive,
+ GtkWidget *menu,
+ NMApplet *applet)
+{
+ AppletMenuItemInfo *info;
+ GtkWidget *item;
+
+ item = gtk_check_menu_item_new_with_label (label);
+ gtk_widget_set_sensitive (GTK_WIDGET (item), sensitive);
+ gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (item), TRUE);
+
+ info = g_slice_new0 (AppletMenuItemInfo);
+ info->applet = applet;
+ info->device = g_object_ref (device);
+
+ g_signal_connect_data (item, "activate",
+ G_CALLBACK (applet_menu_item_activate),
+ info,
+ applet_menu_item_info_destroy, 0);
+
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+}
+
/*****************************************************************************/
diff --git a/src/applet.h b/src/applet.h
index a0bd271..849a9e2 100644
--- a/src/applet.h
+++ b/src/applet.h
@@ -339,5 +339,23 @@ gboolean applet_wifi_can_create_wifi_network (NMApplet *applet);
void nma_edit_connections (void);
+typedef enum {
+ NMA_ADD_ACTIVE = 1,
+ NMA_ADD_INACTIVE = 2,
+} NMAAddActiveInactiveEnum;
+
+void applet_add_connection_items (NMDevice *device,
+ GSList *connections,
+ gboolean sensitive,
+ NMConnection *active,
+ NMAAddActiveInactiveEnum flag,
+ GtkWidget *menu,
+ NMApplet *applet);
+
+void applet_add_default_connection_item (NMDevice *device,
+ const char *label,
+ gboolean sensitive,
+ GtkWidget *menu,
+ NMApplet *applet);
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]