Mercurial > pidgin.yaz
comparison src/dialogs.c @ 6334:930708df05dd
[gaim-migrate @ 6833]
When I got back from swimming, I found a bunch of IMs and chat requests
from some annoying user who kept asking if I was dumb or dead. I decided to
block this user, but realized just how ugly the dialog for doing so is. So,
I rewrote it. Now I can block him in peace.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Wed, 30 Jul 2003 01:45:31 +0000 |
parents | b7f983d1392c |
children | 7a34722b3164 |
comparison
equal
deleted
inserted
replaced
6333:e06e04e44914 | 6334:930708df05dd |
---|---|
82 GtkWidget *entry_for_alias; | 82 GtkWidget *entry_for_alias; |
83 GtkWidget *account; | 83 GtkWidget *account; |
84 GaimConnection *gc; | 84 GaimConnection *gc; |
85 }; | 85 }; |
86 | 86 |
87 struct addperm { | |
88 GtkWidget *window; | |
89 GtkWidget *entry; | |
90 GaimConnection *gc; | |
91 gboolean permit; | |
92 }; | |
93 | |
94 struct findbyemail { | 87 struct findbyemail { |
95 GtkWidget *window; | 88 GtkWidget *window; |
96 GtkWidget *emailentry; | 89 GtkWidget *emailentry; |
97 GaimConnection *gc; | 90 GaimConnection *gc; |
98 }; | 91 }; |
120 GtkWidget *window; | 113 GtkWidget *window; |
121 GtkWidget *entry; | 114 GtkWidget *entry; |
122 GtkWidget *account; | 115 GtkWidget *account; |
123 GaimConnection *gc; | 116 GaimConnection *gc; |
124 }; | 117 }; |
118 | |
119 typedef struct | |
120 { | |
121 char *username; | |
122 gboolean block; | |
123 GaimConnection *gc; | |
124 | |
125 } GaimGtkBlockData; | |
125 | 126 |
126 static GSList *info_dlgs = NULL; | 127 static GSList *info_dlgs = NULL; |
127 | 128 |
128 static struct info_dlg *find_info_dlg(GaimConnection *gc, const char *who) | 129 static struct info_dlg *find_info_dlg(GaimConnection *gc, const char *who) |
129 { | 130 { |
377 | 378 |
378 dialogwindows = g_list_prepend(dialogwindows, w->window); | 379 dialogwindows = g_list_prepend(dialogwindows, w->window); |
379 gtk_widget_show_all(w->window); | 380 gtk_widget_show_all(w->window); |
380 } | 381 } |
381 | 382 |
382 void do_remove_chat(struct chat *chat) | 383 static void |
384 do_remove_chat(struct chat *chat) | |
383 { | 385 { |
384 gaim_blist_remove_chat(chat); | 386 gaim_blist_remove_chat(chat); |
385 gaim_blist_save(); | 387 gaim_blist_save(); |
386 } | 388 } |
387 | 389 |
388 void do_remove_buddy(struct buddy *b) | 390 static void |
391 do_remove_buddy(struct buddy *b) | |
389 { | 392 { |
390 struct group *g; | 393 struct group *g; |
391 GaimConversation *c; | 394 GaimConversation *c; |
392 gchar *name; | 395 gchar *name; |
393 | 396 |
2316 | 2319 |
2317 /*------------------------------------------------------------------------*/ | 2320 /*------------------------------------------------------------------------*/ |
2318 /* The dialog for adding to permit/deny */ | 2321 /* The dialog for adding to permit/deny */ |
2319 /*------------------------------------------------------------------------*/ | 2322 /*------------------------------------------------------------------------*/ |
2320 | 2323 |
2321 | 2324 static void |
2322 static void do_add_perm(GtkWidget *w, struct addperm *p) | 2325 destroy_block_data_cb(GaimGtkBlockData *data) |
2323 { | 2326 { |
2324 | 2327 g_free(data->username); |
2325 const char *who; | 2328 g_free(data); |
2326 | 2329 } |
2327 who = gtk_entry_get_text(GTK_ENTRY(p->entry)); | 2330 |
2328 | 2331 static void |
2329 if (!p->permit) { | 2332 block_unblock_cb(GaimGtkBlockData *data) |
2330 if (gaim_privacy_deny_add(p->gc->account, who)) { | 2333 { |
2331 serv_add_deny(p->gc, who); | 2334 GaimAccount *account; |
2335 | |
2336 account = gaim_connection_get_account(data->gc); | |
2337 | |
2338 if (data->block) { | |
2339 if (gaim_privacy_deny_add(account, data->username)) { | |
2340 serv_add_deny(data->gc, data->username); | |
2332 build_block_list(); | 2341 build_block_list(); |
2333 gaim_blist_save(); | 2342 gaim_blist_save(); |
2334 } | 2343 } |
2335 } else { | 2344 } |
2336 if (gaim_privacy_permit_add(p->gc->account, who)) { | 2345 else { |
2337 serv_add_permit(p->gc, who); | 2346 if (gaim_privacy_permit_add(account, data->username)) { |
2347 serv_add_permit(data->gc, data->username); | |
2338 build_allow_list(); | 2348 build_allow_list(); |
2339 gaim_blist_save(); | 2349 gaim_blist_save(); |
2340 } | 2350 } |
2341 } | 2351 } |
2342 | 2352 |
2343 destroy_dialog(NULL, p->window); | 2353 destroy_block_data_cb(data); |
2344 } | 2354 } |
2345 | 2355 |
2346 | 2356 void |
2347 | 2357 show_add_perm(GaimConnection *gc, char *who, gboolean permit) |
2348 void show_add_perm(GaimConnection *gc, char *who, gboolean permit) | 2358 { |
2349 { | 2359 char *primary, *secondary; |
2350 GtkWidget *cancel; | 2360 GaimGtkBlockData *data; |
2351 GtkWidget *add; | 2361 |
2352 GtkWidget *label; | 2362 data = g_new0(GaimGtkBlockData, 1); |
2353 GtkWidget *bbox; | 2363 |
2354 GtkWidget *vbox; | 2364 data->gc = gc; |
2355 GtkWidget *topbox; | 2365 data->block = !permit; |
2356 | 2366 data->username = g_strdup(who); |
2357 struct addperm *p = g_new0(struct addperm, 1); | 2367 |
2358 p->gc = gc; | 2368 if (permit) { |
2359 p->permit = permit; | 2369 primary = g_strdup_printf(_("Unblock %s?"), who); |
2360 | 2370 secondary = g_strdup_printf( |
2361 GAIM_DIALOG(p->window); | 2371 _("You are about to unblock %s. This will allow %s " |
2362 gtk_container_set_border_width(GTK_CONTAINER(p->window), 5); | 2372 "to speak to you again. Do you want to continue?"), |
2363 gtk_window_set_resizable(GTK_WINDOW(p->window), FALSE); | 2373 who, who); |
2364 gtk_widget_realize(p->window); | 2374 |
2365 | 2375 gaim_request_action(gc, _("Unblock User"), primary, secondary, |
2366 dialogwindows = g_list_prepend(dialogwindows, p->window); | 2376 0, data, 2, |
2367 | 2377 _("Unblock"), G_CALLBACK(block_unblock_cb), |
2368 bbox = gtk_hbox_new(FALSE, 5); | 2378 _("Cancel"), G_CALLBACK(destroy_block_data_cb)); |
2369 topbox = gtk_hbox_new(FALSE, 5); | 2379 } |
2370 vbox = gtk_vbox_new(FALSE, 5); | |
2371 p->entry = gtk_entry_new(); | |
2372 | |
2373 /* Build Add Button */ | |
2374 | |
2375 if (permit) | |
2376 add = gaim_pixbuf_button_from_stock(_("Permit"), GTK_STOCK_ADD, GAIM_BUTTON_HORIZONTAL); | |
2377 else | 2380 else |
2378 add = gaim_pixbuf_button_from_stock(_("Deny"), GTK_STOCK_ADD, GAIM_BUTTON_HORIZONTAL); | 2381 { |
2379 cancel = gaim_pixbuf_button_from_stock(_("Cancel"), GTK_STOCK_CANCEL, GAIM_BUTTON_HORIZONTAL); | 2382 primary = g_strdup_printf(_("Block %s?"), who); |
2380 | 2383 secondary = g_strdup_printf( |
2381 /* End of Cancel Button */ | 2384 _("You are about to block %s. This will prevent %s " |
2382 if (who != NULL) | 2385 "from speaking to you again. Do you want to continue?"), |
2383 gtk_entry_set_text(GTK_ENTRY(p->entry), who); | 2386 who, who); |
2384 | 2387 |
2385 /* Put the buttons in the box */ | 2388 gaim_request_action(gc, _("Unblock User"), primary, secondary, |
2386 | 2389 0, data, 2, |
2387 gtk_box_pack_end(GTK_BOX(bbox), add, FALSE, FALSE, 5); | 2390 _("Block"), G_CALLBACK(block_unblock_cb), |
2388 gtk_box_pack_end(GTK_BOX(bbox), cancel, FALSE, FALSE, 5); | 2391 _("Cancel"), G_CALLBACK(destroy_block_data_cb)); |
2389 | 2392 } |
2390 label = gtk_label_new(_("Add")); | 2393 |
2391 gtk_box_pack_start(GTK_BOX(topbox), label, FALSE, FALSE, 5); | 2394 g_free(primary); |
2392 gtk_box_pack_start(GTK_BOX(topbox), p->entry, FALSE, FALSE, 5); | 2395 g_free(secondary); |
2393 /* And the boxes in the box */ | |
2394 gtk_box_pack_start(GTK_BOX(vbox), topbox, TRUE, TRUE, 5); | |
2395 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 5); | |
2396 topbox=gtk_hbox_new(FALSE, 5); | |
2397 gtk_box_pack_start(GTK_BOX(topbox), vbox, FALSE, FALSE, 5); | |
2398 | |
2399 | |
2400 /* Handle closes right */ | |
2401 g_signal_connect(G_OBJECT(p->window), "destroy", G_CALLBACK(destroy_dialog), p->window); | |
2402 g_signal_connect(G_OBJECT(cancel), "clicked", G_CALLBACK(destroy_dialog), p->window); | |
2403 g_signal_connect(G_OBJECT(add), "clicked", G_CALLBACK(do_add_perm), p); | |
2404 g_signal_connect(G_OBJECT(p->entry), "activate", G_CALLBACK(do_add_perm), p); | |
2405 | |
2406 /* Finish up */ | |
2407 if (permit) | |
2408 gtk_window_set_title(GTK_WINDOW(p->window), _("Add Permit")); | |
2409 else | |
2410 gtk_window_set_title(GTK_WINDOW(p->window), _("Add Deny")); | |
2411 gtk_window_set_focus(GTK_WINDOW(p->window), p->entry); | |
2412 gtk_container_add(GTK_CONTAINER(p->window), topbox); | |
2413 gtk_widget_realize(p->window); | |
2414 | |
2415 gtk_widget_show_all(p->window); | |
2416 } | 2396 } |
2417 | 2397 |
2418 | 2398 |
2419 /*------------------------------------------------------------------------*/ | 2399 /*------------------------------------------------------------------------*/ |
2420 /* Functions Called To Add A Log */ | 2400 /* Functions Called To Add A Log */ |