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