1diff -ur bfm-0.6.1.orig/README bfm-0.6.1/README
2--- bfm-0.6.1.orig/README	2003-10-11 03:29:08.000000000 -0500
3+++ bfm-0.6.1/README	2003-11-01 20:59:22.000000000 -0600
4@@ -7,7 +7,6 @@
5
6
7 TODO
8-- Any way to fix the update speed? Gkrellm maximum update is 10 per second.
9 - Someone tests/does the FreeBSD and SunOS platform?
10 - Possible/Make more sense, to make a gkrellm swallow plugin?
11   (Quick search on google:
12diff -ur bfm-0.6.1.orig/gkrellm-bfm.c bfm-0.6.1/gkrellm-bfm.c
13--- bfm-0.6.1.orig/gkrellm-bfm.c	2003-11-01 10:44:15.000000000 -0600
14+++ bfm-0.6.1/gkrellm-bfm.c	2003-11-01 20:58:57.000000000 -0600
15@@ -68,6 +68,8 @@
16 static Chart *chart = NULL;
17 static ChartConfig *chart_config = NULL;
18
19+static gint	timeout_id,
20+			update_interval;
21
22
23 /* From the actual bfm */
24@@ -92,13 +94,13 @@
25 GtkWidget *clock_check = NULL;
26 GtkWidget *fish_traffic_check = NULL;
27
28-static void
29+static gboolean
30 update_plugin(void)
31 {
32 	GdkEventExpose event;
33 	gint ret_val;
34 	gtk_signal_emit_by_name(GTK_OBJECT(chart->drawing_area), "expose_event", &event, &ret_val);
35-
36+	return TRUE;	/* restart timer */
37 }
38
39
40@@ -154,6 +156,15 @@
41 	return TRUE;
42 }
43
44+
45+static void
46+disable_plugin(void)
47+	{
48+	if (timeout_id)
49+		gtk_timeout_remove(timeout_id);
50+	timeout_id = 0;
51+	}
52+
53 static void
54 create_plugin(GtkWidget *vbox, gint first_create)
55 {
56@@ -182,7 +193,10 @@
57 				"leave_notify_event", GTK_SIGNAL_FUNC(leave_notify_event),
58 				NULL);
59 	}
60-
61+	if (!timeout_id)
62+		timeout_id = gtk_timeout_add(1000 / update_interval,
63+					(GtkFunction) update_plugin, NULL);
64+	gkrellm_disable_plugin_connect(mon, disable_plugin);
65 }
66
67
68@@ -240,6 +254,44 @@
69 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(fish_traffic_check), fish_traffic);
70 }
71
72+
73+static void
74+cb_interval_modified(GtkWidget *widget, GtkSpinButton *spin)
75+	{
76+	update_interval = gtk_spin_button_get_value_as_int(spin);
77+	if (timeout_id)
78+		gtk_timeout_remove(timeout_id);
79+	timeout_id = gtk_timeout_add(1000 / update_interval,
80+					(GtkFunction) update_plugin, NULL);
81+	}
82+
83+static gchar	*pending_prog;
84+
85+static void
86+cb_prog_entry(GtkWidget *widget, gpointer data)
87+{
88+	gboolean	activate_sig = GPOINTER_TO_INT(data);
89+	gchar		*s           = gkrellm_gtk_entry_get_text(&prog_entry);
90+
91+	if (activate_sig)
92+		{
93+		gkrellm_dup_string(&prog, s);
94+		g_free(pending_prog);
95+		pending_prog = NULL;
96+		}
97+	else	/* "changed" sig, entry is pending on "activate" or config close */
98+		gkrellm_dup_string(&pending_prog, s);
99+}
100+
101+static void
102+config_destroyed(void)
103+	{
104+	if (pending_prog)
105+		gkrellm_dup_string(&prog, pending_prog);
106+	g_free(pending_prog);
107+	pending_prog = NULL;
108+	}
109+
110 static void
111 create_plugin_tab(GtkWidget *tab_vbox)
112 {
113@@ -287,10 +339,7 @@
114 		"   fish swiming from right to left represents incoming traffic)\n",
115 		"- Cute little duck swimming...\n",
116 		"- Clock hands representing time (obviously)...\n",
117-		"- Click and it will run a command for you (requested by Nick =)\n\n",
118-		"<i>Notes\n\n",
119-		"- Currently Gkrellm updates at most 10 times a second, and so\n",
120-		"  BFM updates is a bit jerky still.\n",
121+		"- Click and it will run a command for you (requested by Nick =)\n",
122 		"\n\n",
123 	};
124
125@@ -307,6 +356,8 @@
126 	tabs = gtk_notebook_new();
127 	gtk_notebook_set_tab_pos(GTK_NOTEBOOK(tabs), GTK_POS_TOP);
128 	gtk_box_pack_start(GTK_BOX(tab_vbox), tabs, TRUE, TRUE, 0);
129+	g_signal_connect(G_OBJECT(tabs),"destroy",
130+			 G_CALLBACK(config_destroyed), NULL);
131
132 	/* Options tab */
133 	options_tab = gkrellm_create_tab(tabs, _("Options"));
134@@ -346,6 +397,10 @@
135 							(GtkDestroyNotify) gtk_widget_unref);
136 	gtk_widget_show (prog_entry);
137 	gtk_box_pack_start (GTK_BOX (prog_box), prog_entry, TRUE, TRUE, 0);
138+	g_signal_connect(G_OBJECT(prog_entry), "activate",
139+				G_CALLBACK(cb_prog_entry), GINT_TO_POINTER(1));
140+	g_signal_connect(G_OBJECT(prog_entry), "changed",
141+				G_CALLBACK(cb_prog_entry), GINT_TO_POINTER(0));
142
143 	row1 = gtk_hbox_new (FALSE, 0);
144 	gtk_widget_set_name (row1, "row1");
145@@ -470,6 +525,11 @@
146 	gtk_widget_show (fish_traffic_check);
147 	gtk_box_pack_start (GTK_BOX (fish_traffic_box), fish_traffic_check, TRUE, TRUE, 0);
148
149+	gkrellm_gtk_spin_button(main_box, NULL, update_interval,
150+				10.0, 50.0, 1.0, 5.0, 0, 60,
151+				cb_interval_modified, NULL, FALSE,
152+				_("Updates per second"));
153+
154 	setup_toggle_buttons();
155
156 	gtk_signal_connect(GTK_OBJECT(cpu_check), "toggled", GTK_SIGNAL_FUNC(option_toggled_cb), NULL);
157@@ -494,15 +554,6 @@
158
159 }
160
161-static void
162-apply_plugin_config(void)
163-{
164-	if(prog)
165-	{
166-		g_free(prog);
167-	}
168-	prog = g_strdup(gtk_editable_get_chars(GTK_EDITABLE(prog_entry), 0, -1));
169-}
170
171 static void
172 save_plugin_config(FILE *f)
173@@ -511,13 +562,15 @@
174 	{
175 		fprintf(f, "%s prog %s\n", PLUGIN_KEYWORD, prog);
176 	}
177-	fprintf(f, "%s options %d.%d.%d.%d.%d.%d\n", PLUGIN_KEYWORD,
178+	fprintf(f, "%s options %d.%d.%d.%d.%d.%d.%d\n", PLUGIN_KEYWORD,
179 			cpu_enabled,
180 			duck_enabled,
181 			memscreen_enabled,
182 			fish_enabled,
183 			fish_traffic,
184-			time_enabled);
185+			time_enabled,
186+			update_interval);
187+
188 }
189
190 static void
191@@ -539,13 +592,14 @@
192 	}
193 	else if(!strcmp(config_item, "options"))
194 	{
195-		sscanf(value, "%d.%d.%d.%d.%d.%d",
196+		sscanf(value, "%d.%d.%d.%d.%d.%d.%d",
197 				&cpu_enabled,
198 				&duck_enabled,
199 				&memscreen_enabled,
200 				&fish_enabled,
201 				&fish_traffic,
202-				&time_enabled);
203+				&time_enabled,
204+				&update_interval);
205 	}
206
207 }
208@@ -556,9 +610,9 @@
209 	PLUGIN_NAME,         /* Name, for config tab.                    */
210 	0,                   /* Id,  0 if a plugin                       */
211 	create_plugin,       /* The create_plugin() function             */
212-	update_plugin,       /* The update_plugin() function             */
213+	NULL,                /* The update_plugin() function             */
214 	create_plugin_tab,   /* The create_plugin_tab() config function  */
215-	apply_plugin_config, /* The apply_plugin_config() function       */
216+	NULL,                /* The apply_plugin_config() function       */
217
218 	save_plugin_config,  /* The save_plugin_config() function        */
219 	load_plugin_config,  /* The load_plugin_config() function        */
220@@ -577,6 +631,7 @@
221 Monitor *
222 init_plugin(void)
223 {
224+	update_interval = 20;
225 	style_id = gkrellm_add_meter_style(&bfm_mon, PLUGIN_STYLE);
226 	return (mon = &bfm_mon);
227 }
228