Mercurial > pidgin.yaz
comparison plugins/lagmeter.c @ 848:5f19ec4a91f7
[gaim-migrate @ 858]
wow. the lagometer works as a plugin. this is how it should have been all along anyway.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Thu, 07 Sep 2000 02:06:34 +0000 |
parents | 6af9b88e4f90 |
children | a05ad732b613 |
comparison
equal
deleted
inserted
replaced
847:430a88eb4a68 | 848:5f19ec4a91f7 |
---|---|
28 | 28 |
29 void *handle; | 29 void *handle; |
30 GtkWidget *lagbox; | 30 GtkWidget *lagbox; |
31 GtkWidget *my_lagometer; | 31 GtkWidget *my_lagometer; |
32 struct timeval my_lag_tv; | 32 struct timeval my_lag_tv; |
33 int check_timeout; | 33 int check_timeout = -1; |
34 guint delay = 10; | 34 guint delay = 10; |
35 static GtkWidget *confdlg; | 35 static GtkWidget *confdlg; |
36 | 36 |
37 void update_lag(int us) { | 37 void update_lag(int us) { |
38 double pct; | 38 double pct; |
69 gtk_progress_bar_update(GTK_PROGRESS_BAR(my_lagometer), pct); | 69 gtk_progress_bar_update(GTK_PROGRESS_BAR(my_lagometer), pct); |
70 } | 70 } |
71 | 71 |
72 void check_lag(char **who, char **message, void *m) { | 72 void check_lag(char **who, char **message, void *m) { |
73 char *name = g_strdup(normalize(*who)); | 73 char *name = g_strdup(normalize(*who)); |
74 if (!strcasecmp(current_user->username, name) && | 74 if (!strcasecmp(normalize(current_user->username), name) && |
75 !strcmp(*message, MY_LAG_STRING)) { | 75 !strcmp(*message, MY_LAG_STRING)) { |
76 struct timeval tv; | 76 struct timeval tv; |
77 int ms; | 77 int ms; |
78 | 78 |
79 gettimeofday(&tv, NULL); | 79 gettimeofday(&tv, NULL); |
92 gettimeofday(&my_lag_tv, NULL); | 92 gettimeofday(&my_lag_tv, NULL); |
93 serv_send_im(current_user->username, MY_LAG_STRING, 1); | 93 serv_send_im(current_user->username, MY_LAG_STRING, 1); |
94 } | 94 } |
95 | 95 |
96 void gaim_plugin_remove() { | 96 void gaim_plugin_remove() { |
97 gtk_timeout_remove(check_timeout); | 97 if (check_timeout != -1) |
98 gtk_timeout_remove(check_timeout); | |
98 if (confdlg) | 99 if (confdlg) |
99 gtk_widget_destroy(confdlg); | 100 gtk_widget_destroy(confdlg); |
100 confdlg = NULL; | 101 confdlg = NULL; |
101 gtk_widget_destroy(lagbox); | 102 gtk_widget_destroy(lagbox); |
102 } | 103 } |
120 void adjust_timeout(GtkWidget *button, GtkWidget *spinner) { | 121 void adjust_timeout(GtkWidget *button, GtkWidget *spinner) { |
121 delay = CLAMP(gtk_spin_button_get_value_as_int( | 122 delay = CLAMP(gtk_spin_button_get_value_as_int( |
122 GTK_SPIN_BUTTON(spinner)), 0, 3600); | 123 GTK_SPIN_BUTTON(spinner)), 0, 3600); |
123 sprintf(debug_buff, "new updates: %d\n", delay); | 124 sprintf(debug_buff, "new updates: %d\n", delay); |
124 debug_print(debug_buff); | 125 debug_print(debug_buff); |
125 gtk_timeout_remove(check_timeout); | 126 if (check_timeout >= 0) |
127 gtk_timeout_remove(check_timeout); | |
126 check_timeout = gtk_timeout_add(1000 * delay, (GtkFunction)send_lag, NULL); | 128 check_timeout = gtk_timeout_add(1000 * delay, (GtkFunction)send_lag, NULL); |
127 gtk_widget_destroy(confdlg); | 129 gtk_widget_destroy(confdlg); |
128 confdlg = NULL; | 130 confdlg = NULL; |
129 } | 131 } |
130 | 132 |