From dee1ba19c94f64ca3c75d21a090c2b889a747883 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Mon, 11 Mar 2013 18:53:32 +0000 Subject: [PATCH] Implementando sinal e callback para impressão do conteúdo da tela --- po/pt_BR.po | 64 ++++++++++++++++++++++++++++++++++++---------------------------- src/include/lib3270/session.h | 1 + src/lib3270/session.c | 7 +++++++ src/lib3270/util.c | 4 +++- src/pw3270/v3270/keyboard.c | 4 ++-- src/pw3270/v3270/private.h | 1 + src/pw3270/v3270/widget.c | 64 +++++++++++++++++----------------------------------------------- src/pw3270/window.c | 6 ++++++ 8 files changed, 73 insertions(+), 78 deletions(-) diff --git a/po/pt_BR.po b/po/pt_BR.po index 0b447ac..4c98e6c 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -5,8 +5,8 @@ msgid "" msgstr "" "Project-Id-Version: pw3270 5.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-03-06 09:33-0300\n" -"PO-Revision-Date: 2013-02-25 14:46-0300\n" +"POT-Creation-Date: 2013-03-11 11:24-0300\n" +"PO-Revision-Date: 2013-03-11 11:30-0300\n" "Last-Translator: Perry Werneck \n" "Language-Team: Português <>\n" "Language: pt_BR\n" @@ -38,7 +38,7 @@ msgstr "Ação %s precisa de um valor válido" msgid "%s action needs src attribute" msgstr "Ação %s precisa do atributo src" -#: main.c:86 +#: main.c:88 #, c-format msgid "%s requires GTK version %d.%d.%d" msgstr "%s requer GTK versão %d.%d.%d" @@ -83,7 +83,7 @@ msgstr "%s: Familia %d é inválida" msgid "%s:%d" msgstr "%s:%d" -#: main.c:318 +#: main.c:323 msgid "- 3270 Emulator for Gtk" msgstr "- Emulador 3270 para GTK" @@ -164,7 +164,7 @@ msgstr "" msgid "SSL state is undefinedUnexpected SSL status %ld" msgstr "Estado do SSL é indefinidoEstado SSL inesperado %ld" -#: main.c:338 +#: main.c:343 msgid "" "Valid options:\n" "\n" @@ -217,7 +217,7 @@ msgid "An error occurred trying to allocate memory. This should never happen." msgstr "" "Ocorreu um erro ao tentar alocar memória. Isso nunca deveria acontecer." -#: main.c:302 main.c:304 +#: main.c:304 main.c:306 msgid "Application name" msgstr "Nome da aplicação" @@ -292,15 +292,15 @@ msgstr "Conexão interrompida" #: v3270/security.c:124 msgid "CRL has expired" -msgstr "CRL has expired" +msgstr "CRL expirou" #: v3270/security.c:117 msgid "CRL is not yet valid" -msgstr "CRL is not yet valid" +msgstr "CRL ainda não é válido" #: v3270/security.c:96 msgid "CRL signature failure" -msgstr "CRL signature failure" +msgstr "Erro na assinatura CRL" #: dialog.c:109 msgid "C_haracter Coding:" @@ -430,7 +430,7 @@ msgstr "Não foi possível criar um manipulador de socket" #: session.c:323 #, c-format msgid "Cannot find charset \"%s\", using defaults" -msgstr "Não encontrei codificação \"%s\", usando defaults" +msgstr "Não encontrei codificação \"%s\", usando padrão" #: charset.c:660 #, c-format @@ -443,7 +443,7 @@ msgstr "O certificado expirou" #: v3270/security.c:103 msgid "Certificate is not yet valid" -msgstr "Certificate is not yet valid" +msgstr "O certificado ainda não é válido" #: v3270/security.c:222 msgid "Certificate not trusted" @@ -722,7 +722,7 @@ msgstr "Tela cheia" msgid "Function bar" msgstr "Barra de funções" -#: main.c:90 main.c:379 +#: main.c:92 main.c:384 msgid "GTK Version mismatch" msgstr "Divergência de versão GTK" @@ -791,11 +791,11 @@ msgstr "Servidor rejeitou o tipo de dispositivo ou requisição" msgid "Host rejected resource(s)" msgstr "Servidor rejeitou recurso(s)" -#: main.c:310 +#: main.c:312 msgid "Host system type" msgstr "Tipo do sistema no servidor" -#: main.c:308 +#: main.c:310 msgid "Host to connect" msgstr "Servidor a conectar" @@ -814,7 +814,7 @@ msgstr "IBM S/390" #: v3270/widget.c:314 msgid "Identity not verified" -msgstr "Identity not verified" +msgstr "Identidade não verificada" #: ft_cut.c:508 msgid "Illegal frame length" @@ -1007,15 +1007,15 @@ msgstr "Laranja" #: hostdialog.c:44 msgid "Other (TSO)" -msgstr "Other (TSO)" +msgstr "Outro (TSO)" #: hostdialog.c:45 msgid "Other (VM/CMS)" -msgstr "Other (VM/CMS)" +msgstr "Outro (VM/CMS)" #: v3270/security.c:159 msgid "Out of memory" -msgstr "Out of memory" +msgstr "Memória insuficiente" #: ui/10keypad.xml:138 msgid "PA1" @@ -1125,7 +1125,7 @@ msgstr "PF8" msgid "PF9" msgstr "PF9" -#: main.c:336 +#: main.c:341 msgid "Parse error" msgstr "Erro de interpretação" @@ -1162,9 +1162,9 @@ msgstr "Colar com margem esquerda" msgid "Path length constraint exceeded" msgstr "Path length constraint exceeded" -#: main.c:305 +#: main.c:307 msgid "Path to application data files" -msgstr "Path to application data files" +msgstr "Caminho para os arquivos de dados da aplicação" #: colors.c:396 msgid "Pink" @@ -1565,11 +1565,11 @@ msgstr "Frente da seleção" #: v3270/security.c:166 msgid "Self signed certificate" -msgstr "Self signed certificate" +msgstr "Certificado auto assinada" #: v3270/security.c:173 msgid "Self signed certificate in certificate chain" -msgstr "Self signed certificate in certificate chain" +msgstr "Certificado auto assinado na cadeia de certificados" #: ui/00default.xml:277 msgid "Send file" @@ -1579,7 +1579,7 @@ msgstr "Enviar arquivo" msgid "Send file to host" msgstr "Enviar arquivo para o servidor" -#: main.c:312 +#: main.c:317 msgid "Send messages to syslog" msgstr "Send messages to syslog" @@ -1587,7 +1587,7 @@ msgstr "Send messages to syslog" msgid "Send/Receive" msgstr "Enviar/Receber" -#: main.c:307 +#: main.c:309 msgid "Session name" msgstr "Nome da sessão" @@ -1595,10 +1595,18 @@ msgstr "Nome da sessão" msgid "Set hostname" msgstr "Selecione servidor" -#: main.c:309 +#: main.c:311 msgid "Set reported colors (8/16)" msgstr "Define número de cores informadas (8/16)" +#: main.c:314 +msgid "Set toggles OFF" +msgstr "Desativa toggles" + +#: main.c:313 +msgid "Set toggles ON" +msgstr "Ativa toggles" + #: ui/00default.xml:329 msgid "Settings" msgstr "Configurações" @@ -1874,7 +1882,7 @@ msgstr "" "programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple " "Place, Suite 330, Boston, MA, 02111-1307, USA" -#: main.c:375 +#: main.c:380 #, c-format msgid "This program requires GTK version %d.%d.%d" msgstr "Este programa precisa do GTK versão %d.%d.%d" @@ -2011,7 +2019,7 @@ msgstr "Atributo %s inesperado ou inválido: \"%s\"" msgid "Unexpected or invalid attribute value \"%s\"" msgstr "Valor de attributo inesperado ou inválido: \"%s\"" -#: main.c:191 +#: main.c:193 #, c-format msgid "Unexpected or invalid color value \"%s\"" msgstr "Valor de cor inválido ou inesperado: \"%s\"" diff --git a/src/include/lib3270/session.h b/src/include/lib3270/session.h index 6ccf1da..d16fc7e 100644 --- a/src/include/lib3270/session.h +++ b/src/include/lib3270/session.h @@ -412,6 +412,7 @@ void (*set_selection)(H3270 *session, unsigned char on); void (*ctlr_done)(H3270 *session); void (*autostart)(H3270 *session); + int (*print)(H3270 *session); void (*message)(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *text); diff --git a/src/lib3270/session.c b/src/lib3270/session.c index ae32dd6..8c518ad 100644 --- a/src/lib3270/session.c +++ b/src/lib3270/session.c @@ -138,6 +138,12 @@ static void set_cursor(H3270 *session, LIB3270_CURSOR id) { } +static int print(H3270 *session) +{ + lib3270_write_log(session, "print", "%s", "Printing is unavailable"); + return -1; +} + static void message(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *msg, const char *text) { #ifdef ANDROID @@ -203,6 +209,7 @@ static void lib3270_session_init(H3270 *hSession, const char *model) hSession->update_status = (void (*)(H3270 *, LIB3270_STATUS)) nop_int; hSession->autostart = nop; hSession->set_timer = set_timer; + hSession->print = print; // Set the defaults. hSession->extended = 1; diff --git a/src/lib3270/util.c b/src/lib3270/util.c index 44612f7..5895599 100644 --- a/src/lib3270/util.c +++ b/src/lib3270/util.c @@ -1020,5 +1020,7 @@ int gettimeofday(struct timeval *tv, void *ignored) LIB3270_EXPORT int lib3270_print(H3270 *h) { - return -1; + CHECK_SESSION_HANDLE(h); + trace("%s(%p)",__FUNCTION__,h); + return h->print(h); } diff --git a/src/pw3270/v3270/keyboard.c b/src/pw3270/v3270/keyboard.c index 8250100..45247d9 100644 --- a/src/pw3270/v3270/keyboard.c +++ b/src/pw3270/v3270/keyboard.c @@ -79,10 +79,10 @@ { GDK_KP_Add, GDK_NUMLOCK_MASK, NULL, NULL }, { GDK_KP_Subtract, GDK_NUMLOCK_MASK, NULL, NULL }, - { GDK_3270_PrintScreen, 0, NULL, NULL }, + { GDK_3270_PrintScreen, 0, lib3270_print, NULL }, { GDK_Sys_Req, 0, lib3270_sysreq, NULL }, - { GDK_Print, GDK_CONTROL_MASK, NULL, NULL }, + { GDK_Print, GDK_CONTROL_MASK, lib3270_print, NULL }, { GDK_Print, GDK_SHIFT_MASK, lib3270_sysreq, NULL }, { GDK_Control_R, 0, NULL, NULL }, { GDK_Control_L, 0, NULL, NULL }, diff --git a/src/pw3270/v3270/private.h b/src/pw3270/v3270/private.h index c79cd6d..bb574a5 100644 --- a/src/pw3270/v3270/private.h +++ b/src/pw3270/v3270/private.h @@ -81,6 +81,7 @@ G_BEGIN_DECLS SIGNAL_CHANGED, SIGNAL_MESSAGE, SIGNAL_FIELD, + SIGNAL_PRINT, LAST_SIGNAL }; diff --git a/src/pw3270/v3270/widget.c b/src/pw3270/v3270/widget.c index 4148a77..c8ad695 100644 --- a/src/pw3270/v3270/widget.c +++ b/src/pw3270/v3270/widget.c @@ -165,18 +165,6 @@ static gboolean v3270_popup_menu(GtkWidget * widget) #if GTK_CHECK_VERSION(3,0,0) -/* -static GtkSizeRequestMode get_request_mode(GtkWidget *widget) -{ - int rows, cols; - - lib3270_get_screen_size(GTK_V3270(widget)->host,&rows,&cols); - - return rows > cols ? GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT : GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH; - -} -*/ - void get_preferred_height(GtkWidget *widget, gint *minimum_height, gint *natural_height) { int height = GTK_V3270(widget)->minimum_height; @@ -200,31 +188,6 @@ void get_preferred_width(GtkWidget *widget, gint *minimum_width, gint *natural_w *natural_width = 600; } -/* -void get_preferred_height_for_width(GtkWidget *widget, gint width, gint *minimum_height, gint *natural_height) -{ - trace("%s",__FUNCTION__); - - if(minimum_height) - *minimum_height = 10; - - if(natural_height) - *natural_height = 10; -} - -static void get_preferred_width_for_height(GtkWidget *widget,gint height, gint *minimum_width, gint *natural_width) -{ - trace("%s",__FUNCTION__); - - if(minimum_width) - *minimum_width = 10; - - if(natural_width) - *natural_width = 10; - -} -*/ - #endif // GTK(3,0,0) void v3270_popup_message(GtkWidget *widget, LIB3270_NOTIFY type , const gchar *title, const gchar *message, const gchar *text) @@ -276,14 +239,6 @@ void v3270_popup_message(GtkWidget *widget, LIB3270_NOTIFY type , const gchar *t gboolean v3270_query_tooltip(GtkWidget *widget, gint x, gint y, gboolean keyboard_tooltip, GtkTooltip *tooltip) { -/* - if(!lib3270_connected(GTK_V3270(widget)->host)) - { - gtk_tooltip_set_text(tooltip,_( "Disconnected" ) ); - return TRUE; - } -*/ - if(y >= GTK_V3270(widget)->oia_rect->y) { GdkRectangle *rect = GTK_V3270(widget)->oia_rect; @@ -369,8 +324,6 @@ static void v3270_class_init(v3270Class *klass) widget_class->get_preferred_height = get_preferred_height; widget_class->get_preferred_width = get_preferred_width; -// widget_class->get_preferred_width_for_height = get_preferred_width_for_height; -// widget_class->get_preferred_height_for_width = get_preferred_height_for_width; widget_class->destroy = v3270_destroy; widget_class->draw = v3270_draw; @@ -589,6 +542,16 @@ static void v3270_class_init(v3270Class *klass) pw3270_BOOL__VOID_BOOL_UINT_POINTER, G_TYPE_BOOLEAN, 3, G_TYPE_BOOLEAN, G_TYPE_UINT, G_TYPE_POINTER); + + v3270_widget_signal[SIGNAL_PRINT] = + g_signal_new( "print", + G_OBJECT_CLASS_TYPE (gobject_class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, NULL, + pw3270_VOID__VOID, + G_TYPE_NONE, 0); + } void v3270_update_font_metrics(v3270 *terminal, cairo_t *cr, int width, int height) @@ -865,6 +828,12 @@ static void message(H3270 *session, LIB3270_NOTIFY id , const char *title, const } +static int emit_print_signal(H3270 *session) +{ + g_signal_emit(GTK_WIDGET(session->widget), v3270_widget_signal[SIGNAL_PRINT], 0); + return 0; +} + static void v3270_init(v3270 *widget) { widget->host = lib3270_session_new(""); @@ -899,6 +868,7 @@ static void v3270_init(v3270 *widget) widget->host->ctlr_done = ctlr_done; widget->host->message = message; widget->host->update_ssl = v3270_update_ssl; + widget->host->print = emit_print_signal; // Setup input method widget->input_method = gtk_im_multicontext_new(); diff --git a/src/pw3270/window.c b/src/pw3270/window.c index a338415..66dfdcb 100644 --- a/src/pw3270/window.c +++ b/src/pw3270/window.c @@ -457,6 +457,11 @@ gtk_action_group_set_sensitive(group[ACTION_GROUP_CLIPBOARD],on); } + static void print_all(GtkWidget *widget, GtkWidget *window) + { + pw3270_print(widget,G_OBJECT(widget), GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, PW3270_SRC_ALL); + } + static void toggle_changed(GtkWidget *widget, LIB3270_TOGGLE id, gboolean toggled, const gchar *name, GtkWindow *toplevel) { GtkAction **list = (GtkAction **) g_object_get_data(G_OBJECT(widget),"toggle_actions"); @@ -604,6 +609,7 @@ // Connect widget signals g_signal_connect(widget->terminal,"field_clicked",G_CALLBACK(field_clicked),widget); g_signal_connect(widget->terminal,"toggle_changed",G_CALLBACK(toggle_changed),widget); + g_signal_connect(widget->terminal,"print",G_CALLBACK(print_all),widget); // Connect window signals g_signal_connect(widget,"window_state_event",G_CALLBACK(window_state_event),widget->terminal); -- libgit2 0.21.2