annotate plugins/lagmeter.c @ 568:c53958bfaf00

[gaim-migrate @ 578] :-) committer: Tailor Script <tailor@pidgin.im>
author Rob Flynn <gaim@robflynn.com>
date Tue, 01 Aug 2000 17:04:16 +0000
parents 6af9b88e4f90
children 5f19ec4a91f7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
193
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 /* KNOWN BUGS:
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 * if you are also using notify.so, it will open a new window to yourself.
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3 * it will not, however, write anything in that window. this is a problem
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 * with notify.c. maybe one day i'll modify notify.c so that these two
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 * plugins are more compatible. we'll see.
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 *
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7 * This lagometer has a tendency to not at all show the same lag that the
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8 * built-in lagometer shows. My guess as to why this is (because they use the
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 * exact same code) is because it sends the string more often. That's why I
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 * included the configuration option to set the delay between updates.
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 *
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 * You can load this plugin even when you're not signed on, even though it
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 * modifies the buddy list. This is because it checks to see that the buddy
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 * list is actually there. In every case that I've been able to think of so
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 * far, it does the right thing (tm).
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 */
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 #define GAIM_PLUGINS
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 #include "gaim.h"
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21 #include <time.h>
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22 #include <sys/types.h>
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23 #include <sys/time.h>
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24 #include <unistd.h>
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25 #include <math.h>
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27 #define MY_LAG_STRING "ZYXCHECKLAGXYZ"
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29 void *handle;
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 GtkWidget *lagbox;
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31 GtkWidget *my_lagometer;
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32 struct timeval my_lag_tv;
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
33 int check_timeout;
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
34 guint delay = 10;
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35 static GtkWidget *confdlg;
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37 void update_lag(int us) {
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38 double pct;
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40 if (lagbox == NULL) {
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41 /* guess we better build it then :P */
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
42 GtkWidget *label = gtk_label_new("Lag-O-Meter: ");
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43 GList *tmp = gtk_container_children(GTK_CONTAINER(blist));
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44 GtkWidget *vbox2 = (GtkWidget *)tmp->data;
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45 lagbox = gtk_hbox_new(FALSE, 0);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46 my_lagometer = gtk_progress_bar_new();
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48 gtk_box_pack_start(GTK_BOX(lagbox), label, FALSE, FALSE, 5);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
49 gtk_box_pack_start(GTK_BOX(lagbox), my_lagometer, TRUE, TRUE, 5);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
50 gtk_widget_set_usize(my_lagometer, 5, 5);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
51
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
52 gtk_widget_show(label);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53 gtk_widget_show(my_lagometer);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55 gtk_box_pack_start(GTK_BOX(vbox2), lagbox, FALSE, TRUE, 0);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
56 gtk_box_reorder_child(GTK_BOX(vbox2), lagbox, 1);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57 gtk_widget_show(lagbox);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58 }
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
59
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
60 pct = us/100000;
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
61 if (pct > 0)
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
62 pct = 25 * log(pct);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
63 if (pct < 0)
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
64 pct = 0;
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
65 if (pct > 100)
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
66 pct = 100;
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
67 pct /= 100;
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
68
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
69 gtk_progress_bar_update(GTK_PROGRESS_BAR(my_lagometer), pct);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
70 }
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
71
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
72 void check_lag(char **who, char **message, void *m) {
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
73 char *name = g_strdup(normalize(*who));
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
74 if (!strcasecmp(current_user->username, name) &&
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
75 !strcmp(*message, MY_LAG_STRING)) {
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
76 struct timeval tv;
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
77 int ms;
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
78
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
79 gettimeofday(&tv, NULL);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
80
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
81 ms = 1000000 * (tv.tv_sec - my_lag_tv.tv_sec);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
82
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
83 ms += tv.tv_usec - my_lag_tv.tv_usec;
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
84
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
85 update_lag(ms);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
86 *message = NULL;
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
87 }
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
88 g_free(name);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
89 }
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
90
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
91 void send_lag() {
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
92 gettimeofday(&my_lag_tv, NULL);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
93 serv_send_im(current_user->username, MY_LAG_STRING, 1);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
94 }
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
95
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
96 void gaim_plugin_remove() {
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
97 gtk_timeout_remove(check_timeout);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
98 if (confdlg)
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
99 gtk_widget_destroy(confdlg);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
100 confdlg = NULL;
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
101 gtk_widget_destroy(lagbox);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
102 }
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
103
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
104 void avail_now(void *m) {
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
105 update_lag(0);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
106 gaim_signal_connect(handle, event_im_recv, check_lag, NULL);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
107 gaim_signal_connect(handle, event_signoff, gaim_plugin_remove, NULL);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
108 check_timeout = gtk_timeout_add(1000 * delay, (GtkFunction)send_lag, NULL);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
109 }
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
110
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
111 void gaim_plugin_init(void *h) {
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
112 handle = h;
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
113
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
114 if (!blist)
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
115 gaim_signal_connect(handle, event_signon, avail_now, NULL);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
116 else
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
117 avail_now(NULL);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
118 }
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
119
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
120 void adjust_timeout(GtkWidget *button, GtkWidget *spinner) {
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
121 delay = CLAMP(gtk_spin_button_get_value_as_int(
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
122 GTK_SPIN_BUTTON(spinner)), 0, 3600);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
123 sprintf(debug_buff, "new updates: %d\n", delay);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
124 debug_print(debug_buff);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
125 gtk_timeout_remove(check_timeout);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
126 check_timeout = gtk_timeout_add(1000 * delay, (GtkFunction)send_lag, NULL);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
127 gtk_widget_destroy(confdlg);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
128 confdlg = NULL;
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
129 }
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
130
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
131 void gaim_plugin_config() {
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
132 GtkWidget *label;
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
133 GtkAdjustment *adj;
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
134 GtkWidget *spinner;
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
135 GtkWidget *button;
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
136 GtkWidget *box;
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
137
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
138 if (confdlg) {
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
139 gtk_widget_show(confdlg);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
140 return;
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
141 }
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
142
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
143 confdlg = gtk_window_new(GTK_WINDOW_DIALOG);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
144 gtk_window_set_title(GTK_WINDOW(confdlg), "Gaim Lag Delay");
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
145
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
146 box = gtk_hbox_new(FALSE, 0);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
147 gtk_container_set_border_width(GTK_CONTAINER(box), 5);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
148 gtk_container_add(GTK_CONTAINER(confdlg), box);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
149 gtk_widget_show(box);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
150
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
151 label = gtk_label_new("Delay between updates: ");
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
152 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
153 gtk_box_pack_start(GTK_BOX(box), label, FALSE, TRUE, 0);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
154 gtk_widget_show(label);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
155
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
156 adj = (GtkAdjustment *)gtk_adjustment_new(delay, 0, 3600, 1, 0, 0);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
157 spinner = gtk_spin_button_new(GTK_ADJUSTMENT(adj), 0, 0);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
158 gtk_box_pack_start(GTK_BOX(box), spinner, TRUE, TRUE, 0);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
159 gtk_widget_show(spinner);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
160
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
161 button = gtk_button_new_with_label("OK");
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
162 gtk_signal_connect(GTK_OBJECT(button), "clicked",
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
163 (GtkSignalFunc)adjust_timeout, spinner);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
164 gtk_box_pack_start(GTK_BOX(box), button, FALSE, TRUE, 0);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
165 gtk_widget_show(button);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
166
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
167 gtk_widget_show(confdlg);
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
168 }
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
169
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
170 char *name() {
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
171 return "Lag-O-Meter, Pluggified";
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
172 }
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
173
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
174 char *description() {
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
175 return "Your old familiar Lag-O-Meter, in a brand new form.";
6af9b88e4f90 [gaim-migrate @ 203]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
176 }