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