Commit 97a58c8f4ccf02f9ddba64f41f8861562b810a75
1 parent
6fde193e
Exists in
master
and in
1 other branch
Implementing clipboard settings dialog.
Showing
4 changed files
with
93 additions
and
75 deletions
Show diff stats
src/dialogs/settings/clipboard.c
@@ -88,7 +88,7 @@ | @@ -88,7 +88,7 @@ | ||
88 | .n_columns = 2, | 88 | .n_columns = 2, |
89 | .types = (const GType []) { | 89 | .types = (const GType []) { |
90 | G_TYPE_STRING, | 90 | G_TYPE_STRING, |
91 | - G_TYPE_UINT | 91 | + G_TYPE_STRING |
92 | } | 92 | } |
93 | 93 | ||
94 | }, | 94 | }, |
@@ -105,7 +105,7 @@ | @@ -105,7 +105,7 @@ | ||
105 | .n_columns = 2, | 105 | .n_columns = 2, |
106 | .types = (const GType []) { | 106 | .types = (const GType []) { |
107 | G_TYPE_STRING, | 107 | G_TYPE_STRING, |
108 | - G_TYPE_UINT | 108 | + G_TYPE_STRING |
109 | } | 109 | } |
110 | 110 | ||
111 | }, | 111 | }, |
@@ -122,7 +122,7 @@ | @@ -122,7 +122,7 @@ | ||
122 | .n_columns = 2, | 122 | .n_columns = 2, |
123 | .types = (const GType []) { | 123 | .types = (const GType []) { |
124 | G_TYPE_STRING, | 124 | G_TYPE_STRING, |
125 | - G_TYPE_UINT | 125 | + G_TYPE_STRING |
126 | } | 126 | } |
127 | 127 | ||
128 | }, | 128 | }, |
@@ -168,17 +168,8 @@ static void V3270ClipboardSettings_class_init(V3270ClipboardSettingsClass *klass | @@ -168,17 +168,8 @@ static void V3270ClipboardSettings_class_init(V3270ClipboardSettingsClass *klass | ||
168 | 168 | ||
169 | static void copy_format_changed(GtkComboBox *widget, GtkWidget *grid) { | 169 | static void copy_format_changed(GtkComboBox *widget, GtkWidget *grid) { |
170 | 170 | ||
171 | - GtkTreeIter iter; | ||
172 | - | ||
173 | - if(gtk_combo_box_get_active_iter(widget,&iter)) { | ||
174 | - | ||
175 | - GValue value = { 0, }; | ||
176 | - gtk_tree_model_get_value(gtk_combo_box_get_model(widget),&iter,1,&value); | ||
177 | - guint flag = g_value_get_uint(&value); | ||
178 | - gtk_widget_set_sensitive(grid,flag == 1); | ||
179 | - g_value_unset(&value); | ||
180 | - | ||
181 | - } | 171 | + const gchar * active = gtk_combo_box_get_active_id(widget); |
172 | + gtk_widget_set_sensitive(grid,active && *active == '1'); | ||
182 | 173 | ||
183 | } | 174 | } |
184 | 175 | ||
@@ -235,12 +226,14 @@ static void V3270ClipboardSettings_init(V3270ClipboardSettings *widget) { | @@ -235,12 +226,14 @@ static void V3270ClipboardSettings_init(V3270ClipboardSettings *widget) { | ||
235 | model = GTK_LIST_STORE(gtk_combo_box_get_model(widget->input.combos[1])); | 226 | model = GTK_LIST_STORE(gtk_combo_box_get_model(widget->input.combos[1])); |
236 | for(ix = 0;ix < G_N_ELEMENTS(html_color_options); ix++) { | 227 | for(ix = 0;ix < G_N_ELEMENTS(html_color_options); ix++) { |
237 | 228 | ||
229 | + gchar id[] = { '0' + ix, 0 }; | ||
230 | + | ||
238 | gtk_list_store_append(model, &iter); | 231 | gtk_list_store_append(model, &iter); |
239 | gtk_list_store_set( | 232 | gtk_list_store_set( |
240 | model, | 233 | model, |
241 | &iter, | 234 | &iter, |
242 | 0, g_dgettext(PACKAGE_NAME, html_color_options[ix]), | 235 | 0, g_dgettext(PACKAGE_NAME, html_color_options[ix]), |
243 | - 1, (guint) ix, | 236 | + 1, id, |
244 | -1 | 237 | -1 |
245 | ); | 238 | ); |
246 | 239 | ||
@@ -276,7 +269,7 @@ static void V3270ClipboardSettings_init(V3270ClipboardSettings *widget) { | @@ -276,7 +269,7 @@ static void V3270ClipboardSettings_init(V3270ClipboardSettings *widget) { | ||
276 | (GtkListStore *) model, | 269 | (GtkListStore *) model, |
277 | &iter, | 270 | &iter, |
278 | 0, label ? label : group[ix], | 271 | 0, label ? label : group[ix], |
279 | - 1, (guint) 99, | 272 | + 1, "S", |
280 | -1 | 273 | -1 |
281 | ); | 274 | ); |
282 | 275 | ||
@@ -296,15 +289,21 @@ static void V3270ClipboardSettings_init(V3270ClipboardSettings *widget) { | @@ -296,15 +289,21 @@ static void V3270ClipboardSettings_init(V3270ClipboardSettings *widget) { | ||
296 | N_("Complete with terminal attributes") | 289 | N_("Complete with terminal attributes") |
297 | }; | 290 | }; |
298 | 291 | ||
292 | + gtk_combo_box_set_id_column(widget->input.combos[0],1); | ||
293 | + gtk_combo_box_set_id_column(widget->input.combos[1],1); | ||
294 | + gtk_combo_box_set_id_column(widget->input.combos[2],1); | ||
295 | + | ||
299 | model = GTK_LIST_STORE(gtk_combo_box_get_model(widget->input.combos[2])); | 296 | model = GTK_LIST_STORE(gtk_combo_box_get_model(widget->input.combos[2])); |
300 | for(ix = 0;ix < G_N_ELEMENTS(copy_formats); ix++) { | 297 | for(ix = 0;ix < G_N_ELEMENTS(copy_formats); ix++) { |
301 | 298 | ||
299 | + gchar id[] = { '0' + ix, 0 }; | ||
300 | + | ||
302 | gtk_list_store_append(model, &iter); | 301 | gtk_list_store_append(model, &iter); |
303 | gtk_list_store_set( | 302 | gtk_list_store_set( |
304 | model, | 303 | model, |
305 | &iter, | 304 | &iter, |
306 | 0, g_dgettext(PACKAGE_NAME, copy_formats[ix]), | 305 | 0, g_dgettext(PACKAGE_NAME, copy_formats[ix]), |
307 | - 1, (guint) ix, | 306 | + 1, id, |
308 | -1 | 307 | -1 |
309 | ); | 308 | ); |
310 | 309 | ||
@@ -347,12 +346,14 @@ static void load(GtkWidget *w, GtkWidget *t) { | @@ -347,12 +346,14 @@ static void load(GtkWidget *w, GtkWidget *t) { | ||
347 | gtk_list_store_clear(model); | 346 | gtk_list_store_clear(model); |
348 | for(ix = 0;ix < G_N_ELEMENTS(html_font_options); ix++) { | 347 | for(ix = 0;ix < G_N_ELEMENTS(html_font_options); ix++) { |
349 | 348 | ||
349 | + gchar id[] = { '0' + ix, 0 }; | ||
350 | + | ||
350 | gtk_list_store_append(model, &iter); | 351 | gtk_list_store_append(model, &iter); |
351 | gtk_list_store_set( | 352 | gtk_list_store_set( |
352 | model, | 353 | model, |
353 | &iter, | 354 | &iter, |
354 | 0, g_dgettext(PACKAGE_NAME, html_font_options[ix]), | 355 | 0, g_dgettext(PACKAGE_NAME, html_font_options[ix]), |
355 | - 1, (guint) ix, | 356 | + 1, id, |
356 | -1 | 357 | -1 |
357 | ); | 358 | ); |
358 | 359 | ||
@@ -371,7 +372,7 @@ static void load(GtkWidget *w, GtkWidget *t) { | @@ -371,7 +372,7 @@ static void load(GtkWidget *w, GtkWidget *t) { | ||
371 | GtkTreeIter iter; | 372 | GtkTreeIter iter; |
372 | 373 | ||
373 | gtk_list_store_append((GtkListStore *) model,&iter); | 374 | gtk_list_store_append((GtkListStore *) model,&iter); |
374 | - gtk_list_store_set((GtkListStore *) model, &iter,0, name, 1, (guint) 99, -1); | 375 | + gtk_list_store_set((GtkListStore *) model, &iter,0, name, 1, "S", -1); |
375 | 376 | ||
376 | } | 377 | } |
377 | 378 | ||
@@ -379,15 +380,82 @@ static void load(GtkWidget *w, GtkWidget *t) { | @@ -379,15 +380,82 @@ static void load(GtkWidget *w, GtkWidget *t) { | ||
379 | 380 | ||
380 | } | 381 | } |
381 | 382 | ||
382 | - gtk_combo_box_select_column_uint(widget->input.combos[2],1,((terminal->selection.options & V3270_SELECTION_PLAIN_TEXT) ? 0 : 1)); | 383 | + debug("Plain text: %s",((terminal->selection.options & V3270_SELECTION_PLAIN_TEXT) ? "0" : "1")); |
384 | + gtk_combo_box_set_active_id(widget->input.combos[2],(terminal->selection.options & (V3270_SELECTION_ENABLE_HTML|V3270_SELECTION_DIALOG_STATE)) == 0 ? "0" : "1"); | ||
383 | 385 | ||
384 | } | 386 | } |
385 | 387 | ||
386 | -static void apply(GtkWidget *w, GtkWidget *terminal) { | 388 | +static gchar get_active_id(V3270ClipboardSettings *widget, size_t combo) { |
389 | + | ||
390 | + const gchar * id = gtk_combo_box_get_active_id(widget->input.combos[combo]); | ||
391 | + | ||
392 | + if(id) | ||
393 | + return id[0]; | ||
394 | + | ||
395 | + return '?'; | ||
396 | +} | ||
397 | + | ||
398 | +static void apply(GtkWidget *w, GtkWidget *t) { | ||
387 | 399 | ||
388 | V3270ClipboardSettings *widget = (V3270ClipboardSettings *) w; | 400 | V3270ClipboardSettings *widget = (V3270ClipboardSettings *) w; |
401 | + v3270 *terminal = GTK_V3270(t); | ||
402 | + | ||
403 | + v3270_settings_apply_toggle_buttons(toggles,G_N_ELEMENTS(toggles),t,widget->input.toggles); | ||
404 | + | ||
405 | + if(gtk_combo_box_get_active_id(widget->input.combos[2])[0] == '0') { | ||
389 | 406 | ||
390 | - v3270_settings_apply_toggle_buttons(toggles,G_N_ELEMENTS(toggles),terminal,widget->input.toggles); | 407 | + terminal->selection.options &= ~(V3270_SELECTION_ENABLE_HTML|V3270_SELECTION_DIALOG_STATE); |
408 | + | ||
409 | + } else { | ||
410 | + | ||
411 | + terminal->selection.options |= V3270_SELECTION_DIALOG_STATE; | ||
412 | + terminal->selection.options |= V3270_SELECTION_NON_BREAKABLE_SPACE; // TODO: Use a checkbox to enable-it | ||
413 | + | ||
414 | + // Get font settings | ||
415 | + switch(get_active_id(widget,0)) { | ||
416 | + case '0': | ||
417 | + // Disable font information | ||
418 | + debug("%s","Disable font information"); | ||
419 | + terminal->selection.options &= ~V3270_SELECTION_FONT_FAMILY; | ||
420 | + break; | ||
421 | + | ||
422 | + case '1': | ||
423 | + // Use same font of the screen | ||
424 | + debug("%s","Use same font of the screen"); | ||
425 | + terminal->selection.options |= V3270_SELECTION_FONT_FAMILY; | ||
426 | + break; | ||
427 | + | ||
428 | + case 'S': | ||
429 | + // Use selected font | ||
430 | + debug("%s","Use selected font"); | ||
431 | + terminal->selection.options |= V3270_SELECTION_FONT_FAMILY; | ||
432 | + break; | ||
433 | + | ||
434 | + } | ||
435 | + | ||
436 | + switch(get_active_id(widget,1)) { | ||
437 | + case '0': | ||
438 | + | ||
439 | + // Disable color information | ||
440 | + debug("%s","Disable color information"); | ||
441 | + terminal->selection.options &= ~V3270_SELECTION_COLORS; | ||
442 | + break; | ||
443 | + | ||
444 | + case '1': | ||
445 | + | ||
446 | + // Use same colors of the screen | ||
447 | + debug("%s","Use same colors of the screen"); | ||
448 | + terminal->selection.options |= V3270_SELECTION_COLORS; | ||
449 | + break; | ||
450 | + | ||
451 | + case 'S': | ||
452 | + // Use selected color scheme | ||
453 | + debug("%s","Use selected color scheme"); | ||
454 | + terminal->selection.options |= V3270_SELECTION_COLORS; | ||
455 | + | ||
456 | + } | ||
457 | + | ||
458 | + } | ||
391 | 459 | ||
392 | } | 460 | } |
393 | 461 |
src/dialogs/settings/private.h
@@ -34,8 +34,6 @@ | @@ -34,8 +34,6 @@ | ||
34 | #include <lib3270/toggle.h> | 34 | #include <lib3270/toggle.h> |
35 | #include <v3270/settings.h> | 35 | #include <v3270/settings.h> |
36 | 36 | ||
37 | - G_GNUC_INTERNAL void gtk_combo_box_select_column_uint(GtkComboBox * combo_box, gint column, guint value); | ||
38 | - | ||
39 | /// @brief Toggle button factory. | 37 | /// @brief Toggle button factory. |
40 | struct ToggleButtonDefinition { | 38 | struct ToggleButtonDefinition { |
41 | gint left; | 39 | gint left; |
src/dialogs/settings/tools.c
@@ -131,54 +131,4 @@ | @@ -131,54 +131,4 @@ | ||
131 | 131 | ||
132 | } | 132 | } |
133 | 133 | ||
134 | - struct combo_select_uint { | ||
135 | - GtkComboBox * combo_box; | ||
136 | - gint column; | ||
137 | - guint new_value; | ||
138 | - }; | ||
139 | - | ||
140 | - static gboolean test_combo_select_uint(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, struct combo_select_uint *arg) { | ||
141 | - | ||
142 | - // Get value | ||
143 | - GValue value = { 0, }; | ||
144 | - gtk_tree_model_get_value(model,iter,arg->column,&value); | ||
145 | - guint row_value = g_value_get_uint(&value); | ||
146 | - g_value_unset(&value); | ||
147 | - | ||
148 | - if(row_value == arg->new_value) { | ||
149 | - gtk_combo_box_set_active_iter(arg->combo_box,iter); | ||
150 | - return TRUE; | ||
151 | - } | ||
152 | - | ||
153 | - return FALSE; | ||
154 | - } | ||
155 | - | ||
156 | - void gtk_combo_box_select_column_uint(GtkComboBox * combo_box, gint column, guint new_value) { | ||
157 | - | ||
158 | - GtkTreeIter iter; | ||
159 | - GtkListStore * list = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(combo_box))); | ||
160 | - | ||
161 | - // Is the value already selected? | ||
162 | - if(gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo_box),&iter)) { | ||
163 | - | ||
164 | - GValue value = { 0, }; | ||
165 | - gtk_tree_model_get_value(GTK_TREE_MODEL(list),&iter,column,&value); | ||
166 | - guint active = g_value_get_uint(&value); | ||
167 | - g_value_unset(&value); | ||
168 | - | ||
169 | - if(active == new_value) | ||
170 | - return; | ||
171 | - | ||
172 | - } | ||
173 | - | ||
174 | - // No, it's not, find one. | ||
175 | - struct combo_select_uint arg = { | ||
176 | - .combo_box = combo_box, | ||
177 | - .column = column, | ||
178 | - .new_value = new_value | ||
179 | - }; | ||
180 | - | ||
181 | - gtk_tree_model_foreach(GTK_TREE_MODEL(list),(GtkTreeModelForeachFunc) test_combo_select_uint, &arg); | ||
182 | - } | ||
183 | - | ||
184 | 134 |
src/include/terminal.h
@@ -124,10 +124,12 @@ G_BEGIN_DECLS | @@ -124,10 +124,12 @@ G_BEGIN_DECLS | ||
124 | V3270_SELECTION_FONT_FAMILY = 0x0001, ///< @brief Inform font-family. | 124 | V3270_SELECTION_FONT_FAMILY = 0x0001, ///< @brief Inform font-family. |
125 | V3270_SELECTION_COLORS = 0x0002, ///< @brief Inform terminal colors. | 125 | V3270_SELECTION_COLORS = 0x0002, ///< @brief Inform terminal colors. |
126 | V3270_SELECTION_NON_BREAKABLE_SPACE = 0x0004, ///< @brief Use non breakable spaces. | 126 | V3270_SELECTION_NON_BREAKABLE_SPACE = 0x0004, ///< @brief Use non breakable spaces. |
127 | + V3270_SELECTION_DIALOG_STATE = 0x0010, ///< @brief Used for settings dialog. | ||
127 | 128 | ||
128 | } V3270SelectionOption; | 129 | } V3270SelectionOption; |
129 | 130 | ||
130 | - #define V3270_SELECTION_DEFAULT (V3270_SELECTION_FONT_FAMILY|V3270_SELECTION_COLORS|V3270_SELECTION_NON_BREAKABLE_SPACE) | 131 | + #define V3270_SELECTION_DEFAULT (V3270_SELECTION_FONT_FAMILY|V3270_SELECTION_COLORS|V3270_SELECTION_NON_BREAKABLE_SPACE) |
132 | + #define V3270_SELECTION_ENABLE_HTML (V3270_SELECTION_FONT_FAMILY|V3270_SELECTION_COLORS|V3270_SELECTION_NON_BREAKABLE_SPACE) | ||
131 | 133 | ||
132 | /*--[ Globals ]--------------------------------------------------------------------------------------*/ | 134 | /*--[ Globals ]--------------------------------------------------------------------------------------*/ |
133 | 135 |