Mercurial > pidgin.yaz
annotate src/gtkpounce.c @ 5411:2c4188300aba
[gaim-migrate @ 5787]
This fixes an i18n thing, I think.
I changed some stuff in oscar.c to use _() instead of calling gettext
directly. That's ok, right? I like the macro better.
I also fixed a compile warning or two. If that function declaration
isn't supposed to be there, feel free to move it, or remove it, or
lemme know and I'll do it.
Viva 0.63!
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sat, 17 May 2003 05:41:18 +0000 |
parents | 3adb20b869b4 |
children | ad445074d239 |
rev | line source |
---|---|
5032 | 1 /** |
2 * @file gtkpounce.h GTK+ buddy pounce API | |
3 * | |
4 * gaim | |
5 * | |
6 * Copyright (C) 2003, Christian Hammond <chipx86@gnupdate.org> | |
7 * | |
8 * This program is free software; you can redistribute it and/or modify | |
9 * it under the terms of the GNU General Public License as published by | |
10 * the Free Software Foundation; either version 2 of the License, or | |
11 * (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, | |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 * GNU General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU General Public License | |
19 * along with this program; if not, write to the Free Software | |
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 * | |
22 */ | |
5054 | 23 #include <unistd.h> |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
24 #include <string.h> |
5032 | 25 #include "gaim.h" |
26 #include "gtkpounce.h" | |
5228
1a53330dfd34
[gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
27 #include "gtkblist.h" |
5032 | 28 #include "prpl.h" |
29 #include "sound.h" | |
30 | |
31 struct gaim_gtkpounce_dialog | |
32 { | |
33 /* Pounce data */ | |
34 struct gaim_pounce *pounce; | |
35 struct gaim_account *account; | |
36 | |
37 /* The window */ | |
38 GtkWidget *window; | |
39 | |
40 /* Pounce Who */ | |
41 GtkWidget *account_menu; | |
42 GtkWidget *buddy_entry; | |
43 | |
44 /* Pounce When */ | |
45 GtkWidget *signon; | |
46 GtkWidget *signoff; | |
47 GtkWidget *away; | |
48 GtkWidget *away_return; | |
49 GtkWidget *idle; | |
50 GtkWidget *idle_return; | |
51 GtkWidget *typing; | |
52 GtkWidget *stop_typing; | |
53 | |
54 /* Pounce Action */ | |
55 GtkWidget *open_win; | |
56 GtkWidget *popup; | |
57 GtkWidget *send_msg; | |
58 GtkWidget *send_msg_entry; | |
59 GtkWidget *exec_cmd; | |
60 GtkWidget *exec_cmd_entry; | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
61 GtkWidget *exec_cmd_browse; |
5032 | 62 GtkWidget *play_sound; |
63 GtkWidget *play_sound_entry; | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
64 GtkWidget *play_sound_browse; |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
65 GtkWidget *play_sound_test; |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
66 |
5032 | 67 GtkWidget *save_pounce; |
68 }; | |
69 | |
70 /************************************************************************** | |
71 * Callbacks | |
72 **************************************************************************/ | |
73 static gint | |
74 delete_win_cb(GtkWidget *w, GdkEventAny *e, | |
75 struct gaim_gtkpounce_dialog *dialog) | |
76 { | |
77 gtk_widget_destroy(dialog->window); | |
78 g_free(dialog); | |
79 | |
80 return TRUE; | |
81 } | |
82 | |
83 static void | |
5052
6a7759f63766
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
84 delete_cb(GtkWidget *w, struct gaim_gtkpounce_dialog *dialog) |
6a7759f63766
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
85 { |
6a7759f63766
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
86 gaim_pounce_destroy(dialog->pounce); |
6a7759f63766
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
87 |
6a7759f63766
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
88 delete_win_cb(NULL, NULL, dialog); |
6a7759f63766
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
89 } |
6a7759f63766
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
90 |
6a7759f63766
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
91 static void |
5032 | 92 cancel_cb(GtkWidget *w, struct gaim_gtkpounce_dialog *dialog) |
93 { | |
94 delete_win_cb(NULL, NULL, dialog); | |
95 } | |
96 | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
97 static void |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
98 pounce_update_entryfields(GtkWidget *w, gpointer data) |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
99 { |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
100 const char *selected_filename; |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
101 GHashTable *args; |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
102 |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
103 args = (GHashTable *) data; |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
104 |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
105 selected_filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION(g_hash_table_lookup(args, "pounce_file_selector"))); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
106 if (selected_filename != NULL) |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
107 gtk_entry_set_text(GTK_ENTRY(g_hash_table_lookup(args, "entry")),selected_filename); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
108 |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
109 g_free(args); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
110 } |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
111 |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
112 static void |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
113 pounce_file_selector(GtkWidget *w, gpointer data) |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
114 { |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
115 GtkWidget *pounce_file_selector; |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
116 GtkWidget *entry; |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
117 GHashTable *args; |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
118 |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
119 entry = (GtkWidget *) data; |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
120 |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
121 pounce_file_selector = gtk_file_selection_new(_("Select a file")); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
122 gtk_file_selection_set_filename(GTK_FILE_SELECTION(pounce_file_selector), gtk_entry_get_text(GTK_ENTRY(entry))); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
123 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(pounce_file_selector)); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
124 gtk_file_selection_set_select_multiple(GTK_FILE_SELECTION(pounce_file_selector), FALSE); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
125 |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
126 args = g_hash_table_new(g_str_hash,g_str_equal); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
127 g_hash_table_insert(args, "pounce_file_selector", (gpointer) pounce_file_selector); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
128 g_hash_table_insert(args, "entry", (gpointer) entry); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
129 |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
130 g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(pounce_file_selector)->ok_button), |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
131 "clicked", G_CALLBACK(pounce_update_entryfields), (gpointer) args); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
132 |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
133 g_signal_connect_swapped(G_OBJECT(GTK_FILE_SELECTION(pounce_file_selector)->ok_button), |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
134 "clicked", G_CALLBACK(gtk_widget_destroy), (gpointer) pounce_file_selector); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
135 g_signal_connect_swapped(G_OBJECT(GTK_FILE_SELECTION(pounce_file_selector)->cancel_button), |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
136 "clicked", G_CALLBACK(gtk_widget_destroy), (gpointer) pounce_file_selector); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
137 |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
138 gtk_widget_show(pounce_file_selector); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
139 } |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
140 |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
141 static void |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
142 pounce_test_sound(GtkWidget *w, gpointer data) |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
143 { |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
144 const char *filename; |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
145 GtkWidget *entry; |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
146 |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
147 entry = (GtkWidget *) data; |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
148 |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
149 filename = gtk_entry_get_text(GTK_ENTRY(entry)); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
150 if ((filename != NULL) && (strlen(filename) > 0)) |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
151 gaim_sound_play_file((char *) filename); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
152 else |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
153 gaim_sound_play_event(GAIM_SOUND_POUNCE_DEFAULT); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
154 } |
5032 | 155 |
156 static void | |
157 save_pounce_cb(GtkWidget *w, struct gaim_gtkpounce_dialog *dialog) | |
158 { | |
159 const char *name; | |
160 const char *message, *command, *sound; | |
161 struct gaim_buddy_list *blist; | |
162 struct gaim_gtk_buddy_list *gtkblist; | |
163 GaimPounceEvent events = GAIM_POUNCE_NONE; | |
164 GaimGtkPounceAction actions = GAIM_GTKPOUNCE_NONE; | |
165 gboolean save; | |
166 | |
167 name = gtk_entry_get_text(GTK_ENTRY(dialog->buddy_entry)); | |
168 | |
169 if (*name == '\0') { | |
170 do_error_dialog(_("Please enter a buddy to pounce."), NULL, GAIM_ERROR); | |
171 return; | |
172 } | |
173 | |
174 /* Events */ | |
175 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->signon))) | |
176 events |= GAIM_POUNCE_SIGNON; | |
177 | |
178 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->signoff))) | |
179 events |= GAIM_POUNCE_SIGNOFF; | |
180 | |
181 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->away))) | |
182 events |= GAIM_POUNCE_AWAY; | |
183 | |
184 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->away_return))) | |
185 events |= GAIM_POUNCE_AWAY_RETURN; | |
186 | |
187 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->idle))) | |
188 events |= GAIM_POUNCE_IDLE; | |
189 | |
190 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->idle_return))) | |
191 events |= GAIM_POUNCE_IDLE_RETURN; | |
192 | |
193 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->typing))) | |
194 events |= GAIM_POUNCE_TYPING; | |
195 | |
196 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->stop_typing))) | |
197 events |= GAIM_POUNCE_TYPING_STOPPED; | |
198 | |
199 | |
200 /* Actions */ | |
201 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->open_win))) | |
202 actions |= GAIM_GTKPOUNCE_OPEN_WIN; | |
203 | |
204 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->popup))) | |
205 actions |= GAIM_GTKPOUNCE_POPUP; | |
206 | |
207 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->send_msg))) | |
208 actions |= GAIM_GTKPOUNCE_SEND_MSG; | |
209 | |
210 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->exec_cmd))) | |
211 actions |= GAIM_GTKPOUNCE_EXEC_CMD; | |
212 | |
213 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->play_sound))) | |
214 actions |= GAIM_GTKPOUNCE_PLAY_SOUND; | |
215 | |
216 save = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->save_pounce)); | |
217 | |
218 /* Data fields */ | |
219 message = gtk_entry_get_text(GTK_ENTRY(dialog->send_msg_entry)); | |
220 command = gtk_entry_get_text(GTK_ENTRY(dialog->exec_cmd_entry)); | |
221 sound = gtk_entry_get_text(GTK_ENTRY(dialog->play_sound_entry)); | |
222 | |
223 if (*message == '\0') message = NULL; | |
224 if (*command == '\0') command = NULL; | |
225 if (*sound == '\0') sound = NULL; | |
226 | |
227 if (dialog->pounce == NULL) | |
228 { | |
229 gaim_gtkpounce_new(dialog->account, name, events, actions, | |
230 message, command, sound, save); | |
231 } | |
232 else | |
233 { | |
234 struct gaim_gtkpounce_data *pounce_data; | |
235 | |
236 gaim_pounce_set_events(dialog->pounce, events); | |
237 gaim_pounce_set_pouncer(dialog->pounce, dialog->account); | |
238 gaim_pounce_set_pouncee(dialog->pounce, name); | |
239 | |
240 pounce_data = GAIM_GTKPOUNCE(dialog->pounce); | |
241 | |
242 if (pounce_data->message != NULL) g_free(pounce_data->message); | |
243 if (pounce_data->command != NULL) g_free(pounce_data->command); | |
244 if (pounce_data->sound != NULL) g_free(pounce_data->sound); | |
245 | |
246 pounce_data->message = (message == NULL ? NULL : g_strdup(message)); | |
247 pounce_data->command = (command == NULL ? NULL : g_strdup(command)); | |
248 pounce_data->sound = (sound == NULL ? NULL : g_strdup(sound)); | |
249 | |
250 pounce_data->actions = actions; | |
251 pounce_data->save = save; | |
252 } | |
253 | |
254 delete_win_cb(NULL, NULL, dialog); | |
255 /* Rebuild the pounce menu */ | |
256 blist = gaim_get_blist(); | |
257 | |
258 if (GAIM_IS_GTK_BLIST(blist)) | |
259 { | |
260 gtkblist = GAIM_GTK_BLIST(blist); | |
261 | |
262 gaim_gtkpounce_menu_build(gtkblist->bpmenu); | |
263 } | |
264 | |
265 save_prefs(); | |
266 } | |
267 | |
5054 | 268 static void |
5032 | 269 pounce_choose_cb(GtkWidget *item, struct gaim_gtkpounce_dialog *dialog) |
270 { | |
271 dialog->account = g_object_get_data(G_OBJECT(item), "user_data"); | |
272 } | |
273 | |
274 static GtkWidget * | |
275 pounce_user_menu(struct gaim_gtkpounce_dialog *dialog) | |
276 { | |
277 struct gaim_account *account; | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
278 GaimPlugin *prpl; |
5032 | 279 GtkWidget *opt_menu; |
280 GtkWidget *menu; | |
281 GtkWidget *item; | |
282 GSList *l; | |
283 char buf[2048]; | |
5054 | 284 int count, place = 0; |
5032 | 285 |
286 opt_menu = gtk_option_menu_new(); | |
287 menu = gtk_menu_new(); | |
288 | |
289 for (l = gaim_accounts, count = 0; l != NULL; l = l->next, count++) { | |
290 account = (struct gaim_account *)l->data; | |
291 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
292 prpl = gaim_find_prpl(account->protocol); |
5032 | 293 |
294 g_snprintf(buf, sizeof(buf), "%s (%s)", account->username, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
295 (prpl && prpl->info->name) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
296 ? prpl->info->name : _("Unknown")); |
5032 | 297 |
298 item = gtk_menu_item_new_with_label(buf); | |
299 g_object_set_data(G_OBJECT(item), "user_data", account); | |
300 | |
301 g_signal_connect(G_OBJECT(item), "activate", | |
302 G_CALLBACK(pounce_choose_cb), dialog); | |
303 | |
304 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); | |
305 gtk_widget_show(item); | |
306 | |
307 if (dialog->account == account) { | |
308 gtk_menu_item_activate(GTK_MENU_ITEM(item)); | |
309 place = count; | |
310 } | |
311 } | |
312 | |
313 gtk_option_menu_set_menu(GTK_OPTION_MENU(opt_menu), menu); | |
314 gtk_option_menu_set_history(GTK_OPTION_MENU(opt_menu), place); | |
315 | |
316 return opt_menu; | |
317 } | |
318 | |
319 static void | |
320 pounce_cb(struct gaim_pounce *pounce, GaimPounceEvent events, void *data) | |
321 { | |
322 struct gaim_conversation *conv; | |
323 struct gaim_account *account; | |
324 struct gaim_gtkpounce_data *pounce_data; | |
325 const char *pouncee; | |
326 | |
327 pounce_data = (struct gaim_gtkpounce_data *)data; | |
328 pouncee = gaim_pounce_get_pouncee(pounce); | |
329 account = gaim_pounce_get_pouncer(pounce); | |
330 | |
331 if (pounce_data->actions & GAIM_GTKPOUNCE_OPEN_WIN) { | |
332 conv = gaim_find_conversation(pouncee); | |
333 | |
334 if (conv == NULL) | |
335 conv = gaim_conversation_new(GAIM_CONV_IM, account, pouncee); | |
336 } | |
337 | |
338 if (pounce_data->actions & GAIM_GTKPOUNCE_POPUP) { | |
339 char tmp[1024]; | |
340 | |
341 g_snprintf(tmp, sizeof(tmp), | |
342 (events & GAIM_POUNCE_TYPING) ? _("%s has started typing to you") : | |
343 (events & GAIM_POUNCE_SIGNON) ? _("%s has signed on") : | |
344 (events & GAIM_POUNCE_IDLE_RETURN) ? _("%s has returned from being idle") : | |
345 (events & GAIM_POUNCE_AWAY_RETURN) ? _("%s has returned from being away") : | |
346 (events & GAIM_POUNCE_TYPING_STOPPED) ? _("%s has stopped typing to you") : | |
347 (events & GAIM_POUNCE_SIGNOFF) ? _("%s has signed off") : | |
348 (events & GAIM_POUNCE_IDLE) ? _("%s has become idle") : | |
349 (events & GAIM_POUNCE_AWAY) ? _("%s has gone away.") : | |
350 _("Unknown pounce event. Please report this!"), | |
351 pouncee); | |
352 | |
353 do_error_dialog(tmp, NULL, GAIM_INFO); | |
354 } | |
355 | |
356 if (pounce_data->actions & GAIM_GTKPOUNCE_SEND_MSG && | |
5051
b3d9195777bb
[gaim-migrate @ 5400]
Christian Hammond <chipx86@chipx86.com>
parents:
5032
diff
changeset
|
357 pounce_data->message != NULL) { |
5032 | 358 |
359 conv = gaim_find_conversation(pouncee); | |
360 | |
361 if (conv == NULL) | |
362 conv = gaim_conversation_new(GAIM_CONV_IM, account, pouncee); | |
363 | |
364 gaim_conversation_write(conv, NULL, pounce_data->message, -1, | |
365 WFLAG_SEND, time(NULL)); | |
366 | |
367 serv_send_im(account->gc, (char *)pouncee, pounce_data->message, -1, 0); | |
368 } | |
369 | |
370 if (pounce_data->actions & GAIM_GTKPOUNCE_EXEC_CMD && | |
5051
b3d9195777bb
[gaim-migrate @ 5400]
Christian Hammond <chipx86@chipx86.com>
parents:
5032
diff
changeset
|
371 pounce_data->command != NULL) { |
5032 | 372 #ifndef _WIN32 |
373 int pid = fork(); | |
374 | |
375 if (pid == 0) { | |
376 char *args[4]; | |
377 | |
378 args[0] = "sh"; | |
379 args[1] = "-c"; | |
380 args[2] = pounce_data->command; | |
381 args[3] = NULL; | |
382 | |
383 execvp(args[0], args); | |
384 | |
385 _exit(0); | |
386 } | |
387 #endif /* _WIN32 */ | |
388 } | |
389 | |
390 if (pounce_data->actions & GAIM_GTKPOUNCE_PLAY_SOUND) { | |
5051
b3d9195777bb
[gaim-migrate @ 5400]
Christian Hammond <chipx86@chipx86.com>
parents:
5032
diff
changeset
|
391 if (pounce_data->sound != NULL) |
5032 | 392 gaim_sound_play_file(pounce_data->sound); |
393 else | |
394 gaim_sound_play_event(GAIM_SOUND_POUNCE_DEFAULT); | |
395 } | |
396 | |
397 if (!pounce_data->save) | |
398 gaim_pounce_destroy(pounce); | |
399 } | |
400 | |
401 static void | |
402 free_pounce(void *data) | |
403 { | |
404 struct gaim_gtkpounce_data *pounce_data; | |
405 struct gaim_buddy_list *blist; | |
406 struct gaim_gtk_buddy_list *gtkblist; | |
407 | |
408 pounce_data = (struct gaim_gtkpounce_data *)data; | |
409 | |
410 if (pounce_data->message != NULL) g_free(pounce_data->message); | |
411 if (pounce_data->command != NULL) g_free(pounce_data->command); | |
412 if (pounce_data->sound != NULL) g_free(pounce_data->sound); | |
413 | |
414 g_free(data); | |
415 | |
416 /* Rebuild the pounce menu */ | |
417 blist = gaim_get_blist(); | |
418 | |
419 if (GAIM_IS_GTK_BLIST(blist)) | |
420 { | |
421 gtkblist = GAIM_GTK_BLIST(blist); | |
422 | |
423 gaim_gtkpounce_menu_build(gtkblist->bpmenu); | |
424 } | |
425 | |
426 save_prefs(); | |
427 } | |
428 | |
429 struct gaim_pounce * | |
430 gaim_gtkpounce_new(struct gaim_account *pouncer, const char *pouncee, | |
431 GaimPounceEvent events, GaimGtkPounceAction actions, | |
432 const char *message, const char *command, | |
433 const char *sound, gboolean save) | |
434 { | |
435 struct gaim_gtkpounce_data *data; | |
436 | |
437 data = g_new0(struct gaim_gtkpounce_data, 1); | |
438 | |
439 data->actions = actions; | |
440 | |
441 if (message != NULL) data->message = g_strdup(message); | |
442 if (command != NULL) data->command = g_strdup(command); | |
443 if (sound != NULL) data->sound = g_strdup(sound); | |
444 | |
445 data->save = save; | |
446 | |
447 return gaim_pounce_new(pouncer, pouncee, events, pounce_cb, data, | |
448 free_pounce); | |
449 } | |
450 | |
451 void | |
452 gaim_gtkpounce_dialog_show(struct buddy *buddy, | |
453 struct gaim_pounce *cur_pounce) | |
454 { | |
455 struct gaim_gtkpounce_dialog *dialog; | |
456 GtkWidget *window; | |
457 GtkWidget *label; | |
458 GtkWidget *bbox; | |
459 GtkWidget *vbox1, *vbox2; | |
460 GtkWidget *hbox; | |
461 GtkWidget *button; | |
462 GtkWidget *frame; | |
463 GtkWidget *table; | |
464 GtkWidget *sep; | |
465 GtkSizeGroup *sg; | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
466 GPtrArray *sound_widgets; |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
467 GPtrArray *exec_widgets; |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
468 |
5032 | 469 dialog = g_new0(struct gaim_gtkpounce_dialog, 1); |
470 | |
471 if (cur_pounce != NULL) { | |
472 dialog->pounce = cur_pounce; | |
473 dialog->account = gaim_pounce_get_pouncer(cur_pounce); | |
474 } | |
475 else if (buddy != NULL) { | |
476 dialog->pounce = NULL; | |
477 dialog->account = buddy->account; | |
478 } | |
479 else { | |
480 dialog->pounce = NULL; | |
481 dialog->account = gaim_accounts->data; | |
482 } | |
483 | |
484 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); | |
485 | |
486 /* Create the window. */ | |
487 dialog->window = window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
488 gtk_window_set_type_hint(GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_DIALOG); | |
489 gtk_window_set_role(GTK_WINDOW(window), "buddy_pounce"); | |
490 gtk_window_set_resizable(GTK_WINDOW(window), FALSE); | |
491 gtk_window_set_title(GTK_WINDOW(window), | |
492 (cur_pounce == NULL | |
493 ? _("New Buddy Pounce") : _("Edit Buddy Pounce"))); | |
494 | |
495 gtk_container_set_border_width(GTK_CONTAINER(window), 12); | |
496 gtk_widget_realize(window); | |
497 | |
498 g_signal_connect(G_OBJECT(window), "delete_event", | |
499 G_CALLBACK(delete_win_cb), dialog); | |
500 | |
501 /* Create the parent vbox for everything. */ | |
502 vbox1 = gtk_vbox_new(FALSE, 12); | |
503 gtk_container_add(GTK_CONTAINER(window), vbox1); | |
504 gtk_widget_show(vbox1); | |
505 | |
506 /* Create the vbox that will contain all the prefs stuff. */ | |
507 vbox2 = gtk_vbox_new(FALSE, 18); | |
508 gtk_box_pack_start(GTK_BOX(vbox1), vbox2, TRUE, TRUE, 0); | |
509 | |
510 /* Create the "Pounce Who" frame. */ | |
511 frame = make_frame(vbox2, _("Pounce Who")); | |
512 | |
513 /* Account: */ | |
514 hbox = gtk_hbox_new(FALSE, 6); | |
515 gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); | |
516 gtk_widget_show(hbox); | |
517 | |
518 label = gtk_label_new_with_mnemonic(_("_Account:")); | |
519 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
520 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
521 gtk_widget_show(label); | |
522 gtk_size_group_add_widget(sg, label); | |
523 | |
524 dialog->account_menu = pounce_user_menu(dialog); | |
525 gtk_box_pack_start(GTK_BOX(hbox), dialog->account_menu, FALSE, FALSE, 0); | |
526 gtk_widget_show(dialog->account_menu); | |
527 | |
528 /* Buddy: */ | |
529 hbox = gtk_hbox_new(FALSE, 6); | |
530 gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); | |
531 gtk_widget_show(hbox); | |
532 | |
533 label = gtk_label_new_with_mnemonic(_("_Buddy Name:")); | |
534 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
535 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
536 gtk_widget_show(label); | |
537 gtk_size_group_add_widget(sg, label); | |
538 | |
539 dialog->buddy_entry = gtk_entry_new(); | |
540 gtk_box_pack_start(GTK_BOX(hbox), dialog->buddy_entry, TRUE, TRUE, 0); | |
541 gtk_widget_show(dialog->buddy_entry); | |
542 | |
543 if (cur_pounce != NULL) { | |
544 gtk_entry_set_text(GTK_ENTRY(dialog->buddy_entry), | |
545 gaim_pounce_get_pouncee(cur_pounce)); | |
546 } | |
547 else if (buddy != NULL) { | |
548 gtk_entry_set_text(GTK_ENTRY(dialog->buddy_entry), buddy->name); | |
549 } | |
550 | |
551 /* Create the "Pounce When" frame. */ | |
552 frame = make_frame(vbox2, _("Pounce When")); | |
553 | |
554 table = gtk_table_new(2, 4, FALSE); | |
555 gtk_container_add(GTK_CONTAINER(frame), table); | |
556 gtk_table_set_col_spacings(GTK_TABLE(table), 12); | |
557 gtk_widget_show(table); | |
558 | |
559 dialog->signon = | |
560 gtk_check_button_new_with_label(_("Sign on")); | |
561 dialog->signoff = | |
562 gtk_check_button_new_with_label(_("Sign off")); | |
563 dialog->away = | |
564 gtk_check_button_new_with_label(_("Away")); | |
565 dialog->away_return = | |
566 gtk_check_button_new_with_label(_("Return from away")); | |
567 dialog->idle = | |
568 gtk_check_button_new_with_label(_("Idle")); | |
569 dialog->idle_return = | |
570 gtk_check_button_new_with_label(_("Return from idle")); | |
571 dialog->typing = | |
572 gtk_check_button_new_with_label(_("Buddy starts typing")); | |
573 dialog->stop_typing = | |
574 gtk_check_button_new_with_label(_("Buddy stops typing")); | |
575 | |
576 gtk_table_attach(GTK_TABLE(table), dialog->signon, 0, 1, 0, 1, | |
577 GTK_FILL, 0, 0, 0); | |
578 gtk_table_attach(GTK_TABLE(table), dialog->signoff, 1, 2, 0, 1, | |
579 GTK_FILL, 0, 0, 0); | |
580 gtk_table_attach(GTK_TABLE(table), dialog->away, 0, 1, 1, 2, | |
581 GTK_FILL, 0, 0, 0); | |
582 gtk_table_attach(GTK_TABLE(table), dialog->away_return, 1, 2, 1, 2, | |
583 GTK_FILL, 0, 0, 0); | |
584 gtk_table_attach(GTK_TABLE(table), dialog->idle, 0, 1, 2, 3, | |
585 GTK_FILL, 0, 0, 0); | |
586 gtk_table_attach(GTK_TABLE(table), dialog->idle_return, 1, 2, 2, 3, | |
587 GTK_FILL, 0, 0, 0); | |
588 gtk_table_attach(GTK_TABLE(table), dialog->typing, 0, 1, 3, 4, | |
589 GTK_FILL, 0, 0, 0); | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
590 gtk_table_attach(GTK_TABLE(table), dialog->stop_typing, 1, 2, 3, 5, |
5032 | 591 GTK_FILL, 0, 0, 0); |
592 | |
593 gtk_widget_show(dialog->signon); | |
594 gtk_widget_show(dialog->signoff); | |
595 gtk_widget_show(dialog->away); | |
596 gtk_widget_show(dialog->away_return); | |
597 gtk_widget_show(dialog->idle); | |
598 gtk_widget_show(dialog->idle_return); | |
599 gtk_widget_show(dialog->typing); | |
600 gtk_widget_show(dialog->stop_typing); | |
601 | |
602 /* Create the "Pounce Action" frame. */ | |
603 frame = make_frame(vbox2, _("Pounce Action")); | |
604 | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
605 table = gtk_table_new(3, 5, FALSE); |
5032 | 606 gtk_container_add(GTK_CONTAINER(frame), table); |
607 gtk_table_set_col_spacings(GTK_TABLE(table), 12); | |
608 gtk_widget_show(table); | |
609 | |
610 dialog->open_win = gtk_check_button_new_with_label(_("Open an IM window")); | |
611 dialog->popup = gtk_check_button_new_with_label(_("Popup notification")); | |
612 dialog->send_msg = gtk_check_button_new_with_label(_("Send a message")); | |
613 dialog->exec_cmd = gtk_check_button_new_with_label(_("Execute a command")); | |
5051
b3d9195777bb
[gaim-migrate @ 5400]
Christian Hammond <chipx86@chipx86.com>
parents:
5032
diff
changeset
|
614 dialog->play_sound = gtk_check_button_new_with_label(_("Play a sound")); |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
615 |
5032 | 616 dialog->send_msg_entry = gtk_entry_new(); |
617 dialog->exec_cmd_entry = gtk_entry_new(); | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
618 dialog->exec_cmd_browse = gtk_button_new_with_label(_("Browse")); |
5032 | 619 dialog->play_sound_entry = gtk_entry_new(); |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
620 dialog->play_sound_browse = gtk_button_new_with_label(_("Browse")); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
621 dialog->play_sound_test = gtk_button_new_with_label(_("Test")); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
622 |
5032 | 623 gtk_widget_set_sensitive(dialog->send_msg_entry, FALSE); |
624 gtk_widget_set_sensitive(dialog->exec_cmd_entry, FALSE); | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
625 gtk_widget_set_sensitive(dialog->exec_cmd_browse, FALSE); |
5032 | 626 gtk_widget_set_sensitive(dialog->play_sound_entry, FALSE); |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
627 gtk_widget_set_sensitive(dialog->play_sound_browse, FALSE); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
628 gtk_widget_set_sensitive(dialog->play_sound_test, FALSE); |
5032 | 629 |
630 gtk_table_attach(GTK_TABLE(table), dialog->open_win, 0, 1, 0, 1, | |
631 GTK_FILL, 0, 0, 0); | |
632 gtk_table_attach(GTK_TABLE(table), dialog->popup, 0, 1, 1, 2, | |
633 GTK_FILL, 0, 0, 0); | |
634 gtk_table_attach(GTK_TABLE(table), dialog->send_msg, 0, 1, 2, 3, | |
635 GTK_FILL, 0, 0, 0); | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
636 gtk_table_attach(GTK_TABLE(table), dialog->send_msg_entry, 1, 4, 2, 3, |
5032 | 637 GTK_FILL, 0, 0, 0); |
638 gtk_table_attach(GTK_TABLE(table), dialog->exec_cmd, 0, 1, 3, 4, | |
639 GTK_FILL, 0, 0, 0); | |
640 gtk_table_attach(GTK_TABLE(table), dialog->exec_cmd_entry, 1, 2, 3, 4, | |
641 GTK_FILL, 0, 0, 0); | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
642 gtk_table_attach(GTK_TABLE(table), dialog->exec_cmd_browse, 2, 3, 3, 4, |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
643 GTK_FILL | GTK_EXPAND, 0, 0, 0); |
5032 | 644 gtk_table_attach(GTK_TABLE(table), dialog->play_sound, 0, 1, 4, 5, |
645 GTK_FILL, 0, 0, 0); | |
646 gtk_table_attach(GTK_TABLE(table), dialog->play_sound_entry, 1, 2, 4, 5, | |
647 GTK_FILL, 0, 0, 0); | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
648 gtk_table_attach(GTK_TABLE(table), dialog->play_sound_browse, 2, 3, 4, 5, |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
649 GTK_FILL | GTK_EXPAND, 0, 0, 0); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
650 gtk_table_attach(GTK_TABLE(table), dialog->play_sound_test, 3, 4, 4, 5, |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
651 GTK_FILL | GTK_EXPAND, 0, 0, 0); |
5032 | 652 |
653 gtk_widget_show(dialog->open_win); | |
654 gtk_widget_show(dialog->popup); | |
655 gtk_widget_show(dialog->send_msg); | |
656 gtk_widget_show(dialog->send_msg_entry); | |
657 gtk_widget_show(dialog->exec_cmd); | |
658 gtk_widget_show(dialog->exec_cmd_entry); | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
659 gtk_widget_show(dialog->exec_cmd_browse); |
5032 | 660 gtk_widget_show(dialog->play_sound); |
661 gtk_widget_show(dialog->play_sound_entry); | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
662 gtk_widget_show(dialog->play_sound_browse); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
663 gtk_widget_show(dialog->play_sound_test); |
5032 | 664 |
665 g_signal_connect(G_OBJECT(dialog->send_msg), "clicked", | |
666 G_CALLBACK(gaim_gtk_toggle_sensitive), | |
667 dialog->send_msg_entry); | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
668 |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
669 exec_widgets = g_ptr_array_new(); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
670 g_ptr_array_add(exec_widgets,dialog->exec_cmd_entry); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
671 g_ptr_array_add(exec_widgets,dialog->exec_cmd_browse); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
672 |
5032 | 673 g_signal_connect(G_OBJECT(dialog->exec_cmd), "clicked", |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
674 G_CALLBACK(gtk_toggle_sensitive_array), |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
675 exec_widgets); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
676 g_signal_connect(G_OBJECT(dialog->exec_cmd_browse), "clicked", |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
677 G_CALLBACK(pounce_file_selector), |
5032 | 678 dialog->exec_cmd_entry); |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
679 |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
680 sound_widgets = g_ptr_array_new(); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
681 g_ptr_array_add(sound_widgets,dialog->play_sound_entry); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
682 g_ptr_array_add(sound_widgets,dialog->play_sound_browse); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
683 g_ptr_array_add(sound_widgets,dialog->play_sound_test); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
684 |
5032 | 685 g_signal_connect(G_OBJECT(dialog->play_sound), "clicked", |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
686 G_CALLBACK(gtk_toggle_sensitive_array), |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
687 sound_widgets); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
688 g_signal_connect(G_OBJECT(dialog->play_sound_browse), "clicked", |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
689 G_CALLBACK(pounce_file_selector), |
5032 | 690 dialog->play_sound_entry); |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
691 g_signal_connect(G_OBJECT(dialog->play_sound_test), "clicked", |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
692 G_CALLBACK(pounce_test_sound), |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
693 dialog->play_sound_entry); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
694 |
5032 | 695 g_signal_connect(G_OBJECT(dialog->send_msg_entry), "activate", |
696 G_CALLBACK(save_pounce_cb), dialog); | |
697 g_signal_connect(G_OBJECT(dialog->exec_cmd_entry), "activate", | |
698 G_CALLBACK(save_pounce_cb), dialog); | |
699 g_signal_connect(G_OBJECT(dialog->play_sound_entry), "activate", | |
700 G_CALLBACK(save_pounce_cb), dialog); | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
701 |
5032 | 702 /* Now the last part, where we have the Save checkbox */ |
703 dialog->save_pounce = gtk_check_button_new_with_mnemonic( | |
704 _("_Save this pounce after activation")); | |
705 | |
706 gtk_box_pack_start(GTK_BOX(vbox2), dialog->save_pounce, FALSE, FALSE, 0); | |
707 | |
708 /* Separator... */ | |
709 sep = gtk_hseparator_new(); | |
710 gtk_box_pack_start(GTK_BOX(vbox1), sep, FALSE, FALSE, 0); | |
711 gtk_widget_show(sep); | |
712 | |
713 /* Now the button box! */ | |
714 bbox = gtk_hbutton_box_new(); | |
715 gtk_box_set_spacing(GTK_BOX(bbox), 6); | |
716 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
717 gtk_box_pack_end(GTK_BOX(vbox1), bbox, FALSE, FALSE, 0); | |
718 gtk_widget_show(bbox); | |
719 | |
5052
6a7759f63766
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
720 /* Delete button */ |
6a7759f63766
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
721 button = gtk_button_new_from_stock(GTK_STOCK_DELETE); |
6a7759f63766
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
722 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); |
6a7759f63766
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
723 gtk_widget_show(button); |
6a7759f63766
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
724 |
6a7759f63766
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
725 g_signal_connect(G_OBJECT(button), "clicked", |
6a7759f63766
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
726 G_CALLBACK(delete_cb), dialog); |
6a7759f63766
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
727 |
5032 | 728 /* Cancel button */ |
729 button = gtk_button_new_from_stock(GTK_STOCK_CANCEL); | |
730 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
731 gtk_widget_show(button); | |
732 | |
733 g_signal_connect(G_OBJECT(button), "clicked", | |
734 G_CALLBACK(cancel_cb), dialog); | |
735 | |
736 /* OK button */ | |
737 button = gtk_button_new_from_stock(GTK_STOCK_OK); | |
738 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
739 gtk_widget_show(button); | |
740 | |
741 g_signal_connect(G_OBJECT(button), "clicked", | |
742 G_CALLBACK(save_pounce_cb), dialog); | |
743 | |
744 /* Set the values of stuff. */ | |
745 if (cur_pounce != NULL) { | |
746 GaimPounceEvent events; | |
747 GaimGtkPounceAction actions; | |
748 struct gaim_gtkpounce_data *pounce_data; | |
749 | |
750 pounce_data = GAIM_GTKPOUNCE(cur_pounce); | |
751 events = gaim_pounce_get_events(cur_pounce); | |
752 actions = pounce_data->actions; | |
753 | |
754 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->signon), | |
755 (events & GAIM_POUNCE_SIGNON)); | |
756 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->signoff), | |
757 (events & GAIM_POUNCE_SIGNOFF)); | |
758 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->away), | |
759 (events & GAIM_POUNCE_AWAY)); | |
760 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->away_return), | |
761 (events & GAIM_POUNCE_AWAY_RETURN)); | |
762 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->idle), | |
763 (events & GAIM_POUNCE_IDLE)); | |
764 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->idle_return), | |
765 (events & GAIM_POUNCE_IDLE_RETURN)); | |
766 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->typing), | |
767 (events & GAIM_POUNCE_TYPING)); | |
768 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->stop_typing), | |
769 (events & GAIM_POUNCE_TYPING_STOPPED)); | |
770 | |
771 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->open_win), | |
772 (actions & GAIM_GTKPOUNCE_OPEN_WIN)); | |
773 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->popup), | |
774 (actions & GAIM_GTKPOUNCE_POPUP)); | |
775 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->send_msg), | |
776 (actions & GAIM_GTKPOUNCE_SEND_MSG)); | |
777 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->exec_cmd), | |
778 (actions & GAIM_GTKPOUNCE_EXEC_CMD)); | |
779 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->play_sound), | |
780 (actions & GAIM_GTKPOUNCE_PLAY_SOUND)); | |
781 | |
782 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->save_pounce), | |
783 pounce_data->save); | |
784 | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
785 if (pounce_data->message != NULL) |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
786 gtk_entry_set_text(GTK_ENTRY(dialog->send_msg_entry), |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
787 pounce_data->message); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
788 if (pounce_data->command != NULL) |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
789 gtk_entry_set_text(GTK_ENTRY(dialog->exec_cmd_entry), |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
790 pounce_data->command); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
791 if (pounce_data->sound != NULL) |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
792 gtk_entry_set_text(GTK_ENTRY(dialog->play_sound_entry), |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
793 pounce_data->sound); |
5032 | 794 } |
795 else { | |
796 /* Set some defaults */ | |
797 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->send_msg), TRUE); | |
798 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->signon), TRUE); | |
799 } | |
800 | |
801 gtk_widget_show_all(vbox2); | |
802 gtk_widget_show(window); | |
803 } | |
804 | |
805 static void | |
806 new_pounce_cb(GtkWidget *w, struct buddy *b) | |
807 { | |
808 gaim_gtkpounce_dialog_show(b, NULL); | |
809 } | |
810 | |
811 static void | |
5153
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
812 delete_pounce_cb(GtkWidget *w, struct gaim_pounce *pounce) |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
813 { |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
814 gaim_pounce_destroy(pounce); |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
815 } |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
816 |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
817 static void |
5032 | 818 edit_pounce_cb(GtkWidget *w, struct gaim_pounce *pounce) |
819 { | |
820 struct buddy *buddy; | |
821 | |
822 buddy = gaim_find_buddy(gaim_pounce_get_pouncer(pounce), | |
823 gaim_pounce_get_pouncee(pounce)); | |
824 | |
825 gaim_gtkpounce_dialog_show(buddy, pounce); | |
826 } | |
827 | |
5153
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
828 static void |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
829 fill_menu(GtkWidget *menu, GCallback cb) |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
830 { |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
831 GtkWidget *image; |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
832 GtkWidget *item; |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
833 GdkPixbuf *pixbuf, *scale; |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
834 struct gaim_pounce *pounce; |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
835 const char *buddy; |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
836 GList *bp; |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
837 |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
838 for (bp = gaim_get_pounces(); bp != NULL; bp = bp->next) { |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
839 pounce = (struct gaim_pounce *)bp->data; |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
840 buddy = gaim_pounce_get_pouncee(pounce); |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
841 |
5161 | 842 /* Build the menu item */ |
843 item = gtk_image_menu_item_new_with_label(buddy); | |
844 | |
5153
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
845 /* Create a pixmap for the protocol icon. */ |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
846 pixbuf = create_prpl_icon(gaim_pounce_get_pouncer(pounce)); |
5161 | 847 if(pixbuf) { |
848 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, | |
849 GDK_INTERP_BILINEAR); | |
5153
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
850 |
5161 | 851 /* Now convert it to GtkImage */ |
5153
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
852 image = gtk_image_new_from_pixbuf(scale); |
5161 | 853 g_object_unref(G_OBJECT(scale)); |
854 g_object_unref(G_OBJECT(pixbuf)); | |
855 gtk_widget_show(image); | |
856 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image); | |
857 } | |
5153
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
858 |
5161 | 859 /* Put the item in the menu */ |
5153
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
860 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
861 gtk_widget_show(item); |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
862 |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
863 /* Set our callbacks. */ |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
864 g_signal_connect(G_OBJECT(item), "activate", cb, pounce); |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
865 } |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
866 } |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
867 |
5032 | 868 void |
869 gaim_gtkpounce_menu_build(GtkWidget *menu) | |
870 { | |
5153
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
871 GtkWidget *remmenu; |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
872 GtkWidget *item; |
5032 | 873 GList *l; |
874 | |
875 for (l = gtk_container_get_children(GTK_CONTAINER(menu)); | |
876 l != NULL; | |
877 l = l->next) { | |
878 | |
879 gtk_widget_destroy(GTK_WIDGET(l->data)); | |
880 } | |
881 | |
882 /* "New Buddy Pounce" */ | |
883 item = gtk_menu_item_new_with_label(_("New Buddy Pounce")); | |
884 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); | |
885 gtk_widget_show(item); | |
886 g_signal_connect(G_OBJECT(item), "activate", | |
887 G_CALLBACK(new_pounce_cb), NULL); | |
888 | |
889 /* "Remove Buddy Pounce" */ | |
890 item = gtk_menu_item_new_with_label(_("Remove Buddy Pounce")); | |
891 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); | |
892 | |
893 /* "Remove Buddy Pounce" menu */ | |
894 remmenu = gtk_menu_new(); | |
895 | |
5153
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
896 fill_menu(remmenu, G_CALLBACK(delete_pounce_cb)); |
5032 | 897 |
898 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), remmenu); | |
899 gtk_widget_show(remmenu); | |
900 gtk_widget_show(item); | |
901 | |
902 /* Separator */ | |
903 item = gtk_separator_menu_item_new(); | |
904 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); | |
905 gtk_widget_show(item); | |
906 | |
5153
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
907 fill_menu(menu, G_CALLBACK(edit_pounce_cb)); |
5032 | 908 } |
909 |