Commit a27ef558 authored by Carlos Garnacho Parro's avatar Carlos Garnacho Parro Committed by Carlos Garnacho

added, configures the interface calling network-admin from g-s-t

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
parent 894f599a
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
......
......@@ -39,6 +39,7 @@
#include "lookup.h"
#include "finger.h"
#include "whois.h"
#include "utils.h"
#include "gn-combo-history.h"
/* Ping callbacks */
......@@ -128,6 +129,46 @@ on_info_nic_changed (GtkEntry * entry, gpointer info)
}*/
#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
on_scan_activate (GtkWidget * widget, gpointer data)
......
......@@ -18,6 +18,8 @@ void on_finger_activate (GtkWidget * editable, gpointer data);
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);
......
......@@ -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>
......
......@@ -357,6 +357,17 @@ info_ip6_construct_address (const struct ifaddrs *ifr6)
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 @@ info_get_nic_information (const gchar *nic, Netinfo *info)
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 */
......
......@@ -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)
......
......@@ -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 @@ load_info_widgets_from_xml (GladeXML * xml)
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 @@ load_info_widgets_from_xml (GladeXML * xml)
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);
......
......@@ -58,6 +58,7 @@ struct _Netinfo {
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 @@ struct _Netinfo {
GtkWidget *broadcast;
GtkWidget *netmask;
GtkWidget *dst_address;
GtkWidget *configure_button;
/*GtkWidget *multicast;*/
GtkWidget *link_speed;
GtkWidget *state;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment