network-manager-applet r768 - in trunk: . src src/connection-editor



Author: dcbw
Date: Thu Jun 26 17:36:11 2008
New Revision: 768
URL: http://svn.gnome.org/viewvc/network-manager-applet?rev=768&view=rev

Log:
2008-06-26  Dan Williams  <dcbw redhat com>

	* src/applet.c
		- (nma_menu_configure_vpn_item_activate): call the connection editor not
			nm-vpn-properties

	* src/connection-editor/nm-connection-list.c
	  src/connection-editor/nm-connection-list.h
		- (nm_connection_list_new): takes the default type
		- (add_connection_tab): if a default type was given, select that type's
			tab

	* src/connection-editor/main.c
		- (main): add --type argument which will select that type's tab



Modified:
   trunk/ChangeLog
   trunk/src/applet.c
   trunk/src/connection-editor/main.c
   trunk/src/connection-editor/nm-connection-list.c
   trunk/src/connection-editor/nm-connection-list.h

Modified: trunk/src/applet.c
==============================================================================
--- trunk/src/applet.c	(original)
+++ trunk/src/applet.c	Thu Jun 26 17:36:11 2008
@@ -724,7 +724,7 @@
 static void
 nma_menu_configure_vpn_item_activate (GtkMenuItem *item, gpointer user_data)
 {
-	const char *argv[] = { BINDIR "/nm-vpn-properties", NULL};
+	const char *argv[] = { BINDIR "/nm-connection-editor", "--type", NM_SETTING_VPN_SETTING_NAME, NULL};
 
 	g_spawn_async (NULL, (gchar **) argv, NULL, 0, NULL, NULL, NULL, NULL);
 

Modified: trunk/src/connection-editor/main.c
==============================================================================
--- trunk/src/connection-editor/main.c	(original)
+++ trunk/src/connection-editor/main.c	Thu Jun 26 17:36:11 2008
@@ -32,6 +32,7 @@
 #include <glib/gi18n-lib.h>
 #include <dbus/dbus-glib.h>
 
+#include <nm-setting-wired.h>
 #include "nm-connection-list.h"
 
 static GMainLoop *loop = NULL;
@@ -68,8 +69,16 @@
 int
 main (int argc, char *argv[])
 {
+	GOptionContext *opt_ctx;
+	GError *error = NULL;
 	NMConnectionList *list;
 	DBusGConnection *ignore;
+	char *type = NULL;
+
+	GOptionEntry entries[] = {
+		{ "type", 0, 0, G_OPTION_ARG_STRING, &type, "Type of connection to show at launch", NM_SETTING_WIRED_SETTING_NAME },
+		{ NULL }
+	};
 
 	bindtextdomain (GETTEXT_PACKAGE, NMALOCALEDIR);
 	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
@@ -79,13 +88,25 @@
 	/* parse arguments: an idea is to use gconf://$setting_name / system://$setting_name to
 	   allow this program to work with both GConf and system-wide settings */
 
+	opt_ctx = g_option_context_new (NULL);
+	g_option_context_set_summary (opt_ctx, "Allows users to view and edit network connection settings");
+	g_option_context_add_main_entries (opt_ctx, entries, NULL);
+
+	if (!g_option_context_parse (opt_ctx, &argc, &argv, &error)) {
+		g_warning ("%s\n", error->message);
+		g_error_free (error);
+		return 1;
+	}
+
+	g_option_context_free (opt_ctx);
+
 	/* Hack to init the dbus-glib type system */
 	ignore = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
 	dbus_g_connection_unref (ignore);
 
 	loop = g_main_loop_new (NULL, FALSE);
 
-	list = nm_connection_list_new ();
+	list = nm_connection_list_new (type);
 	if (!list) {
 		g_warning ("Failed to initialize the UI, exiting...");
 		return 1;

Modified: trunk/src/connection-editor/nm-connection-list.c
==============================================================================
--- trunk/src/connection-editor/nm-connection-list.c	(original)
+++ trunk/src/connection-editor/nm-connection-list.c	Thu Jun 26 17:36:11 2008
@@ -1380,15 +1380,15 @@
 
 static void
 add_connection_tab (NMConnectionList *self,
-				GSList *connection_types,
-				GdkPixbuf *pixbuf,
-				const char *prefix,
-				const char *label_text,
-				gboolean is_vpn)
+                    const char *def_type,
+                    GSList *connection_types,
+                    GdkPixbuf *pixbuf,
+                    const char *prefix,
+                    const char *label_text,
+                    gboolean is_vpn)
 {
 	char *name;
-	GtkWidget *child;
-	GtkWidget *hbox;
+	GtkWidget *child, *hbox, *notebook;
 	GtkTreeView *treeview;
 	GSList *iter;
 
@@ -1407,39 +1407,47 @@
 	gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (label_text), FALSE, FALSE, 0);
 	gtk_widget_show_all (hbox);
 
-	gtk_notebook_set_tab_label (GTK_NOTEBOOK (glade_xml_get_widget (self->gui, "list_notebook")), child, hbox);
+	notebook = glade_xml_get_widget (self->gui, "list_notebook");
+	gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook), child, hbox);
 
 	treeview = add_connection_treeview (self, prefix);
 	add_connection_buttons (self, prefix, treeview, is_vpn);
 
-	for (iter = connection_types; iter; iter = iter->next)
+	for (iter = connection_types; iter; iter = iter->next) {
 		g_hash_table_insert (self->treeviews, g_strdup ((const char *) iter->data), treeview);
+		if (def_type && !strcmp ((const char *) iter->data, def_type)) {
+			int pnum;
+
+			pnum = gtk_notebook_page_num (GTK_NOTEBOOK (notebook), child);
+			gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), pnum);
+		}
+	}
 }
 
 static void
-add_connection_tabs (NMConnectionList *self)
+add_connection_tabs (NMConnectionList *self, const char *def_type)
 {
 	GSList *types;
 
 	types = g_slist_append (NULL, NM_SETTING_WIRED_SETTING_NAME);
-	add_connection_tab (self, types, self->wired_icon, "wired", _("Wired"), FALSE);
+	add_connection_tab (self, def_type, types, self->wired_icon, "wired", _("Wired"), FALSE);
 	g_slist_free (types);
 
 	types = g_slist_append (NULL, NM_SETTING_WIRELESS_SETTING_NAME);
-	add_connection_tab (self, types, self->wireless_icon, "wireless", _("Wireless"), FALSE);
+	add_connection_tab (self, def_type, types, self->wireless_icon, "wireless", _("Wireless"), FALSE);
 	g_slist_free (types);
 
 	types = g_slist_append (NULL, NM_SETTING_GSM_SETTING_NAME);
 	types = g_slist_append (types, NM_SETTING_CDMA_SETTING_NAME);
-	add_connection_tab (self, types, self->wwan_icon, "wwan", _("Mobile Broadband"), FALSE);
+	add_connection_tab (self, def_type, types, self->wwan_icon, "wwan", _("Mobile Broadband"), FALSE);
 	g_slist_free (types);
 
 	types = g_slist_append (NULL, NM_SETTING_VPN_SETTING_NAME);
-	add_connection_tab (self, types, self->vpn_icon, "vpn", _("VPN"), TRUE);
+	add_connection_tab (self, def_type, types, self->vpn_icon, "vpn", _("VPN"), TRUE);
 	g_slist_free (types);
 
 	types = g_slist_append (NULL, NM_SETTING_PPPOE_SETTING_NAME);
-	add_connection_tab (self, types, self->wired_icon, "dsl", _("DSL"), FALSE);
+	add_connection_tab (self, def_type, types, self->wired_icon, "dsl", _("DSL"), FALSE);
 	g_slist_free (types);
 }
 
@@ -1511,7 +1519,7 @@
 	}
 
 NMConnectionList *
-nm_connection_list_new (void)
+nm_connection_list_new (const char *def_type)
 {
 	NMConnectionList *list;
 	DBusGConnection *dbus_connection;
@@ -1559,7 +1567,7 @@
 				   G_CALLBACK (connection_added),
 				   list);
 
-	add_connection_tabs (list);
+	add_connection_tabs (list, def_type);
 
 	list->editors = g_hash_table_new_full (g_direct_hash, g_direct_equal, g_object_unref, g_object_unref);
 

Modified: trunk/src/connection-editor/nm-connection-list.h
==============================================================================
--- trunk/src/connection-editor/nm-connection-list.h	(original)
+++ trunk/src/connection-editor/nm-connection-list.h	Thu Jun 26 17:36:11 2008
@@ -66,7 +66,7 @@
 } NMConnectionListClass;
 
 GType             nm_connection_list_get_type (void);
-NMConnectionList *nm_connection_list_new (void);
+NMConnectionList *nm_connection_list_new (const char *def_type);
 
 void              nm_connection_list_run (NMConnectionList *list);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]