[gnome-network] [PATCH] integrating the GST network tool with gnome-nettool
- From: Carlos Garnacho <garnacho tuxerver net>
- To: gnome-network-list gnome org
- Subject: [gnome-network] [PATCH] integrating the GST network tool with gnome-nettool
- Date: Wed, 09 Jun 2004 23:26:20 +0200
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? :)
Carlos
? gnome-netinfo.patch
? pixmaps/Makefile
? pixmaps/Makefile.in
? src/gnome-nettool.gladep
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 9 Jun 2004 21:19:59 -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,37 @@
g_free (nic);
}*/
#endif
+
+void
+on_configure_button_clicked (GtkButton *button, gpointer data)
+{
+ gchar *tool_path;
+ GString *command_line;
+ GtkComboBox *combo;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ Netinfo *info;
+ 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);
+
+ g_spawn_command_line_async (command_line->str, NULL);
+
+ 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 9 Jun 2004 21:19:59 -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 9 Jun 2004 21:20:10 -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 9 Jun 2004 21:20:11 -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 9 Jun 2004 21:20:11 -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 9 Jun 2004 21:20:14 -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 9 Jun 2004 21:20:14 -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]