Commit c146f368dcdb7b566bba22f7d5d82e33dad1b85d
1 parent
8ca37962
Exists in
master
and in
1 other branch
Rewriting file transfer properties widget.
Showing
5 changed files
with
115 additions
and
7 deletions
Show diff stats
src/include/v3270/filetransfer.h
@@ -77,7 +77,7 @@ | @@ -77,7 +77,7 @@ | ||
77 | void v3270ft_append_file(GtkWidget *widget, const gchar *filename, gboolean text); | 77 | void v3270ft_append_file(GtkWidget *widget, const gchar *filename, gboolean text); |
78 | guint v3270ft_append_selection(GtkWidget *widget, GtkSelectionData *data); | 78 | guint v3270ft_append_selection(GtkWidget *widget, GtkSelectionData *data); |
79 | 79 | ||
80 | - gchar * v3270ft_select_file(v3270ft *dialog, const gchar *title, const gchar *button, GtkFileChooserAction action, const gchar *filename, const gchar *filter, ... ) G_GNUC_NULL_TERMINATED; | 80 | + gchar * v3270ft_select_file(GtkWidget *dialog, const gchar *title, const gchar *button, GtkFileChooserAction action, const gchar *filename, const gchar *filter, ... ) G_GNUC_NULL_TERMINATED; |
81 | 81 | ||
82 | gint v3270ft_transfer(GtkWidget *dialog, H3270 *session); | 82 | gint v3270ft_transfer(GtkWidget *dialog, H3270 *session); |
83 | 83 |
src/v3270ft/select.c
@@ -73,7 +73,7 @@ static gpointer select_file(struct file *fl) { | @@ -73,7 +73,7 @@ static gpointer select_file(struct file *fl) { | ||
73 | #endif // _WIN32 | 73 | #endif // _WIN32 |
74 | */ | 74 | */ |
75 | 75 | ||
76 | -gchar * v3270ft_select_file(v3270ft *dialog, const gchar *title, const gchar *button, GtkFileChooserAction action, G_GNUC_UNUSED const gchar *filename, G_GNUC_UNUSED const gchar *filter, ...) { | 76 | +gchar * v3270ft_select_file(GtkWidget *dialog, const gchar *title, const gchar *button, GtkFileChooserAction action, G_GNUC_UNUSED const gchar *filename, G_GNUC_UNUSED const gchar *filter, ...) { |
77 | 77 | ||
78 | gchar *rc = NULL; | 78 | gchar *rc = NULL; |
79 | 79 |
src/v3270ft/settings.c
@@ -50,6 +50,7 @@ | @@ -50,6 +50,7 @@ | ||
50 | } file; | 50 | } file; |
51 | 51 | ||
52 | GtkWidget * options[NUM_OPTIONS_WIDGETS]; | 52 | GtkWidget * options[NUM_OPTIONS_WIDGETS]; |
53 | + GtkWidget * spins[LIB3270_FT_VALUE_COUNT]; | ||
53 | }; | 54 | }; |
54 | 55 | ||
55 | G_DEFINE_TYPE(V3270FTSettings, V3270FTSettings, GTK_TYPE_GRID); | 56 | G_DEFINE_TYPE(V3270FTSettings, V3270FTSettings, GTK_TYPE_GRID); |
@@ -99,6 +100,78 @@ | @@ -99,6 +100,78 @@ | ||
99 | return box; | 100 | return box; |
100 | } | 101 | } |
101 | 102 | ||
103 | + static GtkWidget * create_grid(GtkWidget *container, GtkAlign align) | ||
104 | + { | ||
105 | + GtkWidget * grid = gtk_grid_new(); | ||
106 | + | ||
107 | + gtk_grid_set_row_spacing(GTK_GRID(grid),6); | ||
108 | + gtk_grid_set_column_spacing(GTK_GRID(grid),12); | ||
109 | + | ||
110 | + g_object_set(G_OBJECT(grid),"margin-top",6,NULL); | ||
111 | + gtk_widget_set_halign(GTK_WIDGET(grid),align); | ||
112 | + gtk_box_pack_start(GTK_BOX(container),GTK_WIDGET(grid),TRUE,TRUE,0); | ||
113 | + | ||
114 | + return grid; | ||
115 | + } | ||
116 | + | ||
117 | + GtkWidget * create_spin_button(V3270FTSettings *widget, GtkWidget *grid, size_t row, LIB3270_FT_VALUE id) | ||
118 | + { | ||
119 | + GtkWidget * label = gtk_label_new_with_mnemonic(gettext(ft_value[id].label)); | ||
120 | + gtk_widget_set_halign(label,GTK_ALIGN_END); | ||
121 | + | ||
122 | + gtk_grid_attach(GTK_GRID(grid),label,0,row,1,1); | ||
123 | + | ||
124 | + GtkWidget * button = gtk_spin_button_new_with_range(ft_value[id].minval,ft_value[id].maxval,1); | ||
125 | + // g_signal_connect(G_OBJECT(button),"value-changed",G_CALLBACK(spin_changed),dialog); | ||
126 | + // g_signal_connect(G_OBJECT(button),"output",G_CALLBACK(spin_format),dialog); | ||
127 | + | ||
128 | + gtk_widget_set_tooltip_markup(button,gettext(ft_value[id].tooltip)); | ||
129 | + gtk_widget_set_tooltip_markup(label,gettext(ft_value[id].tooltip)); | ||
130 | + | ||
131 | + gtk_label_set_mnemonic_widget(GTK_LABEL(label),button); | ||
132 | + | ||
133 | + gtk_grid_attach(GTK_GRID(grid),button,1,row,1,1); | ||
134 | + | ||
135 | + widget->spins[id] = button; | ||
136 | + | ||
137 | + return button; | ||
138 | + | ||
139 | + } | ||
140 | + | ||
141 | +static void open_select_file_dialog(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconPosition icon_pos, G_GNUC_UNUSED GdkEvent *event, GtkWidget *widget) | ||
142 | +{ | ||
143 | + gchar *filename = v3270ft_select_file( | ||
144 | + gtk_widget_get_toplevel(widget), | ||
145 | + _("Select local file"), | ||
146 | + _("Select"), | ||
147 | + GTK_FILE_CHOOSER_ACTION_OPEN, | ||
148 | + gtk_entry_get_text(entry), | ||
149 | + N_("All files"), "*.*", | ||
150 | + N_("Text files"), "*.txt", | ||
151 | + NULL ); | ||
152 | + | ||
153 | + if(filename) { | ||
154 | + | ||
155 | + gtk_entry_set_text(entry,filename); | ||
156 | + | ||
157 | + /* | ||
158 | + const gchar *remote = gtk_entry_get_text(dialog->remote); | ||
159 | + | ||
160 | + gtk_entry_set_text(dialog->local,filename); | ||
161 | + | ||
162 | + if(!*remote) { | ||
163 | + gchar * text = g_path_get_basename(filename); | ||
164 | + gtk_entry_set_text(dialog->remote,text); | ||
165 | + g_free(text); | ||
166 | + } | ||
167 | + | ||
168 | + g_free(filename); | ||
169 | + */ | ||
170 | + | ||
171 | + } | ||
172 | + | ||
173 | +} | ||
174 | + | ||
102 | static void V3270FTSettings_init(V3270FTSettings *widget) | 175 | static void V3270FTSettings_init(V3270FTSettings *widget) |
103 | { | 176 | { |
104 | size_t ix; | 177 | size_t ix; |
@@ -134,10 +207,11 @@ | @@ -134,10 +207,11 @@ | ||
134 | gtk_entry_set_icon_activatable(widget->file.local,GTK_ENTRY_ICON_SECONDARY,TRUE); | 207 | gtk_entry_set_icon_activatable(widget->file.local,GTK_ENTRY_ICON_SECONDARY,TRUE); |
135 | gtk_entry_set_icon_tooltip_text(widget->file.local,GTK_ENTRY_ICON_SECONDARY,_("Select file")); | 208 | gtk_entry_set_icon_tooltip_text(widget->file.local,GTK_ENTRY_ICON_SECONDARY,_("Select file")); |
136 | 209 | ||
137 | - // g_signal_connect(G_OBJECT(widget->file.local),"icon-press",G_CALLBACK(open_select_file_dialog),dialog); | 210 | + g_signal_connect(G_OBJECT(widget->file.local),"icon-press",G_CALLBACK(open_select_file_dialog),widget); |
138 | 211 | ||
139 | // Remote file name | 212 | // Remote file name |
140 | widget->file.remote = GTK_ENTRY(create_entry(widget,"_Remote file",gtk_entry_new(),0,2,9)); | 213 | widget->file.remote = GTK_ENTRY(create_entry(widget,"_Remote file",gtk_entry_new(),0,2,9)); |
214 | + gtk_entry_set_max_length(widget->file.remote,PATH_MAX); | ||
141 | 215 | ||
142 | } | 216 | } |
143 | 217 | ||
@@ -195,10 +269,39 @@ | @@ -195,10 +269,39 @@ | ||
195 | } | 269 | } |
196 | } | 270 | } |
197 | 271 | ||
272 | + // Values box | ||
273 | + GtkWidget * values = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,6); | ||
274 | + gtk_box_set_homogeneous(GTK_BOX(values),TRUE); | ||
275 | + g_object_set(G_OBJECT(values),"margin-top",8,NULL); | ||
276 | + gtk_widget_set_hexpand(values,TRUE); | ||
277 | + gtk_grid_attach(GTK_GRID(widget),values,0,8,10,2); | ||
278 | + | ||
198 | gtk_widget_show_all(GTK_WIDGET(widget)); | 279 | gtk_widget_show_all(GTK_WIDGET(widget)); |
199 | 280 | ||
200 | - } | 281 | + // Values |
282 | + { | ||
283 | + GtkWidget * box = create_grid(values,GTK_ALIGN_START); | ||
284 | + | ||
285 | + create_spin_button(widget, box, 0, LIB3270_FT_VALUE_LRECL); | ||
286 | + create_spin_button(widget, box, 1, LIB3270_FT_VALUE_BLKSIZE); | ||
287 | + | ||
288 | + } | ||
289 | + | ||
290 | + { | ||
291 | + GtkWidget * box = create_grid(values,GTK_ALIGN_CENTER); | ||
292 | + | ||
293 | + create_spin_button(widget, box, 0, LIB3270_FT_VALUE_PRIMSPACE); | ||
294 | + create_spin_button(widget, box, 1, LIB3270_FT_VALUE_SECSPACE); | ||
295 | + | ||
296 | + } | ||
201 | 297 | ||
298 | + { | ||
299 | + GtkWidget * box = create_grid(values,GTK_ALIGN_END); | ||
300 | + create_spin_button(widget, box, 0, LIB3270_FT_VALUE_DFT); | ||
301 | + | ||
302 | + } | ||
303 | + | ||
304 | + } | ||
202 | 305 | ||
203 | LIB3270_EXPORT GtkWidget * v3270_ft_settings_new() | 306 | LIB3270_EXPORT GtkWidget * v3270_ft_settings_new() |
204 | { | 307 | { |
src/v3270ft/tables.c
@@ -151,6 +151,7 @@ const struct v3270ft_type ft_type[] = { | @@ -151,6 +151,7 @@ const struct v3270ft_type ft_type[] = { | ||
151 | 151 | ||
152 | const struct v3270ft_value ft_value[] = { | 152 | const struct v3270ft_value ft_value[] = { |
153 | { | 153 | { |
154 | + // LIB3270_FT_VALUE_LRECL | ||
154 | "lrecl", | 155 | "lrecl", |
155 | 0, 32760, | 156 | 0, 32760, |
156 | N_( "Record Length:" ), | 157 | N_( "Record Length:" ), |
@@ -159,6 +160,7 @@ const struct v3270ft_value ft_value[] = { | @@ -159,6 +160,7 @@ const struct v3270ft_value ft_value[] = { | ||
159 | 160 | ||
160 | 161 | ||
161 | { | 162 | { |
163 | + // LIB3270_FT_VALUE_BLKSIZE | ||
162 | "primary", | 164 | "primary", |
163 | 0,99999, | 165 | 0,99999, |
164 | N_( "Primary space:" ), | 166 | N_( "Primary space:" ), |
@@ -166,6 +168,7 @@ const struct v3270ft_value ft_value[] = { | @@ -166,6 +168,7 @@ const struct v3270ft_value ft_value[] = { | ||
166 | }, | 168 | }, |
167 | 169 | ||
168 | { | 170 | { |
171 | + // LIB3270_FT_VALUE_PRIMSPACE | ||
169 | "blksize", | 172 | "blksize", |
170 | 0,32760, | 173 | 0,32760, |
171 | N_( "Block size:" ), | 174 | N_( "Block size:" ), |
@@ -177,6 +180,7 @@ const struct v3270ft_value ft_value[] = { | @@ -177,6 +180,7 @@ const struct v3270ft_value ft_value[] = { | ||
177 | }, | 180 | }, |
178 | 181 | ||
179 | { | 182 | { |
183 | + // LIB3270_FT_VALUE_SECSPACE | ||
180 | "secondary", | 184 | "secondary", |
181 | 0,99999, | 185 | 0,99999, |
182 | N_( "Secondary space:" ), | 186 | N_( "Secondary space:" ), |
@@ -184,6 +188,7 @@ const struct v3270ft_value ft_value[] = { | @@ -184,6 +188,7 @@ const struct v3270ft_value ft_value[] = { | ||
184 | }, | 188 | }, |
185 | 189 | ||
186 | { | 190 | { |
191 | + // LIB3270_FT_VALUE_DFT | ||
187 | "dft", | 192 | "dft", |
188 | 0,99999, | 193 | 0,99999, |
189 | N_( "DFT B_uffer size:" ), | 194 | N_( "DFT B_uffer size:" ), |
src/v3270ft/v3270ft.c
@@ -191,7 +191,7 @@ static void remove_file(G_GNUC_UNUSED GtkButton *button, v3270ft *dialog) { | @@ -191,7 +191,7 @@ static void remove_file(G_GNUC_UNUSED GtkButton *button, v3270ft *dialog) { | ||
191 | static void load_file(G_GNUC_UNUSED GtkButton *button, v3270ft *dialog) { | 191 | static void load_file(G_GNUC_UNUSED GtkButton *button, v3270ft *dialog) { |
192 | 192 | ||
193 | gchar * filename = v3270ft_select_file( | 193 | gchar * filename = v3270ft_select_file( |
194 | - dialog, | 194 | + GTK_WIDGET(dialog), |
195 | _("Load queue from file"), | 195 | _("Load queue from file"), |
196 | _("Load"), GTK_FILE_CHOOSER_ACTION_OPEN, | 196 | _("Load"), GTK_FILE_CHOOSER_ACTION_OPEN, |
197 | "", | 197 | "", |
@@ -210,7 +210,7 @@ static void load_file(G_GNUC_UNUSED GtkButton *button, v3270ft *dialog) { | @@ -210,7 +210,7 @@ static void load_file(G_GNUC_UNUSED GtkButton *button, v3270ft *dialog) { | ||
210 | static void save_file(G_GNUC_UNUSED GtkButton *button, v3270ft *dialog) { | 210 | static void save_file(G_GNUC_UNUSED GtkButton *button, v3270ft *dialog) { |
211 | 211 | ||
212 | gchar * filename = v3270ft_select_file( | 212 | gchar * filename = v3270ft_select_file( |
213 | - dialog, | 213 | + GTK_WIDGET(dialog), |
214 | _("Save queue to file"), | 214 | _("Save queue to file"), |
215 | _("Save"), | 215 | _("Save"), |
216 | GTK_FILE_CHOOSER_ACTION_SAVE, | 216 | GTK_FILE_CHOOSER_ACTION_SAVE, |
@@ -298,7 +298,7 @@ static void icon_press(G_GNUC_UNUSED GtkEntry *entry, G_GNUC_UNUSED GtkEntryIcon | @@ -298,7 +298,7 @@ static void icon_press(G_GNUC_UNUSED GtkEntry *entry, G_GNUC_UNUSED GtkEntryIcon | ||
298 | #endif // WIN32 | 298 | #endif // WIN32 |
299 | 299 | ||
300 | gchar *filename = v3270ft_select_file( | 300 | gchar *filename = v3270ft_select_file( |
301 | - dialog, | 301 | + GTK_WIDGET(dialog), |
302 | _("Select local file"), | 302 | _("Select local file"), |
303 | _("Select"), | 303 | _("Select"), |
304 | GTK_FILE_CHOOSER_ACTION_OPEN, | 304 | GTK_FILE_CHOOSER_ACTION_OPEN, |