Commit 6e737ce0e5762985c0b20ff093914aae018a1b4c
1 parent
008d7136
Exists in
master
and in
1 other branch
Adjustments on 'save' dialog.
Showing
2 changed files
with
28 additions
and
10 deletions
Show diff stats
src/dialogs/save/save.c
| ... | ... | @@ -34,6 +34,7 @@ |
| 34 | 34 | #include <lib3270/selection.h> |
| 35 | 35 | #include <clipboard.h> |
| 36 | 36 | #include <limits.h> |
| 37 | + #include <v3270/tools.h> | |
| 37 | 38 | |
| 38 | 39 | /*--[ GTK Requires ]---------------------------------------------------------------------------------*/ |
| 39 | 40 | |
| ... | ... | @@ -71,6 +72,7 @@ |
| 71 | 72 | |
| 72 | 73 | } |
| 73 | 74 | |
| 75 | +/* | |
| 74 | 76 | #ifdef WIN32 |
| 75 | 77 | static void icon_press(GtkEntry G_GNUC_UNUSED(*entry), G_GNUC_UNUSED GtkEntryIconPosition icon_pos, G_GNUC_UNUSED GdkEvent *event, V3270SaveDialog *widget) |
| 76 | 78 | { |
| ... | ... | @@ -119,7 +121,7 @@ static void icon_press(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconPosition icon_ |
| 119 | 121 | |
| 120 | 122 | } |
| 121 | 123 | #endif // _WIN32 |
| 122 | - | |
| 124 | +*/ | |
| 123 | 125 | |
| 124 | 126 | static void filename_changed(GtkEntry *entry, V3270SaveDialog *dialog) |
| 125 | 127 | { |
| ... | ... | @@ -139,9 +141,7 @@ static void icon_press(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconPosition icon_ |
| 139 | 141 | g_autofree gchar * dirname = g_path_get_dirname(text); |
| 140 | 142 | g_autofree gchar * basename = g_path_get_basename(text); |
| 141 | 143 | |
| 142 | - gtk_widget_set_sensitive(button,g_file_test(dirname,G_FILE_TEST_IS_DIR) && *basename && (*basename != '.')); | |
| 143 | - | |
| 144 | - debug("*************[%s]***********",basename); | |
| 144 | + gtk_widget_set_sensitive(button,g_file_test(dirname,G_FILE_TEST_IS_DIR)); | |
| 145 | 145 | |
| 146 | 146 | const gchar * extension = strrchr(basename,'.'); |
| 147 | 147 | if(!extension) |
| ... | ... | @@ -250,10 +250,21 @@ static void icon_press(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconPosition icon_ |
| 250 | 250 | gtk_grid_attach(grid,widget,0,0,1,1); |
| 251 | 251 | gtk_label_set_mnemonic_widget(GTK_LABEL(widget),dialog->filename); |
| 252 | 252 | |
| 253 | + /* | |
| 253 | 254 | gtk_entry_set_icon_from_icon_name(GTK_ENTRY(dialog->filename),GTK_ENTRY_ICON_SECONDARY,"document-save-as"); |
| 254 | 255 | gtk_entry_set_icon_activatable(GTK_ENTRY(dialog->filename),GTK_ENTRY_ICON_SECONDARY,TRUE); |
| 255 | 256 | gtk_entry_set_icon_tooltip_text(GTK_ENTRY(dialog->filename),GTK_ENTRY_ICON_SECONDARY,_("Select file")); |
| 256 | 257 | g_signal_connect(G_OBJECT(dialog->filename),"icon-press",G_CALLBACK(icon_press),dialog); |
| 258 | + */ | |
| 259 | + | |
| 260 | + gtk_entry_bind_to_filechooser( | |
| 261 | + dialog->filename, | |
| 262 | + GTK_FILE_CHOOSER_ACTION_SAVE, | |
| 263 | + _( "Select destination file" ), | |
| 264 | + NULL, | |
| 265 | + NULL, | |
| 266 | + NULL | |
| 267 | + ); | |
| 257 | 268 | |
| 258 | 269 | gtk_entry_set_width_chars(GTK_ENTRY(dialog->filename),60); |
| 259 | 270 | gtk_entry_set_max_length(GTK_ENTRY(dialog->filename),PATH_MAX); | ... | ... |
src/tools/entry.c
| ... | ... | @@ -101,7 +101,8 @@ |
| 101 | 101 | NULL |
| 102 | 102 | ); |
| 103 | 103 | |
| 104 | - { | |
| 104 | + if(descr->pattern) { | |
| 105 | + | |
| 105 | 106 | GtkFileFilter *filter; |
| 106 | 107 | |
| 107 | 108 | // Standard filter |
| ... | ... | @@ -148,7 +149,11 @@ |
| 148 | 149 | ); |
| 149 | 150 | |
| 150 | 151 | // Store data |
| 151 | - gsize szEntry = sizeof(struct FileEntry) + strlen(title) + strlen(pattern) + strlen(name) + 4; | |
| 152 | + gsize szEntry = sizeof(struct FileEntry) + strlen(title) + 4; | |
| 153 | + | |
| 154 | + if(pattern) { | |
| 155 | + szEntry += (strlen(pattern) + strlen(name)); | |
| 156 | + } | |
| 152 | 157 | struct FileEntry * entry = (struct FileEntry *) g_malloc0(szEntry); |
| 153 | 158 | gtk_widget_bind_ptr(widget,entry); |
| 154 | 159 | |
| ... | ... | @@ -171,11 +176,13 @@ |
| 171 | 176 | entry->title = (const char *) (entry+1); |
| 172 | 177 | strcpy((char *) entry->title,title); |
| 173 | 178 | |
| 174 | - entry->pattern = entry->title + strlen(entry->title) +1; | |
| 175 | - strcpy((char *) entry->pattern,pattern); | |
| 179 | + if(pattern) { | |
| 180 | + entry->pattern = entry->title + strlen(entry->title) +1; | |
| 181 | + strcpy((char *) entry->pattern,pattern); | |
| 176 | 182 | |
| 177 | - entry->name = entry->pattern + strlen(entry->pattern) + 1; | |
| 178 | - strcpy((char *) entry->name,name); | |
| 183 | + entry->name = entry->pattern + strlen(entry->pattern) + 1; | |
| 184 | + strcpy((char *) entry->name,name); | |
| 185 | + } | |
| 179 | 186 | |
| 180 | 187 | g_signal_connect(widget,"icon_press",G_CALLBACK(icon_press),(gpointer) entry); |
| 181 | 188 | ... | ... |