Commit 0bd7e473044fad59eb73e41697332f4fb84452c7
1 parent
438f898a
Exists in
master
and in
1 other branch
Fixing memory leaks, improving print dialog.
Showing
10 changed files
with
46 additions
and
23 deletions
Show diff stats
src/dialogs/colors.c
src/dialogs/colorscheme.c
@@ -88,6 +88,8 @@ | @@ -88,6 +88,8 @@ | ||
88 | debug("%s=%p",__FUNCTION__,clr); | 88 | debug("%s=%p",__FUNCTION__,clr); |
89 | g_signal_emit(widget, color_signal[CHANGED], 0, clr); | 89 | g_signal_emit(widget, color_signal[CHANGED], 0, clr); |
90 | 90 | ||
91 | + g_value_unset(&value); | ||
92 | + | ||
91 | } | 93 | } |
92 | 94 | ||
93 | static void V3270ColorScheme_class_init(G_GNUC_UNUSED V3270ColorSchemeClass *klass) | 95 | static void V3270ColorScheme_class_init(G_GNUC_UNUSED V3270ColorSchemeClass *klass) |
@@ -370,19 +372,22 @@ | @@ -370,19 +372,22 @@ | ||
370 | 372 | ||
371 | gtk_tree_model_get_value(gtk_combo_box_get_model(GTK_COMBO_BOX(widget)),&iter,1,&value); | 373 | gtk_tree_model_get_value(gtk_combo_box_get_model(GTK_COMBO_BOX(widget)),&iter,1,&value); |
372 | clr = g_value_get_pointer(&value); | 374 | clr = g_value_get_pointer(&value); |
373 | - if(!clr) | ||
374 | - return g_strdup(""); | ||
375 | - | ||
376 | GString *str = g_string_new(""); | 375 | GString *str = g_string_new(""); |
377 | - for(f=0;f<V3270_COLOR_COUNT;f++) | 376 | + |
377 | + if(clr) | ||
378 | { | 378 | { |
379 | - if(f) | ||
380 | - g_string_append_c(str,';'); | 379 | + for(f=0;f<V3270_COLOR_COUNT;f++) |
380 | + { | ||
381 | + if(f) | ||
382 | + g_string_append_c(str,';'); | ||
381 | 383 | ||
382 | - g_autofree gchar * color = gdk_rgba_to_string(clr+f); | ||
383 | - g_string_append_printf(str,"%s",color); | 384 | + g_autofree gchar * color = gdk_rgba_to_string(clr+f); |
385 | + g_string_append_printf(str,"%s",color); | ||
386 | + } | ||
384 | } | 387 | } |
385 | 388 | ||
389 | + g_value_unset(&value); | ||
390 | + | ||
386 | return g_string_free(str,FALSE); | 391 | return g_string_free(str,FALSE); |
387 | 392 | ||
388 | } | 393 | } |
src/dialogs/fontselect.c
@@ -100,9 +100,12 @@ | @@ -100,9 +100,12 @@ | ||
100 | if(!g_ascii_strcasecmp(fontname,g_value_get_string(&value))) | 100 | if(!g_ascii_strcasecmp(fontname,g_value_get_string(&value))) |
101 | { | 101 | { |
102 | gtk_combo_box_set_active_iter(GTK_COMBO_BOX(widget),&iter); | 102 | gtk_combo_box_set_active_iter(GTK_COMBO_BOX(widget),&iter); |
103 | + g_value_unset(&value); | ||
103 | return TRUE; | 104 | return TRUE; |
104 | } | 105 | } |
105 | 106 | ||
107 | + g_value_unset(&value); | ||
108 | + | ||
106 | } while(gtk_tree_model_iter_next(model,&iter)); | 109 | } while(gtk_tree_model_iter_next(model,&iter)); |
107 | } | 110 | } |
108 | 111 | ||
@@ -110,7 +113,7 @@ | @@ -110,7 +113,7 @@ | ||
110 | 113 | ||
111 | } | 114 | } |
112 | 115 | ||
113 | - LIB3270_EXPORT const gchar * v3270_font_selection_get_family(GtkWidget *widget) | 116 | + LIB3270_EXPORT gchar * v3270_font_selection_get_family(GtkWidget *widget) |
114 | { | 117 | { |
115 | GtkTreeIter iter; | 118 | GtkTreeIter iter; |
116 | 119 | ||
@@ -119,7 +122,12 @@ | @@ -119,7 +122,12 @@ | ||
119 | GValue value = { 0, }; | 122 | GValue value = { 0, }; |
120 | 123 | ||
121 | gtk_tree_model_get_value(gtk_combo_box_get_model(GTK_COMBO_BOX(widget)),&iter,0,&value); | 124 | gtk_tree_model_get_value(gtk_combo_box_get_model(GTK_COMBO_BOX(widget)),&iter,0,&value); |
122 | - return g_value_get_string(&value); | 125 | + |
126 | + gchar * rc = g_value_dup_string(&value); | ||
127 | + | ||
128 | + g_value_unset(&value); | ||
129 | + | ||
130 | + return rc; | ||
123 | 131 | ||
124 | } | 132 | } |
125 | 133 |
src/dialogs/print/convenience.c
@@ -34,7 +34,7 @@ | @@ -34,7 +34,7 @@ | ||
34 | 34 | ||
35 | /*--[ Implement ]------------------------------------------------------------------------------------*/ | 35 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
36 | 36 | ||
37 | - int v3270_print(GtkWidget *widget, LIB3270_CONTENT_OPTION mode, GError **error) | 37 | + int v3270_print_dialog(GtkWidget *widget, LIB3270_CONTENT_OPTION mode, GError **error) |
38 | { | 38 | { |
39 | int rc; | 39 | int rc; |
40 | 40 | ||
@@ -76,6 +76,8 @@ | @@ -76,6 +76,8 @@ | ||
76 | // Print operation. | 76 | // Print operation. |
77 | V3270PrintOperation * operation = v3270_print_operation_new(widget, mode); | 77 | V3270PrintOperation * operation = v3270_print_operation_new(widget, mode); |
78 | 78 | ||
79 | + gtk_print_operation_set_show_progress(GTK_PRINT_OPERATION(operation),TRUE); | ||
80 | + | ||
79 | if(error) | 81 | if(error) |
80 | { | 82 | { |
81 | gtk_print_operation_run( | 83 | gtk_print_operation_run( |
@@ -127,18 +129,24 @@ | @@ -127,18 +129,24 @@ | ||
127 | 129 | ||
128 | } | 130 | } |
129 | 131 | ||
132 | + int v3270_print(GtkWidget *widget, GError **error) | ||
133 | + { | ||
134 | + return v3270_print_dialog(widget,(lib3270_has_selection(GTK_V3270(widget)->host) ? LIB3270_CONTENT_SELECTED : LIB3270_CONTENT_ALL),error); | ||
135 | + } | ||
136 | + | ||
137 | + | ||
130 | int v3270_print_all(GtkWidget *widget, GError **error) | 138 | int v3270_print_all(GtkWidget *widget, GError **error) |
131 | { | 139 | { |
132 | - return v3270_print(widget,LIB3270_CONTENT_ALL,error); | 140 | + return v3270_print_dialog(widget,LIB3270_CONTENT_ALL,error); |
133 | } | 141 | } |
134 | 142 | ||
135 | int v3270_print_selected(GtkWidget *widget, GError **error) | 143 | int v3270_print_selected(GtkWidget *widget, GError **error) |
136 | { | 144 | { |
137 | - return v3270_print(widget,LIB3270_CONTENT_SELECTED,error); | 145 | + return v3270_print_dialog(widget,LIB3270_CONTENT_SELECTED,error); |
138 | } | 146 | } |
139 | 147 | ||
140 | int v3270_print_copy(GtkWidget *widget, GError **error) | 148 | int v3270_print_copy(GtkWidget *widget, GError **error) |
141 | { | 149 | { |
142 | - return v3270_print(widget,LIB3270_CONTENT_COPY,error); | 150 | + return v3270_print_dialog(widget,LIB3270_CONTENT_COPY,error); |
143 | } | 151 | } |
144 | 152 |
src/dialogs/print/print.c
@@ -130,12 +130,12 @@ | @@ -130,12 +130,12 @@ | ||
130 | 130 | ||
131 | // Setup options. | 131 | // Setup options. |
132 | operation->show_selection = v3270_print_settings_get_show_selection(settings); | 132 | operation->show_selection = v3270_print_settings_get_show_selection(settings); |
133 | - operation->font.name = g_strdup(v3270_font_selection_get_family(settings)); | 133 | + operation->font.name = v3270_print_settings_get_font_family(settings); |
134 | 134 | ||
135 | v3270_print_settings_get_rgba(settings, operation->settings.colors, V3270_COLOR_COUNT); | 135 | v3270_print_settings_get_rgba(settings, operation->settings.colors, V3270_COLOR_COUNT); |
136 | 136 | ||
137 | } | 137 | } |
138 | -#endif // _WIN32 | 138 | +#endif // !_WIN32 |
139 | 139 | ||
140 | static void V3270PrintOperation_class_init(V3270PrintOperationClass *klass) | 140 | static void V3270PrintOperation_class_init(V3270PrintOperationClass *klass) |
141 | { | 141 | { |
@@ -149,7 +149,7 @@ | @@ -149,7 +149,7 @@ | ||
149 | #ifndef _WIN32 | 149 | #ifndef _WIN32 |
150 | operation->create_custom_widget = custom_widget_new; | 150 | operation->create_custom_widget = custom_widget_new; |
151 | operation->custom_widget_apply = custom_widget_apply; | 151 | operation->custom_widget_apply = custom_widget_apply; |
152 | -#endif // _WIN32 | 152 | +#endif // !_WIN32 |
153 | 153 | ||
154 | } | 154 | } |
155 | 155 |
src/dialogs/print/settings.c
@@ -146,7 +146,7 @@ LIB3270_EXPORT void v3270_print_settings_set_color_scheme(GtkWidget *widget, con | @@ -146,7 +146,7 @@ LIB3270_EXPORT void v3270_print_settings_set_color_scheme(GtkWidget *widget, con | ||
146 | v3270_color_scheme_set_text(GTK_V3270_PRINT_SETTINGS(widget)->color, colors); | 146 | v3270_color_scheme_set_text(GTK_V3270_PRINT_SETTINGS(widget)->color, colors); |
147 | } | 147 | } |
148 | 148 | ||
149 | -LIB3270_EXPORT const gchar * v3270_print_settings_get_font_family(GtkWidget *widget) | 149 | +LIB3270_EXPORT gchar * v3270_print_settings_get_font_family(GtkWidget *widget) |
150 | { | 150 | { |
151 | return v3270_font_selection_get_family(GTK_V3270_PRINT_SETTINGS(widget)->font); | 151 | return v3270_font_selection_get_family(GTK_V3270_PRINT_SETTINGS(widget)->font); |
152 | } | 152 | } |
src/include/v3270.h
@@ -265,10 +265,11 @@ | @@ -265,10 +265,11 @@ | ||
265 | LIB3270_EXPORT void v3270_select_host(GtkWidget *widget); | 265 | LIB3270_EXPORT void v3270_select_host(GtkWidget *widget); |
266 | 266 | ||
267 | 267 | ||
268 | - LIB3270_EXPORT int v3270_print(GtkWidget *widget, LIB3270_CONTENT_OPTION mode, GError **error); | 268 | + LIB3270_EXPORT int v3270_print(GtkWidget *widget, GError **error); |
269 | LIB3270_EXPORT int v3270_print_all(GtkWidget *widget, GError **error); | 269 | LIB3270_EXPORT int v3270_print_all(GtkWidget *widget, GError **error); |
270 | LIB3270_EXPORT int v3270_print_selected(GtkWidget *widget, GError **error); | 270 | LIB3270_EXPORT int v3270_print_selected(GtkWidget *widget, GError **error); |
271 | LIB3270_EXPORT int v3270_print_copy(GtkWidget *widget, GError **error); | 271 | LIB3270_EXPORT int v3270_print_copy(GtkWidget *widget, GError **error); |
272 | + LIB3270_EXPORT int v3270_print_dialog(GtkWidget *widget, LIB3270_CONTENT_OPTION mode, GError **error); | ||
272 | 273 | ||
273 | // Save | 274 | // Save |
274 | LIB3270_EXPORT int v3270_save(GtkWidget *widget, LIB3270_CONTENT_OPTION mode, const gchar *filename, GError **error); | 275 | LIB3270_EXPORT int v3270_save(GtkWidget *widget, LIB3270_CONTENT_OPTION mode, const gchar *filename, GError **error); |
src/include/v3270/print.h
@@ -69,7 +69,7 @@ | @@ -69,7 +69,7 @@ | ||
69 | 69 | ||
70 | LIB3270_EXPORT GtkWidget * v3270_font_selection_new(const gchar *fontname); | 70 | LIB3270_EXPORT GtkWidget * v3270_font_selection_new(const gchar *fontname); |
71 | LIB3270_EXPORT gboolean v3270_font_selection_set_family(GtkWidget *widget, const gchar *fontname); | 71 | LIB3270_EXPORT gboolean v3270_font_selection_set_family(GtkWidget *widget, const gchar *fontname); |
72 | - LIB3270_EXPORT const gchar * v3270_font_selection_get_family(GtkWidget *widget); | 72 | + LIB3270_EXPORT gchar * v3270_font_selection_get_family(GtkWidget *widget); |
73 | 73 | ||
74 | LIB3270_EXPORT GType V3270PrintSettings_get_type(void); | 74 | LIB3270_EXPORT GType V3270PrintSettings_get_type(void); |
75 | LIB3270_EXPORT GtkWidget * V3270_print_settings_new(GtkWidget *widget); | 75 | LIB3270_EXPORT GtkWidget * V3270_print_settings_new(GtkWidget *widget); |
@@ -77,7 +77,7 @@ | @@ -77,7 +77,7 @@ | ||
77 | LIB3270_EXPORT void v3270_print_settings_set_show_selection(GtkWidget *widget, gboolean is_active); | 77 | LIB3270_EXPORT void v3270_print_settings_set_show_selection(GtkWidget *widget, gboolean is_active); |
78 | LIB3270_EXPORT gchar * v3270_print_settings_get_color_scheme(GtkWidget *widget); | 78 | LIB3270_EXPORT gchar * v3270_print_settings_get_color_scheme(GtkWidget *widget); |
79 | LIB3270_EXPORT void v3270_print_settings_set_color_scheme(GtkWidget *widget, const gchar *colors); | 79 | LIB3270_EXPORT void v3270_print_settings_set_color_scheme(GtkWidget *widget, const gchar *colors); |
80 | - LIB3270_EXPORT const gchar * v3270_print_settings_get_font_family(GtkWidget *widget); | 80 | + LIB3270_EXPORT gchar * v3270_print_settings_get_font_family(GtkWidget *widget); |
81 | LIB3270_EXPORT gboolean v3270_print_settings_set_font_family(GtkWidget *widget, const gchar *fontname); | 81 | LIB3270_EXPORT gboolean v3270_print_settings_set_font_family(GtkWidget *widget, const gchar *fontname); |
82 | LIB3270_EXPORT int v3270_print_settings_get_rgba(GtkWidget *widget, GdkRGBA *colors, size_t num_colors); | 82 | LIB3270_EXPORT int v3270_print_settings_get_rgba(GtkWidget *widget, GdkRGBA *colors, size_t num_colors); |
83 | 83 |
src/terminal/callbacks.c
@@ -329,7 +329,7 @@ static void message(H3270 *session, LIB3270_NOTIFY id , const char *title, const | @@ -329,7 +329,7 @@ static void message(H3270 *session, LIB3270_NOTIFY id , const char *title, const | ||
329 | 329 | ||
330 | static int print(H3270 *session, LIB3270_CONTENT_OPTION mode) | 330 | static int print(H3270 *session, LIB3270_CONTENT_OPTION mode) |
331 | { | 331 | { |
332 | - return v3270_print(GTK_WIDGET(lib3270_get_user_data(session)), mode, NULL); | 332 | + return v3270_print_dialog(GTK_WIDGET(lib3270_get_user_data(session)), mode, NULL); |
333 | } | 333 | } |
334 | 334 | ||
335 | static int save(H3270 *session, LIB3270_CONTENT_OPTION mode, const char *filename) | 335 | static int save(H3270 *session, LIB3270_CONTENT_OPTION mode, const char *filename) |
src/testprogram/toolbar.c
@@ -40,7 +40,7 @@ | @@ -40,7 +40,7 @@ | ||
40 | 40 | ||
41 | static void print_clicked(GtkButton G_GNUC_UNUSED(*button), GtkWidget *terminal) | 41 | static void print_clicked(GtkButton G_GNUC_UNUSED(*button), GtkWidget *terminal) |
42 | { | 42 | { |
43 | - lib3270_print_all(v3270_get_session(terminal)); | 43 | + v3270_print(terminal,NULL); |
44 | } | 44 | } |
45 | 45 | ||
46 | static void host_clicked(GtkButton G_GNUC_UNUSED(*button), GtkWidget *terminal) | 46 | static void host_clicked(GtkButton G_GNUC_UNUSED(*button), GtkWidget *terminal) |