Modem Lights patch
- From: Sean Middleditch <sean middleditch iname com>
- To: gnome-devel-list gnome org
- Subject: Modem Lights patch
- Date: Fri, 04 Feb 2000 17:34:41 -0500
OK, here is the patch for the Modem Lights. Um, run it from the
gnome-applets directory, and it'll patch the code in the modemlights
directory.
It adds a feature so that modemlights will run the disconnect command
when you logout (well, actually, when the applet closes... I couldn't
figure out how to get it to tell the difference). An option was added
to the Preferences dialog to turn this on/off (default off). I tried to
keep my code as close to the style as the original authors as possible.
Oh, yeah, I added my name to the about box, because I love fame like
that... ;-) If that's not allowed, just tear it out and yell at me.
Sean Middleditch
diff -u modemlights-old/modemlights.c modemlights/modemlights.c
--- modemlights-old/modemlights.c Fri Jan 28 16:20:26 2000
+++ modemlights/modemlights.c Fri Feb 4 17:26:35 2000
@@ -59,6 +59,7 @@
gint ask_for_confirmation = TRUE; /* do we ask for confirmation? */
gint use_ISDN = FALSE; /* do we use ISDN? */
gint show_extra_info = FALSE; /* display larger version with time/byte count */
+gint disconnect_on_close = FALSE; /* close connection when applet closes */
GtkWidget *applet;
static GtkWidget *frame;
@@ -103,7 +104,8 @@
authors[0] = "John Ellis <johne@bellatlantic.net>";
authors[1] = "Martin Baulig <martin@home-of-linux.org> - ISDN";
- authors[2] = NULL;
+ authors[2] = "Sean Middleditch <sean.middleditch@iname.com> - Disconnect on close";
+ authors[3] = NULL;
about = gnome_about_new ( _("Modem Lights Applet"), VERSION,
"(C) 1999",
@@ -453,6 +455,14 @@
applet_widget_set_widget_tooltip(APPLET_WIDGET(applet),button,text);
}
+static void disconnect_close_cb(gint button, gpointer data)
+{
+ if (disconnect_on_close && is_connected ())
+ {
+ system (command_disconnect);
+ }
+}
+
/*
*-------------------------------------
* display drawing
@@ -1202,6 +1212,9 @@
gtk_signal_connect(GTK_OBJECT(applet),"save_session",
GTK_SIGNAL_FUNC(applet_save_session), NULL);
+ gtk_signal_connect(GTK_OBJECT(applet),"delete_event",
+ GTK_SIGNAL_FUNC(disconnect_close_cb), NULL);
+
applet_widget_register_stock_callback(APPLET_WIDGET(applet),
"properties",
GNOME_STOCK_MENU_PROP,
@@ -1217,6 +1230,7 @@
start_callback_update();
applet_widget_gtk_main();
+
return 0;
}
diff -u modemlights-old/modemlights.h modemlights/modemlights.h
--- modemlights-old/modemlights.h Sun Jul 11 23:35:57 1999
+++ modemlights/modemlights.h Thu Feb 3 17:05:49 2000
@@ -40,6 +40,7 @@
extern gchar *device_name;
extern gint use_ISDN;
extern gint show_extra_info;
+extern gint disconnect_on_close;
extern GtkWidget *applet;
diff -u modemlights-old/properties.c modemlights/properties.c
--- modemlights-old/properties.c Fri Jan 28 16:20:26 2000
+++ modemlights/properties.c Fri Feb 4 17:26:43 2000
@@ -23,12 +23,14 @@
static gint P_use_ISDN = FALSE;
static gint P_verify_lock_file = TRUE;
static gint P_show_extra_info = FALSE;
+static gint P_disconnect_on_close = TRUE;
static void show_extra_info_cb( GtkWidget *widget, gpointer data );
static void verify_lock_file_cb( GtkWidget *widget, gpointer data );
static void update_delay_cb( GtkWidget *widget, GtkWidget *spin );
static void confirm_checkbox_cb( GtkWidget *widget, gpointer data );
static void isdn_checkbox_cb( GtkWidget *widget, gpointer data );
+static void disconnect_checkbox_cb( GtkWidget *widget, gpointer data );
static void property_apply_cb( GtkWidget *widget, void *data );
static gint property_destroy_cb( GtkWidget *widget, void *data );
@@ -59,6 +61,7 @@
use_ISDN = gnome_config_get_int("modem/isdn=0");
verify_lock_file = gnome_config_get_int("modem/verify_lock=1");
show_extra_info = gnome_config_get_int("modem/extra_info=0");
+ disconnect_on_close = gnome_config_get_int("modem/disconnect_on_close=0");
gnome_config_pop_prefix ();
}
@@ -74,6 +77,7 @@
gnome_config_set_int("modem/isdn", use_ISDN);
gnome_config_set_int("modem/verify_lock", verify_lock_file);
gnome_config_set_int("modem/extra_info", show_extra_info);
+ gnome_config_set_int("modem/disconnect_on_close", disconnect_on_close);
gnome_config_sync();
gnome_config_drop_all();
gnome_config_pop_prefix();
@@ -111,6 +115,14 @@
data = NULL;
}
+static void disconnect_checkbox_cb( GtkWidget *widget, gpointer data )
+{
+ P_disconnect_on_close = GTK_TOGGLE_BUTTON (widget)->active;
+ gnome_property_box_changed(GNOME_PROPERTY_BOX(propwindow));
+ return;
+ data = NULL;
+}
+
static void isdn_checkbox_cb( GtkWidget *widget, gpointer data )
{
P_use_ISDN = GTK_TOGGLE_BUTTON (widget)->active;
@@ -146,6 +158,7 @@
UPDATE_DELAY = P_UPDATE_DELAY;
ask_for_confirmation = P_ask_for_confirmation;
+ disconnect_on_close = P_disconnect_on_close;
use_ISDN = P_use_ISDN;
verify_lock_file = P_verify_lock_file;
@@ -194,6 +207,7 @@
P_UPDATE_DELAY = UPDATE_DELAY;
P_ask_for_confirmation = ask_for_confirmation;
+ P_disconnect_on_close = disconnect_on_close;
P_verify_lock_file = verify_lock_file;
P_show_extra_info = show_extra_info;
@@ -252,6 +266,14 @@
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbox), ask_for_confirmation);
gtk_signal_connect(GTK_OBJECT(checkbox), "toggled",
GTK_SIGNAL_FUNC(confirm_checkbox_cb), NULL);
+ gtk_box_pack_start(GTK_BOX(vbox1), checkbox, FALSE, FALSE, 0);
+ gtk_widget_show(checkbox);
+
+ /* disconnect on close */
+ checkbox = gtk_check_button_new_with_label(_("Disconnect on close"));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbox), disconnect_on_close);
+ gtk_signal_connect(GTK_OBJECT(checkbox), "toggled",
+ GTK_SIGNAL_FUNC(disconnect_checkbox_cb), NULL);
gtk_box_pack_start(GTK_BOX(vbox1), checkbox, FALSE, FALSE, 0);
gtk_widget_show(checkbox);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]