Commit 4460bdccafb7cf8ddd08e806d001cae7e611e901
1 parent
15c6d6d2
Exists in
v5.2
Removing warnings about no printer settings.
Cleaning unused code.
Showing
2 changed files
with
25 additions
and
48 deletions
Show diff stats
src/pw3270/linux/print.c
@@ -37,76 +37,44 @@ | @@ -37,76 +37,44 @@ | ||
37 | 37 | ||
38 | /*--[ Implement ]------------------------------------------------------------------------------------*/ | 38 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
39 | 39 | ||
40 | -/* | ||
41 | - static GtkWidget * create_custom_widget(GtkPrintOperation *prt, gpointer G_GNUC_UNUSED(dunno)) | ||
42 | - { | ||
43 | - GtkWidget * widget = gtk_frame_new(""); | ||
44 | - GtkWidget * settings = V3270_print_settings_new(v3270_print_operation_get_terminal(prt)); | ||
45 | - | ||
46 | - // Load values from configuration | ||
47 | - g_autofree gchar * font_family = get_string_from_config("print",FONT_CONFIG,DEFAULT_FONT); | ||
48 | - if(font_family && *font_family) | ||
49 | - v3270_print_settings_set_font_family(settings,font_family); | ||
50 | - | ||
51 | - g_autofree gchar * color_scheme = get_string_from_config("print","colors",""); | ||
52 | - if(color_scheme && *color_scheme) | ||
53 | - v3270_print_settings_set_color_scheme(settings,color_scheme); | ||
54 | - | ||
55 | - // Create frame | ||
56 | - GtkWidget *label = gtk_label_new(NULL); | ||
57 | - gtk_label_set_markup(GTK_LABEL(label),_("<b>Text options</b>")); | ||
58 | - gtk_frame_set_label_widget(GTK_FRAME(widget),label); | ||
59 | - | ||
60 | - gtk_container_set_border_width(GTK_CONTAINER(widget),12); | ||
61 | - | ||
62 | - // The print dialog doesn't follow the guidelines from https://developer.gnome.org/hig/stable/visual-layout.html.en )-: | ||
63 | - gtk_frame_set_shadow_type(GTK_FRAME(widget),GTK_SHADOW_NONE); | ||
64 | - | ||
65 | - gtk_container_set_border_width(GTK_CONTAINER(settings),6); | ||
66 | - g_object_set(G_OBJECT(settings),"margin-start",8,NULL); | ||
67 | - | ||
68 | - gtk_container_add(GTK_CONTAINER(widget),settings); | ||
69 | - | ||
70 | - gtk_widget_show_all(widget); | ||
71 | - | ||
72 | - return widget; | ||
73 | - } | ||
74 | -*/ | ||
75 | - | ||
76 | -/* | ||
77 | - static void custom_widget_apply(GtkPrintOperation *prt, GtkWidget *widget, gpointer G_GNUC_UNUSED(dunno)) | ||
78 | - { | ||
79 | - GtkWidget * settings = gtk_bin_get_child(GTK_BIN(widget)); | ||
80 | - v3270_print_operation_apply_settings(prt,settings); | ||
81 | - } | ||
82 | -*/ | ||
83 | - | ||
84 | void load_print_operation_settings(GtkPrintOperation * operation) | 40 | void load_print_operation_settings(GtkPrintOperation * operation) |
85 | { | 41 | { |
86 | GtkPrintSettings * settings = gtk_print_settings_new(); | 42 | GtkPrintSettings * settings = gtk_print_settings_new(); |
87 | GtkPageSetup * setup = gtk_page_setup_new(); | 43 | GtkPageSetup * setup = gtk_page_setup_new(); |
88 | GtkPaperSize * papersize = NULL; | 44 | GtkPaperSize * papersize = NULL; |
89 | 45 | ||
90 | -// g_signal_connect(operation,"create-custom-widget",G_CALLBACK(create_custom_widget),NULL); | ||
91 | -// g_signal_connect(operation,"custom-widget-apply",G_CALLBACK(custom_widget_apply), NULL); | 46 | + trace("%s(%p)",__FUNCTION__,operation); |
47 | + g_message("Loading print settings"); | ||
92 | 48 | ||
93 | // Load page and print settings | 49 | // Load page and print settings |
94 | GKeyFile * conf = get_application_keyfile(); | 50 | GKeyFile * conf = get_application_keyfile(); |
95 | GError * err = NULL; | 51 | GError * err = NULL; |
96 | 52 | ||
97 | - if(!gtk_print_settings_load_key_file(settings,conf,"print_settings",&err)) | 53 | + if(g_key_file_has_group(conf,"print_settings") && !gtk_print_settings_load_key_file(settings,conf,"print_settings",&err)) |
98 | { | 54 | { |
99 | g_warning("Error getting print settings: %s",err->message); | 55 | g_warning("Error getting print settings: %s",err->message); |
100 | g_error_free(err); | 56 | g_error_free(err); |
101 | err = NULL; | 57 | err = NULL; |
102 | } | 58 | } |
59 | +#ifdef DEBUG | ||
60 | + else | ||
61 | + { | ||
62 | + trace("%p using default print settings",operation); | ||
63 | + } | ||
64 | +#endif // DEBUG | ||
103 | 65 | ||
104 | - if(!gtk_page_setup_load_key_file(setup,conf,"page_setup",&err)) | 66 | + if(g_key_file_has_group(conf,"page_setup") && !gtk_page_setup_load_key_file(setup,conf,"page_setup",&err)) |
105 | { | 67 | { |
106 | g_warning("Error getting page setup: %s",err->message); | 68 | g_warning("Error getting page setup: %s",err->message); |
107 | g_error_free(err); | 69 | g_error_free(err); |
108 | err = NULL; | 70 | err = NULL; |
109 | } | 71 | } |
72 | +#ifdef DEBUG | ||
73 | + else | ||
74 | + { | ||
75 | + trace("%p using default page setup",operation); | ||
76 | + } | ||
77 | +#endif // DEBUG | ||
110 | 78 | ||
111 | if(g_key_file_has_group(conf,"paper_size")) | 79 | if(g_key_file_has_group(conf,"paper_size")) |
112 | { | 80 | { |
@@ -149,6 +117,7 @@ | @@ -149,6 +117,7 @@ | ||
149 | GtkPageSetup * pgsetup = gtk_print_operation_get_default_page_setup(operation); | 117 | GtkPageSetup * pgsetup = gtk_print_operation_get_default_page_setup(operation); |
150 | GtkPaperSize * papersize = gtk_page_setup_get_paper_size(pgsetup); | 118 | GtkPaperSize * papersize = gtk_page_setup_get_paper_size(pgsetup); |
151 | 119 | ||
120 | + trace("%s(%p)",__FUNCTION__,operation); | ||
152 | g_message("Saving print settings"); | 121 | g_message("Saving print settings"); |
153 | 122 | ||
154 | GKeyFile * conf = get_application_keyfile(); | 123 | GKeyFile * conf = get_application_keyfile(); |
src/pw3270/print.c
@@ -70,6 +70,8 @@ | @@ -70,6 +70,8 @@ | ||
70 | 70 | ||
71 | gtk_print_operation_set_allow_async(operation,get_boolean_from_config("print","allow_async",TRUE)); | 71 | gtk_print_operation_set_allow_async(operation,get_boolean_from_config("print","allow_async",TRUE)); |
72 | 72 | ||
73 | + trace("Allow async is %s",get_boolean_from_config("print","allow_async",TRUE) ? "TRUE" : "FALSE"); | ||
74 | + | ||
73 | load_print_operation_settings(operation); | 75 | load_print_operation_settings(operation); |
74 | 76 | ||
75 | // | 77 | // |
@@ -98,6 +100,8 @@ | @@ -98,6 +100,8 @@ | ||
98 | } | 100 | } |
99 | else | 101 | else |
100 | { | 102 | { |
103 | + trace("Print operation result was %u",(unsigned int) result); | ||
104 | + | ||
101 | switch(result) | 105 | switch(result) |
102 | { | 106 | { |
103 | case GTK_PRINT_OPERATION_RESULT_ERROR: // An error has occurred. | 107 | case GTK_PRINT_OPERATION_RESULT_ERROR: // An error has occurred. |
@@ -121,18 +125,22 @@ | @@ -121,18 +125,22 @@ | ||
121 | break; | 125 | break; |
122 | 126 | ||
123 | case GTK_PRINT_OPERATION_RESULT_APPLY: // The print settings should be stored. | 127 | case GTK_PRINT_OPERATION_RESULT_APPLY: // The print settings should be stored. |
128 | + trace("%s","GTK_PRINT_OPERATION_RESULT_APPLY"); | ||
124 | save_print_operation_settings(operation); | 129 | save_print_operation_settings(operation); |
125 | break; | 130 | break; |
126 | 131 | ||
127 | case GTK_PRINT_OPERATION_RESULT_CANCEL: // The print operation has been canceled, the print settings should not be stored. | 132 | case GTK_PRINT_OPERATION_RESULT_CANCEL: // The print operation has been canceled, the print settings should not be stored. |
133 | + trace("%s","GTK_PRINT_OPERATION_RESULT_CANCEL"); | ||
128 | g_message("Print operation was cancelled"); | 134 | g_message("Print operation was cancelled"); |
129 | break; | 135 | break; |
130 | 136 | ||
131 | case GTK_PRINT_OPERATION_RESULT_IN_PROGRESS: // The print operation is not complete yet. This value will only be returned when running asynchronously. | 137 | case GTK_PRINT_OPERATION_RESULT_IN_PROGRESS: // The print operation is not complete yet. This value will only be returned when running asynchronously. |
138 | + trace("%s","GTK_PRINT_OPERATION_RESULT_IN_PROGRESS"); | ||
132 | g_message("Print operation is in progress"); | 139 | g_message("Print operation is in progress"); |
133 | break; | 140 | break; |
134 | 141 | ||
135 | default: | 142 | default: |
143 | + trace("%s","Unexpected"); | ||
136 | g_warning("Unexpected print operation result: %d",(int) result); | 144 | g_warning("Unexpected print operation result: %d",(int) result); |
137 | 145 | ||
138 | } | 146 | } |