Mercurial > pidgin
annotate finch/gntpounce.c @ 18475:3131e25b8925
Fix a typo in the British English translation.
Fixes #2074
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Wed, 11 Jul 2007 16:48:54 +0000 |
parents | 2d4df5ef0090 |
children | 7ee0e0597a26 |
rev | line source |
---|---|
15817 | 1 /** |
2 * @file gntpounce.c GNT Buddy Pounce API | |
16194
0f0832c13fcb
Rename the Doxygen group from gntui to finch and define the finch group
Richard Laager <rlaager@wiktel.com>
parents:
15870
diff
changeset
|
3 * @ingroup finch |
15817 | 4 * |
15870
66dff3dfdea6
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
5 * finch |
15817 | 6 * |
15870
66dff3dfdea6
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
7 * Finch is the legal property of its developers, whose names are too numerous |
15817 | 8 * to list here. Please refer to the COPYRIGHT file distributed with this |
9 * source distribution. | |
10 * | |
11 * This program is free software; you can redistribute it and/or modify | |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 * | |
25 */ | |
26 #include <gnt.h> | |
27 #include <gntbox.h> | |
28 #include <gntbutton.h> | |
29 #include <gntcheckbox.h> | |
30 #include <gntcombobox.h> | |
31 #include <gntentry.h> | |
32 #include <gntlabel.h> | |
33 #include <gntline.h> | |
34 #include <gnttree.h> | |
35 #include "internal.h" | |
15822 | 36 #include "finch.h" |
15817 | 37 |
38 #include "account.h" | |
39 #include "conversation.h" | |
40 #include "debug.h" | |
41 #include "notify.h" | |
42 #include "prpl.h" | |
43 #include "request.h" | |
44 #include "server.h" | |
45 #include "util.h" | |
46 | |
47 #include "gntpounce.h" | |
48 | |
49 | |
50 typedef struct | |
51 { | |
52 /* Pounce data */ | |
15822 | 53 PurplePounce *pounce; |
54 PurpleAccount *account; | |
15817 | 55 |
56 /* The window */ | |
57 GntWidget *window; | |
58 | |
59 /* Pounce on Whom */ | |
60 GntWidget *account_menu; | |
61 GntWidget *buddy_entry; | |
62 | |
63 /* Pounce options */ | |
64 GntWidget *on_away; | |
65 | |
66 /* Pounce When Buddy... */ | |
67 GntWidget *signon; | |
68 GntWidget *signoff; | |
69 GntWidget *away; | |
70 GntWidget *away_return; | |
71 GntWidget *idle; | |
72 GntWidget *idle_return; | |
73 GntWidget *typing; | |
74 GntWidget *typed; | |
75 GntWidget *stop_typing; | |
76 GntWidget *message_recv; | |
77 | |
78 /* Action */ | |
79 GntWidget *open_win; | |
80 GntWidget *popup; | |
81 GntWidget *popup_entry; | |
82 GntWidget *send_msg; | |
83 GntWidget *send_msg_entry; | |
84 GntWidget *exec_cmd; | |
85 GntWidget *exec_cmd_entry; | |
86 GntWidget *play_sound; | |
87 | |
88 GntWidget *save_pounce; | |
89 | |
90 /* Buttons */ | |
91 GntWidget *save_button; | |
92 | |
15822 | 93 } PurpleGntPounceDialog; |
15817 | 94 |
95 typedef struct | |
96 { | |
97 GntWidget *window; | |
98 GntWidget *tree; | |
99 GntWidget *modify_button; | |
100 GntWidget *delete_button; | |
101 } PouncesManager; | |
102 | |
103 static PouncesManager *pounces_manager = NULL; | |
104 | |
105 /************************************************************************** | |
106 * Callbacks | |
107 **************************************************************************/ | |
108 static gint | |
15822 | 109 delete_win_cb(GntWidget *w, PurpleGntPounceDialog *dialog) |
15817 | 110 { |
111 gnt_widget_destroy(dialog->window); | |
112 g_free(dialog); | |
113 | |
114 return TRUE; | |
115 } | |
116 | |
117 static void | |
15822 | 118 cancel_cb(GntWidget *w, PurpleGntPounceDialog *dialog) |
15817 | 119 { |
120 gnt_widget_destroy(dialog->window); | |
121 } | |
122 | |
123 static void | |
15822 | 124 add_pounce_to_treeview(GntTree *tree, PurplePounce *pounce) |
15817 | 125 { |
15822 | 126 PurpleAccount *account; |
15817 | 127 const char *pouncer; |
128 const char *pouncee; | |
129 | |
15822 | 130 account = purple_pounce_get_pouncer(pounce); |
131 pouncer = purple_account_get_username(account); | |
132 pouncee = purple_pounce_get_pouncee(pounce); | |
15817 | 133 gnt_tree_add_row_last(tree, pounce, |
134 gnt_tree_create_row(tree, pouncer, pouncee), NULL); | |
135 } | |
136 | |
137 static void | |
138 populate_pounces_list(PouncesManager *dialog) | |
139 { | |
18118
ab6d2763b8d8
Re-fix the DBus list handling code by killing const GList* / const GSList*
Richard Laager <rlaager@wiktel.com>
parents:
18063
diff
changeset
|
140 GList *pounces; |
15817 | 141 |
142 gnt_tree_remove_all(GNT_TREE(dialog->tree)); | |
143 | |
18137
323272a9bb65
Fix #1574. (Pidgin and Finch show each other's pounces, interact in
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18118
diff
changeset
|
144 for (pounces = purple_pounces_get_all_for_ui(FINCH_UI); pounces != NULL; |
323272a9bb65
Fix #1574. (Pidgin and Finch show each other's pounces, interact in
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18118
diff
changeset
|
145 pounces = g_list_delete_link(pounces, pounces)) |
15817 | 146 { |
147 add_pounce_to_treeview(GNT_TREE(dialog->tree), pounces->data); | |
148 } | |
149 } | |
150 | |
151 static void | |
152 update_pounces(void) | |
153 { | |
154 /* Rebuild the pounces list if the pounces manager is open */ | |
155 if (pounces_manager != NULL) | |
156 { | |
157 populate_pounces_list(pounces_manager); | |
158 } | |
159 } | |
160 | |
161 static void | |
15822 | 162 signed_on_off_cb(PurpleConnection *gc, gpointer user_data) |
15817 | 163 { |
164 update_pounces(); | |
165 } | |
166 | |
167 static void | |
15822 | 168 save_pounce_cb(GntWidget *w, PurpleGntPounceDialog *dialog) |
15817 | 169 { |
170 const char *name; | |
171 const char *message, *command, *reason; | |
15822 | 172 PurplePounceEvent events = PURPLE_POUNCE_NONE; |
173 PurplePounceOption options = PURPLE_POUNCE_OPTION_NONE; | |
15817 | 174 |
175 name = gnt_entry_get_text(GNT_ENTRY(dialog->buddy_entry)); | |
176 | |
177 if (*name == '\0') | |
178 { | |
15822 | 179 purple_notify_error(NULL, NULL, |
15817 | 180 _("Please enter a buddy to pounce."), NULL); |
181 return; | |
182 } | |
183 | |
184 /* Options */ | |
185 if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->on_away))) | |
15822 | 186 options |= PURPLE_POUNCE_OPTION_AWAY; |
15817 | 187 |
188 /* Events */ | |
189 if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->signon))) | |
15822 | 190 events |= PURPLE_POUNCE_SIGNON; |
15817 | 191 |
192 if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->signoff))) | |
15822 | 193 events |= PURPLE_POUNCE_SIGNOFF; |
15817 | 194 |
195 if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->away))) | |
15822 | 196 events |= PURPLE_POUNCE_AWAY; |
15817 | 197 |
198 if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->away_return))) | |
15822 | 199 events |= PURPLE_POUNCE_AWAY_RETURN; |
15817 | 200 |
201 if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->idle))) | |
15822 | 202 events |= PURPLE_POUNCE_IDLE; |
15817 | 203 |
204 if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->idle_return))) | |
15822 | 205 events |= PURPLE_POUNCE_IDLE_RETURN; |
15817 | 206 |
207 if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->typing))) | |
15822 | 208 events |= PURPLE_POUNCE_TYPING; |
15817 | 209 |
210 if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->typed))) | |
15822 | 211 events |= PURPLE_POUNCE_TYPED; |
15817 | 212 |
213 if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->stop_typing))) | |
15822 | 214 events |= PURPLE_POUNCE_TYPING_STOPPED; |
15817 | 215 |
216 if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->message_recv))) | |
15822 | 217 events |= PURPLE_POUNCE_MESSAGE_RECEIVED; |
15817 | 218 |
219 /* Data fields */ | |
220 message = gnt_entry_get_text(GNT_ENTRY(dialog->send_msg_entry)); | |
221 command = gnt_entry_get_text(GNT_ENTRY(dialog->exec_cmd_entry)); | |
222 reason = gnt_entry_get_text(GNT_ENTRY(dialog->popup_entry)); | |
223 | |
224 if (*reason == '\0') reason = NULL; | |
225 if (*message == '\0') message = NULL; | |
226 if (*command == '\0') command = NULL; | |
227 | |
228 if (dialog->pounce == NULL) { | |
15822 | 229 dialog->pounce = purple_pounce_new(FINCH_UI, dialog->account, |
15817 | 230 name, events, options); |
231 } else { | |
15822 | 232 purple_pounce_set_events(dialog->pounce, events); |
233 purple_pounce_set_options(dialog->pounce, options); | |
234 purple_pounce_set_pouncer(dialog->pounce, dialog->account); | |
235 purple_pounce_set_pouncee(dialog->pounce, name); | |
15817 | 236 } |
237 | |
238 /* Actions */ | |
15822 | 239 purple_pounce_action_set_enabled(dialog->pounce, "open-window", |
15817 | 240 gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->open_win))); |
15822 | 241 purple_pounce_action_set_enabled(dialog->pounce, "popup-notify", |
15817 | 242 gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->popup))); |
15822 | 243 purple_pounce_action_set_enabled(dialog->pounce, "send-message", |
15817 | 244 gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->send_msg))); |
15822 | 245 purple_pounce_action_set_enabled(dialog->pounce, "execute-command", |
15817 | 246 gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->exec_cmd))); |
15822 | 247 purple_pounce_action_set_enabled(dialog->pounce, "play-beep", |
15817 | 248 gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->play_sound))); |
249 | |
15822 | 250 purple_pounce_action_set_attribute(dialog->pounce, "send-message", |
15817 | 251 "message", message); |
15822 | 252 purple_pounce_action_set_attribute(dialog->pounce, "execute-command", |
15817 | 253 "command", command); |
15822 | 254 purple_pounce_action_set_attribute(dialog->pounce, "popup-notify", |
15817 | 255 "reason", reason); |
256 | |
257 /* Set the defaults for next time. */ | |
16424
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16287
diff
changeset
|
258 purple_prefs_set_bool("/finch/pounces/default_actions/open-window", |
15817 | 259 gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->open_win))); |
16424
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16287
diff
changeset
|
260 purple_prefs_set_bool("/finch/pounces/default_actions/popup-notify", |
15817 | 261 gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->popup))); |
16424
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16287
diff
changeset
|
262 purple_prefs_set_bool("/finch/pounces/default_actions/send-message", |
15817 | 263 gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->send_msg))); |
16424
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16287
diff
changeset
|
264 purple_prefs_set_bool("/finch/pounces/default_actions/execute-command", |
15817 | 265 gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->exec_cmd))); |
16424
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16287
diff
changeset
|
266 purple_prefs_set_bool("/finch/pounces/default_actions/play-beep", |
15817 | 267 gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->play_sound))); |
268 | |
15822 | 269 purple_pounce_set_save(dialog->pounce, |
15817 | 270 gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->save_pounce))); |
271 | |
15822 | 272 purple_pounce_set_pouncer(dialog->pounce, |
273 (PurpleAccount *)gnt_combo_box_get_selected_data(GNT_COMBO_BOX(dialog->account_menu))); | |
15817 | 274 |
275 update_pounces(); | |
276 | |
277 gnt_widget_destroy(dialog->window); | |
278 } | |
279 | |
280 | |
281 void | |
15822 | 282 finch_pounce_editor_show(PurpleAccount *account, const char *name, |
283 PurplePounce *cur_pounce) | |
15817 | 284 { |
15822 | 285 PurpleGntPounceDialog *dialog; |
15817 | 286 GntWidget *window; |
287 GntWidget *bbox; | |
16287
776bf7979b4f
Line up the event-checkboxes in the pounce dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
288 GntWidget *hbox, *vbox; |
15817 | 289 GntWidget *button; |
290 GntWidget *combo; | |
18063
926ccb104da0
disapproval of revision '1411afd7660760db59966c3a9f18e2adab8eb27e'
Richard Laager <rlaager@wiktel.com>
parents:
18058
diff
changeset
|
291 GList *list; |
15817 | 292 |
293 g_return_if_fail((cur_pounce != NULL) || | |
294 (account != NULL) || | |
15822 | 295 (purple_accounts_get_all() != NULL)); |
15817 | 296 |
15822 | 297 dialog = g_new0(PurpleGntPounceDialog, 1); |
15817 | 298 |
299 if (cur_pounce != NULL) { | |
300 dialog->pounce = cur_pounce; | |
15822 | 301 dialog->account = purple_pounce_get_pouncer(cur_pounce); |
15817 | 302 } else if (account != NULL) { |
303 dialog->pounce = NULL; | |
304 dialog->account = account; | |
305 } else { | |
18063
926ccb104da0
disapproval of revision '1411afd7660760db59966c3a9f18e2adab8eb27e'
Richard Laager <rlaager@wiktel.com>
parents:
18058
diff
changeset
|
306 GList *connections = purple_connections_get_all(); |
15822 | 307 PurpleConnection *gc; |
15817 | 308 |
309 if (connections != NULL) { | |
15822 | 310 gc = (PurpleConnection *)connections->data; |
311 dialog->account = purple_connection_get_account(gc); | |
15817 | 312 } else |
15822 | 313 dialog->account = purple_accounts_get_all()->data; |
15817 | 314 |
315 dialog->pounce = NULL; | |
316 } | |
317 | |
318 /* Create the window. */ | |
319 dialog->window = window = gnt_vbox_new(FALSE); | |
320 gnt_box_set_pad(GNT_BOX(window), 0); | |
321 gnt_box_set_toplevel(GNT_BOX(window), TRUE); | |
322 gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_LEFT); | |
323 gnt_box_set_title(GNT_BOX(window), | |
324 (cur_pounce == NULL | |
325 ? _("New Buddy Pounce") : _("Edit Buddy Pounce"))); | |
326 | |
327 g_signal_connect(G_OBJECT(window), "destroy", | |
328 G_CALLBACK(delete_win_cb), dialog); | |
329 | |
330 gnt_box_add_widget(GNT_BOX(window), gnt_label_new_with_format(_("Pounce Who"), GNT_TEXT_FLAG_BOLD)); | |
331 | |
332 /* Account: */ | |
333 gnt_box_add_widget(GNT_BOX(window), gnt_label_new(_("Account:"))); | |
334 dialog->account_menu = combo = gnt_combo_box_new(); | |
15822 | 335 list = purple_accounts_get_all(); |
15817 | 336 for (; list; list = list->next) |
337 { | |
15822 | 338 PurpleAccount *account; |
15817 | 339 char *text; |
340 | |
341 account = list->data; | |
342 text = g_strdup_printf("%s (%s)", | |
15822 | 343 purple_account_get_username(account), |
344 purple_account_get_protocol_name(account)); | |
15817 | 345 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), account, text); |
346 g_free(text); | |
347 } | |
348 if (dialog->account) | |
349 gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), dialog->account); | |
350 | |
351 gnt_box_add_widget(GNT_BOX(window), combo); | |
352 | |
353 /* Buddy: */ | |
354 hbox = gnt_hbox_new(FALSE); | |
355 gnt_box_add_widget(GNT_BOX(hbox), gnt_label_new(_("Buddy name:"))); | |
356 | |
357 dialog->buddy_entry = gnt_entry_new(NULL); | |
358 gnt_box_add_widget(GNT_BOX(hbox), dialog->buddy_entry); | |
359 | |
360 gnt_box_add_widget(GNT_BOX(window), hbox); | |
361 | |
362 if (cur_pounce != NULL) { | |
363 gnt_entry_set_text(GNT_ENTRY(dialog->buddy_entry), | |
15822 | 364 purple_pounce_get_pouncee(cur_pounce)); |
15817 | 365 } else if (name != NULL) { |
366 gnt_entry_set_text(GNT_ENTRY(dialog->buddy_entry), name); | |
367 } | |
368 | |
16287
776bf7979b4f
Line up the event-checkboxes in the pounce dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
369 /* Create the event frame */ |
15817 | 370 gnt_box_add_widget(GNT_BOX(window), gnt_line_new(FALSE)); |
371 gnt_box_add_widget(GNT_BOX(window), gnt_label_new_with_format(_("Pounce When Buddy..."), GNT_TEXT_FLAG_BOLD)); | |
372 | |
373 dialog->signon = gnt_check_box_new(_("Signs on")); | |
374 dialog->signoff = gnt_check_box_new(_("Signs off")); | |
375 dialog->away = gnt_check_box_new(_("Goes away")); | |
376 dialog->away_return = gnt_check_box_new(_("Returns from away")); | |
377 dialog->idle = gnt_check_box_new(_("Becomes idle")); | |
378 dialog->idle_return = gnt_check_box_new(_("Is no longer idle")); | |
379 dialog->typing = gnt_check_box_new(_("Starts typing")); | |
380 dialog->typed = gnt_check_box_new(_("Pauses while typing")); | |
381 dialog->stop_typing = gnt_check_box_new(_("Stops typing")); | |
382 dialog->message_recv = gnt_check_box_new(_("Sends a message")); | |
383 | |
16287
776bf7979b4f
Line up the event-checkboxes in the pounce dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
384 hbox = gnt_hbox_new(TRUE); |
15817 | 385 gnt_box_set_pad(GNT_BOX(hbox), 2); |
16287
776bf7979b4f
Line up the event-checkboxes in the pounce dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
386 |
776bf7979b4f
Line up the event-checkboxes in the pounce dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
387 vbox = gnt_vbox_new(FALSE); |
776bf7979b4f
Line up the event-checkboxes in the pounce dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
388 gnt_box_set_pad(GNT_BOX(vbox), 0); |
776bf7979b4f
Line up the event-checkboxes in the pounce dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
389 gnt_box_add_widget(GNT_BOX(hbox), vbox); |
776bf7979b4f
Line up the event-checkboxes in the pounce dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
390 |
776bf7979b4f
Line up the event-checkboxes in the pounce dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
391 gnt_box_add_widget(GNT_BOX(vbox), dialog->signon); |
776bf7979b4f
Line up the event-checkboxes in the pounce dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
392 gnt_box_add_widget(GNT_BOX(vbox), dialog->away); |
776bf7979b4f
Line up the event-checkboxes in the pounce dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
393 gnt_box_add_widget(GNT_BOX(vbox), dialog->idle); |
776bf7979b4f
Line up the event-checkboxes in the pounce dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
394 gnt_box_add_widget(GNT_BOX(vbox), dialog->typing); |
776bf7979b4f
Line up the event-checkboxes in the pounce dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
395 gnt_box_add_widget(GNT_BOX(vbox), dialog->stop_typing); |
776bf7979b4f
Line up the event-checkboxes in the pounce dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
396 |
776bf7979b4f
Line up the event-checkboxes in the pounce dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
397 vbox = gnt_vbox_new(FALSE); |
776bf7979b4f
Line up the event-checkboxes in the pounce dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
398 gnt_box_set_pad(GNT_BOX(vbox), 0); |
776bf7979b4f
Line up the event-checkboxes in the pounce dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
399 gnt_box_add_widget(GNT_BOX(hbox), vbox); |
776bf7979b4f
Line up the event-checkboxes in the pounce dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
400 |
776bf7979b4f
Line up the event-checkboxes in the pounce dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
401 gnt_box_add_widget(GNT_BOX(vbox), dialog->signoff); |
776bf7979b4f
Line up the event-checkboxes in the pounce dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
402 gnt_box_add_widget(GNT_BOX(vbox), dialog->away_return); |
776bf7979b4f
Line up the event-checkboxes in the pounce dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
403 gnt_box_add_widget(GNT_BOX(vbox), dialog->idle_return); |
776bf7979b4f
Line up the event-checkboxes in the pounce dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
404 gnt_box_add_widget(GNT_BOX(vbox), dialog->typed); |
776bf7979b4f
Line up the event-checkboxes in the pounce dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
405 gnt_box_add_widget(GNT_BOX(vbox), dialog->message_recv); |
776bf7979b4f
Line up the event-checkboxes in the pounce dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
406 |
15817 | 407 gnt_box_add_widget(GNT_BOX(window), hbox); |
408 | |
409 /* Create the "Action" frame. */ | |
410 gnt_box_add_widget(GNT_BOX(window), gnt_line_new(FALSE)); | |
411 gnt_box_add_widget(GNT_BOX(window), gnt_label_new_with_format(_("Action"), GNT_TEXT_FLAG_BOLD)); | |
412 | |
413 dialog->open_win = gnt_check_box_new(_("Open an IM window")); | |
414 dialog->popup = gnt_check_box_new(_("Pop up a notification")); | |
415 dialog->send_msg = gnt_check_box_new(_("Send a message")); | |
416 dialog->exec_cmd = gnt_check_box_new(_("Execute a command")); | |
417 dialog->play_sound = gnt_check_box_new(_("Play a sound")); | |
418 | |
419 dialog->send_msg_entry = gnt_entry_new(NULL); | |
420 dialog->exec_cmd_entry = gnt_entry_new(NULL); | |
421 dialog->popup_entry = gnt_entry_new(NULL); | |
422 dialog->exec_cmd_entry = gnt_entry_new(NULL); | |
423 | |
424 hbox = gnt_hbox_new(FALSE); | |
425 gnt_box_add_widget(GNT_BOX(hbox), dialog->open_win); | |
426 gnt_box_add_widget(GNT_BOX(window), hbox); | |
427 hbox = gnt_hbox_new(FALSE); | |
428 gnt_box_add_widget(GNT_BOX(hbox), dialog->popup); | |
429 gnt_box_add_widget(GNT_BOX(hbox), dialog->popup_entry); | |
430 gnt_box_add_widget(GNT_BOX(window), hbox); | |
431 hbox = gnt_hbox_new(FALSE); | |
432 gnt_box_add_widget(GNT_BOX(hbox), dialog->send_msg); | |
433 gnt_box_add_widget(GNT_BOX(hbox), dialog->send_msg_entry); | |
434 gnt_box_add_widget(GNT_BOX(window), hbox); | |
435 hbox = gnt_hbox_new(FALSE); | |
436 gnt_box_add_widget(GNT_BOX(hbox), dialog->exec_cmd); | |
437 gnt_box_add_widget(GNT_BOX(hbox), dialog->exec_cmd_entry); | |
438 gnt_box_add_widget(GNT_BOX(window), hbox); | |
439 hbox = gnt_hbox_new(FALSE); | |
440 gnt_box_add_widget(GNT_BOX(hbox), dialog->play_sound); | |
441 gnt_box_add_widget(GNT_BOX(window), hbox); | |
442 | |
443 gnt_box_add_widget(GNT_BOX(window), gnt_line_new(FALSE)); | |
444 gnt_box_add_widget(GNT_BOX(window), gnt_label_new_with_format(_("Options"), GNT_TEXT_FLAG_BOLD)); | |
445 dialog->on_away = gnt_check_box_new(_("Pounce only when my status is not available")); | |
446 gnt_box_add_widget(GNT_BOX(window), dialog->on_away); | |
447 dialog->save_pounce = gnt_check_box_new(_("Recurring")); | |
448 gnt_box_add_widget(GNT_BOX(window), dialog->save_pounce); | |
449 | |
450 | |
451 gnt_box_add_widget(GNT_BOX(window), gnt_line_new(FALSE)); | |
452 /* Now the button box! */ | |
453 bbox = gnt_hbox_new(TRUE); | |
454 | |
455 /* Cancel button */ | |
456 button = gnt_button_new(_("Cancel")); | |
457 gnt_box_add_widget(GNT_BOX(bbox), button); | |
458 g_signal_connect(G_OBJECT(button), "activate", | |
459 G_CALLBACK(cancel_cb), dialog); | |
460 | |
461 /* Save button */ | |
462 dialog->save_button = button = gnt_button_new(_("Save")); | |
463 gnt_box_add_widget(GNT_BOX(bbox), button); | |
464 g_signal_connect(G_OBJECT(button), "activate", | |
465 G_CALLBACK(save_pounce_cb), dialog); | |
466 | |
467 gnt_box_add_widget(GNT_BOX(window), bbox); | |
468 | |
469 | |
470 /* Set the values of stuff. */ | |
471 if (cur_pounce != NULL) | |
472 { | |
15822 | 473 PurplePounceEvent events = purple_pounce_get_events(cur_pounce); |
474 PurplePounceOption options = purple_pounce_get_options(cur_pounce); | |
15817 | 475 const char *value; |
476 | |
477 /* Options */ | |
478 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->on_away), | |
15822 | 479 (options & PURPLE_POUNCE_OPTION_AWAY)); |
15817 | 480 |
481 /* Events */ | |
482 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->signon), | |
15822 | 483 (events & PURPLE_POUNCE_SIGNON)); |
15817 | 484 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->signoff), |
15822 | 485 (events & PURPLE_POUNCE_SIGNOFF)); |
15817 | 486 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->away), |
15822 | 487 (events & PURPLE_POUNCE_AWAY)); |
15817 | 488 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->away_return), |
15822 | 489 (events & PURPLE_POUNCE_AWAY_RETURN)); |
15817 | 490 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->idle), |
15822 | 491 (events & PURPLE_POUNCE_IDLE)); |
15817 | 492 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->idle_return), |
15822 | 493 (events & PURPLE_POUNCE_IDLE_RETURN)); |
15817 | 494 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->typing), |
15822 | 495 (events & PURPLE_POUNCE_TYPING)); |
15817 | 496 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->typed), |
15822 | 497 (events & PURPLE_POUNCE_TYPED)); |
15817 | 498 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->stop_typing), |
15822 | 499 (events & PURPLE_POUNCE_TYPING_STOPPED)); |
15817 | 500 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->message_recv), |
15822 | 501 (events & PURPLE_POUNCE_MESSAGE_RECEIVED)); |
15817 | 502 |
503 /* Actions */ | |
504 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->open_win), | |
15822 | 505 purple_pounce_action_is_enabled(cur_pounce, "open-window")); |
15817 | 506 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->popup), |
15822 | 507 purple_pounce_action_is_enabled(cur_pounce, "popup-notify")); |
15817 | 508 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->send_msg), |
15822 | 509 purple_pounce_action_is_enabled(cur_pounce, "send-message")); |
15817 | 510 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->exec_cmd), |
15822 | 511 purple_pounce_action_is_enabled(cur_pounce, "execute-command")); |
15817 | 512 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->play_sound), |
15822 | 513 purple_pounce_action_is_enabled(cur_pounce, "play-beep")); |
15817 | 514 |
515 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->save_pounce), | |
15822 | 516 purple_pounce_get_save(cur_pounce)); |
15817 | 517 |
15822 | 518 if ((value = purple_pounce_action_get_attribute(cur_pounce, |
15817 | 519 "send-message", |
520 "message")) != NULL) | |
521 { | |
522 gnt_entry_set_text(GNT_ENTRY(dialog->send_msg_entry), value); | |
523 } | |
524 | |
15822 | 525 if ((value = purple_pounce_action_get_attribute(cur_pounce, |
15817 | 526 "popup-notify", |
527 "reason")) != NULL) | |
528 { | |
529 gnt_entry_set_text(GNT_ENTRY(dialog->popup_entry), value); | |
530 } | |
531 | |
15822 | 532 if ((value = purple_pounce_action_get_attribute(cur_pounce, |
15817 | 533 "execute-command", |
534 "command")) != NULL) | |
535 { | |
536 gnt_entry_set_text(GNT_ENTRY(dialog->exec_cmd_entry), value); | |
537 } | |
538 } | |
539 else | |
540 { | |
15822 | 541 PurpleBuddy *buddy = NULL; |
15817 | 542 |
543 if (name != NULL) | |
15822 | 544 buddy = purple_find_buddy(account, name); |
15817 | 545 |
546 /* Set some defaults */ | |
547 if (buddy == NULL) { | |
548 gnt_check_box_set_checked( | |
549 GNT_CHECK_BOX(dialog->signon), TRUE); | |
550 } else { | |
15822 | 551 if (!PURPLE_BUDDY_IS_ONLINE(buddy)) { |
15817 | 552 gnt_check_box_set_checked( |
553 GNT_CHECK_BOX(dialog->signon), TRUE); | |
554 } else { | |
555 gboolean default_set = FALSE; | |
15822 | 556 PurplePresence *presence = purple_buddy_get_presence(buddy); |
15817 | 557 |
15822 | 558 if (purple_presence_is_idle(presence)) |
15817 | 559 { |
560 gnt_check_box_set_checked( | |
561 GNT_CHECK_BOX(dialog->idle_return), TRUE); | |
562 | |
563 default_set = TRUE; | |
564 } | |
565 | |
15822 | 566 if (!purple_presence_is_available(presence)) |
15817 | 567 { |
568 gnt_check_box_set_checked( | |
569 GNT_CHECK_BOX(dialog->away_return), TRUE); | |
570 | |
571 default_set = TRUE; | |
572 } | |
573 | |
574 if (!default_set) | |
575 { | |
576 gnt_check_box_set_checked( | |
577 GNT_CHECK_BOX(dialog->signon), TRUE); | |
578 } | |
579 } | |
580 } | |
581 | |
582 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->open_win), | |
16424
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16287
diff
changeset
|
583 purple_prefs_get_bool("/finch/pounces/default_actions/open-window")); |
15817 | 584 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->popup), |
16424
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16287
diff
changeset
|
585 purple_prefs_get_bool("/finch/pounces/default_actions/popup-notify")); |
15817 | 586 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->send_msg), |
16424
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16287
diff
changeset
|
587 purple_prefs_get_bool("/finch/pounces/default_actions/send-message")); |
15817 | 588 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->exec_cmd), |
16424
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16287
diff
changeset
|
589 purple_prefs_get_bool("/finch/pounces/default_actions/execute-command")); |
15817 | 590 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->play_sound), |
16424
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16287
diff
changeset
|
591 purple_prefs_get_bool("/finch/pounces/default_actions/play-beep")); |
15817 | 592 } |
593 | |
594 gnt_widget_show(window); | |
595 } | |
596 | |
597 | |
598 | |
599 static gboolean | |
600 pounces_manager_destroy_cb(GntWidget *widget, gpointer user_data) | |
601 { | |
602 PouncesManager *dialog = user_data; | |
603 | |
604 dialog->window = NULL; | |
605 finch_pounces_manager_hide(); | |
606 | |
607 return FALSE; | |
608 } | |
609 | |
610 | |
611 static void | |
612 pounces_manager_add_cb(GntButton *button, gpointer user_data) | |
613 { | |
614 finch_pounce_editor_show(NULL, NULL, NULL); | |
615 } | |
616 | |
617 | |
618 static void | |
619 pounces_manager_modify_cb(GntButton *button, gpointer user_data) | |
620 { | |
621 PouncesManager *dialog = user_data; | |
15822 | 622 PurplePounce *pounce = gnt_tree_get_selection_data(GNT_TREE(dialog->tree)); |
15817 | 623 finch_pounce_editor_show(NULL, NULL, pounce); |
624 } | |
625 | |
626 static void | |
15822 | 627 pounces_manager_delete_confirm_cb(PurplePounce *pounce) |
15817 | 628 { |
629 gnt_tree_remove(GNT_TREE(pounces_manager->tree), pounce); | |
630 | |
15822 | 631 purple_request_close_with_handle(pounce); |
632 purple_pounce_destroy(pounce); | |
15817 | 633 } |
634 | |
635 | |
636 static void | |
637 pounces_manager_delete_cb(GntButton *button, gpointer user_data) | |
638 { | |
639 PouncesManager *dialog = user_data; | |
15822 | 640 PurplePounce *pounce; |
641 PurpleAccount *account; | |
15817 | 642 const char *pouncer, *pouncee; |
643 char *buf; | |
644 | |
15822 | 645 pounce = (PurplePounce *)gnt_tree_get_selection_data(GNT_TREE(dialog->tree)); |
646 account = purple_pounce_get_pouncer(pounce); | |
647 pouncer = purple_account_get_username(account); | |
648 pouncee = purple_pounce_get_pouncee(pounce); | |
15817 | 649 buf = g_strdup_printf(_("Are you sure you want to delete the pounce on %s for %s?"), pouncee, pouncer); |
16439
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16424
diff
changeset
|
650 purple_request_action(pounce, NULL, buf, NULL, 0, |
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16424
diff
changeset
|
651 account, pouncee, NULL, |
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16424
diff
changeset
|
652 pounce, 2, |
15817 | 653 _("Delete"), pounces_manager_delete_confirm_cb, |
654 _("Cancel"), NULL); | |
655 g_free(buf); | |
656 } | |
657 | |
658 static void | |
659 pounces_manager_close_cb(GntButton *button, gpointer user_data) | |
660 { | |
661 finch_pounces_manager_hide(); | |
662 } | |
663 | |
664 | |
665 void | |
666 finch_pounces_manager_show(void) | |
667 { | |
668 PouncesManager *dialog; | |
669 GntWidget *bbox; | |
670 GntWidget *button; | |
671 GntWidget *tree; | |
672 GntWidget *win; | |
673 | |
674 if (pounces_manager != NULL) { | |
18345
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18137
diff
changeset
|
675 gnt_window_present(pounces_manager->window); |
15817 | 676 return; |
677 } | |
678 | |
679 pounces_manager = dialog = g_new0(PouncesManager, 1); | |
680 | |
681 dialog->window = win = gnt_vbox_new(FALSE); | |
682 gnt_box_set_toplevel(GNT_BOX(win), TRUE); | |
683 gnt_box_set_title(GNT_BOX(win), _("Buddy Pounces")); | |
684 gnt_box_set_pad(GNT_BOX(win), 0); | |
685 | |
686 g_signal_connect(G_OBJECT(win), "destroy", | |
687 G_CALLBACK(pounces_manager_destroy_cb), dialog); | |
688 | |
689 /* List of saved buddy pounces */ | |
690 dialog->tree = tree = GNT_WIDGET(gnt_tree_new_with_columns(2)); | |
691 gnt_tree_set_column_titles(GNT_TREE(tree), "Account", "Pouncee", NULL); | |
692 gnt_tree_set_show_title(GNT_TREE(tree), TRUE); | |
693 | |
694 gnt_box_add_widget(GNT_BOX(win), tree); | |
695 | |
696 /* Button box. */ | |
697 bbox = gnt_hbox_new(TRUE); | |
698 | |
699 /* Add button */ | |
700 button = gnt_button_new(_("Add")); | |
701 gnt_box_add_widget(GNT_BOX(bbox), button); | |
702 | |
703 g_signal_connect(G_OBJECT(button), "activate", | |
704 G_CALLBACK(pounces_manager_add_cb), dialog); | |
705 | |
706 /* Modify button */ | |
707 button = gnt_button_new(_("Modify")); | |
708 dialog->modify_button = button; | |
709 gnt_box_add_widget(GNT_BOX(bbox), button); | |
710 | |
711 g_signal_connect(G_OBJECT(button), "activate", | |
712 G_CALLBACK(pounces_manager_modify_cb), dialog); | |
713 | |
714 /* Delete button */ | |
715 button = gnt_button_new(_("Delete")); | |
716 dialog->delete_button = button; | |
717 gnt_box_add_widget(GNT_BOX(bbox), button); | |
718 | |
719 g_signal_connect(G_OBJECT(button), "activate", | |
720 G_CALLBACK(pounces_manager_delete_cb), dialog); | |
721 | |
722 /* Close button */ | |
723 button = gnt_button_new(_("Close")); | |
724 gnt_box_add_widget(GNT_BOX(bbox), button); | |
725 gnt_widget_show(button); | |
726 | |
727 g_signal_connect(G_OBJECT(button), "activate", | |
728 G_CALLBACK(pounces_manager_close_cb), dialog); | |
729 | |
730 gnt_box_add_widget(GNT_BOX(win), bbox); | |
731 | |
732 gnt_widget_show(win); | |
733 populate_pounces_list(pounces_manager); | |
734 } | |
735 | |
736 void | |
737 finch_pounces_manager_hide(void) | |
738 { | |
739 if (pounces_manager == NULL) | |
740 return; | |
741 | |
742 if (pounces_manager->window != NULL) | |
743 gnt_widget_destroy(pounces_manager->window); | |
744 | |
15822 | 745 purple_signals_disconnect_by_handle(pounces_manager); |
15817 | 746 |
747 g_free(pounces_manager); | |
748 pounces_manager = NULL; | |
749 } | |
750 | |
751 static void | |
15822 | 752 pounce_cb(PurplePounce *pounce, PurplePounceEvent events, void *data) |
15817 | 753 { |
15822 | 754 PurpleConversation *conv; |
755 PurpleAccount *account; | |
756 PurpleBuddy *buddy; | |
15817 | 757 const char *pouncee; |
758 const char *alias; | |
759 | |
15822 | 760 pouncee = purple_pounce_get_pouncee(pounce); |
761 account = purple_pounce_get_pouncer(pounce); | |
15817 | 762 |
15822 | 763 buddy = purple_find_buddy(account, pouncee); |
15817 | 764 if (buddy != NULL) |
765 { | |
15822 | 766 alias = purple_buddy_get_alias(buddy); |
15817 | 767 if (alias == NULL) |
768 alias = pouncee; | |
769 } | |
770 else | |
771 alias = pouncee; | |
772 | |
15822 | 773 if (purple_pounce_action_is_enabled(pounce, "open-window")) |
15817 | 774 { |
15822 | 775 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, pouncee, account); |
15817 | 776 |
777 if (conv == NULL) | |
15822 | 778 conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, pouncee); |
15817 | 779 } |
780 | |
15822 | 781 if (purple_pounce_action_is_enabled(pounce, "popup-notify")) |
15817 | 782 { |
783 char *tmp; | |
784 const char *name_shown; | |
785 const char *reason; | |
15822 | 786 reason = purple_pounce_action_get_attribute(pounce, "popup-notify", |
15817 | 787 "reason"); |
788 | |
789 /* | |
790 * Here we place the protocol name in the pounce dialog to lessen | |
791 * confusion about what protocol a pounce is for. | |
792 */ | |
793 tmp = g_strdup_printf( | |
15822 | 794 (events & PURPLE_POUNCE_TYPING) ? |
15817 | 795 _("%s has started typing to you (%s)") : |
15822 | 796 (events & PURPLE_POUNCE_TYPED) ? |
15817 | 797 _("%s has paused while typing to you (%s)") : |
15822 | 798 (events & PURPLE_POUNCE_SIGNON) ? |
15817 | 799 _("%s has signed on (%s)") : |
15822 | 800 (events & PURPLE_POUNCE_IDLE_RETURN) ? |
15817 | 801 _("%s has returned from being idle (%s)") : |
15822 | 802 (events & PURPLE_POUNCE_AWAY_RETURN) ? |
15817 | 803 _("%s has returned from being away (%s)") : |
15822 | 804 (events & PURPLE_POUNCE_TYPING_STOPPED) ? |
15817 | 805 _("%s has stopped typing to you (%s)") : |
15822 | 806 (events & PURPLE_POUNCE_SIGNOFF) ? |
15817 | 807 _("%s has signed off (%s)") : |
15822 | 808 (events & PURPLE_POUNCE_IDLE) ? |
15817 | 809 _("%s has become idle (%s)") : |
15822 | 810 (events & PURPLE_POUNCE_AWAY) ? |
15817 | 811 _("%s has gone away. (%s)") : |
15822 | 812 (events & PURPLE_POUNCE_MESSAGE_RECEIVED) ? |
15817 | 813 _("%s has sent you a message. (%s)") : |
814 _("Unknown pounce event. Please report this!"), | |
15822 | 815 alias, purple_account_get_protocol_name(account)); |
15817 | 816 |
817 /* | |
818 * Ok here is where I change the second argument, title, from | |
819 * NULL to the account alias if we have it or the account | |
820 * name if that's all we have | |
821 */ | |
15822 | 822 if ((name_shown = purple_account_get_alias(account)) == NULL) |
823 name_shown = purple_account_get_username(account); | |
15817 | 824 |
825 if (reason == NULL) | |
826 { | |
15822 | 827 purple_notify_info(NULL, name_shown, tmp, purple_date_format_full(NULL)); |
15817 | 828 } |
829 else | |
830 { | |
15822 | 831 char *tmp2 = g_strdup_printf("%s\n\n%s", reason, purple_date_format_full(NULL)); |
832 purple_notify_info(NULL, name_shown, tmp, tmp2); | |
15817 | 833 g_free(tmp2); |
834 } | |
835 g_free(tmp); | |
836 } | |
837 | |
15822 | 838 if (purple_pounce_action_is_enabled(pounce, "send-message")) |
15817 | 839 { |
840 const char *message; | |
841 | |
15822 | 842 message = purple_pounce_action_get_attribute(pounce, "send-message", |
15817 | 843 "message"); |
844 | |
845 if (message != NULL) | |
846 { | |
15822 | 847 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, pouncee, account); |
15817 | 848 |
849 if (conv == NULL) | |
15822 | 850 conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, pouncee); |
15817 | 851 |
15822 | 852 purple_conversation_write(conv, NULL, message, |
853 PURPLE_MESSAGE_SEND, time(NULL)); | |
15817 | 854 |
855 serv_send_im(account->gc, (char *)pouncee, (char *)message, 0); | |
856 } | |
857 } | |
858 | |
15822 | 859 if (purple_pounce_action_is_enabled(pounce, "execute-command")) |
15817 | 860 { |
861 const char *command; | |
862 | |
15822 | 863 command = purple_pounce_action_get_attribute(pounce, |
15817 | 864 "execute-command", "command"); |
865 | |
866 if (command != NULL) | |
867 { | |
868 char *localecmd = g_locale_from_utf8(command, -1, NULL, | |
869 NULL, NULL); | |
870 | |
871 if (localecmd != NULL) | |
872 { | |
873 int pid = fork(); | |
874 | |
875 if (pid == 0) { | |
876 char *args[4]; | |
877 | |
878 args[0] = "sh"; | |
879 args[1] = "-c"; | |
880 args[2] = (char *)localecmd; | |
881 args[3] = NULL; | |
882 | |
883 execvp(args[0], args); | |
884 | |
885 _exit(0); | |
886 } | |
887 g_free(localecmd); | |
888 } | |
889 } | |
890 } | |
891 | |
15822 | 892 if (purple_pounce_action_is_enabled(pounce, "play-beep")) |
15817 | 893 { |
894 beep(); | |
895 } | |
896 } | |
897 | |
898 static void | |
15822 | 899 free_pounce(PurplePounce *pounce) |
15817 | 900 { |
901 update_pounces(); | |
902 } | |
903 | |
904 static void | |
15822 | 905 new_pounce(PurplePounce *pounce) |
15817 | 906 { |
15822 | 907 purple_pounce_action_register(pounce, "open-window"); |
908 purple_pounce_action_register(pounce, "popup-notify"); | |
909 purple_pounce_action_register(pounce, "send-message"); | |
910 purple_pounce_action_register(pounce, "execute-command"); | |
911 purple_pounce_action_register(pounce, "play-beep"); | |
15817 | 912 |
913 update_pounces(); | |
914 } | |
915 | |
916 void * | |
917 finch_pounces_get_handle() | |
918 { | |
919 static int handle; | |
920 | |
921 return &handle; | |
922 } | |
923 | |
924 void | |
925 finch_pounces_init(void) | |
926 { | |
15822 | 927 purple_pounces_register_handler(FINCH_UI, pounce_cb, new_pounce, |
15817 | 928 free_pounce); |
929 | |
16424
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16287
diff
changeset
|
930 purple_prefs_add_none("/finch/pounces"); |
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16287
diff
changeset
|
931 purple_prefs_add_none("/finch/pounces/default_actions"); |
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16287
diff
changeset
|
932 purple_prefs_add_bool("/finch/pounces/default_actions/open-window", |
15817 | 933 FALSE); |
16424
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16287
diff
changeset
|
934 purple_prefs_add_bool("/finch/pounces/default_actions/popup-notify", |
15817 | 935 TRUE); |
16424
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16287
diff
changeset
|
936 purple_prefs_add_bool("/finch/pounces/default_actions/send-message", |
15817 | 937 FALSE); |
16424
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16287
diff
changeset
|
938 purple_prefs_add_bool("/finch/pounces/default_actions/execute-command", |
15817 | 939 FALSE); |
16424
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16287
diff
changeset
|
940 purple_prefs_add_bool("/finch/pounces/default_actions/play-beep", |
15817 | 941 FALSE); |
16424
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16287
diff
changeset
|
942 purple_prefs_add_none("/finch/pounces/dialog"); |
15817 | 943 |
15822 | 944 purple_signal_connect(purple_connections_get_handle(), "signed-on", |
15817 | 945 finch_pounces_get_handle(), |
15822 | 946 PURPLE_CALLBACK(signed_on_off_cb), NULL); |
947 purple_signal_connect(purple_connections_get_handle(), "signed-off", | |
15817 | 948 finch_pounces_get_handle(), |
15822 | 949 PURPLE_CALLBACK(signed_on_off_cb), NULL); |
15817 | 950 } |
951 | |
952 /* XXX: There's no such thing in pidgin. Perhaps there should be? */ | |
953 void finch_pounces_uninit() | |
954 { | |
15822 | 955 purple_pounces_register_handler(FINCH_UI, NULL, NULL, NULL); |
15817 | 956 |
15822 | 957 purple_signals_disconnect_by_handle(finch_pounces_get_handle()); |
15817 | 958 } |
959 |