Mercurial > pidgin.yaz
comparison src/dialogs.c @ 5436:ad445074d239
[gaim-migrate @ 5818]
Another big commit. Ugh. I need a very smart regexp.
Core/UI split do_error_dialog(), and soon the mail dialogs! Yay! This
should work without problems at all, but standard disclaimer..
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Sun, 18 May 2003 19:59:02 +0000 |
parents | 2c4188300aba |
children | cce2d7868c78 |
comparison
equal
deleted
inserted
replaced
5435:a2f26666de42 | 5436:ad445074d239 |
---|---|
47 #include <gtk/gtk.h> | 47 #include <gtk/gtk.h> |
48 #include "gaim.h" | 48 #include "gaim.h" |
49 #include "gtkimhtml.h" | 49 #include "gtkimhtml.h" |
50 #include "prpl.h" | 50 #include "prpl.h" |
51 #include "gtkblist.h" | 51 #include "gtkblist.h" |
52 #include "notify.h" | |
52 | 53 |
53 #ifdef _WIN32 | 54 #ifdef _WIN32 |
54 #include "win32dep.h" | 55 #include "win32dep.h" |
55 #endif | 56 #endif |
56 | 57 |
484 } | 485 } |
485 | 486 |
486 /*------------------------------------------------------------------------*/ | 487 /*------------------------------------------------------------------------*/ |
487 /* The dialog for getting an error */ | 488 /* The dialog for getting an error */ |
488 /*------------------------------------------------------------------------*/ | 489 /*------------------------------------------------------------------------*/ |
489 | |
490 GtkWidget *do_error_dialog(const char *primary, const char *secondary, int type) | |
491 { | |
492 GtkWidget *d; | |
493 GtkWidget *label; | |
494 GtkWidget *img = NULL; | |
495 GtkWidget *hbox; | |
496 char labeltext[1024 * 2]; | |
497 const char *name = NULL; | |
498 | |
499 /* These are the GTK stock dialog icons with our little Gaim logo on top. | |
500 * Inspired by the GIMP. */ | |
501 switch (type){ | |
502 case GAIM_LOGO: | |
503 name = GAIM_STOCK_ICON_ONLINE; | |
504 break; | |
505 case GAIM_INFO: | |
506 name = GAIM_STOCK_DIALOG_INFO; | |
507 break; | |
508 case GAIM_WARNING: | |
509 name = GAIM_STOCK_DIALOG_WARNING; | |
510 break; | |
511 case GAIM_ERROR: | |
512 name = GAIM_STOCK_DIALOG_ERROR; | |
513 break; | |
514 } | |
515 | |
516 if (name) { | |
517 img = gtk_image_new_from_stock(name, GTK_ICON_SIZE_DIALOG); | |
518 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
519 } | |
520 | |
521 d = gtk_dialog_new_with_buttons("", NULL, 0, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); | |
522 g_signal_connect(d, "response", G_CALLBACK(gtk_widget_destroy), NULL); | |
523 | |
524 gtk_container_set_border_width (GTK_CONTAINER(d), 6); | |
525 gtk_window_set_resizable(GTK_WINDOW(d), FALSE); | |
526 gtk_dialog_set_has_separator(GTK_DIALOG(d), FALSE); | |
527 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(d)->vbox), 12); | |
528 gtk_container_set_border_width (GTK_CONTAINER(GTK_DIALOG(d)->vbox), 6); | |
529 | |
530 hbox = gtk_hbox_new(FALSE, 12); | |
531 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(d)->vbox), hbox); | |
532 if (img) { | |
533 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
534 } | |
535 | |
536 g_snprintf(labeltext, sizeof(labeltext), "<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s", primary, secondary ? secondary : ""); | |
537 | |
538 label = gtk_label_new(NULL); | |
539 gtk_label_set_markup(GTK_LABEL(label), labeltext); | |
540 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
541 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
542 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
543 | |
544 gtk_widget_show_all(d); | |
545 | |
546 return d; | |
547 } | |
548 | |
549 static void do_im(GtkWidget *widget, int resp, struct getuserinfo *info) | 490 static void do_im(GtkWidget *widget, int resp, struct getuserinfo *info) |
550 { | 491 { |
551 const char *who; | 492 const char *who; |
552 struct gaim_conversation *conv; | 493 struct gaim_conversation *conv; |
553 struct gaim_account *account; | 494 struct gaim_account *account; |
1399 } | 1340 } |
1400 } | 1341 } |
1401 } | 1342 } |
1402 | 1343 |
1403 if (!ac->account) { | 1344 if (!ac->account) { |
1404 do_error_dialog( | 1345 gaim_notify_error(NULL, NULL, |
1405 _("You are not currently signed on with any protocols " | 1346 _("You are not currently signed on with any " |
1406 "that have the ability to chat."), NULL, GAIM_ERROR); | 1347 "protocols that have the ability to chat."), NULL); |
1407 return; | 1348 return; |
1408 } | 1349 } |
1409 | 1350 |
1410 ac->sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); | 1351 ac->sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
1411 | 1352 |
1412 ac->window = gtk_dialog_new_with_buttons(_("Add Chat"), | 1353 ac->window = gtk_dialog_new_with_buttons(_("Add Chat"), |
2157 orig = gtk_entry_get_text(GTK_ENTRY(b->original)); | 2098 orig = gtk_entry_get_text(GTK_ENTRY(b->original)); |
2158 new1 = gtk_entry_get_text(GTK_ENTRY(b->new1)); | 2099 new1 = gtk_entry_get_text(GTK_ENTRY(b->new1)); |
2159 new2 = gtk_entry_get_text(GTK_ENTRY(b->new2)); | 2100 new2 = gtk_entry_get_text(GTK_ENTRY(b->new2)); |
2160 | 2101 |
2161 if (g_utf8_collate(new1, new2)) { | 2102 if (g_utf8_collate(new1, new2)) { |
2162 do_error_dialog(_("New Passwords Do Not Match"), NULL, GAIM_ERROR); | 2103 gaim_notify_error(NULL, NULL, |
2104 _("New passwords do not match."), NULL); | |
2163 return; | 2105 return; |
2164 } | 2106 } |
2165 | 2107 |
2166 if ((strlen(orig) < 1) || (strlen(new1) < 1) || (strlen(new2) < 1)) { | 2108 if ((strlen(orig) < 1) || (strlen(new1) < 1) || (strlen(new2) < 1)) { |
2167 do_error_dialog(_("Fill out all fields completely"), NULL, GAIM_ERROR); | 2109 gaim_notify_error(NULL, NULL, |
2110 _("Fill out all fields completely."), NULL); | |
2168 return; | 2111 return; |
2169 } | 2112 } |
2170 | 2113 |
2171 serv_change_passwd(b->gc, orig, new1); | 2114 serv_change_passwd(b->gc, orig, new1); |
2172 g_snprintf(b->gc->account->password, sizeof(b->gc->account->password), "%s", new1); | 2115 g_snprintf(b->gc->account->password, sizeof(b->gc->account->password), "%s", new1); |
3309 int check_away_mess(struct create_away *ca, int type) | 3252 int check_away_mess(struct create_away *ca, int type) |
3310 { | 3253 { |
3311 char *msg; | 3254 char *msg; |
3312 if ((strlen(gtk_entry_get_text(GTK_ENTRY(ca->entry))) == 0) && (type == 1)) { | 3255 if ((strlen(gtk_entry_get_text(GTK_ENTRY(ca->entry))) == 0) && (type == 1)) { |
3313 /* We shouldn't allow a blank title */ | 3256 /* We shouldn't allow a blank title */ |
3314 do_error_dialog(_("You cannot save an away message with a blank title"), | 3257 gaim_notify_error(NULL, NULL, |
3315 _("Please give the message a title, or choose \"Use\" to use " | 3258 _("You cannot save an away message with a " |
3316 "without saving."), GAIM_ERROR); | 3259 "blank title"), |
3260 _("Please give the message a title, or choose " | |
3261 "\"Use\" to use without saving.")); | |
3317 return 0; | 3262 return 0; |
3318 } | 3263 } |
3319 | 3264 |
3320 msg = gtk_text_view_get_text(GTK_TEXT_VIEW(ca->text), FALSE); | 3265 msg = gtk_text_view_get_text(GTK_TEXT_VIEW(ca->text), FALSE); |
3321 | 3266 |
3322 if (!msg && (type <= 1)) { | 3267 if (!msg && (type <= 1)) { |
3323 /* We shouldn't allow a blank message */ | 3268 /* We shouldn't allow a blank message */ |
3324 do_error_dialog(_("You cannot create an empty away message"), NULL, GAIM_ERROR); | 3269 gaim_notify_error(NULL, NULL, |
3270 _("You cannot create an empty away message"), NULL); | |
3325 return 0; | 3271 return 0; |
3326 } | 3272 } |
3327 | 3273 |
3328 g_free(msg); | 3274 g_free(msg); |
3329 | 3275 |
3843 return; | 3789 return; |
3844 | 3790 |
3845 if ((fp_new = fopen(path, "w")) == NULL) { | 3791 if ((fp_new = fopen(path, "w")) == NULL) { |
3846 g_snprintf(error, BUF_LONG, | 3792 g_snprintf(error, BUF_LONG, |
3847 _("Couldn't write to %s."), path); | 3793 _("Couldn't write to %s."), path); |
3848 do_error_dialog(error, strerror(errno), GAIM_ERROR); | 3794 gaim_notify_error(NULL, NULL, error, strerror(errno)); |
3849 return; | 3795 return; |
3850 } | 3796 } |
3851 | 3797 |
3852 if ((fp_old = fopen(filename, "r")) == NULL) { | 3798 if ((fp_old = fopen(filename, "r")) == NULL) { |
3853 g_snprintf(error, BUF_LONG, | 3799 g_snprintf(error, BUF_LONG, |
3854 _("Couldn't write to %s."), filename); | 3800 _("Couldn't write to %s."), filename); |
3855 do_error_dialog(error, strerror(errno), GAIM_ERROR); | 3801 gaim_notify_error(NULL, NULL, error, strerror(errno)); |
3856 fclose(fp_new); | 3802 fclose(fp_new); |
3857 return; | 3803 return; |
3858 } | 3804 } |
3859 | 3805 |
3860 while (fgets(buf, BUF_LONG, fp_old)) | 3806 while (fgets(buf, BUF_LONG, fp_old)) |
3904 g_snprintf(filename, 256, "%s" G_DIR_SEPARATOR_S "logs" G_DIR_SEPARATOR_S "%s%s", tmp, | 3850 g_snprintf(filename, 256, "%s" G_DIR_SEPARATOR_S "logs" G_DIR_SEPARATOR_S "%s%s", tmp, |
3905 name ? normalize(name) : "system", name ? ".log" : ""); | 3851 name ? normalize(name) : "system", name ? ".log" : ""); |
3906 | 3852 |
3907 if ((remove(filename)) == -1) { | 3853 if ((remove(filename)) == -1) { |
3908 g_snprintf(buf, 256, _("Couldn't remove file %s." ), filename); | 3854 g_snprintf(buf, 256, _("Couldn't remove file %s." ), filename); |
3909 do_error_dialog(buf, strerror(errno), GAIM_ERROR); | 3855 gaim_notify_error(NULL, NULL, buf, strerror(errno)); |
3910 } | 3856 } |
3911 | 3857 |
3912 window = g_object_get_data(G_OBJECT(w), "log_window"); | 3858 window = g_object_get_data(G_OBJECT(w), "log_window"); |
3913 destroy_dialog(NULL, window); | 3859 destroy_dialog(NULL, window); |
3914 } | 3860 } |
3977 g_snprintf(filename, 256, "%s" G_DIR_SEPARATOR_S "logs" G_DIR_SEPARATOR_S "system", tmp); | 3923 g_snprintf(filename, 256, "%s" G_DIR_SEPARATOR_S "logs" G_DIR_SEPARATOR_S "system", tmp); |
3978 } | 3924 } |
3979 if ((fp = fopen(filename, "r")) == NULL) { | 3925 if ((fp = fopen(filename, "r")) == NULL) { |
3980 if (view->name) { | 3926 if (view->name) { |
3981 g_snprintf(buf, BUF_LONG, _("Couldn't open log file %s."), filename); | 3927 g_snprintf(buf, BUF_LONG, _("Couldn't open log file %s."), filename); |
3982 do_error_dialog(buf, strerror(errno), GAIM_ERROR); | 3928 gaim_notify_error(NULL, NULL, buf, strerror(errno)); |
3983 } | 3929 } |
3984 /* If the system log doesn't exist.. no message just show empty system log window. | 3930 /* If the system log doesn't exist.. no message just show empty system log window. |
3985 That way user knows that the log is empty :) | 3931 That way user knows that the log is empty :) |
3986 */ | 3932 */ |
3987 return; | 3933 return; |
4139 if (name) { | 4085 if (name) { |
4140 char *tmp = gaim_user_dir(); | 4086 char *tmp = gaim_user_dir(); |
4141 g_snprintf(filename, 256, "%s" G_DIR_SEPARATOR_S "logs" G_DIR_SEPARATOR_S "%s.log", tmp, normalize(name)); | 4087 g_snprintf(filename, 256, "%s" G_DIR_SEPARATOR_S "logs" G_DIR_SEPARATOR_S "%s.log", tmp, normalize(name)); |
4142 if ((fp = fopen(filename, "r")) == NULL) { | 4088 if ((fp = fopen(filename, "r")) == NULL) { |
4143 g_snprintf(buf, BUF_LONG, _("Couldn't open log file %s"), filename); | 4089 g_snprintf(buf, BUF_LONG, _("Couldn't open log file %s"), filename); |
4144 do_error_dialog(buf, strerror(errno), GAIM_ERROR); | 4090 gaim_notify_error(NULL, NULL, buf, strerror(errno)); |
4145 return; | 4091 return; |
4146 } | 4092 } |
4147 | 4093 |
4148 list_store = gtk_list_store_new(2, | 4094 list_store = gtk_list_store_new(2, |
4149 G_TYPE_STRING, | 4095 G_TYPE_STRING, |