Mercurial > pidgin
annotate finch/gntpounce.c @ 27491:a350c546f5a5
merge of '08cad9bb29fe8faaea25ef487d9d70c2f66fd6b5'
and 'cd91a95e17c080b804ab56a9024840a03432cb7e'
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Mon, 13 Jul 2009 05:28:25 +0000 |
parents | 1c73d2ef9ddc |
children | f7c5bb2f6623 |
rev | line source |
---|---|
15817 | 1 /** |
2 * @file gntpounce.c GNT Buddy Pounce API | |
16194
0f0832c13fcb
Rename the Doxygen group from gntui to finch and define the finch group
Richard Laager <rlaager@wiktel.com>
parents:
15870
diff
changeset
|
3 * @ingroup finch |
20074
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19681
diff
changeset
|
4 */ |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19681
diff
changeset
|
5 |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19681
diff
changeset
|
6 /* finch |
15817 | 7 * |
15870
66dff3dfdea6
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
8 * Finch is the legal property of its developers, whose names are too numerous |
15817 | 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 | |
19681
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 |
15817 | 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 |
15822 | 38 #include "finch.h" |
15817 | 39 |
26347
1c73d2ef9ddc
Remove some extra edits that snuck into Finch.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24943
diff
changeset
|
40 #include "account.h" |
1c73d2ef9ddc
Remove some extra edits that snuck into Finch.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24943
diff
changeset
|
41 #include "conversation.h" |
1c73d2ef9ddc
Remove some extra edits that snuck into Finch.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24943
diff
changeset
|
42 #include "debug.h" |
1c73d2ef9ddc
Remove some extra edits that snuck into Finch.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24943
diff
changeset
|
43 #include "notify.h" |
1c73d2ef9ddc
Remove some extra edits that snuck into Finch.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24943
diff
changeset
|
44 #include "prpl.h" |
1c73d2ef9ddc
Remove some extra edits that snuck into Finch.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24943
diff
changeset
|
45 #include "request.h" |
1c73d2ef9ddc
Remove some extra edits that snuck into Finch.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24943
diff
changeset
|
46 #include "server.h" |
1c73d2ef9ddc
Remove some extra edits that snuck into Finch.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24943
diff
changeset
|
47 #include "util.h" |
1c73d2ef9ddc
Remove some extra edits that snuck into Finch.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24943
diff
changeset
|
48 |
15817 | 49 #include "gntpounce.h" |
50 | |
51 | |
52 typedef struct | |
53 { | |
54 /* Pounce data */ | |
15822 | 55 PurplePounce *pounce; |
56 PurpleAccount *account; | |
15817 | 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 | |
15822 | 95 } PurpleGntPounceDialog; |
15817 | 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 | |
15822 | 111 delete_win_cb(GntWidget *w, PurpleGntPounceDialog *dialog) |
15817 | 112 { |
113 gnt_widget_destroy(dialog->window); | |
114 g_free(dialog); | |
115 | |
116 return TRUE; | |
117 } | |
118 | |
119 static void | |
15822 | 120 cancel_cb(GntWidget *w, PurpleGntPounceDialog *dialog) |
15817 | 121 { |
122 gnt_widget_destroy(dialog->window); | |
123 } | |
124 | |
125 static void | |
15822 | 126 add_pounce_to_treeview(GntTree *tree, PurplePounce *pounce) |
15817 | 127 { |
15822 | 128 PurpleAccount *account; |
15817 | 129 const char *pouncer; |
130 const char *pouncee; | |
131 | |
15822 | 132 account = purple_pounce_get_pouncer(pounce); |
133 pouncer = purple_account_get_username(account); | |
134 pouncee = purple_pounce_get_pouncee(pounce); | |
15817 | 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; |
15817 | 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)) |
15817 | 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 | |
15822 | 164 signed_on_off_cb(PurpleConnection *gc, gpointer user_data) |
15817 | 165 { |
166 update_pounces(); | |
167 } | |
168 | |
169 static void | |
21279
47118f6062e9
Enable auto-complete in the pounce dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21244
diff
changeset
|
170 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
|
171 { |
47118f6062e9
Enable auto-complete in the pounce dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21244
diff
changeset
|
172 PurpleBlistNode *node = purple_blist_get_root(); |
47118f6062e9
Enable auto-complete in the pounce dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21244
diff
changeset
|
173 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
|
174 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
|
175 continue; |
47118f6062e9
Enable auto-complete in the pounce dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21244
diff
changeset
|
176 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
|
177 } |
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 static void |
15822 | 181 save_pounce_cb(GntWidget *w, PurpleGntPounceDialog *dialog) |
15817 | 182 { |
183 const char *name; | |
184 const char *message, *command, *reason; | |
15822 | 185 PurplePounceEvent events = PURPLE_POUNCE_NONE; |
186 PurplePounceOption options = PURPLE_POUNCE_OPTION_NONE; | |
15817 | 187 |
188 name = gnt_entry_get_text(GNT_ENTRY(dialog->buddy_entry)); | |
189 | |
190 if (*name == '\0') | |
191 { | |
15822 | 192 purple_notify_error(NULL, NULL, |
15817 | 193 _("Please enter a buddy to pounce."), NULL); |
194 return; | |
195 } | |
196 | |
197 /* Options */ | |
198 if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->on_away))) | |
15822 | 199 options |= PURPLE_POUNCE_OPTION_AWAY; |
15817 | 200 |
201 /* Events */ | |
202 if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->signon))) | |
15822 | 203 events |= PURPLE_POUNCE_SIGNON; |
15817 | 204 |
205 if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->signoff))) | |
15822 | 206 events |= PURPLE_POUNCE_SIGNOFF; |
15817 | 207 |
208 if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->away))) | |
15822 | 209 events |= PURPLE_POUNCE_AWAY; |
15817 | 210 |
211 if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->away_return))) | |
15822 | 212 events |= PURPLE_POUNCE_AWAY_RETURN; |
15817 | 213 |
214 if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->idle))) | |
15822 | 215 events |= PURPLE_POUNCE_IDLE; |
15817 | 216 |
217 if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->idle_return))) | |
15822 | 218 events |= PURPLE_POUNCE_IDLE_RETURN; |
15817 | 219 |
220 if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->typing))) | |
15822 | 221 events |= PURPLE_POUNCE_TYPING; |
15817 | 222 |
223 if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->typed))) | |
15822 | 224 events |= PURPLE_POUNCE_TYPED; |
15817 | 225 |
226 if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->stop_typing))) | |
15822 | 227 events |= PURPLE_POUNCE_TYPING_STOPPED; |
15817 | 228 |
229 if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->message_recv))) | |
15822 | 230 events |= PURPLE_POUNCE_MESSAGE_RECEIVED; |
15817 | 231 |
232 /* Data fields */ | |
233 message = gnt_entry_get_text(GNT_ENTRY(dialog->send_msg_entry)); | |
234 command = gnt_entry_get_text(GNT_ENTRY(dialog->exec_cmd_entry)); | |
235 reason = gnt_entry_get_text(GNT_ENTRY(dialog->popup_entry)); | |
236 | |
237 if (*reason == '\0') reason = NULL; | |
238 if (*message == '\0') message = NULL; | |
239 if (*command == '\0') command = NULL; | |
240 | |
241 if (dialog->pounce == NULL) { | |
15822 | 242 dialog->pounce = purple_pounce_new(FINCH_UI, dialog->account, |
15817 | 243 name, events, options); |
244 } else { | |
15822 | 245 purple_pounce_set_events(dialog->pounce, events); |
246 purple_pounce_set_options(dialog->pounce, options); | |
247 purple_pounce_set_pouncer(dialog->pounce, dialog->account); | |
248 purple_pounce_set_pouncee(dialog->pounce, name); | |
15817 | 249 } |
250 | |
251 /* Actions */ | |
15822 | 252 purple_pounce_action_set_enabled(dialog->pounce, "open-window", |
15817 | 253 gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->open_win))); |
15822 | 254 purple_pounce_action_set_enabled(dialog->pounce, "popup-notify", |
15817 | 255 gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->popup))); |
15822 | 256 purple_pounce_action_set_enabled(dialog->pounce, "send-message", |
15817 | 257 gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->send_msg))); |
15822 | 258 purple_pounce_action_set_enabled(dialog->pounce, "execute-command", |
15817 | 259 gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->exec_cmd))); |
15822 | 260 purple_pounce_action_set_enabled(dialog->pounce, "play-beep", |
15817 | 261 gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->play_sound))); |
262 | |
15822 | 263 purple_pounce_action_set_attribute(dialog->pounce, "send-message", |
15817 | 264 "message", message); |
15822 | 265 purple_pounce_action_set_attribute(dialog->pounce, "execute-command", |
15817 | 266 "command", command); |
15822 | 267 purple_pounce_action_set_attribute(dialog->pounce, "popup-notify", |
15817 | 268 "reason", reason); |
269 | |
270 /* Set the defaults for next time. */ | |
16424
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16287
diff
changeset
|
271 purple_prefs_set_bool("/finch/pounces/default_actions/open-window", |
15817 | 272 gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->open_win))); |
16424
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16287
diff
changeset
|
273 purple_prefs_set_bool("/finch/pounces/default_actions/popup-notify", |
15817 | 274 gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->popup))); |
16424
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16287
diff
changeset
|
275 purple_prefs_set_bool("/finch/pounces/default_actions/send-message", |
15817 | 276 gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->send_msg))); |
16424
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16287
diff
changeset
|
277 purple_prefs_set_bool("/finch/pounces/default_actions/execute-command", |
15817 | 278 gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->exec_cmd))); |
16424
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16287
diff
changeset
|
279 purple_prefs_set_bool("/finch/pounces/default_actions/play-beep", |
15817 | 280 gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->play_sound))); |
281 | |
15822 | 282 purple_pounce_set_save(dialog->pounce, |
15817 | 283 gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->save_pounce))); |
284 | |
15822 | 285 purple_pounce_set_pouncer(dialog->pounce, |
286 (PurpleAccount *)gnt_combo_box_get_selected_data(GNT_COMBO_BOX(dialog->account_menu))); | |
15817 | 287 |
288 update_pounces(); | |
289 | |
290 gnt_widget_destroy(dialog->window); | |
291 } | |
292 | |
293 | |
294 void | |
15822 | 295 finch_pounce_editor_show(PurpleAccount *account, const char *name, |
296 PurplePounce *cur_pounce) | |
15817 | 297 { |
15822 | 298 PurpleGntPounceDialog *dialog; |
15817 | 299 GntWidget *window; |
300 GntWidget *bbox; | |
16287
776bf7979b4f
Line up the event-checkboxes in the pounce dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
301 GntWidget *hbox, *vbox; |
15817 | 302 GntWidget *button; |
303 GntWidget *combo; | |
18063
926ccb104da0
disapproval of revision '1411afd7660760db59966c3a9f18e2adab8eb27e'
Richard Laager <rlaager@wiktel.com>
parents:
18058
diff
changeset
|
304 GList *list; |
15817 | 305 |
306 g_return_if_fail((cur_pounce != NULL) || | |
307 (account != NULL) || | |
15822 | 308 (purple_accounts_get_all() != NULL)); |
15817 | 309 |
15822 | 310 dialog = g_new0(PurpleGntPounceDialog, 1); |
15817 | 311 |
312 if (cur_pounce != NULL) { | |
313 dialog->pounce = cur_pounce; | |
15822 | 314 dialog->account = purple_pounce_get_pouncer(cur_pounce); |
15817 | 315 } else if (account != NULL) { |
316 dialog->pounce = NULL; | |
317 dialog->account = account; | |
318 } else { | |
18063
926ccb104da0
disapproval of revision '1411afd7660760db59966c3a9f18e2adab8eb27e'
Richard Laager <rlaager@wiktel.com>
parents:
18058
diff
changeset
|
319 GList *connections = purple_connections_get_all(); |
15822 | 320 PurpleConnection *gc; |
15817 | 321 |
322 if (connections != NULL) { | |
15822 | 323 gc = (PurpleConnection *)connections->data; |
324 dialog->account = purple_connection_get_account(gc); | |
15817 | 325 } else |
15822 | 326 dialog->account = purple_accounts_get_all()->data; |
15817 | 327 |
328 dialog->pounce = NULL; | |
329 } | |
330 | |
331 /* Create the window. */ | |
332 dialog->window = window = gnt_vbox_new(FALSE); | |
333 gnt_box_set_pad(GNT_BOX(window), 0); | |
334 gnt_box_set_toplevel(GNT_BOX(window), TRUE); | |
335 gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_LEFT); | |
336 gnt_box_set_title(GNT_BOX(window), | |
337 (cur_pounce == NULL | |
338 ? _("New Buddy Pounce") : _("Edit Buddy Pounce"))); | |
339 | |
340 g_signal_connect(G_OBJECT(window), "destroy", | |
341 G_CALLBACK(delete_win_cb), dialog); | |
342 | |
343 gnt_box_add_widget(GNT_BOX(window), gnt_label_new_with_format(_("Pounce Who"), GNT_TEXT_FLAG_BOLD)); | |
344 | |
345 /* Account: */ | |
346 gnt_box_add_widget(GNT_BOX(window), gnt_label_new(_("Account:"))); | |
347 dialog->account_menu = combo = gnt_combo_box_new(); | |
15822 | 348 list = purple_accounts_get_all(); |
15817 | 349 for (; list; list = list->next) |
350 { | |
15822 | 351 PurpleAccount *account; |
15817 | 352 char *text; |
353 | |
354 account = list->data; | |
355 text = g_strdup_printf("%s (%s)", | |
15822 | 356 purple_account_get_username(account), |
357 purple_account_get_protocol_name(account)); | |
15817 | 358 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), account, text); |
359 g_free(text); | |
360 } | |
361 if (dialog->account) | |
362 gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), dialog->account); | |
363 | |
364 gnt_box_add_widget(GNT_BOX(window), combo); | |
365 | |
366 /* Buddy: */ | |
367 hbox = gnt_hbox_new(FALSE); | |
368 gnt_box_add_widget(GNT_BOX(hbox), gnt_label_new(_("Buddy name:"))); | |
369 | |
370 dialog->buddy_entry = gnt_entry_new(NULL); | |
371 gnt_box_add_widget(GNT_BOX(hbox), dialog->buddy_entry); | |
372 | |
21279
47118f6062e9
Enable auto-complete in the pounce dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21244
diff
changeset
|
373 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
|
374 |
15817 | 375 gnt_box_add_widget(GNT_BOX(window), hbox); |
376 | |
377 if (cur_pounce != NULL) { | |
378 gnt_entry_set_text(GNT_ENTRY(dialog->buddy_entry), | |
15822 | 379 purple_pounce_get_pouncee(cur_pounce)); |
15817 | 380 } else if (name != NULL) { |
381 gnt_entry_set_text(GNT_ENTRY(dialog->buddy_entry), name); | |
382 } | |
383 | |
16287
776bf7979b4f
Line up the event-checkboxes in the pounce dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
384 /* Create the event frame */ |
15817 | 385 gnt_box_add_widget(GNT_BOX(window), gnt_line_new(FALSE)); |
386 gnt_box_add_widget(GNT_BOX(window), gnt_label_new_with_format(_("Pounce When Buddy..."), GNT_TEXT_FLAG_BOLD)); | |
387 | |
388 dialog->signon = gnt_check_box_new(_("Signs on")); | |
389 dialog->signoff = gnt_check_box_new(_("Signs off")); | |
390 dialog->away = gnt_check_box_new(_("Goes away")); | |
391 dialog->away_return = gnt_check_box_new(_("Returns from away")); | |
392 dialog->idle = gnt_check_box_new(_("Becomes idle")); | |
393 dialog->idle_return = gnt_check_box_new(_("Is no longer idle")); | |
394 dialog->typing = gnt_check_box_new(_("Starts typing")); | |
395 dialog->typed = gnt_check_box_new(_("Pauses while typing")); | |
396 dialog->stop_typing = gnt_check_box_new(_("Stops typing")); | |
397 dialog->message_recv = gnt_check_box_new(_("Sends a message")); | |
398 | |
16287
776bf7979b4f
Line up the event-checkboxes in the pounce dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
399 hbox = gnt_hbox_new(TRUE); |
15817 | 400 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
|
401 |
776bf7979b4f
Line up the event-checkboxes in the pounce dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
402 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
|
403 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
|
404 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
|
405 |
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->signon); |
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->away); |
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->idle); |
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->typing); |
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->stop_typing); |
776bf7979b4f
Line up the event-checkboxes in the pounce dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
411 |
776bf7979b4f
Line up the event-checkboxes in the pounce dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
412 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
|
413 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
|
414 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
|
415 |
776bf7979b4f
Line up the event-checkboxes in the pounce dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
416 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
|
417 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
|
418 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
|
419 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
|
420 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
|
421 |
15817 | 422 gnt_box_add_widget(GNT_BOX(window), hbox); |
423 | |
424 /* Create the "Action" frame. */ | |
425 gnt_box_add_widget(GNT_BOX(window), gnt_line_new(FALSE)); | |
426 gnt_box_add_widget(GNT_BOX(window), gnt_label_new_with_format(_("Action"), GNT_TEXT_FLAG_BOLD)); | |
427 | |
428 dialog->open_win = gnt_check_box_new(_("Open an IM window")); | |
429 dialog->popup = gnt_check_box_new(_("Pop up a notification")); | |
430 dialog->send_msg = gnt_check_box_new(_("Send a message")); | |
431 dialog->exec_cmd = gnt_check_box_new(_("Execute a command")); | |
432 dialog->play_sound = gnt_check_box_new(_("Play a sound")); | |
433 | |
434 dialog->send_msg_entry = gnt_entry_new(NULL); | |
435 dialog->exec_cmd_entry = gnt_entry_new(NULL); | |
436 dialog->popup_entry = gnt_entry_new(NULL); | |
437 dialog->exec_cmd_entry = gnt_entry_new(NULL); | |
438 | |
439 hbox = gnt_hbox_new(FALSE); | |
440 gnt_box_add_widget(GNT_BOX(hbox), dialog->open_win); | |
441 gnt_box_add_widget(GNT_BOX(window), hbox); | |
442 hbox = gnt_hbox_new(FALSE); | |
443 gnt_box_add_widget(GNT_BOX(hbox), dialog->popup); | |
444 gnt_box_add_widget(GNT_BOX(hbox), dialog->popup_entry); | |
445 gnt_box_add_widget(GNT_BOX(window), hbox); | |
446 hbox = gnt_hbox_new(FALSE); | |
447 gnt_box_add_widget(GNT_BOX(hbox), dialog->send_msg); | |
448 gnt_box_add_widget(GNT_BOX(hbox), dialog->send_msg_entry); | |
449 gnt_box_add_widget(GNT_BOX(window), hbox); | |
450 hbox = gnt_hbox_new(FALSE); | |
451 gnt_box_add_widget(GNT_BOX(hbox), dialog->exec_cmd); | |
452 gnt_box_add_widget(GNT_BOX(hbox), dialog->exec_cmd_entry); | |
453 gnt_box_add_widget(GNT_BOX(window), hbox); | |
454 hbox = gnt_hbox_new(FALSE); | |
455 gnt_box_add_widget(GNT_BOX(hbox), dialog->play_sound); | |
456 gnt_box_add_widget(GNT_BOX(window), hbox); | |
457 | |
458 gnt_box_add_widget(GNT_BOX(window), gnt_line_new(FALSE)); | |
459 gnt_box_add_widget(GNT_BOX(window), gnt_label_new_with_format(_("Options"), GNT_TEXT_FLAG_BOLD)); | |
22249 | 460 dialog->on_away = gnt_check_box_new(_("Pounce only when my status is not Available")); |
15817 | 461 gnt_box_add_widget(GNT_BOX(window), dialog->on_away); |
462 dialog->save_pounce = gnt_check_box_new(_("Recurring")); | |
463 gnt_box_add_widget(GNT_BOX(window), dialog->save_pounce); | |
464 | |
465 | |
466 gnt_box_add_widget(GNT_BOX(window), gnt_line_new(FALSE)); | |
467 /* 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
|
468 bbox = gnt_hbox_new(FALSE); |
15817 | 469 |
470 /* Cancel button */ | |
471 button = gnt_button_new(_("Cancel")); | |
472 gnt_box_add_widget(GNT_BOX(bbox), button); | |
473 g_signal_connect(G_OBJECT(button), "activate", | |
474 G_CALLBACK(cancel_cb), dialog); | |
475 | |
476 /* Save button */ | |
477 dialog->save_button = button = gnt_button_new(_("Save")); | |
478 gnt_box_add_widget(GNT_BOX(bbox), button); | |
479 g_signal_connect(G_OBJECT(button), "activate", | |
480 G_CALLBACK(save_pounce_cb), dialog); | |
481 | |
482 gnt_box_add_widget(GNT_BOX(window), bbox); | |
483 | |
484 | |
485 /* Set the values of stuff. */ | |
486 if (cur_pounce != NULL) | |
487 { | |
15822 | 488 PurplePounceEvent events = purple_pounce_get_events(cur_pounce); |
489 PurplePounceOption options = purple_pounce_get_options(cur_pounce); | |
15817 | 490 const char *value; |
491 | |
492 /* Options */ | |
493 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->on_away), | |
15822 | 494 (options & PURPLE_POUNCE_OPTION_AWAY)); |
15817 | 495 |
496 /* Events */ | |
497 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->signon), | |
15822 | 498 (events & PURPLE_POUNCE_SIGNON)); |
15817 | 499 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->signoff), |
15822 | 500 (events & PURPLE_POUNCE_SIGNOFF)); |
15817 | 501 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->away), |
15822 | 502 (events & PURPLE_POUNCE_AWAY)); |
15817 | 503 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->away_return), |
15822 | 504 (events & PURPLE_POUNCE_AWAY_RETURN)); |
15817 | 505 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->idle), |
15822 | 506 (events & PURPLE_POUNCE_IDLE)); |
15817 | 507 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->idle_return), |
15822 | 508 (events & PURPLE_POUNCE_IDLE_RETURN)); |
15817 | 509 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->typing), |
15822 | 510 (events & PURPLE_POUNCE_TYPING)); |
15817 | 511 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->typed), |
15822 | 512 (events & PURPLE_POUNCE_TYPED)); |
15817 | 513 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->stop_typing), |
15822 | 514 (events & PURPLE_POUNCE_TYPING_STOPPED)); |
15817 | 515 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->message_recv), |
15822 | 516 (events & PURPLE_POUNCE_MESSAGE_RECEIVED)); |
15817 | 517 |
518 /* Actions */ | |
519 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->open_win), | |
15822 | 520 purple_pounce_action_is_enabled(cur_pounce, "open-window")); |
15817 | 521 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->popup), |
15822 | 522 purple_pounce_action_is_enabled(cur_pounce, "popup-notify")); |
15817 | 523 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->send_msg), |
15822 | 524 purple_pounce_action_is_enabled(cur_pounce, "send-message")); |
15817 | 525 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->exec_cmd), |
15822 | 526 purple_pounce_action_is_enabled(cur_pounce, "execute-command")); |
15817 | 527 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->play_sound), |
15822 | 528 purple_pounce_action_is_enabled(cur_pounce, "play-beep")); |
15817 | 529 |
530 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->save_pounce), | |
15822 | 531 purple_pounce_get_save(cur_pounce)); |
15817 | 532 |
15822 | 533 if ((value = purple_pounce_action_get_attribute(cur_pounce, |
15817 | 534 "send-message", |
535 "message")) != NULL) | |
536 { | |
537 gnt_entry_set_text(GNT_ENTRY(dialog->send_msg_entry), value); | |
538 } | |
539 | |
15822 | 540 if ((value = purple_pounce_action_get_attribute(cur_pounce, |
15817 | 541 "popup-notify", |
542 "reason")) != NULL) | |
543 { | |
544 gnt_entry_set_text(GNT_ENTRY(dialog->popup_entry), value); | |
545 } | |
546 | |
15822 | 547 if ((value = purple_pounce_action_get_attribute(cur_pounce, |
15817 | 548 "execute-command", |
549 "command")) != NULL) | |
550 { | |
551 gnt_entry_set_text(GNT_ENTRY(dialog->exec_cmd_entry), value); | |
552 } | |
553 } | |
554 else | |
555 { | |
15822 | 556 PurpleBuddy *buddy = NULL; |
15817 | 557 |
558 if (name != NULL) | |
15822 | 559 buddy = purple_find_buddy(account, name); |
15817 | 560 |
561 /* Set some defaults */ | |
562 if (buddy == NULL) { | |
563 gnt_check_box_set_checked( | |
564 GNT_CHECK_BOX(dialog->signon), TRUE); | |
565 } else { | |
15822 | 566 if (!PURPLE_BUDDY_IS_ONLINE(buddy)) { |
15817 | 567 gnt_check_box_set_checked( |
568 GNT_CHECK_BOX(dialog->signon), TRUE); | |
569 } else { | |
570 gboolean default_set = FALSE; | |
15822 | 571 PurplePresence *presence = purple_buddy_get_presence(buddy); |
15817 | 572 |
15822 | 573 if (purple_presence_is_idle(presence)) |
15817 | 574 { |
575 gnt_check_box_set_checked( | |
576 GNT_CHECK_BOX(dialog->idle_return), TRUE); | |
577 | |
578 default_set = TRUE; | |
579 } | |
580 | |
15822 | 581 if (!purple_presence_is_available(presence)) |
15817 | 582 { |
583 gnt_check_box_set_checked( | |
584 GNT_CHECK_BOX(dialog->away_return), TRUE); | |
585 | |
586 default_set = TRUE; | |
587 } | |
588 | |
589 if (!default_set) | |
590 { | |
591 gnt_check_box_set_checked( | |
592 GNT_CHECK_BOX(dialog->signon), TRUE); | |
593 } | |
594 } | |
595 } | |
596 | |
597 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->open_win), | |
16424
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16287
diff
changeset
|
598 purple_prefs_get_bool("/finch/pounces/default_actions/open-window")); |
15817 | 599 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->popup), |
16424
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16287
diff
changeset
|
600 purple_prefs_get_bool("/finch/pounces/default_actions/popup-notify")); |
15817 | 601 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->send_msg), |
16424
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16287
diff
changeset
|
602 purple_prefs_get_bool("/finch/pounces/default_actions/send-message")); |
15817 | 603 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->exec_cmd), |
16424
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16287
diff
changeset
|
604 purple_prefs_get_bool("/finch/pounces/default_actions/execute-command")); |
15817 | 605 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->play_sound), |
16424
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16287
diff
changeset
|
606 purple_prefs_get_bool("/finch/pounces/default_actions/play-beep")); |
15817 | 607 } |
608 | |
609 gnt_widget_show(window); | |
610 } | |
611 | |
612 | |
613 | |
614 static gboolean | |
615 pounces_manager_destroy_cb(GntWidget *widget, gpointer user_data) | |
616 { | |
617 PouncesManager *dialog = user_data; | |
618 | |
619 dialog->window = NULL; | |
620 finch_pounces_manager_hide(); | |
621 | |
622 return FALSE; | |
623 } | |
624 | |
625 | |
626 static void | |
627 pounces_manager_add_cb(GntButton *button, gpointer user_data) | |
628 { | |
19374
d65ce3df5be2
Make some of the dialogs look and behave more like each other.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18511
diff
changeset
|
629 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
|
630 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
|
631 _("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
|
632 _("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
|
633 return; |
d65ce3df5be2
Make some of the dialogs look and behave more like each other.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18511
diff
changeset
|
634 } |
15817 | 635 finch_pounce_editor_show(NULL, NULL, NULL); |
636 } | |
637 | |
638 | |
639 static void | |
640 pounces_manager_modify_cb(GntButton *button, gpointer user_data) | |
641 { | |
642 PouncesManager *dialog = user_data; | |
15822 | 643 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
|
644 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
|
645 finch_pounce_editor_show(NULL, NULL, pounce); |
15817 | 646 } |
647 | |
648 static void | |
15822 | 649 pounces_manager_delete_confirm_cb(PurplePounce *pounce) |
15817 | 650 { |
651 gnt_tree_remove(GNT_TREE(pounces_manager->tree), pounce); | |
652 | |
15822 | 653 purple_request_close_with_handle(pounce); |
654 purple_pounce_destroy(pounce); | |
15817 | 655 } |
656 | |
657 | |
658 static void | |
659 pounces_manager_delete_cb(GntButton *button, gpointer user_data) | |
660 { | |
661 PouncesManager *dialog = user_data; | |
15822 | 662 PurplePounce *pounce; |
663 PurpleAccount *account; | |
15817 | 664 const char *pouncer, *pouncee; |
665 char *buf; | |
666 | |
15822 | 667 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
|
668 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
|
669 return; |
d65ce3df5be2
Make some of the dialogs look and behave more like each other.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18511
diff
changeset
|
670 |
15822 | 671 account = purple_pounce_get_pouncer(pounce); |
672 pouncer = purple_account_get_username(account); | |
673 pouncee = purple_pounce_get_pouncee(pounce); | |
15817 | 674 buf = g_strdup_printf(_("Are you sure you want to delete the pounce on %s for %s?"), pouncee, pouncer); |
16439
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16424
diff
changeset
|
675 purple_request_action(pounce, NULL, buf, NULL, 0, |
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16424
diff
changeset
|
676 account, pouncee, NULL, |
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16424
diff
changeset
|
677 pounce, 2, |
15817 | 678 _("Delete"), pounces_manager_delete_confirm_cb, |
679 _("Cancel"), NULL); | |
680 g_free(buf); | |
681 } | |
682 | |
683 static void | |
684 pounces_manager_close_cb(GntButton *button, gpointer user_data) | |
685 { | |
686 finch_pounces_manager_hide(); | |
687 } | |
688 | |
689 | |
690 void | |
691 finch_pounces_manager_show(void) | |
692 { | |
693 PouncesManager *dialog; | |
694 GntWidget *bbox; | |
695 GntWidget *button; | |
696 GntWidget *tree; | |
697 GntWidget *win; | |
698 | |
699 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
|
700 gnt_window_present(pounces_manager->window); |
15817 | 701 return; |
702 } | |
703 | |
704 pounces_manager = dialog = g_new0(PouncesManager, 1); | |
705 | |
706 dialog->window = win = gnt_vbox_new(FALSE); | |
707 gnt_box_set_toplevel(GNT_BOX(win), TRUE); | |
708 gnt_box_set_title(GNT_BOX(win), _("Buddy Pounces")); | |
709 gnt_box_set_pad(GNT_BOX(win), 0); | |
710 | |
711 g_signal_connect(G_OBJECT(win), "destroy", | |
712 G_CALLBACK(pounces_manager_destroy_cb), dialog); | |
713 | |
714 /* List of saved buddy pounces */ | |
715 dialog->tree = tree = GNT_WIDGET(gnt_tree_new_with_columns(2)); | |
716 gnt_tree_set_column_titles(GNT_TREE(tree), "Account", "Pouncee", NULL); | |
717 gnt_tree_set_show_title(GNT_TREE(tree), TRUE); | |
718 | |
719 gnt_box_add_widget(GNT_BOX(win), tree); | |
720 | |
721 /* 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
|
722 bbox = gnt_hbox_new(FALSE); |
15817 | 723 |
724 /* Add button */ | |
725 button = gnt_button_new(_("Add")); | |
726 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
|
727 gnt_util_set_trigger_widget(tree, GNT_KEY_INS, button); |
15817 | 728 |
729 g_signal_connect(G_OBJECT(button), "activate", | |
730 G_CALLBACK(pounces_manager_add_cb), dialog); | |
731 | |
732 /* Modify button */ | |
733 button = gnt_button_new(_("Modify")); | |
734 dialog->modify_button = button; | |
735 gnt_box_add_widget(GNT_BOX(bbox), button); | |
736 | |
737 g_signal_connect(G_OBJECT(button), "activate", | |
738 G_CALLBACK(pounces_manager_modify_cb), dialog); | |
739 | |
740 /* Delete button */ | |
741 button = gnt_button_new(_("Delete")); | |
742 dialog->delete_button = button; | |
743 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
|
744 gnt_util_set_trigger_widget(tree, GNT_KEY_DEL, button); |
15817 | 745 |
746 g_signal_connect(G_OBJECT(button), "activate", | |
747 G_CALLBACK(pounces_manager_delete_cb), dialog); | |
748 | |
749 /* Close button */ | |
750 button = gnt_button_new(_("Close")); | |
751 gnt_box_add_widget(GNT_BOX(bbox), button); | |
752 gnt_widget_show(button); | |
753 | |
754 g_signal_connect(G_OBJECT(button), "activate", | |
755 G_CALLBACK(pounces_manager_close_cb), dialog); | |
756 | |
757 gnt_box_add_widget(GNT_BOX(win), bbox); | |
758 | |
759 gnt_widget_show(win); | |
760 populate_pounces_list(pounces_manager); | |
761 } | |
762 | |
763 void | |
764 finch_pounces_manager_hide(void) | |
765 { | |
766 if (pounces_manager == NULL) | |
767 return; | |
768 | |
769 if (pounces_manager->window != NULL) | |
770 gnt_widget_destroy(pounces_manager->window); | |
771 | |
15822 | 772 purple_signals_disconnect_by_handle(pounces_manager); |
15817 | 773 |
774 g_free(pounces_manager); | |
775 pounces_manager = NULL; | |
776 } | |
777 | |
778 static void | |
15822 | 779 pounce_cb(PurplePounce *pounce, PurplePounceEvent events, void *data) |
15817 | 780 { |
15822 | 781 PurpleConversation *conv; |
782 PurpleAccount *account; | |
783 PurpleBuddy *buddy; | |
15817 | 784 const char *pouncee; |
785 const char *alias; | |
786 | |
15822 | 787 pouncee = purple_pounce_get_pouncee(pounce); |
788 account = purple_pounce_get_pouncer(pounce); | |
15817 | 789 |
15822 | 790 buddy = purple_find_buddy(account, pouncee); |
15817 | 791 if (buddy != NULL) |
792 { | |
15822 | 793 alias = purple_buddy_get_alias(buddy); |
15817 | 794 if (alias == NULL) |
795 alias = pouncee; | |
796 } | |
797 else | |
798 alias = pouncee; | |
799 | |
15822 | 800 if (purple_pounce_action_is_enabled(pounce, "open-window")) |
15817 | 801 { |
15822 | 802 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, pouncee, account); |
15817 | 803 |
804 if (conv == NULL) | |
15822 | 805 conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, pouncee); |
15817 | 806 } |
807 | |
15822 | 808 if (purple_pounce_action_is_enabled(pounce, "popup-notify")) |
15817 | 809 { |
22213
16ff37f64e29
Update finch to not touch the internals of PurpleAccount. This also includes a change I made to reduce the Cyclomatic Complexity of one of the functions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21560
diff
changeset
|
810 char *tmp = NULL; |
15817 | 811 const char *name_shown; |
812 const char *reason; | |
22213
16ff37f64e29
Update finch to not touch the internals of PurpleAccount. This also includes a change I made to reduce the Cyclomatic Complexity of one of the functions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21560
diff
changeset
|
813 struct { |
16ff37f64e29
Update finch to not touch the internals of PurpleAccount. This also includes a change I made to reduce the Cyclomatic Complexity of one of the functions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21560
diff
changeset
|
814 PurplePounceEvent event; |
16ff37f64e29
Update finch to not touch the internals of PurpleAccount. This also includes a change I made to reduce the Cyclomatic Complexity of one of the functions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21560
diff
changeset
|
815 const char *format; |
16ff37f64e29
Update finch to not touch the internals of PurpleAccount. This also includes a change I made to reduce the Cyclomatic Complexity of one of the functions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21560
diff
changeset
|
816 } messages[] = { |
16ff37f64e29
Update finch to not touch the internals of PurpleAccount. This also includes a change I made to reduce the Cyclomatic Complexity of one of the functions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21560
diff
changeset
|
817 {PURPLE_POUNCE_TYPING, _("%s has started typing to you (%s)")}, |
16ff37f64e29
Update finch to not touch the internals of PurpleAccount. This also includes a change I made to reduce the Cyclomatic Complexity of one of the functions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21560
diff
changeset
|
818 {PURPLE_POUNCE_TYPED, _("%s has paused while typing to you (%s)")}, |
16ff37f64e29
Update finch to not touch the internals of PurpleAccount. This also includes a change I made to reduce the Cyclomatic Complexity of one of the functions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21560
diff
changeset
|
819 {PURPLE_POUNCE_SIGNON, _("%s has signed on (%s)")}, |
16ff37f64e29
Update finch to not touch the internals of PurpleAccount. This also includes a change I made to reduce the Cyclomatic Complexity of one of the functions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21560
diff
changeset
|
820 {PURPLE_POUNCE_IDLE_RETURN, _("%s has returned from being idle (%s)")}, |
16ff37f64e29
Update finch to not touch the internals of PurpleAccount. This also includes a change I made to reduce the Cyclomatic Complexity of one of the functions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21560
diff
changeset
|
821 {PURPLE_POUNCE_AWAY_RETURN, _("%s has returned from being away (%s)")}, |
16ff37f64e29
Update finch to not touch the internals of PurpleAccount. This also includes a change I made to reduce the Cyclomatic Complexity of one of the functions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21560
diff
changeset
|
822 {PURPLE_POUNCE_TYPING_STOPPED, _("%s has stopped typing to you (%s)")}, |
16ff37f64e29
Update finch to not touch the internals of PurpleAccount. This also includes a change I made to reduce the Cyclomatic Complexity of one of the functions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21560
diff
changeset
|
823 {PURPLE_POUNCE_SIGNOFF, _("%s has signed off (%s)")}, |
16ff37f64e29
Update finch to not touch the internals of PurpleAccount. This also includes a change I made to reduce the Cyclomatic Complexity of one of the functions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21560
diff
changeset
|
824 {PURPLE_POUNCE_IDLE, _("%s has become idle (%s)")}, |
16ff37f64e29
Update finch to not touch the internals of PurpleAccount. This also includes a change I made to reduce the Cyclomatic Complexity of one of the functions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21560
diff
changeset
|
825 {PURPLE_POUNCE_AWAY, _("%s has gone away. (%s)")}, |
16ff37f64e29
Update finch to not touch the internals of PurpleAccount. This also includes a change I made to reduce the Cyclomatic Complexity of one of the functions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21560
diff
changeset
|
826 {PURPLE_POUNCE_MESSAGE_RECEIVED, _("%s has sent you a message. (%s)")}, |
16ff37f64e29
Update finch to not touch the internals of PurpleAccount. This also includes a change I made to reduce the Cyclomatic Complexity of one of the functions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21560
diff
changeset
|
827 {0, NULL} |
16ff37f64e29
Update finch to not touch the internals of PurpleAccount. This also includes a change I made to reduce the Cyclomatic Complexity of one of the functions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21560
diff
changeset
|
828 }; |
16ff37f64e29
Update finch to not touch the internals of PurpleAccount. This also includes a change I made to reduce the Cyclomatic Complexity of one of the functions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21560
diff
changeset
|
829 int i; |
15822 | 830 reason = purple_pounce_action_get_attribute(pounce, "popup-notify", |
22213
16ff37f64e29
Update finch to not touch the internals of PurpleAccount. This also includes a change I made to reduce the Cyclomatic Complexity of one of the functions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21560
diff
changeset
|
831 "reason"); |
15817 | 832 |
833 /* | |
834 * Here we place the protocol name in the pounce dialog to lessen | |
835 * confusion about what protocol a pounce is for. | |
836 */ | |
22213
16ff37f64e29
Update finch to not touch the internals of PurpleAccount. This also includes a change I made to reduce the Cyclomatic Complexity of one of the functions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21560
diff
changeset
|
837 for (i = 0; messages[i].format != NULL; i++) { |
16ff37f64e29
Update finch to not touch the internals of PurpleAccount. This also includes a change I made to reduce the Cyclomatic Complexity of one of the functions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21560
diff
changeset
|
838 if (messages[i].event & events) { |
16ff37f64e29
Update finch to not touch the internals of PurpleAccount. This also includes a change I made to reduce the Cyclomatic Complexity of one of the functions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21560
diff
changeset
|
839 tmp = g_strdup_printf(messages[i].format, alias, |
16ff37f64e29
Update finch to not touch the internals of PurpleAccount. This also includes a change I made to reduce the Cyclomatic Complexity of one of the functions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21560
diff
changeset
|
840 purple_account_get_protocol_name(account)); |
16ff37f64e29
Update finch to not touch the internals of PurpleAccount. This also includes a change I made to reduce the Cyclomatic Complexity of one of the functions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21560
diff
changeset
|
841 break; |
16ff37f64e29
Update finch to not touch the internals of PurpleAccount. This also includes a change I made to reduce the Cyclomatic Complexity of one of the functions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21560
diff
changeset
|
842 } |
16ff37f64e29
Update finch to not touch the internals of PurpleAccount. This also includes a change I made to reduce the Cyclomatic Complexity of one of the functions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21560
diff
changeset
|
843 } |
16ff37f64e29
Update finch to not touch the internals of PurpleAccount. This also includes a change I made to reduce the Cyclomatic Complexity of one of the functions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21560
diff
changeset
|
844 if (tmp == NULL) |
16ff37f64e29
Update finch to not touch the internals of PurpleAccount. This also includes a change I made to reduce the Cyclomatic Complexity of one of the functions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21560
diff
changeset
|
845 tmp = g_strdup(_("Unknown pounce event. Please report this!")); |
15817 | 846 |
847 /* | |
848 * Ok here is where I change the second argument, title, from | |
849 * NULL to the account alias if we have it or the account | |
850 * name if that's all we have | |
851 */ | |
15822 | 852 if ((name_shown = purple_account_get_alias(account)) == NULL) |
853 name_shown = purple_account_get_username(account); | |
15817 | 854 |
855 if (reason == NULL) | |
856 { | |
15822 | 857 purple_notify_info(NULL, name_shown, tmp, purple_date_format_full(NULL)); |
15817 | 858 } |
859 else | |
860 { | |
15822 | 861 char *tmp2 = g_strdup_printf("%s\n\n%s", reason, purple_date_format_full(NULL)); |
862 purple_notify_info(NULL, name_shown, tmp, tmp2); | |
15817 | 863 g_free(tmp2); |
864 } | |
865 g_free(tmp); | |
866 } | |
867 | |
15822 | 868 if (purple_pounce_action_is_enabled(pounce, "send-message")) |
15817 | 869 { |
870 const char *message; | |
871 | |
15822 | 872 message = purple_pounce_action_get_attribute(pounce, "send-message", |
15817 | 873 "message"); |
874 | |
875 if (message != NULL) | |
876 { | |
15822 | 877 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, pouncee, account); |
15817 | 878 |
879 if (conv == NULL) | |
15822 | 880 conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, pouncee); |
15817 | 881 |
15822 | 882 purple_conversation_write(conv, NULL, message, |
883 PURPLE_MESSAGE_SEND, time(NULL)); | |
15817 | 884 |
22213
16ff37f64e29
Update finch to not touch the internals of PurpleAccount. This also includes a change I made to reduce the Cyclomatic Complexity of one of the functions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21560
diff
changeset
|
885 serv_send_im(purple_account_get_connection(account), (char *)pouncee, (char *)message, 0); |
15817 | 886 } |
887 } | |
888 | |
15822 | 889 if (purple_pounce_action_is_enabled(pounce, "execute-command")) |
15817 | 890 { |
891 const char *command; | |
892 | |
15822 | 893 command = purple_pounce_action_get_attribute(pounce, |
15817 | 894 "execute-command", "command"); |
895 | |
896 if (command != NULL) | |
897 { | |
898 char *localecmd = g_locale_from_utf8(command, -1, NULL, | |
899 NULL, NULL); | |
900 | |
901 if (localecmd != NULL) | |
902 { | |
903 int pid = fork(); | |
904 | |
905 if (pid == 0) { | |
906 char *args[4]; | |
907 | |
908 args[0] = "sh"; | |
909 args[1] = "-c"; | |
910 args[2] = (char *)localecmd; | |
911 args[3] = NULL; | |
912 | |
913 execvp(args[0], args); | |
914 | |
915 _exit(0); | |
916 } | |
917 g_free(localecmd); | |
918 } | |
919 } | |
920 } | |
921 | |
15822 | 922 if (purple_pounce_action_is_enabled(pounce, "play-beep")) |
15817 | 923 { |
924 beep(); | |
925 } | |
926 } | |
927 | |
928 static void | |
15822 | 929 free_pounce(PurplePounce *pounce) |
15817 | 930 { |
931 update_pounces(); | |
932 } | |
933 | |
934 static void | |
15822 | 935 new_pounce(PurplePounce *pounce) |
15817 | 936 { |
15822 | 937 purple_pounce_action_register(pounce, "open-window"); |
938 purple_pounce_action_register(pounce, "popup-notify"); | |
939 purple_pounce_action_register(pounce, "send-message"); | |
940 purple_pounce_action_register(pounce, "execute-command"); | |
941 purple_pounce_action_register(pounce, "play-beep"); | |
15817 | 942 |
943 update_pounces(); | |
944 } | |
945 | |
946 void * | |
947 finch_pounces_get_handle() | |
948 { | |
949 static int handle; | |
950 | |
951 return &handle; | |
952 } | |
953 | |
954 void | |
955 finch_pounces_init(void) | |
956 { | |
15822 | 957 purple_pounces_register_handler(FINCH_UI, pounce_cb, new_pounce, |
15817 | 958 free_pounce); |
959 | |
16424
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16287
diff
changeset
|
960 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
|
961 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
|
962 purple_prefs_add_bool("/finch/pounces/default_actions/open-window", |
15817 | 963 FALSE); |
16424
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16287
diff
changeset
|
964 purple_prefs_add_bool("/finch/pounces/default_actions/popup-notify", |
15817 | 965 TRUE); |
16424
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16287
diff
changeset
|
966 purple_prefs_add_bool("/finch/pounces/default_actions/send-message", |
15817 | 967 FALSE); |
16424
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16287
diff
changeset
|
968 purple_prefs_add_bool("/finch/pounces/default_actions/execute-command", |
15817 | 969 FALSE); |
16424
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16287
diff
changeset
|
970 purple_prefs_add_bool("/finch/pounces/default_actions/play-beep", |
15817 | 971 FALSE); |
16424
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16287
diff
changeset
|
972 purple_prefs_add_none("/finch/pounces/dialog"); |
15817 | 973 |
15822 | 974 purple_signal_connect(purple_connections_get_handle(), "signed-on", |
15817 | 975 finch_pounces_get_handle(), |
15822 | 976 PURPLE_CALLBACK(signed_on_off_cb), NULL); |
977 purple_signal_connect(purple_connections_get_handle(), "signed-off", | |
15817 | 978 finch_pounces_get_handle(), |
15822 | 979 PURPLE_CALLBACK(signed_on_off_cb), NULL); |
15817 | 980 } |
981 | |
982 /* XXX: There's no such thing in pidgin. Perhaps there should be? */ | |
983 void finch_pounces_uninit() | |
984 { | |
24078
4ada5e2189d6
Use the more appropriate _unregister_handler function.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22249
diff
changeset
|
985 purple_pounces_unregister_handler(FINCH_UI); |
15817 | 986 |
15822 | 987 purple_signals_disconnect_by_handle(finch_pounces_get_handle()); |
15817 | 988 } |
989 |