Commit 81afde048e9fe06548851b74f29eb46d4e6f9d20
1 parent
bcfcba8d
Exists in
master
and in
1 other branch
Splitting sources to group similars methods.
Showing
8 changed files
with
892 additions
and
774 deletions
Show diff stats
src/v3270/accessible.c
| ... | ... | @@ -74,6 +74,22 @@ G_DEFINE_TYPE_WITH_CODE (v3270Accessible, v3270_accessible, GTK_TYPE_ACCESSIBLE, |
| 74 | 74 | |
| 75 | 75 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
| 76 | 76 | |
| 77 | +AtkObject * v3270_get_accessible(GtkWidget * widget) | |
| 78 | +{ | |
| 79 | + v3270 * terminal = GTK_V3270(widget); | |
| 80 | + | |
| 81 | + if(!terminal->accessible) | |
| 82 | + { | |
| 83 | + terminal->accessible = g_object_new(GTK_TYPE_V3270_ACCESSIBLE,NULL); | |
| 84 | + atk_object_initialize(ATK_OBJECT(terminal->accessible), widget); | |
| 85 | + gtk_accessible_set_widget(GTK_ACCESSIBLE(terminal->accessible),widget); | |
| 86 | + g_object_ref(terminal->accessible); | |
| 87 | + } | |
| 88 | + | |
| 89 | + return ATK_OBJECT(terminal->accessible); | |
| 90 | +} | |
| 91 | + | |
| 92 | + | |
| 77 | 93 | static const gchar * v3270_accessible_get_description (AtkObject *accessible) |
| 78 | 94 | { |
| 79 | 95 | GtkWidget *widget = gtk_accessible_get_widget(GTK_ACCESSIBLE (accessible)); | ... | ... |
| ... | ... | @@ -0,0 +1,422 @@ |
| 1 | +/* | |
| 2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
| 3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
| 4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
| 5 | + * | |
| 6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
| 7 | + * | |
| 8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
| 9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
| 10 | + * Free Software Foundation. | |
| 11 | + * | |
| 12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
| 13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
| 14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
| 15 | + * obter mais detalhes. | |
| 16 | + * | |
| 17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
| 18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
| 19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
| 20 | + * | |
| 21 | + * Este programa está nomeado como - e possui - linhas de código. | |
| 22 | + * | |
| 23 | + * Contatos: | |
| 24 | + * | |
| 25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
| 26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
| 27 | + * | |
| 28 | + */ | |
| 29 | + | |
| 30 | + #include <config.h> | |
| 31 | + #include "private.h" | |
| 32 | + | |
| 33 | + #include <gtk/gtk.h> | |
| 34 | + #include <libintl.h> | |
| 35 | + #include <glib/gi18n.h> | |
| 36 | + | |
| 37 | + #include <lib3270.h> | |
| 38 | + #include <lib3270/session.h> | |
| 39 | + #include <lib3270/log.h> | |
| 40 | + #include <errno.h> | |
| 41 | + | |
| 42 | +/** | |
| 43 | + * SECTION: v3270 | |
| 44 | + * @title: Virtual 3270 widget | |
| 45 | + * @short_description: The virtual 3270 terminal widget. | |
| 46 | + * | |
| 47 | + * Manages lib3270 callbacks. | |
| 48 | + * | |
| 49 | + */ | |
| 50 | + | |
| 51 | +/*--[ Widget definition ]----------------------------------------------------------------------------*/ | |
| 52 | + | |
| 53 | +/*--[ Implement ]------------------------------------------------------------------------------------*/ | |
| 54 | + | |
| 55 | +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" | |
| 56 | + | |
| 57 | +static void set_timer(H3270 *session, unsigned char on) | |
| 58 | +{ | |
| 59 | + GtkWidget *widget = GTK_WIDGET(lib3270_get_user_data(session)); | |
| 60 | + | |
| 61 | + if(on) | |
| 62 | + v3270_start_timer(widget); | |
| 63 | + else | |
| 64 | + v3270_stop_timer(widget); | |
| 65 | + | |
| 66 | +} | |
| 67 | + | |
| 68 | +static void update_toggle(H3270 *session, LIB3270_TOGGLE ix, unsigned char value, G_GNUC_UNUSED LIB3270_TOGGLE_TYPE reason, const char *name) | |
| 69 | +{ | |
| 70 | + GtkWidget *widget = GTK_WIDGET(lib3270_get_user_data(session)); | |
| 71 | + | |
| 72 | + switch(ix) | |
| 73 | + { | |
| 74 | + case LIB3270_TOGGLE_CURSOR_POS: | |
| 75 | + case LIB3270_TOGGLE_MONOCASE: | |
| 76 | + case LIB3270_TOGGLE_LINE_WRAP: | |
| 77 | + case LIB3270_TOGGLE_CROSSHAIR: | |
| 78 | + case LIB3270_TOGGLE_BLANK_FILL: | |
| 79 | + case LIB3270_TOGGLE_MARGINED_PASTE: | |
| 80 | + case LIB3270_TOGGLE_SHOW_TIMING: | |
| 81 | + case LIB3270_TOGGLE_RECTANGLE_SELECT: | |
| 82 | + case LIB3270_TOGGLE_UNDERLINE: | |
| 83 | + case LIB3270_TOGGLE_VIEW_FIELD: | |
| 84 | + case LIB3270_TOGGLE_ALTSCREEN: | |
| 85 | + v3270_reload(widget); | |
| 86 | + gtk_widget_queue_draw(widget); | |
| 87 | + break; | |
| 88 | + | |
| 89 | + case LIB3270_TOGGLE_CURSOR_BLINK: | |
| 90 | + GTK_V3270(widget)->cursor.show |= 1; | |
| 91 | + break; | |
| 92 | + | |
| 93 | + case LIB3270_TOGGLE_INSERT: | |
| 94 | + v3270_draw_ins_status(GTK_V3270(widget)); | |
| 95 | + v3270_cursor_draw(GTK_V3270(widget)); | |
| 96 | + break; | |
| 97 | + | |
| 98 | + case LIB3270_TOGGLE_BOLD: | |
| 99 | + v3270_reload(widget); | |
| 100 | + gtk_widget_queue_draw(widget); | |
| 101 | + break; | |
| 102 | + | |
| 103 | + case LIB3270_TOGGLE_FULL_SCREEN: | |
| 104 | + if(value) | |
| 105 | + gtk_window_fullscreen(GTK_WINDOW(gtk_widget_get_toplevel(widget))); | |
| 106 | + else | |
| 107 | + gtk_window_unfullscreen(GTK_WINDOW(gtk_widget_get_toplevel(widget))); | |
| 108 | + | |
| 109 | + break; | |
| 110 | + | |
| 111 | + case LIB3270_TOGGLE_DS_TRACE: | |
| 112 | + case LIB3270_TOGGLE_SSL_TRACE: | |
| 113 | + case LIB3270_TOGGLE_SCREEN_TRACE: | |
| 114 | + case LIB3270_TOGGLE_EVENT_TRACE: | |
| 115 | + case LIB3270_TOGGLE_RECONNECT: | |
| 116 | + case LIB3270_TOGGLE_SMART_PASTE: | |
| 117 | + case LIB3270_TOGGLE_KEEP_SELECTED: | |
| 118 | + case LIB3270_TOGGLE_CONNECT_ON_STARTUP: | |
| 119 | + case LIB3270_TOGGLE_KP_ALTERNATIVE: | |
| 120 | + case LIB3270_TOGGLE_NETWORK_TRACE: | |
| 121 | + case LIB3270_TOGGLE_BEEP: | |
| 122 | + case LIB3270_TOGGLE_KEEP_ALIVE: | |
| 123 | + break; | |
| 124 | + | |
| 125 | + case LIB3270_TOGGLE_COUNT: | |
| 126 | + break; | |
| 127 | + | |
| 128 | + } | |
| 129 | + | |
| 130 | + g_object_notify_by_pspec(G_OBJECT(widget), v3270_properties.toggle[ix]); | |
| 131 | + g_signal_emit(widget, v3270_widget_signal[SIGNAL_TOGGLE_CHANGED], 0, (guint) ix, (gboolean) (value != 0), (gchar *) name); | |
| 132 | + | |
| 133 | +} | |
| 134 | + | |
| 135 | +static void bg_update_message(H3270 *session) | |
| 136 | +{ | |
| 137 | + void *widget = lib3270_get_user_data(session); | |
| 138 | + trace("-----A %s %p",__FUNCTION__, lib3270_get_user_data(session)); | |
| 139 | + | |
| 140 | + g_signal_emit( | |
| 141 | + GTK_WIDGET(widget), | |
| 142 | + v3270_widget_signal[SIGNAL_MESSAGE_CHANGED], | |
| 143 | + 0, | |
| 144 | + (gint) lib3270_get_program_message(session) | |
| 145 | + ); | |
| 146 | + | |
| 147 | + trace("-----B %s %p",__FUNCTION__, lib3270_get_user_data(session)); | |
| 148 | +} | |
| 149 | + | |
| 150 | +static void update_message(H3270 *session, G_GNUC_UNUSED LIB3270_MESSAGE id) | |
| 151 | +{ | |
| 152 | + g_idle_add((GSourceFunc) bg_update_message, session); | |
| 153 | +} | |
| 154 | + | |
| 155 | +static void update_luname(H3270 *session, const char *name) | |
| 156 | +{ | |
| 157 | + v3270_update_luname(GTK_WIDGET(lib3270_get_user_data(session)),name); | |
| 158 | +} | |
| 159 | + | |
| 160 | +struct select_cursor_data | |
| 161 | +{ | |
| 162 | + H3270 * hSession; | |
| 163 | + LIB3270_POINTER id; | |
| 164 | +}; | |
| 165 | + | |
| 166 | +static void bg_select_cursor(struct select_cursor_data *data) | |
| 167 | +{ | |
| 168 | + GtkWidget *widget = GTK_WIDGET(lib3270_get_user_data(data->hSession)); | |
| 169 | + | |
| 170 | +#if GTK_CHECK_VERSION(2,20,0) | |
| 171 | + if(gtk_widget_get_realized(widget) && gtk_widget_get_has_window(widget)) | |
| 172 | +#else | |
| 173 | + if(GTK_WIDGET_REALIZED(widget) && widget->window) | |
| 174 | +#endif // GTK(2,20) | |
| 175 | + { | |
| 176 | + GTK_V3270(widget)->pointer_id = data->id; | |
| 177 | + v3270_update_mouse_pointer(widget); | |
| 178 | + } | |
| 179 | +} | |
| 180 | + | |
| 181 | +static void select_cursor(H3270 *session, LIB3270_POINTER id) | |
| 182 | +{ | |
| 183 | + struct select_cursor_data *data = g_new0(struct select_cursor_data,1); | |
| 184 | + data->hSession = session; | |
| 185 | + data->id = id; | |
| 186 | + g_idle_add_full(G_PRIORITY_DEFAULT_IDLE,(GSourceFunc) bg_select_cursor, data, g_free); | |
| 187 | +} | |
| 188 | + | |
| 189 | +static void ctlr_done(H3270 *session) | |
| 190 | +{ | |
| 191 | + GtkWidget *widget = GTK_WIDGET(lib3270_get_user_data(session)); | |
| 192 | + | |
| 193 | +#if GTK_CHECK_VERSION(2,20,0) | |
| 194 | + if(gtk_widget_get_realized(widget) && gtk_widget_get_has_window(widget)) | |
| 195 | +#else | |
| 196 | + if(GTK_WIDGET_REALIZED(widget) && widget->window) | |
| 197 | +#endif // GTK(2,20) | |
| 198 | + { | |
| 199 | + v3270_update_mouse_pointer(widget); | |
| 200 | + } | |
| 201 | + | |
| 202 | +} | |
| 203 | + | |
| 204 | +static void update_connect(H3270 *session, unsigned char connected) | |
| 205 | +{ | |
| 206 | + v3270 *widget = GTK_V3270(lib3270_get_user_data(session)); | |
| 207 | + | |
| 208 | + if(connected) | |
| 209 | + { | |
| 210 | + widget->cursor.show |= 2; | |
| 211 | + g_signal_emit(GTK_WIDGET(widget), v3270_widget_signal[SIGNAL_CONNECTED], 0, lib3270_get_host(session)); | |
| 212 | + } | |
| 213 | + else | |
| 214 | + { | |
| 215 | + widget->cursor.show &= ~2; | |
| 216 | + g_signal_emit(GTK_WIDGET(widget), v3270_widget_signal[SIGNAL_DISCONNECTED], 0); | |
| 217 | + } | |
| 218 | + | |
| 219 | + if(v3270_properties.online) | |
| 220 | + g_object_notify_by_pspec(G_OBJECT(widget), v3270_properties.online); | |
| 221 | + | |
| 222 | + widget->activity.timestamp = time(0); | |
| 223 | + | |
| 224 | + gtk_widget_queue_draw(GTK_WIDGET(widget)); | |
| 225 | +} | |
| 226 | + | |
| 227 | +static void update_screen_size(H3270 *session, G_GNUC_UNUSED unsigned short rows, G_GNUC_UNUSED unsigned short cols) | |
| 228 | +{ | |
| 229 | + v3270_reload(GTK_WIDGET(lib3270_get_user_data(session))); | |
| 230 | + gtk_widget_queue_draw(GTK_WIDGET(lib3270_get_user_data(session))); | |
| 231 | +} | |
| 232 | + | |
| 233 | +static void update_model(H3270 *session, const char *name, int model, G_GNUC_UNUSED int rows, G_GNUC_UNUSED int cols) | |
| 234 | +{ | |
| 235 | + if(v3270_properties.model) | |
| 236 | + g_object_notify_by_pspec(G_OBJECT(lib3270_get_user_data(session)), v3270_properties.model); | |
| 237 | + | |
| 238 | + g_signal_emit(GTK_WIDGET(lib3270_get_user_data(session)),v3270_widget_signal[SIGNAL_MODEL_CHANGED], 0, (guint) model, name); | |
| 239 | +} | |
| 240 | + | |
| 241 | +static void changed(H3270 *session, int offset, int len) | |
| 242 | +{ | |
| 243 | + GtkWidget * widget = lib3270_get_user_data(session); | |
| 244 | + GtkAccessible * obj = GTK_V3270(widget)->accessible; | |
| 245 | + | |
| 246 | + if(obj) | |
| 247 | + { | |
| 248 | + // Get new text, notify atk | |
| 249 | + gsize bytes_written = 0; | |
| 250 | + char * text = lib3270_get_string_at_address(session,offset,len,'\n'); | |
| 251 | + | |
| 252 | + if(text) | |
| 253 | + { | |
| 254 | + GError * error = NULL; | |
| 255 | + gchar * utfchar = g_convert_with_fallback( text, | |
| 256 | + -1, | |
| 257 | + "UTF-8", | |
| 258 | + lib3270_get_display_charset(session), | |
| 259 | + " ", | |
| 260 | + NULL, | |
| 261 | + &bytes_written, | |
| 262 | + &error ); | |
| 263 | + | |
| 264 | + lib3270_free(text); | |
| 265 | + | |
| 266 | + if(error) | |
| 267 | + { | |
| 268 | + g_warning("%s failed: %s",__FUNCTION__,error->message); | |
| 269 | + g_error_free(error); | |
| 270 | + } | |
| 271 | + | |
| 272 | + if(utfchar) | |
| 273 | + { | |
| 274 | + g_signal_emit_by_name(obj, "text-insert", offset, bytes_written, utfchar); | |
| 275 | + g_free(utfchar); | |
| 276 | + } | |
| 277 | + | |
| 278 | + } | |
| 279 | + } | |
| 280 | + | |
| 281 | +#ifdef WIN32 | |
| 282 | + gtk_widget_queue_draw(widget); | |
| 283 | +#endif // WIN32 | |
| 284 | + | |
| 285 | + g_signal_emit(GTK_WIDGET(widget),v3270_widget_signal[SIGNAL_CHANGED], 0, (guint) offset, (guint) len); | |
| 286 | +} | |
| 287 | + | |
| 288 | +static void set_selection(H3270 *session, unsigned char status) | |
| 289 | +{ | |
| 290 | + GtkWidget * widget = GTK_WIDGET(lib3270_get_user_data(session)); | |
| 291 | + | |
| 292 | + if(v3270_properties.selection) | |
| 293 | + g_object_notify_by_pspec(G_OBJECT(widget), v3270_properties.selection); | |
| 294 | + | |
| 295 | + g_signal_emit(widget,v3270_widget_signal[SIGNAL_SELECTING], 0, status ? TRUE : FALSE); | |
| 296 | + | |
| 297 | +} | |
| 298 | + | |
| 299 | +static void update_selection(H3270 *session, G_GNUC_UNUSED int start, G_GNUC_UNUSED int end) | |
| 300 | +{ | |
| 301 | + // Selected region changed | |
| 302 | + GtkWidget * widget = GTK_WIDGET(lib3270_get_user_data(session)); | |
| 303 | + GtkAccessible * atk_obj = GTK_V3270(widget)->accessible; | |
| 304 | + | |
| 305 | + if(atk_obj) | |
| 306 | + g_signal_emit_by_name(atk_obj,"text-selection-changed"); | |
| 307 | + | |
| 308 | +} | |
| 309 | + | |
| 310 | +static void message(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *text) | |
| 311 | +{ | |
| 312 | + g_signal_emit( GTK_WIDGET(lib3270_get_user_data(session)), v3270_widget_signal[SIGNAL_MESSAGE], 0, | |
| 313 | + (int) id, | |
| 314 | + (gchar *) title, | |
| 315 | + (gchar *) message, | |
| 316 | + (gchar *) text ); | |
| 317 | + | |
| 318 | +} | |
| 319 | + | |
| 320 | +static int emit_print_signal(H3270 *session) | |
| 321 | +{ | |
| 322 | + g_signal_emit(GTK_WIDGET(lib3270_get_user_data(session)), v3270_widget_signal[SIGNAL_PRINT], 0); | |
| 323 | + return 0; | |
| 324 | +} | |
| 325 | + | |
| 326 | +static void popup_handler(H3270 *session, LIB3270_NOTIFY type, const char *title, const char *msg, const char *fmt, va_list args) | |
| 327 | +{ | |
| 328 | + GtkWidget *terminal = (GtkWidget *) lib3270_get_user_data(session); | |
| 329 | + | |
| 330 | + if(terminal && GTK_IS_V3270(terminal)) { | |
| 331 | + | |
| 332 | + if(fmt) | |
| 333 | + { | |
| 334 | + gchar *text = g_strdup_vprintf(fmt,args); | |
| 335 | + v3270_popup_message(GTK_WIDGET(terminal),type,title,msg,text); | |
| 336 | + g_free(text); | |
| 337 | + } | |
| 338 | + else | |
| 339 | + { | |
| 340 | + v3270_popup_message(GTK_WIDGET(terminal),type,title,msg,NULL); | |
| 341 | + } | |
| 342 | + | |
| 343 | + } | |
| 344 | + | |
| 345 | + } | |
| 346 | + | |
| 347 | + static gboolean bg_update_ssl(H3270 *session) | |
| 348 | + { | |
| 349 | + trace("%s",__FUNCTION__); | |
| 350 | + | |
| 351 | + v3270_blink_ssl(GTK_V3270(lib3270_get_user_data(session))); | |
| 352 | + | |
| 353 | + if(lib3270_get_secure(session) == LIB3270_SSL_NEGOTIATING) | |
| 354 | + v3270_start_blinking(GTK_WIDGET(lib3270_get_user_data(session))); | |
| 355 | + | |
| 356 | + return FALSE; | |
| 357 | + } | |
| 358 | + | |
| 359 | + static void update_ssl(H3270 *session, G_GNUC_UNUSED LIB3270_SSL_STATE state) | |
| 360 | + { | |
| 361 | + g_idle_add((GSourceFunc) bg_update_ssl, session); | |
| 362 | + } | |
| 363 | + | |
| 364 | + struct update_oia_data | |
| 365 | + { | |
| 366 | + H3270 *session; | |
| 367 | + LIB3270_FLAG id; | |
| 368 | + unsigned char on; | |
| 369 | + }; | |
| 370 | + | |
| 371 | + static gboolean bg_update_oia(struct update_oia_data *data) | |
| 372 | + { | |
| 373 | + v3270_update_oia(GTK_V3270(lib3270_get_user_data(data->session)), data->id, data->on); | |
| 374 | + return FALSE; | |
| 375 | + } | |
| 376 | + | |
| 377 | + static void update_oia(H3270 *session, LIB3270_FLAG id, unsigned char on) | |
| 378 | + { | |
| 379 | + struct update_oia_data *data = g_new0(struct update_oia_data,1); | |
| 380 | + data->session = session; | |
| 381 | + data->id = id; | |
| 382 | + data->on = on; | |
| 383 | + g_idle_add_full(G_PRIORITY_DEFAULT_IDLE,(GSourceFunc) bg_update_oia, data, g_free); | |
| 384 | + } | |
| 385 | + | |
| 386 | + void v3270_install_callbacks(v3270 *widget) | |
| 387 | + { | |
| 388 | + struct lib3270_session_callbacks *cbk; | |
| 389 | + | |
| 390 | + lib3270_set_popup_handler(widget->host, popup_handler); | |
| 391 | + | |
| 392 | + cbk = lib3270_get_session_callbacks(widget->host,sizeof(struct lib3270_session_callbacks)); | |
| 393 | + if(!cbk) | |
| 394 | + { | |
| 395 | + g_error( _( "Invalid callback table, possible version mismatch in lib3270") ); | |
| 396 | + return; | |
| 397 | + } | |
| 398 | + | |
| 399 | + cbk->update = v3270_update_char; | |
| 400 | + cbk->changed = changed; | |
| 401 | + cbk->set_timer = set_timer; | |
| 402 | + | |
| 403 | + cbk->set_selection = set_selection; | |
| 404 | + cbk->update_selection = update_selection; | |
| 405 | + | |
| 406 | + cbk->update_luname = update_luname; | |
| 407 | + cbk->configure = update_screen_size; | |
| 408 | + cbk->update_status = update_message; | |
| 409 | + cbk->update_cursor = v3270_update_cursor; | |
| 410 | + cbk->update_toggle = update_toggle; | |
| 411 | + cbk->update_oia = update_oia; | |
| 412 | + cbk->cursor = select_cursor; | |
| 413 | + cbk->update_connect = update_connect; | |
| 414 | + cbk->update_model = update_model; | |
| 415 | + cbk->changed = changed; | |
| 416 | + cbk->ctlr_done = ctlr_done; | |
| 417 | + cbk->message = message; | |
| 418 | + cbk->update_ssl = update_ssl; | |
| 419 | + cbk->print = emit_print_signal; | |
| 420 | + | |
| 421 | +} | |
| 422 | + | ... | ... |
| ... | ... | @@ -0,0 +1,201 @@ |
| 1 | +/* | |
| 2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
| 3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
| 4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
| 5 | + * | |
| 6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
| 7 | + * | |
| 8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
| 9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
| 10 | + * Free Software Foundation. | |
| 11 | + * | |
| 12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
| 13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
| 14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
| 15 | + * obter mais detalhes. | |
| 16 | + * | |
| 17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
| 18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
| 19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
| 20 | + * | |
| 21 | + * Este programa está nomeado como - e possui - linhas de código. | |
| 22 | + * | |
| 23 | + * Contatos: | |
| 24 | + * | |
| 25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
| 26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
| 27 | + * | |
| 28 | + */ | |
| 29 | + | |
| 30 | + #include <config.h> | |
| 31 | + #include "private.h" | |
| 32 | + | |
| 33 | + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" | |
| 34 | + | |
| 35 | + #include <lib3270.h> | |
| 36 | + #include <lib3270/log.h> | |
| 37 | + | |
| 38 | +/*--[ Globals ]--------------------------------------------------------------------------------------*/ | |
| 39 | + | |
| 40 | +const gchar * v3270_default_colors = | |
| 41 | + "#000000," // V3270_COLOR_BACKGROUND | |
| 42 | + "#7890F0," // V3270_COLOR_BLUE | |
| 43 | + "#FF0000," // V3270_COLOR_RED | |
| 44 | + "#FF00FF," // V3270_COLOR_PINK | |
| 45 | + "#00FF00," // V3270_COLOR_GREEN | |
| 46 | + "#00FFFF," // V3270_COLOR_TURQUOISE | |
| 47 | + "#FFFF00," // V3270_COLOR_YELLOW | |
| 48 | + "#FFFFFF," // V3270_COLOR_WHITE | |
| 49 | + "#000000," // V3270_COLOR_BLACK | |
| 50 | + "#000080," // V3270_COLOR_DARK_BLUE | |
| 51 | + "#FFA200," // V3270_COLOR_ORANGE | |
| 52 | + "#800080," // V3270_COLOR_PURPLE | |
| 53 | + "#008000," // V3270_COLOR_DARK_GREEN | |
| 54 | + "#008080," // V3270_COLOR_DARK_TURQUOISE | |
| 55 | + "#A0A000," // V3270_COLOR_MUSTARD | |
| 56 | + "#C0C0C0," // V3270_COLOR_GRAY | |
| 57 | + | |
| 58 | + "#00FF00," // V3270_COLOR_FIELD_DEFAULT | |
| 59 | + "#FF0000," // V3270_COLOR_FIELD_INTENSIFIED | |
| 60 | + "#00FFFF," // V3270_COLOR_FIELD_PROTECTED | |
| 61 | + "#FFFFFF," // V3270_COLOR_FIELD_PROTECTED_INTENSIFIED | |
| 62 | + | |
| 63 | + "#404040," // V3270_COLOR_SELECTED_BG | |
| 64 | + "#FFFFFF," // V3270_COLOR_SELECTED_FG, | |
| 65 | + | |
| 66 | + "#00FF00," // V3270_COLOR_CROSS_HAIR | |
| 67 | + | |
| 68 | + "#000000," // V3270_COLOR_OIA_BACKGROUND | |
| 69 | + "#00FF00," // V3270_COLOR_OIA | |
| 70 | + "#7890F0," // V3270_COLOR_OIA_SEPARATOR | |
| 71 | + "#FFFFFF," // V3270_COLOR_OIA_STATUS_OK | |
| 72 | + "#FFFF00," // V3270_COLOR_OIA_STATUS_WARNING | |
| 73 | + "#FF0000"; // V3270_COLOR_OIA_STATUS_INVALID | |
| 74 | + | |
| 75 | + | |
| 76 | +/*--[ Implement ]------------------------------------------------------------------------------------*/ | |
| 77 | + | |
| 78 | +void v3270_set_colors(GtkWidget *widget, const gchar *colors) | |
| 79 | +{ | |
| 80 | + g_return_if_fail(GTK_IS_V3270(widget)); | |
| 81 | + | |
| 82 | + if(!colors) | |
| 83 | + { | |
| 84 | + colors = v3270_default_colors; | |
| 85 | + } | |
| 86 | + | |
| 87 | + v3270_set_color_table(GTK_V3270(widget)->color,colors); | |
| 88 | + g_signal_emit(widget,v3270_widget_signal[SIGNAL_UPDATE_CONFIG], 0, "colors", colors); | |
| 89 | + v3270_reload(widget); | |
| 90 | + | |
| 91 | +} | |
| 92 | + | |
| 93 | +void v3270_set_color(GtkWidget *widget, enum V3270_COLOR id, GdkRGBA *color) | |
| 94 | +{ | |
| 95 | + g_return_if_fail(GTK_IS_V3270(widget)); | |
| 96 | + | |
| 97 | + GTK_V3270(widget)->color[id] = *color; | |
| 98 | + | |
| 99 | +#if !GTK_CHECK_VERSION(3,0,0) | |
| 100 | + gdk_colormap_alloc_color(gtk_widget_get_default_colormap(),color,TRUE,TRUE); | |
| 101 | +#endif // !GTK(3,0,0) | |
| 102 | + | |
| 103 | +} | |
| 104 | +GdkRGBA * v3270_get_color(GtkWidget *widget, enum V3270_COLOR id) | |
| 105 | +{ | |
| 106 | + g_return_val_if_fail(GTK_IS_V3270(widget),NULL); | |
| 107 | + return GTK_V3270(widget)->color+id; | |
| 108 | +} | |
| 109 | + | |
| 110 | +const GdkRGBA * v3270_get_color_table(GtkWidget *widget) | |
| 111 | +{ | |
| 112 | + g_return_val_if_fail(GTK_IS_V3270(widget),NULL); | |
| 113 | + return GTK_V3270(widget)->color; | |
| 114 | +} | |
| 115 | + | |
| 116 | +void v3270_set_mono_color_table(GdkRGBA *clr, const gchar *fg, const gchar *bg) | |
| 117 | +{ | |
| 118 | + int f; | |
| 119 | + | |
| 120 | + gdk_rgba_parse(clr,bg); | |
| 121 | + gdk_rgba_parse(clr+1,fg); | |
| 122 | + | |
| 123 | + for(f=2;f<V3270_COLOR_COUNT;f++) | |
| 124 | + clr[f] = clr[1]; | |
| 125 | + | |
| 126 | + clr[V3270_COLOR_BLACK] = *clr; | |
| 127 | + clr[V3270_COLOR_OIA_BACKGROUND] = *clr; | |
| 128 | + clr[V3270_COLOR_SELECTED_BG] = clr[V3270_COLOR_WHITE]; | |
| 129 | + clr[V3270_COLOR_SELECTED_FG] = clr[V3270_COLOR_BLACK]; | |
| 130 | + | |
| 131 | + | |
| 132 | +} | |
| 133 | + | |
| 134 | +void v3270_set_color_table(GdkRGBA *table, const gchar *colors) | |
| 135 | +{ | |
| 136 | + gchar **clr; | |
| 137 | + guint cnt; | |
| 138 | + guint f; | |
| 139 | + | |
| 140 | + if(strchr(colors,':')) | |
| 141 | + clr = g_strsplit(colors,":",V3270_COLOR_COUNT+1); | |
| 142 | + else if(strchr(colors,';')) | |
| 143 | + clr = g_strsplit(colors,";",V3270_COLOR_COUNT+1); | |
| 144 | + else | |
| 145 | + clr = g_strsplit(colors,",",V3270_COLOR_COUNT+1); | |
| 146 | + | |
| 147 | + cnt = g_strv_length(clr); | |
| 148 | + | |
| 149 | + switch(cnt) | |
| 150 | + { | |
| 151 | + case 28: // Version 4 string | |
| 152 | + for(f=0;f < 28;f++) | |
| 153 | + gdk_rgba_parse(table+f,clr[f]); | |
| 154 | + table[V3270_COLOR_OIA_STATUS_INVALID] = table[V3270_COLOR_OIA_STATUS_WARNING]; | |
| 155 | + break; | |
| 156 | + | |
| 157 | + case V3270_COLOR_COUNT: // Complete string | |
| 158 | + for(f=0;f < V3270_COLOR_COUNT;f++) | |
| 159 | + gdk_rgba_parse(table+f,clr[f]); | |
| 160 | + break; | |
| 161 | + | |
| 162 | + default: | |
| 163 | + | |
| 164 | + g_warning("Color table has %d elements; should be %d.",cnt,V3270_COLOR_COUNT); | |
| 165 | + | |
| 166 | + if(cnt < V3270_COLOR_COUNT) | |
| 167 | + { | |
| 168 | + // Less than the required | |
| 169 | + for(f=0;f < cnt;f++) | |
| 170 | + gdk_rgba_parse(table+f,clr[f]); | |
| 171 | + | |
| 172 | + for(f=cnt; f < V3270_COLOR_COUNT;f++) | |
| 173 | + gdk_rgba_parse(table+f,clr[cnt-1]); | |
| 174 | + | |
| 175 | + clr[V3270_COLOR_OIA_BACKGROUND] = clr[0]; | |
| 176 | + clr[V3270_COLOR_SELECTED_BG] = clr[0]; | |
| 177 | + } | |
| 178 | + else | |
| 179 | + { | |
| 180 | + // More than required | |
| 181 | + for(f=0;f < V3270_COLOR_COUNT;f++) | |
| 182 | + gdk_rgba_parse(table+f,clr[f]); | |
| 183 | + } | |
| 184 | + } | |
| 185 | + | |
| 186 | + g_strfreev(clr); | |
| 187 | + | |
| 188 | +} | |
| 189 | + | |
| 190 | +LIB3270_EXPORT int v3270_set_session_color_type(GtkWidget *widget, unsigned short colortype) | |
| 191 | +{ | |
| 192 | + g_return_val_if_fail(GTK_IS_V3270(widget),EINVAL); | |
| 193 | + return lib3270_set_color_type(GTK_V3270(widget)->host,colortype); | |
| 194 | +} | |
| 195 | + | |
| 196 | +LIB3270_EXPORT unsigned short v3270_get_session_color_type(GtkWidget *widget) | |
| 197 | +{ | |
| 198 | + g_return_val_if_fail(GTK_IS_V3270(widget),-1); | |
| 199 | + return lib3270_get_color_type(GTK_V3270(widget)->host); | |
| 200 | +} | |
| 201 | + | ... | ... |
src/v3270/draw.c
| ... | ... | @@ -522,3 +522,18 @@ void v3270_queue_draw_area(GtkWidget *widget, gint x, gint y, gint width, gint h |
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | } |
| 525 | + | |
| 526 | +void v3270_disable_updates(GtkWidget *widget) | |
| 527 | +{ | |
| 528 | + GTK_V3270(widget)->drawing = 0; | |
| 529 | +} | |
| 530 | + | |
| 531 | +void v3270_enable_updates(GtkWidget *widget) | |
| 532 | +{ | |
| 533 | + if(gtk_widget_get_realized(widget)) | |
| 534 | + { | |
| 535 | + GTK_V3270(widget)->drawing = 1; | |
| 536 | + v3270_reload(widget); | |
| 537 | + gtk_widget_queue_draw(widget); | |
| 538 | + } | |
| 539 | +} | ... | ... |
| ... | ... | @@ -0,0 +1,192 @@ |
| 1 | +/* | |
| 2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
| 3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
| 4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
| 5 | + * | |
| 6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
| 7 | + * | |
| 8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
| 9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
| 10 | + * Free Software Foundation. | |
| 11 | + * | |
| 12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
| 13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
| 14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
| 15 | + * obter mais detalhes. | |
| 16 | + * | |
| 17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
| 18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
| 19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
| 20 | + * | |
| 21 | + * Este programa está nomeado como - e possui - linhas de código. | |
| 22 | + * | |
| 23 | + * Contatos: | |
| 24 | + * | |
| 25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
| 26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
| 27 | + * | |
| 28 | + */ | |
| 29 | + | |
| 30 | + #include <config.h> | |
| 31 | + #include "private.h" | |
| 32 | + #include <lib3270.h> | |
| 33 | + #include <lib3270/log.h> | |
| 34 | + | |
| 35 | + #define WIDTH_IN_PIXELS(terminal,x) (x * cols) | |
| 36 | + #define HEIGHT_IN_PIXELS(terminal,x) (x * (rows+1)) | |
| 37 | + | |
| 38 | + #define CONTENTS_WIDTH(terminal) (cols * terminal->font.width) | |
| 39 | + #define CONTENTS_HEIGHT(terminal) (((rows+1) * terminal->font.spacing)+OIA_TOP_MARGIN+2) | |
| 40 | + | |
| 41 | +/*--[ Globals ]--------------------------------------------------------------------------------------*/ | |
| 42 | + | |
| 43 | + const gchar * v3270_default_font = "monospace"; | |
| 44 | + | |
| 45 | +/*--[ Implement ]------------------------------------------------------------------------------------*/ | |
| 46 | + | |
| 47 | +void v3270_update_font_metrics(v3270 *terminal, cairo_t *cr, int width, int height) | |
| 48 | +{ | |
| 49 | + // update font metrics | |
| 50 | + int rows, cols, hFont, size; | |
| 51 | + | |
| 52 | + cairo_font_extents_t extents; | |
| 53 | + | |
| 54 | + lib3270_get_screen_size(terminal->host,&rows,&cols); | |
| 55 | + | |
| 56 | + terminal->font.weight = lib3270_get_toggle(terminal->host,LIB3270_TOGGLE_BOLD) ? CAIRO_FONT_WEIGHT_BOLD : CAIRO_FONT_WEIGHT_NORMAL; | |
| 57 | + | |
| 58 | + cairo_select_font_face(cr,terminal->font.family, CAIRO_FONT_SLANT_NORMAL,terminal->font.weight); | |
| 59 | + | |
| 60 | + if(terminal->font.scaled) | |
| 61 | + { | |
| 62 | + double w = ((double) width) / ((double)cols); | |
| 63 | + double h = ((double) height) / ((double) (rows+2)); | |
| 64 | + double s = w < h ? w : h; | |
| 65 | + | |
| 66 | + cairo_set_font_size(cr,s); | |
| 67 | + cairo_font_extents(cr,&extents); | |
| 68 | + | |
| 69 | + while( HEIGHT_IN_PIXELS(terminal,(extents.height+extents.descent)) < height && WIDTH_IN_PIXELS(terminal,extents.max_x_advance) < width ) | |
| 70 | + { | |
| 71 | + s += 1.0; | |
| 72 | + cairo_set_font_size(cr,s); | |
| 73 | + cairo_font_extents(cr,&extents); | |
| 74 | + } | |
| 75 | + | |
| 76 | + s -= 1.0; | |
| 77 | + | |
| 78 | + cairo_set_font_size(cr,s < 1.0 ? 1.0 : s); | |
| 79 | + cairo_font_extents(cr,&extents); | |
| 80 | + } | |
| 81 | + else | |
| 82 | + { | |
| 83 | + static const int font_size[] = { 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 18, 20, 22, 24, 26, 28, 32, 36, 40, 48, 56, 64, 72, 0 }; | |
| 84 | + int f; | |
| 85 | + | |
| 86 | + size = font_size[0]; | |
| 87 | + | |
| 88 | + for(f=0;font_size[f];f++) | |
| 89 | + { | |
| 90 | + cairo_set_font_size(cr,font_size[f]); | |
| 91 | + cairo_font_extents(cr,&extents); | |
| 92 | + | |
| 93 | + if(f == 0) | |
| 94 | + { | |
| 95 | + terminal->minimum_width = (cols * extents.max_x_advance); | |
| 96 | + terminal->minimum_height = ((rows+1) * (extents.height + extents.descent)) + (OIA_TOP_MARGIN+2); | |
| 97 | + } | |
| 98 | + | |
| 99 | + if( HEIGHT_IN_PIXELS(terminal,(extents.height+extents.descent)) < height && WIDTH_IN_PIXELS(terminal,extents.max_x_advance) < width ) | |
| 100 | + size = font_size[f]; | |
| 101 | + } | |
| 102 | + | |
| 103 | + cairo_set_font_size(cr,size); | |
| 104 | + | |
| 105 | + #if !GTK_CHECK_VERSION(3,0,0) | |
| 106 | + gtk_widget_set_size_request(GTK_WIDGET(terminal),terminal->minimum_width,terminal->minimum_height); | |
| 107 | + #endif // !GTK(3,0,0) | |
| 108 | + | |
| 109 | + } | |
| 110 | + | |
| 111 | + cairo_font_extents(cr,&extents); | |
| 112 | + | |
| 113 | + // Save scaled font for use on next drawings | |
| 114 | + if(terminal->font.scaled) | |
| 115 | + cairo_scaled_font_destroy(terminal->font.scaled); | |
| 116 | + | |
| 117 | + terminal->font.scaled = cairo_get_scaled_font(cr); | |
| 118 | + cairo_scaled_font_reference(terminal->font.scaled); | |
| 119 | + | |
| 120 | + cairo_scaled_font_extents(terminal->font.scaled,&extents); | |
| 121 | + | |
| 122 | + terminal->font.width = (int) extents.max_x_advance; | |
| 123 | + terminal->font.height = (int) extents.height; | |
| 124 | + terminal->font.ascent = (int) extents.ascent; | |
| 125 | + terminal->font.descent = (int) extents.descent; | |
| 126 | + | |
| 127 | + hFont = terminal->font.height + terminal->font.descent; | |
| 128 | + | |
| 129 | + // Create new cursor surface | |
| 130 | + if(terminal->cursor.surface) | |
| 131 | + cairo_surface_destroy(terminal->cursor.surface); | |
| 132 | + | |
| 133 | + terminal->cursor.surface = gdk_window_create_similar_surface(gtk_widget_get_window(GTK_WIDGET(terminal)),CAIRO_CONTENT_COLOR,terminal->font.width,hFont); | |
| 134 | + | |
| 135 | + // Center image | |
| 136 | + size = CONTENTS_WIDTH(terminal); | |
| 137 | + terminal->font.left = (width >> 1) - ((size) >> 1); | |
| 138 | + | |
| 139 | + terminal->font.spacing = height / (rows+2); | |
| 140 | + if((int) terminal->font.spacing < hFont) | |
| 141 | + terminal->font.spacing = hFont; | |
| 142 | + | |
| 143 | + size = CONTENTS_HEIGHT(terminal); | |
| 144 | + | |
| 145 | + terminal->font.top = (height >> 1) - (size >> 1); | |
| 146 | + | |
| 147 | +} | |
| 148 | + | |
| 149 | +LIB3270_EXPORT void v3270_set_font_family(GtkWidget *widget, const gchar *name) | |
| 150 | +{ | |
| 151 | + v3270 * terminal; | |
| 152 | + | |
| 153 | + g_return_if_fail(GTK_IS_V3270(widget)); | |
| 154 | + | |
| 155 | + terminal = GTK_V3270(widget); | |
| 156 | + | |
| 157 | + if(!name) | |
| 158 | + { | |
| 159 | + name = v3270_default_font; | |
| 160 | + } | |
| 161 | + | |
| 162 | + if(g_ascii_strcasecmp(terminal->font.family,name)) | |
| 163 | + { | |
| 164 | + // Font has changed, update it | |
| 165 | + g_free(terminal->font.family); | |
| 166 | + | |
| 167 | + terminal->font.family = g_strdup(name); | |
| 168 | + terminal->font.weight = lib3270_get_toggle(terminal->host,LIB3270_TOGGLE_BOLD) ? CAIRO_FONT_WEIGHT_BOLD : CAIRO_FONT_WEIGHT_NORMAL; | |
| 169 | + | |
| 170 | + g_signal_emit(widget,v3270_widget_signal[SIGNAL_UPDATE_CONFIG], 0, "font-family", name); | |
| 171 | + | |
| 172 | + v3270_reload(widget); | |
| 173 | + gtk_widget_queue_draw(widget); | |
| 174 | + | |
| 175 | + } | |
| 176 | + | |
| 177 | + | |
| 178 | +} | |
| 179 | + | |
| 180 | +LIB3270_EXPORT const gchar * v3270_get_font_family(GtkWidget *widget) | |
| 181 | +{ | |
| 182 | + g_return_val_if_fail(GTK_IS_V3270(widget),NULL); | |
| 183 | + return GTK_V3270(widget)->font.family; | |
| 184 | +} | |
| 185 | + | |
| 186 | +void v3270_set_scaled_fonts(GtkWidget *widget, gboolean on) | |
| 187 | +{ | |
| 188 | + g_return_if_fail(GTK_IS_V3270(widget)); | |
| 189 | + | |
| 190 | + GTK_V3270(widget)->scaled_fonts = on ? 1 : 0; | |
| 191 | + | |
| 192 | +} | ... | ... |
src/v3270/private.h
| ... | ... | @@ -275,10 +275,13 @@ G_BEGIN_DECLS |
| 275 | 275 | const GtkWidgetClass * v3270_get_parent_class(void); |
| 276 | 276 | |
| 277 | 277 | G_GNUC_INTERNAL gboolean v3270_draw(GtkWidget * widget, cairo_t * cr); |
| 278 | +G_GNUC_INTERNAL void v3270_cursor_draw(v3270 *widget); | |
| 278 | 279 | |
| 279 | 280 | G_GNUC_INTERNAL void v3270_draw_oia(v3270 *terminal, cairo_t *cr, int row, int cols); |
| 280 | 281 | G_GNUC_INTERNAL void v3270_update_mouse_pointer(GtkWidget *widget); |
| 281 | 282 | |
| 283 | +G_GNUC_INTERNAL AtkObject * v3270_get_accessible(GtkWidget * widget); | |
| 284 | + | |
| 282 | 285 | #if ! GTK_CHECK_VERSION(2,18,0) |
| 283 | 286 | G_GNUC_INTERNAL void gtk_widget_get_allocation(GtkWidget *widget,GtkAllocation *allocation); |
| 284 | 287 | #endif // !GTK(2,18) | ... | ... |
src/v3270/properties.c
| ... | ... | @@ -269,3 +269,25 @@ |
| 269 | 269 | g_return_val_if_fail(GTK_IS_V3270(widget),0); |
| 270 | 270 | return GTK_V3270(widget)->activity.disconnect; |
| 271 | 271 | } |
| 272 | + | |
| 273 | +LIB3270_EXPORT gboolean v3270_get_toggle(GtkWidget *widget, LIB3270_TOGGLE ix) | |
| 274 | +{ | |
| 275 | + g_return_val_if_fail(GTK_IS_V3270(widget),FALSE); | |
| 276 | + | |
| 277 | + if(ix < LIB3270_TOGGLE_COUNT) | |
| 278 | + return lib3270_get_toggle(GTK_V3270(widget)->host,ix) ? TRUE : FALSE; | |
| 279 | + | |
| 280 | + return FALSE; | |
| 281 | +} | |
| 282 | + | |
| 283 | +LIB3270_EXPORT gboolean v3270_set_toggle(GtkWidget *widget, LIB3270_TOGGLE ix, gboolean state) | |
| 284 | +{ | |
| 285 | + g_return_val_if_fail(GTK_IS_V3270(widget),FALSE); | |
| 286 | + | |
| 287 | + if(ix < LIB3270_TOGGLE_COUNT) | |
| 288 | + return lib3270_set_toggle(GTK_V3270(widget)->host,ix,state ? 1 : 0) ? TRUE : FALSE; | |
| 289 | + | |
| 290 | + return FALSE; | |
| 291 | + | |
| 292 | +} | |
| 293 | + | ... | ... |
src/v3270/widget.c
| ... | ... | @@ -18,7 +18,7 @@ |
| 18 | 18 | * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin |
| 19 | 19 | * St, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | 20 | * |
| 21 | - * Este programa está nomeado como widget.c e possui - linhas de código. | |
| 21 | + * Este programa está nomeado como - e possui - linhas de código. | |
| 22 | 22 | * |
| 23 | 23 | * Contatos: |
| 24 | 24 | * |
| ... | ... | @@ -28,43 +28,17 @@ |
| 28 | 28 | */ |
| 29 | 29 | |
| 30 | 30 | #include <config.h> |
| 31 | - | |
| 32 | - #pragma GCC diagnostic ignored "-Wdeprecated-declarations" | |
| 33 | - | |
| 34 | - #define ENABLE_NLS | |
| 35 | - #define GETTEXT_PACKAGE PACKAGE_NAME | |
| 36 | - | |
| 37 | - #include <gtk/gtk.h> | |
| 38 | - #include <libintl.h> | |
| 39 | - #include <glib/gi18n.h> | |
| 40 | - | |
| 41 | -#ifdef WIN32 | |
| 42 | - #include <winsock2.h> | |
| 43 | - #include <windows.h> | |
| 44 | - #include <ws2tcpip.h> | |
| 45 | -#endif // WIN32 | |
| 31 | + #include "private.h" | |
| 32 | + #include "marshal.h" | |
| 46 | 33 | |
| 47 | 34 | #include <lib3270.h> |
| 48 | - #include <lib3270/session.h> | |
| 49 | - #include <lib3270/actions.h> | |
| 50 | 35 | #include <lib3270/log.h> |
| 51 | -// #include <lib3270/macros.h> | |
| 52 | - #include <errno.h> | |
| 53 | - | |
| 54 | -#ifdef HAVE_MALLOC_H | |
| 55 | - #include <malloc.h> | |
| 56 | -#endif // HAVE_MALLOC_H | |
| 57 | - | |
| 58 | - #include <v3270.h> | |
| 59 | - #include "private.h" | |
| 60 | - #include <v3270/accessible.h> | |
| 61 | - #include "marshal.h" | |
| 62 | 36 | |
| 63 | -#if GTK_CHECK_VERSION(3,0,0) | |
| 37 | + #if GTK_CHECK_VERSION(3,0,0) | |
| 64 | 38 | #include <gdk/gdkkeysyms-compat.h> |
| 65 | -#else | |
| 39 | + #else | |
| 66 | 40 | #include <gdk/gdkkeysyms.h> |
| 67 | -#endif | |
| 41 | + #endif | |
| 68 | 42 | |
| 69 | 43 | #define WIDTH_IN_PIXELS(terminal,x) (x * cols) |
| 70 | 44 | #define HEIGHT_IN_PIXELS(terminal,x) (x * (rows+1)) |
| ... | ... | @@ -96,7 +70,6 @@ static void v3270_realize ( GtkWidget * widget) ; |
| 96 | 70 | static void v3270_size_allocate ( GtkWidget * widget, |
| 97 | 71 | GtkAllocation * allocation ); |
| 98 | 72 | static void v3270_send_configure ( v3270 * terminal ); |
| 99 | -static AtkObject * v3270_get_accessible ( GtkWidget * widget ); | |
| 100 | 73 | |
| 101 | 74 | // Signals |
| 102 | 75 | static void v3270_activate (GtkWidget *widget); |
| ... | ... | @@ -104,19 +77,11 @@ static void v3270_activate (GtkWidget *widget); |
| 104 | 77 | gboolean v3270_focus_in_event(GtkWidget *widget, GdkEventFocus *event); |
| 105 | 78 | gboolean v3270_focus_out_event(GtkWidget *widget, GdkEventFocus *event); |
| 106 | 79 | |
| 107 | -#if GTK_CHECK_VERSION(3,0,0) | |
| 108 | - | |
| 109 | 80 | static void v3270_destroy (GtkWidget * object); |
| 110 | 81 | |
| 111 | -#else | |
| 112 | - | |
| 113 | -static void v3270_destroy (GtkObject * object); | |
| 114 | - | |
| 115 | -#endif // gtk3 | |
| 116 | - | |
| 117 | 82 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
| 118 | 83 | |
| 119 | -static void v3270_cursor_draw(v3270 *widget) | |
| 84 | +void v3270_cursor_draw(v3270 *widget) | |
| 120 | 85 | { |
| 121 | 86 | int pos = lib3270_get_cursor_address(widget->host); |
| 122 | 87 | unsigned char c; |
| ... | ... | @@ -130,16 +95,6 @@ static void v3270_cursor_draw(v3270 *widget) |
| 130 | 95 | |
| 131 | 96 | } |
| 132 | 97 | |
| 133 | - | |
| 134 | -static void v3270_toggle_changed(G_GNUC_UNUSED v3270 *widget, G_GNUC_UNUSED LIB3270_TOGGLE toggle_id, G_GNUC_UNUSED gboolean toggle_state, G_GNUC_UNUSED const gchar *toggle_name) | |
| 135 | -{ | |
| 136 | -} | |
| 137 | - | |
| 138 | -static void loghandler(G_GNUC_UNUSED H3270 *session, const char *module, int rc, const char *fmt, va_list args) | |
| 139 | -{ | |
| 140 | - g_logv(module,rc ? G_LOG_LEVEL_WARNING : G_LOG_LEVEL_MESSAGE, fmt, args); | |
| 141 | -} | |
| 142 | - | |
| 143 | 98 | static gboolean v3270_popup_menu(GtkWidget * widget) |
| 144 | 99 | { |
| 145 | 100 | GdkEventButton event; |
| ... | ... | @@ -157,8 +112,6 @@ static gboolean v3270_popup_menu(GtkWidget * widget) |
| 157 | 112 | return TRUE; |
| 158 | 113 | } |
| 159 | 114 | |
| 160 | -#if GTK_CHECK_VERSION(3,0,0) | |
| 161 | - | |
| 162 | 115 | void get_preferred_height(GtkWidget *widget, gint *minimum_height, gint *natural_height) |
| 163 | 116 | { |
| 164 | 117 | int height = GTK_V3270(widget)->minimum_height; |
| ... | ... | @@ -182,8 +135,6 @@ void get_preferred_width(GtkWidget *widget, gint *minimum_width, gint *natural_w |
| 182 | 135 | *natural_width = 600; |
| 183 | 136 | } |
| 184 | 137 | |
| 185 | -#endif // GTK(3,0,0) | |
| 186 | - | |
| 187 | 138 | void v3270_popup_message(GtkWidget *widget, LIB3270_NOTIFY type , const gchar *title, const gchar *message, const gchar *text) |
| 188 | 139 | { |
| 189 | 140 | GtkWidget * dialog; |
| ... | ... | @@ -288,6 +239,15 @@ gboolean v3270_query_tooltip(GtkWidget *widget, gint x, gint y, G_GNUC_UNUSED g |
| 288 | 239 | return FALSE; |
| 289 | 240 | } |
| 290 | 241 | |
| 242 | +static void loghandler(G_GNUC_UNUSED H3270 *session, const char *module, int rc, const char *fmt, va_list args) | |
| 243 | +{ | |
| 244 | + g_logv(module,rc ? G_LOG_LEVEL_WARNING : G_LOG_LEVEL_MESSAGE, fmt, args); | |
| 245 | +} | |
| 246 | + | |
| 247 | +static void v3270_toggle_changed(G_GNUC_UNUSED v3270 *widget, G_GNUC_UNUSED LIB3270_TOGGLE toggle_id, G_GNUC_UNUSED gboolean toggle_state, G_GNUC_UNUSED const gchar *toggle_name) | |
| 248 | +{ | |
| 249 | +} | |
| 250 | + | |
| 291 | 251 | static void v3270_class_init(v3270Class *klass) |
| 292 | 252 | { |
| 293 | 253 | GObjectClass * gobject_class = G_OBJECT_CLASS(klass); |
| ... | ... | @@ -547,371 +507,6 @@ static void v3270_class_init(v3270Class *klass) |
| 547 | 507 | |
| 548 | 508 | } |
| 549 | 509 | |
| 550 | -void v3270_update_font_metrics(v3270 *terminal, cairo_t *cr, int width, int height) | |
| 551 | -{ | |
| 552 | - // update font metrics | |
| 553 | - int rows, cols, hFont, size; | |
| 554 | - | |
| 555 | - cairo_font_extents_t extents; | |
| 556 | - | |
| 557 | - lib3270_get_screen_size(terminal->host,&rows,&cols); | |
| 558 | - | |
| 559 | - terminal->font.weight = lib3270_get_toggle(terminal->host,LIB3270_TOGGLE_BOLD) ? CAIRO_FONT_WEIGHT_BOLD : CAIRO_FONT_WEIGHT_NORMAL; | |
| 560 | - | |
| 561 | - cairo_select_font_face(cr,terminal->font.family, CAIRO_FONT_SLANT_NORMAL,terminal->font.weight); | |
| 562 | - | |
| 563 | - if(terminal->font.scaled) | |
| 564 | - { | |
| 565 | - double w = ((double) width) / ((double)cols); | |
| 566 | - double h = ((double) height) / ((double) (rows+2)); | |
| 567 | - double s = w < h ? w : h; | |
| 568 | - | |
| 569 | - cairo_set_font_size(cr,s); | |
| 570 | - cairo_font_extents(cr,&extents); | |
| 571 | - | |
| 572 | - while( HEIGHT_IN_PIXELS(terminal,(extents.height+extents.descent)) < height && WIDTH_IN_PIXELS(terminal,extents.max_x_advance) < width ) | |
| 573 | - { | |
| 574 | - s += 1.0; | |
| 575 | - cairo_set_font_size(cr,s); | |
| 576 | - cairo_font_extents(cr,&extents); | |
| 577 | - } | |
| 578 | - | |
| 579 | - s -= 1.0; | |
| 580 | - | |
| 581 | - cairo_set_font_size(cr,s < 1.0 ? 1.0 : s); | |
| 582 | - cairo_font_extents(cr,&extents); | |
| 583 | - } | |
| 584 | - else | |
| 585 | - { | |
| 586 | - static const int font_size[] = { 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 18, 20, 22, 24, 26, 28, 32, 36, 40, 48, 56, 64, 72, 0 }; | |
| 587 | - int f; | |
| 588 | - | |
| 589 | - size = font_size[0]; | |
| 590 | - | |
| 591 | - for(f=0;font_size[f];f++) | |
| 592 | - { | |
| 593 | - cairo_set_font_size(cr,font_size[f]); | |
| 594 | - cairo_font_extents(cr,&extents); | |
| 595 | - | |
| 596 | - if(f == 0) | |
| 597 | - { | |
| 598 | - terminal->minimum_width = (cols * extents.max_x_advance); | |
| 599 | - terminal->minimum_height = ((rows+1) * (extents.height + extents.descent)) + (OIA_TOP_MARGIN+2); | |
| 600 | - } | |
| 601 | - | |
| 602 | - if( HEIGHT_IN_PIXELS(terminal,(extents.height+extents.descent)) < height && WIDTH_IN_PIXELS(terminal,extents.max_x_advance) < width ) | |
| 603 | - size = font_size[f]; | |
| 604 | - } | |
| 605 | - | |
| 606 | - cairo_set_font_size(cr,size); | |
| 607 | - | |
| 608 | - #if !GTK_CHECK_VERSION(3,0,0) | |
| 609 | - gtk_widget_set_size_request(GTK_WIDGET(terminal),terminal->minimum_width,terminal->minimum_height); | |
| 610 | - #endif // !GTK(3,0,0) | |
| 611 | - | |
| 612 | - } | |
| 613 | - | |
| 614 | - cairo_font_extents(cr,&extents); | |
| 615 | - | |
| 616 | - // Save scaled font for use on next drawings | |
| 617 | - if(terminal->font.scaled) | |
| 618 | - cairo_scaled_font_destroy(terminal->font.scaled); | |
| 619 | - | |
| 620 | - terminal->font.scaled = cairo_get_scaled_font(cr); | |
| 621 | - cairo_scaled_font_reference(terminal->font.scaled); | |
| 622 | - | |
| 623 | - cairo_scaled_font_extents(terminal->font.scaled,&extents); | |
| 624 | - | |
| 625 | - terminal->font.width = (int) extents.max_x_advance; | |
| 626 | - terminal->font.height = (int) extents.height; | |
| 627 | - terminal->font.ascent = (int) extents.ascent; | |
| 628 | - terminal->font.descent = (int) extents.descent; | |
| 629 | - | |
| 630 | - hFont = terminal->font.height + terminal->font.descent; | |
| 631 | - | |
| 632 | - // Create new cursor surface | |
| 633 | - if(terminal->cursor.surface) | |
| 634 | - cairo_surface_destroy(terminal->cursor.surface); | |
| 635 | - | |
| 636 | - terminal->cursor.surface = gdk_window_create_similar_surface(gtk_widget_get_window(GTK_WIDGET(terminal)),CAIRO_CONTENT_COLOR,terminal->font.width,hFont); | |
| 637 | - | |
| 638 | - // Center image | |
| 639 | - size = CONTENTS_WIDTH(terminal); | |
| 640 | - terminal->font.left = (width >> 1) - ((size) >> 1); | |
| 641 | - | |
| 642 | - terminal->font.spacing = height / (rows+2); | |
| 643 | - if((int) terminal->font.spacing < hFont) | |
| 644 | - terminal->font.spacing = hFont; | |
| 645 | - | |
| 646 | - size = CONTENTS_HEIGHT(terminal); | |
| 647 | - | |
| 648 | - terminal->font.top = (height >> 1) - (size >> 1); | |
| 649 | - | |
| 650 | -} | |
| 651 | - | |
| 652 | -static void set_timer(H3270 *session, unsigned char on) | |
| 653 | -{ | |
| 654 | - GtkWidget *widget = GTK_WIDGET(lib3270_get_user_data(session)); | |
| 655 | - | |
| 656 | - if(on) | |
| 657 | - v3270_start_timer(widget); | |
| 658 | - else | |
| 659 | - v3270_stop_timer(widget); | |
| 660 | - | |
| 661 | -} | |
| 662 | - | |
| 663 | -static void update_toggle(H3270 *session, LIB3270_TOGGLE ix, unsigned char value, G_GNUC_UNUSED LIB3270_TOGGLE_TYPE reason, const char *name) | |
| 664 | -{ | |
| 665 | - GtkWidget *widget = GTK_WIDGET(lib3270_get_user_data(session)); | |
| 666 | - | |
| 667 | - switch(ix) | |
| 668 | - { | |
| 669 | - case LIB3270_TOGGLE_CURSOR_POS: | |
| 670 | - case LIB3270_TOGGLE_MONOCASE: | |
| 671 | - case LIB3270_TOGGLE_LINE_WRAP: | |
| 672 | - case LIB3270_TOGGLE_CROSSHAIR: | |
| 673 | - case LIB3270_TOGGLE_BLANK_FILL: | |
| 674 | - case LIB3270_TOGGLE_MARGINED_PASTE: | |
| 675 | - case LIB3270_TOGGLE_SHOW_TIMING: | |
| 676 | - case LIB3270_TOGGLE_RECTANGLE_SELECT: | |
| 677 | - case LIB3270_TOGGLE_UNDERLINE: | |
| 678 | - case LIB3270_TOGGLE_VIEW_FIELD: | |
| 679 | - case LIB3270_TOGGLE_ALTSCREEN: | |
| 680 | - v3270_reload(widget); | |
| 681 | - gtk_widget_queue_draw(widget); | |
| 682 | - break; | |
| 683 | - | |
| 684 | - case LIB3270_TOGGLE_CURSOR_BLINK: | |
| 685 | - GTK_V3270(widget)->cursor.show |= 1; | |
| 686 | - break; | |
| 687 | - | |
| 688 | - case LIB3270_TOGGLE_INSERT: | |
| 689 | - v3270_draw_ins_status(GTK_V3270(widget)); | |
| 690 | - v3270_cursor_draw(GTK_V3270(widget)); | |
| 691 | - break; | |
| 692 | - | |
| 693 | - case LIB3270_TOGGLE_BOLD: | |
| 694 | - v3270_reload(widget); | |
| 695 | - gtk_widget_queue_draw(widget); | |
| 696 | - break; | |
| 697 | - | |
| 698 | - case LIB3270_TOGGLE_FULL_SCREEN: | |
| 699 | - if(value) | |
| 700 | - gtk_window_fullscreen(GTK_WINDOW(gtk_widget_get_toplevel(widget))); | |
| 701 | - else | |
| 702 | - gtk_window_unfullscreen(GTK_WINDOW(gtk_widget_get_toplevel(widget))); | |
| 703 | - | |
| 704 | - break; | |
| 705 | - | |
| 706 | - case LIB3270_TOGGLE_DS_TRACE: | |
| 707 | - case LIB3270_TOGGLE_SSL_TRACE: | |
| 708 | - case LIB3270_TOGGLE_SCREEN_TRACE: | |
| 709 | - case LIB3270_TOGGLE_EVENT_TRACE: | |
| 710 | - case LIB3270_TOGGLE_RECONNECT: | |
| 711 | - case LIB3270_TOGGLE_SMART_PASTE: | |
| 712 | - case LIB3270_TOGGLE_KEEP_SELECTED: | |
| 713 | - case LIB3270_TOGGLE_CONNECT_ON_STARTUP: | |
| 714 | - case LIB3270_TOGGLE_KP_ALTERNATIVE: | |
| 715 | - case LIB3270_TOGGLE_NETWORK_TRACE: | |
| 716 | - case LIB3270_TOGGLE_BEEP: | |
| 717 | - case LIB3270_TOGGLE_KEEP_ALIVE: | |
| 718 | - break; | |
| 719 | - | |
| 720 | - case LIB3270_TOGGLE_COUNT: | |
| 721 | - break; | |
| 722 | - | |
| 723 | - } | |
| 724 | - | |
| 725 | - g_object_notify_by_pspec(G_OBJECT(widget), v3270_properties.toggle[ix]); | |
| 726 | - g_signal_emit(widget, v3270_widget_signal[SIGNAL_TOGGLE_CHANGED], 0, (guint) ix, (gboolean) (value != 0), (gchar *) name); | |
| 727 | - | |
| 728 | -} | |
| 729 | - | |
| 730 | -static void bg_update_message(H3270 *session) | |
| 731 | -{ | |
| 732 | - void *widget = lib3270_get_user_data(session); | |
| 733 | - trace("-----A %s %p",__FUNCTION__, lib3270_get_user_data(session)); | |
| 734 | - | |
| 735 | - g_signal_emit( | |
| 736 | - GTK_WIDGET(widget), | |
| 737 | - v3270_widget_signal[SIGNAL_MESSAGE_CHANGED], | |
| 738 | - 0, | |
| 739 | - (gint) lib3270_get_program_message(session) | |
| 740 | - ); | |
| 741 | - | |
| 742 | - trace("-----B %s %p",__FUNCTION__, lib3270_get_user_data(session)); | |
| 743 | -} | |
| 744 | - | |
| 745 | -static void update_message(H3270 *session, G_GNUC_UNUSED LIB3270_MESSAGE id) | |
| 746 | -{ | |
| 747 | - g_idle_add((GSourceFunc) bg_update_message, session); | |
| 748 | -} | |
| 749 | - | |
| 750 | -static void update_luname(H3270 *session, const char *name) | |
| 751 | -{ | |
| 752 | - v3270_update_luname(GTK_WIDGET(lib3270_get_user_data(session)),name); | |
| 753 | -} | |
| 754 | - | |
| 755 | -struct select_cursor_data | |
| 756 | -{ | |
| 757 | - H3270 * hSession; | |
| 758 | - LIB3270_POINTER id; | |
| 759 | -}; | |
| 760 | - | |
| 761 | -static void bg_select_cursor(struct select_cursor_data *data) | |
| 762 | -{ | |
| 763 | - GtkWidget *widget = GTK_WIDGET(lib3270_get_user_data(data->hSession)); | |
| 764 | - | |
| 765 | -#if GTK_CHECK_VERSION(2,20,0) | |
| 766 | - if(gtk_widget_get_realized(widget) && gtk_widget_get_has_window(widget)) | |
| 767 | -#else | |
| 768 | - if(GTK_WIDGET_REALIZED(widget) && widget->window) | |
| 769 | -#endif // GTK(2,20) | |
| 770 | - { | |
| 771 | - GTK_V3270(widget)->pointer_id = data->id; | |
| 772 | - v3270_update_mouse_pointer(widget); | |
| 773 | - } | |
| 774 | -} | |
| 775 | - | |
| 776 | -static void select_cursor(H3270 *session, LIB3270_POINTER id) | |
| 777 | -{ | |
| 778 | - struct select_cursor_data *data = g_new0(struct select_cursor_data,1); | |
| 779 | - data->hSession = session; | |
| 780 | - data->id = id; | |
| 781 | - g_idle_add_full(G_PRIORITY_DEFAULT_IDLE,(GSourceFunc) bg_select_cursor, data, g_free); | |
| 782 | -} | |
| 783 | - | |
| 784 | -static void ctlr_done(H3270 *session) | |
| 785 | -{ | |
| 786 | - GtkWidget *widget = GTK_WIDGET(lib3270_get_user_data(session)); | |
| 787 | - | |
| 788 | -#if GTK_CHECK_VERSION(2,20,0) | |
| 789 | - if(gtk_widget_get_realized(widget) && gtk_widget_get_has_window(widget)) | |
| 790 | -#else | |
| 791 | - if(GTK_WIDGET_REALIZED(widget) && widget->window) | |
| 792 | -#endif // GTK(2,20) | |
| 793 | - { | |
| 794 | - v3270_update_mouse_pointer(widget); | |
| 795 | - } | |
| 796 | - | |
| 797 | -} | |
| 798 | - | |
| 799 | -static void update_connect(H3270 *session, unsigned char connected) | |
| 800 | -{ | |
| 801 | - v3270 *widget = GTK_V3270(lib3270_get_user_data(session)); | |
| 802 | - | |
| 803 | - if(connected) | |
| 804 | - { | |
| 805 | - widget->cursor.show |= 2; | |
| 806 | - g_signal_emit(GTK_WIDGET(widget), v3270_widget_signal[SIGNAL_CONNECTED], 0, lib3270_get_host(session)); | |
| 807 | - } | |
| 808 | - else | |
| 809 | - { | |
| 810 | - widget->cursor.show &= ~2; | |
| 811 | - g_signal_emit(GTK_WIDGET(widget), v3270_widget_signal[SIGNAL_DISCONNECTED], 0); | |
| 812 | - } | |
| 813 | - | |
| 814 | - if(v3270_properties.online) | |
| 815 | - g_object_notify_by_pspec(G_OBJECT(widget), v3270_properties.online); | |
| 816 | - | |
| 817 | - widget->activity.timestamp = time(0); | |
| 818 | - | |
| 819 | - gtk_widget_queue_draw(GTK_WIDGET(widget)); | |
| 820 | -} | |
| 821 | - | |
| 822 | -static void update_screen_size(H3270 *session, G_GNUC_UNUSED unsigned short rows, G_GNUC_UNUSED unsigned short cols) | |
| 823 | -{ | |
| 824 | - v3270_reload(GTK_WIDGET(lib3270_get_user_data(session))); | |
| 825 | - gtk_widget_queue_draw(GTK_WIDGET(lib3270_get_user_data(session))); | |
| 826 | -} | |
| 827 | - | |
| 828 | -static void update_model(H3270 *session, const char *name, int model, G_GNUC_UNUSED int rows, G_GNUC_UNUSED int cols) | |
| 829 | -{ | |
| 830 | - if(v3270_properties.model) | |
| 831 | - g_object_notify_by_pspec(G_OBJECT(lib3270_get_user_data(session)), v3270_properties.model); | |
| 832 | - | |
| 833 | - g_signal_emit(GTK_WIDGET(lib3270_get_user_data(session)),v3270_widget_signal[SIGNAL_MODEL_CHANGED], 0, (guint) model, name); | |
| 834 | -} | |
| 835 | - | |
| 836 | -static void changed(H3270 *session, int offset, int len) | |
| 837 | -{ | |
| 838 | - GtkWidget * widget = lib3270_get_user_data(session); | |
| 839 | - GtkAccessible * obj = GTK_V3270(widget)->accessible; | |
| 840 | - | |
| 841 | - if(obj) | |
| 842 | - { | |
| 843 | - // Get new text, notify atk | |
| 844 | - gsize bytes_written = 0; | |
| 845 | - char * text = lib3270_get_string_at_address(session,offset,len,'\n'); | |
| 846 | - | |
| 847 | - if(text) | |
| 848 | - { | |
| 849 | - GError * error = NULL; | |
| 850 | - gchar * utfchar = g_convert_with_fallback( text, | |
| 851 | - -1, | |
| 852 | - "UTF-8", | |
| 853 | - lib3270_get_display_charset(session), | |
| 854 | - " ", | |
| 855 | - NULL, | |
| 856 | - &bytes_written, | |
| 857 | - &error ); | |
| 858 | - | |
| 859 | - lib3270_free(text); | |
| 860 | - | |
| 861 | - if(error) | |
| 862 | - { | |
| 863 | - g_warning("%s failed: %s",__FUNCTION__,error->message); | |
| 864 | - g_error_free(error); | |
| 865 | - } | |
| 866 | - | |
| 867 | - if(utfchar) | |
| 868 | - { | |
| 869 | - g_signal_emit_by_name(obj, "text-insert", offset, bytes_written, utfchar); | |
| 870 | - g_free(utfchar); | |
| 871 | - } | |
| 872 | - | |
| 873 | - } | |
| 874 | - } | |
| 875 | - | |
| 876 | -#ifdef WIN32 | |
| 877 | - gtk_widget_queue_draw(widget); | |
| 878 | -#endif // WIN32 | |
| 879 | - | |
| 880 | - g_signal_emit(GTK_WIDGET(widget),v3270_widget_signal[SIGNAL_CHANGED], 0, (guint) offset, (guint) len); | |
| 881 | -} | |
| 882 | - | |
| 883 | -static void set_selection(H3270 *session, unsigned char status) | |
| 884 | -{ | |
| 885 | - GtkWidget * widget = GTK_WIDGET(lib3270_get_user_data(session)); | |
| 886 | - | |
| 887 | - if(v3270_properties.selection) | |
| 888 | - g_object_notify_by_pspec(G_OBJECT(widget), v3270_properties.selection); | |
| 889 | - | |
| 890 | - g_signal_emit(widget,v3270_widget_signal[SIGNAL_SELECTING], 0, status ? TRUE : FALSE); | |
| 891 | - | |
| 892 | -} | |
| 893 | - | |
| 894 | -static void update_selection(H3270 *session, G_GNUC_UNUSED int start, G_GNUC_UNUSED int end) | |
| 895 | -{ | |
| 896 | - // Selected region changed | |
| 897 | - GtkWidget * widget = GTK_WIDGET(lib3270_get_user_data(session)); | |
| 898 | - GtkAccessible * atk_obj = GTK_V3270(widget)->accessible; | |
| 899 | - | |
| 900 | - if(atk_obj) | |
| 901 | - g_signal_emit_by_name(atk_obj,"text-selection-changed"); | |
| 902 | - | |
| 903 | -} | |
| 904 | - | |
| 905 | -static void message(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *text) | |
| 906 | -{ | |
| 907 | - g_signal_emit( GTK_WIDGET(lib3270_get_user_data(session)), v3270_widget_signal[SIGNAL_MESSAGE], 0, | |
| 908 | - (int) id, | |
| 909 | - (gchar *) title, | |
| 910 | - (gchar *) message, | |
| 911 | - (gchar *) text ); | |
| 912 | - | |
| 913 | -} | |
| 914 | - | |
| 915 | 510 | static int emit_print_signal(H3270 *session) |
| 916 | 511 | { |
| 917 | 512 | g_signal_emit(GTK_WIDGET(lib3270_get_user_data(session)), v3270_widget_signal[SIGNAL_PRINT], 0); |
| ... | ... | @@ -922,7 +517,6 @@ static gboolean activity_tick(v3270 *widget) |
| 922 | 517 | { |
| 923 | 518 | if(widget->activity.disconnect && lib3270_is_connected(widget->host) && ((time(0) - widget->activity.timestamp)/60) >= widget->activity.disconnect) |
| 924 | 519 | lib3270_disconnect(widget->host); |
| 925 | - | |
| 926 | 520 | return TRUE; |
| 927 | 521 | } |
| 928 | 522 | |
| ... | ... | @@ -931,106 +525,14 @@ static void release_activity_timer(v3270 *widget) |
| 931 | 525 | widget->activity.timer = NULL; |
| 932 | 526 | } |
| 933 | 527 | |
| 934 | -static void popup_handler(H3270 *session, LIB3270_NOTIFY type, const char *title, const char *msg, const char *fmt, va_list args) | |
| 528 | +static void v3270_init(v3270 *widget) | |
| 935 | 529 | { |
| 936 | - GtkWidget *terminal = (GtkWidget *) lib3270_get_user_data(session); | |
| 937 | - | |
| 938 | - if(terminal && GTK_IS_V3270(terminal)) { | |
| 939 | - | |
| 940 | - if(fmt) | |
| 941 | - { | |
| 942 | - gchar *text = g_strdup_vprintf(fmt,args); | |
| 943 | - v3270_popup_message(GTK_WIDGET(terminal),type,title,msg,text); | |
| 944 | - g_free(text); | |
| 945 | - } | |
| 946 | - else | |
| 947 | - { | |
| 948 | - v3270_popup_message(GTK_WIDGET(terminal),type,title,msg,NULL); | |
| 949 | - } | |
| 950 | - | |
| 951 | - } | |
| 952 | - | |
| 953 | - } | |
| 954 | - | |
| 955 | - static gboolean bg_update_ssl(H3270 *session) | |
| 956 | - { | |
| 957 | - trace("%s",__FUNCTION__); | |
| 958 | - | |
| 959 | - v3270_blink_ssl(GTK_V3270(lib3270_get_user_data(session))); | |
| 960 | - | |
| 961 | - if(lib3270_get_secure(session) == LIB3270_SSL_NEGOTIATING) | |
| 962 | - v3270_start_blinking(GTK_WIDGET(lib3270_get_user_data(session))); | |
| 963 | - | |
| 964 | - return FALSE; | |
| 965 | - } | |
| 966 | - | |
| 967 | - static void update_ssl(H3270 *session, G_GNUC_UNUSED LIB3270_SSL_STATE state) | |
| 968 | - { | |
| 969 | - g_idle_add((GSourceFunc) bg_update_ssl, session); | |
| 970 | - } | |
| 971 | - | |
| 972 | - const gchar * v3270_default_font = "monospace"; | |
| 973 | - | |
| 974 | - struct update_oia_data | |
| 975 | - { | |
| 976 | - H3270 *session; | |
| 977 | - LIB3270_FLAG id; | |
| 978 | - unsigned char on; | |
| 979 | - }; | |
| 980 | - | |
| 981 | - static gboolean bg_update_oia(struct update_oia_data *data) | |
| 982 | - { | |
| 983 | - v3270_update_oia(GTK_V3270(lib3270_get_user_data(data->session)), data->id, data->on); | |
| 984 | - return FALSE; | |
| 985 | - } | |
| 986 | - | |
| 987 | - static void update_oia(H3270 *session, LIB3270_FLAG id, unsigned char on) | |
| 988 | - { | |
| 989 | - struct update_oia_data *data = g_new0(struct update_oia_data,1); | |
| 990 | - data->session = session; | |
| 991 | - data->id = id; | |
| 992 | - data->on = on; | |
| 993 | - g_idle_add_full(G_PRIORITY_DEFAULT_IDLE,(GSourceFunc) bg_update_oia, data, g_free); | |
| 994 | - } | |
| 995 | - | |
| 996 | - static void v3270_init(v3270 *widget) | |
| 997 | - { | |
| 998 | - struct lib3270_session_callbacks *cbk; | |
| 999 | 530 | |
| 1000 | 531 | widget->host = lib3270_session_new(""); |
| 1001 | - | |
| 1002 | 532 | lib3270_set_user_data(widget->host,widget); |
| 1003 | - lib3270_set_popup_handler(widget->host, popup_handler); | |
| 1004 | - | |
| 1005 | - cbk = lib3270_get_session_callbacks(widget->host,sizeof(struct lib3270_session_callbacks)); | |
| 1006 | - if(!cbk) | |
| 1007 | - { | |
| 1008 | - g_error( _( "Invalid callback table, possible version mismatch in lib3270") ); | |
| 1009 | - return; | |
| 1010 | - } | |
| 1011 | - | |
| 1012 | 533 | |
| 1013 | - cbk->update = v3270_update_char; | |
| 1014 | - cbk->changed = changed; | |
| 1015 | - cbk->set_timer = set_timer; | |
| 1016 | - | |
| 1017 | - cbk->set_selection = set_selection; | |
| 1018 | - cbk->update_selection = update_selection; | |
| 1019 | - | |
| 1020 | - cbk->update_luname = update_luname; | |
| 1021 | - cbk->configure = update_screen_size; | |
| 1022 | - cbk->update_status = update_message; | |
| 1023 | - cbk->update_cursor = v3270_update_cursor; | |
| 1024 | - cbk->update_toggle = update_toggle; | |
| 1025 | - cbk->update_oia = update_oia; | |
| 1026 | - cbk->cursor = select_cursor; | |
| 1027 | - cbk->update_connect = update_connect; | |
| 1028 | - cbk->update_model = update_model; | |
| 1029 | - cbk->changed = changed; | |
| 1030 | - cbk->ctlr_done = ctlr_done; | |
| 1031 | - cbk->message = message; | |
| 1032 | - cbk->update_ssl = update_ssl; | |
| 1033 | - cbk->print = emit_print_signal; | |
| 534 | + // Install callbacks | |
| 535 | + v3270_install_callbacks(widget); | |
| 1034 | 536 | |
| 1035 | 537 | // Reset timer |
| 1036 | 538 | widget->activity.timestamp = time(0); |
| ... | ... | @@ -1365,192 +867,6 @@ static void v3270_send_configure(v3270 * terminal) |
| 1365 | 867 | gdk_event_free(event); |
| 1366 | 868 | } |
| 1367 | 869 | |
| 1368 | -const gchar * v3270_default_colors = | |
| 1369 | - "#000000," // V3270_COLOR_BACKGROUND | |
| 1370 | - "#7890F0," // V3270_COLOR_BLUE | |
| 1371 | - "#FF0000," // V3270_COLOR_RED | |
| 1372 | - "#FF00FF," // V3270_COLOR_PINK | |
| 1373 | - "#00FF00," // V3270_COLOR_GREEN | |
| 1374 | - "#00FFFF," // V3270_COLOR_TURQUOISE | |
| 1375 | - "#FFFF00," // V3270_COLOR_YELLOW | |
| 1376 | - "#FFFFFF," // V3270_COLOR_WHITE | |
| 1377 | - "#000000," // V3270_COLOR_BLACK | |
| 1378 | - "#000080," // V3270_COLOR_DARK_BLUE | |
| 1379 | - "#FFA200," // V3270_COLOR_ORANGE | |
| 1380 | - "#800080," // V3270_COLOR_PURPLE | |
| 1381 | - "#008000," // V3270_COLOR_DARK_GREEN | |
| 1382 | - "#008080," // V3270_COLOR_DARK_TURQUOISE | |
| 1383 | - "#A0A000," // V3270_COLOR_MUSTARD | |
| 1384 | - "#C0C0C0," // V3270_COLOR_GRAY | |
| 1385 | - | |
| 1386 | - "#00FF00," // V3270_COLOR_FIELD_DEFAULT | |
| 1387 | - "#FF0000," // V3270_COLOR_FIELD_INTENSIFIED | |
| 1388 | - "#00FFFF," // V3270_COLOR_FIELD_PROTECTED | |
| 1389 | - "#FFFFFF," // V3270_COLOR_FIELD_PROTECTED_INTENSIFIED | |
| 1390 | - | |
| 1391 | - "#404040," // V3270_COLOR_SELECTED_BG | |
| 1392 | - "#FFFFFF," // V3270_COLOR_SELECTED_FG, | |
| 1393 | - | |
| 1394 | - "#00FF00," // V3270_COLOR_CROSS_HAIR | |
| 1395 | - | |
| 1396 | - "#000000," // V3270_COLOR_OIA_BACKGROUND | |
| 1397 | - "#00FF00," // V3270_COLOR_OIA | |
| 1398 | - "#7890F0," // V3270_COLOR_OIA_SEPARATOR | |
| 1399 | - "#FFFFFF," // V3270_COLOR_OIA_STATUS_OK | |
| 1400 | - "#FFFF00," // V3270_COLOR_OIA_STATUS_WARNING | |
| 1401 | - "#FF0000"; // V3270_COLOR_OIA_STATUS_INVALID | |
| 1402 | - | |
| 1403 | - | |
| 1404 | - | |
| 1405 | -void v3270_set_colors(GtkWidget *widget, const gchar *colors) | |
| 1406 | -{ | |
| 1407 | - g_return_if_fail(GTK_IS_V3270(widget)); | |
| 1408 | - | |
| 1409 | - if(!colors) | |
| 1410 | - { | |
| 1411 | - colors = v3270_default_colors; | |
| 1412 | - } | |
| 1413 | - | |
| 1414 | - v3270_set_color_table(GTK_V3270(widget)->color,colors); | |
| 1415 | - g_signal_emit(widget,v3270_widget_signal[SIGNAL_UPDATE_CONFIG], 0, "colors", colors); | |
| 1416 | - v3270_reload(widget); | |
| 1417 | - | |
| 1418 | -} | |
| 1419 | - | |
| 1420 | -void v3270_set_color(GtkWidget *widget, enum V3270_COLOR id, GdkRGBA *color) | |
| 1421 | -{ | |
| 1422 | - g_return_if_fail(GTK_IS_V3270(widget)); | |
| 1423 | - | |
| 1424 | - GTK_V3270(widget)->color[id] = *color; | |
| 1425 | - | |
| 1426 | -#if !GTK_CHECK_VERSION(3,0,0) | |
| 1427 | - gdk_colormap_alloc_color(gtk_widget_get_default_colormap(),color,TRUE,TRUE); | |
| 1428 | -#endif // !GTK(3,0,0) | |
| 1429 | - | |
| 1430 | -} | |
| 1431 | -GdkRGBA * v3270_get_color(GtkWidget *widget, enum V3270_COLOR id) | |
| 1432 | -{ | |
| 1433 | - g_return_val_if_fail(GTK_IS_V3270(widget),NULL); | |
| 1434 | - return GTK_V3270(widget)->color+id; | |
| 1435 | -} | |
| 1436 | - | |
| 1437 | -const GdkRGBA * v3270_get_color_table(GtkWidget *widget) | |
| 1438 | -{ | |
| 1439 | - g_return_val_if_fail(GTK_IS_V3270(widget),NULL); | |
| 1440 | - return GTK_V3270(widget)->color; | |
| 1441 | -} | |
| 1442 | - | |
| 1443 | -void v3270_set_mono_color_table(GdkRGBA *clr, const gchar *fg, const gchar *bg) | |
| 1444 | -{ | |
| 1445 | - int f; | |
| 1446 | - | |
| 1447 | - gdk_rgba_parse(clr,bg); | |
| 1448 | - gdk_rgba_parse(clr+1,fg); | |
| 1449 | - | |
| 1450 | - for(f=2;f<V3270_COLOR_COUNT;f++) | |
| 1451 | - clr[f] = clr[1]; | |
| 1452 | - | |
| 1453 | - clr[V3270_COLOR_BLACK] = *clr; | |
| 1454 | - clr[V3270_COLOR_OIA_BACKGROUND] = *clr; | |
| 1455 | - clr[V3270_COLOR_SELECTED_BG] = clr[V3270_COLOR_WHITE]; | |
| 1456 | - clr[V3270_COLOR_SELECTED_FG] = clr[V3270_COLOR_BLACK]; | |
| 1457 | - | |
| 1458 | - | |
| 1459 | -} | |
| 1460 | - | |
| 1461 | -void v3270_set_color_table(GdkRGBA *table, const gchar *colors) | |
| 1462 | -{ | |
| 1463 | - gchar **clr; | |
| 1464 | - guint cnt; | |
| 1465 | - guint f; | |
| 1466 | - | |
| 1467 | - if(strchr(colors,':')) | |
| 1468 | - clr = g_strsplit(colors,":",V3270_COLOR_COUNT+1); | |
| 1469 | - else if(strchr(colors,';')) | |
| 1470 | - clr = g_strsplit(colors,";",V3270_COLOR_COUNT+1); | |
| 1471 | - else | |
| 1472 | - clr = g_strsplit(colors,",",V3270_COLOR_COUNT+1); | |
| 1473 | - | |
| 1474 | - cnt = g_strv_length(clr); | |
| 1475 | - | |
| 1476 | - switch(cnt) | |
| 1477 | - { | |
| 1478 | - case 28: // Version 4 string | |
| 1479 | - for(f=0;f < 28;f++) | |
| 1480 | - gdk_rgba_parse(table+f,clr[f]); | |
| 1481 | - table[V3270_COLOR_OIA_STATUS_INVALID] = table[V3270_COLOR_OIA_STATUS_WARNING]; | |
| 1482 | - break; | |
| 1483 | - | |
| 1484 | - case V3270_COLOR_COUNT: // Complete string | |
| 1485 | - for(f=0;f < V3270_COLOR_COUNT;f++) | |
| 1486 | - gdk_rgba_parse(table+f,clr[f]); | |
| 1487 | - break; | |
| 1488 | - | |
| 1489 | - default: | |
| 1490 | - | |
| 1491 | - g_warning("Color table has %d elements; should be %d.",cnt,V3270_COLOR_COUNT); | |
| 1492 | - | |
| 1493 | - if(cnt < V3270_COLOR_COUNT) | |
| 1494 | - { | |
| 1495 | - // Less than the required | |
| 1496 | - for(f=0;f < cnt;f++) | |
| 1497 | - gdk_rgba_parse(table+f,clr[f]); | |
| 1498 | - | |
| 1499 | - for(f=cnt; f < V3270_COLOR_COUNT;f++) | |
| 1500 | - gdk_rgba_parse(table+f,clr[cnt-1]); | |
| 1501 | - | |
| 1502 | - clr[V3270_COLOR_OIA_BACKGROUND] = clr[0]; | |
| 1503 | - clr[V3270_COLOR_SELECTED_BG] = clr[0]; | |
| 1504 | - } | |
| 1505 | - else | |
| 1506 | - { | |
| 1507 | - // More than required | |
| 1508 | - for(f=0;f < V3270_COLOR_COUNT;f++) | |
| 1509 | - gdk_rgba_parse(table+f,clr[f]); | |
| 1510 | - } | |
| 1511 | - } | |
| 1512 | - | |
| 1513 | - g_strfreev(clr); | |
| 1514 | - | |
| 1515 | -} | |
| 1516 | - | |
| 1517 | -LIB3270_EXPORT void v3270_set_font_family(GtkWidget *widget, const gchar *name) | |
| 1518 | -{ | |
| 1519 | - v3270 * terminal; | |
| 1520 | - | |
| 1521 | - g_return_if_fail(GTK_IS_V3270(widget)); | |
| 1522 | - | |
| 1523 | - terminal = GTK_V3270(widget); | |
| 1524 | - | |
| 1525 | - if(!name) | |
| 1526 | - { | |
| 1527 | - name = v3270_default_font; | |
| 1528 | - } | |
| 1529 | - | |
| 1530 | - if(g_ascii_strcasecmp(terminal->font.family,name)) | |
| 1531 | - { | |
| 1532 | - // Font has changed, update it | |
| 1533 | - g_free(terminal->font.family); | |
| 1534 | - | |
| 1535 | - terminal->font.family = g_strdup(name); | |
| 1536 | - terminal->font.weight = lib3270_get_toggle(terminal->host,LIB3270_TOGGLE_BOLD) ? CAIRO_FONT_WEIGHT_BOLD : CAIRO_FONT_WEIGHT_NORMAL; | |
| 1537 | - | |
| 1538 | - g_signal_emit(widget,v3270_widget_signal[SIGNAL_UPDATE_CONFIG], 0, "font-family", name); | |
| 1539 | - | |
| 1540 | - v3270_reload(widget); | |
| 1541 | - gtk_widget_queue_draw(widget); | |
| 1542 | - | |
| 1543 | - } | |
| 1544 | - | |
| 1545 | - | |
| 1546 | -} | |
| 1547 | - | |
| 1548 | -LIB3270_EXPORT const gchar * v3270_get_font_family(GtkWidget *widget) | |
| 1549 | -{ | |
| 1550 | - g_return_val_if_fail(GTK_IS_V3270(widget),NULL); | |
| 1551 | - return GTK_V3270(widget)->font.family; | |
| 1552 | -} | |
| 1553 | - | |
| 1554 | 870 | LIB3270_EXPORT void v3270_disconnect(GtkWidget *widget) |
| 1555 | 871 | { |
| 1556 | 872 | g_return_if_fail(GTK_IS_V3270(widget)); |
| ... | ... | @@ -1624,47 +940,11 @@ const GtkWidgetClass * v3270_get_parent_class(void) |
| 1624 | 940 | return GTK_WIDGET_CLASS(v3270_parent_class); |
| 1625 | 941 | } |
| 1626 | 942 | |
| 1627 | -static AtkObject * v3270_get_accessible(GtkWidget * widget) | |
| 1628 | -{ | |
| 1629 | - v3270 * terminal = GTK_V3270(widget); | |
| 1630 | - | |
| 1631 | - if(!terminal->accessible) | |
| 1632 | - { | |
| 1633 | - terminal->accessible = g_object_new(GTK_TYPE_V3270_ACCESSIBLE,NULL); | |
| 1634 | - atk_object_initialize(ATK_OBJECT(terminal->accessible), widget); | |
| 1635 | - gtk_accessible_set_widget(GTK_ACCESSIBLE(terminal->accessible),widget); | |
| 1636 | - g_object_ref(terminal->accessible); | |
| 1637 | - } | |
| 1638 | - | |
| 1639 | - return ATK_OBJECT(terminal->accessible); | |
| 1640 | -} | |
| 1641 | - | |
| 1642 | 943 | GtkIMContext * v3270_get_im_context(GtkWidget *widget) |
| 1643 | 944 | { |
| 1644 | 945 | return GTK_V3270(widget)->input_method; |
| 1645 | 946 | } |
| 1646 | 947 | |
| 1647 | -LIB3270_EXPORT gboolean v3270_get_toggle(GtkWidget *widget, LIB3270_TOGGLE ix) | |
| 1648 | -{ | |
| 1649 | - g_return_val_if_fail(GTK_IS_V3270(widget),FALSE); | |
| 1650 | - | |
| 1651 | - if(ix < LIB3270_TOGGLE_COUNT) | |
| 1652 | - return lib3270_get_toggle(GTK_V3270(widget)->host,ix) ? TRUE : FALSE; | |
| 1653 | - | |
| 1654 | - return FALSE; | |
| 1655 | -} | |
| 1656 | - | |
| 1657 | -LIB3270_EXPORT gboolean v3270_set_toggle(GtkWidget *widget, LIB3270_TOGGLE ix, gboolean state) | |
| 1658 | -{ | |
| 1659 | - g_return_val_if_fail(GTK_IS_V3270(widget),FALSE); | |
| 1660 | - | |
| 1661 | - if(ix < LIB3270_TOGGLE_COUNT) | |
| 1662 | - return lib3270_set_toggle(GTK_V3270(widget)->host,ix,state ? 1 : 0) ? TRUE : FALSE; | |
| 1663 | - | |
| 1664 | - return FALSE; | |
| 1665 | - | |
| 1666 | -} | |
| 1667 | - | |
| 1668 | 948 | /** |
| 1669 | 949 | * v3270_set_url: |
| 1670 | 950 | * |
| ... | ... | @@ -1706,14 +986,6 @@ LIB3270_EXPORT const gchar * v3270_get_session_name(GtkWidget *widget) |
| 1706 | 986 | return GTK_V3270(widget)->session_name; |
| 1707 | 987 | } |
| 1708 | 988 | |
| 1709 | -void v3270_set_scaled_fonts(GtkWidget *widget, gboolean on) | |
| 1710 | -{ | |
| 1711 | - g_return_if_fail(GTK_IS_V3270(widget)); | |
| 1712 | - | |
| 1713 | - GTK_V3270(widget)->scaled_fonts = on ? 1 : 0; | |
| 1714 | - | |
| 1715 | -} | |
| 1716 | - | |
| 1717 | 989 | LIB3270_EXPORT void v3270_set_session_name(GtkWidget *widget, const gchar *name) |
| 1718 | 990 | { |
| 1719 | 991 | g_return_if_fail(GTK_IS_V3270(widget)); |
| ... | ... | @@ -1737,19 +1009,6 @@ LIB3270_EXPORT int v3270_set_host_type_by_name(GtkWidget *widget, const char *na |
| 1737 | 1009 | return lib3270_set_host_type_by_name(GTK_V3270(widget)->host,name); |
| 1738 | 1010 | } |
| 1739 | 1011 | |
| 1740 | -LIB3270_EXPORT int v3270_set_session_color_type(GtkWidget *widget, unsigned short colortype) | |
| 1741 | -{ | |
| 1742 | - g_return_val_if_fail(GTK_IS_V3270(widget),EINVAL); | |
| 1743 | - return lib3270_set_color_type(GTK_V3270(widget)->host,colortype); | |
| 1744 | -} | |
| 1745 | - | |
| 1746 | - | |
| 1747 | -LIB3270_EXPORT unsigned short v3270_get_session_color_type(GtkWidget *widget) | |
| 1748 | -{ | |
| 1749 | - g_return_val_if_fail(GTK_IS_V3270(widget),-1); | |
| 1750 | - return lib3270_get_color_type(GTK_V3270(widget)->host); | |
| 1751 | -} | |
| 1752 | - | |
| 1753 | 1012 | LIB3270_EXPORT gboolean v3270_is_connected(GtkWidget *widget) |
| 1754 | 1013 | { |
| 1755 | 1014 | g_return_val_if_fail(GTK_IS_V3270(widget),FALSE); |
| ... | ... | @@ -1762,6 +1021,7 @@ LIB3270_EXPORT int v3270_set_host_charset(GtkWidget *widget, const gchar *name) |
| 1762 | 1021 | return lib3270_set_host_charset(GTK_V3270(widget)->host,name); |
| 1763 | 1022 | } |
| 1764 | 1023 | |
| 1024 | +/* | |
| 1765 | 1025 | GtkWidget * v3270_get_default_widget(void) |
| 1766 | 1026 | { |
| 1767 | 1027 | H3270 * hSession = lib3270_get_default_session_handle(); |
| ... | ... | @@ -1782,18 +1042,5 @@ GtkWidget * v3270_get_default_widget(void) |
| 1782 | 1042 | |
| 1783 | 1043 | return GTK_WIDGET(widget); |
| 1784 | 1044 | } |
| 1045 | +*/ | |
| 1785 | 1046 | |
| 1786 | -void v3270_disable_updates(GtkWidget *widget) | |
| 1787 | -{ | |
| 1788 | - GTK_V3270(widget)->drawing = 0; | |
| 1789 | -} | |
| 1790 | - | |
| 1791 | -void v3270_enable_updates(GtkWidget *widget) | |
| 1792 | -{ | |
| 1793 | - if(gtk_widget_get_realized(widget)) | |
| 1794 | - { | |
| 1795 | - GTK_V3270(widget)->drawing = 1; | |
| 1796 | - v3270_reload(widget); | |
| 1797 | - gtk_widget_queue_draw(widget); | |
| 1798 | - } | |
| 1799 | -} | ... | ... |