Mercurial > pidgin
annotate finch/gntpounce.c @ 31518:76595d4edf86
Add a couple items to the !ChangeLog. Refs #12891.
author | John Bailey <rekkanoryo@rekkanoryo.org> |
---|---|
date | Mon, 02 May 2011 03:27:29 +0000 |
parents | 259bbfb423d4 |
children |
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 */ | |
28770
259bbfb423d4
Fix all the remaining files for which internal.h doesn't end up being the first include.
Paul Aurich <paul@darkrain42.org>
parents:
27587
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:
27587
diff
changeset
|
28 |
15817 | 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 |
15822 | 40 #include "finch.h" |
15817 | 41 |
26347
1c73d2ef9ddc
Remove some extra edits that snuck into Finch.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24943
diff
changeset
|
42 #include "account.h" |
1c73d2ef9ddc
Remove some extra edits that snuck into Finch.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24943
diff
changeset
|
43 #include "conversation.h" |
1c73d2ef9ddc
Remove some extra edits that snuck into Finch.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24943
diff
changeset
|
44 #include "debug.h" |
1c73d2ef9ddc
Remove some extra edits that snuck into Finch.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24943
diff
changeset
|
45 #include "notify.h" |
1c73d2ef9ddc
Remove some extra edits that snuck into Finch.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24943
diff
changeset
|
46 #include "prpl.h" |
1c73d2ef9ddc
Remove some extra edits that snuck into Finch.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24943
diff
changeset
|
47 #include "request.h" |
1c73d2ef9ddc
Remove some extra edits that snuck into Finch.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24943
diff
changeset
|
48 #include "server.h" |
1c73d2ef9ddc
Remove some extra edits that snuck into Finch.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24943
diff
changeset
|
49 #include "util.h" |
1c73d2ef9ddc
Remove some extra edits that snuck into Finch.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24943
diff
changeset
|
50 |
15817 | 51 #include "gntpounce.h" |
52 | |
53 | |
54 typedef struct | |
55 { | |
56 /* Pounce data */ | |
15822 | 57 PurplePounce *pounce; |
58 PurpleAccount *account; | |
15817 | 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 | |
15822 | 97 } PurpleGntPounceDialog; |
15817 | 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 | |
15822 | 113 delete_win_cb(GntWidget *w, PurpleGntPounceDialog *dialog) |
15817 | 114 { |
115 gnt_widget_destroy(dialog->window); | |
116 g_free(dialog); | |
117 | |
118 return TRUE; | |
119 } | |
120 | |
121 static void | |
15822 | 122 cancel_cb(GntWidget *w, PurpleGntPounceDialog *dialog) |
15817 | 123 { |
124 gnt_widget_destroy(dialog->window); | |
125 } | |
126 | |
127 static void | |
15822 | 128 add_pounce_to_treeview(GntTree *tree, PurplePounce *pounce) |
15817 | 129 { |
15822 | 130 PurpleAccount *account; |
15817 | 131 const char *pouncer; |
132 const char *pouncee; | |
133 | |
15822 | 134 account = purple_pounce_get_pouncer(pounce); |
135 pouncer = purple_account_get_username(account); | |
136 pouncee = purple_pounce_get_pouncee(pounce); | |
15817 | 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; |
15817 | 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)) |
15817 | 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 | |
15822 | 166 signed_on_off_cb(PurpleConnection *gc, gpointer user_data) |
15817 | 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 |
15822 | 183 save_pounce_cb(GntWidget *w, PurpleGntPounceDialog *dialog) |
15817 | 184 { |
185 const char *name; | |
186 const char *message, *command, *reason; | |
15822 | 187 PurplePounceEvent events = PURPLE_POUNCE_NONE; |
188 PurplePounceOption options = PURPLE_POUNCE_OPTION_NONE; | |
15817 | 189 |
190 name = gnt_entry_get_text(GNT_ENTRY(dialog->buddy_entry)); | |
191 | |
192 if (*name == '\0') | |
193 { | |
15822 | 194 purple_notify_error(NULL, NULL, |
15817 | 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))) | |
15822 | 201 options |= PURPLE_POUNCE_OPTION_AWAY; |
15817 | 202 |
203 /* Events */ | |
204 if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->signon))) | |
15822 | 205 events |= PURPLE_POUNCE_SIGNON; |
15817 | 206 |
207 if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->signoff))) | |
15822 | 208 events |= PURPLE_POUNCE_SIGNOFF; |
15817 | 209 |
210 if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->away))) | |
15822 | 211 events |= PURPLE_POUNCE_AWAY; |
15817 | 212 |
213 if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->away_return))) | |
15822 | 214 events |= PURPLE_POUNCE_AWAY_RETURN; |
15817 | 215 |
216 if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->idle))) | |
15822 | 217 events |= PURPLE_POUNCE_IDLE; |
15817 | 218 |
219 if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->idle_return))) | |
15822 | 220 events |= PURPLE_POUNCE_IDLE_RETURN; |
15817 | 221 |
222 if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->typing))) | |
15822 | 223 events |= PURPLE_POUNCE_TYPING; |
15817 | 224 |
225 if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->typed))) | |
15822 | 226 events |= PURPLE_POUNCE_TYPED; |
15817 | 227 |
228 if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->stop_typing))) | |
15822 | 229 events |= PURPLE_POUNCE_TYPING_STOPPED; |
15817 | 230 |
231 if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->message_recv))) | |
15822 | 232 events |= PURPLE_POUNCE_MESSAGE_RECEIVED; |
15817 | 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) { | |
15822 | 244 dialog->pounce = purple_pounce_new(FINCH_UI, dialog->account, |
15817 | 245 name, events, options); |
246 } else { | |
15822 | 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); | |
15817 | 251 } |
252 | |
253 /* Actions */ | |
15822 | 254 purple_pounce_action_set_enabled(dialog->pounce, "open-window", |
15817 | 255 gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->open_win))); |
15822 | 256 purple_pounce_action_set_enabled(dialog->pounce, "popup-notify", |
15817 | 257 gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->popup))); |
15822 | 258 purple_pounce_action_set_enabled(dialog->pounce, "send-message", |
15817 | 259 gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->send_msg))); |
15822 | 260 purple_pounce_action_set_enabled(dialog->pounce, "execute-command", |
15817 | 261 gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->exec_cmd))); |
15822 | 262 purple_pounce_action_set_enabled(dialog->pounce, "play-beep", |
15817 | 263 gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->play_sound))); |
264 | |
15822 | 265 purple_pounce_action_set_attribute(dialog->pounce, "send-message", |
15817 | 266 "message", message); |
15822 | 267 purple_pounce_action_set_attribute(dialog->pounce, "execute-command", |
15817 | 268 "command", command); |
15822 | 269 purple_pounce_action_set_attribute(dialog->pounce, "popup-notify", |
15817 | 270 "reason", reason); |
271 | |
272 /* 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
|
273 purple_prefs_set_bool("/finch/pounces/default_actions/open-window", |
15817 | 274 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
|
275 purple_prefs_set_bool("/finch/pounces/default_actions/popup-notify", |
15817 | 276 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
|
277 purple_prefs_set_bool("/finch/pounces/default_actions/send-message", |
15817 | 278 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
|
279 purple_prefs_set_bool("/finch/pounces/default_actions/execute-command", |
15817 | 280 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
|
281 purple_prefs_set_bool("/finch/pounces/default_actions/play-beep", |
15817 | 282 gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->play_sound))); |
283 | |
15822 | 284 purple_pounce_set_save(dialog->pounce, |
15817 | 285 gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->save_pounce))); |
286 | |
15822 | 287 purple_pounce_set_pouncer(dialog->pounce, |
288 (PurpleAccount *)gnt_combo_box_get_selected_data(GNT_COMBO_BOX(dialog->account_menu))); | |
15817 | 289 |
290 update_pounces(); | |
291 | |
292 gnt_widget_destroy(dialog->window); | |
293 } | |
294 | |
295 | |
296 void | |
15822 | 297 finch_pounce_editor_show(PurpleAccount *account, const char *name, |
298 PurplePounce *cur_pounce) | |
15817 | 299 { |
15822 | 300 PurpleGntPounceDialog *dialog; |
15817 | 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; |
15817 | 304 GntWidget *button; |
305 GntWidget *combo; | |
18063
926ccb104da0
disapproval of revision '1411afd7660760db59966c3a9f18e2adab8eb27e'
Richard Laager <rlaager@wiktel.com>
parents:
18058
diff
changeset
|
306 GList *list; |
15817 | 307 |
308 g_return_if_fail((cur_pounce != NULL) || | |
309 (account != NULL) || | |
15822 | 310 (purple_accounts_get_all() != NULL)); |
15817 | 311 |
15822 | 312 dialog = g_new0(PurpleGntPounceDialog, 1); |
15817 | 313 |
314 if (cur_pounce != NULL) { | |
315 dialog->pounce = cur_pounce; | |
15822 | 316 dialog->account = purple_pounce_get_pouncer(cur_pounce); |
15817 | 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(); |
15822 | 322 PurpleConnection *gc; |
15817 | 323 |
324 if (connections != NULL) { | |
15822 | 325 gc = (PurpleConnection *)connections->data; |
326 dialog->account = purple_connection_get_account(gc); | |
15817 | 327 } else |
15822 | 328 dialog->account = purple_accounts_get_all()->data; |
15817 | 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(); | |
15822 | 350 list = purple_accounts_get_all(); |
15817 | 351 for (; list; list = list->next) |
352 { | |
15822 | 353 PurpleAccount *account; |
15817 | 354 char *text; |
355 | |
356 account = list->data; | |
357 text = g_strdup_printf("%s (%s)", | |
15822 | 358 purple_account_get_username(account), |
359 purple_account_get_protocol_name(account)); | |
15817 | 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 |
15817 | 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), | |
15822 | 381 purple_pounce_get_pouncee(cur_pounce)); |
15817 | 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 */ |
15817 | 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); |
15817 | 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 |
15817 | 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")); |
15817 | 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); |
15817 | 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 { | |
15822 | 490 PurplePounceEvent events = purple_pounce_get_events(cur_pounce); |
491 PurplePounceOption options = purple_pounce_get_options(cur_pounce); | |
15817 | 492 const char *value; |
493 | |
494 /* Options */ | |
495 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->on_away), | |
15822 | 496 (options & PURPLE_POUNCE_OPTION_AWAY)); |
15817 | 497 |
498 /* Events */ | |
499 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->signon), | |
15822 | 500 (events & PURPLE_POUNCE_SIGNON)); |
15817 | 501 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->signoff), |
15822 | 502 (events & PURPLE_POUNCE_SIGNOFF)); |
15817 | 503 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->away), |
15822 | 504 (events & PURPLE_POUNCE_AWAY)); |
15817 | 505 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->away_return), |
15822 | 506 (events & PURPLE_POUNCE_AWAY_RETURN)); |
15817 | 507 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->idle), |
15822 | 508 (events & PURPLE_POUNCE_IDLE)); |
15817 | 509 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->idle_return), |
15822 | 510 (events & PURPLE_POUNCE_IDLE_RETURN)); |
15817 | 511 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->typing), |
15822 | 512 (events & PURPLE_POUNCE_TYPING)); |
15817 | 513 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->typed), |
15822 | 514 (events & PURPLE_POUNCE_TYPED)); |
15817 | 515 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->stop_typing), |
15822 | 516 (events & PURPLE_POUNCE_TYPING_STOPPED)); |
15817 | 517 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->message_recv), |
15822 | 518 (events & PURPLE_POUNCE_MESSAGE_RECEIVED)); |
15817 | 519 |
520 /* Actions */ | |
521 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->open_win), | |
15822 | 522 purple_pounce_action_is_enabled(cur_pounce, "open-window")); |
15817 | 523 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->popup), |
15822 | 524 purple_pounce_action_is_enabled(cur_pounce, "popup-notify")); |
15817 | 525 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->send_msg), |
15822 | 526 purple_pounce_action_is_enabled(cur_pounce, "send-message")); |
15817 | 527 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->exec_cmd), |
15822 | 528 purple_pounce_action_is_enabled(cur_pounce, "execute-command")); |
15817 | 529 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->play_sound), |
15822 | 530 purple_pounce_action_is_enabled(cur_pounce, "play-beep")); |
15817 | 531 |
532 gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->save_pounce), | |
15822 | 533 purple_pounce_get_save(cur_pounce)); |
15817 | 534 |
15822 | 535 if ((value = purple_pounce_action_get_attribute(cur_pounce, |
15817 | 536 "send-message", |
537 "message")) != NULL) | |
538 { | |
539 gnt_entry_set_text(GNT_ENTRY(dialog->send_msg_entry), value); | |
540 } | |
541 | |
15822 | 542 if ((value = purple_pounce_action_get_attribute(cur_pounce, |
15817 | 543 "popup-notify", |
544 "reason")) != NULL) | |
545 { | |
546 gnt_entry_set_text(GNT_ENTRY(dialog->popup_entry), value); | |
547 } | |
548 | |
15822 | 549 if ((value = purple_pounce_action_get_attribute(cur_pounce, |
15817 | 550 "execute-command", |
551 "command")) != NULL) | |
552 { | |
553 gnt_entry_set_text(GNT_ENTRY(dialog->exec_cmd_entry), value); | |
554 } | |
555 } | |
556 else | |
557 { | |
15822 | 558 PurpleBuddy *buddy = NULL; |
15817 | 559 |
560 if (name != NULL) | |
15822 | 561 buddy = purple_find_buddy(account, name); |
15817 | 562 |
563 /* Set some defaults */ | |
564 if (buddy == NULL) { | |
565 gnt_check_box_set_checked( | |
566 GNT_CHECK_BOX(dialog->signon), TRUE); | |
567 } else { | |
15822 | 568 if (!PURPLE_BUDDY_IS_ONLINE(buddy)) { |
15817 | 569 gnt_check_box_set_checked( |
570 GNT_CHECK_BOX(dialog->signon), TRUE); | |
571 } else { | |
572 gboolean default_set = FALSE; | |
15822 | 573 PurplePresence *presence = purple_buddy_get_presence(buddy); |
15817 | 574 |
15822 | 575 if (purple_presence_is_idle(presence)) |
15817 | 576 { |
577 gnt_check_box_set_checked( | |
578 GNT_CHECK_BOX(dialog->idle_return), TRUE); | |
579 | |
580 default_set = TRUE; | |
581 } | |
582 | |
15822 | 583 if (!purple_presence_is_available(presence)) |
15817 | 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), | |
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/open-window")); |
15817 | 601 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
|
602 purple_prefs_get_bool("/finch/pounces/default_actions/popup-notify")); |
15817 | 603 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
|
604 purple_prefs_get_bool("/finch/pounces/default_actions/send-message")); |
15817 | 605 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
|
606 purple_prefs_get_bool("/finch/pounces/default_actions/execute-command")); |
15817 | 607 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
|
608 purple_prefs_get_bool("/finch/pounces/default_actions/play-beep")); |
15817 | 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 } |
15817 | 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; | |
15822 | 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); |
15817 | 648 } |
649 | |
650 static void | |
15822 | 651 pounces_manager_delete_confirm_cb(PurplePounce *pounce) |
15817 | 652 { |
653 gnt_tree_remove(GNT_TREE(pounces_manager->tree), pounce); | |
654 | |
15822 | 655 purple_request_close_with_handle(pounce); |
656 purple_pounce_destroy(pounce); | |
15817 | 657 } |
658 | |
659 | |
660 static void | |
661 pounces_manager_delete_cb(GntButton *button, gpointer user_data) | |
662 { | |
663 PouncesManager *dialog = user_data; | |
15822 | 664 PurplePounce *pounce; |
665 PurpleAccount *account; | |
15817 | 666 const char *pouncer, *pouncee; |
667 char *buf; | |
668 | |
15822 | 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 |
15822 | 673 account = purple_pounce_get_pouncer(pounce); |
674 pouncer = purple_account_get_username(account); | |
675 pouncee = purple_pounce_get_pouncee(pounce); | |
15817 | 676 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
|
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:
16424
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:
16424
diff
changeset
|
679 pounce, 2, |
15817 | 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); |
15817 | 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); |
15817 | 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); |
15817 | 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); |
15817 | 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 | |
15822 | 774 purple_signals_disconnect_by_handle(pounces_manager); |
15817 | 775 |
776 g_free(pounces_manager); | |
777 pounces_manager = NULL; | |
778 } | |
779 | |
780 static void | |
15822 | 781 pounce_cb(PurplePounce *pounce, PurplePounceEvent events, void *data) |
15817 | 782 { |
15822 | 783 PurpleConversation *conv; |
784 PurpleAccount *account; | |
785 PurpleBuddy *buddy; | |
15817 | 786 const char *pouncee; |
787 const char *alias; | |
788 | |
15822 | 789 pouncee = purple_pounce_get_pouncee(pounce); |
790 account = purple_pounce_get_pouncer(pounce); | |
15817 | 791 |
15822 | 792 buddy = purple_find_buddy(account, pouncee); |
15817 | 793 if (buddy != NULL) |
794 { | |
15822 | 795 alias = purple_buddy_get_alias(buddy); |
15817 | 796 if (alias == NULL) |
797 alias = pouncee; | |
798 } | |
799 else | |
800 alias = pouncee; | |
801 | |
15822 | 802 if (purple_pounce_action_is_enabled(pounce, "open-window")) |
15817 | 803 { |
15822 | 804 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, pouncee, account); |
15817 | 805 |
806 if (conv == NULL) | |
15822 | 807 conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, pouncee); |
15817 | 808 } |
809 | |
15822 | 810 if (purple_pounce_action_is_enabled(pounce, "popup-notify")) |
15817 | 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; |
15817 | 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; |
15822 | 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"); |
15817 | 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!")); |
15817 | 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 */ | |
15822 | 854 if ((name_shown = purple_account_get_alias(account)) == NULL) |
855 name_shown = purple_account_get_username(account); | |
15817 | 856 |
857 if (reason == NULL) | |
858 { | |
15822 | 859 purple_notify_info(NULL, name_shown, tmp, purple_date_format_full(NULL)); |
15817 | 860 } |
861 else | |
862 { | |
15822 | 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); | |
15817 | 865 g_free(tmp2); |
866 } | |
867 g_free(tmp); | |
868 } | |
869 | |
15822 | 870 if (purple_pounce_action_is_enabled(pounce, "send-message")) |
15817 | 871 { |
872 const char *message; | |
873 | |
15822 | 874 message = purple_pounce_action_get_attribute(pounce, "send-message", |
15817 | 875 "message"); |
876 | |
877 if (message != NULL) | |
878 { | |
15822 | 879 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, pouncee, account); |
15817 | 880 |
881 if (conv == NULL) | |
15822 | 882 conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, pouncee); |
15817 | 883 |
15822 | 884 purple_conversation_write(conv, NULL, message, |
885 PURPLE_MESSAGE_SEND, time(NULL)); | |
15817 | 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); |
15817 | 888 } |
889 } | |
890 | |
15822 | 891 if (purple_pounce_action_is_enabled(pounce, "execute-command")) |
15817 | 892 { |
893 const char *command; | |
894 | |
15822 | 895 command = purple_pounce_action_get_attribute(pounce, |
15817 | 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 | |
15822 | 924 if (purple_pounce_action_is_enabled(pounce, "play-beep")) |
15817 | 925 { |
926 beep(); | |
927 } | |
928 } | |
929 | |
930 static void | |
15822 | 931 free_pounce(PurplePounce *pounce) |
15817 | 932 { |
933 update_pounces(); | |
934 } | |
935 | |
936 static void | |
15822 | 937 new_pounce(PurplePounce *pounce) |
15817 | 938 { |
15822 | 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"); | |
15817 | 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 { | |
15822 | 959 purple_pounces_register_handler(FINCH_UI, pounce_cb, new_pounce, |
15817 | 960 free_pounce); |
961 | |
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
|
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", |
15817 | 965 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
|
966 purple_prefs_add_bool("/finch/pounces/default_actions/popup-notify", |
15817 | 967 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
|
968 purple_prefs_add_bool("/finch/pounces/default_actions/send-message", |
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/execute-command", |
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_bool("/finch/pounces/default_actions/play-beep", |
15817 | 973 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
|
974 purple_prefs_add_none("/finch/pounces/dialog"); |
15817 | 975 |
15822 | 976 purple_signal_connect(purple_connections_get_handle(), "signed-on", |
15817 | 977 finch_pounces_get_handle(), |
15822 | 978 PURPLE_CALLBACK(signed_on_off_cb), NULL); |
979 purple_signal_connect(purple_connections_get_handle(), "signed-off", | |
15817 | 980 finch_pounces_get_handle(), |
15822 | 981 PURPLE_CALLBACK(signed_on_off_cb), NULL); |
15817 | 982 } |
983 | |
984 /* XXX: There's no such thing in pidgin. Perhaps there should be? */ | |
985 void finch_pounces_uninit() | |
986 { | |
24078
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); |
15817 | 988 |
15822 | 989 purple_signals_disconnect_by_handle(finch_pounces_get_handle()); |
15817 | 990 } |
991 |