Commit 320424c69b76154522e056d297d32e52ae122699
1 parent
c146f368
Exists in
master
and in
1 other branch
Rewriting file transfer settings widget.
Showing
1 changed file
with
70 additions
and
28 deletions
Show diff stats
src/v3270ft/settings.c
| ... | ... | @@ -49,6 +49,9 @@ |
| 49 | 49 | GtkEntry * remote; |
| 50 | 50 | } file; |
| 51 | 51 | |
| 52 | + GtkWidget * recordFormatBox; | |
| 53 | + GtkWidget * spaceAllocationBox; | |
| 54 | + | |
| 52 | 55 | GtkWidget * options[NUM_OPTIONS_WIDGETS]; |
| 53 | 56 | GtkWidget * spins[LIB3270_FT_VALUE_COUNT]; |
| 54 | 57 | }; |
| ... | ... | @@ -140,37 +143,74 @@ |
| 140 | 143 | |
| 141 | 144 | static void open_select_file_dialog(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconPosition icon_pos, G_GNUC_UNUSED GdkEvent *event, GtkWidget *widget) |
| 142 | 145 | { |
| 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 ); | |
| 146 | + v3270_autofree gchar *filename = | |
| 147 | + v3270ft_select_file( | |
| 148 | + gtk_widget_get_toplevel(widget), | |
| 149 | + _("Select local file"), | |
| 150 | + _("Select"), | |
| 151 | + GTK_FILE_CHOOSER_ACTION_OPEN, | |
| 152 | + gtk_entry_get_text(entry), | |
| 153 | + N_("All files"), "*.*", | |
| 154 | + N_("Text files"), "*.txt", | |
| 155 | + NULL | |
| 156 | + ); | |
| 152 | 157 | |
| 153 | 158 | if(filename) { |
| 154 | - | |
| 155 | 159 | gtk_entry_set_text(entry,filename); |
| 160 | + } | |
| 161 | + | |
| 162 | + } | |
| 163 | + | |
| 164 | + static void set_options(V3270FTSettings *widget, LIB3270_FT_OPTION options) | |
| 165 | + { | |
| 166 | + size_t ix; | |
| 156 | 167 | |
| 157 | - /* | |
| 158 | - const gchar *remote = gtk_entry_get_text(dialog->remote); | |
| 168 | + if(options & LIB3270_FT_OPTION_RECEIVE) | |
| 169 | + { | |
| 170 | + debug("%s option selected","LIB3270_FT_OPTION_RECEIVE"); | |
| 159 | 171 | |
| 160 | - gtk_entry_set_text(dialog->local,filename); | |
| 172 | + gtk_widget_set_sensitive(widget->recordFormatBox,FALSE); | |
| 173 | + gtk_widget_set_sensitive(widget->spaceAllocationBox,FALSE); | |
| 161 | 174 | |
| 162 | - if(!*remote) { | |
| 163 | - gchar * text = g_path_get_basename(filename); | |
| 164 | - gtk_entry_set_text(dialog->remote,text); | |
| 165 | - g_free(text); | |
| 175 | + for(ix = 0; ix < 4; ix++) { | |
| 176 | + gtk_widget_set_sensitive(widget->spins[ix],FALSE); | |
| 177 | + gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget->spins[ix]),0); | |
| 166 | 178 | } |
| 167 | 179 | |
| 168 | - g_free(filename); | |
| 169 | - */ | |
| 180 | + } | |
| 181 | + else | |
| 182 | + { | |
| 183 | + debug("%s option selected","LIB3270_FT_OPTION_SEND"); | |
| 184 | + | |
| 185 | + gtk_widget_set_sensitive(widget->recordFormatBox,TRUE); | |
| 186 | + gtk_widget_set_sensitive(widget->spaceAllocationBox,TRUE); | |
| 187 | + | |
| 188 | + for(ix = 0; ix < 4; ix++) { | |
| 189 | + gtk_widget_set_sensitive(widget->spins[ix],TRUE); | |
| 190 | + gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget->spins[ix]),0); | |
| 191 | + } | |
| 170 | 192 | |
| 171 | 193 | } |
| 172 | 194 | |
| 173 | -} | |
| 195 | + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget->options[4]),TRUE); | |
| 196 | + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget->options[8]),TRUE); | |
| 197 | + | |
| 198 | + for(ix=0;ix<NUM_OPTIONS_WIDGETS;ix++) { | |
| 199 | + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget->options[ix]),(options & ft_option[ix].opt) == ft_option[ix].opt); | |
| 200 | + } | |
| 201 | + | |
| 202 | + } | |
| 203 | + | |
| 204 | + static void transfer_type_changed(GtkComboBox *widget, V3270FTSettings *dialog) | |
| 205 | + { | |
| 206 | + gint selected = gtk_combo_box_get_active(widget); | |
| 207 | + | |
| 208 | + debug("Transfer type=%u", (unsigned int) selected); | |
| 209 | + | |
| 210 | + if(selected >= 0) | |
| 211 | + set_options(dialog,ft_type[selected].opt); | |
| 212 | + | |
| 213 | + } | |
| 174 | 214 | |
| 175 | 215 | static void V3270FTSettings_init(V3270FTSettings *widget) |
| 176 | 216 | { |
| ... | ... | @@ -182,10 +222,12 @@ static void open_select_file_dialog(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconP |
| 182 | 222 | |
| 183 | 223 | // Operation type |
| 184 | 224 | { |
| 185 | - GtkTreeModel * model = GTK_TREE_MODEL(gtk_list_store_new(2,G_TYPE_STRING,G_TYPE_ULONG)); | |
| 225 | + GtkTreeModel * model = GTK_TREE_MODEL(gtk_list_store_new(1,G_TYPE_STRING)); | |
| 186 | 226 | GtkWidget * entry = create_entry(widget,"_Operation",gtk_combo_box_new_with_model(model),0,0,9); |
| 187 | 227 | GtkCellRenderer * renderer = gtk_cell_renderer_text_new(); |
| 188 | 228 | |
| 229 | + g_signal_connect(G_OBJECT(entry),"changed",G_CALLBACK(transfer_type_changed),widget); | |
| 230 | + | |
| 189 | 231 | gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(entry), renderer, TRUE); |
| 190 | 232 | gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(entry), renderer, "text", 0, NULL); |
| 191 | 233 | |
| ... | ... | @@ -193,7 +235,7 @@ static void open_select_file_dialog(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconP |
| 193 | 235 | { |
| 194 | 236 | GtkTreeIter iter; |
| 195 | 237 | gtk_list_store_append((GtkListStore *) model,&iter); |
| 196 | - gtk_list_store_set((GtkListStore *) model, &iter, 0, gettext(ft_type[ix].label),-1); | |
| 238 | + gtk_list_store_set((GtkListStore *) model, &iter, 0, gettext(ft_type[ix].label), -1); | |
| 197 | 239 | } |
| 198 | 240 | |
| 199 | 241 | |
| ... | ... | @@ -239,8 +281,8 @@ static void open_select_file_dialog(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconP |
| 239 | 281 | |
| 240 | 282 | // Record format |
| 241 | 283 | { |
| 242 | - GtkWidget * box = create_frame(options, _("Record format"), gtk_box_new(GTK_ORIENTATION_VERTICAL,6),GTK_ALIGN_CENTER); | |
| 243 | - GSList * group = NULL; | |
| 284 | + GSList * group = NULL; | |
| 285 | + widget->recordFormatBox = create_frame(options, _("Record format"), gtk_box_new(GTK_ORIENTATION_VERTICAL,6),GTK_ALIGN_CENTER); | |
| 244 | 286 | |
| 245 | 287 | for(ix=4;ix<8;ix++) |
| 246 | 288 | { |
| ... | ... | @@ -248,15 +290,15 @@ static void open_select_file_dialog(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconP |
| 248 | 290 | gtk_widget_set_tooltip_markup(widget->options[ix],gettext(ft_option[ix].tooltip)); |
| 249 | 291 | group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(widget->options[ix])); |
| 250 | 292 | // g_signal_connect(G_OBJECT(widget->options[ix]),"toggled",G_CALLBACK(option_toggled),widget); |
| 251 | - gtk_box_pack_start(GTK_BOX(box),widget->options[ix],FALSE,TRUE,0); | |
| 293 | + gtk_box_pack_start(GTK_BOX(widget->recordFormatBox),widget->options[ix],FALSE,TRUE,0); | |
| 252 | 294 | |
| 253 | 295 | } |
| 254 | 296 | } |
| 255 | 297 | |
| 256 | 298 | // Space allocation units |
| 257 | 299 | { |
| 258 | - GtkWidget * box = create_frame(options, _("Space allocation units"), gtk_box_new(GTK_ORIENTATION_VERTICAL,6),GTK_ALIGN_END); | |
| 259 | - GSList * group = NULL; | |
| 300 | + GSList * group = NULL; | |
| 301 | + widget->spaceAllocationBox = create_frame(options, _("Space allocation units"), gtk_box_new(GTK_ORIENTATION_VERTICAL,6),GTK_ALIGN_END); | |
| 260 | 302 | |
| 261 | 303 | for(ix=8;ix<12;ix++) |
| 262 | 304 | { |
| ... | ... | @@ -264,7 +306,7 @@ static void open_select_file_dialog(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconP |
| 264 | 306 | gtk_widget_set_tooltip_markup(widget->options[ix],gettext(ft_option[ix].tooltip)); |
| 265 | 307 | group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(widget->options[ix])); |
| 266 | 308 | // g_signal_connect(G_OBJECT(widget->options[ix]),"toggled",G_CALLBACK(option_toggled),widget); |
| 267 | - gtk_box_pack_start(GTK_BOX(box),widget->options[ix],FALSE,TRUE,0); | |
| 309 | + gtk_box_pack_start(GTK_BOX(widget->spaceAllocationBox),widget->options[ix],FALSE,TRUE,0); | |
| 268 | 310 | |
| 269 | 311 | } |
| 270 | 312 | } | ... | ... |