Commit 177484324918f54b54a911683bf7e49c1016e91c
1 parent
2ba14c1f
Exists in
master
and in
1 other branch
Adding button bar to allow enable/disable of the trace options in the
trace widget.
Showing
1 changed file
with
109 additions
and
0 deletions
Show diff stats
| @@ -0,0 +1,109 @@ | @@ -0,0 +1,109 @@ | ||
| 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 <internals.h> | ||
| 31 | + #include <lib3270.h> | ||
| 32 | + | ||
| 33 | + /*--[ Widget definition ]----------------------------------------------------------------------------*/ | ||
| 34 | + | ||
| 35 | + struct _V3270ToggleButtonClass | ||
| 36 | + { | ||
| 37 | + GtkToggleButtonClass parent_class; | ||
| 38 | + | ||
| 39 | + }; | ||
| 40 | + | ||
| 41 | + struct _V3270ToggleButton | ||
| 42 | + { | ||
| 43 | + GtkToggleButton parent; | ||
| 44 | + | ||
| 45 | + H3270 * hSession; | ||
| 46 | + LIB3270_TOGGLE id; | ||
| 47 | + | ||
| 48 | + }; | ||
| 49 | + | ||
| 50 | + G_DEFINE_TYPE(V3270ToggleButton, V3270ToggleButton, GTK_TYPE_TOGGLE_BUTTON); | ||
| 51 | + | ||
| 52 | +/*--[ Implement ]------------------------------------------------------------------------------------*/ | ||
| 53 | + | ||
| 54 | + static void dispose(GObject *object) | ||
| 55 | + { | ||
| 56 | + debug("%s",__FUNCTION__); | ||
| 57 | + | ||
| 58 | + V3270ToggleButton * widget = GTK_V3270_TOGGLE_BUTTON(object); | ||
| 59 | + | ||
| 60 | + G_OBJECT_CLASS(V3270ToggleButton_parent_class)->dispose(object); | ||
| 61 | + | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + static void toggled(GtkToggleButton *toggle_button) | ||
| 65 | + { | ||
| 66 | + V3270ToggleButton * widget = GTK_V3270_TOGGLE_BUTTON(toggle_button); | ||
| 67 | + | ||
| 68 | + int rc = lib3270_set_toggle(widget->hSession, widget->id, gtk_toggle_button_get_active(toggle_button) ? 1 : 0); | ||
| 69 | + | ||
| 70 | + if(rc < 0) | ||
| 71 | + { | ||
| 72 | + gtk_widget_set_sensitive(GTK_WIDGET(toggle_button),FALSE); | ||
| 73 | + g_warning("Can't set toggle button: %s",strerror(errno)); | ||
| 74 | + return; | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + if(rc) | ||
| 78 | + gtk_toggle_button_toggled(toggle_button); | ||
| 79 | + | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + static void V3270ToggleButton_class_init(G_GNUC_UNUSED V3270ToggleButtonClass *klass) | ||
| 83 | + { | ||
| 84 | + GTK_TOGGLE_BUTTON_CLASS(klass)->toggled = toggled; | ||
| 85 | + G_OBJECT_CLASS(klass)->dispose = dispose; | ||
| 86 | + | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + static void V3270ToggleButton_init(V3270ToggleButton *widget) | ||
| 90 | + { | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + GtkWidget * v3270_toggle_button_new(GtkWidget *terminal, LIB3270_TOGGLE toggle) | ||
| 94 | + { | ||
| 95 | + g_return_val_if_fail(GTK_IS_V3270(terminal),NULL); | ||
| 96 | + | ||
| 97 | + V3270ToggleButton * widget = GTK_V3270_TOGGLE_BUTTON(g_object_new(GTK_TYPE_V3270_TOGGLE_BUTTON, NULL)); | ||
| 98 | + | ||
| 99 | + widget->hSession = v3270_get_session(terminal); | ||
| 100 | + widget->id = toggle; | ||
| 101 | + | ||
| 102 | + gtk_widget_set_name(GTK_WIDGET(widget),lib3270_get_toggle_name(toggle)); | ||
| 103 | + gtk_button_set_label(GTK_BUTTON(widget),gettext(lib3270_get_toggle_label(toggle))); | ||
| 104 | + gtk_widget_set_tooltip_text(GTK_WIDGET(widget),gettext(lib3270_get_toggle_description(toggle))); | ||
| 105 | + | ||
| 106 | + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget),lib3270_get_toggle(widget->hSession, widget->id)); | ||
| 107 | + | ||
| 108 | + return GTK_WIDGET(widget); | ||
| 109 | + } |