annotate console/plugins/gntgf.c @ 14305:fd46a9845fc2

[gaim-migrate @ 16995] Do it right committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Wed, 23 Aug 2006 05:10:08 +0000
parents d9aa45c10588
children 9e9699792bb9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1 /**
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
2 * @file gntgf.c Minimal toaster plugin in Gnt.
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
3 *
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
4 * Copyright (C) 2006 Sadrul Habib Chowdhury <sadrul@users.sourceforge.net>
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
5 *
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
9 * (at your option) any later version.
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
10 *
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
14 * GNU General Public License for more details.
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
15 *
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
19 */
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
20
14223
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14157
diff changeset
21
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14157
diff changeset
22 #include "internal.h"
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
23
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
24 #define PLUGIN_STATIC_NAME "GntGf"
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
25
14157
d822e68acb3e [gaim-migrate @ 16802]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14146
diff changeset
26 #define PREFS_PREFIX "/plugins/gnt/gntgf"
d822e68acb3e [gaim-migrate @ 16802]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14146
diff changeset
27 #define PREFS_EVENT PREFS_PREFIX "/events"
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
28 #define PREFS_EVENT_SIGNONF PREFS_EVENT "/signonf"
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
29 #define PREFS_EVENT_IM_MSG PREFS_EVENT "/immsg"
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
30 #define PREFS_EVENT_CHAT_MSG PREFS_EVENT "/chatmsg"
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
31 #define PREFS_EVENT_CHAT_NICK PREFS_EVENT "/chatnick"
14157
d822e68acb3e [gaim-migrate @ 16802]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14146
diff changeset
32 #define PREFS_BEEP PREFS_PREFIX "/beep"
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
33
14303
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
34 #define MAX_COLS 3
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
35
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
36 #include <glib.h>
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
37
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
38 #include <plugin.h>
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
39 #include <version.h>
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
40 #include <blist.h>
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
41 #include <conversation.h>
14303
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
42 #include <debug.h>
14146
55e3db9db9f6 [gaim-migrate @ 16789]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14139
diff changeset
43 #include <util.h>
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
44
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
45 #include <gnt.h>
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
46 #include <gntbox.h>
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
47 #include <gntbutton.h>
14157
d822e68acb3e [gaim-migrate @ 16802]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14146
diff changeset
48 #include <gntcheckbox.h>
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
49 #include <gntlabel.h>
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
50 #include <gnttree.h>
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
51
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
52 #include <gntplugin.h>
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
53
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
54 typedef struct
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
55 {
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
56 GntWidget *window;
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
57 int timer;
14303
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
58 int column;
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
59 } GntToast;
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
60
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
61 static GList *toasters;
14303
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
62 static int gpsy[MAX_COLS];
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
63 static int gpsw[MAX_COLS];
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
64
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
65 static void
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
66 destroy_toaster(GntToast *toast)
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
67 {
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
68 toasters = g_list_remove(toasters, toast);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
69 gnt_widget_destroy(toast->window);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
70 g_source_remove(toast->timer);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
71 g_free(toast);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
72 }
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
73
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
74 static gboolean
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
75 remove_toaster(GntToast *toast)
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
76 {
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
77 GList *iter;
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
78 int h;
14303
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
79 int col;
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
80 int nwin[MAX_COLS];
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
81
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
82 gnt_widget_get_size(toast->window, NULL, &h);
14303
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
83 gpsy[toast->column] -= h;
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
84 col = toast->column;
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
85
14303
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
86 memset(&nwin, 0, sizeof(nwin));
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
87 destroy_toaster(toast);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
88
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
89 for (iter = toasters; iter; iter = iter->next)
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
90 {
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
91 int x, y;
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
92 toast = iter->data;
14303
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
93 nwin[toast->column]++;
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
94 if (toast->column != col) continue;
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
95 gnt_widget_get_position(toast->window, &x, &y);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
96 y += h;
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
97 gnt_screen_move_widget(toast->window, x, y);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
98 }
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
99
14303
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
100 if (nwin[col] == 0)
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
101 gpsw[col] = 0;
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
102
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
103 return FALSE;
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
104 }
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
105
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
106 static void
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
107 notify(const char *fmt, ...)
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
108 {
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
109 GntWidget *window;
14303
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
110 GntToast *toast;
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
111 char *str;
14303
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
112 int h, w, i;
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
113 va_list args;
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
114
14157
d822e68acb3e [gaim-migrate @ 16802]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14146
diff changeset
115 if (gaim_prefs_get_bool(PREFS_BEEP))
d822e68acb3e [gaim-migrate @ 16802]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14146
diff changeset
116 beep();
d822e68acb3e [gaim-migrate @ 16802]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14146
diff changeset
117
14303
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
118 window = gnt_vbox_new(FALSE);
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
119 GNT_WIDGET_SET_FLAGS(window, GNT_WIDGET_TRANSIENT);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
120 GNT_WIDGET_UNSET_FLAGS(window, GNT_WIDGET_NO_BORDER);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
121
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
122 va_start(args, fmt);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
123 str = g_strdup_vprintf(fmt, args);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
124 va_end(args);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
125
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
126 gnt_box_add_widget(GNT_BOX(window),
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
127 gnt_label_new_with_format(str, GNT_TEXT_FLAG_HIGHLIGHT));
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
128
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
129 g_free(str);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
130 gnt_widget_size_request(window);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
131 gnt_widget_get_size(window, &w, &h);
14305
fd46a9845fc2 [gaim-migrate @ 16995]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14303
diff changeset
132 for (i = 0; i < MAX_COLS && gpsy[i] + h >= getmaxy(stdscr) ; ++i)
14303
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
133 ;
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
134 if (i >= MAX_COLS) {
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
135 gaim_debug_warning("GntGf", "Dude, that's way too many popups\n");
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
136 gnt_widget_destroy(window);
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
137 return;
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
138 }
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
139
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
140 toast = g_new0(GntToast, 1);
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
141 toast->window = window;
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
142 toast->column = i;
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
143 gpsy[i] += h;
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
144 if (w > gpsw[i]) {
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
145 if (i == 0)
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
146 gpsw[i] = w;
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
147 else
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
148 gpsw[i] = gpsw[i - 1] + w + 1;
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
149 }
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
150
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
151 if (i == 0 || (w + gpsw[i - 1] >= getmaxx(stdscr))) {
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
152 /* if it's going to be too far left, overlap. */
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
153 gnt_widget_set_position(window, getmaxx(stdscr) - w - 1,
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
154 getmaxy(stdscr) - gpsy[i] - 1);
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
155 } else {
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
156 gnt_widget_set_position(window, getmaxx(stdscr) - gpsw[i - 1] - w - 1,
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
157 getmaxy(stdscr) - gpsy[i] - 1);
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
158 }
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
159 gnt_widget_draw(window);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
160
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
161 toast->timer = g_timeout_add(4000, (GSourceFunc)remove_toaster, toast);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
162 toasters = g_list_prepend(toasters, toast);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
163 }
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
164
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
165 static void
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
166 buddy_signed_on(GaimBuddy *buddy, gpointer null)
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
167 {
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
168 if (gaim_prefs_get_bool(PREFS_EVENT_SIGNONF))
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
169 notify(_("%s just signed on"), gaim_buddy_get_alias(buddy));
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
170 }
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
171
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
172 static void
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
173 buddy_signed_off(GaimBuddy *buddy, gpointer null)
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
174 {
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
175 if (gaim_prefs_get_bool(PREFS_EVENT_SIGNONF))
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
176 notify(_("%s just signed off"), gaim_buddy_get_alias(buddy));
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
177 }
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
178
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
179 static void
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
180 received_im_msg(GaimAccount *account, const char *sender, const char *msg,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
181 GaimConversation *conv, GaimMessageFlags flags, gpointer null)
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
182 {
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
183 if (gaim_prefs_get_bool(PREFS_EVENT_IM_MSG))
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
184 notify(_("%s sent you a message"), sender);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
185 }
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
186
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
187 static void
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
188 received_chat_msg(GaimAccount *account, const char *sender, const char *msg,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
189 GaimConversation *conv, GaimMessageFlags flags, gpointer null)
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
190 {
14146
55e3db9db9f6 [gaim-migrate @ 16789]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14139
diff changeset
191 const char *nick;
55e3db9db9f6 [gaim-migrate @ 16789]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14139
diff changeset
192
55e3db9db9f6 [gaim-migrate @ 16789]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14139
diff changeset
193 if (flags & GAIM_MESSAGE_WHISPER)
55e3db9db9f6 [gaim-migrate @ 16789]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14139
diff changeset
194 return;
55e3db9db9f6 [gaim-migrate @ 16789]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14139
diff changeset
195
55e3db9db9f6 [gaim-migrate @ 16789]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14139
diff changeset
196 nick = GAIM_CONV_CHAT(conv)->nick;
55e3db9db9f6 [gaim-migrate @ 16789]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14139
diff changeset
197
55e3db9db9f6 [gaim-migrate @ 16789]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14139
diff changeset
198 if (g_utf8_collate(sender, nick) == 0)
55e3db9db9f6 [gaim-migrate @ 16789]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14139
diff changeset
199 return;
55e3db9db9f6 [gaim-migrate @ 16789]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14139
diff changeset
200
55e3db9db9f6 [gaim-migrate @ 16789]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14139
diff changeset
201 if (gaim_prefs_get_bool(PREFS_EVENT_CHAT_NICK) &&
55e3db9db9f6 [gaim-migrate @ 16789]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14139
diff changeset
202 (gaim_utf8_has_word(msg, nick)))
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
203 notify(_("%s said your nick in %s"), sender, gaim_conversation_get_name(conv));
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
204 else if (gaim_prefs_get_bool(PREFS_EVENT_CHAT_MSG))
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
205 notify(_("%s sent a message in %s"), sender, gaim_conversation_get_name(conv));
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
206 }
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
207
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
208 static gboolean
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
209 plugin_load(GaimPlugin *plugin)
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
210 {
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
211 gaim_signal_connect(gaim_blist_get_handle(), "buddy-signed-on", plugin,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
212 GAIM_CALLBACK(buddy_signed_on), NULL);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
213 gaim_signal_connect(gaim_blist_get_handle(), "buddy-signed-off", plugin,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
214 GAIM_CALLBACK(buddy_signed_off), NULL);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
215 gaim_signal_connect(gaim_conversations_get_handle(), "received-im-msg", plugin,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
216 GAIM_CALLBACK(received_im_msg), NULL);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
217 gaim_signal_connect(gaim_conversations_get_handle(), "received-chat-msg", plugin,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
218 GAIM_CALLBACK(received_chat_msg), NULL);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
219
14303
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
220 memset(&gpsy, 0, sizeof(gpsy));
d9aa45c10588 [gaim-migrate @ 16993]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
221 memset(&gpsw, 0, sizeof(gpsw));
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
222
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
223 return TRUE;
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
224 }
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
225
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
226 static gboolean
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
227 plugin_unload(GaimPlugin *plugin)
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
228 {
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
229 while (toasters)
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
230 {
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
231 GntToast *toast = toasters->data;
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
232 destroy_toaster(toast);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
233 }
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
234 return TRUE;
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
235 }
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
236
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
237 static struct
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
238 {
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
239 char *pref;
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
240 char *display;
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
241 } prefs[] =
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
242 {
14223
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14157
diff changeset
243 {PREFS_EVENT_SIGNONF, N_("Buddy signs on/off")},
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14157
diff changeset
244 {PREFS_EVENT_IM_MSG, N_("You receive an IM")},
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14157
diff changeset
245 {PREFS_EVENT_CHAT_MSG, N_("Someone speaks in a chat")},
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14157
diff changeset
246 {PREFS_EVENT_CHAT_NICK, N_("Someone says your name in a chat")},
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
247 {NULL, NULL}
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
248 };
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
249
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
250 static void
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
251 pref_toggled(GntTree *tree, char *key, gpointer null)
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
252 {
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
253 gaim_prefs_set_bool(key, gnt_tree_get_choice(tree, key));
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
254 }
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
255
14157
d822e68acb3e [gaim-migrate @ 16802]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14146
diff changeset
256 static void
d822e68acb3e [gaim-migrate @ 16802]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14146
diff changeset
257 beep_toggled(GntCheckBox *check, gpointer null)
d822e68acb3e [gaim-migrate @ 16802]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14146
diff changeset
258 {
d822e68acb3e [gaim-migrate @ 16802]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14146
diff changeset
259 gaim_prefs_set_bool(PREFS_BEEP, gnt_check_box_get_checked(check));
d822e68acb3e [gaim-migrate @ 16802]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14146
diff changeset
260 }
d822e68acb3e [gaim-migrate @ 16802]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14146
diff changeset
261
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
262 static GntWidget *
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
263 config_frame()
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
264 {
14157
d822e68acb3e [gaim-migrate @ 16802]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14146
diff changeset
265 GntWidget *window, *tree, *check;
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
266 int i;
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
267
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
268 window = gnt_vbox_new(FALSE);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
269 gnt_box_set_pad(GNT_BOX(window), 0);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
270 gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
271 gnt_box_set_fill(GNT_BOX(window), TRUE);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
272
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
273 gnt_box_add_widget(GNT_BOX(window),
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
274 gnt_label_new(_("Notify with a toaster when")));
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
275
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
276 tree = gnt_tree_new();
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
277 gnt_box_add_widget(GNT_BOX(window), tree);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
278
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
279 for (i = 0; prefs[i].pref; i++)
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
280 {
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
281 gnt_tree_add_choice(GNT_TREE(tree), prefs[i].pref,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
282 gnt_tree_create_row(GNT_TREE(tree), prefs[i].display), NULL, NULL);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
283 gnt_tree_set_choice(GNT_TREE(tree), prefs[i].pref,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
284 gaim_prefs_get_bool(prefs[i].pref));
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
285 }
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
286 gnt_tree_set_col_width(GNT_TREE(tree), 0, 40);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
287 g_signal_connect(G_OBJECT(tree), "toggled", G_CALLBACK(pref_toggled), NULL);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
288
14157
d822e68acb3e [gaim-migrate @ 16802]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14146
diff changeset
289 check = gnt_check_box_new(_("Beep too!"));
d822e68acb3e [gaim-migrate @ 16802]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14146
diff changeset
290 gnt_check_box_set_checked(GNT_CHECK_BOX(check), gaim_prefs_get_bool(PREFS_BEEP));
d822e68acb3e [gaim-migrate @ 16802]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14146
diff changeset
291 g_signal_connect(G_OBJECT(check), "toggled", G_CALLBACK(beep_toggled), NULL);
d822e68acb3e [gaim-migrate @ 16802]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14146
diff changeset
292 gnt_box_add_widget(GNT_BOX(window), check);
d822e68acb3e [gaim-migrate @ 16802]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14146
diff changeset
293
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
294 return window;
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
295 }
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
296
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
297 static GaimPluginInfo info =
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
298 {
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
299 GAIM_PLUGIN_MAGIC,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
300 GAIM_MAJOR_VERSION,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
301 GAIM_MINOR_VERSION,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
302 GAIM_PLUGIN_STANDARD,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
303 GAIM_GNT_PLUGIN_TYPE,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
304 0,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
305 NULL,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
306 GAIM_PRIORITY_DEFAULT,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
307 "gntgf",
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
308 N_("GntGf"),
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
309 VERSION,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
310 N_("Toaster plugin for GntGaim."),
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
311 N_("Toaster plugin for GntGaim."),
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
312 "Sadrul H Chowdhury <sadrul@users.sourceforge.net>",
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
313 "http://gaim.sourceforge.net",
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
314 plugin_load,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
315 plugin_unload,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
316 NULL,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
317 config_frame,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
318 NULL,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
319 NULL,
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
320 NULL
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
321 };
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
322
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
323 static void
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
324 init_plugin(GaimPlugin *plugin)
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
325 {
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
326 gaim_prefs_add_none("/plugins");
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
327 gaim_prefs_add_none("/plugins/gnt");
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
328
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
329 gaim_prefs_add_none("/plugins/gnt/gntgf");
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
330 gaim_prefs_add_none(PREFS_EVENT);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
331
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
332 gaim_prefs_add_bool(PREFS_EVENT_SIGNONF, TRUE);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
333 gaim_prefs_add_bool(PREFS_EVENT_IM_MSG, TRUE);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
334 gaim_prefs_add_bool(PREFS_EVENT_CHAT_MSG, TRUE);
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
335 gaim_prefs_add_bool(PREFS_EVENT_CHAT_NICK, TRUE);
14157
d822e68acb3e [gaim-migrate @ 16802]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14146
diff changeset
336
d822e68acb3e [gaim-migrate @ 16802]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14146
diff changeset
337 gaim_prefs_add_bool(PREFS_BEEP, TRUE);
14139
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
338 }
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
339
44ec6c7cbc76 [gaim-migrate @ 16781]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
340 GAIM_INIT_PLUGIN(PLUGIN_STATIC_NAME, init_plugin, info)