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,31 +32,70 @@ | ||
32 | #include "globals.h" | 32 | #include "globals.h" |
33 | #include "v3270/v3270.h" | 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 | /*--[ Implement ]------------------------------------------------------------------------------------*/ | 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 | trace("%s",__FUNCTION__); | 47 | trace("%s",__FUNCTION__); |
40 | gtk_print_operation_cancel(prt); | 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 | trace("%s",__FUNCTION__); | 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 | trace("%s",__FUNCTION__); | 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 | static void custom_widget_apply(GtkPrintOperation *prt, GtkWidget *font_dialog, gpointer user_data) | 101 | static void custom_widget_apply(GtkPrintOperation *prt, GtkWidget *font_dialog, gpointer user_data) |
@@ -66,13 +105,14 @@ | @@ -66,13 +105,14 @@ | ||
66 | 105 | ||
67 | static GtkPrintOperation * begin_print_operation(GtkAction *action, GtkWidget *widget) | 106 | static GtkPrintOperation * begin_print_operation(GtkAction *action, GtkWidget *widget) |
68 | { | 107 | { |
108 | + PRINT_INFO * info = g_new0(PRINT_INFO,1); | ||
69 | GtkPrintOperation * print = gtk_print_operation_new(); | 109 | GtkPrintOperation * print = gtk_print_operation_new(); |
70 | // GtkPrintSettings * settings = gtk_print_settings_new(); | 110 | // GtkPrintSettings * settings = gtk_print_settings_new(); |
71 | // GtkPageSetup * setup = gtk_page_setup_new(); | 111 | // GtkPageSetup * setup = gtk_page_setup_new(); |
72 | // gchar * ptr; | 112 | // gchar * ptr; |
73 | 113 | ||
74 | // Basic setup | 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 | ptr = g_strconcat(PACKAGE_NAME,".",gtk_action_get_name(action),NULL); | 118 | ptr = g_strconcat(PACKAGE_NAME,".",gtk_action_get_name(action),NULL); |
@@ -80,16 +120,16 @@ | @@ -80,16 +120,16 @@ | ||
80 | g_free(ptr); | 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 | // gtk_print_operation_set_show_progress(print,TRUE); | 125 | // gtk_print_operation_set_show_progress(print,TRUE); |
86 | 126 | ||
87 | // Common signals | 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 | // Finish settings | 134 | // Finish settings |
95 | // gtk_print_operation_set_print_settings(print,settings); | 135 | // gtk_print_operation_set_print_settings(print,settings); |
src/gtk/v3270/v3270.h
@@ -166,7 +166,7 @@ | @@ -166,7 +166,7 @@ | ||
166 | struct v3270_metrics metrics; | 166 | struct v3270_metrics metrics; |
167 | 167 | ||
168 | /* Colors */ | 168 | /* Colors */ |
169 | - GdkColor color[V3270_COLOR_COUNT+1]; /**< Terminal widget colors */ | 169 | + GdkColor color[V3270_COLOR_COUNT]; /**< Terminal widget colors */ |
170 | 170 | ||
171 | /* Regions */ | 171 | /* Regions */ |
172 | GdkRectangle oia_rect[V3270_OIA_FIELD_COUNT]; | 172 | GdkRectangle oia_rect[V3270_OIA_FIELD_COUNT]; |