Commit a3de0daff7230248fc14750443befe2534909445
1 parent
3e66dbe3
Exists in
master
and in
5 other branches
Implementando dialogo de impressao
Showing
2 changed files
with
55 additions
and
15 deletions
Show diff stats
src/gtk/print.c
... | ... | @@ -32,31 +32,70 @@ |
32 | 32 | #include "globals.h" |
33 | 33 | #include "v3270/v3270.h" |
34 | 34 | |
35 | +/*--[ Structs ]--------------------------------------------------------------------------------------*/ | |
36 | + | |
37 | + typedef struct _print_info | |
38 | + { | |
39 | + GdkColor color[V3270_COLOR_COUNT]; | |
40 | + | |
41 | + } PRINT_INFO; | |
42 | + | |
35 | 43 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
36 | 44 | |
37 | - static void begin_print(GtkPrintOperation *prt, GtkPrintContext *context, gpointer user_data) | |
45 | + static void begin_print(GtkPrintOperation *prt, GtkPrintContext *context, PRINT_INFO *info) | |
38 | 46 | { |
39 | 47 | trace("%s",__FUNCTION__); |
40 | 48 | gtk_print_operation_cancel(prt); |
41 | 49 | } |
42 | 50 | |
43 | - static void draw_page(GtkPrintOperation *prt, GtkPrintContext *context, gint pg, gpointer user_data) | |
51 | + static void draw_page(GtkPrintOperation *prt, GtkPrintContext *context, gint pg, PRINT_INFO *info) | |
44 | 52 | { |
45 | 53 | trace("%s",__FUNCTION__); |
46 | 54 | |
47 | 55 | } |
48 | 56 | |
49 | - static void done(GtkPrintOperation *prt, GtkPrintOperationResult result, gpointer user_data) | |
57 | + static void done(GtkPrintOperation *prt, GtkPrintOperationResult result, PRINT_INFO *info) | |
50 | 58 | { |
51 | 59 | trace("%s",__FUNCTION__); |
52 | 60 | |
61 | + | |
62 | + g_free(info); | |
53 | 63 | } |
54 | 64 | |
55 | - static GObject * create_custom_widget(GtkPrintOperation *prt, gpointer user_data) | |
65 | +#if GTK_CHECK_VERSION(3,2,0) | |
66 | + static gboolean filter_monospaced(const PangoFontFamily *family,const PangoFontFace *face,gpointer data) | |
56 | 67 | { |
57 | - GtkWidget * font_dialog = gtk_font_selection_new(); | |
58 | - trace("%s",__FUNCTION__); | |
59 | - return G_OBJECT(font_dialog); | |
68 | + return pango_font_family_is_monospace((PangoFontFamily *) family); | |
69 | + } | |
70 | +#endif // GTK(3,2,0) | |
71 | + | |
72 | + static GObject * create_custom_widget(GtkPrintOperation *prt, PRINT_INFO *info) | |
73 | + { | |
74 | + static const gchar * label[] = { "Font:", "Colors:" }; | |
75 | + GtkWidget * container = gtk_table_new(2,2,FALSE); | |
76 | + GtkWidget * widget; | |
77 | + int f; | |
78 | + | |
79 | + for(f=0;f<G_N_ELEMENTS(label);f++) | |
80 | + { | |
81 | + widget = gtk_label_new(label[f]); | |
82 | + gtk_misc_set_alignment(GTK_MISC(widget),0,0.5); | |
83 | + gtk_table_attach(GTK_TABLE(container),widget,0,1,f,f+1,GTK_FILL,GTK_FILL,0,0); | |
84 | + } | |
85 | + | |
86 | + // Font selection button | |
87 | + widget = gtk_font_button_new(); | |
88 | + gtk_font_button_set_show_size(GTK_FONT_BUTTON(widget),FALSE); | |
89 | +#if GTK_CHECK_VERSION(3,2,0) | |
90 | + gtk_font_chooser_set_filter_func(widget,filter_monospaced,0); | |
91 | +#endif // GTK(3,2,0) | |
92 | + gtk_table_attach(GTK_TABLE(container),widget,1,2,0,1,GTK_EXPAND|GTK_FILL,GTK_FILL,5,0); | |
93 | + | |
94 | + // Color scheme dropdown | |
95 | + | |
96 | + // Show and return | |
97 | + gtk_widget_show_all(container); | |
98 | + return G_OBJECT(container); | |
60 | 99 | } |
61 | 100 | |
62 | 101 | static void custom_widget_apply(GtkPrintOperation *prt, GtkWidget *font_dialog, gpointer user_data) |
... | ... | @@ -66,13 +105,14 @@ |
66 | 105 | |
67 | 106 | static GtkPrintOperation * begin_print_operation(GtkAction *action, GtkWidget *widget) |
68 | 107 | { |
108 | + PRINT_INFO * info = g_new0(PRINT_INFO,1); | |
69 | 109 | GtkPrintOperation * print = gtk_print_operation_new(); |
70 | 110 | // GtkPrintSettings * settings = gtk_print_settings_new(); |
71 | 111 | // GtkPageSetup * setup = gtk_page_setup_new(); |
72 | 112 | // gchar * ptr; |
73 | 113 | |
74 | 114 | // Basic setup |
75 | - gtk_print_operation_set_allow_async(print,FALSE); | |
115 | + gtk_print_operation_set_allow_async(print,TRUE); | |
76 | 116 | |
77 | 117 | /* |
78 | 118 | ptr = g_strconcat(PACKAGE_NAME,".",gtk_action_get_name(action),NULL); |
... | ... | @@ -80,16 +120,16 @@ |
80 | 120 | g_free(ptr); |
81 | 121 | */ |
82 | 122 | |
83 | -// gtk_print_operation_set_custom_tab_label(print,_( "Style" )); | |
123 | + gtk_print_operation_set_custom_tab_label(print,_( "Style" )); | |
84 | 124 | |
85 | 125 | // gtk_print_operation_set_show_progress(print,TRUE); |
86 | 126 | |
87 | 127 | // Common signals |
88 | - g_signal_connect(print,"begin_print",G_CALLBACK(begin_print),0); | |
89 | - g_signal_connect(print,"draw_page",G_CALLBACK(draw_page),0); | |
90 | - g_signal_connect(print,"done",G_CALLBACK(done),0); | |
91 | -// g_signal_connect(print,"create-custom-widget",G_CALLBACK(create_custom_widget), 0); | |
92 | -// g_signal_connect(print,"custom-widget-apply",G_CALLBACK(custom_widget_apply),0); | |
128 | + g_signal_connect(print,"begin_print",G_CALLBACK(begin_print),info); | |
129 | + g_signal_connect(print,"draw_page",G_CALLBACK(draw_page),info); | |
130 | + g_signal_connect(print,"done",G_CALLBACK(done),info); | |
131 | + g_signal_connect(print,"create-custom-widget",G_CALLBACK(create_custom_widget), info); | |
132 | + g_signal_connect(print,"custom-widget-apply",G_CALLBACK(custom_widget_apply), info); | |
93 | 133 | |
94 | 134 | // Finish settings |
95 | 135 | // gtk_print_operation_set_print_settings(print,settings); | ... | ... |
src/gtk/v3270/v3270.h
... | ... | @@ -166,7 +166,7 @@ |
166 | 166 | struct v3270_metrics metrics; |
167 | 167 | |
168 | 168 | /* Colors */ |
169 | - GdkColor color[V3270_COLOR_COUNT+1]; /**< Terminal widget colors */ | |
169 | + GdkColor color[V3270_COLOR_COUNT]; /**< Terminal widget colors */ | |
170 | 170 | |
171 | 171 | /* Regions */ |
172 | 172 | GdkRectangle oia_rect[V3270_OIA_FIELD_COUNT]; | ... | ... |