[gnome-nettool] Use NetworkManager connection editor if available



commit ebd926803175ee56f2c9e6824ddef0aebfa4009e
Author: Rodrigo Moya <rodrigo gnome-db org>
Date:   Thu Nov 11 10:41:19 2010 +0100

    Use NetworkManager connection editor if available
    
    Try first to run nm-connection-editor to configure network interfaces,
    and fall back to network-admin if it's not available

 src/callbacks.c |   17 +++++++++++++----
 src/info.c      |   10 +++++++++-
 src/info.h      |    2 --
 src/main.c      |    2 --
 src/nettool.h   |    1 -
 5 files changed, 22 insertions(+), 10 deletions(-)
---
diff --git a/src/callbacks.c b/src/callbacks.c
index 6c7e957..05e1ad6 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -135,17 +135,25 @@ on_configure_button_clicked (GtkButton *button, gpointer data)
 
 	g_return_if_fail (data != NULL);
 	info = (Netinfo *) data;
-	g_return_if_fail (info->network_tool_path != NULL);
 
 	combo = GTK_COMBO_BOX (info->combo);
 	model = gtk_combo_box_get_model (combo);
 
 	if (gtk_combo_box_get_active_iter (combo, &iter)) {
+		gchar *network_tool_path;
+
 		gtk_tree_model_get (model, &iter, 2, &nic, -1);
 
-		command_line = g_string_new (info->network_tool_path);
-		g_string_append (command_line, " --configure ");
-		g_string_append (command_line, nic);
+		network_tool_path = util_find_program_in_path ("nm-connection-editor", NULL);
+		if (network_tool_path != NULL) {
+			command_line = g_string_new ("nm-connection-editor");
+		} else {
+			network_tool_path = util_find_program_in_path ("network-admin", NULL);
+
+			command_line = g_string_new (network_tool_path);
+			g_string_append (command_line, " --configure ");
+			g_string_append (command_line, nic);
+		}
 
 		if (!g_spawn_command_line_async (command_line->str, &error)) {
 			dialog = gtk_message_dialog_new (GTK_WINDOW (info->main_window),
@@ -157,6 +165,7 @@ on_configure_button_clicked (GtkButton *button, gpointer data)
 			gtk_widget_destroy (dialog);
 		}
 
+		g_free (network_tool_path);
 		g_string_free (command_line, TRUE);
 	}
 }
diff --git a/src/info.c b/src/info.c
index c9d2df2..ae1d2bd 100644
--- a/src/info.c
+++ b/src/info.c
@@ -333,11 +333,19 @@ info_ip_addr_free (InfoIpAddr *ip)
 static void
 info_setup_configure_button (Netinfo *info, gboolean enable)
 {
-	if (!info->network_tool_path)
+	gchar *network_tool_path;
+
+	network_tool_path = util_find_program_in_path ("nm-connection-editor", NULL);
+	if (!network_tool_path)
+		network_tool_path = util_find_program_in_path ("network-admin", NULL);
+
+	if (!network_tool_path)
 		gtk_widget_hide (info->configure_button);
 	else {
 		gtk_widget_show (info->configure_button);
 		gtk_widget_set_sensitive (info->configure_button, enable);
+
+		g_free (network_tool_path);
 	}
 }
 
diff --git a/src/info.h b/src/info.h
index 694abd4..1adb2a4 100644
--- a/src/info.h
+++ b/src/info.h
@@ -27,8 +27,6 @@
 #define NOT_AVAILABLE _("not available")
 #define DELAY_STATS 1000  /* 1 second */
 
-#define GST_NETWORK_TOOL "network-admin"
-
 /* Solaris store the MTU in ifr_metric, and doesn't have 
    ifr_mtu define */
 #if !defined(ifr_mtu)
diff --git a/src/main.c b/src/main.c
index d0fe9df..17c3377 100644
--- a/src/main.c
+++ b/src/main.c
@@ -555,8 +555,6 @@ load_info_widgets_from_builder (GtkBuilder * builder)
 	info->status_bar = GTK_WIDGET (gtk_builder_get_object (builder, "statusbar"));
 	info->stbar_text = NULL;
 
-	info->network_tool_path = util_find_program_in_path (GST_NETWORK_TOOL, NULL);
-
 	model = GTK_TREE_MODEL (gtk_list_store_new (5, G_TYPE_STRING, G_TYPE_STRING,
 						    G_TYPE_STRING, G_TYPE_STRING,
 						    G_TYPE_STRING));
diff --git a/src/nettool.h b/src/nettool.h
index 367b595..e0fcfc2 100644
--- a/src/nettool.h
+++ b/src/nettool.h
@@ -62,7 +62,6 @@ struct _Netinfo {
 	gchar **command_line;
 	gchar *label_run;
 	gchar *label_stop;
-	gchar *network_tool_path;
 	GString *command_output;
 	NetinfoForeachFunc process_line;
 	NetinfoCopyFunc copy_output;



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