comparison src/dialogs.c @ 3427:8fa61405af2b

[gaim-migrate @ 3453] Who never commits anything *now*, Etan? I changed most of the error message text around. If you think any of it should be different, just let me know, or send a patch. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Sun, 25 Aug 2002 10:51:24 +0000
parents 3cd2fbddf95a
children 7a3f16a375a5
comparison
equal deleted inserted replaced
3426:ccbcc11a68c2 3427:8fa61405af2b
549 549
550 /*------------------------------------------------------------------------*/ 550 /*------------------------------------------------------------------------*/
551 /* The dialog for getting an error */ 551 /* The dialog for getting an error */
552 /*------------------------------------------------------------------------*/ 552 /*------------------------------------------------------------------------*/
553 553
554 GtkWidget *do_error_dialog(char *message, char *title) 554 GtkWidget *do_error_dialog(char *primary, char *secondary, int type)
555 { 555 {
556 GtkWidget *d; 556 GtkWidget *d;
557 GtkWidget *label; 557 GtkWidget *label;
558 GtkWidget *close; 558 GtkWidget *close;
559 GtkWidget *img = NULL; 559 GtkWidget *img = NULL;
560 /* 560 GtkWidget *hbox;
561 #if GTK_CHECK_VERSION(1,3,0) 561 char labeltext[1024 * 2];
562 char *filename; 562 char *filename = NULL;
563
564 /* These are the GTK stock dialog icons with our little Gaim logo on top.
565 * Inspired by the GIMP. */
563 switch (type){ 566 switch (type){
564 case GAIM_LOGO: 567 case GAIM_LOGO:
565 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "gaim.png", NULL); 568 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "gaim.png", NULL);
566 break; 569 break;
567 case GAIM_INFO: 570 case GAIM_INFO:
568 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "dialogs", "gaim_info.png", NULL); 571 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "dialogs", "gaim_info.png", NULL);
569 break; 572 break;
570 case GAIM_WARNING: 573 case GAIM_WARNING:
571 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "dialogs", "gaim_warning.png", NULL); 574 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "dialogs", "gaim_warning.png", NULL);
572 break; 575 break;
573 case GAIM_ERROR: 576 case GAIM_ERROR:
574 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "dialogs", "gaim_error.png", NULL); 577 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "dialogs", "gaim_error.png", NULL);
575 break; 578 break;
576 case GAIM_QUESTION: 579 /* case GAIM_QUESTION:
577 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "dialogs", "gaim_question.png", NULL); 580 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "dialogs", "gaim_question.png", NULL);
578 break; 581 break;
579 } 582 */
580 img = gtk_image_new_from_file(filename); 583 }
581 #endif 584 if (filename) {
582 */ 585 img = gtk_image_new_from_file(filename);
583 586 gtk_misc_set_alignment(GTK_MISC(img), 0, 0);
584 d = gtk_dialog_new(); 587 }
585 gtk_window_set_policy(GTK_WINDOW(d), FALSE, FALSE, TRUE); 588 d = gtk_dialog_new_with_buttons(NULL, NULL, GTK_DIALOG_MODAL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT);
586 gtk_widget_realize(d); 589 g_signal_connect(d, "response", G_CALLBACK(gtk_widget_destroy), NULL);
587 label = gtk_label_new(message); 590
591 gtk_container_set_border_width (GTK_CONTAINER(d), 6);
592 gtk_window_set_resizable(GTK_WINDOW(d), FALSE);
593 gtk_dialog_set_has_separator(GTK_DIALOG(d), FALSE);
594 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(d)->vbox), 12);
595 gtk_container_set_border_width (GTK_CONTAINER(GTK_DIALOG(d)->vbox), 6);
596
597 hbox = gtk_hbox_new(FALSE, 12);
598 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(d)->vbox), hbox);
599 if (filename) {
600 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);
601 }
602 gtk_widget_show(img);
603
604 g_snprintf(labeltext, sizeof(labeltext), "<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s", primary, secondary ? secondary : "");
605
606 label = gtk_label_new(NULL);
607 gtk_label_set_markup(GTK_LABEL(label), labeltext);
588 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); 608 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
609 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
589 gtk_widget_show(label); 610 gtk_widget_show(label);
590 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->vbox), label, FALSE, FALSE, 5); 611 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
591 612
592 close = picture_button(d, _("Close"), cancel_xpm); 613 gtk_widget_show(hbox);
593
594 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->action_area), close, FALSE, FALSE, 5);
595
596 gtk_container_set_border_width(GTK_CONTAINER(d), 5);
597 gtk_window_set_title(GTK_WINDOW(d), title);
598 gtk_signal_connect(GTK_OBJECT(close), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), d);
599 aol_icon(d->window); 614 aol_icon(d->window);
600 615
601 gtk_widget_show(d); 616 gtk_widget_show(d);
602 gtk_widget_grab_focus(close);
603 return d; 617 return d;
604 } 618 }
605 619
606 620
607 621
1541 void do_new_bp(GtkWidget *w, struct addbp *b) 1555 void do_new_bp(GtkWidget *w, struct addbp *b)
1542 { 1556 {
1543 struct buddy_pounce *bp; 1557 struct buddy_pounce *bp;
1544 1558
1545 if (strlen(gtk_entry_get_text(GTK_ENTRY(b->nameentry))) == 0) { 1559 if (strlen(gtk_entry_get_text(GTK_ENTRY(b->nameentry))) == 0) {
1546 do_error_dialog(_("Please enter a buddy to pounce."), _("Buddy Pounce Error")); 1560 do_error_dialog(_("Please enter a buddy to pounce."), NULL, GAIM_ERROR);
1547 return; 1561 return;
1548 } 1562 }
1549 1563
1550 if(!b->buddy_pounce) 1564 if(!b->buddy_pounce)
1551 bp = g_new0(struct buddy_pounce, 1); 1565 bp = g_new0(struct buddy_pounce, 1);
2107 orig = gtk_entry_get_text(GTK_ENTRY(b->original)); 2121 orig = gtk_entry_get_text(GTK_ENTRY(b->original));
2108 new1 = gtk_entry_get_text(GTK_ENTRY(b->new1)); 2122 new1 = gtk_entry_get_text(GTK_ENTRY(b->new1));
2109 new2 = gtk_entry_get_text(GTK_ENTRY(b->new2)); 2123 new2 = gtk_entry_get_text(GTK_ENTRY(b->new2));
2110 2124
2111 if (g_strcasecmp(new1, new2)) { 2125 if (g_strcasecmp(new1, new2)) {
2112 do_error_dialog(_("New Passwords Do Not Match"), _("Gaim - Change Password Error")); 2126 do_error_dialog(_("New Passwords Do Not Match"), NULL, GAIM_ERROR);
2113 return; 2127 return;
2114 } 2128 }
2115 2129
2116 if ((strlen(orig) < 1) || (strlen(new1) < 1) || (strlen(new2) < 1)) { 2130 if ((strlen(orig) < 1) || (strlen(new1) < 1) || (strlen(new2) < 1)) {
2117 do_error_dialog(_("Fill out all fields completely"), _("Gaim - Change Password Error")); 2131 do_error_dialog(_("Fill out all fields completely"), NULL, GAIM_ERROR);
2118 return; 2132 return;
2119 } 2133 }
2120 2134
2121 serv_change_passwd(b->gc, orig, new1); 2135 serv_change_passwd(b->gc, orig, new1);
2122 2136
3426 3440
3427 int check_away_mess(struct create_away *ca, int type) 3441 int check_away_mess(struct create_away *ca, int type)
3428 { 3442 {
3429 if ((strlen(gtk_entry_get_text(GTK_ENTRY(ca->entry))) == 0) && (type == 1)) { 3443 if ((strlen(gtk_entry_get_text(GTK_ENTRY(ca->entry))) == 0) && (type == 1)) {
3430 /* We shouldn't allow a blank title */ 3444 /* We shouldn't allow a blank title */
3431 do_error_dialog(_("You cannot create an away message with a blank title"), 3445 do_error_dialog(_("You cannot save an away message with a blank title"),
3432 _("Gaim - Error")); 3446 _("Please give the message a title, or choose \"Make Away\" to use "
3447 "without saving."), GAIM_ERROR);
3433 return 0; 3448 return 0;
3434 } 3449 }
3435 3450
3436 if ((gtk_text_get_length(GTK_TEXT(ca->text)) == 0) && (type <= 1)) { 3451 if ((gtk_text_get_length(GTK_TEXT(ca->text)) == 0) && (type <= 1)) {
3437 /* We shouldn't allow a blank message */ 3452 /* We shouldn't allow a blank message */
3438 do_error_dialog(_("You cannot create an empty away message"), _("Gaim - Error")); 3453 do_error_dialog(_("You cannot create an empty away message"), NULL, GAIM_ERROR);
3439 return 0; 3454 return 0;
3440 } 3455 }
3441 3456
3442 return 1; 3457 return 1;
3443 } 3458 }
3913 if (file_is_dir(path, filesel)) 3928 if (file_is_dir(path, filesel))
3914 return; 3929 return;
3915 3930
3916 if ((fp_new = fopen(path, "w")) == NULL) { 3931 if ((fp_new = fopen(path, "w")) == NULL) {
3917 g_snprintf(error, BUF_LONG, 3932 g_snprintf(error, BUF_LONG,
3918 "Can't open file %s for writing - %s", path, strerror(errno)); 3933 _("Couldn't write to %s."), path);
3919 do_error_dialog(error, "Error"); 3934 do_error_dialog(error, strerror(errno), GAIM_ERROR);
3920 return; 3935 return;
3921 } 3936 }
3922 3937
3923 if ((fp_old = fopen(filename, "r")) == NULL) { 3938 if ((fp_old = fopen(filename, "r")) == NULL) {
3924 g_snprintf(error, BUF_LONG, 3939 g_snprintf(error, BUF_LONG,
3925 "Can't open file %s for reading - %s", filename, strerror(errno)); 3940 _("Couldn't write to %s."), filename);
3926 do_error_dialog(error, "Error"); 3941 do_error_dialog(error, strerror(errno), GAIM_ERROR);
3927 fclose(fp_new); 3942 fclose(fp_new);
3928 return; 3943 return;
3929 } 3944 }
3930 3945
3931 while (fgets(buf, BUF_LONG, fp_old)) 3946 while (fgets(buf, BUF_LONG, fp_old))
3976 g_snprintf(filename, 256, "%s/logs/%s%s", tmp, 3991 g_snprintf(filename, 256, "%s/logs/%s%s", tmp,
3977 name ? normalize(name) : "system", name ? ".log" : ""); 3992 name ? normalize(name) : "system", name ? ".log" : "");
3978 g_free(tmp); 3993 g_free(tmp);
3979 3994
3980 if ((remove(filename)) == -1) { 3995 if ((remove(filename)) == -1) {
3981 g_snprintf(buf, 256, _("Unable to remove file %s - %s"), filename, strerror(errno)); 3996 g_snprintf(buf, 256, _("Couldn't remove file %s." ), filename);
3982 do_error_dialog(buf, _("Error")); 3997 do_error_dialog(buf, strerror(errno), GAIM_ERROR);
3983 } 3998 }
3984 3999
3985 window = gtk_object_get_user_data(GTK_OBJECT(w)); 4000 window = gtk_object_get_user_data(GTK_OBJECT(w));
3986 destroy_dialog(NULL, window); 4001 destroy_dialog(NULL, window);
3987 } 4002 }
4052 char *tmp = gaim_user_dir(); 4067 char *tmp = gaim_user_dir();
4053 g_snprintf(filename, 256, "%s/logs/system", tmp); 4068 g_snprintf(filename, 256, "%s/logs/system", tmp);
4054 g_free(tmp); 4069 g_free(tmp);
4055 } 4070 }
4056 if ((fp = fopen(filename, "r")) == NULL) { 4071 if ((fp = fopen(filename, "r")) == NULL) {
4057 g_snprintf(buf, BUF_LONG, "Unable to open log file %s", filename); 4072 g_snprintf(buf, BUF_LONG, "Couldn't open log file %s.", filename);
4058 do_error_dialog(buf, "Error!"); 4073 do_error_dialog(buf, strerror(errno), GAIM_ERROR);
4059 return; 4074 return;
4060 } 4075 }
4061 4076
4062 gtk_widget_set_sensitive(view->bbox, FALSE); 4077 gtk_widget_set_sensitive(view->bbox, FALSE);
4063 gtk_signal_disconnect_by_func(GTK_OBJECT(view->window), 4078 gtk_signal_disconnect_by_func(GTK_OBJECT(view->window),
4183 if (name) { 4198 if (name) {
4184 char *tmp = gaim_user_dir(); 4199 char *tmp = gaim_user_dir();
4185 g_snprintf(filename, 256, "%s/logs/%s.log", tmp, normalize(name)); 4200 g_snprintf(filename, 256, "%s/logs/%s.log", tmp, normalize(name));
4186 g_free(tmp); 4201 g_free(tmp);
4187 if ((fp = fopen(filename, "r")) == NULL) { 4202 if ((fp = fopen(filename, "r")) == NULL) {
4188 g_snprintf(buf, BUF_LONG, "Unable to open log file %s", filename); 4203 g_snprintf(buf, BUF_LONG, "Couldn't open log file %s", filename);
4189 do_error_dialog(buf, "Error!"); 4204 do_error_dialog(buf, strerror(errno), GAIM_ERROR);
4190 return; 4205 return;
4191 } 4206 }
4192 4207
4193 list = gtk_list_new(); 4208 list = gtk_list_new();
4194 4209
4601 gdk_window_set_icon(w, NULL, icon_pm, icon_bm); 4616 gdk_window_set_icon(w, NULL, icon_pm, icon_bm);
4602 if (mainwindow) 4617 if (mainwindow)
4603 gdk_window_set_group(w, mainwindow->window); 4618 gdk_window_set_group(w, mainwindow->window);
4604 #endif 4619 #endif
4605 } 4620 }
4606 4621
4607 #if GTK_CHECK_VERSION(1,3,0)
4608 GtkWidget *pixbuf_button(char *text, char *iconfile) 4622 GtkWidget *pixbuf_button(char *text, char *iconfile)
4609 { 4623 {
4610 GtkWidget *button, *image, *label, *bbox; 4624 GtkWidget *button, *image, *label, *bbox;
4611 button = gtk_button_new(); 4625 button = gtk_button_new();
4612 bbox = gtk_hbox_new(FALSE, 5); 4626 bbox = gtk_hbox_new(FALSE, 5);
4626 gtk_box_pack_start(GTK_BOX(bbox), label, FALSE, FALSE, 0); 4640 gtk_box_pack_start(GTK_BOX(bbox), label, FALSE, FALSE, 0);
4627 } 4641 }
4628 gtk_widget_show_all(bbox); 4642 gtk_widget_show_all(bbox);
4629 return button; 4643 return button;
4630 } 4644 }
4631 #endif 4645
4632 4646
4633 GtkWidget *picture_button(GtkWidget *window, char *text, char **xpm) 4647 GtkWidget *picture_button(GtkWidget *window, char *text, char **xpm)
4634 { 4648 {
4635 GtkWidget *button; 4649 GtkWidget *button;
4636 GtkWidget *button_box, *button_box_2, *button_box_3; 4650 GtkWidget *button_box, *button_box_2, *button_box_3;