Commit 553d56a4e8eed7e8c22ea5996f4cfbfada9db6bd
1 parent
ae787d0a
Exists in
master
and in
5 other branches
Iniciando implementação do dialogo de impressao
Showing
3 changed files
with
74 additions
and
5 deletions
Show diff stats
src/gtk/actions.c
... | ... | @@ -458,9 +458,9 @@ GtkAction * ui_get_action(GtkWidget *widget, const gchar *name, GHashTable *hash |
458 | 458 | } |
459 | 459 | else if(!g_strcasecmp(name,"print")) |
460 | 460 | { |
461 | - static const GCallback cbk[] = { G_CALLBACK(nop_action), | |
462 | - G_CALLBACK(nop_action), | |
463 | - G_CALLBACK(nop_action) | |
461 | + static const GCallback cbk[] = { G_CALLBACK(print_all_action), | |
462 | + G_CALLBACK(print_selected_action), | |
463 | + G_CALLBACK(print_copy_action) | |
464 | 464 | }; |
465 | 465 | |
466 | 466 | callback = cbk; | ... | ... |
src/gtk/print.c
... | ... | @@ -34,10 +34,79 @@ |
34 | 34 | |
35 | 35 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
36 | 36 | |
37 | + static void begin_print(GtkPrintOperation *prt, GtkPrintContext *context, gpointer user_data) | |
38 | + { | |
39 | + trace("%s",__FUNCTION__); | |
40 | + | |
41 | + } | |
42 | + | |
43 | + static void draw_page(GtkPrintOperation *prt, GtkPrintContext *context, gint pg, gpointer user_data) | |
44 | + { | |
45 | + trace("%s",__FUNCTION__); | |
46 | + | |
47 | + } | |
48 | + | |
49 | + static void done(GtkPrintOperation *prt, GtkPrintOperationResult result, gpointer user_data) | |
50 | + { | |
51 | + trace("%s",__FUNCTION__); | |
52 | + | |
53 | + } | |
54 | + | |
55 | + static GObject * create_custom_widget(GtkPrintOperation *prt, gpointer user_data) | |
56 | + { | |
57 | + GtkWidget * font_dialog = gtk_font_selection_new(); | |
58 | + trace("%s",__FUNCTION__); | |
59 | + return G_OBJECT(font_dialog); | |
60 | + } | |
61 | + | |
62 | + static void custom_widget_apply(GtkPrintOperation *prt, GtkWidget *font_dialog, gpointer user_data) | |
63 | + { | |
64 | + trace("%s",__FUNCTION__); | |
65 | + } | |
66 | + | |
67 | + static GtkPrintOperation * begin_print_operation(GtkAction *action, GtkWidget *widget) | |
68 | + { | |
69 | + GtkPrintOperation * print = gtk_print_operation_new(); | |
70 | +// GtkPrintSettings * settings = gtk_print_settings_new(); | |
71 | +// GtkPageSetup * setup = gtk_page_setup_new(); | |
72 | + gchar * ptr; | |
73 | + | |
74 | + // Basic setup | |
75 | + gtk_print_operation_set_allow_async(print,FALSE); | |
76 | + | |
77 | + ptr = g_strconcat(PACKAGE_NAME,".",gtk_action_get_name(action),NULL); | |
78 | + gtk_print_operation_set_job_name(print,ptr); | |
79 | + g_free(ptr); | |
80 | + | |
81 | + gtk_print_operation_set_custom_tab_label(print,_( "Style" )); | |
82 | + | |
83 | + gtk_print_operation_set_show_progress(print,TRUE); | |
84 | + | |
85 | + // Common signals | |
86 | + g_signal_connect(print,"begin_print",G_CALLBACK(begin_print),0); | |
87 | + g_signal_connect(print,"draw_page",G_CALLBACK(draw_page),0); | |
88 | + g_signal_connect(print,"done",G_CALLBACK(done),0); | |
89 | +// g_signal_connect(print,"create-custom-widget",G_CALLBACK(create_custom_widget), 0); | |
90 | +// g_signal_connect(print,"custom-widget-apply",G_CALLBACK(custom_widget_apply),0); | |
91 | + | |
92 | + // Finish settings | |
93 | + // gtk_print_operation_set_print_settings(print,settings); | |
94 | + // gtk_print_operation_set_default_page_setup(print,setup); | |
95 | + | |
96 | + return print; | |
97 | + } | |
98 | + | |
37 | 99 | void print_all_action(GtkAction *action, GtkWidget *widget) |
38 | 100 | { |
39 | - trace("Action %s activated on widget %p",gtk_action_get_name(action),widget); | |
101 | + GtkPrintOperation *print = begin_print_operation(action,widget); | |
102 | + | |
103 | + trace("Action %s activated on widget %p print=%p",gtk_action_get_name(action),widget,print); | |
104 | + | |
105 | + // Run Print dialog | |
106 | + gtk_print_operation_run(print,GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,GTK_WINDOW(gtk_widget_get_toplevel(widget)),NULL); | |
107 | + | |
40 | 108 | |
109 | + g_object_unref(print); | |
41 | 110 | } |
42 | 111 | |
43 | 112 | void print_selected_action(GtkAction *action, GtkWidget *widget) | ... | ... |
ui/00default.xml
... | ... | @@ -37,7 +37,7 @@ |
37 | 37 | <menuitem action='save' src='selected' group='selection' label='Save selected' /> |
38 | 38 | <menuitem action='save' src='copy' group='clipboard' label='Save copy' /> |
39 | 39 | <separator/> |
40 | - <menuitem action='print' src='all' key='Print' icon='print' group='online' label='Print' /> | |
40 | + <menuitem action='print' src='all' key='Print' icon='print' label='Print' /> | |
41 | 41 | <menuitem action='print' src='selected' group='selection' label='Print selected' /> |
42 | 42 | <menuitem action='print' src='copy' group='clipboard' label='Print copy' /> |
43 | 43 | <separator/> | ... | ... |