comparison src/dialogs.c @ 3630:9682c0e022c6

[gaim-migrate @ 3753] Yeah this will probably break a lot of shit knowing my luck. But hey, I really don't care what people thnk. committer: Tailor Script <tailor@pidgin.im>
author Rob Flynn <gaim@robflynn.com>
date Fri, 11 Oct 2002 03:14:01 +0000
parents bdd0bebd2d04
children f09193608fd3
comparison
equal deleted inserted replaced
3629:afc5bb164c5a 3630:9682c0e022c6
23 #include <config.h> 23 #include <config.h>
24 #endif 24 #endif
25 #include <string.h> 25 #include <string.h>
26 #include <stdio.h> 26 #include <stdio.h>
27 #include <stdlib.h> 27 #include <stdlib.h>
28 #include <time.h>
29 #include <sys/types.h> 28 #include <sys/types.h>
30 #include <sys/stat.h> 29 #include <sys/stat.h>
31 #include <fcntl.h> 30 #include <fcntl.h>
32 #include <ctype.h> 31 #include <ctype.h>
32
33 #ifdef _WIN32
34 #include <winsock.h>
35 #else
33 #include <sys/socket.h> 36 #include <sys/socket.h>
37 #include <time.h>
34 #include <netdb.h> 38 #include <netdb.h>
35 #include <netinet/in.h> 39 #include <netinet/in.h>
36 #include <unistd.h> 40 #include <unistd.h>
37 #include <netinet/in.h>
38 #include <arpa/inet.h> 41 #include <arpa/inet.h>
42 #endif
43
39 #include <errno.h> 44 #include <errno.h>
40 #include <math.h> 45 #include <math.h>
41 46
42 #include <gtk/gtk.h> 47 #include <gtk/gtk.h>
43 #include "gaim.h" 48 #include "gaim.h"
44 #include "gtkimhtml.h" 49 #include "gtkimhtml.h"
45 #include "prpl.h" 50 #include "prpl.h"
51
52 #ifdef _WIN32
53 #include "win32dep.h"
54 #endif
46 55
47 #include "pixmaps/gnome_preferences.xpm" 56 #include "pixmaps/gnome_preferences.xpm"
48 #include "pixmaps/cancel.xpm" 57 #include "pixmaps/cancel.xpm"
49 #include "pixmaps/save.xpm" 58 #include "pixmaps/save.xpm"
50 #include "pixmaps/ok.xpm" 59 #include "pixmaps/ok.xpm"
2607 if (!c->log_dialog) { 2616 if (!c->log_dialog) {
2608 c->log_dialog = gtk_file_selection_new(_("Gaim - Log Conversation")); 2617 c->log_dialog = gtk_file_selection_new(_("Gaim - Log Conversation"));
2609 2618
2610 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(c->log_dialog)); 2619 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(c->log_dialog));
2611 2620
2612 g_snprintf(buf, BUF_LEN - 1, "%s/%s.log", getenv("HOME"), normalize(c->name)); 2621 g_snprintf(buf, BUF_LEN - 1, "%s" G_DIR_SEPARATOR_S "%s.log", gaim_home_dir(), normalize(c->name));
2613 gtk_object_set_user_data(GTK_OBJECT(c->log_dialog), "log dialog"); 2622 gtk_object_set_user_data(GTK_OBJECT(c->log_dialog), "log dialog");
2614 gtk_file_selection_set_filename(GTK_FILE_SELECTION(c->log_dialog), buf); 2623 gtk_file_selection_set_filename(GTK_FILE_SELECTION(c->log_dialog), buf);
2615 gtk_signal_connect(GTK_OBJECT(c->log_dialog), "delete_event", 2624 gtk_signal_connect(GTK_OBJECT(c->log_dialog), "delete_event",
2616 GTK_SIGNAL_FUNC(delete_event_dialog), c); 2625 GTK_SIGNAL_FUNC(delete_event_dialog), c);
2617 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(c->log_dialog)->ok_button), "clicked", 2626 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(c->log_dialog)->ok_button), "clicked",
3363 if (!importdialog) { 3372 if (!importdialog) {
3364 importdialog = gtk_file_selection_new(_("Gaim - Import Buddy List")); 3373 importdialog = gtk_file_selection_new(_("Gaim - Import Buddy List"));
3365 3374
3366 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(importdialog)); 3375 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(importdialog));
3367 3376
3368 g_snprintf(buf, BUF_LEN - 1, "%s/", getenv("HOME")); 3377 g_snprintf(buf, BUF_LEN - 1, "%s" G_DIR_SEPARATOR_S, gaim_home_dir());
3369 3378
3370 gtk_file_selection_set_filename(GTK_FILE_SELECTION(importdialog), buf); 3379 gtk_file_selection_set_filename(GTK_FILE_SELECTION(importdialog), buf);
3371 gtk_signal_connect(GTK_OBJECT(importdialog), "destroy", 3380 gtk_signal_connect(GTK_OBJECT(importdialog), "destroy",
3372 GTK_SIGNAL_FUNC(destroy_dialog), importdialog); 3381 GTK_SIGNAL_FUNC(destroy_dialog), importdialog);
3373 3382
3883 char *name; 3892 char *name;
3884 char *tmp; 3893 char *tmp;
3885 3894
3886 name = gtk_object_get_user_data(GTK_OBJECT(filesel)); 3895 name = gtk_object_get_user_data(GTK_OBJECT(filesel));
3887 tmp = gaim_user_dir(); 3896 tmp = gaim_user_dir();
3888 g_snprintf(filename, PATHSIZE, "%s/logs/%s%s", tmp, 3897 g_snprintf(filename, PATHSIZE, "%s" G_DIR_SEPARATOR_S "logs" G_DIR_SEPARATOR_S "%s%s", tmp,
3889 name ? normalize(name) : "system", name ? ".log" : ""); 3898 name ? normalize(name) : "system", name ? ".log" : "");
3890 g_free(tmp);
3891 3899
3892 file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(filesel)); 3900 file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(filesel));
3893 strncpy(path, file, PATHSIZE - 1); 3901 strncpy(path, file, PATHSIZE - 1);
3894 if (file_is_dir(path, filesel)) 3902 if (file_is_dir(path, filesel))
3895 return; 3903 return;
3922 static void show_save_log(GtkWidget *w, gchar *name) 3930 static void show_save_log(GtkWidget *w, gchar *name)
3923 { 3931 {
3924 GtkWidget *filesel; 3932 GtkWidget *filesel;
3925 gchar buf[BUF_LEN]; 3933 gchar buf[BUF_LEN];
3926 3934
3927 g_snprintf(buf, BUF_LEN - 1, "%s/%s%s", getenv("HOME"), 3935 g_snprintf(buf, BUF_LEN - 1, "%s" G_DIR_SEPARATOR_S "%s%s", gaim_home_dir(),
3928 name ? normalize(name) : "system", name ? ".log" : ""); 3936 name ? normalize(name) : "system", name ? ".log" : "");
3929 3937
3930 filesel = gtk_file_selection_new(_("Gaim - Save Log File")); 3938 filesel = gtk_file_selection_new(_("Gaim - Save Log File"));
3931 gtk_signal_connect(GTK_OBJECT(filesel), "delete_event", 3939 gtk_signal_connect(GTK_OBJECT(filesel), "delete_event",
3932 GTK_SIGNAL_FUNC(destroy_dialog), filesel); 3940 GTK_SIGNAL_FUNC(destroy_dialog), filesel);
3951 gchar filename[256]; 3959 gchar filename[256];
3952 GtkWidget *window; 3960 GtkWidget *window;
3953 char *tmp; 3961 char *tmp;
3954 3962
3955 tmp = gaim_user_dir(); 3963 tmp = gaim_user_dir();
3956 g_snprintf(filename, 256, "%s/logs/%s%s", tmp, 3964 g_snprintf(filename, 256, "%s" G_DIR_SEPARATOR_S "logs" G_DIR_SEPARATOR_S "%s%s", tmp,
3957 name ? normalize(name) : "system", name ? ".log" : ""); 3965 name ? normalize(name) : "system", name ? ".log" : "");
3958 g_free(tmp);
3959 3966
3960 if ((remove(filename)) == -1) { 3967 if ((remove(filename)) == -1) {
3961 g_snprintf(buf, 256, _("Couldn't remove file %s." ), filename); 3968 g_snprintf(buf, 256, _("Couldn't remove file %s." ), filename);
3962 do_error_dialog(buf, strerror(errno), GAIM_ERROR); 3969 do_error_dialog(buf, strerror(errno), GAIM_ERROR);
3963 } 3970 }
4023 4030
4024 string = g_string_new(""); 4031 string = g_string_new("");
4025 4032
4026 if (view->name) { 4033 if (view->name) {
4027 char *tmp = gaim_user_dir(); 4034 char *tmp = gaim_user_dir();
4028 g_snprintf(filename, 256, "%s/logs/%s.log", tmp, normalize(view->name)); 4035 g_snprintf(filename, 256, "%s" G_DIR_SEPARATOR_S "logs" G_DIR_SEPARATOR_S "%s.log", tmp, normalize(view->name));
4029 g_free(tmp);
4030 } else { 4036 } else {
4031 char *tmp = gaim_user_dir(); 4037 char *tmp = gaim_user_dir();
4032 g_snprintf(filename, 256, "%s/logs/system", tmp); 4038 g_snprintf(filename, 256, "%s" G_DIR_SEPARATOR_S "logs" G_DIR_SEPARATOR_S "system", tmp);
4033 g_free(tmp);
4034 } 4039 }
4035 if ((fp = fopen(filename, "r")) == NULL) { 4040 if ((fp = fopen(filename, "r")) == NULL) {
4036 g_snprintf(buf, BUF_LONG, "Couldn't open log file %s.", filename); 4041 g_snprintf(buf, BUF_LONG, "Couldn't open log file %s.", filename);
4037 do_error_dialog(buf, strerror(errno), GAIM_ERROR); 4042 do_error_dialog(buf, strerror(errno), GAIM_ERROR);
4038 return; 4043 return;
4172 hbox = gtk_hbox_new(FALSE, 5); 4177 hbox = gtk_hbox_new(FALSE, 5);
4173 gtk_box_pack_start(GTK_BOX(box), hbox, TRUE, TRUE, 0); 4178 gtk_box_pack_start(GTK_BOX(box), hbox, TRUE, TRUE, 0);
4174 4179
4175 if (name) { 4180 if (name) {
4176 char *tmp = gaim_user_dir(); 4181 char *tmp = gaim_user_dir();
4177 g_snprintf(filename, 256, "%s/logs/%s.log", tmp, normalize(name)); 4182 g_snprintf(filename, 256, "%s" G_DIR_SEPARATOR_S "logs" G_DIR_SEPARATOR_S "%s.log", tmp, normalize(name));
4178 g_free(tmp);
4179 if ((fp = fopen(filename, "r")) == NULL) { 4183 if ((fp = fopen(filename, "r")) == NULL) {
4180 g_snprintf(buf, BUF_LONG, "Couldn't open log file %s", filename); 4184 g_snprintf(buf, BUF_LONG, "Couldn't open log file %s", filename);
4181 do_error_dialog(buf, strerror(errno), GAIM_ERROR); 4185 do_error_dialog(buf, strerror(errno), GAIM_ERROR);
4182 return; 4186 return;
4183 } 4187 }
4555 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(perl_config)); 4559 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(perl_config));
4556 4560
4557 if (!perl_last_dir) { 4561 if (!perl_last_dir) {
4558 temp = gaim_user_dir(); 4562 temp = gaim_user_dir();
4559 buf = g_strconcat(temp, G_DIR_SEPARATOR_S, NULL); 4563 buf = g_strconcat(temp, G_DIR_SEPARATOR_S, NULL);
4560 g_free(temp);
4561 } else { 4564 } else {
4562 buf = g_strconcat(perl_last_dir, G_DIR_SEPARATOR_S, NULL); 4565 buf = g_strconcat(perl_last_dir, G_DIR_SEPARATOR_S, NULL);
4563 } 4566 }
4564 4567
4565 gtk_file_selection_set_filename(GTK_FILE_SELECTION(perl_config), buf); 4568 gtk_file_selection_set_filename(GTK_FILE_SELECTION(perl_config), buf);