Commit 55be299a11561cb945b288ace73c7e197c01dcd1

Authored by Perry Werneck
1 parent 26bed00a
Exists in master and in 1 other branch develop

Print dialog doesn't follow the gnome style, fixing custom widget to

match.
src/dialogs/fontselect.c
@@ -27,28 +27,30 @@ @@ -27,28 +27,30 @@
27 * 27 *
28 */ 28 */
29 29
  30 + #include <string.h>
30 #include <v3270.h> 31 #include <v3270.h>
31 #include <v3270/print.h> 32 #include <v3270/print.h>
32 #include <lib3270/log.h> 33 #include <lib3270/log.h>
33 34
34 /*--[ Widget definition ]----------------------------------------------------------------------------*/ 35 /*--[ Widget definition ]----------------------------------------------------------------------------*/
35 36
36 - LIB3270_EXPORT GtkWidget * v3270_font_selection_new(const gchar *fontname) 37 + LIB3270_EXPORT GtkTreeModel * v3270_font_family_model_new(GtkWidget *widget, const gchar *selected, GtkTreeIter * active)
37 { 38 {
38 - GtkTreeModel * model = (GtkTreeModel *) gtk_list_store_new(1,G_TYPE_STRING);  
39 - GtkWidget * widget = gtk_combo_box_new_with_model(model); 39 + GtkTreeModel * model = (GtkTreeModel *) gtk_list_store_new(1,G_TYPE_STRING);
40 40
41 - GtkCellRenderer * renderer = gtk_cell_renderer_text_new(); 41 + GtkCellRenderer * renderer = gtk_cell_renderer_text_new();
42 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget), renderer, TRUE); 42 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget), renderer, TRUE);
43 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(widget), renderer, "text", 0, NULL); 43 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(widget), renderer, "text", 0, NULL);
44 44
45 - if(!(fontname && *fontname))  
46 - fontname = v3270_get_default_font_name();  
47 -  
48 gint n_families, i; 45 gint n_families, i;
49 PangoFontFamily **families; 46 PangoFontFamily **families;
50 pango_context_list_families(gtk_widget_get_pango_context(widget),&families, &n_families); 47 pango_context_list_families(gtk_widget_get_pango_context(widget),&families, &n_families);
51 48
  49 + if(!(selected && *selected))
  50 + selected = v3270_get_default_font_name();
  51 +
  52 + memset(active,0,sizeof(GtkTreeIter));
  53 +
52 for(i=0; i < n_families; i++) 54 for(i=0; i < n_families; i++)
53 { 55 {
54 if(!pango_font_family_is_monospace(families[i])) 56 if(!pango_font_family_is_monospace(families[i]))
@@ -60,13 +62,25 @@ @@ -60,13 +62,25 @@
60 gtk_list_store_append((GtkListStore *) model,&iter); 62 gtk_list_store_append((GtkListStore *) model,&iter);
61 gtk_list_store_set((GtkListStore *) model, &iter,0, name, -1); 63 gtk_list_store_set((GtkListStore *) model, &iter,0, name, -1);
62 64
63 - if(!g_ascii_strcasecmp(name,fontname))  
64 - gtk_combo_box_set_active_iter(GTK_COMBO_BOX(widget),&iter); 65 + if(!g_ascii_strcasecmp(name,selected))
  66 + *active = iter;
65 67
66 } 68 }
67 69
68 g_free(families); 70 g_free(families);
69 71
  72 + return model;
  73 + }
  74 +
  75 + LIB3270_EXPORT GtkWidget * v3270_font_selection_new(const gchar *selected)
  76 + {
  77 + GtkWidget * widget = gtk_combo_box_new();
  78 + GtkTreeIter active;
  79 + GtkTreeModel * model = v3270_font_family_model_new(widget,selected,&active);
  80 +
  81 + gtk_combo_box_set_model(GTK_COMBO_BOX(widget),model);
  82 + gtk_combo_box_set_active_iter(GTK_COMBO_BOX(widget),&active);
  83 +
70 return widget; 84 return widget;
71 } 85 }
72 86
src/dialogs/print/print.c
@@ -84,8 +84,8 @@ @@ -84,8 +84,8 @@
84 { 84 {
85 static const gchar * text[] = 85 static const gchar * text[] =
86 { 86 {
87 - N_( "_Font" ),  
88 - N_( "C_olor scheme" ) 87 + N_( "_Font:" ),
  88 + N_( "C_olor scheme:" )
89 }; 89 };
90 90
91 size_t f; 91 size_t f;
@@ -97,13 +97,27 @@ @@ -97,13 +97,27 @@
97 97
98 // Create dialog 98 // Create dialog
99 99
  100 + GtkWidget * frame = gtk_frame_new("");
100 GtkGrid * grid = GTK_GRID(gtk_grid_new()); 101 GtkGrid * grid = GTK_GRID(gtk_grid_new());
101 GtkWidget * font = v3270_font_selection_new(operation->font.name); 102 GtkWidget * font = v3270_font_selection_new(operation->font.name);
102 GtkWidget * color = v3270_color_scheme_new(); 103 GtkWidget * color = v3270_color_scheme_new();
103 GtkWidget * selected = gtk_check_button_new_with_label( _("Print selection box") ); 104 GtkWidget * selected = gtk_check_button_new_with_label( _("Print selection box") );
104 105
105 - // https://developer.gnome.org/hig/stable/visual-layout.html.en  
106 - gtk_container_set_border_width(GTK_CONTAINER(grid),18); 106 + // The print dialog doesn't follow the guidelines from https://developer.gnome.org/hig/stable/visual-layout.html.en )-:
  107 +
  108 + gtk_frame_set_shadow_type(GTK_FRAME(frame),GTK_SHADOW_NONE);
  109 +
  110 + GtkWidget *label = gtk_label_new(NULL);
  111 +
  112 + gtk_label_set_markup(GTK_LABEL(label),_("<b>Text options</b>"));
  113 + gtk_frame_set_label_widget(GTK_FRAME(frame),label);
  114 +
  115 + gtk_container_set_border_width(GTK_CONTAINER(frame),12);
  116 +
  117 + gtk_container_set_border_width(GTK_CONTAINER(grid),6);
  118 +
  119 + g_object_set(G_OBJECT(grid),"margin-start",8,NULL);
  120 +
107 gtk_grid_set_row_spacing(grid,6); 121 gtk_grid_set_row_spacing(grid,6);
108 gtk_grid_set_column_spacing(grid,12); 122 gtk_grid_set_column_spacing(grid,12);
109 123
@@ -116,7 +130,7 @@ @@ -116,7 +130,7 @@
116 for(f=0;f<G_N_ELEMENTS(text);f++) 130 for(f=0;f<G_N_ELEMENTS(text);f++)
117 { 131 {
118 GtkWidget *label = gtk_label_new_with_mnemonic(gettext(text[f])); 132 GtkWidget *label = gtk_label_new_with_mnemonic(gettext(text[f]));
119 - gtk_widget_set_halign(label,GTK_ALIGN_END); 133 + gtk_widget_set_halign(label,GTK_ALIGN_START);
120 gtk_grid_attach(grid,label,0,f,1,1); 134 gtk_grid_attach(grid,label,0,f,1,1);
121 } 135 }
122 136
@@ -124,8 +138,10 @@ @@ -124,8 +138,10 @@
124 gtk_grid_attach(grid,color,1,1,1,1); 138 gtk_grid_attach(grid,color,1,1,1,1);
125 gtk_grid_attach(grid,selected,1,2,1,1); 139 gtk_grid_attach(grid,selected,1,2,1,1);
126 140
127 - gtk_widget_show_all(GTK_WIDGET(grid));  
128 - return GTK_WIDGET(grid); 141 + gtk_container_add(GTK_CONTAINER(frame),GTK_WIDGET(grid));
  142 +
  143 + gtk_widget_show_all(GTK_WIDGET(frame));
  144 + return frame;
129 } 145 }
130 146
131 static void custom_widget_apply(GtkPrintOperation *prt, GtkWidget G_GNUC_UNUSED(*widget)) 147 static void custom_widget_apply(GtkPrintOperation *prt, GtkWidget G_GNUC_UNUSED(*widget))
@@ -194,7 +210,7 @@ @@ -194,7 +210,7 @@
194 // Setup defaults 210 // Setup defaults
195 widget->mode = LIB3270_PRINT_ALL; 211 widget->mode = LIB3270_PRINT_ALL;
196 widget->show_selection = FALSE; 212 widget->show_selection = FALSE;
197 - widget->font.name = g_strdup(v3270_default_font); 213 + widget->font.name = NULL; // g_strdup(v3270_default_font);
198 widget->contents.width = 80; 214 widget->contents.width = 80;
199 215
200 v3270_set_mono_color_table(widget->colors,"#000000","#FFFFFF"); 216 v3270_set_mono_color_table(widget->colors,"#000000","#FFFFFF");
@@ -210,6 +226,7 @@ V3270PrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_PRINT @@ -210,6 +226,7 @@ V3270PrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_PRINT
210 operation->mode = mode; 226 operation->mode = mode;
211 operation->widget = GTK_V3270(widget); 227 operation->widget = GTK_V3270(widget);
212 operation->session = v3270_get_session(widget); 228 operation->session = v3270_get_session(widget);
  229 + operation->font.name = g_strdup(v3270_get_font_family(widget));
213 230
214 V3270PrintOperation_set_text_by_mode(operation, mode); 231 V3270PrintOperation_set_text_by_mode(operation, mode);
215 232
src/include/v3270/print.h
@@ -54,7 +54,8 @@ @@ -54,7 +54,8 @@
54 LIB3270_EXPORT V3270PrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_PRINT_MODE mode); 54 LIB3270_EXPORT V3270PrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_PRINT_MODE mode);
55 LIB3270_EXPORT void V3270PrintOperation_set_text_by_mode(V3270PrintOperation * operation, LIB3270_PRINT_MODE mode); 55 LIB3270_EXPORT void V3270PrintOperation_set_text_by_mode(V3270PrintOperation * operation, LIB3270_PRINT_MODE mode);
56 56
57 - LIB3270_EXPORT GtkWidget * v3270_font_selection_new(const gchar *fontname); 57 + LIB3270_EXPORT GtkTreeModel * v3270_font_family_model_new(GtkWidget *widget, const gchar *selected, GtkTreeIter * active);
  58 + LIB3270_EXPORT GtkWidget * v3270_font_selection_new(const gchar *fontname);
58 59
59 60
60 LIB3270_EXPORT GType V3270PrintOperation_get_type(void); 61 LIB3270_EXPORT GType V3270PrintOperation_get_type(void);
src/testprogram/testprogram.c
@@ -168,6 +168,7 @@ static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) { @@ -168,6 +168,7 @@ static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) {
168 168
169 v3270_set_url(terminal,NULL); 169 v3270_set_url(terminal,NULL);
170 170
  171 + // v3270_set_font_family(terminal,"Droid Sans Mono");
171 g_signal_connect(terminal,"field_clicked",G_CALLBACK(field_clicked),window); 172 g_signal_connect(terminal,"field_clicked",G_CALLBACK(field_clicked),window);
172 173
173 GtkWidget *trace = v3270_new_trace_window(terminal,NULL); 174 GtkWidget *trace = v3270_new_trace_window(terminal,NULL);