diff --git a/src/dialogs/fontselect.c b/src/dialogs/fontselect.c index 1e11652..de06b6d 100644 --- a/src/dialogs/fontselect.c +++ b/src/dialogs/fontselect.c @@ -89,6 +89,9 @@ GtkTreeModel * model = gtk_combo_box_get_model(GTK_COMBO_BOX(widget)); GtkTreeIter iter; + if(!fontname) + fontname = "monospace"; + if(gtk_tree_model_get_iter_first(model,&iter)) { do diff --git a/src/dialogs/print/draw.c b/src/dialogs/print/draw.c index 04efafe..3c59fd7 100644 --- a/src/dialogs/print/draw.c +++ b/src/dialogs/print/draw.c @@ -122,7 +122,7 @@ // Draw character. unsigned short attr = selection->contents[pos].attribute.visual; - if(!operation->show_selection) + if(!operation->settings.show_selection) attr &= ~LIB3270_ATTR_SELECTED; v3270_draw_element( diff --git a/src/dialogs/print/print.c b/src/dialogs/print/print.c index a2db99d..464e519 100644 --- a/src/dialogs/print/print.c +++ b/src/dialogs/print/print.c @@ -102,7 +102,7 @@ static GtkWidget * custom_widget_new(GtkPrintOperation *prt) { GtkWidget * widget = gtk_frame_new(""); - GtkWidget * settings = V3270_print_settings_new(GTK_WIDGET(GTK_V3270_PRINT_OPERATION(prt)->widget)); + GtkWidget * settings = V3270_print_settings_new_from_operation(prt); GtkWidget *label = gtk_label_new(NULL); gtk_label_set_markup(GTK_LABEL(label),_("Text options")); @@ -138,8 +138,8 @@ V3270PrintOperation * operation = GTK_V3270_PRINT_OPERATION(prt); // Setup options. - operation->show_selection = v3270_print_settings_get_show_selection(settings); - operation->font.name = v3270_print_settings_get_font_family(settings); + operation->settings.show_selection = v3270_print_settings_get_show_selection(settings); + operation->font.name = v3270_print_settings_get_font_family(settings); v3270_print_settings_get_rgba(settings, operation->settings.colors, V3270_COLOR_COUNT); @@ -170,9 +170,9 @@ gtk_print_operation_set_default_page_setup(GTK_PRINT_OPERATION(widget),gtk_page_setup_new()); // Setup defaults - widget->mode = LIB3270_CONTENT_ALL; - widget->show_selection = FALSE; - widget->font.name = NULL; // g_strdup(v3270_default_font); + widget->mode = LIB3270_CONTENT_ALL; + widget->settings.show_selection = FALSE; + widget->font.name = NULL; // g_strdup(v3270_default_font); } diff --git a/src/dialogs/print/private.h b/src/dialogs/print/private.h index 6526806..841f649 100644 --- a/src/dialogs/print/private.h +++ b/src/dialogs/print/private.h @@ -52,7 +52,6 @@ LIB3270_CONTENT_OPTION mode; v3270 * widget; H3270 * session; - gboolean show_selection; ///< @brief Print selection box? size_t lpp; ///< @brief Lines per page (in rows). size_t pages; ///< @brief Number of pages. @@ -60,6 +59,7 @@ struct { GdkRGBA colors[V3270_COLOR_COUNT]; ///< @brief Color scheme for printing. + gboolean show_selection; ///< @brief Print selection box? } settings; diff --git a/src/dialogs/print/settings.c b/src/dialogs/print/settings.c index 0c6c18c..5d347dc 100644 --- a/src/dialogs/print/settings.c +++ b/src/dialogs/print/settings.c @@ -120,6 +120,21 @@ LIB3270_EXPORT GtkWidget * V3270_print_settings_new(GtkWidget *widget) } +LIB3270_EXPORT GtkWidget * V3270_print_settings_new_from_operation(GtkPrintOperation *operation) +{ + g_return_val_if_fail(GTK_IS_V3270_PRINT_OPERATION(operation),NULL); + + V3270PrintOperation * opr = GTK_V3270_PRINT_OPERATION(operation); + V3270PrintSettings * settings = GTK_V3270_PRINT_SETTINGS(g_object_new(GTK_TYPE_V3270_PRINT_SETTINGS, NULL)); + + v3270_font_selection_set_family(settings->font, opr->font.name); + v3270_color_scheme_set_rgba(settings->color,opr->settings.colors); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(settings->selected),opr->settings.show_selection); + + return GTK_WIDGET(settings); + +} + LIB3270_EXPORT int v3270_print_settings_get_rgba(GtkWidget *widget, GdkRGBA *colors, size_t num_colors) { V3270PrintSettings * settings = GTK_V3270_PRINT_SETTINGS(widget); diff --git a/src/include/v3270/print.h b/src/include/v3270/print.h index b59e902..8cc72f6 100644 --- a/src/include/v3270/print.h +++ b/src/include/v3270/print.h @@ -82,6 +82,8 @@ LIB3270_EXPORT GType V3270PrintSettings_get_type(void); LIB3270_EXPORT GtkWidget * V3270_print_settings_new(GtkWidget *widget); + LIB3270_EXPORT GtkWidget * V3270_print_settings_new_from_operation(GtkPrintOperation *operation); + LIB3270_EXPORT gboolean v3270_print_settings_get_show_selection(GtkWidget *widget); LIB3270_EXPORT void v3270_print_settings_set_show_selection(GtkWidget *widget, gboolean is_active); LIB3270_EXPORT gchar * v3270_print_settings_get_color_scheme(GtkWidget *widget); -- libgit2 0.21.2