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