Thu, 17 Apr 2003 23:44:34 +0000
[gaim-migrate @ 5517]
The return of the Remove Buddy Pounce menu (I think I accidentally killed
it before? Anyhow, it's here now.)
Also, pounce menu items now have the protocol icon. This made is extremely
easier to figure out who I was looking for. Yay.
Imma go beat up the mailman.
| 5032 | 1 | /** |
| 2 | * @file gtkpounce.h GTK+ buddy pounce API | |
| 3 | * | |
| 4 | * gaim | |
| 5 | * | |
| 6 | * Copyright (C) 2003, Christian Hammond <chipx86@gnupdate.org> | |
| 7 | * | |
| 8 | * This program is free software; you can redistribute it and/or modify | |
| 9 | * it under the terms of the GNU General Public License as published by | |
| 10 | * the Free Software Foundation; either version 2 of the License, or | |
| 11 | * (at your option) any later version. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | * GNU General Public License for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU General Public License | |
| 19 | * along with this program; if not, write to the Free Software | |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 21 | * | |
| 22 | */ | |
| 5054 | 23 | #include <unistd.h> |
| 5032 | 24 | #include "gaim.h" |
| 25 | #include "gtkpounce.h" | |
| 26 | #include "gtklist.h" | |
| 27 | #include "prpl.h" | |
| 28 | #include "sound.h" | |
| 29 | ||
| 30 | struct gaim_gtkpounce_dialog | |
| 31 | { | |
| 32 | /* Pounce data */ | |
| 33 | struct gaim_pounce *pounce; | |
| 34 | struct gaim_account *account; | |
| 35 | ||
| 36 | /* The window */ | |
| 37 | GtkWidget *window; | |
| 38 | ||
| 39 | /* Pounce Who */ | |
| 40 | GtkWidget *account_menu; | |
| 41 | GtkWidget *buddy_entry; | |
| 42 | ||
| 43 | /* Pounce When */ | |
| 44 | GtkWidget *signon; | |
| 45 | GtkWidget *signoff; | |
| 46 | GtkWidget *away; | |
| 47 | GtkWidget *away_return; | |
| 48 | GtkWidget *idle; | |
| 49 | GtkWidget *idle_return; | |
| 50 | GtkWidget *typing; | |
| 51 | GtkWidget *stop_typing; | |
| 52 | ||
| 53 | /* Pounce Action */ | |
| 54 | GtkWidget *open_win; | |
| 55 | GtkWidget *popup; | |
| 56 | GtkWidget *send_msg; | |
| 57 | GtkWidget *send_msg_entry; | |
| 58 | GtkWidget *exec_cmd; | |
| 59 | GtkWidget *exec_cmd_entry; | |
| 60 | GtkWidget *play_sound; | |
| 61 | GtkWidget *play_sound_entry; | |
| 62 | ||
| 63 | GtkWidget *save_pounce; | |
| 64 | }; | |
| 65 | ||
| 66 | /************************************************************************** | |
| 67 | * Callbacks | |
| 68 | **************************************************************************/ | |
| 69 | static gint | |
| 70 | delete_win_cb(GtkWidget *w, GdkEventAny *e, | |
| 71 | struct gaim_gtkpounce_dialog *dialog) | |
| 72 | { | |
| 73 | gtk_widget_destroy(dialog->window); | |
| 74 | g_free(dialog); | |
| 75 | ||
| 76 | return TRUE; | |
| 77 | } | |
| 78 | ||
| 79 | static void | |
|
5052
8df6b6a43a49
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
80 | delete_cb(GtkWidget *w, struct gaim_gtkpounce_dialog *dialog) |
|
8df6b6a43a49
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
81 | { |
|
8df6b6a43a49
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
82 | gaim_pounce_destroy(dialog->pounce); |
|
8df6b6a43a49
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
83 | |
|
8df6b6a43a49
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
84 | delete_win_cb(NULL, NULL, dialog); |
|
8df6b6a43a49
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
85 | } |
|
8df6b6a43a49
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
86 | |
|
8df6b6a43a49
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
87 | static void |
| 5032 | 88 | cancel_cb(GtkWidget *w, struct gaim_gtkpounce_dialog *dialog) |
| 89 | { | |
| 90 | delete_win_cb(NULL, NULL, dialog); | |
| 91 | } | |
| 92 | ||
| 93 | ||
| 94 | static void | |
| 95 | save_pounce_cb(GtkWidget *w, struct gaim_gtkpounce_dialog *dialog) | |
| 96 | { | |
| 97 | const char *name; | |
| 98 | const char *message, *command, *sound; | |
| 99 | struct gaim_buddy_list *blist; | |
| 100 | struct gaim_gtk_buddy_list *gtkblist; | |
| 101 | GaimPounceEvent events = GAIM_POUNCE_NONE; | |
| 102 | GaimGtkPounceAction actions = GAIM_GTKPOUNCE_NONE; | |
| 103 | gboolean save; | |
| 104 | ||
| 105 | name = gtk_entry_get_text(GTK_ENTRY(dialog->buddy_entry)); | |
| 106 | ||
| 107 | if (*name == '\0') { | |
| 108 | do_error_dialog(_("Please enter a buddy to pounce."), NULL, GAIM_ERROR); | |
| 109 | return; | |
| 110 | } | |
| 111 | ||
| 112 | /* Events */ | |
| 113 | if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->signon))) | |
| 114 | events |= GAIM_POUNCE_SIGNON; | |
| 115 | ||
| 116 | if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->signoff))) | |
| 117 | events |= GAIM_POUNCE_SIGNOFF; | |
| 118 | ||
| 119 | if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->away))) | |
| 120 | events |= GAIM_POUNCE_AWAY; | |
| 121 | ||
| 122 | if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->away_return))) | |
| 123 | events |= GAIM_POUNCE_AWAY_RETURN; | |
| 124 | ||
| 125 | if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->idle))) | |
| 126 | events |= GAIM_POUNCE_IDLE; | |
| 127 | ||
| 128 | if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->idle_return))) | |
| 129 | events |= GAIM_POUNCE_IDLE_RETURN; | |
| 130 | ||
| 131 | if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->typing))) | |
| 132 | events |= GAIM_POUNCE_TYPING; | |
| 133 | ||
| 134 | if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->stop_typing))) | |
| 135 | events |= GAIM_POUNCE_TYPING_STOPPED; | |
| 136 | ||
| 137 | ||
| 138 | /* Actions */ | |
| 139 | if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->open_win))) | |
| 140 | actions |= GAIM_GTKPOUNCE_OPEN_WIN; | |
| 141 | ||
| 142 | if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->popup))) | |
| 143 | actions |= GAIM_GTKPOUNCE_POPUP; | |
| 144 | ||
| 145 | if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->send_msg))) | |
| 146 | actions |= GAIM_GTKPOUNCE_SEND_MSG; | |
| 147 | ||
| 148 | if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->exec_cmd))) | |
| 149 | actions |= GAIM_GTKPOUNCE_EXEC_CMD; | |
| 150 | ||
| 151 | if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->play_sound))) | |
| 152 | actions |= GAIM_GTKPOUNCE_PLAY_SOUND; | |
| 153 | ||
| 154 | save = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->save_pounce)); | |
| 155 | ||
| 156 | /* Data fields */ | |
| 157 | message = gtk_entry_get_text(GTK_ENTRY(dialog->send_msg_entry)); | |
| 158 | command = gtk_entry_get_text(GTK_ENTRY(dialog->exec_cmd_entry)); | |
| 159 | sound = gtk_entry_get_text(GTK_ENTRY(dialog->play_sound_entry)); | |
| 160 | ||
| 161 | if (*message == '\0') message = NULL; | |
| 162 | if (*command == '\0') command = NULL; | |
| 163 | if (*sound == '\0') sound = NULL; | |
| 164 | ||
| 165 | if (dialog->pounce == NULL) | |
| 166 | { | |
| 167 | gaim_gtkpounce_new(dialog->account, name, events, actions, | |
| 168 | message, command, sound, save); | |
| 169 | } | |
| 170 | else | |
| 171 | { | |
| 172 | struct gaim_gtkpounce_data *pounce_data; | |
| 173 | ||
| 174 | gaim_pounce_set_events(dialog->pounce, events); | |
| 175 | gaim_pounce_set_pouncer(dialog->pounce, dialog->account); | |
| 176 | gaim_pounce_set_pouncee(dialog->pounce, name); | |
| 177 | ||
| 178 | pounce_data = GAIM_GTKPOUNCE(dialog->pounce); | |
| 179 | ||
| 180 | if (pounce_data->message != NULL) g_free(pounce_data->message); | |
| 181 | if (pounce_data->command != NULL) g_free(pounce_data->command); | |
| 182 | if (pounce_data->sound != NULL) g_free(pounce_data->sound); | |
| 183 | ||
| 184 | pounce_data->message = (message == NULL ? NULL : g_strdup(message)); | |
| 185 | pounce_data->command = (command == NULL ? NULL : g_strdup(command)); | |
| 186 | pounce_data->sound = (sound == NULL ? NULL : g_strdup(sound)); | |
| 187 | ||
| 188 | pounce_data->actions = actions; | |
| 189 | pounce_data->save = save; | |
| 190 | } | |
| 191 | ||
| 192 | delete_win_cb(NULL, NULL, dialog); | |
| 193 | ||
| 194 | /* Rebuild the pounce menu */ | |
| 195 | blist = gaim_get_blist(); | |
| 196 | ||
| 197 | if (GAIM_IS_GTK_BLIST(blist)) | |
| 198 | { | |
| 199 | gtkblist = GAIM_GTK_BLIST(blist); | |
| 200 | ||
| 201 | gaim_gtkpounce_menu_build(gtkblist->bpmenu); | |
| 202 | } | |
| 203 | ||
| 204 | save_prefs(); | |
| 205 | } | |
| 206 | ||
| 5054 | 207 | static void |
| 5032 | 208 | pounce_choose_cb(GtkWidget *item, struct gaim_gtkpounce_dialog *dialog) |
| 209 | { | |
| 210 | dialog->account = g_object_get_data(G_OBJECT(item), "user_data"); | |
| 211 | } | |
| 212 | ||
| 213 | static GtkWidget * | |
| 214 | pounce_user_menu(struct gaim_gtkpounce_dialog *dialog) | |
| 215 | { | |
| 216 | struct gaim_account *account; | |
| 217 | struct prpl *prpl; | |
| 218 | GtkWidget *opt_menu; | |
| 219 | GtkWidget *menu; | |
| 220 | GtkWidget *item; | |
| 221 | GSList *l; | |
| 222 | char buf[2048]; | |
| 5054 | 223 | int count, place = 0; |
| 5032 | 224 | |
| 225 | opt_menu = gtk_option_menu_new(); | |
| 226 | menu = gtk_menu_new(); | |
| 227 | ||
| 228 | for (l = gaim_accounts, count = 0; l != NULL; l = l->next, count++) { | |
| 229 | account = (struct gaim_account *)l->data; | |
| 230 | ||
| 231 | prpl = (struct prpl *)find_prpl(account->protocol); | |
| 232 | ||
| 233 | g_snprintf(buf, sizeof(buf), "%s (%s)", account->username, | |
| 234 | (prpl && prpl->name) ? prpl->name : _("Unknown")); | |
| 235 | ||
| 236 | item = gtk_menu_item_new_with_label(buf); | |
| 237 | g_object_set_data(G_OBJECT(item), "user_data", account); | |
| 238 | ||
| 239 | g_signal_connect(G_OBJECT(item), "activate", | |
| 240 | G_CALLBACK(pounce_choose_cb), dialog); | |
| 241 | ||
| 242 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); | |
| 243 | gtk_widget_show(item); | |
| 244 | ||
| 245 | if (dialog->account == account) { | |
| 246 | gtk_menu_item_activate(GTK_MENU_ITEM(item)); | |
| 247 | place = count; | |
| 248 | } | |
| 249 | } | |
| 250 | ||
| 251 | gtk_option_menu_set_menu(GTK_OPTION_MENU(opt_menu), menu); | |
| 252 | gtk_option_menu_set_history(GTK_OPTION_MENU(opt_menu), place); | |
| 253 | ||
| 254 | return opt_menu; | |
| 255 | } | |
| 256 | ||
| 257 | static void | |
| 258 | pounce_cb(struct gaim_pounce *pounce, GaimPounceEvent events, void *data) | |
| 259 | { | |
| 260 | struct gaim_conversation *conv; | |
| 261 | struct gaim_account *account; | |
| 262 | struct gaim_gtkpounce_data *pounce_data; | |
| 263 | const char *pouncee; | |
| 264 | ||
| 265 | pounce_data = (struct gaim_gtkpounce_data *)data; | |
| 266 | pouncee = gaim_pounce_get_pouncee(pounce); | |
| 267 | account = gaim_pounce_get_pouncer(pounce); | |
| 268 | ||
| 269 | if (pounce_data->actions & GAIM_GTKPOUNCE_OPEN_WIN) { | |
| 270 | conv = gaim_find_conversation(pouncee); | |
| 271 | ||
| 272 | if (conv == NULL) | |
| 273 | conv = gaim_conversation_new(GAIM_CONV_IM, account, pouncee); | |
| 274 | } | |
| 275 | ||
| 276 | if (pounce_data->actions & GAIM_GTKPOUNCE_POPUP) { | |
| 277 | char tmp[1024]; | |
| 278 | ||
| 279 | g_snprintf(tmp, sizeof(tmp), | |
| 280 | (events & GAIM_POUNCE_TYPING) ? _("%s has started typing to you") : | |
| 281 | (events & GAIM_POUNCE_SIGNON) ? _("%s has signed on") : | |
| 282 | (events & GAIM_POUNCE_IDLE_RETURN) ? _("%s has returned from being idle") : | |
| 283 | (events & GAIM_POUNCE_AWAY_RETURN) ? _("%s has returned from being away") : | |
| 284 | (events & GAIM_POUNCE_TYPING_STOPPED) ? _("%s has stopped typing to you") : | |
| 285 | (events & GAIM_POUNCE_SIGNOFF) ? _("%s has signed off") : | |
| 286 | (events & GAIM_POUNCE_IDLE) ? _("%s has become idle") : | |
| 287 | (events & GAIM_POUNCE_AWAY) ? _("%s has gone away.") : | |
| 288 | _("Unknown pounce event. Please report this!"), | |
| 289 | pouncee); | |
| 290 | ||
| 291 | do_error_dialog(tmp, NULL, GAIM_INFO); | |
| 292 | } | |
| 293 | ||
| 294 | if (pounce_data->actions & GAIM_GTKPOUNCE_SEND_MSG && | |
|
5051
17caa7e7287c
[gaim-migrate @ 5400]
Christian Hammond <chipx86@chipx86.com>
parents:
5032
diff
changeset
|
295 | pounce_data->message != NULL) { |
| 5032 | 296 | |
| 297 | conv = gaim_find_conversation(pouncee); | |
| 298 | ||
| 299 | if (conv == NULL) | |
| 300 | conv = gaim_conversation_new(GAIM_CONV_IM, account, pouncee); | |
| 301 | ||
| 302 | gaim_conversation_write(conv, NULL, pounce_data->message, -1, | |
| 303 | WFLAG_SEND, time(NULL)); | |
| 304 | ||
| 305 | serv_send_im(account->gc, (char *)pouncee, pounce_data->message, -1, 0); | |
| 306 | } | |
| 307 | ||
| 308 | if (pounce_data->actions & GAIM_GTKPOUNCE_EXEC_CMD && | |
|
5051
17caa7e7287c
[gaim-migrate @ 5400]
Christian Hammond <chipx86@chipx86.com>
parents:
5032
diff
changeset
|
309 | pounce_data->command != NULL) { |
| 5032 | 310 | #ifndef _WIN32 |
| 311 | int pid = fork(); | |
| 312 | ||
| 313 | if (pid == 0) { | |
| 314 | char *args[4]; | |
| 315 | ||
| 316 | args[0] = "sh"; | |
| 317 | args[1] = "-c"; | |
| 318 | args[2] = pounce_data->command; | |
| 319 | args[3] = NULL; | |
| 320 | ||
| 321 | execvp(args[0], args); | |
| 322 | ||
| 323 | _exit(0); | |
| 324 | } | |
| 325 | #endif /* _WIN32 */ | |
| 326 | } | |
| 327 | ||
| 328 | if (pounce_data->actions & GAIM_GTKPOUNCE_PLAY_SOUND) { | |
|
5051
17caa7e7287c
[gaim-migrate @ 5400]
Christian Hammond <chipx86@chipx86.com>
parents:
5032
diff
changeset
|
329 | if (pounce_data->sound != NULL) |
| 5032 | 330 | gaim_sound_play_file(pounce_data->sound); |
| 331 | else | |
| 332 | gaim_sound_play_event(GAIM_SOUND_POUNCE_DEFAULT); | |
| 333 | } | |
| 334 | ||
| 335 | if (!pounce_data->save) | |
| 336 | gaim_pounce_destroy(pounce); | |
| 337 | } | |
| 338 | ||
| 339 | static void | |
| 340 | free_pounce(void *data) | |
| 341 | { | |
| 342 | struct gaim_gtkpounce_data *pounce_data; | |
| 343 | struct gaim_buddy_list *blist; | |
| 344 | struct gaim_gtk_buddy_list *gtkblist; | |
| 345 | ||
| 346 | pounce_data = (struct gaim_gtkpounce_data *)data; | |
| 347 | ||
| 348 | if (pounce_data->message != NULL) g_free(pounce_data->message); | |
| 349 | if (pounce_data->command != NULL) g_free(pounce_data->command); | |
| 350 | if (pounce_data->sound != NULL) g_free(pounce_data->sound); | |
| 351 | ||
| 352 | g_free(data); | |
| 353 | ||
| 354 | /* Rebuild the pounce menu */ | |
| 355 | blist = gaim_get_blist(); | |
| 356 | ||
| 357 | if (GAIM_IS_GTK_BLIST(blist)) | |
| 358 | { | |
| 359 | gtkblist = GAIM_GTK_BLIST(blist); | |
| 360 | ||
| 361 | gaim_gtkpounce_menu_build(gtkblist->bpmenu); | |
| 362 | } | |
| 363 | ||
| 364 | save_prefs(); | |
| 365 | } | |
| 366 | ||
| 367 | struct gaim_pounce * | |
| 368 | gaim_gtkpounce_new(struct gaim_account *pouncer, const char *pouncee, | |
| 369 | GaimPounceEvent events, GaimGtkPounceAction actions, | |
| 370 | const char *message, const char *command, | |
| 371 | const char *sound, gboolean save) | |
| 372 | { | |
| 373 | struct gaim_gtkpounce_data *data; | |
| 374 | ||
| 375 | data = g_new0(struct gaim_gtkpounce_data, 1); | |
| 376 | ||
| 377 | data->actions = actions; | |
| 378 | ||
| 379 | if (message != NULL) data->message = g_strdup(message); | |
| 380 | if (command != NULL) data->command = g_strdup(command); | |
| 381 | if (sound != NULL) data->sound = g_strdup(sound); | |
| 382 | ||
| 383 | data->save = save; | |
| 384 | ||
| 385 | return gaim_pounce_new(pouncer, pouncee, events, pounce_cb, data, | |
| 386 | free_pounce); | |
| 387 | } | |
| 388 | ||
| 389 | void | |
| 390 | gaim_gtkpounce_dialog_show(struct buddy *buddy, | |
| 391 | struct gaim_pounce *cur_pounce) | |
| 392 | { | |
| 393 | struct gaim_gtkpounce_dialog *dialog; | |
| 394 | GtkWidget *window; | |
| 395 | GtkWidget *label; | |
| 396 | GtkWidget *bbox; | |
| 397 | GtkWidget *vbox1, *vbox2; | |
| 398 | GtkWidget *hbox; | |
| 399 | GtkWidget *button; | |
| 400 | GtkWidget *frame; | |
| 401 | GtkWidget *table; | |
| 402 | GtkWidget *sep; | |
| 403 | GtkSizeGroup *sg; | |
| 404 | ||
| 405 | dialog = g_new0(struct gaim_gtkpounce_dialog, 1); | |
| 406 | ||
| 407 | if (cur_pounce != NULL) { | |
| 408 | dialog->pounce = cur_pounce; | |
| 409 | dialog->account = gaim_pounce_get_pouncer(cur_pounce); | |
| 410 | } | |
| 411 | else if (buddy != NULL) { | |
| 412 | dialog->pounce = NULL; | |
| 413 | dialog->account = buddy->account; | |
| 414 | } | |
| 415 | else { | |
| 416 | dialog->pounce = NULL; | |
| 417 | dialog->account = gaim_accounts->data; | |
| 418 | } | |
| 419 | ||
| 420 | sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); | |
| 421 | ||
| 422 | /* Create the window. */ | |
| 423 | dialog->window = window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
| 424 | gtk_window_set_type_hint(GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_DIALOG); | |
| 425 | gtk_window_set_role(GTK_WINDOW(window), "buddy_pounce"); | |
| 426 | gtk_window_set_resizable(GTK_WINDOW(window), FALSE); | |
| 427 | gtk_window_set_title(GTK_WINDOW(window), | |
| 428 | (cur_pounce == NULL | |
| 429 | ? _("New Buddy Pounce") : _("Edit Buddy Pounce"))); | |
| 430 | ||
| 431 | gtk_container_set_border_width(GTK_CONTAINER(window), 12); | |
| 432 | gtk_widget_realize(window); | |
| 433 | ||
| 434 | g_signal_connect(G_OBJECT(window), "delete_event", | |
| 435 | G_CALLBACK(delete_win_cb), dialog); | |
| 436 | ||
| 437 | /* Create the parent vbox for everything. */ | |
| 438 | vbox1 = gtk_vbox_new(FALSE, 12); | |
| 439 | gtk_container_add(GTK_CONTAINER(window), vbox1); | |
| 440 | gtk_widget_show(vbox1); | |
| 441 | ||
| 442 | /* Create the vbox that will contain all the prefs stuff. */ | |
| 443 | vbox2 = gtk_vbox_new(FALSE, 18); | |
| 444 | gtk_box_pack_start(GTK_BOX(vbox1), vbox2, TRUE, TRUE, 0); | |
| 445 | ||
| 446 | /* Create the "Pounce Who" frame. */ | |
| 447 | frame = make_frame(vbox2, _("Pounce Who")); | |
| 448 | ||
| 449 | /* Account: */ | |
| 450 | hbox = gtk_hbox_new(FALSE, 6); | |
| 451 | gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); | |
| 452 | gtk_widget_show(hbox); | |
| 453 | ||
| 454 | label = gtk_label_new_with_mnemonic(_("_Account:")); | |
| 455 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 456 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 457 | gtk_widget_show(label); | |
| 458 | gtk_size_group_add_widget(sg, label); | |
| 459 | ||
| 460 | dialog->account_menu = pounce_user_menu(dialog); | |
| 461 | gtk_box_pack_start(GTK_BOX(hbox), dialog->account_menu, FALSE, FALSE, 0); | |
| 462 | gtk_widget_show(dialog->account_menu); | |
| 463 | ||
| 464 | /* Buddy: */ | |
| 465 | hbox = gtk_hbox_new(FALSE, 6); | |
| 466 | gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); | |
| 467 | gtk_widget_show(hbox); | |
| 468 | ||
| 469 | label = gtk_label_new_with_mnemonic(_("_Buddy Name:")); | |
| 470 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 471 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 472 | gtk_widget_show(label); | |
| 473 | gtk_size_group_add_widget(sg, label); | |
| 474 | ||
| 475 | dialog->buddy_entry = gtk_entry_new(); | |
| 476 | gtk_box_pack_start(GTK_BOX(hbox), dialog->buddy_entry, TRUE, TRUE, 0); | |
| 477 | gtk_widget_show(dialog->buddy_entry); | |
| 478 | ||
| 479 | if (cur_pounce != NULL) { | |
| 480 | gtk_entry_set_text(GTK_ENTRY(dialog->buddy_entry), | |
| 481 | gaim_pounce_get_pouncee(cur_pounce)); | |
| 482 | } | |
| 483 | else if (buddy != NULL) { | |
| 484 | gtk_entry_set_text(GTK_ENTRY(dialog->buddy_entry), buddy->name); | |
| 485 | } | |
| 486 | ||
| 487 | /* Create the "Pounce When" frame. */ | |
| 488 | frame = make_frame(vbox2, _("Pounce When")); | |
| 489 | ||
| 490 | table = gtk_table_new(2, 4, FALSE); | |
| 491 | gtk_container_add(GTK_CONTAINER(frame), table); | |
| 492 | gtk_table_set_col_spacings(GTK_TABLE(table), 12); | |
| 493 | gtk_widget_show(table); | |
| 494 | ||
| 495 | dialog->signon = | |
| 496 | gtk_check_button_new_with_label(_("Sign on")); | |
| 497 | dialog->signoff = | |
| 498 | gtk_check_button_new_with_label(_("Sign off")); | |
| 499 | dialog->away = | |
| 500 | gtk_check_button_new_with_label(_("Away")); | |
| 501 | dialog->away_return = | |
| 502 | gtk_check_button_new_with_label(_("Return from away")); | |
| 503 | dialog->idle = | |
| 504 | gtk_check_button_new_with_label(_("Idle")); | |
| 505 | dialog->idle_return = | |
| 506 | gtk_check_button_new_with_label(_("Return from idle")); | |
| 507 | dialog->typing = | |
| 508 | gtk_check_button_new_with_label(_("Buddy starts typing")); | |
| 509 | dialog->stop_typing = | |
| 510 | gtk_check_button_new_with_label(_("Buddy stops typing")); | |
| 511 | ||
| 512 | gtk_table_attach(GTK_TABLE(table), dialog->signon, 0, 1, 0, 1, | |
| 513 | GTK_FILL, 0, 0, 0); | |
| 514 | gtk_table_attach(GTK_TABLE(table), dialog->signoff, 1, 2, 0, 1, | |
| 515 | GTK_FILL, 0, 0, 0); | |
| 516 | gtk_table_attach(GTK_TABLE(table), dialog->away, 0, 1, 1, 2, | |
| 517 | GTK_FILL, 0, 0, 0); | |
| 518 | gtk_table_attach(GTK_TABLE(table), dialog->away_return, 1, 2, 1, 2, | |
| 519 | GTK_FILL, 0, 0, 0); | |
| 520 | gtk_table_attach(GTK_TABLE(table), dialog->idle, 0, 1, 2, 3, | |
| 521 | GTK_FILL, 0, 0, 0); | |
| 522 | gtk_table_attach(GTK_TABLE(table), dialog->idle_return, 1, 2, 2, 3, | |
| 523 | GTK_FILL, 0, 0, 0); | |
| 524 | gtk_table_attach(GTK_TABLE(table), dialog->typing, 0, 1, 3, 4, | |
| 525 | GTK_FILL, 0, 0, 0); | |
| 526 | gtk_table_attach(GTK_TABLE(table), dialog->stop_typing, 1, 2, 3, 4, | |
| 527 | GTK_FILL, 0, 0, 0); | |
| 528 | ||
| 529 | gtk_widget_show(dialog->signon); | |
| 530 | gtk_widget_show(dialog->signoff); | |
| 531 | gtk_widget_show(dialog->away); | |
| 532 | gtk_widget_show(dialog->away_return); | |
| 533 | gtk_widget_show(dialog->idle); | |
| 534 | gtk_widget_show(dialog->idle_return); | |
| 535 | gtk_widget_show(dialog->typing); | |
| 536 | gtk_widget_show(dialog->stop_typing); | |
| 537 | ||
| 538 | /* Create the "Pounce Action" frame. */ | |
| 539 | frame = make_frame(vbox2, _("Pounce Action")); | |
| 540 | ||
| 541 | table = gtk_table_new(2, 5, FALSE); | |
| 542 | gtk_container_add(GTK_CONTAINER(frame), table); | |
| 543 | gtk_table_set_col_spacings(GTK_TABLE(table), 12); | |
| 544 | gtk_widget_show(table); | |
| 545 | ||
| 546 | dialog->open_win = gtk_check_button_new_with_label(_("Open an IM window")); | |
| 547 | dialog->popup = gtk_check_button_new_with_label(_("Popup notification")); | |
| 548 | dialog->send_msg = gtk_check_button_new_with_label(_("Send a message")); | |
| 549 | dialog->exec_cmd = gtk_check_button_new_with_label(_("Execute a command")); | |
|
5051
17caa7e7287c
[gaim-migrate @ 5400]
Christian Hammond <chipx86@chipx86.com>
parents:
5032
diff
changeset
|
550 | dialog->play_sound = gtk_check_button_new_with_label(_("Play a sound")); |
| 5032 | 551 | |
| 552 | dialog->send_msg_entry = gtk_entry_new(); | |
| 553 | dialog->exec_cmd_entry = gtk_entry_new(); | |
| 554 | dialog->play_sound_entry = gtk_entry_new(); | |
| 555 | ||
| 556 | gtk_widget_set_sensitive(dialog->send_msg_entry, FALSE); | |
| 557 | gtk_widget_set_sensitive(dialog->exec_cmd_entry, FALSE); | |
| 558 | gtk_widget_set_sensitive(dialog->play_sound_entry, FALSE); | |
| 559 | ||
| 560 | gtk_table_attach(GTK_TABLE(table), dialog->open_win, 0, 1, 0, 1, | |
| 561 | GTK_FILL, 0, 0, 0); | |
| 562 | gtk_table_attach(GTK_TABLE(table), dialog->popup, 0, 1, 1, 2, | |
| 563 | GTK_FILL, 0, 0, 0); | |
| 564 | gtk_table_attach(GTK_TABLE(table), dialog->send_msg, 0, 1, 2, 3, | |
| 565 | GTK_FILL, 0, 0, 0); | |
| 566 | gtk_table_attach(GTK_TABLE(table), dialog->send_msg_entry, 1, 2, 2, 3, | |
| 567 | GTK_FILL, 0, 0, 0); | |
| 568 | gtk_table_attach(GTK_TABLE(table), dialog->exec_cmd, 0, 1, 3, 4, | |
| 569 | GTK_FILL, 0, 0, 0); | |
| 570 | gtk_table_attach(GTK_TABLE(table), dialog->exec_cmd_entry, 1, 2, 3, 4, | |
| 571 | GTK_FILL, 0, 0, 0); | |
| 572 | gtk_table_attach(GTK_TABLE(table), dialog->play_sound, 0, 1, 4, 5, | |
| 573 | GTK_FILL, 0, 0, 0); | |
| 574 | gtk_table_attach(GTK_TABLE(table), dialog->play_sound_entry, 1, 2, 4, 5, | |
| 575 | GTK_FILL, 0, 0, 0); | |
| 576 | ||
| 577 | gtk_widget_show(dialog->open_win); | |
| 578 | gtk_widget_show(dialog->popup); | |
| 579 | gtk_widget_show(dialog->send_msg); | |
| 580 | gtk_widget_show(dialog->send_msg_entry); | |
| 581 | gtk_widget_show(dialog->exec_cmd); | |
| 582 | gtk_widget_show(dialog->exec_cmd_entry); | |
| 583 | gtk_widget_show(dialog->play_sound); | |
| 584 | gtk_widget_show(dialog->play_sound_entry); | |
| 585 | ||
| 586 | g_signal_connect(G_OBJECT(dialog->send_msg), "clicked", | |
| 587 | G_CALLBACK(gaim_gtk_toggle_sensitive), | |
| 588 | dialog->send_msg_entry); | |
| 589 | g_signal_connect(G_OBJECT(dialog->exec_cmd), "clicked", | |
| 590 | G_CALLBACK(gaim_gtk_toggle_sensitive), | |
| 591 | dialog->exec_cmd_entry); | |
| 592 | g_signal_connect(G_OBJECT(dialog->play_sound), "clicked", | |
| 593 | G_CALLBACK(gaim_gtk_toggle_sensitive), | |
| 594 | dialog->play_sound_entry); | |
| 595 | ||
| 596 | g_signal_connect(G_OBJECT(dialog->send_msg_entry), "activate", | |
| 597 | G_CALLBACK(save_pounce_cb), dialog); | |
| 598 | g_signal_connect(G_OBJECT(dialog->exec_cmd_entry), "activate", | |
| 599 | G_CALLBACK(save_pounce_cb), dialog); | |
| 600 | g_signal_connect(G_OBJECT(dialog->play_sound_entry), "activate", | |
| 601 | G_CALLBACK(save_pounce_cb), dialog); | |
| 602 | ||
| 603 | /* Now the last part, where we have the Save checkbox */ | |
| 604 | dialog->save_pounce = gtk_check_button_new_with_mnemonic( | |
| 605 | _("_Save this pounce after activation")); | |
| 606 | ||
| 607 | gtk_box_pack_start(GTK_BOX(vbox2), dialog->save_pounce, FALSE, FALSE, 0); | |
| 608 | ||
| 609 | /* Separator... */ | |
| 610 | sep = gtk_hseparator_new(); | |
| 611 | gtk_box_pack_start(GTK_BOX(vbox1), sep, FALSE, FALSE, 0); | |
| 612 | gtk_widget_show(sep); | |
| 613 | ||
| 614 | /* Now the button box! */ | |
| 615 | bbox = gtk_hbutton_box_new(); | |
| 616 | gtk_box_set_spacing(GTK_BOX(bbox), 6); | |
| 617 | gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
| 618 | gtk_box_pack_end(GTK_BOX(vbox1), bbox, FALSE, FALSE, 0); | |
| 619 | gtk_widget_show(bbox); | |
| 620 | ||
|
5052
8df6b6a43a49
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
621 | /* Delete button */ |
|
8df6b6a43a49
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
622 | button = gtk_button_new_from_stock(GTK_STOCK_DELETE); |
|
8df6b6a43a49
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
623 | gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); |
|
8df6b6a43a49
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
624 | gtk_widget_show(button); |
|
8df6b6a43a49
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
625 | |
|
8df6b6a43a49
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
626 | g_signal_connect(G_OBJECT(button), "clicked", |
|
8df6b6a43a49
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
627 | G_CALLBACK(delete_cb), dialog); |
|
8df6b6a43a49
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
628 | |
| 5032 | 629 | /* Cancel button */ |
| 630 | button = gtk_button_new_from_stock(GTK_STOCK_CANCEL); | |
| 631 | gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
| 632 | gtk_widget_show(button); | |
| 633 | ||
| 634 | g_signal_connect(G_OBJECT(button), "clicked", | |
| 635 | G_CALLBACK(cancel_cb), dialog); | |
| 636 | ||
| 637 | /* OK button */ | |
| 638 | button = gtk_button_new_from_stock(GTK_STOCK_OK); | |
| 639 | gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
| 640 | gtk_widget_show(button); | |
| 641 | ||
| 642 | g_signal_connect(G_OBJECT(button), "clicked", | |
| 643 | G_CALLBACK(save_pounce_cb), dialog); | |
| 644 | ||
| 645 | /* Set the values of stuff. */ | |
| 646 | if (cur_pounce != NULL) { | |
| 647 | GaimPounceEvent events; | |
| 648 | GaimGtkPounceAction actions; | |
| 649 | struct gaim_gtkpounce_data *pounce_data; | |
| 650 | ||
| 651 | pounce_data = GAIM_GTKPOUNCE(cur_pounce); | |
| 652 | events = gaim_pounce_get_events(cur_pounce); | |
| 653 | actions = pounce_data->actions; | |
| 654 | ||
| 655 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->signon), | |
| 656 | (events & GAIM_POUNCE_SIGNON)); | |
| 657 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->signoff), | |
| 658 | (events & GAIM_POUNCE_SIGNOFF)); | |
| 659 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->away), | |
| 660 | (events & GAIM_POUNCE_AWAY)); | |
| 661 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->away_return), | |
| 662 | (events & GAIM_POUNCE_AWAY_RETURN)); | |
| 663 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->idle), | |
| 664 | (events & GAIM_POUNCE_IDLE)); | |
| 665 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->idle_return), | |
| 666 | (events & GAIM_POUNCE_IDLE_RETURN)); | |
| 667 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->typing), | |
| 668 | (events & GAIM_POUNCE_TYPING)); | |
| 669 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->stop_typing), | |
| 670 | (events & GAIM_POUNCE_TYPING_STOPPED)); | |
| 671 | ||
| 672 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->open_win), | |
| 673 | (actions & GAIM_GTKPOUNCE_OPEN_WIN)); | |
| 674 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->popup), | |
| 675 | (actions & GAIM_GTKPOUNCE_POPUP)); | |
| 676 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->send_msg), | |
| 677 | (actions & GAIM_GTKPOUNCE_SEND_MSG)); | |
| 678 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->exec_cmd), | |
| 679 | (actions & GAIM_GTKPOUNCE_EXEC_CMD)); | |
| 680 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->play_sound), | |
| 681 | (actions & GAIM_GTKPOUNCE_PLAY_SOUND)); | |
| 682 | ||
| 683 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->save_pounce), | |
| 684 | pounce_data->save); | |
| 685 | ||
| 686 | gtk_entry_set_text(GTK_ENTRY(dialog->send_msg_entry), | |
| 687 | pounce_data->message); | |
| 688 | gtk_entry_set_text(GTK_ENTRY(dialog->exec_cmd_entry), | |
| 689 | pounce_data->command); | |
| 690 | gtk_entry_set_text(GTK_ENTRY(dialog->play_sound_entry), | |
| 691 | pounce_data->sound); | |
| 692 | } | |
| 693 | else { | |
| 694 | /* Set some defaults */ | |
| 695 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->send_msg), TRUE); | |
| 696 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->signon), TRUE); | |
| 697 | } | |
| 698 | ||
| 699 | gtk_widget_show_all(vbox2); | |
| 700 | gtk_widget_show(window); | |
| 701 | } | |
| 702 | ||
| 703 | static void | |
| 704 | new_pounce_cb(GtkWidget *w, struct buddy *b) | |
| 705 | { | |
| 706 | gaim_gtkpounce_dialog_show(b, NULL); | |
| 707 | } | |
| 708 | ||
| 709 | static void | |
|
5153
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
710 | delete_pounce_cb(GtkWidget *w, struct gaim_pounce *pounce) |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
711 | { |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
712 | gaim_pounce_destroy(pounce); |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
713 | } |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
714 | |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
715 | static void |
| 5032 | 716 | edit_pounce_cb(GtkWidget *w, struct gaim_pounce *pounce) |
| 717 | { | |
| 718 | struct buddy *buddy; | |
| 719 | ||
| 720 | buddy = gaim_find_buddy(gaim_pounce_get_pouncer(pounce), | |
| 721 | gaim_pounce_get_pouncee(pounce)); | |
| 722 | ||
| 723 | gaim_gtkpounce_dialog_show(buddy, pounce); | |
| 724 | } | |
| 725 | ||
|
5153
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
726 | static void |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
727 | fill_menu(GtkWidget *menu, GCallback cb) |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
728 | { |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
729 | GtkWidget *box; |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
730 | GtkWidget *label; |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
731 | GtkWidget *image; |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
732 | GtkWidget *item; |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
733 | GdkPixbuf *pixbuf, *scale; |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
734 | struct gaim_pounce *pounce; |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
735 | const char *buddy; |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
736 | GtkSizeGroup *sg; |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
737 | GList *bp; |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
738 | |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
739 | sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
740 | |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
741 | for (bp = gaim_get_pounces(); bp != NULL; bp = bp->next) { |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
742 | pounce = (struct gaim_pounce *)bp->data; |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
743 | buddy = gaim_pounce_get_pouncee(pounce); |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
744 | |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
745 | /* Create a pixmap for the protocol icon. */ |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
746 | pixbuf = create_prpl_icon(gaim_pounce_get_pouncer(pounce)); |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
747 | scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, GDK_INTERP_BILINEAR); |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
748 | |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
749 | /* Now convert it to GtkImage */ |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
750 | if (pixbuf == NULL) |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
751 | image = gtk_image_new(); |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
752 | else |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
753 | image = gtk_image_new_from_pixbuf(scale); |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
754 | |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
755 | gtk_size_group_add_widget(sg, image); |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
756 | |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
757 | g_object_unref(G_OBJECT(scale)); |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
758 | g_object_unref(G_OBJECT(pixbuf)); |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
759 | |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
760 | /* Build the menu item */ |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
761 | item = gtk_menu_item_new_with_label(buddy); |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
762 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
763 | gtk_widget_show(item); |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
764 | |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
765 | /* Do some evil, see some evil, speak some evil, continued. */ |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
766 | box = gtk_hbox_new(FALSE, 0); |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
767 | |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
768 | label = gtk_bin_get_child(GTK_BIN(item)); |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
769 | g_object_ref(label); |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
770 | gtk_container_remove(GTK_CONTAINER(item), label); |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
771 | |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
772 | gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0); |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
773 | gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 4); |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
774 | |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
775 | g_object_unref(label); |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
776 | |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
777 | gtk_container_add(GTK_CONTAINER(item), box); |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
778 | |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
779 | gtk_widget_show(label); |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
780 | gtk_widget_show(image); |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
781 | gtk_widget_show(box); |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
782 | |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
783 | /* Set our callbacks. */ |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
784 | g_signal_connect(G_OBJECT(item), "activate", cb, pounce); |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
785 | } |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
786 | |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
787 | g_object_unref(sg); |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
788 | } |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
789 | |
| 5032 | 790 | void |
| 791 | gaim_gtkpounce_menu_build(GtkWidget *menu) | |
| 792 | { | |
|
5153
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
793 | GtkWidget *remmenu; |
|
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
794 | GtkWidget *item; |
| 5032 | 795 | GList *l; |
| 796 | ||
| 797 | for (l = gtk_container_get_children(GTK_CONTAINER(menu)); | |
| 798 | l != NULL; | |
| 799 | l = l->next) { | |
| 800 | ||
| 801 | gtk_widget_destroy(GTK_WIDGET(l->data)); | |
| 802 | } | |
| 803 | ||
| 804 | /* "New Buddy Pounce" */ | |
| 805 | item = gtk_menu_item_new_with_label(_("New Buddy Pounce")); | |
| 806 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); | |
| 807 | gtk_widget_show(item); | |
| 808 | g_signal_connect(G_OBJECT(item), "activate", | |
| 809 | G_CALLBACK(new_pounce_cb), NULL); | |
| 810 | ||
| 811 | /* "Remove Buddy Pounce" */ | |
| 812 | item = gtk_menu_item_new_with_label(_("Remove Buddy Pounce")); | |
| 813 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); | |
| 814 | ||
| 815 | /* "Remove Buddy Pounce" menu */ | |
| 816 | remmenu = gtk_menu_new(); | |
| 817 | ||
|
5153
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
818 | fill_menu(remmenu, G_CALLBACK(delete_pounce_cb)); |
| 5032 | 819 | |
| 820 | gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), remmenu); | |
| 821 | gtk_widget_show(remmenu); | |
| 822 | gtk_widget_show(item); | |
| 823 | ||
| 824 | /* Separator */ | |
| 825 | item = gtk_separator_menu_item_new(); | |
| 826 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); | |
| 827 | gtk_widget_show(item); | |
| 828 | ||
|
5153
4865538db77a
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
829 | fill_menu(menu, G_CALLBACK(edit_pounce_cb)); |
| 5032 | 830 | } |
| 831 |