1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
--- src/callback.c.orig Mon Dec 20 12:58:26 2004
+++ src/callback.c Thu Feb 3 20:08:07 2005
@@ -93,7 +93,7 @@
if (!check_text_modification(sd)) {
// fi = get_file_info_by_selector(OPEN, sd->fi);
- fi = get_fileinfo_from_selector(sd->mainwin->window, sd->fi, OPEN);
+ fi = get_fileinfo_from_chooser(sd->mainwin->window, sd->fi, OPEN);
if (fi) {
if (file_open_real(sd->mainwin->textview, fi)) {
g_free(fi);
@@ -123,7 +123,7 @@
{
FileInfo *fi;
- fi = get_fileinfo_from_selector(sd->mainwin->window, sd->fi, SAVE);
+ fi = get_fileinfo_from_chooser(sd->mainwin->window, sd->fi, SAVE);
if (fi) {
if (file_save_real(sd->mainwin->textview, fi))
g_free(fi);
--- src/selector.c.orig Fri Dec 24 10:35:12 2004
+++ src/selector.c Thu Feb 3 21:02:00 2005
@@ -310,7 +310,7 @@
return option_menu;
}
-static GtkWidget *create_file_selector(FileInfo *selected_fi)
+static GtkWidget *create_file_chooser(FileInfo *selected_fi, GtkWidget *window)
{
GtkWidget *filesel;
GtkWidget *align;
@@ -322,12 +322,19 @@
title = mode ? _("Open") : _("Save As");
- filesel = gtk_file_selection_new(title);
-// gtk_window_set_transient_for(GTK_WINDOW(filesel), GTK_WINDOW(window));
+ if(mode == OPEN)
+ filesel = gtk_file_chooser_dialog_new(title, GTK_WINDOW(window),
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,NULL);
+ else
+ filesel = gtk_file_chooser_dialog_new(title, GTK_WINDOW(window),
+ GTK_FILE_CHOOSER_ACTION_SAVE,
+ GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,
+ GTK_STOCK_SAVE,GTK_RESPONSE_ACCEPT,NULL);
align = gtk_alignment_new(1, 0, 0, 0);
- gtk_box_pack_end(GTK_BOX(GTK_FILE_SELECTION(filesel)->main_vbox),
- align, FALSE, FALSE, 0);
+ gtk_file_chooser_set_extra_widget(GTK_FILE_CHOOSER(filesel),align);
table = gtk_table_new(2, 2, FALSE);
gtk_table_set_row_spacings(GTK_TABLE(table), 5);
gtk_container_add(GTK_CONTAINER(align), table);
@@ -340,15 +347,15 @@
option_menu_lineend = create_lineend_menu(selected_fi);
gtk_table_attach_defaults(GTK_TABLE(table), option_menu_lineend, 1, 2, 0, 1);
}
- gtk_widget_show_all(GTK_FILE_SELECTION(filesel)->main_vbox);
+ gtk_widget_show_all(GTK_FILE_CHOOSER(filesel));
if (selected_fi->filename)
- gtk_file_selection_set_filename(GTK_FILE_SELECTION(filesel), selected_fi->filename);
+ gtk_file_chooser_select_filename(GTK_FILE_CHOOSER(filesel), selected_fi->filename);
return filesel;
}
-FileInfo *get_fileinfo_from_selector(GtkWidget *window, FileInfo *fi, gint requested_mode)
+FileInfo *get_fileinfo_from_chooser(GtkWidget *window, FileInfo *fi, gint requested_mode)
{
FileInfo *selected_fi;
GtkWidget *filesel;
@@ -366,24 +373,24 @@
selected_fi->manual_charset =
fi->manual_charset ? g_strdup(fi->manual_charset) : NULL;
- filesel = create_file_selector(selected_fi);
+ filesel = create_file_chooser(selected_fi,window);
gtk_window_set_transient_for(GTK_WINDOW(filesel), GTK_WINDOW(window));
do {
res = gtk_dialog_run(GTK_DIALOG(filesel));
- if (res == GTK_RESPONSE_OK) {
+ if (res == GTK_RESPONSE_ACCEPT) {
if (selected_fi->filename)
g_free(selected_fi->filename);
selected_fi->filename = g_strdup(
- gtk_file_selection_get_filename(GTK_FILE_SELECTION(filesel)));
+ gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(filesel)));
if (g_file_test(selected_fi->filename, G_FILE_TEST_IS_DIR)) {
len = strlen(selected_fi->filename);
if (len < 1 || selected_fi->filename[len - 1] != G_DIR_SEPARATOR)
str = g_strconcat(selected_fi->filename, G_DIR_SEPARATOR_S, NULL);
else
str = g_strdup(selected_fi->filename);
- gtk_file_selection_set_filename(GTK_FILE_SELECTION(filesel), str);
+ gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(filesel), str);
g_free(str);
continue;
}
@@ -397,14 +404,14 @@
case GTK_RESPONSE_NO:
continue;
case GTK_RESPONSE_YES:
- res = GTK_RESPONSE_OK;
+ res = GTK_RESPONSE_ACCEPT;
}
}
}
gtk_widget_hide(filesel);
} while (GTK_WIDGET_VISIBLE(filesel));
- if (res != GTK_RESPONSE_OK) {
+ if (res != GTK_RESPONSE_ACCEPT) {
if (selected_fi->charset)
g_free(selected_fi->charset);
if (selected_fi->manual_charset)
--- src/selector.h.orig Thu Feb 3 20:17:09 2005
+++ src/selector.h Thu Feb 3 20:17:27 2005
@@ -30,6 +30,6 @@
OPEN
};
-FileInfo *get_fileinfo_from_selector(GtkWidget *window, FileInfo *fi, gint requested_mode);
+FileInfo *get_fileinfo_from_chooser(GtkWidget *window, FileInfo *fi, gint requested_mode);
#endif /* _SELECTOR_H */
|