From 1c2b276912917735c52be04ced4f3cff1bb09795 Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Wed, 31 Jul 2019 16:38:50 -0300 Subject: [PATCH] Addint methods to get/set properties on the print operation dialog. --- src/dialogs/colorscheme.c | 47 ++++++++++++++++++++++++++++++----------------- src/dialogs/print/convenience.c | 28 ---------------------------- src/dialogs/print/print.c | 32 ++++++++++++++++++++++++++++++++ src/include/internals.h | 4 ++++ src/include/v3270/print.h | 9 ++++++++- 5 files changed, 74 insertions(+), 46 deletions(-) diff --git a/src/dialogs/colorscheme.c b/src/dialogs/colorscheme.c index 2742139..d6baf79 100644 --- a/src/dialogs/colorscheme.c +++ b/src/dialogs/colorscheme.c @@ -363,33 +363,40 @@ gchar * v3270_color_scheme_get_text(GtkWidget *widget) { GdkRGBA * clr = NULL; - GValue value = { 0, }; + gchar * rc = NULL; + GValue value = { 0, }; GtkTreeIter iter; - int f; if(!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(widget),&iter)) return NULL; gtk_tree_model_get_value(gtk_combo_box_get_model(GTK_COMBO_BOX(widget)),&iter,1,&value); clr = g_value_get_pointer(&value); - GString *str = g_string_new(""); if(clr) + rc = v3270_translate_rgba_to_text(clr); + + g_value_unset(&value); + + return rc; + + } + + gchar * v3270_translate_rgba_to_text(GdkRGBA *clr) + { + int f; + GString *str = g_string_new(""); + + for(f=0;ffont.name) + g_free(opr->font.name); + + opr->font.name = g_strdup(fontname); + + return TRUE; + +} + +gchar * v3270_print_operation_get_font_family(GtkPrintOperation *operation) +{ + g_return_val_if_fail(GTK_IS_V3270_PRINT_OPERATION(operation),NULL); + return g_strdup(GTK_V3270_PRINT_OPERATION(operation)->font.name); +} + +void v3270_print_operation_set_color_scheme(GtkPrintOperation *operation, const gchar *colors) +{ + g_return_if_fail(GTK_IS_V3270_PRINT_OPERATION(operation)); + v3270_translate_text_to_rgba(colors,GTK_V3270_PRINT_OPERATION(operation)->settings.colors); +} + +gchar * v3270_print_operation_get_color_scheme(GtkPrintOperation *operation) +{ + g_return_val_if_fail(GTK_IS_V3270_PRINT_OPERATION(operation),NULL); + return v3270_translate_rgba_to_text(GTK_V3270_PRINT_OPERATION(operation)->settings.colors); +} diff --git a/src/include/internals.h b/src/include/internals.h index 2ee0e95..9cccfb7 100644 --- a/src/include/internals.h +++ b/src/include/internals.h @@ -238,6 +238,10 @@ G_GNUC_INTERNAL GSource * IO_source_new(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*call)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata); G_GNUC_INTERNAL void IO_source_set_state(GSource *source, gboolean enable); + // Tools + G_GNUC_INTERNAL void v3270_translate_text_to_rgba(const gchar *colors, GdkRGBA *clr); + G_GNUC_INTERNAL gchar * v3270_translate_rgba_to_text(GdkRGBA *clr); + G_END_DECLS #endif // V3270_INTERNALS_H_INCLUDED diff --git a/src/include/v3270/print.h b/src/include/v3270/print.h index d5b07b5..b59e902 100644 --- a/src/include/v3270/print.h +++ b/src/include/v3270/print.h @@ -64,9 +64,16 @@ LIB3270_EXPORT GType V3270PrintOperation_get_type(void); LIB3270_EXPORT GtkPrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_CONTENT_OPTION mode); - LIB3270_EXPORT GtkWidget * v3270_print_operation_get_terminal(GtkPrintOperation *operation); LIB3270_EXPORT void v3270_print_operation_apply_settings(GtkPrintOperation *operation, GtkWidget *settings); + LIB3270_EXPORT GtkWidget * v3270_print_operation_get_terminal(GtkPrintOperation *operation); + + LIB3270_EXPORT gboolean v3270_print_operation_set_font_family(GtkPrintOperation *operation, const gchar *fontname); + LIB3270_EXPORT gchar * v3270_print_operation_get_font_family(GtkPrintOperation *operation); + + LIB3270_EXPORT void v3270_print_operation_set_color_scheme(GtkPrintOperation *operation, const gchar *colors); + LIB3270_EXPORT gchar * v3270_print_operation_get_color_scheme(GtkPrintOperation *operation); + LIB3270_EXPORT GtkTreeModel * v3270_font_family_model_new(GtkWidget *widget, const gchar *selected, GtkTreeIter * active); LIB3270_EXPORT GtkWidget * v3270_font_selection_new(const gchar *fontname); -- libgit2 0.21.2