Commit 46b0df7692a7b598954374cf8e3d44e5987d6366

Authored by Perry Werneck
1 parent 9055e808
Exists in master and in 1 other branch develop

Fixing bug on file selection dialog.

src/dialogs/linux/select.c
@@ -33,12 +33,14 @@ @@ -33,12 +33,14 @@
33 33
34 /*--[ Implement ]------------------------------------------------------------------------------------*/ 34 /*--[ Implement ]------------------------------------------------------------------------------------*/
35 35
36 -gchar * v3270_select_file(GtkWidget *widget, const gchar *title, const gchar *button, GtkFileChooserAction action, const gchar *filename, const gchar *filter, ...) 36 +gchar * v3270_select_file(GtkWidget *widget, const gchar *title, const gchar *button, GtkFileChooserAction action, const gchar *filename)
37 { 37 {
38 gchar *rc = NULL; 38 gchar *rc = NULL;
39 39
40 #if GTK_CHECK_VERSION(3,20,0) 40 #if GTK_CHECK_VERSION(3,20,0)
41 41
  42 + debug("%s action=%d",__FUNCTION__,(int) action);
  43 +
42 GtkFileChooserNative *native = 44 GtkFileChooserNative *native =
43 gtk_file_chooser_native_new 45 gtk_file_chooser_native_new
44 ( 46 (
@@ -54,26 +56,6 @@ gchar * v3270_select_file(GtkWidget *widget, const gchar *title, const gchar *bu @@ -54,26 +56,6 @@ gchar * v3270_select_file(GtkWidget *widget, const gchar *title, const gchar *bu
54 if(filename && *filename) 56 if(filename && *filename)
55 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(native),filename); 57 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(native),filename);
56 58
57 - // Setup filters  
58 - va_list args;  
59 - va_start (args, filter);  
60 - while(filter)  
61 - {  
62 - const gchar * name = va_arg(args, const gchar *);  
63 - if(!name)  
64 - break;  
65 -  
66 - const gchar * pattern = va_arg(args, const gchar *);  
67 - if(!pattern)  
68 - break;  
69 -  
70 - GtkFileFilter *filter = gtk_file_filter_new();  
71 - gtk_file_filter_set_name(filter,name);  
72 - gtk_file_filter_add_pattern(filter, pattern);  
73 - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(native), filter);  
74 -  
75 - }  
76 - va_end(args);  
77 59
78 // Run dialog 60 // Run dialog
79 if(gtk_native_dialog_run(GTK_NATIVE_DIALOG (native)) == GTK_RESPONSE_ACCEPT) { 61 if(gtk_native_dialog_run(GTK_NATIVE_DIALOG (native)) == GTK_RESPONSE_ACCEPT) {
@@ -84,6 +66,8 @@ gchar * v3270_select_file(GtkWidget *widget, const gchar *title, const gchar *bu @@ -84,6 +66,8 @@ gchar * v3270_select_file(GtkWidget *widget, const gchar *title, const gchar *bu
84 66
85 #else 67 #else
86 68
  69 + debug("%s action=%d",__FUNCTION__,(int) action);
  70 +
87 GtkWidget * chooser = 71 GtkWidget * chooser =
88 gtk_file_chooser_dialog_new 72 gtk_file_chooser_dialog_new
89 ( 73 (
@@ -98,34 +82,12 @@ gchar * v3270_select_file(GtkWidget *widget, const gchar *title, const gchar *bu @@ -98,34 +82,12 @@ gchar * v3270_select_file(GtkWidget *widget, const gchar *title, const gchar *bu
98 if(filename && *filename) 82 if(filename && *filename)
99 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(chooser),filename); 83 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(chooser),filename);
100 84
101 - // Setup filters  
102 - va_list args;  
103 - va_start (args, filter);  
104 - while(filter)  
105 - {  
106 - const gchar * name = va_arg(args, const gchar *);  
107 - if(!name)  
108 - break;  
109 -  
110 - const gchar * pattern = va_arg(args, const gchar *);  
111 - if(!pattern)  
112 - break;  
113 -  
114 - GtkFileFilter *filter = gtk_file_filter_new();  
115 - gtk_file_filter_set_name(filter,name);  
116 - gtk_file_filter_add_pattern(filter, pattern);  
117 - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(chooser), filter);  
118 -  
119 - }  
120 - va_end(args);  
121 -  
122 if(gtk_dialog_run(GTK_DIALOG(chooser)) == GTK_RESPONSE_ACCEPT) { 85 if(gtk_dialog_run(GTK_DIALOG(chooser)) == GTK_RESPONSE_ACCEPT) {
123 rc = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(chooser)); 86 rc = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(chooser));
124 } 87 }
125 88
126 gtk_widget_destroy(chooser); 89 gtk_widget_destroy(chooser);
127 90
128 -  
129 #endif // GTK 3.20 91 #endif // GTK 3.20
130 92
131 return rc; 93 return rc;
src/dialogs/save/save.c
@@ -113,9 +113,7 @@ static void icon_press(GtkEntry G_GNUC_UNUSED(*entry), G_GNUC_UNUSED GtkEntryIco @@ -113,9 +113,7 @@ static void icon_press(GtkEntry G_GNUC_UNUSED(*entry), G_GNUC_UNUSED GtkEntryIco
113 _( "Select destination file"), 113 _( "Select destination file"),
114 _("Select"), 114 _("Select"),
115 GTK_FILE_CHOOSER_ACTION_SAVE, 115 GTK_FILE_CHOOSER_ACTION_SAVE,
116 - gtk_entry_get_text(GTK_ENTRY(widget->filename)),  
117 - N_("All files"), "*.*",  
118 - NULL 116 + gtk_entry_get_text(GTK_ENTRY(widget->filename))
119 ); 117 );
120 118
121 if(filename && *filename) { 119 if(filename && *filename) {
src/dialogs/transfer.c
@@ -72,9 +72,7 @@ static void save_activity_clicked(GtkWidget *button, GObject *activity) @@ -72,9 +72,7 @@ static void save_activity_clicked(GtkWidget *button, GObject *activity)
72 _("Save transfer activity to file"), 72 _("Save transfer activity to file"),
73 _("Save"), 73 _("Save"),
74 GTK_FILE_CHOOSER_ACTION_SAVE, 74 GTK_FILE_CHOOSER_ACTION_SAVE,
75 - NULL,  
76 - N_("XML file"), "*.xml",  
77 - NULL ); 75 + NULL);
78 76
79 if(filename) 77 if(filename)
80 { 78 {
src/dialogs/windows/select.c
@@ -145,7 +145,7 @@ gchar * v3270_select_file(GtkWidget *widget, const gchar *title, const gchar *bu @@ -145,7 +145,7 @@ gchar * v3270_select_file(GtkWidget *widget, const gchar *title, const gchar *bu
145 } 145 }
146 */ 146 */
147 147
148 -gchar * v3270_select_file(GtkWidget *widget, const gchar *title, const gchar *button, GtkFileChooserAction action, const gchar *filename, const gchar *filter, ...) 148 +gchar * v3270_select_file(GtkWidget *widget, const gchar *title, const gchar *button, GtkFileChooserAction action, const gchar *filename)
149 { 149 {
150 gchar *rc = NULL; 150 gchar *rc = NULL;
151 151
src/filetransfer/activitylist.c
@@ -382,9 +382,7 @@ @@ -382,9 +382,7 @@
382 widget, 382 widget,
383 _("Load queue from file"), 383 _("Load queue from file"),
384 _("Load"), GTK_FILE_CHOOSER_ACTION_OPEN, 384 _("Load"), GTK_FILE_CHOOSER_ACTION_OPEN,
385 - "",  
386 - N_("XML file"), "*.xml",  
387 - NULL ); 385 + "");
388 386
389 if(filename) { 387 if(filename) {
390 g_free(list->filename); 388 g_free(list->filename);
@@ -454,9 +452,7 @@ @@ -454,9 +452,7 @@
454 _("Save queue to file"), 452 _("Save queue to file"),
455 _("Save"), 453 _("Save"),
456 GTK_FILE_CHOOSER_ACTION_SAVE, 454 GTK_FILE_CHOOSER_ACTION_SAVE,
457 - list->filename,  
458 - N_("XML file"), "*.xml",  
459 - NULL ); 455 + list->filename);
460 456
461 if(filename) { 457 if(filename) {
462 g_free(list->filename); 458 g_free(list->filename);
src/filetransfer/settings.c
@@ -208,10 +208,7 @@ static void open_select_file_dialog(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconP @@ -208,10 +208,7 @@ static void open_select_file_dialog(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconP
208 _("Select local file"), 208 _("Select local file"),
209 _("Select"), 209 _("Select"),
210 GTK_FILE_CHOOSER_ACTION_OPEN, 210 GTK_FILE_CHOOSER_ACTION_OPEN,
211 - gtk_entry_get_text(entry),  
212 - N_("All files"), "*.*",  
213 - N_("Text files"), "*.txt",  
214 - NULL 211 + gtk_entry_get_text(entry)
215 ); 212 );
216 213
217 if(filename) { 214 if(filename) {
src/filetransfer/v3270ft.c
@@ -196,9 +196,7 @@ static void load_file(G_GNUC_UNUSED GtkButton *button, v3270ft *dialog) { @@ -196,9 +196,7 @@ static void load_file(G_GNUC_UNUSED GtkButton *button, v3270ft *dialog) {
196 GTK_WIDGET(dialog), 196 GTK_WIDGET(dialog),
197 _("Load queue from file"), 197 _("Load queue from file"),
198 _("Load"), GTK_FILE_CHOOSER_ACTION_OPEN, 198 _("Load"), GTK_FILE_CHOOSER_ACTION_OPEN,
199 - "",  
200 - N_("XML file"), "*.xml",  
201 - NULL ); 199 + "");
202 200
203 if(filename) { 201 if(filename) {
204 v3270ft_load(GTK_WIDGET(dialog),filename); 202 v3270ft_load(GTK_WIDGET(dialog),filename);
@@ -216,9 +214,7 @@ static void save_file(G_GNUC_UNUSED GtkButton *button, v3270ft *dialog) { @@ -216,9 +214,7 @@ static void save_file(G_GNUC_UNUSED GtkButton *button, v3270ft *dialog) {
216 _("Save queue to file"), 214 _("Save queue to file"),
217 _("Save"), 215 _("Save"),
218 GTK_FILE_CHOOSER_ACTION_SAVE, 216 GTK_FILE_CHOOSER_ACTION_SAVE,
219 - "",  
220 - N_("XML file"), "*.xml",  
221 - NULL ); 217 + "");
222 218
223 if(filename) { 219 if(filename) {
224 v3270ft_save(GTK_WIDGET(dialog),filename); 220 v3270ft_save(GTK_WIDGET(dialog),filename);
@@ -299,17 +295,14 @@ static gboolean spin_format(GtkSpinButton *spin, G_GNUC_UNUSED gpointer data) { @@ -299,17 +295,14 @@ static gboolean spin_format(GtkSpinButton *spin, G_GNUC_UNUSED gpointer data) {
299 static void icon_press(G_GNUC_UNUSED GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconPosition icon_pos, G_GNUC_UNUSED GdkEvent *event, v3270ft *dialog) { 295 static void icon_press(G_GNUC_UNUSED GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconPosition icon_pos, G_GNUC_UNUSED GdkEvent *event, v3270ft *dialog) {
300 //#endif // WIN32 296 //#endif // WIN32
301 297
302 - debug("%s",__FUNCTION__); 298 + debug("%s: action=%d",__FUNCTION__, (int) GTK_FILE_CHOOSER_ACTION_OPEN);
303 299
304 gchar *filename = v3270_select_file( 300 gchar *filename = v3270_select_file(
305 GTK_WIDGET(dialog), 301 GTK_WIDGET(dialog),
306 _("Select local file"), 302 _("Select local file"),
307 _("Select"), 303 _("Select"),
308 GTK_FILE_CHOOSER_ACTION_OPEN, 304 GTK_FILE_CHOOSER_ACTION_OPEN,
309 - gtk_entry_get_text(dialog->local),  
310 - N_("All files"), "*.*",  
311 - N_("Text files"), "*.txt",  
312 - NULL ); 305 + gtk_entry_get_text(dialog->local));
313 306
314 if(filename) { 307 if(filename) {
315 308
src/include/internals.h
@@ -142,7 +142,7 @@ @@ -142,7 +142,7 @@
142 G_GNUC_INTERNAL void v3270_activity_list_save(GtkWidget *widget); 142 G_GNUC_INTERNAL void v3270_activity_list_save(GtkWidget *widget);
143 G_GNUC_INTERNAL void v3270_activity_list_save_as(GtkWidget *widget); 143 G_GNUC_INTERNAL void v3270_activity_list_save_as(GtkWidget *widget);
144 144
145 - G_GNUC_INTERNAL gchar * v3270_select_file(GtkWidget *widget, const gchar *title, const gchar *button, GtkFileChooserAction action, const gchar *filename, const gchar *filter, ... ) G_GNUC_NULL_TERMINATED; 145 + G_GNUC_INTERNAL gchar * v3270_select_file(GtkWidget *widget, const gchar *title, const gchar *button, GtkFileChooserAction action, const gchar *filename);
146 146
147 #if ! GTK_CHECK_VERSION(3,16,0) 147 #if ! GTK_CHECK_VERSION(3,16,0)
148 G_GNUC_INTERNAL void gtk_text_view_set_monospace (GtkTextView *text_view, gboolean monospace); 148 G_GNUC_INTERNAL void gtk_text_view_set_monospace (GtkTextView *text_view, gboolean monospace);
src/trace/trace.c
@@ -497,9 +497,7 @@ @@ -497,9 +497,7 @@
497 _("Save trace to file"), 497 _("Save trace to file"),
498 _("Save"), 498 _("Save"),
499 GTK_FILE_CHOOSER_ACTION_SAVE, 499 GTK_FILE_CHOOSER_ACTION_SAVE,
500 - trace->filename,  
501 - N_("Text file"), "*.txt",  
502 - NULL 500 + trace->filename
503 ); 501 );
504 502
505 if(filename) { 503 if(filename) {