From 3798a669aa7799d6b0647dd5d60b866748d25cd5 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Wed, 26 Sep 2012 18:21:13 +0000 Subject: [PATCH] Criando dialogo para configuracao de fonte --- src/pw3270/actions.c | 25 +++++++++++++------------ src/pw3270/colors.c | 2 +- src/pw3270/globals.h | 1 + src/pw3270/print.c | 43 +++++++++++++++++++++++++++++++++++++++---- ui/99debug.xml | 1 + 5 files changed, 55 insertions(+), 17 deletions(-) diff --git a/src/pw3270/actions.c b/src/pw3270/actions.c index 39735ed..a581b41 100644 --- a/src/pw3270/actions.c +++ b/src/pw3270/actions.c @@ -246,19 +246,20 @@ static void connect_standard_action(GtkAction *action, GtkWidget *widget, const } gtk_action[] = { - { "activate", activate_action }, - { "reload", reload_action }, - { "connect", connect_action }, - { "disconnect", disconnect_action }, - { "hostname", hostname_action }, - { "editcolors", editcolors_action }, - { "about", about_dialog_action }, - { "kpsubtract", kp_subtract_action }, - { "kpadd", kp_add_action }, - { "download", download_action }, - { "upload", upload_action }, + { "activate", activate_action }, + { "reload", reload_action }, + { "connect", connect_action }, + { "disconnect", disconnect_action }, + { "hostname", hostname_action }, + { "editcolors", editcolors_action }, + { "printsettings", print_settings_action }, + { "about", about_dialog_action }, + { "kpsubtract", kp_subtract_action }, + { "kpadd", kp_add_action }, + { "download", download_action }, + { "upload", upload_action }, #ifdef DEBUG - { "copyashtml", copy_as_html_action }, + { "copyashtml", copy_as_html_action }, #endif // DEBUG }; diff --git a/src/pw3270/colors.c b/src/pw3270/colors.c index 81ed05c..8fb9055 100644 --- a/src/pw3270/colors.c +++ b/src/pw3270/colors.c @@ -411,7 +411,7 @@ static void load_color_scheme(GKeyFile *conf, const gchar *group, GdkColor *clr) const gchar * title = g_object_get_data(G_OBJECT(action),"title"); GtkWidget * dialog = gtk_dialog_new_with_buttons ( gettext(title ? title : N_( "Color setup") ), - NULL, + gtk_widget_get_toplevel(widget), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, diff --git a/src/pw3270/globals.h b/src/pw3270/globals.h index 56cbe78..b7dbec7 100644 --- a/src/pw3270/globals.h +++ b/src/pw3270/globals.h @@ -76,6 +76,7 @@ G_GNUC_INTERNAL void about_dialog_action(GtkAction *action, GtkWidget *widget); G_GNUC_INTERNAL void download_action(GtkAction *action, GtkWidget *widget); G_GNUC_INTERNAL void upload_action(GtkAction *action, GtkWidget *widget); + G_GNUC_INTERNAL void print_settings_action(GtkAction *action, GtkWidget *widget); // plugins G_GNUC_INTERNAL void init_plugins(GtkWidget *widget); diff --git a/src/pw3270/print.c b/src/pw3270/print.c index b10e60f..6e6713c 100644 --- a/src/pw3270/print.c +++ b/src/pw3270/print.c @@ -289,6 +289,9 @@ static gchar * enum_to_string(GType type, guint enum_value) pango_font_description_free(descr); set_string_to_config("print","font",name); + set_integer_to_config("print","fontsize",info->fontsize); + set_integer_to_config("print","fontweight",info->fontweight); + trace("Font set to \"%s\" with size %d",info->font,info->fontsize); } @@ -299,16 +302,18 @@ static gchar * enum_to_string(GType type, guint enum_value) set_boolean_to_config("print","selection",active); } - static void load_settings(PRINT_INFO *i) + static void load_settings(PRINT_INFO *info) { gchar *ptr = get_string_from_config("print","colors",""); - i->font = get_string_from_config("print","font","Courier 10"); + info->font = get_string_from_config("print","font","Courier New 10"); + info->fontsize = get_integer_from_config("print","fontsize",10240); + info->fontweight = get_integer_from_config("print","fontweight",0); if(*ptr) - v3270_set_color_table(i->color,ptr); + v3270_set_color_table(info->color,ptr); else - v3270_set_mono_color_table(i->color,"black","white"); + v3270_set_mono_color_table(info->color,"black","white"); g_free(ptr); } @@ -639,3 +644,33 @@ static gchar * enum_to_string(GType type, guint enum_value) gtk_print_operation_run(print,oper,GTK_WINDOW(gtk_widget_get_toplevel(widget)),NULL); g_object_unref(print); } + +void print_settings_action(GtkAction *action, GtkWidget *terminal) +{ + const gchar * title = g_object_get_data(G_OBJECT(action),"title"); + PRINT_INFO info; + GtkWidget * widget; + GtkWidget * dialog = gtk_dialog_new_with_buttons ( gettext(title ? title : N_( "Print settings") ), + gtk_widget_get_toplevel(terminal), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, + GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, + NULL ); + + memset(&info,0,sizeof(info)); + + widget = create_custom_widget(NULL,&info); + + gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),GTK_WIDGET(widget),TRUE,TRUE,2); + + if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) + { + // Accepted, save settings + custom_widget_apply(NULL,widget,&info); + } + + gtk_widget_destroy(dialog); + +} + + diff --git a/ui/99debug.xml b/ui/99debug.xml index 2c41f08..0f753c2 100644 --- a/ui/99debug.xml +++ b/ui/99debug.xml @@ -48,6 +48,7 @@ + -- libgit2 0.21.2