Commit 1c2b276912917735c52be04ced4f3cff1bb09795
1 parent
9ad60a5b
Exists in
master
and in
1 other branch
Addint methods to get/set properties on the print operation dialog.
Showing
5 changed files
with
74 additions
and
46 deletions
Show diff stats
src/dialogs/colorscheme.c
| @@ -363,33 +363,40 @@ | @@ -363,33 +363,40 @@ | ||
| 363 | gchar * v3270_color_scheme_get_text(GtkWidget *widget) | 363 | gchar * v3270_color_scheme_get_text(GtkWidget *widget) |
| 364 | { | 364 | { |
| 365 | GdkRGBA * clr = NULL; | 365 | GdkRGBA * clr = NULL; |
| 366 | - GValue value = { 0, }; | 366 | + gchar * rc = NULL; |
| 367 | + GValue value = { 0, }; | ||
| 367 | GtkTreeIter iter; | 368 | GtkTreeIter iter; |
| 368 | - int f; | ||
| 369 | 369 | ||
| 370 | if(!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(widget),&iter)) | 370 | if(!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(widget),&iter)) |
| 371 | return NULL; | 371 | return NULL; |
| 372 | 372 | ||
| 373 | 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); |
| 374 | clr = g_value_get_pointer(&value); | 374 | clr = g_value_get_pointer(&value); |
| 375 | - GString *str = g_string_new(""); | ||
| 376 | 375 | ||
| 377 | if(clr) | 376 | if(clr) |
| 377 | + rc = v3270_translate_rgba_to_text(clr); | ||
| 378 | + | ||
| 379 | + g_value_unset(&value); | ||
| 380 | + | ||
| 381 | + return rc; | ||
| 382 | + | ||
| 383 | + } | ||
| 384 | + | ||
| 385 | + gchar * v3270_translate_rgba_to_text(GdkRGBA *clr) | ||
| 386 | + { | ||
| 387 | + int f; | ||
| 388 | + GString *str = g_string_new(""); | ||
| 389 | + | ||
| 390 | + for(f=0;f<V3270_COLOR_COUNT;f++) | ||
| 378 | { | 391 | { |
| 379 | - for(f=0;f<V3270_COLOR_COUNT;f++) | ||
| 380 | - { | ||
| 381 | - if(f) | ||
| 382 | - g_string_append_c(str,';'); | 392 | + if(f) |
| 393 | + g_string_append_c(str,';'); | ||
| 383 | 394 | ||
| 384 | - g_autofree gchar * color = gdk_rgba_to_string(clr+f); | ||
| 385 | - g_string_append_printf(str,"%s",color); | ||
| 386 | - } | 395 | + g_autofree gchar * color = gdk_rgba_to_string(clr+f); |
| 396 | + g_string_append_printf(str,"%s",color); | ||
| 387 | } | 397 | } |
| 388 | 398 | ||
| 389 | - g_value_unset(&value); | ||
| 390 | - | ||
| 391 | return g_string_free(str,FALSE); | 399 | return g_string_free(str,FALSE); |
| 392 | - | ||
| 393 | } | 400 | } |
| 394 | 401 | ||
| 395 | void v3270_color_scheme_set_rgba(GtkWidget *widget, const GdkRGBA *colors) | 402 | void v3270_color_scheme_set_rgba(GtkWidget *widget, const GdkRGBA *colors) |
| @@ -416,14 +423,22 @@ | @@ -416,14 +423,22 @@ | ||
| 416 | } while(gtk_tree_model_iter_next(model,&iter)); | 423 | } while(gtk_tree_model_iter_next(model,&iter)); |
| 417 | } | 424 | } |
| 418 | 425 | ||
| 419 | - debug("%s: Can't identify color scheme", __FUNCTION__); | 426 | + g_message("Can't find color scheme for %s",colors); |
| 420 | gtk_combo_box_set_active(GTK_COMBO_BOX(widget),-1); | 427 | gtk_combo_box_set_active(GTK_COMBO_BOX(widget),-1); |
| 421 | 428 | ||
| 429 | + // TODO: Create an entry for this scheme as "custom" and select it. | ||
| 430 | + | ||
| 422 | } | 431 | } |
| 423 | 432 | ||
| 424 | void v3270_color_scheme_set_text(GtkWidget *widget, const gchar *colors) | 433 | void v3270_color_scheme_set_text(GtkWidget *widget, const gchar *colors) |
| 425 | { | 434 | { |
| 426 | - GdkRGBA clr[V3270_COLOR_COUNT]; | 435 | + GdkRGBA clr[V3270_COLOR_COUNT]; |
| 436 | + v3270_translate_text_to_rgba(colors,clr); | ||
| 437 | + v3270_color_scheme_set_rgba(widget,clr); | ||
| 438 | + } | ||
| 439 | + | ||
| 440 | + void v3270_translate_text_to_rgba(const gchar *colors, GdkRGBA *clr) | ||
| 441 | + { | ||
| 427 | gchar **str = g_strsplit(colors,";",V3270_COLOR_BASE); | 442 | gchar **str = g_strsplit(colors,";",V3270_COLOR_BASE); |
| 428 | size_t f; | 443 | size_t f; |
| 429 | 444 | ||
| @@ -456,8 +471,6 @@ | @@ -456,8 +471,6 @@ | ||
| 456 | 471 | ||
| 457 | g_strfreev(str); | 472 | g_strfreev(str); |
| 458 | 473 | ||
| 459 | - v3270_color_scheme_set_rgba(widget,clr); | ||
| 460 | - | ||
| 461 | } | 474 | } |
| 462 | 475 | ||
| 463 | int v3270_color_scheme_get_rgba(GtkWidget *widget, GdkRGBA *colors, size_t num_colors) | 476 | int v3270_color_scheme_get_rgba(GtkWidget *widget, GdkRGBA *colors, size_t num_colors) |
src/dialogs/print/convenience.c
| @@ -43,34 +43,6 @@ | @@ -43,34 +43,6 @@ | ||
| 43 | return errno = EINVAL; | 43 | return errno = EINVAL; |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | - /* | ||
| 47 | - if(!v3270_is_connected(widget)) | ||
| 48 | - { | ||
| 49 | - if(error) | ||
| 50 | - { | ||
| 51 | - *error = g_error_new(g_quark_from_static_string(PACKAGE_NAME),ENOTCONN,"%s",strerror(ENOTCONN)); | ||
| 52 | - } | ||
| 53 | - else | ||
| 54 | - { | ||
| 55 | - GtkWidget *popup = gtk_message_dialog_new_with_markup( | ||
| 56 | - GTK_WINDOW(gtk_widget_get_toplevel(widget)), | ||
| 57 | - GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | ||
| 58 | - GTK_MESSAGE_ERROR,GTK_BUTTONS_CLOSE, | ||
| 59 | - _("Can't print data") | ||
| 60 | - ); | ||
| 61 | - | ||
| 62 | - gtk_window_set_title(GTK_WINDOW(popup),_("Operation has failed")); | ||
| 63 | - | ||
| 64 | - gtk_message_dialog_format_secondary_markup(GTK_MESSAGE_DIALOG(popup),"%s",strerror(ENOTCONN)); | ||
| 65 | - | ||
| 66 | - gtk_dialog_run(GTK_DIALOG(popup)); | ||
| 67 | - gtk_widget_destroy(popup); | ||
| 68 | - } | ||
| 69 | - | ||
| 70 | - return errno = ENOTCONN; | ||
| 71 | - } | ||
| 72 | - */ | ||
| 73 | - | ||
| 74 | lib3270_trace_event(v3270_get_session(widget),"print action activated (type=%d)",(int) mode); | 46 | lib3270_trace_event(v3270_get_session(widget),"print action activated (type=%d)",(int) mode); |
| 75 | 47 | ||
| 76 | // Print operation. | 48 | // Print operation. |
src/dialogs/print/print.c
| @@ -235,3 +235,35 @@ GtkPrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_CONTENT | @@ -235,3 +235,35 @@ GtkPrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_CONTENT | ||
| 235 | return GTK_PRINT_OPERATION(operation); | 235 | return GTK_PRINT_OPERATION(operation); |
| 236 | } | 236 | } |
| 237 | 237 | ||
| 238 | +gboolean v3270_print_operation_set_font_family(GtkPrintOperation *operation, const gchar *fontname) | ||
| 239 | +{ | ||
| 240 | + g_return_val_if_fail(GTK_IS_V3270_PRINT_OPERATION(operation),FALSE); | ||
| 241 | + | ||
| 242 | + V3270PrintOperation * opr = GTK_V3270_PRINT_OPERATION(operation); | ||
| 243 | + | ||
| 244 | + if(opr->font.name) | ||
| 245 | + g_free(opr->font.name); | ||
| 246 | + | ||
| 247 | + opr->font.name = g_strdup(fontname); | ||
| 248 | + | ||
| 249 | + return TRUE; | ||
| 250 | + | ||
| 251 | +} | ||
| 252 | + | ||
| 253 | +gchar * v3270_print_operation_get_font_family(GtkPrintOperation *operation) | ||
| 254 | +{ | ||
| 255 | + g_return_val_if_fail(GTK_IS_V3270_PRINT_OPERATION(operation),NULL); | ||
| 256 | + return g_strdup(GTK_V3270_PRINT_OPERATION(operation)->font.name); | ||
| 257 | +} | ||
| 258 | + | ||
| 259 | +void v3270_print_operation_set_color_scheme(GtkPrintOperation *operation, const gchar *colors) | ||
| 260 | +{ | ||
| 261 | + g_return_if_fail(GTK_IS_V3270_PRINT_OPERATION(operation)); | ||
| 262 | + v3270_translate_text_to_rgba(colors,GTK_V3270_PRINT_OPERATION(operation)->settings.colors); | ||
| 263 | +} | ||
| 264 | + | ||
| 265 | +gchar * v3270_print_operation_get_color_scheme(GtkPrintOperation *operation) | ||
| 266 | +{ | ||
| 267 | + g_return_val_if_fail(GTK_IS_V3270_PRINT_OPERATION(operation),NULL); | ||
| 268 | + return v3270_translate_rgba_to_text(GTK_V3270_PRINT_OPERATION(operation)->settings.colors); | ||
| 269 | +} |
src/include/internals.h
| @@ -238,6 +238,10 @@ | @@ -238,6 +238,10 @@ | ||
| 238 | G_GNUC_INTERNAL GSource * IO_source_new(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*call)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata); | 238 | G_GNUC_INTERNAL GSource * IO_source_new(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*call)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata); |
| 239 | G_GNUC_INTERNAL void IO_source_set_state(GSource *source, gboolean enable); | 239 | G_GNUC_INTERNAL void IO_source_set_state(GSource *source, gboolean enable); |
| 240 | 240 | ||
| 241 | + // Tools | ||
| 242 | + G_GNUC_INTERNAL void v3270_translate_text_to_rgba(const gchar *colors, GdkRGBA *clr); | ||
| 243 | + G_GNUC_INTERNAL gchar * v3270_translate_rgba_to_text(GdkRGBA *clr); | ||
| 244 | + | ||
| 241 | G_END_DECLS | 245 | G_END_DECLS |
| 242 | 246 | ||
| 243 | #endif // V3270_INTERNALS_H_INCLUDED | 247 | #endif // V3270_INTERNALS_H_INCLUDED |
src/include/v3270/print.h
| @@ -64,9 +64,16 @@ | @@ -64,9 +64,16 @@ | ||
| 64 | 64 | ||
| 65 | LIB3270_EXPORT GType V3270PrintOperation_get_type(void); | 65 | LIB3270_EXPORT GType V3270PrintOperation_get_type(void); |
| 66 | LIB3270_EXPORT GtkPrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_CONTENT_OPTION mode); | 66 | LIB3270_EXPORT GtkPrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_CONTENT_OPTION mode); |
| 67 | - LIB3270_EXPORT GtkWidget * v3270_print_operation_get_terminal(GtkPrintOperation *operation); | ||
| 68 | LIB3270_EXPORT void v3270_print_operation_apply_settings(GtkPrintOperation *operation, GtkWidget *settings); | 67 | LIB3270_EXPORT void v3270_print_operation_apply_settings(GtkPrintOperation *operation, GtkWidget *settings); |
| 69 | 68 | ||
| 69 | + LIB3270_EXPORT GtkWidget * v3270_print_operation_get_terminal(GtkPrintOperation *operation); | ||
| 70 | + | ||
| 71 | + LIB3270_EXPORT gboolean v3270_print_operation_set_font_family(GtkPrintOperation *operation, const gchar *fontname); | ||
| 72 | + LIB3270_EXPORT gchar * v3270_print_operation_get_font_family(GtkPrintOperation *operation); | ||
| 73 | + | ||
| 74 | + LIB3270_EXPORT void v3270_print_operation_set_color_scheme(GtkPrintOperation *operation, const gchar *colors); | ||
| 75 | + LIB3270_EXPORT gchar * v3270_print_operation_get_color_scheme(GtkPrintOperation *operation); | ||
| 76 | + | ||
| 70 | LIB3270_EXPORT GtkTreeModel * v3270_font_family_model_new(GtkWidget *widget, const gchar *selected, GtkTreeIter * active); | 77 | LIB3270_EXPORT GtkTreeModel * v3270_font_family_model_new(GtkWidget *widget, const gchar *selected, GtkTreeIter * active); |
| 71 | 78 | ||
| 72 | LIB3270_EXPORT GtkWidget * v3270_font_selection_new(const gchar *fontname); | 79 | LIB3270_EXPORT GtkWidget * v3270_font_selection_new(const gchar *fontname); |