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