Re: [gnome-network] [PATCH] integrating the GST network tool with gnome-nettool



Hi rodrigo!

El jue, 10-06-2004 a las 12:38, +0200, Rodrigo Moya escribió:
> On Wed, 2004-06-09 at 23:26 +0200, Carlos Garnacho wrote:
> > Hi all,
> > 
> > 	Ive just readapted the good ol' patch for integrating nettool with
> > network-admin from g-s-t with the current CVS code, it adds a
> > "configure" button that displays a dialog for configuring that interface
> > if network-admin is available, if it doesn't exist it just hides the
> > button. it's OK to commit? :)
> 
> > +       if (gtk_combo_box_get_active_iter (combo, &iter)) {
> > +               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);
> > +
> > +               g_spawn_command_line_async (command_line->str, NULL);
> > +
> here, I would add error processing, so that we can display an error
> dialog if something goes wrong.
> 
> Apart from that, it looks ok to me, so please commit.

It's commited, I've added error processing and removed an unused
variable, I've attached the committed patch :)

	Regards

> 
> cheers
> 
> _______________________________________________
> gnome-network-list mailing list
> gnome-network-list gnome org
> http://mail.gnome.org/mailman/listinfo/gnome-network-list
> 
? gnome-netinfo.patch
? pixmaps/Makefile
? pixmaps/Makefile.in
? src/gnome-nettool.gladep
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-nettool/ChangeLog,v
retrieving revision 1.30
diff -u -r1.30 ChangeLog
--- ChangeLog	9 Jun 2004 18:06:19 -0000	1.30
+++ ChangeLog	10 Jun 2004 23:08:35 -0000
@@ -1,3 +1,19 @@
+2004-06-11  Carlos Garnacho Parro  <carlosg gnome org>
+
+	* src/callbacks.[ch] (on_configure_button_clicked): added, 
+	configures the interface calling network-admin from g-s-t
+
+	* src/gnome-nettool.glade: added the "configure" button
+
+	* src/nettool.h: added configure button and path to network-admin
+	in the struct
+
+	* src/main.c: loaded the button from the glade XML
+
+	* src/info.[ch]: added some logic for hiding/showing and turning
+	sensitive/unsensitive the button, added a define with network-admin
+	executable name
+
 2004-06-09  William Jon McCann  <mccann jhu edu>
 
 	* src/callbacks.c (on_clear_history_activate): Clear history in
Index: src/callbacks.c
===================================================================
RCS file: /cvs/gnome/gnome-nettool/src/callbacks.c,v
retrieving revision 1.8
diff -u -r1.8 callbacks.c
--- src/callbacks.c	9 Jun 2004 18:06:19 -0000	1.8
+++ src/callbacks.c	10 Jun 2004 23:08:36 -0000
@@ -39,6 +39,7 @@
 #include "lookup.h"
 #include "finger.h"
 #include "whois.h"
+#include "utils.h"
 #include "gn-combo-history.h"
 
 /* Ping callbacks */
@@ -127,6 +128,46 @@
 	g_free (nic);
 }*/
 #endif
+
+void
+on_configure_button_clicked (GtkButton *button, gpointer data)
+{
+	GString *command_line;
+	GtkComboBox *combo;
+	GtkTreeModel *model;
+	GtkTreeIter iter;
+	GtkWidget *dialog;
+	Netinfo *info;
+	GError *error;
+	gchar *nic;
+
+	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)) {
+		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);
+
+		if (!g_spawn_command_line_async (command_line->str, &error)) {
+			dialog = gtk_message_dialog_new (GTK_WINDOW (info->main_window),
+							 GTK_DIALOG_DESTROY_WITH_PARENT,
+							 GTK_MESSAGE_ERROR,
+							 GTK_BUTTONS_CLOSE,
+							 error->message);
+			gtk_dialog_run (GTK_DIALOG (dialog));
+			gtk_widget_destroy (dialog);
+		}
+
+		g_string_free (command_line, TRUE);
+	}
+}
 
 /* Scan callbacks */
 void
Index: src/callbacks.h
===================================================================
RCS file: /cvs/gnome/gnome-nettool/src/callbacks.h,v
retrieving revision 1.3
diff -u -r1.3 callbacks.h
--- src/callbacks.h	8 Jun 2004 17:38:16 -0000	1.3
+++ src/callbacks.h	10 Jun 2004 23:08:36 -0000
@@ -18,6 +18,8 @@
 
 void on_whois_activate (GtkWidget * editable, gpointer data);
 
+void on_configure_button_clicked (GtkButton * widget, gpointer data);
+
 /* General stuff */
 void gn_quit_app (GtkWidget * widget, gpointer data);
 
Index: src/gnome-nettool.glade
===================================================================
RCS file: /cvs/gnome/gnome-nettool/src/gnome-nettool.glade,v
retrieving revision 1.10
diff -u -r1.10 gnome-nettool.glade
--- src/gnome-nettool.glade	9 Jun 2004 18:01:05 -0000	1.10
+++ src/gnome-nettool.glade	10 Jun 2004 23:08:47 -0000
@@ -181,6 +181,80 @@
 		      <property name="fill">True</property>
 		    </packing>
 		  </child>
+
+		  <child>
+		    <widget class="GtkButton" id="info_configure_button">
+		      <property name="visible">True</property>
+		      <property name="can_focus">True</property>
+		      <property name="relief">GTK_RELIEF_NORMAL</property>
+		      <property name="focus_on_click">True</property>
+
+		      <child>
+			<widget class="GtkAlignment" id="alignment33">
+			  <property name="visible">True</property>
+			  <property name="xalign">0.5</property>
+			  <property name="yalign">0.5</property>
+			  <property name="xscale">0</property>
+			  <property name="yscale">0</property>
+			  <property name="top_padding">0</property>
+			  <property name="bottom_padding">0</property>
+			  <property name="left_padding">0</property>
+			  <property name="right_padding">0</property>
+
+			  <child>
+			    <widget class="GtkHBox" id="hbox44">
+			      <property name="visible">True</property>
+			      <property name="homogeneous">False</property>
+			      <property name="spacing">2</property>
+
+			      <child>
+				<widget class="GtkImage" id="image13">
+				  <property name="visible">True</property>
+				  <property name="stock">gtk-preferences</property>
+				  <property name="icon_size">4</property>
+				  <property name="xalign">0.5</property>
+				  <property name="yalign">0.5</property>
+				  <property name="xpad">0</property>
+				  <property name="ypad">0</property>
+				</widget>
+				<packing>
+				  <property name="padding">0</property>
+				  <property name="expand">False</property>
+				  <property name="fill">False</property>
+				</packing>
+			      </child>
+
+			      <child>
+				<widget class="GtkLabel" id="label122">
+				  <property name="visible">True</property>
+				  <property name="label" translatable="yes">_Configure</property>
+				  <property name="use_underline">True</property>
+				  <property name="use_markup">False</property>
+				  <property name="justify">GTK_JUSTIFY_LEFT</property>
+				  <property name="wrap">False</property>
+				  <property name="selectable">False</property>
+				  <property name="xalign">0.5</property>
+				  <property name="yalign">0.5</property>
+				  <property name="xpad">0</property>
+				  <property name="ypad">0</property>
+				</widget>
+				<packing>
+				  <property name="padding">0</property>
+				  <property name="expand">False</property>
+				  <property name="fill">False</property>
+				</packing>
+			      </child>
+			    </widget>
+			  </child>
+			</widget>
+		      </child>
+		    </widget>
+		    <packing>
+		      <property name="padding">0</property>
+		      <property name="expand">False</property>
+		      <property name="fill">False</property>
+		    </packing>
+		  </child>
 		</widget>
 		<packing>
 		  <property name="padding">0</property>
Index: src/info.c
===================================================================
RCS file: /cvs/gnome/gnome-nettool/src/info.c,v
retrieving revision 1.2
diff -u -r1.2 info.c
--- src/info.c	8 Jun 2004 17:38:16 -0000	1.2
+++ src/info.c	10 Jun 2004 23:08:48 -0000
@@ -357,6 +357,17 @@
 	return (ip6);
 }
 
+static void
+info_setup_configure_button (Netinfo *info, gboolean enable)
+{
+	if (!info->network_tool_path)
+		gtk_widget_hide (info->configure_button);
+	else {
+		gtk_widget_show (info->configure_button);
+		gtk_widget_set_sensitive (info->configure_button, enable);
+	}
+}
+
 void
 info_get_nic_information (const gchar *nic, Netinfo *info)
 {
@@ -497,12 +508,15 @@
 				gtk_label_set_text (GTK_LABEL (info->broadcast), " ");
 				ip->ip_bcast = g_strdup ("");
 				gtk_label_set_text (GTK_LABEL (info->link_speed), " ");
+				info_setup_configure_button (info, FALSE);
 			} else {
 				if (data.has_data) {
 					gtk_label_set_text (GTK_LABEL (info->link_speed), data.media);
 				} else {
 					gtk_label_set_text (GTK_LABEL (info->link_speed), NOT_AVAILABLE);
 				}
+
+				info_setup_configure_button (info, TRUE);
 			}
 
 			/* Supports multicast */
Index: src/info.h
===================================================================
RCS file: /cvs/gnome/gnome-nettool/src/info.h,v
retrieving revision 1.3
diff -u -r1.3 info.h
--- src/info.h	8 Jun 2004 17:38:16 -0000	1.3
+++ src/info.h	10 Jun 2004 23:08:48 -0000
@@ -27,6 +27,8 @@
 #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)
Index: src/main.c
===================================================================
RCS file: /cvs/gnome/gnome-nettool/src/main.c,v
retrieving revision 1.8
diff -u -r1.8 main.c
--- src/main.c	9 Jun 2004 18:01:05 -0000	1.8
+++ src/main.c	10 Jun 2004 23:08:51 -0000
@@ -34,6 +34,7 @@
 #include "lookup.h"
 #include "finger.h"
 #include "whois.h"
+#include "utils.h"
 #include "gn-combo-history.h"
 
 Netinfo *load_ping_widgets_from_xml (GladeXML * xml);
@@ -517,6 +518,9 @@
 	info->rx_errors = glade_xml_get_widget (xml, "info_rx_errors");
 	info->collisions = glade_xml_get_widget (xml, "info_collisions");
 	info->list_ip_addr = glade_xml_get_widget (xml, "info_list_ip_addr");
+	info->configure_button = glade_xml_get_widget (xml, "info_configure_button");
+
+	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,
@@ -542,7 +546,11 @@
 	gtk_combo_box_set_model (GTK_COMBO_BOX (info->combo), model);
 
 	g_object_unref (model);
-	
+
+	g_signal_connect (G_OBJECT (info->configure_button), "clicked",
+			  G_CALLBACK (on_configure_button_clicked),
+			  info);
+
 	g_signal_connect (G_OBJECT (info->combo), "changed",
 			  G_CALLBACK (info_nic_changed),
 			  info);
Index: src/nettool.h
===================================================================
RCS file: /cvs/gnome/gnome-nettool/src/nettool.h,v
retrieving revision 1.5
diff -u -r1.5 nettool.h
--- src/nettool.h	9 Jun 2004 18:06:19 -0000	1.5
+++ src/nettool.h	10 Jun 2004 23:08:51 -0000
@@ -58,6 +58,7 @@
 	gchar **command_line;
 	gchar *label_run;
 	gchar *label_stop;
+	gchar *network_tool_path;
 	NetinfoForeachFunc process_line;
 	NetinfoCopyFunc copy_output;
 	GCallback button_callback;
@@ -80,6 +81,7 @@
 	GtkWidget *broadcast;
 	GtkWidget *netmask;
 	GtkWidget *dst_address;
+	GtkWidget *configure_button;
 	/*GtkWidget *multicast;*/
 	GtkWidget *link_speed;
 	GtkWidget *state;


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