comparison console/plugins/gntgf.c @ 14157:d822e68acb3e

[gaim-migrate @ 16802] Add an option to beep on events. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Thu, 17 Aug 2006 01:58:20 +0000
parents 55e3db9db9f6
children 7c560c01b8f9
comparison
equal deleted inserted replaced
14156:0154168c414a 14157:d822e68acb3e
20 20
21 #define GAIM_PLUGINS 21 #define GAIM_PLUGINS
22 22
23 #define PLUGIN_STATIC_NAME "GntGf" 23 #define PLUGIN_STATIC_NAME "GntGf"
24 24
25 #define PREFS_EVENT "/plugins/gnt/gntgf/events" 25 #define PREFS_PREFIX "/plugins/gnt/gntgf"
26 #define PREFS_EVENT PREFS_PREFIX "/events"
26 #define PREFS_EVENT_SIGNONF PREFS_EVENT "/signonf" 27 #define PREFS_EVENT_SIGNONF PREFS_EVENT "/signonf"
27 #define PREFS_EVENT_IM_MSG PREFS_EVENT "/immsg" 28 #define PREFS_EVENT_IM_MSG PREFS_EVENT "/immsg"
28 #define PREFS_EVENT_CHAT_MSG PREFS_EVENT "/chatmsg" 29 #define PREFS_EVENT_CHAT_MSG PREFS_EVENT "/chatmsg"
29 #define PREFS_EVENT_CHAT_NICK PREFS_EVENT "/chatnick" 30 #define PREFS_EVENT_CHAT_NICK PREFS_EVENT "/chatnick"
31 #define PREFS_BEEP PREFS_PREFIX "/beep"
30 32
31 #include <glib.h> 33 #include <glib.h>
32 34
33 #include <plugin.h> 35 #include <plugin.h>
34 #include <version.h> 36 #include <version.h>
37 #include <util.h> 39 #include <util.h>
38 40
39 #include <gnt.h> 41 #include <gnt.h>
40 #include <gntbox.h> 42 #include <gntbox.h>
41 #include <gntbutton.h> 43 #include <gntbutton.h>
44 #include <gntcheckbox.h>
42 #include <gntlabel.h> 45 #include <gntlabel.h>
43 #include <gnttree.h> 46 #include <gnttree.h>
44 47
45 #include <gntplugin.h> 48 #include <gntplugin.h>
46 49
94 GntToast *toast = g_new0(GntToast, 1); 97 GntToast *toast = g_new0(GntToast, 1);
95 char *str; 98 char *str;
96 int h, w; 99 int h, w;
97 va_list args; 100 va_list args;
98 101
102 if (gaim_prefs_get_bool(PREFS_BEEP))
103 beep();
104
99 toast->window = window = gnt_vbox_new(FALSE); 105 toast->window = window = gnt_vbox_new(FALSE);
100 GNT_WIDGET_SET_FLAGS(window, GNT_WIDGET_TRANSIENT); 106 GNT_WIDGET_SET_FLAGS(window, GNT_WIDGET_TRANSIENT);
101 GNT_WIDGET_UNSET_FLAGS(window, GNT_WIDGET_NO_BORDER); 107 GNT_WIDGET_UNSET_FLAGS(window, GNT_WIDGET_NO_BORDER);
102 108
103 va_start(args, fmt); 109 va_start(args, fmt);
195 char *pref; 201 char *pref;
196 char *display; 202 char *display;
197 } prefs[] = 203 } prefs[] =
198 { 204 {
199 {PREFS_EVENT_SIGNONF, _("Buddy signs on/off")}, 205 {PREFS_EVENT_SIGNONF, _("Buddy signs on/off")},
200 {PREFS_EVENT_IM_MSG, _("You receive an IMs")}, 206 {PREFS_EVENT_IM_MSG, _("You receive an IM")},
201 {PREFS_EVENT_CHAT_MSG, _("Someone speaks in a chat")}, 207 {PREFS_EVENT_CHAT_MSG, _("Someone speaks in a chat")},
202 {PREFS_EVENT_CHAT_NICK, _("Someone says your name in a chat")}, 208 {PREFS_EVENT_CHAT_NICK, _("Someone says your name in a chat")},
203 {NULL, NULL} 209 {NULL, NULL}
204 }; 210 };
205 211
207 pref_toggled(GntTree *tree, char *key, gpointer null) 213 pref_toggled(GntTree *tree, char *key, gpointer null)
208 { 214 {
209 gaim_prefs_set_bool(key, gnt_tree_get_choice(tree, key)); 215 gaim_prefs_set_bool(key, gnt_tree_get_choice(tree, key));
210 } 216 }
211 217
218 static void
219 beep_toggled(GntCheckBox *check, gpointer null)
220 {
221 gaim_prefs_set_bool(PREFS_BEEP, gnt_check_box_get_checked(check));
222 }
223
212 static GntWidget * 224 static GntWidget *
213 config_frame() 225 config_frame()
214 { 226 {
215 GntWidget *window, *tree; 227 GntWidget *window, *tree, *check;
216 int i; 228 int i;
217 229
218 window = gnt_vbox_new(FALSE); 230 window = gnt_vbox_new(FALSE);
219 gnt_box_set_pad(GNT_BOX(window), 0); 231 gnt_box_set_pad(GNT_BOX(window), 0);
220 gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID); 232 gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID);
233 gnt_tree_set_choice(GNT_TREE(tree), prefs[i].pref, 245 gnt_tree_set_choice(GNT_TREE(tree), prefs[i].pref,
234 gaim_prefs_get_bool(prefs[i].pref)); 246 gaim_prefs_get_bool(prefs[i].pref));
235 } 247 }
236 gnt_tree_set_col_width(GNT_TREE(tree), 0, 40); 248 gnt_tree_set_col_width(GNT_TREE(tree), 0, 40);
237 g_signal_connect(G_OBJECT(tree), "toggled", G_CALLBACK(pref_toggled), NULL); 249 g_signal_connect(G_OBJECT(tree), "toggled", G_CALLBACK(pref_toggled), NULL);
250
251 check = gnt_check_box_new(_("Beep too!"));
252 gnt_check_box_set_checked(GNT_CHECK_BOX(check), gaim_prefs_get_bool(PREFS_BEEP));
253 g_signal_connect(G_OBJECT(check), "toggled", G_CALLBACK(beep_toggled), NULL);
254 gnt_box_add_widget(GNT_BOX(window), check);
238 255
239 return window; 256 return window;
240 } 257 }
241 258
242 static GaimPluginInfo info = 259 static GaimPluginInfo info =
276 293
277 gaim_prefs_add_bool(PREFS_EVENT_SIGNONF, TRUE); 294 gaim_prefs_add_bool(PREFS_EVENT_SIGNONF, TRUE);
278 gaim_prefs_add_bool(PREFS_EVENT_IM_MSG, TRUE); 295 gaim_prefs_add_bool(PREFS_EVENT_IM_MSG, TRUE);
279 gaim_prefs_add_bool(PREFS_EVENT_CHAT_MSG, TRUE); 296 gaim_prefs_add_bool(PREFS_EVENT_CHAT_MSG, TRUE);
280 gaim_prefs_add_bool(PREFS_EVENT_CHAT_NICK, TRUE); 297 gaim_prefs_add_bool(PREFS_EVENT_CHAT_NICK, TRUE);
298
299 gaim_prefs_add_bool(PREFS_BEEP, TRUE);
281 } 300 }
282 301
283 GAIM_INIT_PLUGIN(PLUGIN_STATIC_NAME, init_plugin, info) 302 GAIM_INIT_PLUGIN(PLUGIN_STATIC_NAME, init_plugin, info)