Commit 380165330446cc486993c13cd17a009a7c1e2dea
1 parent
7cc16f51
Exists in
master
and in
4 other branches
Fixing PF/PA actions.
Showing
36 changed files
with
2184 additions
and
2165 deletions
Show diff stats
src/actions/abstract.c
| ... | ... | @@ -1,411 +0,0 @@ |
| 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 "private.h" | |
| 31 | - #include <v3270.h> | |
| 32 | - | |
| 33 | - static void pw3270_action_iface_init(GActionInterface *iface); | |
| 34 | - static void pw3270Action_class_init(pw3270ActionClass *klass); | |
| 35 | - static void pw3270Action_init(pw3270Action *action); | |
| 36 | - static void pw3270_action_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); | |
| 37 | - static void pw3270_action_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); | |
| 38 | - static void pw3270_action_set_state(GAction *action, GVariant *value); | |
| 39 | - static gboolean pw3270_action_get_enabled(GAction *action); | |
| 40 | - static void pw3270_action_activate(GAction *action, GVariant *parameter); | |
| 41 | - | |
| 42 | - static gboolean get_enabled(GAction *action, GtkWidget *terminal); | |
| 43 | - static void activate(GAction *action, GVariant *parameter, GtkWidget *terminal); | |
| 44 | - static void change_widget(GAction *action, GtkWidget *from, GtkWidget *to); | |
| 45 | - | |
| 46 | - static void finalize(GObject *object); | |
| 47 | - | |
| 48 | - static const GVariantType * pw3270_action_get_state_type(GAction *action); | |
| 49 | - static GVariant * pw3270_action_get_state_property(GAction *action); | |
| 50 | - static const GVariantType * pw3270_action_get_parameter_type(GAction *action); | |
| 51 | - static GVariant * pw3270_action_get_state_hint(GAction *action); | |
| 52 | - static void pw3270_action_change_state(GAction *action, GVariant *value); | |
| 53 | - | |
| 54 | - enum { | |
| 55 | - PROP_NONE, | |
| 56 | - PROP_NAME, | |
| 57 | - PROP_PARAMETER_TYPE, | |
| 58 | - PROP_ENABLED, | |
| 59 | - PROP_STATE_TYPE, | |
| 60 | - PROP_STATE | |
| 61 | - }; | |
| 62 | - | |
| 63 | - enum { | |
| 64 | - SIGNAL_CHANGE_STATE, | |
| 65 | - NR_SIGNALS | |
| 66 | - }; | |
| 67 | - | |
| 68 | - static guint action_signals[NR_SIGNALS]; | |
| 69 | - | |
| 70 | - G_DEFINE_TYPE_WITH_CODE(pw3270Action, pw3270Action, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE(G_TYPE_ACTION, pw3270_action_iface_init)) | |
| 71 | - | |
| 72 | - void pw3270_action_iface_init(GActionInterface *iface) { | |
| 73 | - iface->get_name = pw3270_action_get_name; | |
| 74 | - iface->get_parameter_type = pw3270_action_get_parameter_type; | |
| 75 | - iface->get_state_type = pw3270_action_get_state_type; | |
| 76 | - iface->get_state_hint = pw3270_action_get_state_hint; | |
| 77 | - iface->get_enabled = pw3270_action_get_enabled; | |
| 78 | - iface->get_state = pw3270_action_get_state_property; | |
| 79 | - iface->change_state = pw3270_action_change_state; | |
| 80 | - iface->activate = pw3270_action_activate; | |
| 81 | - } | |
| 82 | - | |
| 83 | - static const GVariantType * get_parameter_type(GAction G_GNUC_UNUSED(*action)) | |
| 84 | - { | |
| 85 | - return NULL; | |
| 86 | - } | |
| 87 | - | |
| 88 | - void pw3270Action_class_init(pw3270ActionClass *klass) { | |
| 89 | - | |
| 90 | - GObjectClass *object_class = G_OBJECT_CLASS(klass); | |
| 91 | - | |
| 92 | - klass->change_widget = change_widget; | |
| 93 | - klass->get_enabled = get_enabled; | |
| 94 | - klass->activate = activate; | |
| 95 | - klass->get_parameter_type = get_parameter_type; | |
| 96 | - | |
| 97 | - object_class->finalize = finalize; | |
| 98 | - object_class->set_property = pw3270_action_set_property; | |
| 99 | - object_class->get_property = pw3270_action_get_property; | |
| 100 | - | |
| 101 | - // Install properties | |
| 102 | - g_object_class_install_property(object_class, PROP_NAME, | |
| 103 | - g_param_spec_string ("name", | |
| 104 | - N_("Action Name"), | |
| 105 | - N_("The name used to invoke the action"), | |
| 106 | - NULL, | |
| 107 | - G_PARAM_READWRITE | | |
| 108 | - G_PARAM_CONSTRUCT_ONLY | | |
| 109 | - G_PARAM_STATIC_STRINGS)); | |
| 110 | - | |
| 111 | - g_object_class_install_property (object_class, PROP_PARAMETER_TYPE, | |
| 112 | - g_param_spec_boxed ("parameter-type", | |
| 113 | - N_("Parameter Type"), | |
| 114 | - N_("The type of GVariant passed to activate()"), | |
| 115 | - G_TYPE_VARIANT_TYPE, | |
| 116 | - G_PARAM_READWRITE | | |
| 117 | - G_PARAM_CONSTRUCT_ONLY | | |
| 118 | - G_PARAM_STATIC_STRINGS)); | |
| 119 | - | |
| 120 | - g_object_class_install_property (object_class, PROP_STATE_TYPE, | |
| 121 | - g_param_spec_boxed ("state-type", | |
| 122 | - N_("State Type"), | |
| 123 | - N_("The type of the state kept by the action"), | |
| 124 | - G_TYPE_VARIANT_TYPE, | |
| 125 | - G_PARAM_READABLE | | |
| 126 | - G_PARAM_STATIC_STRINGS)); | |
| 127 | - | |
| 128 | - // Enabled property | |
| 129 | - klass->properties.enabled = | |
| 130 | - g_param_spec_boolean( | |
| 131 | - "enabled", | |
| 132 | - N_("Enabled"), | |
| 133 | - N_("If the action can be activated"), | |
| 134 | - TRUE, | |
| 135 | - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | |
| 136 | - ); | |
| 137 | - | |
| 138 | - g_object_class_install_property(object_class, PROP_ENABLED, klass->properties.enabled); | |
| 139 | - | |
| 140 | - // State property | |
| 141 | - klass->properties.state = | |
| 142 | - g_param_spec_variant( | |
| 143 | - "state", | |
| 144 | - N_("State"), | |
| 145 | - N_("The state the action is in"), | |
| 146 | - G_VARIANT_TYPE_ANY, | |
| 147 | - NULL, | |
| 148 | - G_PARAM_READWRITE | G_PARAM_CONSTRUCT | | |
| 149 | - G_PARAM_STATIC_STRINGS | |
| 150 | - ); | |
| 151 | - | |
| 152 | - g_object_class_install_property (object_class, PROP_STATE, klass->properties.state); | |
| 153 | - | |
| 154 | - // Install signals | |
| 155 | - action_signals[SIGNAL_CHANGE_STATE] = | |
| 156 | - g_signal_new( | |
| 157 | - I_("change-state"), | |
| 158 | - G_TYPE_SIMPLE_ACTION, | |
| 159 | - G_SIGNAL_RUN_LAST | G_SIGNAL_MUST_COLLECT, | |
| 160 | - 0, NULL, NULL, | |
| 161 | - NULL, | |
| 162 | - G_TYPE_NONE, 1, | |
| 163 | - G_TYPE_VARIANT | |
| 164 | - ); | |
| 165 | - } | |
| 166 | - | |
| 167 | - void pw3270Action_init(pw3270Action *action) { | |
| 168 | - | |
| 169 | - action->name = NULL; | |
| 170 | - action->terminal = NULL; | |
| 171 | - action->state = NULL; | |
| 172 | - | |
| 173 | - } | |
| 174 | - | |
| 175 | - void finalize(GObject *object) { | |
| 176 | - | |
| 177 | - pw3270Action * action = PW3270_ACTION(object); | |
| 178 | - | |
| 179 | - debug("Finalizing action %p (%s)",object,action->name); | |
| 180 | - | |
| 181 | - if(action->state) { | |
| 182 | - g_variant_unref(action->state); | |
| 183 | - action->state = NULL; | |
| 184 | - } | |
| 185 | - | |
| 186 | - if(action->terminal) { | |
| 187 | - pw3270_action_set_terminal_widget(G_ACTION(object),NULL); | |
| 188 | - action->terminal = NULL; | |
| 189 | - } | |
| 190 | - | |
| 191 | - if(action->name) { | |
| 192 | - g_free(action->name); | |
| 193 | - action->name = NULL; | |
| 194 | - } | |
| 195 | - | |
| 196 | - if(action->parameter_type) { | |
| 197 | - g_variant_type_free(action->parameter_type); | |
| 198 | - action->parameter_type = NULL; | |
| 199 | - } | |
| 200 | - | |
| 201 | - G_OBJECT_CLASS(pw3270Action_parent_class)->finalize(object); | |
| 202 | - | |
| 203 | - } | |
| 204 | - | |
| 205 | - | |
| 206 | - void pw3270_action_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { | |
| 207 | - | |
| 208 | - GAction *action = G_ACTION(object); | |
| 209 | - | |
| 210 | - debug("%s(%d)",__FUNCTION__,prop_id); | |
| 211 | - | |
| 212 | - switch (prop_id) { | |
| 213 | - case PROP_NAME: | |
| 214 | - g_value_set_string(value, pw3270_action_get_name(action)); | |
| 215 | - break; | |
| 216 | - | |
| 217 | - case PROP_PARAMETER_TYPE: | |
| 218 | - g_value_set_boxed(value, pw3270_action_get_parameter_type(action)); | |
| 219 | - break; | |
| 220 | - | |
| 221 | - case PROP_ENABLED: | |
| 222 | - g_value_set_boolean(value, pw3270_action_get_enabled(action)); | |
| 223 | - break; | |
| 224 | - | |
| 225 | - case PROP_STATE_TYPE: | |
| 226 | - g_value_set_boxed(value, pw3270_action_get_state_type(action)); | |
| 227 | - break; | |
| 228 | - | |
| 229 | - case PROP_STATE: | |
| 230 | - g_value_take_variant(value, pw3270_action_get_state_property(action)); | |
| 231 | - break; | |
| 232 | - | |
| 233 | - default: | |
| 234 | - g_assert_not_reached (); | |
| 235 | - } | |
| 236 | - | |
| 237 | - } | |
| 238 | - | |
| 239 | - void pw3270_action_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { | |
| 240 | - | |
| 241 | -// debug("%s(%d)",__FUNCTION__,prop_id); | |
| 242 | - | |
| 243 | - GAction *action = G_ACTION(object); | |
| 244 | - | |
| 245 | - switch (prop_id) | |
| 246 | - { | |
| 247 | - case PROP_NAME: | |
| 248 | - pw3270_action_set_name(action, g_value_get_string(value)); | |
| 249 | - break; | |
| 250 | - | |
| 251 | - case PROP_PARAMETER_TYPE: | |
| 252 | -// action->parameter_type = g_value_dup_boxed (value); | |
| 253 | - break; | |
| 254 | - | |
| 255 | - case PROP_ENABLED: | |
| 256 | -// action->enabled = g_value_get_boolean (value); | |
| 257 | - break; | |
| 258 | - | |
| 259 | - case PROP_STATE: | |
| 260 | - pw3270_action_set_state(action, g_value_get_variant(value)); | |
| 261 | - break; | |
| 262 | - | |
| 263 | - default: | |
| 264 | - g_assert_not_reached (); | |
| 265 | - } | |
| 266 | - | |
| 267 | - } | |
| 268 | - | |
| 269 | - const gchar * pw3270_action_get_name(GAction *action) { | |
| 270 | - return PW3270_ACTION(action)->name; | |
| 271 | - } | |
| 272 | - | |
| 273 | - void pw3270_action_set_name(GAction *object, const gchar *name) { | |
| 274 | - | |
| 275 | - pw3270Action * action = PW3270_ACTION(object); | |
| 276 | - | |
| 277 | -// debug("%s %s -> %s", __FUNCTION__, action->name, name); | |
| 278 | - | |
| 279 | - if(action->name) | |
| 280 | - g_free(action->name); | |
| 281 | - | |
| 282 | - if(name) | |
| 283 | - action->name = g_strdup(name); | |
| 284 | - else | |
| 285 | - action->name = NULL; | |
| 286 | - | |
| 287 | - } | |
| 288 | - | |
| 289 | - GVariant * pw3270_action_get_state_property(GAction *object) { | |
| 290 | - pw3270Action *action = PW3270_ACTION(object); | |
| 291 | - return action->state ? g_variant_ref(action->state) : NULL; | |
| 292 | - } | |
| 293 | - | |
| 294 | - const GVariantType * pw3270_action_get_parameter_type(GAction *action) { | |
| 295 | - return PW3270_ACTION_GET_CLASS(action)->get_parameter_type(action); | |
| 296 | - } | |
| 297 | - | |
| 298 | - const GVariantType * pw3270_action_get_state_type(GAction *object) { | |
| 299 | - | |
| 300 | - pw3270Action * action = PW3270_ACTION(object); | |
| 301 | - | |
| 302 | - if(action->state) | |
| 303 | - return g_variant_get_type(action->state); | |
| 304 | - | |
| 305 | - return NULL; | |
| 306 | - | |
| 307 | - } | |
| 308 | - | |
| 309 | - GVariant * pw3270_action_get_state_hint(GAction *action) { | |
| 310 | - debug("%s",__FUNCTION__); | |
| 311 | - return NULL; | |
| 312 | - } | |
| 313 | - | |
| 314 | - void pw3270_action_change_state(GAction *object, GVariant *value) { | |
| 315 | - pw3270_action_set_state(object, value); | |
| 316 | - } | |
| 317 | - | |
| 318 | - void pw3270_action_change_state_boolean(GAction *action, gboolean state) { | |
| 319 | - | |
| 320 | - g_return_if_fail(PW3270_IS_ACTION(action)); | |
| 321 | - pw3270_action_set_state(action,g_variant_new_boolean(state)); | |
| 322 | - | |
| 323 | - } | |
| 324 | - | |
| 325 | - void pw3270_action_set_state(GAction *object, GVariant *value) { | |
| 326 | - | |
| 327 | - if(value) { | |
| 328 | - | |
| 329 | - pw3270Action * action = PW3270_ACTION(object); | |
| 330 | - | |
| 331 | - g_variant_ref_sink(value); | |
| 332 | - | |
| 333 | - if (!action->state || !g_variant_equal(action->state, value)) { | |
| 334 | - | |
| 335 | - if(action->state) | |
| 336 | - g_variant_unref(action->state); | |
| 337 | - | |
| 338 | - action->state = g_variant_ref(value); | |
| 339 | - | |
| 340 | - if (g_signal_has_handler_pending(object, action_signals[SIGNAL_CHANGE_STATE], 0, TRUE)) { | |
| 341 | - g_signal_emit(object, action_signals[SIGNAL_CHANGE_STATE], 0, value); | |
| 342 | - } | |
| 343 | - | |
| 344 | - g_object_notify_by_pspec(G_OBJECT(object), PW3270_ACTION_GET_CLASS(object)->properties.state); | |
| 345 | - | |
| 346 | - } | |
| 347 | - | |
| 348 | - g_variant_unref(value); | |
| 349 | - | |
| 350 | - } | |
| 351 | - | |
| 352 | - } | |
| 353 | - | |
| 354 | - void pw3270_action_set_enabled(GAction *object, gboolean state) { | |
| 355 | - g_object_notify_by_pspec(G_OBJECT(object), PW3270_ACTION_GET_CLASS(object)->properties.enabled); | |
| 356 | - } | |
| 357 | - | |
| 358 | - | |
| 359 | - static void change_widget(GAction *action, GtkWidget G_GNUC_UNUSED(*from), GtkWidget *to) { | |
| 360 | - PW3270_ACTION(action)->terminal = to; | |
| 361 | - } | |
| 362 | - | |
| 363 | - void pw3270_action_set_terminal_widget(GAction *object, GtkWidget *widget) { | |
| 364 | - | |
| 365 | - g_return_if_fail(PW3270_IS_ACTION(object) && GTK_IS_V3270(widget)); | |
| 366 | - | |
| 367 | - pw3270Action * action = PW3270_ACTION(object); | |
| 368 | - | |
| 369 | - if(action->terminal != widget) { | |
| 370 | - PW3270_ACTION_GET_CLASS(object)->change_widget(object,action->terminal,widget); | |
| 371 | - action->terminal = widget; | |
| 372 | - } | |
| 373 | - | |
| 374 | - } | |
| 375 | - | |
| 376 | - gboolean pw3270_action_get_enabled(GAction *object) { | |
| 377 | - | |
| 378 | - pw3270Action * action = PW3270_ACTION(object); | |
| 379 | - | |
| 380 | -// debug("%s: terminal=%p",__FUNCTION__,action->terminal); | |
| 381 | - | |
| 382 | - if(action && action->terminal) { | |
| 383 | - | |
| 384 | - return PW3270_ACTION_GET_CLASS(object)->get_enabled(object,action->terminal); | |
| 385 | - | |
| 386 | - } | |
| 387 | - | |
| 388 | - return FALSE; | |
| 389 | - | |
| 390 | - } | |
| 391 | - | |
| 392 | - void pw3270_action_activate(GAction *object, GVariant *parameter) { | |
| 393 | - | |
| 394 | - pw3270Action * action = PW3270_ACTION(object); | |
| 395 | - | |
| 396 | - debug("%s: terminal=%p",__FUNCTION__,action->terminal); | |
| 397 | - | |
| 398 | - if(action && action->terminal) { | |
| 399 | - PW3270_ACTION_GET_CLASS(object)->activate(object,parameter,action->terminal); | |
| 400 | - } | |
| 401 | - | |
| 402 | - } | |
| 403 | - | |
| 404 | - gboolean get_enabled(GAction *object, GtkWidget *terminal) { | |
| 405 | - debug("%s(%s)",__FUNCTION__,pw3270_action_get_name(object)); | |
| 406 | - return TRUE; | |
| 407 | - } | |
| 408 | - | |
| 409 | - void activate(GAction *action, GVariant G_GNUC_UNUSED(*parameter), GtkWidget G_GNUC_UNUSED(*terminal)) { | |
| 410 | - g_message("Action %s can't be activated",pw3270_action_get_name(action)); | |
| 411 | - } |
src/actions/actions.cbp
| ... | ... | @@ -1,72 +0,0 @@ |
| 1 | -<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | |
| 2 | -<CodeBlocks_project_file> | |
| 3 | - <FileVersion major="1" minor="6" /> | |
| 4 | - <Project> | |
| 5 | - <Option title="PW3270 Actions" /> | |
| 6 | - <Option pch_mode="2" /> | |
| 7 | - <Option compiler="gcc" /> | |
| 8 | - <Build> | |
| 9 | - <Target title="Debug"> | |
| 10 | - <Option output=".bin/Debug/PW3270 Actions" prefix_auto="1" extension_auto="1" /> | |
| 11 | - <Option object_output=".obj/Debug/" /> | |
| 12 | - <Option type="1" /> | |
| 13 | - <Option compiler="gcc" /> | |
| 14 | - <Compiler> | |
| 15 | - <Add option="-g" /> | |
| 16 | - <Add option="-DDEBUG=1" /> | |
| 17 | - </Compiler> | |
| 18 | - </Target> | |
| 19 | - <Target title="Release"> | |
| 20 | - <Option output=".bin/Release/PW3270 Actions" prefix_auto="1" extension_auto="1" /> | |
| 21 | - <Option object_output=".obj/Release/" /> | |
| 22 | - <Option type="1" /> | |
| 23 | - <Option compiler="gcc" /> | |
| 24 | - <Compiler> | |
| 25 | - <Add option="-O2" /> | |
| 26 | - <Add option="-DNDEBUG=1" /> | |
| 27 | - </Compiler> | |
| 28 | - <Linker> | |
| 29 | - <Add option="-s" /> | |
| 30 | - </Linker> | |
| 31 | - </Target> | |
| 32 | - </Build> | |
| 33 | - <Compiler> | |
| 34 | - <Add option="-Wall" /> | |
| 35 | - <Add option="`pkg-config --cflags gtk+-3.0 gio-2.0 glib-2.0 lib3270 libv3270`" /> | |
| 36 | - <Add directory="../include" /> | |
| 37 | - </Compiler> | |
| 38 | - <Linker> | |
| 39 | - <Add option="`pkg-config --libs gtk+-3.0 gio-2.0 glib-2.0 lib3270 libv3270`" /> | |
| 40 | - </Linker> | |
| 41 | - <Unit filename="../include/pw3270/actions.h" /> | |
| 42 | - <Unit filename="../include/pw3270/window.h" /> | |
| 43 | - <Unit filename="abstract.c"> | |
| 44 | - <Option compilerVar="CC" /> | |
| 45 | - </Unit> | |
| 46 | - <Unit filename="lib3270/action.c"> | |
| 47 | - <Option compilerVar="CC" /> | |
| 48 | - </Unit> | |
| 49 | - <Unit filename="lib3270/pakey.c"> | |
| 50 | - <Option compilerVar="CC" /> | |
| 51 | - </Unit> | |
| 52 | - <Unit filename="lib3270/pfkey.c"> | |
| 53 | - <Option compilerVar="CC" /> | |
| 54 | - </Unit> | |
| 55 | - <Unit filename="lib3270/toggle.c"> | |
| 56 | - <Option compilerVar="CC" /> | |
| 57 | - </Unit> | |
| 58 | - <Unit filename="private.h" /> | |
| 59 | - <Unit filename="testprogram/testprogram.c"> | |
| 60 | - <Option compilerVar="CC" /> | |
| 61 | - </Unit> | |
| 62 | - <Unit filename="window.c"> | |
| 63 | - <Option compilerVar="CC" /> | |
| 64 | - </Unit> | |
| 65 | - <Extensions> | |
| 66 | - <code_completion /> | |
| 67 | - <envvars /> | |
| 68 | - <debugger /> | |
| 69 | - <lib_finder disable_auto="1" /> | |
| 70 | - </Extensions> | |
| 71 | - </Project> | |
| 72 | -</CodeBlocks_project_file> |
src/actions/lib3270/action.c
| ... | ... | @@ -1,112 +0,0 @@ |
| 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 | - /** | |
| 31 | - * @brief Implement GAction "wrapper" for lib3270's actions. | |
| 32 | - * | |
| 33 | - */ | |
| 34 | - | |
| 35 | - #include "../private.h" | |
| 36 | - #include <v3270.h> | |
| 37 | - | |
| 38 | - #define PW3270_TYPE_LIB3270_ACTION (Lib3270Action_get_type()) | |
| 39 | - #define PW3270_LIB3270_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), PW3270_TYPE_LIB3270_ACTION, Lib3270Action)) | |
| 40 | - #define PW3270_IS_LIB3270_ACTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), PW3270_TYPE_LIB3270_ACTION)) | |
| 41 | - | |
| 42 | - typedef struct _Lib3270ActionClass { | |
| 43 | - pw3270ActionClass parent_class; | |
| 44 | - | |
| 45 | - } Lib3270ActionClass; | |
| 46 | - | |
| 47 | - typedef struct _Lib3270Action { | |
| 48 | - pw3270Action parent; | |
| 49 | - | |
| 50 | - const LIB3270_ACTION * definition; | |
| 51 | - | |
| 52 | - } Lib3270Action; | |
| 53 | - | |
| 54 | - static void Lib3270Action_class_init(Lib3270ActionClass *klass); | |
| 55 | - static void Lib3270Action_init(Lib3270Action *action); | |
| 56 | - static void change_widget(GAction *object, GtkWidget *from, GtkWidget *to); | |
| 57 | - | |
| 58 | - G_DEFINE_TYPE(Lib3270Action, Lib3270Action, PW3270_TYPE_ACTION); | |
| 59 | - | |
| 60 | - static gboolean get_enabled(GAction *action, GtkWidget *terminal) { | |
| 61 | - | |
| 62 | - if(terminal) | |
| 63 | - return PW3270_LIB3270_ACTION(action)->definition->activatable(v3270_get_session(terminal)) > 0 ? TRUE : FALSE; | |
| 64 | - | |
| 65 | - return FALSE; | |
| 66 | - | |
| 67 | - } | |
| 68 | - | |
| 69 | - static void activate(GAction *action, GVariant *parameter, GtkWidget *terminal) { | |
| 70 | - PW3270_LIB3270_ACTION(action)->definition->activate(v3270_get_session(terminal)); | |
| 71 | - } | |
| 72 | - | |
| 73 | - void Lib3270Action_class_init(Lib3270ActionClass *klass) { | |
| 74 | - | |
| 75 | - pw3270ActionClass * action = PW3270_ACTION_CLASS(klass); | |
| 76 | - | |
| 77 | - action->activate = activate; | |
| 78 | - action->get_enabled = get_enabled; | |
| 79 | - action->change_widget = change_widget; | |
| 80 | - | |
| 81 | - } | |
| 82 | - | |
| 83 | - void Lib3270Action_init(Lib3270Action *action) { | |
| 84 | - } | |
| 85 | - | |
| 86 | - GAction * pw3270_action_new_from_lib3270(const LIB3270_ACTION * definition) { | |
| 87 | - | |
| 88 | - Lib3270Action * action = (Lib3270Action *) g_object_new(PW3270_TYPE_LIB3270_ACTION, NULL); | |
| 89 | - action->definition = definition; | |
| 90 | - | |
| 91 | - // Setup the default name. | |
| 92 | - pw3270Action * abstract = PW3270_ACTION(action); | |
| 93 | - | |
| 94 | - if(abstract->name) | |
| 95 | - g_free(abstract->name); | |
| 96 | - | |
| 97 | - abstract->name = g_strconcat("win.",definition->name,NULL); | |
| 98 | - | |
| 99 | - return G_ACTION(action); | |
| 100 | - } | |
| 101 | - | |
| 102 | - void change_widget(GAction *object, GtkWidget *from, GtkWidget *to) { | |
| 103 | - | |
| 104 | - PW3270_ACTION_CLASS(Lib3270Action_parent_class)->change_widget(object,from,to); | |
| 105 | - | |
| 106 | - // Does the "enabled" state has changed? If yes notify customers. | |
| 107 | - gboolean enabled = get_enabled(object,to); | |
| 108 | - if(get_enabled(object,from) != enabled) | |
| 109 | - pw3270_action_set_enabled(object,enabled); | |
| 110 | - | |
| 111 | - } | |
| 112 | - |
src/actions/lib3270/pakey.c
| ... | ... | @@ -1,139 +0,0 @@ |
| 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 | - /** | |
| 31 | - * @brief Implement GAction "wrapper" for lib3270's PAs. | |
| 32 | - * | |
| 33 | - */ | |
| 34 | - | |
| 35 | - #include "../private.h" | |
| 36 | - #include <v3270.h> | |
| 37 | - | |
| 38 | - #define PW3270_TYPE_PAKEY_ACTION (Lib3270PaAction_get_type()) | |
| 39 | - #define PW3270_LIB3270_PAKEY_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), PW3270_TYPE_PAKEY_ACTION, Lib3270PaAction)) | |
| 40 | - #define PW3270_IS_LIB3270_PAKEY_ACTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), PW3270_TYPE_PAKEY_ACTION)) | |
| 41 | - | |
| 42 | - typedef struct _Lib3270PaActionClass { | |
| 43 | - pw3270ActionClass parent_class; | |
| 44 | - | |
| 45 | - } Lib3270PaActionClass; | |
| 46 | - | |
| 47 | - typedef struct _Lib3270PaAction { | |
| 48 | - pw3270Action parent; | |
| 49 | - | |
| 50 | - } Lib3270PaAction; | |
| 51 | - | |
| 52 | - static void Lib3270PaAction_class_init(Lib3270PaActionClass *klass); | |
| 53 | - static void Lib3270PaAction_init(Lib3270PaAction *action); | |
| 54 | - static void change_widget(GAction *object, GtkWidget *from, GtkWidget *to); | |
| 55 | - | |
| 56 | - G_DEFINE_TYPE(Lib3270PaAction, Lib3270PaAction, PW3270_TYPE_PAKEY_ACTION); | |
| 57 | - | |
| 58 | - static gboolean get_enabled(GAction *action, GtkWidget *terminal) { | |
| 59 | - | |
| 60 | - if(terminal) | |
| 61 | - return lib3270_is_connected(v3270_get_session(terminal)) > 0 ? TRUE: FALSE; | |
| 62 | - | |
| 63 | - return FALSE; | |
| 64 | - | |
| 65 | - } | |
| 66 | - | |
| 67 | - static void activate(GAction *action, GVariant *parameter, GtkWidget *terminal) { | |
| 68 | - | |
| 69 | - if(action && terminal && parameter) { | |
| 70 | - | |
| 71 | - H3270 * hSession = v3270_get_session(terminal); | |
| 72 | - | |
| 73 | - if(g_variant_is_of_type(parameter, G_VARIANT_TYPE_INT32)) { | |
| 74 | - | |
| 75 | - lib3270_pakey(hSession,(int) g_variant_get_int32(parameter)); | |
| 76 | - | |
| 77 | - } else if(g_variant_is_of_type(parameter, G_VARIANT_TYPE_UINT32)) { | |
| 78 | - | |
| 79 | - lib3270_pakey(hSession,(int) g_variant_get_uint32(parameter)); | |
| 80 | - | |
| 81 | - } else if(g_variant_is_of_type(parameter, G_VARIANT_TYPE_INT16)) { | |
| 82 | - | |
| 83 | - lib3270_pakey(hSession,(int) g_variant_get_int16(parameter)); | |
| 84 | - | |
| 85 | - } else if(g_variant_is_of_type(parameter, G_VARIANT_TYPE_UINT16)) { | |
| 86 | - | |
| 87 | - lib3270_pakey(hSession,(int) g_variant_get_uint16(parameter)); | |
| 88 | - | |
| 89 | - } | |
| 90 | - | |
| 91 | - } | |
| 92 | - | |
| 93 | - } | |
| 94 | - | |
| 95 | - static const GVariantType * get_parameter_type(GAction *action) | |
| 96 | - { | |
| 97 | - return G_VARIANT_TYPE_UINT16; | |
| 98 | - } | |
| 99 | - | |
| 100 | - void Lib3270PaAction_class_init(Lib3270PaActionClass *klass) { | |
| 101 | - | |
| 102 | - pw3270ActionClass * action = PW3270_ACTION_CLASS(klass); | |
| 103 | - | |
| 104 | - action->activate = activate; | |
| 105 | - action->get_enabled = get_enabled; | |
| 106 | - action->change_widget = change_widget; | |
| 107 | - action->get_parameter_type = get_parameter_type; | |
| 108 | - | |
| 109 | - } | |
| 110 | - | |
| 111 | - void Lib3270PaAction_init(Lib3270PaAction *action) { | |
| 112 | - } | |
| 113 | - | |
| 114 | - GAction * pw3270_action_new_pakey(void) { | |
| 115 | - | |
| 116 | - Lib3270PaAction * action = (Lib3270PaAction *) g_object_new(PW3270_TYPE_PAKEY_ACTION, NULL); | |
| 117 | - | |
| 118 | - // Setup the default name. | |
| 119 | - pw3270Action * abstract = PW3270_ACTION(action); | |
| 120 | - | |
| 121 | - if(abstract->name) | |
| 122 | - g_free(abstract->name); | |
| 123 | - | |
| 124 | - abstract->name = g_strdup("win.pakey"); | |
| 125 | - | |
| 126 | - return G_ACTION(action); | |
| 127 | - } | |
| 128 | - | |
| 129 | - void change_widget(GAction *object, GtkWidget *from, GtkWidget *to) { | |
| 130 | - | |
| 131 | - PW3270_ACTION_CLASS(Lib3270PaAction_parent_class)->change_widget(object,from,to); | |
| 132 | - | |
| 133 | - // Does the "enabled" state has changed? If yes notify customers. | |
| 134 | - gboolean enabled = get_enabled(object,to); | |
| 135 | - if(get_enabled(object,from) != enabled) | |
| 136 | - pw3270_action_set_enabled(object,enabled); | |
| 137 | - | |
| 138 | - } | |
| 139 | - |
src/actions/lib3270/pfkey.c
| ... | ... | @@ -1,139 +0,0 @@ |
| 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 | - /** | |
| 31 | - * @brief Implement GAction "wrapper" for lib3270's PFs. | |
| 32 | - * | |
| 33 | - */ | |
| 34 | - | |
| 35 | - #include "../private.h" | |
| 36 | - #include <v3270.h> | |
| 37 | - | |
| 38 | - #define PW3270_TYPE_PFKEY_ACTION (Lib3270PfAction_get_type()) | |
| 39 | - #define PW3270_LIB3270_PFKEY_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), PW3270_TYPE_PFKEY_ACTION, Lib3270PfAction)) | |
| 40 | - #define PW3270_IS_LIB3270_PFKEY_ACTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), PW3270_TYPE_PFKEY_ACTION)) | |
| 41 | - | |
| 42 | - typedef struct _Lib3270PfActionClass { | |
| 43 | - pw3270ActionClass parent_class; | |
| 44 | - | |
| 45 | - } Lib3270PfActionClass; | |
| 46 | - | |
| 47 | - typedef struct _Lib3270PfAction { | |
| 48 | - pw3270Action parent; | |
| 49 | - | |
| 50 | - } Lib3270PfAction; | |
| 51 | - | |
| 52 | - static void Lib3270PfAction_class_init(Lib3270PfActionClass *klass); | |
| 53 | - static void Lib3270PfAction_init(Lib3270PfAction *action); | |
| 54 | - static void change_widget(GAction *object, GtkWidget *from, GtkWidget *to); | |
| 55 | - | |
| 56 | - G_DEFINE_TYPE(Lib3270PfAction, Lib3270PfAction, PW3270_TYPE_PFKEY_ACTION); | |
| 57 | - | |
| 58 | - static gboolean get_enabled(GAction *action, GtkWidget *terminal) { | |
| 59 | - | |
| 60 | - if(terminal) | |
| 61 | - return lib3270_is_connected(v3270_get_session(terminal)) > 0 ? TRUE: FALSE; | |
| 62 | - | |
| 63 | - return FALSE; | |
| 64 | - | |
| 65 | - } | |
| 66 | - | |
| 67 | - static void activate(GAction *action, GVariant *parameter, GtkWidget *terminal) { | |
| 68 | - | |
| 69 | - if(action && terminal && parameter) { | |
| 70 | - | |
| 71 | - H3270 * hSession = v3270_get_session(terminal); | |
| 72 | - | |
| 73 | - if(g_variant_is_of_type(parameter, G_VARIANT_TYPE_INT32)) { | |
| 74 | - | |
| 75 | - lib3270_pfkey(hSession,(int) g_variant_get_int32(parameter)); | |
| 76 | - | |
| 77 | - } else if(g_variant_is_of_type(parameter, G_VARIANT_TYPE_UINT32)) { | |
| 78 | - | |
| 79 | - lib3270_pfkey(hSession,(int) g_variant_get_uint32(parameter)); | |
| 80 | - | |
| 81 | - } else if(g_variant_is_of_type(parameter, G_VARIANT_TYPE_INT16)) { | |
| 82 | - | |
| 83 | - lib3270_pfkey(hSession,(int) g_variant_get_int16(parameter)); | |
| 84 | - | |
| 85 | - } else if(g_variant_is_of_type(parameter, G_VARIANT_TYPE_UINT16)) { | |
| 86 | - | |
| 87 | - lib3270_pfkey(hSession,(int) g_variant_get_uint16(parameter)); | |
| 88 | - | |
| 89 | - } | |
| 90 | - | |
| 91 | - } | |
| 92 | - | |
| 93 | - } | |
| 94 | - | |
| 95 | - static const GVariantType * get_parameter_type(GAction *action) | |
| 96 | - { | |
| 97 | - return G_VARIANT_TYPE_UINT16; | |
| 98 | - } | |
| 99 | - | |
| 100 | - void Lib3270PfAction_class_init(Lib3270PfActionClass *klass) { | |
| 101 | - | |
| 102 | - pw3270ActionClass * action = PW3270_ACTION_CLASS(klass); | |
| 103 | - | |
| 104 | - action->activate = activate; | |
| 105 | - action->get_enabled = get_enabled; | |
| 106 | - action->change_widget = change_widget; | |
| 107 | - action->get_parameter_type = get_parameter_type; | |
| 108 | - | |
| 109 | - } | |
| 110 | - | |
| 111 | - void Lib3270PfAction_init(Lib3270PfAction *action) { | |
| 112 | - } | |
| 113 | - | |
| 114 | - GAction * pw3270_action_new_pfkey(void) { | |
| 115 | - | |
| 116 | - Lib3270PfAction * action = (Lib3270PfAction *) g_object_new(PW3270_TYPE_PFKEY_ACTION, NULL); | |
| 117 | - | |
| 118 | - // Setup the default name. | |
| 119 | - pw3270Action * abstract = PW3270_ACTION(action); | |
| 120 | - | |
| 121 | - if(abstract->name) | |
| 122 | - g_free(abstract->name); | |
| 123 | - | |
| 124 | - abstract->name = g_strdup("win.pfkey"); | |
| 125 | - | |
| 126 | - return G_ACTION(action); | |
| 127 | - } | |
| 128 | - | |
| 129 | - void change_widget(GAction *object, GtkWidget *from, GtkWidget *to) { | |
| 130 | - | |
| 131 | - PW3270_ACTION_CLASS(Lib3270PfAction_parent_class)->change_widget(object,from,to); | |
| 132 | - | |
| 133 | - // Does the "enabled" state has changed? If yes notify customers. | |
| 134 | - gboolean enabled = get_enabled(object,to); | |
| 135 | - if(get_enabled(object,from) != enabled) | |
| 136 | - pw3270_action_set_enabled(object,enabled); | |
| 137 | - | |
| 138 | - } | |
| 139 | - |
src/actions/lib3270/toggle.c
| ... | ... | @@ -1,133 +0,0 @@ |
| 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 | - /** | |
| 31 | - * @brief Implement GAction "wrapper" for lib3270's toggles. | |
| 32 | - * | |
| 33 | - */ | |
| 34 | - | |
| 35 | - #include "../private.h" | |
| 36 | - #include <pw3270/window.h> | |
| 37 | - #include <v3270.h> | |
| 38 | - | |
| 39 | - #define PW3270_TYPE_LIB3270_TOGGLE_ACTION (Lib3270ToggleAction_get_type()) | |
| 40 | - #define PW3270_LIB3270_TOGGLE_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), PW3270_TYPE_LIB3270_TOGGLE_ACTION, Lib3270ToggleAction)) | |
| 41 | - #define PW3270_IS_LIB3270_TOGGLE_ACTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), PW3270_TYPE_LIB3270_TOGGLE_ACTION)) | |
| 42 | - | |
| 43 | - typedef struct _Lib3270ToggleActionClass { | |
| 44 | - pw3270ActionClass parent_class; | |
| 45 | - | |
| 46 | - } Lib3270ToggleActionClass; | |
| 47 | - | |
| 48 | - typedef struct _Lib3270ToggleAction { | |
| 49 | - pw3270Action parent; | |
| 50 | - | |
| 51 | - const LIB3270_TOGGLE * definition; | |
| 52 | - const void * listener; | |
| 53 | - | |
| 54 | - } Lib3270ToggleAction; | |
| 55 | - | |
| 56 | - static void Lib3270ToggleAction_class_init(Lib3270ToggleActionClass *klass); | |
| 57 | - static void Lib3270ToggleAction_init(Lib3270ToggleAction *action); | |
| 58 | - | |
| 59 | - G_DEFINE_TYPE(Lib3270ToggleAction, Lib3270ToggleAction, PW3270_TYPE_ACTION); | |
| 60 | - | |
| 61 | - static void change_state(H3270 *hSession, LIB3270_TOGGLE_ID id, char state, void * action) { | |
| 62 | - debug("%s: %s",__FUNCTION__,state ? "ON" : "OFF"); | |
| 63 | - pw3270_action_change_state_boolean((GAction *) action, state == 0 ? FALSE : TRUE); | |
| 64 | - } | |
| 65 | - | |
| 66 | - static void change_widget(GAction *object, GtkWidget *from, GtkWidget *to) { | |
| 67 | - | |
| 68 | - Lib3270ToggleAction * action = PW3270_LIB3270_TOGGLE_ACTION(object); | |
| 69 | - | |
| 70 | - if(action->listener) { | |
| 71 | - lib3270_unregister_toggle_listener(v3270_get_session(from),action->definition->id,object); | |
| 72 | - } | |
| 73 | - | |
| 74 | - if(to) { | |
| 75 | - action->listener = lib3270_register_toggle_listener(v3270_get_session(to),action->definition->id,change_state,object); | |
| 76 | - pw3270_action_change_state_boolean(object,lib3270_get_toggle(v3270_get_session(to),action->definition->id)); | |
| 77 | - } | |
| 78 | - | |
| 79 | - PW3270_ACTION_CLASS(Lib3270ToggleAction_parent_class)->change_widget(object,from,to); | |
| 80 | - | |
| 81 | - } | |
| 82 | - | |
| 83 | - static void activate(GAction *action, GVariant *parameter, GtkWidget *terminal) { | |
| 84 | - | |
| 85 | - debug("Activating \"%s\"",pw3270_action_get_name(action)); | |
| 86 | - | |
| 87 | - if(parameter && g_variant_is_of_type(parameter,G_VARIANT_TYPE_BOOLEAN)) { | |
| 88 | - | |
| 89 | - lib3270_set_toggle(v3270_get_session(terminal),PW3270_LIB3270_TOGGLE_ACTION(action)->definition->id,g_variant_get_boolean(parameter)); | |
| 90 | - debug("Toggle set to %s",lib3270_get_toggle(v3270_get_session(terminal),PW3270_LIB3270_TOGGLE_ACTION(action)->definition->id) ? "ON" : "OFF"); | |
| 91 | - | |
| 92 | - } else { | |
| 93 | - | |
| 94 | - lib3270_toggle(v3270_get_session(terminal),PW3270_LIB3270_TOGGLE_ACTION(action)->definition->id); | |
| 95 | - debug("Toggle is %s",lib3270_get_toggle(v3270_get_session(terminal),PW3270_LIB3270_TOGGLE_ACTION(action)->definition->id) ? "ON" : "OFF"); | |
| 96 | - | |
| 97 | - } | |
| 98 | - | |
| 99 | - } | |
| 100 | - | |
| 101 | - void Lib3270ToggleAction_class_init(Lib3270ToggleActionClass *klass) { | |
| 102 | - | |
| 103 | - pw3270ActionClass * action = PW3270_ACTION_CLASS(klass); | |
| 104 | - action->activate = activate; | |
| 105 | - action->change_widget = change_widget; | |
| 106 | - | |
| 107 | - } | |
| 108 | - | |
| 109 | - void Lib3270ToggleAction_init(Lib3270ToggleAction *action) { | |
| 110 | - | |
| 111 | - action->definition = NULL; | |
| 112 | - action->listener = NULL; | |
| 113 | - | |
| 114 | - } | |
| 115 | - | |
| 116 | - GAction * pw3270_toggle_action_new_from_lib3270(const LIB3270_TOGGLE * definition) { | |
| 117 | - | |
| 118 | - Lib3270ToggleAction * action = (Lib3270ToggleAction *) g_object_new(PW3270_TYPE_LIB3270_TOGGLE_ACTION, NULL); | |
| 119 | - action->definition = definition; | |
| 120 | - | |
| 121 | - // Setup the default name. | |
| 122 | - pw3270Action * abstract = PW3270_ACTION(action); | |
| 123 | - | |
| 124 | - if(abstract->name) | |
| 125 | - g_free(abstract->name); | |
| 126 | - | |
| 127 | - abstract->name = g_strconcat("win.",definition->name,NULL); | |
| 128 | - | |
| 129 | - return G_ACTION(action); | |
| 130 | - | |
| 131 | - } | |
| 132 | - | |
| 133 | - |
src/actions/private.h
| ... | ... | @@ -1,88 +0,0 @@ |
| 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 | -#ifndef PRIVATE_H_INCLUDED | |
| 31 | - | |
| 32 | - #define PRIVATE_H_INCLUDED | |
| 33 | - | |
| 34 | - #include <config.h> | |
| 35 | - | |
| 36 | - #ifndef GETTEXT_PACKAGE | |
| 37 | - #define GETTEXT_PACKAGE PACKAGE_NAME | |
| 38 | - #endif | |
| 39 | - | |
| 40 | - #include <libintl.h> | |
| 41 | - #include <glib/gi18n.h> | |
| 42 | - #include <gtk/gtk.h> | |
| 43 | - | |
| 44 | - #include <pw3270/actions.h> | |
| 45 | - | |
| 46 | - #include <lib3270/actions.h> | |
| 47 | - #include <lib3270/toggle.h> | |
| 48 | - | |
| 49 | - #include <lib3270/log.h> | |
| 50 | - | |
| 51 | - /* not really I18N-related, but also a string marker macro */ | |
| 52 | - #define I_(string) g_intern_static_string (string) | |
| 53 | - | |
| 54 | - struct _pw3270Action { | |
| 55 | - GObject parent; | |
| 56 | - | |
| 57 | - GVariantType * parameter_type; | |
| 58 | - GVariant * state; | |
| 59 | - GtkWidget * terminal; | |
| 60 | - gchar * name; | |
| 61 | - | |
| 62 | - }; | |
| 63 | - | |
| 64 | - struct _pw3270ActionClass { | |
| 65 | - GObjectClass parent_class; | |
| 66 | - | |
| 67 | - struct { | |
| 68 | - GParamSpec * state; | |
| 69 | - GParamSpec * enabled; | |
| 70 | - } properties; | |
| 71 | - | |
| 72 | - void (*change_widget)(GAction *action, GtkWidget *from, GtkWidget *to); | |
| 73 | - gboolean (*get_enabled)(GAction *action, GtkWidget *terminal); | |
| 74 | - void (*activate)(GAction *action, GVariant *parameter, GtkWidget *terminal); | |
| 75 | - const GVariantType * (*get_parameter_type)(GAction *action); | |
| 76 | - | |
| 77 | - }; | |
| 78 | - | |
| 79 | - G_GNUC_INTERNAL GAction * pw3270_action_new_from_lib3270(const LIB3270_ACTION * definition); | |
| 80 | - G_GNUC_INTERNAL GAction * pw3270_toggle_action_new_from_lib3270(const LIB3270_TOGGLE * definition); | |
| 81 | - G_GNUC_INTERNAL GAction * pw3270_action_new_pfkey(void); | |
| 82 | - G_GNUC_INTERNAL GAction * pw3270_action_new_pakey(void); | |
| 83 | - | |
| 84 | - G_GNUC_INTERNAL void pw3270_action_change_state_boolean(GAction *action, gboolean state); | |
| 85 | - G_GNUC_INTERNAL void pw3270_action_set_enabled(GAction *action, gboolean state); | |
| 86 | - | |
| 87 | - | |
| 88 | -#endif // PRIVATE_H_INCLUDED |
src/actions/testprogram/testprogram.c
| ... | ... | @@ -1,133 +0,0 @@ |
| 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. Registro no INPI sob | |
| 5 | - * o nome G3270. | |
| 6 | - * | |
| 7 | - * Copyright (C) <2008> <Banco do Brasil S.A.> | |
| 8 | - * | |
| 9 | - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
| 10 | - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
| 11 | - * Free Software Foundation. | |
| 12 | - * | |
| 13 | - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
| 14 | - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
| 15 | - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
| 16 | - * obter mais detalhes. | |
| 17 | - * | |
| 18 | - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
| 19 | - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
| 20 | - * St, Fifth Floor, Boston, MA 02110-1301 USA | |
| 21 | - * | |
| 22 | - * Este programa está nomeado como testprogram.c e possui - linhas de código. | |
| 23 | - * | |
| 24 | - * Contatos: | |
| 25 | - * | |
| 26 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
| 27 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
| 28 | - * | |
| 29 | - */ | |
| 30 | - | |
| 31 | - #include <config.h> | |
| 32 | - #include <v3270.h> | |
| 33 | - #include <v3270/trace.h> | |
| 34 | - #include <lib3270/log.h> | |
| 35 | - #include <lib3270/toggle.h> | |
| 36 | - #include <pw3270/actions.h> | |
| 37 | - #include "../private.h" | |
| 38 | - | |
| 39 | - /*---[ Implement ]----------------------------------------------------------------------------------*/ | |
| 40 | - | |
| 41 | - GtkWidget * pw3270_window_get_terminal_widget(GtkWidget *window) { | |
| 42 | - return g_object_get_data(G_OBJECT(window), "v3270_terminal"); | |
| 43 | - } | |
| 44 | - | |
| 45 | - /* | |
| 46 | - H3270 * pw3270_window_get_session_handle(GtkWidget *window) { | |
| 47 | - return v3270_get_session(pw3270_window_get_terminal_widget(window)); | |
| 48 | - } | |
| 49 | - */ | |
| 50 | - | |
| 51 | - static gboolean handle_command(GtkWidget *trace, const gchar *cmd, const gchar *args, GtkWidget *window) { | |
| 52 | - | |
| 53 | - if(!g_ascii_strcasecmp(cmd,"activate")) { | |
| 54 | - | |
| 55 | - GAction * action = g_action_map_lookup_action(G_ACTION_MAP(window),args); | |
| 56 | - | |
| 57 | - if(!action) { | |
| 58 | - g_message("Invalid action name: \"%s\"",args); | |
| 59 | - } else if(g_action_get_enabled(action)) { | |
| 60 | - g_message("Activating action \"%s\"",args); | |
| 61 | - g_action_activate(action,NULL); | |
| 62 | - } else { | |
| 63 | - g_message("Action \"%s\" is disabled",args); | |
| 64 | - } | |
| 65 | - | |
| 66 | - return TRUE; | |
| 67 | - } | |
| 68 | - | |
| 69 | - return FALSE; | |
| 70 | - } | |
| 71 | - | |
| 72 | - static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) { | |
| 73 | - | |
| 74 | - GtkWidget * window = gtk_application_window_new(app); | |
| 75 | - GtkWidget * terminal = v3270_new(); | |
| 76 | - GtkWidget * vBox = gtk_box_new(GTK_ORIENTATION_VERTICAL,2); | |
| 77 | - GtkWidget * notebook = gtk_notebook_new(); | |
| 78 | - GtkWidget * toolbar = gtk_toolbar_new(); | |
| 79 | - | |
| 80 | - g_object_set_data(G_OBJECT(window),"v3270_terminal",terminal); | |
| 81 | - | |
| 82 | - pw3270_window_add_actions(window); | |
| 83 | - | |
| 84 | - gtk_box_pack_start(GTK_BOX(vBox),toolbar,FALSE,TRUE,0); | |
| 85 | - gtk_box_pack_start(GTK_BOX(vBox),notebook,TRUE,TRUE,0); | |
| 86 | - | |
| 87 | - // Create Terminal window | |
| 88 | - { | |
| 89 | - gtk_widget_set_can_default(terminal,TRUE); | |
| 90 | - | |
| 91 | - gtk_notebook_append_page(GTK_NOTEBOOK(notebook),terminal,gtk_label_new("Terminal")); | |
| 92 | - | |
| 93 | -#ifdef _WIN32 | |
| 94 | - v3270_set_font_family(terminal,"Droid Sans Mono"); | |
| 95 | -#endif // _WIN32 | |
| 96 | - | |
| 97 | - } | |
| 98 | - | |
| 99 | - // Create trace window | |
| 100 | - GtkWidget * trace = v3270_trace_new(terminal); | |
| 101 | - gtk_notebook_append_page(GTK_NOTEBOOK(notebook),trace,gtk_label_new("Trace")); | |
| 102 | - | |
| 103 | - g_signal_connect(trace,"command",G_CALLBACK(handle_command),window); | |
| 104 | - | |
| 105 | - // Setup and show main window | |
| 106 | - gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER); | |
| 107 | - gtk_window_set_default_size (GTK_WINDOW (window), 800, 500); | |
| 108 | - gtk_container_add(GTK_CONTAINER(window),vBox); | |
| 109 | - gtk_widget_show_all(window); | |
| 110 | - | |
| 111 | - gtk_widget_grab_focus(terminal); | |
| 112 | - | |
| 113 | -} | |
| 114 | - | |
| 115 | -int main (int argc, char **argv) { | |
| 116 | - | |
| 117 | - GtkApplication *app; | |
| 118 | - int status; | |
| 119 | - | |
| 120 | - app = gtk_application_new ("br.com.bb.pw3270",G_APPLICATION_FLAGS_NONE); | |
| 121 | - | |
| 122 | - g_signal_connect (app, "activate", G_CALLBACK(activate), NULL); | |
| 123 | - | |
| 124 | - status = g_application_run (G_APPLICATION (app), argc, argv); | |
| 125 | - g_object_unref (app); | |
| 126 | - | |
| 127 | - g_message("rc=%d",status); | |
| 128 | - | |
| 129 | - return 0; | |
| 130 | - | |
| 131 | -} | |
| 132 | - | |
| 133 | - |
src/actions/window.c
| ... | ... | @@ -1,91 +0,0 @@ |
| 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 | - /** | |
| 31 | - * @brief Integrate pw3270 actions with the application window. | |
| 32 | - * | |
| 33 | - */ | |
| 34 | - | |
| 35 | - #include "private.h" | |
| 36 | - #include <lib3270/actions.h> | |
| 37 | - #include <pw3270/window.h> | |
| 38 | - | |
| 39 | - void pw3270_window_add_actions(GtkWidget * appwindow) { | |
| 40 | - | |
| 41 | - GActionMap * map = G_ACTION_MAP(appwindow); | |
| 42 | - GtkWidget * terminal = pw3270_window_get_terminal_widget(appwindow); | |
| 43 | - size_t ix; | |
| 44 | - | |
| 45 | - /* | |
| 46 | - GAction *action = pw3270_action_new_from_lib3270(lib3270_action_get_by_name("testpattern")); | |
| 47 | - pw3270_action_set_terminal_widget(action,terminal); | |
| 48 | - | |
| 49 | - debug("--> \"%s\"",pw3270_action_get_name(action)); | |
| 50 | - | |
| 51 | - g_action_map_add_action(map,action); | |
| 52 | - | |
| 53 | - debug("--> \"%s\"",pw3270_action_get_name(action)); | |
| 54 | - */ | |
| 55 | - | |
| 56 | - /* | |
| 57 | - GAction *action = pw3270_toggle_action_new_from_lib3270(lib3270_get_toggles() + LIB3270_TOGGLE_INSERT); | |
| 58 | - pw3270_action_set_terminal_widget(action,terminal); | |
| 59 | - | |
| 60 | - debug("--> \"%s\"",pw3270_action_get_name(action)); | |
| 61 | - | |
| 62 | - g_action_map_add_action(map,action); | |
| 63 | - | |
| 64 | - debug("--> \"%s\"",pw3270_action_get_name(action)); | |
| 65 | - */ | |
| 66 | - | |
| 67 | - // Map lib3270 actions | |
| 68 | - const LIB3270_ACTION * actions = lib3270_get_actions(); | |
| 69 | - for(ix = 0; actions[ix].name; ix++) { | |
| 70 | - | |
| 71 | - GAction *action = pw3270_action_new_from_lib3270(&actions[ix]); | |
| 72 | - pw3270_action_set_terminal_widget(action,terminal); | |
| 73 | - g_action_map_add_action(map,action); | |
| 74 | - | |
| 75 | - } | |
| 76 | - | |
| 77 | - // Map toggles | |
| 78 | - const LIB3270_TOGGLE * toggles = lib3270_get_toggles(); | |
| 79 | - for(ix = 0; toggles[ix].name; ix++) { | |
| 80 | - | |
| 81 | - GAction *action = pw3270_toggle_action_new_from_lib3270(&toggles[ix]); | |
| 82 | - pw3270_action_set_terminal_widget(action,terminal); | |
| 83 | - g_action_map_add_action(map,action); | |
| 84 | - | |
| 85 | - } | |
| 86 | - | |
| 87 | - g_action_map_add_action(map,pw3270_action_new_pfkey()); | |
| 88 | - g_action_map_add_action(map,pw3270_action_new_pakey()); | |
| 89 | - | |
| 90 | - debug("%s ends",__FUNCTION__); | |
| 91 | - } |
| ... | ... | @@ -0,0 +1,411 @@ |
| 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 "private.h" | |
| 31 | + #include <v3270.h> | |
| 32 | + | |
| 33 | + static void pw3270_action_iface_init(GActionInterface *iface); | |
| 34 | + static void pw3270Action_class_init(pw3270ActionClass *klass); | |
| 35 | + static void pw3270Action_init(pw3270Action *action); | |
| 36 | + static void pw3270_action_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); | |
| 37 | + static void pw3270_action_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); | |
| 38 | + static void pw3270_action_set_state(GAction *action, GVariant *value); | |
| 39 | + static gboolean pw3270_action_get_enabled(GAction *action); | |
| 40 | + static void pw3270_action_activate(GAction *action, GVariant *parameter); | |
| 41 | + | |
| 42 | + static gboolean get_enabled(GAction *action, GtkWidget *terminal); | |
| 43 | + static void activate(GAction *action, GVariant *parameter, GtkWidget *terminal); | |
| 44 | + static void change_widget(GAction *action, GtkWidget *from, GtkWidget *to); | |
| 45 | + | |
| 46 | + static void finalize(GObject *object); | |
| 47 | + | |
| 48 | + static const GVariantType * pw3270_action_get_state_type(GAction *action); | |
| 49 | + static GVariant * pw3270_action_get_state_property(GAction *action); | |
| 50 | + static const GVariantType * pw3270_action_get_parameter_type(GAction *action); | |
| 51 | + static GVariant * pw3270_action_get_state_hint(GAction *action); | |
| 52 | + static void pw3270_action_change_state(GAction *action, GVariant *value); | |
| 53 | + | |
| 54 | + enum { | |
| 55 | + PROP_NONE, | |
| 56 | + PROP_NAME, | |
| 57 | + PROP_PARAMETER_TYPE, | |
| 58 | + PROP_ENABLED, | |
| 59 | + PROP_STATE_TYPE, | |
| 60 | + PROP_STATE | |
| 61 | + }; | |
| 62 | + | |
| 63 | + enum { | |
| 64 | + SIGNAL_CHANGE_STATE, | |
| 65 | + NR_SIGNALS | |
| 66 | + }; | |
| 67 | + | |
| 68 | + static guint action_signals[NR_SIGNALS]; | |
| 69 | + | |
| 70 | + G_DEFINE_TYPE_WITH_CODE(pw3270Action, pw3270Action, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE(G_TYPE_ACTION, pw3270_action_iface_init)) | |
| 71 | + | |
| 72 | + void pw3270_action_iface_init(GActionInterface *iface) { | |
| 73 | + iface->get_name = pw3270_action_get_name; | |
| 74 | + iface->get_parameter_type = pw3270_action_get_parameter_type; | |
| 75 | + iface->get_state_type = pw3270_action_get_state_type; | |
| 76 | + iface->get_state_hint = pw3270_action_get_state_hint; | |
| 77 | + iface->get_enabled = pw3270_action_get_enabled; | |
| 78 | + iface->get_state = pw3270_action_get_state_property; | |
| 79 | + iface->change_state = pw3270_action_change_state; | |
| 80 | + iface->activate = pw3270_action_activate; | |
| 81 | + } | |
| 82 | + | |
| 83 | + static const GVariantType * get_parameter_type(GAction G_GNUC_UNUSED(*action)) | |
| 84 | + { | |
| 85 | + return NULL; | |
| 86 | + } | |
| 87 | + | |
| 88 | + void pw3270Action_class_init(pw3270ActionClass *klass) { | |
| 89 | + | |
| 90 | + GObjectClass *object_class = G_OBJECT_CLASS(klass); | |
| 91 | + | |
| 92 | + klass->change_widget = change_widget; | |
| 93 | + klass->get_enabled = get_enabled; | |
| 94 | + klass->activate = activate; | |
| 95 | + klass->get_parameter_type = get_parameter_type; | |
| 96 | + | |
| 97 | + object_class->finalize = finalize; | |
| 98 | + object_class->set_property = pw3270_action_set_property; | |
| 99 | + object_class->get_property = pw3270_action_get_property; | |
| 100 | + | |
| 101 | + // Install properties | |
| 102 | + g_object_class_install_property(object_class, PROP_NAME, | |
| 103 | + g_param_spec_string ("name", | |
| 104 | + N_("Action Name"), | |
| 105 | + N_("The name used to invoke the action"), | |
| 106 | + NULL, | |
| 107 | + G_PARAM_READWRITE | | |
| 108 | + G_PARAM_CONSTRUCT_ONLY | | |
| 109 | + G_PARAM_STATIC_STRINGS)); | |
| 110 | + | |
| 111 | + g_object_class_install_property (object_class, PROP_PARAMETER_TYPE, | |
| 112 | + g_param_spec_boxed ("parameter-type", | |
| 113 | + N_("Parameter Type"), | |
| 114 | + N_("The type of GVariant passed to activate()"), | |
| 115 | + G_TYPE_VARIANT_TYPE, | |
| 116 | + G_PARAM_READWRITE | | |
| 117 | + G_PARAM_CONSTRUCT_ONLY | | |
| 118 | + G_PARAM_STATIC_STRINGS)); | |
| 119 | + | |
| 120 | + g_object_class_install_property (object_class, PROP_STATE_TYPE, | |
| 121 | + g_param_spec_boxed ("state-type", | |
| 122 | + N_("State Type"), | |
| 123 | + N_("The type of the state kept by the action"), | |
| 124 | + G_TYPE_VARIANT_TYPE, | |
| 125 | + G_PARAM_READABLE | | |
| 126 | + G_PARAM_STATIC_STRINGS)); | |
| 127 | + | |
| 128 | + // Enabled property | |
| 129 | + klass->properties.enabled = | |
| 130 | + g_param_spec_boolean( | |
| 131 | + "enabled", | |
| 132 | + N_("Enabled"), | |
| 133 | + N_("If the action can be activated"), | |
| 134 | + TRUE, | |
| 135 | + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | |
| 136 | + ); | |
| 137 | + | |
| 138 | + g_object_class_install_property(object_class, PROP_ENABLED, klass->properties.enabled); | |
| 139 | + | |
| 140 | + // State property | |
| 141 | + klass->properties.state = | |
| 142 | + g_param_spec_variant( | |
| 143 | + "state", | |
| 144 | + N_("State"), | |
| 145 | + N_("The state the action is in"), | |
| 146 | + G_VARIANT_TYPE_ANY, | |
| 147 | + NULL, | |
| 148 | + G_PARAM_READWRITE | G_PARAM_CONSTRUCT | | |
| 149 | + G_PARAM_STATIC_STRINGS | |
| 150 | + ); | |
| 151 | + | |
| 152 | + g_object_class_install_property (object_class, PROP_STATE, klass->properties.state); | |
| 153 | + | |
| 154 | + // Install signals | |
| 155 | + action_signals[SIGNAL_CHANGE_STATE] = | |
| 156 | + g_signal_new( | |
| 157 | + I_("change-state"), | |
| 158 | + G_TYPE_SIMPLE_ACTION, | |
| 159 | + G_SIGNAL_RUN_LAST | G_SIGNAL_MUST_COLLECT, | |
| 160 | + 0, NULL, NULL, | |
| 161 | + NULL, | |
| 162 | + G_TYPE_NONE, 1, | |
| 163 | + G_TYPE_VARIANT | |
| 164 | + ); | |
| 165 | + } | |
| 166 | + | |
| 167 | + void pw3270Action_init(pw3270Action *action) { | |
| 168 | + | |
| 169 | + action->name = NULL; | |
| 170 | + action->terminal = NULL; | |
| 171 | + action->state = NULL; | |
| 172 | + | |
| 173 | + } | |
| 174 | + | |
| 175 | + void finalize(GObject *object) { | |
| 176 | + | |
| 177 | + pw3270Action * action = PW3270_ACTION(object); | |
| 178 | + | |
| 179 | + debug("Finalizing action %p (%s)",object,action->name); | |
| 180 | + | |
| 181 | + if(action->state) { | |
| 182 | + g_variant_unref(action->state); | |
| 183 | + action->state = NULL; | |
| 184 | + } | |
| 185 | + | |
| 186 | + if(action->terminal) { | |
| 187 | + pw3270_action_set_terminal_widget(G_ACTION(object),NULL); | |
| 188 | + action->terminal = NULL; | |
| 189 | + } | |
| 190 | + | |
| 191 | + if(action->name) { | |
| 192 | + g_free(action->name); | |
| 193 | + action->name = NULL; | |
| 194 | + } | |
| 195 | + | |
| 196 | + if(action->parameter_type) { | |
| 197 | + g_variant_type_free(action->parameter_type); | |
| 198 | + action->parameter_type = NULL; | |
| 199 | + } | |
| 200 | + | |
| 201 | + G_OBJECT_CLASS(pw3270Action_parent_class)->finalize(object); | |
| 202 | + | |
| 203 | + } | |
| 204 | + | |
| 205 | + | |
| 206 | + void pw3270_action_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { | |
| 207 | + | |
| 208 | + GAction *action = G_ACTION(object); | |
| 209 | + | |
| 210 | + debug("%s(%d)",__FUNCTION__,prop_id); | |
| 211 | + | |
| 212 | + switch (prop_id) { | |
| 213 | + case PROP_NAME: | |
| 214 | + g_value_set_string(value, pw3270_action_get_name(action)); | |
| 215 | + break; | |
| 216 | + | |
| 217 | + case PROP_PARAMETER_TYPE: | |
| 218 | + g_value_set_boxed(value, pw3270_action_get_parameter_type(action)); | |
| 219 | + break; | |
| 220 | + | |
| 221 | + case PROP_ENABLED: | |
| 222 | + g_value_set_boolean(value, pw3270_action_get_enabled(action)); | |
| 223 | + break; | |
| 224 | + | |
| 225 | + case PROP_STATE_TYPE: | |
| 226 | + g_value_set_boxed(value, pw3270_action_get_state_type(action)); | |
| 227 | + break; | |
| 228 | + | |
| 229 | + case PROP_STATE: | |
| 230 | + g_value_take_variant(value, pw3270_action_get_state_property(action)); | |
| 231 | + break; | |
| 232 | + | |
| 233 | + default: | |
| 234 | + g_assert_not_reached (); | |
| 235 | + } | |
| 236 | + | |
| 237 | + } | |
| 238 | + | |
| 239 | + void pw3270_action_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { | |
| 240 | + | |
| 241 | +// debug("%s(%d)",__FUNCTION__,prop_id); | |
| 242 | + | |
| 243 | + GAction *action = G_ACTION(object); | |
| 244 | + | |
| 245 | + switch (prop_id) | |
| 246 | + { | |
| 247 | + case PROP_NAME: | |
| 248 | + pw3270_action_set_name(action, g_value_get_string(value)); | |
| 249 | + break; | |
| 250 | + | |
| 251 | + case PROP_PARAMETER_TYPE: | |
| 252 | +// action->parameter_type = g_value_dup_boxed (value); | |
| 253 | + break; | |
| 254 | + | |
| 255 | + case PROP_ENABLED: | |
| 256 | +// action->enabled = g_value_get_boolean (value); | |
| 257 | + break; | |
| 258 | + | |
| 259 | + case PROP_STATE: | |
| 260 | + pw3270_action_set_state(action, g_value_get_variant(value)); | |
| 261 | + break; | |
| 262 | + | |
| 263 | + default: | |
| 264 | + g_assert_not_reached (); | |
| 265 | + } | |
| 266 | + | |
| 267 | + } | |
| 268 | + | |
| 269 | + const gchar * pw3270_action_get_name(GAction *action) { | |
| 270 | + return PW3270_ACTION(action)->name; | |
| 271 | + } | |
| 272 | + | |
| 273 | + void pw3270_action_set_name(GAction *object, const gchar *name) { | |
| 274 | + | |
| 275 | + pw3270Action * action = PW3270_ACTION(object); | |
| 276 | + | |
| 277 | +// debug("%s %s -> %s", __FUNCTION__, action->name, name); | |
| 278 | + | |
| 279 | + if(action->name) | |
| 280 | + g_free(action->name); | |
| 281 | + | |
| 282 | + if(name) | |
| 283 | + action->name = g_strdup(name); | |
| 284 | + else | |
| 285 | + action->name = NULL; | |
| 286 | + | |
| 287 | + } | |
| 288 | + | |
| 289 | + GVariant * pw3270_action_get_state_property(GAction *object) { | |
| 290 | + pw3270Action *action = PW3270_ACTION(object); | |
| 291 | + return action->state ? g_variant_ref(action->state) : NULL; | |
| 292 | + } | |
| 293 | + | |
| 294 | + const GVariantType * pw3270_action_get_parameter_type(GAction *action) { | |
| 295 | + return PW3270_ACTION_GET_CLASS(action)->get_parameter_type(action); | |
| 296 | + } | |
| 297 | + | |
| 298 | + const GVariantType * pw3270_action_get_state_type(GAction *object) { | |
| 299 | + | |
| 300 | + pw3270Action * action = PW3270_ACTION(object); | |
| 301 | + | |
| 302 | + if(action->state) | |
| 303 | + return g_variant_get_type(action->state); | |
| 304 | + | |
| 305 | + return NULL; | |
| 306 | + | |
| 307 | + } | |
| 308 | + | |
| 309 | + GVariant * pw3270_action_get_state_hint(GAction *action) { | |
| 310 | + debug("%s",__FUNCTION__); | |
| 311 | + return NULL; | |
| 312 | + } | |
| 313 | + | |
| 314 | + void pw3270_action_change_state(GAction *object, GVariant *value) { | |
| 315 | + pw3270_action_set_state(object, value); | |
| 316 | + } | |
| 317 | + | |
| 318 | + void pw3270_action_change_state_boolean(GAction *action, gboolean state) { | |
| 319 | + | |
| 320 | + g_return_if_fail(PW3270_IS_ACTION(action)); | |
| 321 | + pw3270_action_set_state(action,g_variant_new_boolean(state)); | |
| 322 | + | |
| 323 | + } | |
| 324 | + | |
| 325 | + void pw3270_action_set_state(GAction *object, GVariant *value) { | |
| 326 | + | |
| 327 | + if(value) { | |
| 328 | + | |
| 329 | + pw3270Action * action = PW3270_ACTION(object); | |
| 330 | + | |
| 331 | + g_variant_ref_sink(value); | |
| 332 | + | |
| 333 | + if (!action->state || !g_variant_equal(action->state, value)) { | |
| 334 | + | |
| 335 | + if(action->state) | |
| 336 | + g_variant_unref(action->state); | |
| 337 | + | |
| 338 | + action->state = g_variant_ref(value); | |
| 339 | + | |
| 340 | + if (g_signal_has_handler_pending(object, action_signals[SIGNAL_CHANGE_STATE], 0, TRUE)) { | |
| 341 | + g_signal_emit(object, action_signals[SIGNAL_CHANGE_STATE], 0, value); | |
| 342 | + } | |
| 343 | + | |
| 344 | + g_object_notify_by_pspec(G_OBJECT(object), PW3270_ACTION_GET_CLASS(object)->properties.state); | |
| 345 | + | |
| 346 | + } | |
| 347 | + | |
| 348 | + g_variant_unref(value); | |
| 349 | + | |
| 350 | + } | |
| 351 | + | |
| 352 | + } | |
| 353 | + | |
| 354 | + void pw3270_action_set_enabled(GAction *object, gboolean state) { | |
| 355 | + g_object_notify_by_pspec(G_OBJECT(object), PW3270_ACTION_GET_CLASS(object)->properties.enabled); | |
| 356 | + } | |
| 357 | + | |
| 358 | + | |
| 359 | + static void change_widget(GAction *action, GtkWidget G_GNUC_UNUSED(*from), GtkWidget *to) { | |
| 360 | + PW3270_ACTION(action)->terminal = to; | |
| 361 | + } | |
| 362 | + | |
| 363 | + void pw3270_action_set_terminal_widget(GAction *object, GtkWidget *widget) { | |
| 364 | + | |
| 365 | + g_return_if_fail(PW3270_IS_ACTION(object) && GTK_IS_V3270(widget)); | |
| 366 | + | |
| 367 | + pw3270Action * action = PW3270_ACTION(object); | |
| 368 | + | |
| 369 | + if(action->terminal != widget) { | |
| 370 | + PW3270_ACTION_GET_CLASS(object)->change_widget(object,action->terminal,widget); | |
| 371 | + action->terminal = widget; | |
| 372 | + } | |
| 373 | + | |
| 374 | + } | |
| 375 | + | |
| 376 | + gboolean pw3270_action_get_enabled(GAction *object) { | |
| 377 | + | |
| 378 | + pw3270Action * action = PW3270_ACTION(object); | |
| 379 | + | |
| 380 | +// debug("%s(%s) action=%p terminal=%p",__FUNCTION__,pw3270_action_get_name(object),action,action->terminal); | |
| 381 | + | |
| 382 | +// debug("%s: terminal=%p",__FUNCTION__,action->terminal); | |
| 383 | + | |
| 384 | + if(action && action->terminal) { | |
| 385 | + return PW3270_ACTION_GET_CLASS(object)->get_enabled(object,action->terminal); | |
| 386 | + } | |
| 387 | + | |
| 388 | + return FALSE; | |
| 389 | + | |
| 390 | + } | |
| 391 | + | |
| 392 | + void pw3270_action_activate(GAction *object, GVariant *parameter) { | |
| 393 | + | |
| 394 | + pw3270Action * action = PW3270_ACTION(object); | |
| 395 | + | |
| 396 | + debug("%s: terminal=%p",__FUNCTION__,action->terminal); | |
| 397 | + | |
| 398 | + if(action && action->terminal) { | |
| 399 | + PW3270_ACTION_GET_CLASS(object)->activate(object,parameter,action->terminal); | |
| 400 | + } | |
| 401 | + | |
| 402 | + } | |
| 403 | + | |
| 404 | + gboolean get_enabled(GAction *object, GtkWidget *terminal) { | |
| 405 | + debug("%s(%s)",__FUNCTION__,pw3270_action_get_name(object)); | |
| 406 | + return TRUE; | |
| 407 | + } | |
| 408 | + | |
| 409 | + void activate(GAction *action, GVariant G_GNUC_UNUSED(*parameter), GtkWidget G_GNUC_UNUSED(*terminal)) { | |
| 410 | + g_message("Action %s can't be activated",pw3270_action_get_name(action)); | |
| 411 | + } | ... | ... |
| ... | ... | @@ -0,0 +1,72 @@ |
| 1 | +<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | |
| 2 | +<CodeBlocks_project_file> | |
| 3 | + <FileVersion major="1" minor="6" /> | |
| 4 | + <Project> | |
| 5 | + <Option title="PW3270 Actions" /> | |
| 6 | + <Option pch_mode="2" /> | |
| 7 | + <Option compiler="gcc" /> | |
| 8 | + <Build> | |
| 9 | + <Target title="Debug"> | |
| 10 | + <Option output=".bin/Debug/PW3270 Actions" prefix_auto="1" extension_auto="1" /> | |
| 11 | + <Option object_output=".obj/Debug/" /> | |
| 12 | + <Option type="1" /> | |
| 13 | + <Option compiler="gcc" /> | |
| 14 | + <Compiler> | |
| 15 | + <Add option="-g" /> | |
| 16 | + <Add option="-DDEBUG=1" /> | |
| 17 | + </Compiler> | |
| 18 | + </Target> | |
| 19 | + <Target title="Release"> | |
| 20 | + <Option output=".bin/Release/PW3270 Actions" prefix_auto="1" extension_auto="1" /> | |
| 21 | + <Option object_output=".obj/Release/" /> | |
| 22 | + <Option type="1" /> | |
| 23 | + <Option compiler="gcc" /> | |
| 24 | + <Compiler> | |
| 25 | + <Add option="-O2" /> | |
| 26 | + <Add option="-DNDEBUG=1" /> | |
| 27 | + </Compiler> | |
| 28 | + <Linker> | |
| 29 | + <Add option="-s" /> | |
| 30 | + </Linker> | |
| 31 | + </Target> | |
| 32 | + </Build> | |
| 33 | + <Compiler> | |
| 34 | + <Add option="-Wall" /> | |
| 35 | + <Add option="`pkg-config --cflags gtk+-3.0 gio-2.0 glib-2.0 lib3270 libv3270`" /> | |
| 36 | + <Add directory="../../include" /> | |
| 37 | + </Compiler> | |
| 38 | + <Linker> | |
| 39 | + <Add option="`pkg-config --libs gtk+-3.0 gio-2.0 glib-2.0 lib3270 libv3270`" /> | |
| 40 | + </Linker> | |
| 41 | + <Unit filename="../include/pw3270/actions.h" /> | |
| 42 | + <Unit filename="../include/pw3270/window.h" /> | |
| 43 | + <Unit filename="abstract.c"> | |
| 44 | + <Option compilerVar="CC" /> | |
| 45 | + </Unit> | |
| 46 | + <Unit filename="lib3270/action.c"> | |
| 47 | + <Option compilerVar="CC" /> | |
| 48 | + </Unit> | |
| 49 | + <Unit filename="lib3270/pakey.c"> | |
| 50 | + <Option compilerVar="CC" /> | |
| 51 | + </Unit> | |
| 52 | + <Unit filename="lib3270/pfkey.c"> | |
| 53 | + <Option compilerVar="CC" /> | |
| 54 | + </Unit> | |
| 55 | + <Unit filename="lib3270/toggle.c"> | |
| 56 | + <Option compilerVar="CC" /> | |
| 57 | + </Unit> | |
| 58 | + <Unit filename="private.h" /> | |
| 59 | + <Unit filename="testprogram/testprogram.c"> | |
| 60 | + <Option compilerVar="CC" /> | |
| 61 | + </Unit> | |
| 62 | + <Unit filename="window.c"> | |
| 63 | + <Option compilerVar="CC" /> | |
| 64 | + </Unit> | |
| 65 | + <Extensions> | |
| 66 | + <code_completion /> | |
| 67 | + <envvars /> | |
| 68 | + <debugger /> | |
| 69 | + <lib_finder disable_auto="1" /> | |
| 70 | + </Extensions> | |
| 71 | + </Project> | |
| 72 | +</CodeBlocks_project_file> | ... | ... |
| ... | ... | @@ -0,0 +1,112 @@ |
| 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 | + /** | |
| 31 | + * @brief Implement GAction "wrapper" for lib3270's actions. | |
| 32 | + * | |
| 33 | + */ | |
| 34 | + | |
| 35 | + #include "../private.h" | |
| 36 | + #include <v3270.h> | |
| 37 | + | |
| 38 | + #define PW3270_TYPE_LIB3270_ACTION (Lib3270Action_get_type()) | |
| 39 | + #define PW3270_LIB3270_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), PW3270_TYPE_LIB3270_ACTION, Lib3270Action)) | |
| 40 | + #define PW3270_IS_LIB3270_ACTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), PW3270_TYPE_LIB3270_ACTION)) | |
| 41 | + | |
| 42 | + typedef struct _Lib3270ActionClass { | |
| 43 | + pw3270ActionClass parent_class; | |
| 44 | + | |
| 45 | + } Lib3270ActionClass; | |
| 46 | + | |
| 47 | + typedef struct _Lib3270Action { | |
| 48 | + pw3270Action parent; | |
| 49 | + | |
| 50 | + const LIB3270_ACTION * definition; | |
| 51 | + | |
| 52 | + } Lib3270Action; | |
| 53 | + | |
| 54 | + static void Lib3270Action_class_init(Lib3270ActionClass *klass); | |
| 55 | + static void Lib3270Action_init(Lib3270Action *action); | |
| 56 | + static void change_widget(GAction *object, GtkWidget *from, GtkWidget *to); | |
| 57 | + | |
| 58 | + G_DEFINE_TYPE(Lib3270Action, Lib3270Action, PW3270_TYPE_ACTION); | |
| 59 | + | |
| 60 | + static gboolean get_enabled(GAction *action, GtkWidget *terminal) { | |
| 61 | + | |
| 62 | + if(terminal) | |
| 63 | + return PW3270_LIB3270_ACTION(action)->definition->activatable(v3270_get_session(terminal)) > 0 ? TRUE : FALSE; | |
| 64 | + | |
| 65 | + return FALSE; | |
| 66 | + | |
| 67 | + } | |
| 68 | + | |
| 69 | + static void activate(GAction *action, GVariant *parameter, GtkWidget *terminal) { | |
| 70 | + PW3270_LIB3270_ACTION(action)->definition->activate(v3270_get_session(terminal)); | |
| 71 | + } | |
| 72 | + | |
| 73 | + void Lib3270Action_class_init(Lib3270ActionClass *klass) { | |
| 74 | + | |
| 75 | + pw3270ActionClass * action = PW3270_ACTION_CLASS(klass); | |
| 76 | + | |
| 77 | + action->activate = activate; | |
| 78 | + action->get_enabled = get_enabled; | |
| 79 | + action->change_widget = change_widget; | |
| 80 | + | |
| 81 | + } | |
| 82 | + | |
| 83 | + void Lib3270Action_init(Lib3270Action *action) { | |
| 84 | + } | |
| 85 | + | |
| 86 | + GAction * pw3270_action_new_from_lib3270(const LIB3270_ACTION * definition) { | |
| 87 | + | |
| 88 | + Lib3270Action * action = (Lib3270Action *) g_object_new(PW3270_TYPE_LIB3270_ACTION, NULL); | |
| 89 | + action->definition = definition; | |
| 90 | + | |
| 91 | + // Setup the default name. | |
| 92 | + pw3270Action * abstract = PW3270_ACTION(action); | |
| 93 | + | |
| 94 | + if(abstract->name) | |
| 95 | + g_free(abstract->name); | |
| 96 | + | |
| 97 | + abstract->name = g_strconcat("win.",definition->name,NULL); | |
| 98 | + | |
| 99 | + return G_ACTION(action); | |
| 100 | + } | |
| 101 | + | |
| 102 | + void change_widget(GAction *object, GtkWidget *from, GtkWidget *to) { | |
| 103 | + | |
| 104 | + PW3270_ACTION_CLASS(Lib3270Action_parent_class)->change_widget(object,from,to); | |
| 105 | + | |
| 106 | + // Does the "enabled" state has changed? If yes notify customers. | |
| 107 | + gboolean enabled = get_enabled(object,to); | |
| 108 | + if(get_enabled(object,from) != enabled) | |
| 109 | + pw3270_action_set_enabled(object,enabled); | |
| 110 | + | |
| 111 | + } | |
| 112 | + | ... | ... |
| ... | ... | @@ -0,0 +1,141 @@ |
| 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 | + /** | |
| 31 | + * @brief Implement GAction "wrapper" for lib3270's PAs. | |
| 32 | + * | |
| 33 | + */ | |
| 34 | + | |
| 35 | + #include "../private.h" | |
| 36 | + #include <v3270.h> | |
| 37 | + | |
| 38 | + #define PW3270_TYPE_PAKEY_ACTION (Lib3270PaAction_get_type()) | |
| 39 | + #define PW3270_LIB3270_PAKEY_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), PW3270_TYPE_PAKEY_ACTION, Lib3270PaAction)) | |
| 40 | + #define PW3270_IS_LIB3270_PAKEY_ACTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), PW3270_TYPE_PAKEY_ACTION)) | |
| 41 | + | |
| 42 | + typedef struct _Lib3270PaActionClass { | |
| 43 | + pw3270ActionClass parent_class; | |
| 44 | + | |
| 45 | + } Lib3270PaActionClass; | |
| 46 | + | |
| 47 | + typedef struct _Lib3270PaAction { | |
| 48 | + pw3270Action parent; | |
| 49 | + | |
| 50 | + } Lib3270PaAction; | |
| 51 | + | |
| 52 | + static void Lib3270PaAction_class_init(Lib3270PaActionClass *klass); | |
| 53 | + static void Lib3270PaAction_init(Lib3270PaAction *action); | |
| 54 | + static void change_widget(GAction *object, GtkWidget *from, GtkWidget *to); | |
| 55 | + | |
| 56 | + G_DEFINE_TYPE(Lib3270PaAction, Lib3270PaAction, PW3270_TYPE_ACTION); | |
| 57 | + | |
| 58 | + static gboolean get_enabled(GAction *action, GtkWidget *terminal) { | |
| 59 | + | |
| 60 | + debug("%s(%s)",__FUNCTION__,pw3270_action_get_name(action)); | |
| 61 | + | |
| 62 | + if(terminal) | |
| 63 | + return lib3270_is_connected(v3270_get_session(terminal)) > 0 ? TRUE: FALSE; | |
| 64 | + | |
| 65 | + return FALSE; | |
| 66 | + | |
| 67 | + } | |
| 68 | + | |
| 69 | + static void activate(GAction *action, GVariant *parameter, GtkWidget *terminal) { | |
| 70 | + | |
| 71 | + if(action && terminal && parameter) { | |
| 72 | + | |
| 73 | + H3270 * hSession = v3270_get_session(terminal); | |
| 74 | + | |
| 75 | + if(g_variant_is_of_type(parameter, G_VARIANT_TYPE_INT32)) { | |
| 76 | + | |
| 77 | + lib3270_pakey(hSession,(int) g_variant_get_int32(parameter)); | |
| 78 | + | |
| 79 | + } else if(g_variant_is_of_type(parameter, G_VARIANT_TYPE_UINT32)) { | |
| 80 | + | |
| 81 | + lib3270_pakey(hSession,(int) g_variant_get_uint32(parameter)); | |
| 82 | + | |
| 83 | + } else if(g_variant_is_of_type(parameter, G_VARIANT_TYPE_INT16)) { | |
| 84 | + | |
| 85 | + lib3270_pakey(hSession,(int) g_variant_get_int16(parameter)); | |
| 86 | + | |
| 87 | + } else if(g_variant_is_of_type(parameter, G_VARIANT_TYPE_UINT16)) { | |
| 88 | + | |
| 89 | + lib3270_pakey(hSession,(int) g_variant_get_uint16(parameter)); | |
| 90 | + | |
| 91 | + } | |
| 92 | + | |
| 93 | + } | |
| 94 | + | |
| 95 | + } | |
| 96 | + | |
| 97 | + static const GVariantType * get_parameter_type(GAction *action) | |
| 98 | + { | |
| 99 | + return G_VARIANT_TYPE_UINT16; | |
| 100 | + } | |
| 101 | + | |
| 102 | + void Lib3270PaAction_class_init(Lib3270PaActionClass *klass) { | |
| 103 | + | |
| 104 | + pw3270ActionClass * action = PW3270_ACTION_CLASS(klass); | |
| 105 | + | |
| 106 | + action->activate = activate; | |
| 107 | + action->get_enabled = get_enabled; | |
| 108 | + action->change_widget = change_widget; | |
| 109 | + action->get_parameter_type = get_parameter_type; | |
| 110 | + | |
| 111 | + } | |
| 112 | + | |
| 113 | + void Lib3270PaAction_init(Lib3270PaAction *action) { | |
| 114 | + } | |
| 115 | + | |
| 116 | + GAction * pw3270_action_new_pakey(void) { | |
| 117 | + | |
| 118 | + Lib3270PaAction * action = (Lib3270PaAction *) g_object_new(PW3270_TYPE_PAKEY_ACTION, NULL); | |
| 119 | + | |
| 120 | + // Setup the default name. | |
| 121 | + pw3270Action * abstract = PW3270_ACTION(action); | |
| 122 | + | |
| 123 | + if(abstract->name) | |
| 124 | + g_free(abstract->name); | |
| 125 | + | |
| 126 | + abstract->name = g_strdup("win.pakey"); | |
| 127 | + | |
| 128 | + return G_ACTION(action); | |
| 129 | + } | |
| 130 | + | |
| 131 | + void change_widget(GAction *object, GtkWidget *from, GtkWidget *to) { | |
| 132 | + | |
| 133 | + PW3270_ACTION_CLASS(Lib3270PaAction_parent_class)->change_widget(object,from,to); | |
| 134 | + | |
| 135 | + // Does the "enabled" state has changed? If yes notify customers. | |
| 136 | + gboolean enabled = get_enabled(object,to); | |
| 137 | + if(get_enabled(object,from) != enabled) | |
| 138 | + pw3270_action_set_enabled(object,enabled); | |
| 139 | + | |
| 140 | + } | |
| 141 | + | ... | ... |
| ... | ... | @@ -0,0 +1,142 @@ |
| 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 | + /** | |
| 31 | + * @brief Implement GAction "wrapper" for lib3270's PFs. | |
| 32 | + * | |
| 33 | + */ | |
| 34 | + | |
| 35 | + #include "../private.h" | |
| 36 | + #include <v3270.h> | |
| 37 | + | |
| 38 | + #define PW3270_TYPE_PFKEY_ACTION (Lib3270PfAction_get_type()) | |
| 39 | + #define PW3270_LIB3270_PFKEY_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), PW3270_TYPE_PFKEY_ACTION, Lib3270PfAction)) | |
| 40 | + #define PW3270_IS_LIB3270_PFKEY_ACTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), PW3270_TYPE_PFKEY_ACTION)) | |
| 41 | + | |
| 42 | + typedef struct _Lib3270PfActionClass { | |
| 43 | + pw3270ActionClass parent_class; | |
| 44 | + | |
| 45 | + } Lib3270PfActionClass; | |
| 46 | + | |
| 47 | + typedef struct _Lib3270PfAction { | |
| 48 | + pw3270Action parent; | |
| 49 | + | |
| 50 | + } Lib3270PfAction; | |
| 51 | + | |
| 52 | + static void Lib3270PfAction_class_init(Lib3270PfActionClass *klass); | |
| 53 | + static void Lib3270PfAction_init(Lib3270PfAction *action); | |
| 54 | + static void change_widget(GAction *object, GtkWidget *from, GtkWidget *to); | |
| 55 | + | |
| 56 | + G_DEFINE_TYPE(Lib3270PfAction, Lib3270PfAction, PW3270_TYPE_ACTION); | |
| 57 | + | |
| 58 | + static gboolean get_enabled(GAction *action, GtkWidget *terminal) { | |
| 59 | + | |
| 60 | + debug("%s(%s)",__FUNCTION__,pw3270_action_get_name(action)); | |
| 61 | + | |
| 62 | + if(terminal) | |
| 63 | + return lib3270_is_connected(v3270_get_session(terminal)) > 0 ? TRUE: FALSE; | |
| 64 | + | |
| 65 | + return FALSE; | |
| 66 | + | |
| 67 | + } | |
| 68 | + | |
| 69 | + static void activate(GAction *action, GVariant *parameter, GtkWidget *terminal) { | |
| 70 | + | |
| 71 | + if(action && terminal && parameter) { | |
| 72 | + | |
| 73 | + H3270 * hSession = v3270_get_session(terminal); | |
| 74 | + | |
| 75 | + if(g_variant_is_of_type(parameter, G_VARIANT_TYPE_INT32)) { | |
| 76 | + | |
| 77 | + lib3270_pfkey(hSession,(int) g_variant_get_int32(parameter)); | |
| 78 | + | |
| 79 | + } else if(g_variant_is_of_type(parameter, G_VARIANT_TYPE_UINT32)) { | |
| 80 | + | |
| 81 | + lib3270_pfkey(hSession,(int) g_variant_get_uint32(parameter)); | |
| 82 | + | |
| 83 | + } else if(g_variant_is_of_type(parameter, G_VARIANT_TYPE_INT16)) { | |
| 84 | + | |
| 85 | + lib3270_pfkey(hSession,(int) g_variant_get_int16(parameter)); | |
| 86 | + | |
| 87 | + } else if(g_variant_is_of_type(parameter, G_VARIANT_TYPE_UINT16)) { | |
| 88 | + | |
| 89 | + lib3270_pfkey(hSession,(int) g_variant_get_uint16(parameter)); | |
| 90 | + | |
| 91 | + } | |
| 92 | + | |
| 93 | + } | |
| 94 | + | |
| 95 | + } | |
| 96 | + | |
| 97 | + static const GVariantType * get_parameter_type(GAction *action) | |
| 98 | + { | |
| 99 | + return G_VARIANT_TYPE_UINT16; | |
| 100 | + } | |
| 101 | + | |
| 102 | + void Lib3270PfAction_class_init(Lib3270PfActionClass *klass) { | |
| 103 | + | |
| 104 | + pw3270ActionClass * action = PW3270_ACTION_CLASS(klass); | |
| 105 | + | |
| 106 | + action->activate = activate; | |
| 107 | + action->get_enabled = get_enabled; | |
| 108 | + action->change_widget = change_widget; | |
| 109 | + action->get_parameter_type = get_parameter_type; | |
| 110 | + | |
| 111 | + } | |
| 112 | + | |
| 113 | + void Lib3270PfAction_init(Lib3270PfAction *action) { | |
| 114 | + } | |
| 115 | + | |
| 116 | + GAction * pw3270_action_new_pfkey(void) { | |
| 117 | + | |
| 118 | + Lib3270PfAction * action = (Lib3270PfAction *) g_object_new(PW3270_TYPE_PFKEY_ACTION, NULL); | |
| 119 | + | |
| 120 | + // Setup the default name. | |
| 121 | + pw3270Action * abstract = PW3270_ACTION(action); | |
| 122 | + | |
| 123 | + if(abstract->name) | |
| 124 | + g_free(abstract->name); | |
| 125 | + | |
| 126 | + abstract->name = g_strdup("win.pfkey"); | |
| 127 | + | |
| 128 | + return G_ACTION(action); | |
| 129 | + | |
| 130 | + } | |
| 131 | + | |
| 132 | + void change_widget(GAction *object, GtkWidget *from, GtkWidget *to) { | |
| 133 | + | |
| 134 | + PW3270_ACTION_CLASS(Lib3270PfAction_parent_class)->change_widget(object,from,to); | |
| 135 | + | |
| 136 | + // Does the "enabled" state has changed? If yes notify customers. | |
| 137 | + gboolean enabled = get_enabled(object,to); | |
| 138 | + if(get_enabled(object,from) != enabled) | |
| 139 | + pw3270_action_set_enabled(object,enabled); | |
| 140 | + | |
| 141 | + } | |
| 142 | + | ... | ... |
| ... | ... | @@ -0,0 +1,133 @@ |
| 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 | + /** | |
| 31 | + * @brief Implement GAction "wrapper" for lib3270's toggles. | |
| 32 | + * | |
| 33 | + */ | |
| 34 | + | |
| 35 | + #include "../private.h" | |
| 36 | + #include <pw3270/window.h> | |
| 37 | + #include <v3270.h> | |
| 38 | + | |
| 39 | + #define PW3270_TYPE_LIB3270_TOGGLE_ACTION (Lib3270ToggleAction_get_type()) | |
| 40 | + #define PW3270_LIB3270_TOGGLE_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), PW3270_TYPE_LIB3270_TOGGLE_ACTION, Lib3270ToggleAction)) | |
| 41 | + #define PW3270_IS_LIB3270_TOGGLE_ACTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), PW3270_TYPE_LIB3270_TOGGLE_ACTION)) | |
| 42 | + | |
| 43 | + typedef struct _Lib3270ToggleActionClass { | |
| 44 | + pw3270ActionClass parent_class; | |
| 45 | + | |
| 46 | + } Lib3270ToggleActionClass; | |
| 47 | + | |
| 48 | + typedef struct _Lib3270ToggleAction { | |
| 49 | + pw3270Action parent; | |
| 50 | + | |
| 51 | + const LIB3270_TOGGLE * definition; | |
| 52 | + const void * listener; | |
| 53 | + | |
| 54 | + } Lib3270ToggleAction; | |
| 55 | + | |
| 56 | + static void Lib3270ToggleAction_class_init(Lib3270ToggleActionClass *klass); | |
| 57 | + static void Lib3270ToggleAction_init(Lib3270ToggleAction *action); | |
| 58 | + | |
| 59 | + G_DEFINE_TYPE(Lib3270ToggleAction, Lib3270ToggleAction, PW3270_TYPE_ACTION); | |
| 60 | + | |
| 61 | + static void change_state(H3270 *hSession, LIB3270_TOGGLE_ID id, char state, void * action) { | |
| 62 | + debug("%s: %s",__FUNCTION__,state ? "ON" : "OFF"); | |
| 63 | + pw3270_action_change_state_boolean((GAction *) action, state == 0 ? FALSE : TRUE); | |
| 64 | + } | |
| 65 | + | |
| 66 | + static void change_widget(GAction *object, GtkWidget *from, GtkWidget *to) { | |
| 67 | + | |
| 68 | + Lib3270ToggleAction * action = PW3270_LIB3270_TOGGLE_ACTION(object); | |
| 69 | + | |
| 70 | + if(action->listener) { | |
| 71 | + lib3270_unregister_toggle_listener(v3270_get_session(from),action->definition->id,object); | |
| 72 | + } | |
| 73 | + | |
| 74 | + if(to) { | |
| 75 | + action->listener = lib3270_register_toggle_listener(v3270_get_session(to),action->definition->id,change_state,object); | |
| 76 | + pw3270_action_change_state_boolean(object,lib3270_get_toggle(v3270_get_session(to),action->definition->id)); | |
| 77 | + } | |
| 78 | + | |
| 79 | + PW3270_ACTION_CLASS(Lib3270ToggleAction_parent_class)->change_widget(object,from,to); | |
| 80 | + | |
| 81 | + } | |
| 82 | + | |
| 83 | + static void activate(GAction *action, GVariant *parameter, GtkWidget *terminal) { | |
| 84 | + | |
| 85 | + debug("Activating \"%s\"",pw3270_action_get_name(action)); | |
| 86 | + | |
| 87 | + if(parameter && g_variant_is_of_type(parameter,G_VARIANT_TYPE_BOOLEAN)) { | |
| 88 | + | |
| 89 | + lib3270_set_toggle(v3270_get_session(terminal),PW3270_LIB3270_TOGGLE_ACTION(action)->definition->id,g_variant_get_boolean(parameter)); | |
| 90 | + debug("Toggle set to %s",lib3270_get_toggle(v3270_get_session(terminal),PW3270_LIB3270_TOGGLE_ACTION(action)->definition->id) ? "ON" : "OFF"); | |
| 91 | + | |
| 92 | + } else { | |
| 93 | + | |
| 94 | + lib3270_toggle(v3270_get_session(terminal),PW3270_LIB3270_TOGGLE_ACTION(action)->definition->id); | |
| 95 | + debug("Toggle is %s",lib3270_get_toggle(v3270_get_session(terminal),PW3270_LIB3270_TOGGLE_ACTION(action)->definition->id) ? "ON" : "OFF"); | |
| 96 | + | |
| 97 | + } | |
| 98 | + | |
| 99 | + } | |
| 100 | + | |
| 101 | + void Lib3270ToggleAction_class_init(Lib3270ToggleActionClass *klass) { | |
| 102 | + | |
| 103 | + pw3270ActionClass * action = PW3270_ACTION_CLASS(klass); | |
| 104 | + action->activate = activate; | |
| 105 | + action->change_widget = change_widget; | |
| 106 | + | |
| 107 | + } | |
| 108 | + | |
| 109 | + void Lib3270ToggleAction_init(Lib3270ToggleAction *action) { | |
| 110 | + | |
| 111 | + action->definition = NULL; | |
| 112 | + action->listener = NULL; | |
| 113 | + | |
| 114 | + } | |
| 115 | + | |
| 116 | + GAction * pw3270_toggle_action_new_from_lib3270(const LIB3270_TOGGLE * definition) { | |
| 117 | + | |
| 118 | + Lib3270ToggleAction * action = (Lib3270ToggleAction *) g_object_new(PW3270_TYPE_LIB3270_TOGGLE_ACTION, NULL); | |
| 119 | + action->definition = definition; | |
| 120 | + | |
| 121 | + // Setup the default name. | |
| 122 | + pw3270Action * abstract = PW3270_ACTION(action); | |
| 123 | + | |
| 124 | + if(abstract->name) | |
| 125 | + g_free(abstract->name); | |
| 126 | + | |
| 127 | + abstract->name = g_strconcat("win.",definition->name,NULL); | |
| 128 | + | |
| 129 | + return G_ACTION(action); | |
| 130 | + | |
| 131 | + } | |
| 132 | + | |
| 133 | + | ... | ... |
| ... | ... | @@ -0,0 +1,88 @@ |
| 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 | +#ifndef PRIVATE_H_INCLUDED | |
| 31 | + | |
| 32 | + #define PRIVATE_H_INCLUDED | |
| 33 | + | |
| 34 | + #include <config.h> | |
| 35 | + | |
| 36 | + #ifndef GETTEXT_PACKAGE | |
| 37 | + #define GETTEXT_PACKAGE PACKAGE_NAME | |
| 38 | + #endif | |
| 39 | + | |
| 40 | + #include <libintl.h> | |
| 41 | + #include <glib/gi18n.h> | |
| 42 | + #include <gtk/gtk.h> | |
| 43 | + | |
| 44 | + #include <pw3270/actions.h> | |
| 45 | + | |
| 46 | + #include <lib3270/actions.h> | |
| 47 | + #include <lib3270/toggle.h> | |
| 48 | + | |
| 49 | + #include <lib3270/log.h> | |
| 50 | + | |
| 51 | + /* not really I18N-related, but also a string marker macro */ | |
| 52 | + #define I_(string) g_intern_static_string (string) | |
| 53 | + | |
| 54 | + struct _pw3270Action { | |
| 55 | + GObject parent; | |
| 56 | + | |
| 57 | + GVariantType * parameter_type; | |
| 58 | + GVariant * state; | |
| 59 | + GtkWidget * terminal; | |
| 60 | + gchar * name; | |
| 61 | + | |
| 62 | + }; | |
| 63 | + | |
| 64 | + struct _pw3270ActionClass { | |
| 65 | + GObjectClass parent_class; | |
| 66 | + | |
| 67 | + struct { | |
| 68 | + GParamSpec * state; | |
| 69 | + GParamSpec * enabled; | |
| 70 | + } properties; | |
| 71 | + | |
| 72 | + void (*change_widget)(GAction *action, GtkWidget *from, GtkWidget *to); | |
| 73 | + gboolean (*get_enabled)(GAction *action, GtkWidget *terminal); | |
| 74 | + void (*activate)(GAction *action, GVariant *parameter, GtkWidget *terminal); | |
| 75 | + const GVariantType * (*get_parameter_type)(GAction *action); | |
| 76 | + | |
| 77 | + }; | |
| 78 | + | |
| 79 | + G_GNUC_INTERNAL GAction * pw3270_action_new_from_lib3270(const LIB3270_ACTION * definition); | |
| 80 | + G_GNUC_INTERNAL GAction * pw3270_toggle_action_new_from_lib3270(const LIB3270_TOGGLE * definition); | |
| 81 | + G_GNUC_INTERNAL GAction * pw3270_action_new_pfkey(void); | |
| 82 | + G_GNUC_INTERNAL GAction * pw3270_action_new_pakey(void); | |
| 83 | + | |
| 84 | + G_GNUC_INTERNAL void pw3270_action_change_state_boolean(GAction *action, gboolean state); | |
| 85 | + G_GNUC_INTERNAL void pw3270_action_set_enabled(GAction *action, gboolean state); | |
| 86 | + | |
| 87 | + | |
| 88 | +#endif // PRIVATE_H_INCLUDED | ... | ... |
| ... | ... | @@ -0,0 +1,133 @@ |
| 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. Registro no INPI sob | |
| 5 | + * o nome G3270. | |
| 6 | + * | |
| 7 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
| 8 | + * | |
| 9 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
| 10 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
| 11 | + * Free Software Foundation. | |
| 12 | + * | |
| 13 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
| 14 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
| 15 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
| 16 | + * obter mais detalhes. | |
| 17 | + * | |
| 18 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
| 19 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
| 20 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
| 21 | + * | |
| 22 | + * Este programa está nomeado como testprogram.c e possui - linhas de código. | |
| 23 | + * | |
| 24 | + * Contatos: | |
| 25 | + * | |
| 26 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
| 27 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
| 28 | + * | |
| 29 | + */ | |
| 30 | + | |
| 31 | + #include <config.h> | |
| 32 | + #include <v3270.h> | |
| 33 | + #include <v3270/trace.h> | |
| 34 | + #include <lib3270/log.h> | |
| 35 | + #include <lib3270/toggle.h> | |
| 36 | + #include <pw3270/actions.h> | |
| 37 | + #include "../private.h" | |
| 38 | + | |
| 39 | + /*---[ Implement ]----------------------------------------------------------------------------------*/ | |
| 40 | + | |
| 41 | + GtkWidget * pw3270_window_get_terminal_widget(GtkWidget *window) { | |
| 42 | + return g_object_get_data(G_OBJECT(window), "v3270_terminal"); | |
| 43 | + } | |
| 44 | + | |
| 45 | + /* | |
| 46 | + H3270 * pw3270_window_get_session_handle(GtkWidget *window) { | |
| 47 | + return v3270_get_session(pw3270_window_get_terminal_widget(window)); | |
| 48 | + } | |
| 49 | + */ | |
| 50 | + | |
| 51 | + static gboolean handle_command(GtkWidget *trace, const gchar *cmd, const gchar *args, GtkWidget *window) { | |
| 52 | + | |
| 53 | + if(!g_ascii_strcasecmp(cmd,"activate")) { | |
| 54 | + | |
| 55 | + GAction * action = g_action_map_lookup_action(G_ACTION_MAP(window),args); | |
| 56 | + | |
| 57 | + if(!action) { | |
| 58 | + g_message("Invalid action name: \"%s\"",args); | |
| 59 | + } else if(g_action_get_enabled(action)) { | |
| 60 | + g_message("Activating action \"%s\"",args); | |
| 61 | + g_action_activate(action,NULL); | |
| 62 | + } else { | |
| 63 | + g_message("Action \"%s\" is disabled",args); | |
| 64 | + } | |
| 65 | + | |
| 66 | + return TRUE; | |
| 67 | + } | |
| 68 | + | |
| 69 | + return FALSE; | |
| 70 | + } | |
| 71 | + | |
| 72 | + static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) { | |
| 73 | + | |
| 74 | + GtkWidget * window = gtk_application_window_new(app); | |
| 75 | + GtkWidget * terminal = v3270_new(); | |
| 76 | + GtkWidget * vBox = gtk_box_new(GTK_ORIENTATION_VERTICAL,2); | |
| 77 | + GtkWidget * notebook = gtk_notebook_new(); | |
| 78 | + GtkWidget * toolbar = gtk_toolbar_new(); | |
| 79 | + | |
| 80 | + g_object_set_data(G_OBJECT(window),"v3270_terminal",terminal); | |
| 81 | + | |
| 82 | + pw3270_window_add_actions(window); | |
| 83 | + | |
| 84 | + gtk_box_pack_start(GTK_BOX(vBox),toolbar,FALSE,TRUE,0); | |
| 85 | + gtk_box_pack_start(GTK_BOX(vBox),notebook,TRUE,TRUE,0); | |
| 86 | + | |
| 87 | + // Create Terminal window | |
| 88 | + { | |
| 89 | + gtk_widget_set_can_default(terminal,TRUE); | |
| 90 | + | |
| 91 | + gtk_notebook_append_page(GTK_NOTEBOOK(notebook),terminal,gtk_label_new("Terminal")); | |
| 92 | + | |
| 93 | +#ifdef _WIN32 | |
| 94 | + v3270_set_font_family(terminal,"Droid Sans Mono"); | |
| 95 | +#endif // _WIN32 | |
| 96 | + | |
| 97 | + } | |
| 98 | + | |
| 99 | + // Create trace window | |
| 100 | + GtkWidget * trace = v3270_trace_new(terminal); | |
| 101 | + gtk_notebook_append_page(GTK_NOTEBOOK(notebook),trace,gtk_label_new("Trace")); | |
| 102 | + | |
| 103 | + g_signal_connect(trace,"command",G_CALLBACK(handle_command),window); | |
| 104 | + | |
| 105 | + // Setup and show main window | |
| 106 | + gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER); | |
| 107 | + gtk_window_set_default_size (GTK_WINDOW (window), 800, 500); | |
| 108 | + gtk_container_add(GTK_CONTAINER(window),vBox); | |
| 109 | + gtk_widget_show_all(window); | |
| 110 | + | |
| 111 | + gtk_widget_grab_focus(terminal); | |
| 112 | + | |
| 113 | +} | |
| 114 | + | |
| 115 | +int main (int argc, char **argv) { | |
| 116 | + | |
| 117 | + GtkApplication *app; | |
| 118 | + int status; | |
| 119 | + | |
| 120 | + app = gtk_application_new ("br.com.bb.pw3270",G_APPLICATION_FLAGS_NONE); | |
| 121 | + | |
| 122 | + g_signal_connect (app, "activate", G_CALLBACK(activate), NULL); | |
| 123 | + | |
| 124 | + status = g_application_run (G_APPLICATION (app), argc, argv); | |
| 125 | + g_object_unref (app); | |
| 126 | + | |
| 127 | + g_message("rc=%d",status); | |
| 128 | + | |
| 129 | + return 0; | |
| 130 | + | |
| 131 | +} | |
| 132 | + | |
| 133 | + | ... | ... |
| ... | ... | @@ -0,0 +1,105 @@ |
| 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 | + /** | |
| 31 | + * @brief Integrate pw3270 actions with the application window. | |
| 32 | + * | |
| 33 | + */ | |
| 34 | + | |
| 35 | + #include "private.h" | |
| 36 | + #include <lib3270/actions.h> | |
| 37 | + #include <pw3270/window.h> | |
| 38 | + | |
| 39 | + void pw3270_window_add_actions(GtkWidget * appwindow) { | |
| 40 | + | |
| 41 | + GActionMap * map = G_ACTION_MAP(appwindow); | |
| 42 | + GtkWidget * terminal = pw3270_window_get_terminal_widget(appwindow); | |
| 43 | + size_t ix; | |
| 44 | + | |
| 45 | + /* | |
| 46 | + GAction *action = pw3270_action_new_from_lib3270(lib3270_action_get_by_name("testpattern")); | |
| 47 | + pw3270_action_set_terminal_widget(action,terminal); | |
| 48 | + | |
| 49 | + debug("--> \"%s\"",pw3270_action_get_name(action)); | |
| 50 | + | |
| 51 | + g_action_map_add_action(map,action); | |
| 52 | + | |
| 53 | + debug("--> \"%s\"",pw3270_action_get_name(action)); | |
| 54 | + */ | |
| 55 | + | |
| 56 | + /* | |
| 57 | + GAction *action = pw3270_toggle_action_new_from_lib3270(lib3270_get_toggles() + LIB3270_TOGGLE_INSERT); | |
| 58 | + pw3270_action_set_terminal_widget(action,terminal); | |
| 59 | + | |
| 60 | + debug("--> \"%s\"",pw3270_action_get_name(action)); | |
| 61 | + | |
| 62 | + g_action_map_add_action(map,action); | |
| 63 | + | |
| 64 | + debug("--> \"%s\"",pw3270_action_get_name(action)); | |
| 65 | + */ | |
| 66 | + | |
| 67 | + // Map lib3270 actions | |
| 68 | + { | |
| 69 | + const LIB3270_ACTION * actions = lib3270_get_actions(); | |
| 70 | + for(ix = 0; actions[ix].name; ix++) { | |
| 71 | + | |
| 72 | + GAction *action = pw3270_action_new_from_lib3270(&actions[ix]); | |
| 73 | + pw3270_action_set_terminal_widget(action,terminal); | |
| 74 | + g_action_map_add_action(map,action); | |
| 75 | + | |
| 76 | + } | |
| 77 | + } | |
| 78 | + | |
| 79 | + // Map toggles | |
| 80 | + { | |
| 81 | + const LIB3270_TOGGLE * toggles = lib3270_get_toggles(); | |
| 82 | + for(ix = 0; toggles[ix].name; ix++) { | |
| 83 | + | |
| 84 | + GAction *action = pw3270_toggle_action_new_from_lib3270(&toggles[ix]); | |
| 85 | + pw3270_action_set_terminal_widget(action,terminal); | |
| 86 | + g_action_map_add_action(map,action); | |
| 87 | + | |
| 88 | + } | |
| 89 | + } | |
| 90 | + | |
| 91 | + // Map special actions | |
| 92 | + { | |
| 93 | + GAction * actions[] = { | |
| 94 | + pw3270_action_new_pfkey(), | |
| 95 | + pw3270_action_new_pakey() | |
| 96 | + }; | |
| 97 | + | |
| 98 | + for(ix = 0; ix < G_N_ELEMENTS(actions); ix++) { | |
| 99 | + pw3270_action_set_terminal_widget(actions[ix],terminal); | |
| 100 | + g_action_map_add_action(map,actions[ix]); | |
| 101 | + } | |
| 102 | + } | |
| 103 | + | |
| 104 | + debug("%s ends",__FUNCTION__); | |
| 105 | + } | ... | ... |
| ... | ... | @@ -0,0 +1,258 @@ |
| 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 "private.h" | |
| 31 | + | |
| 32 | + static gboolean popup_context_menu(GtkToolbar *toolbar, gint x, gint y, gint button_number); | |
| 33 | + static void finalize(GObject *object); | |
| 34 | + | |
| 35 | + | |
| 36 | + struct _pw3270ToolBar { | |
| 37 | + GtkToolbar parent; | |
| 38 | + | |
| 39 | + /// @brief Popup Menu | |
| 40 | + GtkWidget * popup_menu; | |
| 41 | + | |
| 42 | + }; | |
| 43 | + | |
| 44 | + struct _pw3270ToolBarClass { | |
| 45 | + | |
| 46 | + GtkToolbarClass parent_class; | |
| 47 | + | |
| 48 | + | |
| 49 | + }; | |
| 50 | + | |
| 51 | + G_DEFINE_TYPE(pw3270ToolBar, pw3270ToolBar, GTK_TYPE_TOOLBAR); | |
| 52 | + | |
| 53 | + static void pw3270ToolBar_class_init(pw3270ToolBarClass *klass) { | |
| 54 | + | |
| 55 | + GtkToolbarClass * toolbar = GTK_TOOLBAR_CLASS(klass); | |
| 56 | + | |
| 57 | + toolbar->popup_context_menu = popup_context_menu; | |
| 58 | + | |
| 59 | + G_OBJECT_CLASS(klass)->finalize = finalize; | |
| 60 | + | |
| 61 | + } | |
| 62 | + | |
| 63 | + static void detacher(GtkWidget *attach_widget, GtkMenu *menu) { | |
| 64 | + | |
| 65 | + pw3270ToolBar * toolbar = PW3270_TOOLBAR(attach_widget); | |
| 66 | + toolbar->popup_menu = NULL; | |
| 67 | + | |
| 68 | + } | |
| 69 | + | |
| 70 | + static void set_icon_size(GtkMenuItem *menuitem, GtkWidget *toolbar) { | |
| 71 | + | |
| 72 | + GtkIconSize * icon_size = g_object_get_data(G_OBJECT(menuitem),"icon_size"); | |
| 73 | + | |
| 74 | + if(icon_size) | |
| 75 | + gtk_toolbar_set_icon_size(GTK_TOOLBAR(toolbar),*icon_size); | |
| 76 | + else | |
| 77 | + gtk_toolbar_unset_icon_size(GTK_TOOLBAR(toolbar)); | |
| 78 | + | |
| 79 | + } | |
| 80 | + | |
| 81 | + static void set_style(GtkMenuItem *menuitem, GtkWidget *toolbar) { | |
| 82 | + | |
| 83 | + GtkToolbarStyle * style = g_object_get_data(G_OBJECT(menuitem),"toolbar_style"); | |
| 84 | + | |
| 85 | + if(style) | |
| 86 | + gtk_toolbar_set_style(GTK_TOOLBAR(toolbar),*style); | |
| 87 | + else | |
| 88 | + gtk_toolbar_unset_style(GTK_TOOLBAR(toolbar)); | |
| 89 | + | |
| 90 | + } | |
| 91 | + | |
| 92 | + static void pw3270ToolBar_init(pw3270ToolBar *widget) { | |
| 93 | + | |
| 94 | + widget->popup_menu = gtk_menu_new(); | |
| 95 | + | |
| 96 | + // Size options | |
| 97 | + { | |
| 98 | + static const struct { | |
| 99 | + const gchar * label; | |
| 100 | + GtkIconSize icon_size; | |
| 101 | + } itens[] = { | |
| 102 | + | |
| 103 | + { | |
| 104 | + .label = N_( "System default" ) | |
| 105 | + | |
| 106 | + }, | |
| 107 | + | |
| 108 | + { | |
| 109 | + .label = N_( "Small" ), | |
| 110 | + .icon_size = GTK_ICON_SIZE_SMALL_TOOLBAR | |
| 111 | + }, | |
| 112 | + | |
| 113 | + { | |
| 114 | + .label = N_( "Large" ), | |
| 115 | + .icon_size = GTK_ICON_SIZE_LARGE_TOOLBAR | |
| 116 | + }, | |
| 117 | + }; | |
| 118 | + | |
| 119 | + size_t ix; | |
| 120 | + | |
| 121 | + GtkWidget * item = gtk_menu_item_new_with_mnemonic( _("Icon _size") ); | |
| 122 | + gtk_menu_shell_append(GTK_MENU_SHELL(widget->popup_menu),item); | |
| 123 | + | |
| 124 | + GtkWidget * submenu = gtk_menu_new(); | |
| 125 | + gtk_menu_item_set_submenu(GTK_MENU_ITEM(item),submenu); | |
| 126 | + | |
| 127 | + for(ix = 0; ix < G_N_ELEMENTS(itens); ix++) { | |
| 128 | + | |
| 129 | + item = gtk_menu_item_new_with_mnemonic(gettext(itens[ix].label)); | |
| 130 | + | |
| 131 | + if(ix > 0) | |
| 132 | + g_object_set_data(G_OBJECT(item),"icon_size", (gpointer) &itens[ix].icon_size); | |
| 133 | + | |
| 134 | + g_signal_connect(item, "activate", G_CALLBACK(set_icon_size), widget); | |
| 135 | + | |
| 136 | + gtk_menu_shell_append(GTK_MENU_SHELL(submenu),item); | |
| 137 | + | |
| 138 | + } | |
| 139 | + | |
| 140 | + } | |
| 141 | + | |
| 142 | + // Style option | |
| 143 | + { | |
| 144 | + static const struct { | |
| 145 | + const gchar * label; | |
| 146 | + GtkToolbarStyle style; | |
| 147 | + } itens[] = { | |
| 148 | + | |
| 149 | + { | |
| 150 | + .label = N_( "System default" ) | |
| 151 | + }, | |
| 152 | + | |
| 153 | + { | |
| 154 | + .label = N_( "Icons only" ), | |
| 155 | + .style = GTK_TOOLBAR_ICONS | |
| 156 | + }, | |
| 157 | + | |
| 158 | + { | |
| 159 | + .label = N_( "Text only" ), | |
| 160 | + .style = GTK_TOOLBAR_TEXT | |
| 161 | + }, | |
| 162 | + | |
| 163 | + { | |
| 164 | + .label = N_( "Icons & text" ), | |
| 165 | + .style = GTK_TOOLBAR_BOTH | |
| 166 | + }, | |
| 167 | + }; | |
| 168 | + | |
| 169 | + size_t ix; | |
| 170 | + | |
| 171 | + GtkWidget * item = gtk_menu_item_new_with_mnemonic( _("S_tyle") ); | |
| 172 | + gtk_menu_shell_append(GTK_MENU_SHELL(widget->popup_menu),item); | |
| 173 | + | |
| 174 | + GtkWidget * submenu = gtk_menu_new(); | |
| 175 | + gtk_menu_item_set_submenu(GTK_MENU_ITEM(item),submenu); | |
| 176 | + | |
| 177 | + for(ix = 0; ix < G_N_ELEMENTS(itens); ix++) { | |
| 178 | + | |
| 179 | + item = gtk_menu_item_new_with_mnemonic(gettext(itens[ix].label)); | |
| 180 | + | |
| 181 | + if(ix > 0) | |
| 182 | + g_object_set_data(G_OBJECT(item),"toolbar_style", (gpointer) &itens[ix].style); | |
| 183 | + | |
| 184 | + g_signal_connect(item, "activate", G_CALLBACK(set_style), widget); | |
| 185 | + | |
| 186 | + gtk_menu_shell_append(GTK_MENU_SHELL(submenu),item); | |
| 187 | + | |
| 188 | + } | |
| 189 | + | |
| 190 | + } | |
| 191 | + | |
| 192 | + // gtk_container_set_border_width(GTK_CONTAINER(widget->popup_menu),6); | |
| 193 | + gtk_widget_show_all(widget->popup_menu); | |
| 194 | + gtk_menu_attach_to_widget(GTK_MENU(widget->popup_menu),GTK_WIDGET(widget),detacher); | |
| 195 | + | |
| 196 | + } | |
| 197 | + | |
| 198 | + static void finalize(GObject *object) { | |
| 199 | + | |
| 200 | +// pw3270ToolBar * toolbar = PW3270_TOOLBAR(object); | |
| 201 | + | |
| 202 | + | |
| 203 | + G_OBJECT_CLASS(pw3270ToolBar_parent_class)->finalize(object); | |
| 204 | + | |
| 205 | + } | |
| 206 | + | |
| 207 | + GtkWidget * pw3270_toolbar_new(void) { | |
| 208 | + return g_object_new(PW3270_TYPE_TOOLBAR, NULL); | |
| 209 | + } | |
| 210 | + | |
| 211 | + GtkWidget * pw3270_toolbar_insert_lib3270_action(GtkWidget *toolbar, const LIB3270_ACTION *action, gint pos) { | |
| 212 | + | |
| 213 | + g_return_val_if_fail(GTK_IS_TOOLBAR(toolbar),NULL); | |
| 214 | + | |
| 215 | + if(!action) { | |
| 216 | + g_message(_("Invalid action identifier")); | |
| 217 | + return NULL; | |
| 218 | + } | |
| 219 | + | |
| 220 | + if(!action->icon) { | |
| 221 | + g_message(_("Action \"%s\" doesn't have an icon"), action->name); | |
| 222 | + return NULL; | |
| 223 | + } | |
| 224 | + | |
| 225 | + if(!action->label) { | |
| 226 | + g_message(_("Action \"%s\" doesn't have a label"), action->name); | |
| 227 | + return NULL; | |
| 228 | + } | |
| 229 | + | |
| 230 | + debug("Action: %s icon: %s", action->name, action->icon); | |
| 231 | + | |
| 232 | + GtkToolItem * item = gtk_tool_button_new(gtk_image_new_from_icon_name(action->icon,GTK_ICON_SIZE_LARGE_TOOLBAR),gettext(action->label)); | |
| 233 | + gtk_tool_button_set_use_underline(GTK_TOOL_BUTTON(item),TRUE); | |
| 234 | + | |
| 235 | + gtk_widget_set_name(GTK_WIDGET(item), action->name); | |
| 236 | + | |
| 237 | + if(action->summary) | |
| 238 | + gtk_tool_item_set_tooltip_text(item,gettext(action->summary)); | |
| 239 | + | |
| 240 | + gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, pos); | |
| 241 | + | |
| 242 | + return GTK_WIDGET(item); | |
| 243 | + } | |
| 244 | + | |
| 245 | + gboolean popup_context_menu(GtkToolbar *widget, gint x, gint y, gint button_number) { | |
| 246 | + | |
| 247 | + pw3270ToolBar * toolbar = PW3270_TOOLBAR(widget); | |
| 248 | + | |
| 249 | + debug("%s button_number=%d",__FUNCTION__,button_number); | |
| 250 | + | |
| 251 | + if(toolbar->popup_menu) { | |
| 252 | + gtk_menu_popup_at_pointer(GTK_MENU(toolbar->popup_menu),NULL); | |
| 253 | + } | |
| 254 | + | |
| 255 | + | |
| 256 | + return TRUE; | |
| 257 | + | |
| 258 | + } | ... | ... |
| ... | ... | @@ -0,0 +1,47 @@ |
| 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 | +#ifndef PRIVATE_H_INCLUDED | |
| 31 | + | |
| 32 | + #define PRIVATE_H_INCLUDED | |
| 33 | + | |
| 34 | + #include <config.h> | |
| 35 | + | |
| 36 | + #ifndef GETTEXT_PACKAGE | |
| 37 | + #define GETTEXT_PACKAGE PACKAGE_NAME | |
| 38 | + #endif | |
| 39 | + | |
| 40 | + #include <libintl.h> | |
| 41 | + #include <glib/gi18n.h> | |
| 42 | + #include <gtk/gtk.h> | |
| 43 | + | |
| 44 | + #include <pw3270/toolbar.h> | |
| 45 | + #include <lib3270/log.h> | |
| 46 | + | |
| 47 | +#endif // PRIVATE_H_INCLUDED | ... | ... |
| ... | ... | @@ -0,0 +1,110 @@ |
| 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. Registro no INPI sob | |
| 5 | + * o nome G3270. | |
| 6 | + * | |
| 7 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
| 8 | + * | |
| 9 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
| 10 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
| 11 | + * Free Software Foundation. | |
| 12 | + * | |
| 13 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
| 14 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
| 15 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
| 16 | + * obter mais detalhes. | |
| 17 | + * | |
| 18 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
| 19 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
| 20 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
| 21 | + * | |
| 22 | + * Este programa está nomeado como testprogram.c e possui - linhas de código. | |
| 23 | + * | |
| 24 | + * Contatos: | |
| 25 | + * | |
| 26 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
| 27 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
| 28 | + * | |
| 29 | + */ | |
| 30 | + | |
| 31 | + #include <config.h> | |
| 32 | + #include <pw3270/toolbar.h> | |
| 33 | + #include <v3270.h> | |
| 34 | + #include <v3270/trace.h> | |
| 35 | + #include <lib3270/log.h> | |
| 36 | + | |
| 37 | + /*---[ Implement ]----------------------------------------------------------------------------------*/ | |
| 38 | + | |
| 39 | + static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) { | |
| 40 | + | |
| 41 | + GtkWidget * window = gtk_application_window_new(app); | |
| 42 | + GtkWidget * terminal = v3270_new(); | |
| 43 | + GtkWidget * vBox = gtk_box_new(GTK_ORIENTATION_VERTICAL,2); | |
| 44 | + GtkWidget * notebook = gtk_notebook_new(); | |
| 45 | + GtkWidget * toolbar = pw3270_toolbar_new(); | |
| 46 | + | |
| 47 | + { | |
| 48 | + // Setup toolbar | |
| 49 | + static const char * action_names[] = { | |
| 50 | + "reconnect", | |
| 51 | + "disconnect", | |
| 52 | + "selectall", | |
| 53 | + "unselect" | |
| 54 | + }; | |
| 55 | + | |
| 56 | + size_t ix; | |
| 57 | + | |
| 58 | + for(ix = 0; ix < G_N_ELEMENTS(action_names); ix++) { | |
| 59 | + pw3270_toolbar_insert_lib3270_action(toolbar, lib3270_action_get_by_name(action_names[ix]), -1); | |
| 60 | + } | |
| 61 | + | |
| 62 | + } | |
| 63 | + | |
| 64 | + gtk_box_pack_start(GTK_BOX(vBox),toolbar,FALSE,TRUE,0); | |
| 65 | + gtk_box_pack_start(GTK_BOX(vBox),notebook,TRUE,TRUE,0); | |
| 66 | + | |
| 67 | + // Create Terminal window | |
| 68 | + { | |
| 69 | + gtk_widget_set_can_default(terminal,TRUE); | |
| 70 | + | |
| 71 | + gtk_notebook_append_page(GTK_NOTEBOOK(notebook),terminal,gtk_label_new("Terminal")); | |
| 72 | + | |
| 73 | +#ifdef _WIN32 | |
| 74 | + v3270_set_font_family(terminal,"Droid Sans Mono"); | |
| 75 | +#endif // _WIN32 | |
| 76 | + | |
| 77 | + } | |
| 78 | + | |
| 79 | + // Create trace window | |
| 80 | + gtk_notebook_append_page(GTK_NOTEBOOK(notebook),v3270_trace_new(terminal),gtk_label_new("Trace")); | |
| 81 | + | |
| 82 | + // Setup and show main window | |
| 83 | + gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER); | |
| 84 | + gtk_window_set_default_size (GTK_WINDOW (window), 800, 500); | |
| 85 | + gtk_container_add(GTK_CONTAINER(window),vBox); | |
| 86 | + gtk_widget_show_all(window); | |
| 87 | + | |
| 88 | + gtk_widget_grab_focus(terminal); | |
| 89 | + | |
| 90 | +} | |
| 91 | + | |
| 92 | +int main (int argc, char **argv) { | |
| 93 | + | |
| 94 | + GtkApplication *app; | |
| 95 | + int status; | |
| 96 | + | |
| 97 | + app = gtk_application_new ("br.com.bb.pw3270",G_APPLICATION_FLAGS_NONE); | |
| 98 | + | |
| 99 | + g_signal_connect (app, "activate", G_CALLBACK(activate), NULL); | |
| 100 | + | |
| 101 | + status = g_application_run (G_APPLICATION (app), argc, argv); | |
| 102 | + g_object_unref (app); | |
| 103 | + | |
| 104 | + g_message("rc=%d",status); | |
| 105 | + | |
| 106 | + return 0; | |
| 107 | + | |
| 108 | +} | |
| 109 | + | |
| 110 | + | ... | ... |
| ... | ... | @@ -0,0 +1,55 @@ |
| 1 | +<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | |
| 2 | +<CodeBlocks_project_file> | |
| 3 | + <FileVersion major="1" minor="6" /> | |
| 4 | + <Project> | |
| 5 | + <Option title="pw3270 V5.2 toolbar" /> | |
| 6 | + <Option pch_mode="2" /> | |
| 7 | + <Option compiler="gcc" /> | |
| 8 | + <Build> | |
| 9 | + <Target title="Debug"> | |
| 10 | + <Option output=".bin/Debug/toolbar" prefix_auto="1" extension_auto="1" /> | |
| 11 | + <Option object_output=".obj/Debug/" /> | |
| 12 | + <Option type="1" /> | |
| 13 | + <Option compiler="gcc" /> | |
| 14 | + <Compiler> | |
| 15 | + <Add option="-g" /> | |
| 16 | + <Add option="-DDEBUG=1" /> | |
| 17 | + </Compiler> | |
| 18 | + </Target> | |
| 19 | + <Target title="Release"> | |
| 20 | + <Option output=".bin/Release/pw3270 V5" prefix_auto="1" extension_auto="1" /> | |
| 21 | + <Option object_output=".obj/Release/" /> | |
| 22 | + <Option type="1" /> | |
| 23 | + <Option compiler="gcc" /> | |
| 24 | + <Compiler> | |
| 25 | + <Add option="-O2" /> | |
| 26 | + <Add option="-DNDEBUG=1" /> | |
| 27 | + </Compiler> | |
| 28 | + <Linker> | |
| 29 | + <Add option="-s" /> | |
| 30 | + </Linker> | |
| 31 | + </Target> | |
| 32 | + </Build> | |
| 33 | + <Compiler> | |
| 34 | + <Add option="-Wall" /> | |
| 35 | + <Add option="`pkg-config --cflags gtk+-3.0 lib3270 libv3270`" /> | |
| 36 | + <Add directory="../../include" /> | |
| 37 | + </Compiler> | |
| 38 | + <Linker> | |
| 39 | + <Add option="`pkg-config --libs gtk+-3.0 lib3270 libv3270`" /> | |
| 40 | + </Linker> | |
| 41 | + <Unit filename="../../include/pw3270/toolbar.h" /> | |
| 42 | + <Unit filename="core.c"> | |
| 43 | + <Option compilerVar="CC" /> | |
| 44 | + </Unit> | |
| 45 | + <Unit filename="private.h" /> | |
| 46 | + <Unit filename="testprogram/testprogram.c"> | |
| 47 | + <Option compilerVar="CC" /> | |
| 48 | + </Unit> | |
| 49 | + <Extensions> | |
| 50 | + <code_completion /> | |
| 51 | + <envvars /> | |
| 52 | + <debugger /> | |
| 53 | + </Extensions> | |
| 54 | + </Project> | |
| 55 | +</CodeBlocks_project_file> | ... | ... |
| ... | ... | @@ -0,0 +1,64 @@ |
| 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 "private.h" | |
| 31 | + #include <pw3270/toolbar.h> | |
| 32 | + | |
| 33 | + G_DEFINE_TYPE(pw3270ApplicationWindow, pw3270ApplicationWindow, GTK_TYPE_APPLICATION_WINDOW); | |
| 34 | + | |
| 35 | + static void pw3270ApplicationWindow_class_init(pw3270ApplicationWindowClass *klass) { | |
| 36 | + | |
| 37 | + } | |
| 38 | + | |
| 39 | + static void pw3270ApplicationWindow_init(pw3270ApplicationWindow *widget) { | |
| 40 | + | |
| 41 | + GtkBox * vBox = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL,0)); | |
| 42 | + | |
| 43 | + widget->notebook = GTK_NOTEBOOK(gtk_notebook_new()); | |
| 44 | + widget->terminal = pw3270_terminal_new(GTK_WIDGET(widget)); | |
| 45 | + widget->toolbar = GTK_TOOLBAR(pw3270_toolbar_new()); | |
| 46 | + | |
| 47 | + gtk_notebook_set_show_tabs(widget->notebook,FALSE); | |
| 48 | + gtk_notebook_set_show_border(widget->notebook, FALSE); | |
| 49 | + | |
| 50 | + gtk_box_pack_start(vBox,GTK_WIDGET(widget->toolbar),FALSE,TRUE,0); | |
| 51 | + gtk_box_pack_start(vBox,GTK_WIDGET(widget->notebook),TRUE,TRUE,0); | |
| 52 | + | |
| 53 | + gtk_container_add(GTK_CONTAINER(widget),GTK_WIDGET(vBox)); | |
| 54 | + gtk_widget_show_all(GTK_WIDGET(widget)); | |
| 55 | + | |
| 56 | + } | |
| 57 | + | |
| 58 | + GtkWidget * pw3270_application_window_new(GtkApplication * application) { | |
| 59 | + | |
| 60 | + g_return_val_if_fail(GTK_IS_APPLICATION(application), NULL); | |
| 61 | + return g_object_new(PW3270_TYPE_APPLICATION_WINDOW, "application", application, NULL); | |
| 62 | + | |
| 63 | + } | |
| 64 | + | ... | ... |
| ... | ... | @@ -0,0 +1,65 @@ |
| 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 | +#ifndef PRIVATE_H_INCLUDED | |
| 31 | + | |
| 32 | + #define PRIVATE_H_INCLUDED | |
| 33 | + | |
| 34 | + #include <config.h> | |
| 35 | + | |
| 36 | + #ifndef GETTEXT_PACKAGE | |
| 37 | + #define GETTEXT_PACKAGE PACKAGE_NAME | |
| 38 | + #endif | |
| 39 | + | |
| 40 | + #include <libintl.h> | |
| 41 | + #include <glib/gi18n.h> | |
| 42 | + #include <gtk/gtk.h> | |
| 43 | + | |
| 44 | + #include <pw3270/window.h> | |
| 45 | + #include <v3270.h> | |
| 46 | + #include <lib3270.h> | |
| 47 | + #include <lib3270/log.h> | |
| 48 | + | |
| 49 | + struct _pw3270ApplicationWindow { | |
| 50 | + | |
| 51 | + GtkApplicationWindow parent; | |
| 52 | + | |
| 53 | + GtkWidget * terminal; | |
| 54 | + GtkNotebook * notebook; | |
| 55 | + GtkToolbar * toolbar; | |
| 56 | + | |
| 57 | + }; | |
| 58 | + | |
| 59 | + struct _pw3270ApplicationWindowClass { | |
| 60 | + | |
| 61 | + GtkApplicationWindowClass parent_class; | |
| 62 | + | |
| 63 | + }; | |
| 64 | + | |
| 65 | +#endif // PRIVATE_H_INCLUDED | ... | ... |
| ... | ... | @@ -0,0 +1,81 @@ |
| 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 "private.h" | |
| 31 | + #include <pw3270/actions.h> | |
| 32 | + | |
| 33 | + static void session_changed(GtkWidget *terminal, GtkWidget *label) { | |
| 34 | + | |
| 35 | + gtk_label_set_text(GTK_LABEL(label),v3270_get_session_name(terminal)); | |
| 36 | + | |
| 37 | + // Do I have to change the window title? | |
| 38 | + GtkWidget * toplevel = gtk_widget_get_toplevel(terminal); | |
| 39 | + if(PW3270_IS_APPLICATION_WINDOW(toplevel)) { | |
| 40 | + | |
| 41 | + pw3270ApplicationWindow * window = PW3270_APPLICATION_WINDOW(toplevel); | |
| 42 | + | |
| 43 | + if(window->terminal == terminal) { | |
| 44 | + g_autofree gchar * title = v3270_get_session_title(terminal); | |
| 45 | + gtk_window_set_title(GTK_WINDOW(window), title); | |
| 46 | + } | |
| 47 | + | |
| 48 | + } | |
| 49 | + | |
| 50 | + } | |
| 51 | + | |
| 52 | + static gboolean on_terminal_focus(GtkWidget *terminal, GdkEvent *event, pw3270ApplicationWindow * window) { | |
| 53 | + | |
| 54 | + // Store the active terminal widget. | |
| 55 | + window->terminal = terminal; | |
| 56 | + | |
| 57 | + // Change window title | |
| 58 | + g_autofree gchar * title = v3270_get_session_title(terminal); | |
| 59 | + gtk_window_set_title(GTK_WINDOW(window), title); | |
| 60 | + | |
| 61 | + return FALSE; | |
| 62 | + } | |
| 63 | + | |
| 64 | + GtkWidget * pw3270_terminal_new(GtkWidget *widget) { | |
| 65 | + | |
| 66 | + g_return_val_if_fail(PW3270_IS_APPLICATION_WINDOW(widget),NULL); | |
| 67 | + | |
| 68 | + pw3270ApplicationWindow * window = PW3270_APPLICATION_WINDOW(widget); | |
| 69 | + GtkWidget * terminal = v3270_new(); | |
| 70 | + GtkWidget * label = gtk_label_new(v3270_get_session_name(terminal)); | |
| 71 | + | |
| 72 | + g_signal_connect(G_OBJECT(terminal), "focus-in-event", G_CALLBACK(on_terminal_focus), widget); | |
| 73 | + g_signal_connect(G_OBJECT(terminal), "session_changed", G_CALLBACK(session_changed),label); | |
| 74 | + | |
| 75 | + gtk_notebook_append_page(GTK_NOTEBOOK(window->notebook),terminal,label); | |
| 76 | + gtk_notebook_set_show_tabs(GTK_NOTEBOOK(window->notebook),gtk_notebook_get_n_pages(GTK_NOTEBOOK(window->notebook)) > 1); | |
| 77 | + | |
| 78 | + return terminal; | |
| 79 | + | |
| 80 | + } | |
| 81 | + | ... | ... |
| ... | ... | @@ -0,0 +1,106 @@ |
| 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. Registro no INPI sob | |
| 5 | + * o nome G3270. | |
| 6 | + * | |
| 7 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
| 8 | + * | |
| 9 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
| 10 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
| 11 | + * Free Software Foundation. | |
| 12 | + * | |
| 13 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
| 14 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
| 15 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
| 16 | + * obter mais detalhes. | |
| 17 | + * | |
| 18 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
| 19 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
| 20 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
| 21 | + * | |
| 22 | + * Este programa está nomeado como testprogram.c e possui - linhas de código. | |
| 23 | + * | |
| 24 | + * Contatos: | |
| 25 | + * | |
| 26 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
| 27 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
| 28 | + * | |
| 29 | + */ | |
| 30 | + | |
| 31 | + #include <config.h> | |
| 32 | + #include <pw3270/window.h> | |
| 33 | + #include <pw3270/toolbar.h> | |
| 34 | + #include <v3270.h> | |
| 35 | + #include <v3270/trace.h> | |
| 36 | + #include <lib3270/log.h> | |
| 37 | + | |
| 38 | + /*---[ Implement ]----------------------------------------------------------------------------------*/ | |
| 39 | + | |
| 40 | + static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) { | |
| 41 | + | |
| 42 | + GtkWidget * window = pw3270_application_window_new(app); | |
| 43 | + | |
| 44 | + // Create terminal widget | |
| 45 | + pw3270_terminal_new(window); | |
| 46 | + pw3270_terminal_new(window); | |
| 47 | + | |
| 48 | + // Setup and show main window | |
| 49 | + gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER); | |
| 50 | + gtk_window_set_default_size (GTK_WINDOW (window), 800, 500); | |
| 51 | + gtk_widget_show_all(window); | |
| 52 | + | |
| 53 | +} | |
| 54 | + | |
| 55 | +GtkWidget * pw3270_toolbar_new(void) { | |
| 56 | + | |
| 57 | + static const struct _item { | |
| 58 | + const gchar *icon; | |
| 59 | + const gchar *label; | |
| 60 | + } itens[] = { | |
| 61 | + | |
| 62 | + { | |
| 63 | + "gtk-connect", | |
| 64 | + "_Connect" | |
| 65 | + }, | |
| 66 | + | |
| 67 | + { | |
| 68 | + "gtk-disconnect", | |
| 69 | + "_Disconnect" | |
| 70 | + } | |
| 71 | + | |
| 72 | + }; | |
| 73 | + | |
| 74 | + GtkWidget * toolbar = gtk_toolbar_new(); | |
| 75 | + size_t item; | |
| 76 | + | |
| 77 | + for(item = 0; item < G_N_ELEMENTS(itens); item++) { | |
| 78 | + | |
| 79 | + GtkToolItem * button = gtk_tool_button_new(gtk_image_new_from_icon_name(itens[item].icon,GTK_ICON_SIZE_LARGE_TOOLBAR),itens[item].label); | |
| 80 | + gtk_tool_button_set_use_underline(GTK_TOOL_BUTTON(button),TRUE); | |
| 81 | + gtk_toolbar_insert(GTK_TOOLBAR(toolbar), button, -1); | |
| 82 | + | |
| 83 | + } | |
| 84 | + | |
| 85 | + return toolbar; | |
| 86 | +} | |
| 87 | + | |
| 88 | +int main (int argc, char **argv) { | |
| 89 | + | |
| 90 | + GtkApplication *app; | |
| 91 | + int status; | |
| 92 | + | |
| 93 | + app = gtk_application_new ("br.com.bb.pw3270",G_APPLICATION_FLAGS_NONE); | |
| 94 | + | |
| 95 | + g_signal_connect (app, "activate", G_CALLBACK(activate), NULL); | |
| 96 | + | |
| 97 | + status = g_application_run (G_APPLICATION (app), argc, argv); | |
| 98 | + g_object_unref (app); | |
| 99 | + | |
| 100 | + g_message("rc=%d",status); | |
| 101 | + | |
| 102 | + return 0; | |
| 103 | + | |
| 104 | +} | |
| 105 | + | |
| 106 | + | ... | ... |
| ... | ... | @@ -0,0 +1,61 @@ |
| 1 | +<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | |
| 2 | +<CodeBlocks_project_file> | |
| 3 | + <FileVersion major="1" minor="6" /> | |
| 4 | + <Project> | |
| 5 | + <Option title="PW3270 Application Window" /> | |
| 6 | + <Option pch_mode="2" /> | |
| 7 | + <Option compiler="gcc" /> | |
| 8 | + <Build> | |
| 9 | + <Target title="Debug"> | |
| 10 | + <Option output=".bin/Debug/PW3270 Application Window" prefix_auto="1" extension_auto="1" /> | |
| 11 | + <Option object_output=".obj/Debug/" /> | |
| 12 | + <Option type="1" /> | |
| 13 | + <Option compiler="gcc" /> | |
| 14 | + <Compiler> | |
| 15 | + <Add option="-g" /> | |
| 16 | + <Add option="-DDEBUG=1" /> | |
| 17 | + </Compiler> | |
| 18 | + </Target> | |
| 19 | + <Target title="Release"> | |
| 20 | + <Option output=".bin/Release/PW3270 Application Window" prefix_auto="1" extension_auto="1" /> | |
| 21 | + <Option object_output=".obj/Release/" /> | |
| 22 | + <Option type="1" /> | |
| 23 | + <Option compiler="gcc" /> | |
| 24 | + <Compiler> | |
| 25 | + <Add option="-O2" /> | |
| 26 | + <Add option="-DNDEBUG=1" /> | |
| 27 | + </Compiler> | |
| 28 | + <Linker> | |
| 29 | + <Add option="-s" /> | |
| 30 | + </Linker> | |
| 31 | + </Target> | |
| 32 | + </Build> | |
| 33 | + <Compiler> | |
| 34 | + <Add option="-Wall" /> | |
| 35 | + <Add option="`pkg-config --cflags gtk+-3.0 libv3270`" /> | |
| 36 | + <Add directory="../../include" /> | |
| 37 | + </Compiler> | |
| 38 | + <Linker> | |
| 39 | + <Add option="`pkg-config --libs gtk+-3.0 libv3270`" /> | |
| 40 | + </Linker> | |
| 41 | + <Unit filename="../../include/pw3270/actions.h" /> | |
| 42 | + <Unit filename="../../include/pw3270/toolbar.h" /> | |
| 43 | + <Unit filename="../../include/pw3270/window.h" /> | |
| 44 | + <Unit filename="init.c"> | |
| 45 | + <Option compilerVar="CC" /> | |
| 46 | + </Unit> | |
| 47 | + <Unit filename="private.h" /> | |
| 48 | + <Unit filename="terminal.c"> | |
| 49 | + <Option compilerVar="CC" /> | |
| 50 | + </Unit> | |
| 51 | + <Unit filename="testprogram/testprogram.c"> | |
| 52 | + <Option compilerVar="CC" /> | |
| 53 | + </Unit> | |
| 54 | + <Extensions> | |
| 55 | + <code_completion /> | |
| 56 | + <envvars /> | |
| 57 | + <debugger /> | |
| 58 | + <lib_finder disable_auto="1" /> | |
| 59 | + </Extensions> | |
| 60 | + </Project> | |
| 61 | +</CodeBlocks_project_file> | ... | ... |
src/widgets/toolbar/core.c
| ... | ... | @@ -1,258 +0,0 @@ |
| 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 "private.h" | |
| 31 | - | |
| 32 | - static gboolean popup_context_menu(GtkToolbar *toolbar, gint x, gint y, gint button_number); | |
| 33 | - static void finalize(GObject *object); | |
| 34 | - | |
| 35 | - | |
| 36 | - struct _pw3270ToolBar { | |
| 37 | - GtkToolbar parent; | |
| 38 | - | |
| 39 | - /// @brief Popup Menu | |
| 40 | - GtkWidget * popup_menu; | |
| 41 | - | |
| 42 | - }; | |
| 43 | - | |
| 44 | - struct _pw3270ToolBarClass { | |
| 45 | - | |
| 46 | - GtkToolbarClass parent_class; | |
| 47 | - | |
| 48 | - | |
| 49 | - }; | |
| 50 | - | |
| 51 | - G_DEFINE_TYPE(pw3270ToolBar, pw3270ToolBar, GTK_TYPE_TOOLBAR); | |
| 52 | - | |
| 53 | - static void pw3270ToolBar_class_init(pw3270ToolBarClass *klass) { | |
| 54 | - | |
| 55 | - GtkToolbarClass * toolbar = GTK_TOOLBAR_CLASS(klass); | |
| 56 | - | |
| 57 | - toolbar->popup_context_menu = popup_context_menu; | |
| 58 | - | |
| 59 | - G_OBJECT_CLASS(klass)->finalize = finalize; | |
| 60 | - | |
| 61 | - } | |
| 62 | - | |
| 63 | - static void detacher(GtkWidget *attach_widget, GtkMenu *menu) { | |
| 64 | - | |
| 65 | - pw3270ToolBar * toolbar = PW3270_TOOLBAR(attach_widget); | |
| 66 | - toolbar->popup_menu = NULL; | |
| 67 | - | |
| 68 | - } | |
| 69 | - | |
| 70 | - static void set_icon_size(GtkMenuItem *menuitem, GtkWidget *toolbar) { | |
| 71 | - | |
| 72 | - GtkIconSize * icon_size = g_object_get_data(G_OBJECT(menuitem),"icon_size"); | |
| 73 | - | |
| 74 | - if(icon_size) | |
| 75 | - gtk_toolbar_set_icon_size(GTK_TOOLBAR(toolbar),*icon_size); | |
| 76 | - else | |
| 77 | - gtk_toolbar_unset_icon_size(GTK_TOOLBAR(toolbar)); | |
| 78 | - | |
| 79 | - } | |
| 80 | - | |
| 81 | - static void set_style(GtkMenuItem *menuitem, GtkWidget *toolbar) { | |
| 82 | - | |
| 83 | - GtkToolbarStyle * style = g_object_get_data(G_OBJECT(menuitem),"toolbar_style"); | |
| 84 | - | |
| 85 | - if(style) | |
| 86 | - gtk_toolbar_set_style(GTK_TOOLBAR(toolbar),*style); | |
| 87 | - else | |
| 88 | - gtk_toolbar_unset_style(GTK_TOOLBAR(toolbar)); | |
| 89 | - | |
| 90 | - } | |
| 91 | - | |
| 92 | - static void pw3270ToolBar_init(pw3270ToolBar *widget) { | |
| 93 | - | |
| 94 | - widget->popup_menu = gtk_menu_new(); | |
| 95 | - | |
| 96 | - // Size options | |
| 97 | - { | |
| 98 | - static const struct { | |
| 99 | - const gchar * label; | |
| 100 | - GtkIconSize icon_size; | |
| 101 | - } itens[] = { | |
| 102 | - | |
| 103 | - { | |
| 104 | - .label = N_( "Default" ) | |
| 105 | - | |
| 106 | - }, | |
| 107 | - | |
| 108 | - { | |
| 109 | - .label = N_( "Small" ), | |
| 110 | - .icon_size = GTK_ICON_SIZE_SMALL_TOOLBAR | |
| 111 | - }, | |
| 112 | - | |
| 113 | - { | |
| 114 | - .label = N_( "Large" ), | |
| 115 | - .icon_size = GTK_ICON_SIZE_LARGE_TOOLBAR | |
| 116 | - }, | |
| 117 | - }; | |
| 118 | - | |
| 119 | - size_t ix; | |
| 120 | - | |
| 121 | - GtkWidget * item = gtk_menu_item_new_with_mnemonic( _("Icon _size") ); | |
| 122 | - gtk_menu_shell_append(GTK_MENU_SHELL(widget->popup_menu),item); | |
| 123 | - | |
| 124 | - GtkWidget * submenu = gtk_menu_new(); | |
| 125 | - gtk_menu_item_set_submenu(GTK_MENU_ITEM(item),submenu); | |
| 126 | - | |
| 127 | - for(ix = 0; ix < G_N_ELEMENTS(itens); ix++) { | |
| 128 | - | |
| 129 | - item = gtk_menu_item_new_with_mnemonic(gettext(itens[ix].label)); | |
| 130 | - | |
| 131 | - if(ix > 0) | |
| 132 | - g_object_set_data(G_OBJECT(item),"icon_size", (gpointer) &itens[ix].icon_size); | |
| 133 | - | |
| 134 | - g_signal_connect(item, "activate", G_CALLBACK(set_icon_size), widget); | |
| 135 | - | |
| 136 | - gtk_menu_shell_append(GTK_MENU_SHELL(submenu),item); | |
| 137 | - | |
| 138 | - } | |
| 139 | - | |
| 140 | - } | |
| 141 | - | |
| 142 | - // Style option | |
| 143 | - { | |
| 144 | - static const struct { | |
| 145 | - const gchar * label; | |
| 146 | - GtkToolbarStyle style; | |
| 147 | - } itens[] = { | |
| 148 | - | |
| 149 | - { | |
| 150 | - .label = N_( "Default" ) | |
| 151 | - }, | |
| 152 | - | |
| 153 | - { | |
| 154 | - .label = N_( "Icons only" ), | |
| 155 | - .style = GTK_TOOLBAR_ICONS | |
| 156 | - }, | |
| 157 | - | |
| 158 | - { | |
| 159 | - .label = N_( "Text only" ), | |
| 160 | - .style = GTK_TOOLBAR_TEXT | |
| 161 | - }, | |
| 162 | - | |
| 163 | - { | |
| 164 | - .label = N_( "Icons & text" ), | |
| 165 | - .style = GTK_TOOLBAR_BOTH | |
| 166 | - }, | |
| 167 | - }; | |
| 168 | - | |
| 169 | - size_t ix; | |
| 170 | - | |
| 171 | - GtkWidget * item = gtk_menu_item_new_with_mnemonic( _("S_tyle") ); | |
| 172 | - gtk_menu_shell_append(GTK_MENU_SHELL(widget->popup_menu),item); | |
| 173 | - | |
| 174 | - GtkWidget * submenu = gtk_menu_new(); | |
| 175 | - gtk_menu_item_set_submenu(GTK_MENU_ITEM(item),submenu); | |
| 176 | - | |
| 177 | - for(ix = 0; ix < G_N_ELEMENTS(itens); ix++) { | |
| 178 | - | |
| 179 | - item = gtk_menu_item_new_with_mnemonic(gettext(itens[ix].label)); | |
| 180 | - | |
| 181 | - if(ix > 0) | |
| 182 | - g_object_set_data(G_OBJECT(item),"toolbar_style", (gpointer) &itens[ix].style); | |
| 183 | - | |
| 184 | - g_signal_connect(item, "activate", G_CALLBACK(set_style), widget); | |
| 185 | - | |
| 186 | - gtk_menu_shell_append(GTK_MENU_SHELL(submenu),item); | |
| 187 | - | |
| 188 | - } | |
| 189 | - | |
| 190 | - } | |
| 191 | - | |
| 192 | - // gtk_container_set_border_width(GTK_CONTAINER(widget->popup_menu),6); | |
| 193 | - gtk_widget_show_all(widget->popup_menu); | |
| 194 | - gtk_menu_attach_to_widget(GTK_MENU(widget->popup_menu),GTK_WIDGET(widget),detacher); | |
| 195 | - | |
| 196 | - } | |
| 197 | - | |
| 198 | - static void finalize(GObject *object) { | |
| 199 | - | |
| 200 | -// pw3270ToolBar * toolbar = PW3270_TOOLBAR(object); | |
| 201 | - | |
| 202 | - | |
| 203 | - G_OBJECT_CLASS(pw3270ToolBar_parent_class)->finalize(object); | |
| 204 | - | |
| 205 | - } | |
| 206 | - | |
| 207 | - GtkWidget * pw3270_toolbar_new(void) { | |
| 208 | - return g_object_new(PW3270_TYPE_TOOLBAR, NULL); | |
| 209 | - } | |
| 210 | - | |
| 211 | - GtkWidget * pw3270_toolbar_insert_lib3270_action(GtkWidget *toolbar, const LIB3270_ACTION *action, gint pos) { | |
| 212 | - | |
| 213 | - g_return_val_if_fail(GTK_IS_TOOLBAR(toolbar),NULL); | |
| 214 | - | |
| 215 | - if(!action) { | |
| 216 | - g_message(_("Invalid action identifier")); | |
| 217 | - return NULL; | |
| 218 | - } | |
| 219 | - | |
| 220 | - if(!action->icon) { | |
| 221 | - g_message(_("Action \"%s\" doesn't have an icon"), action->name); | |
| 222 | - return NULL; | |
| 223 | - } | |
| 224 | - | |
| 225 | - if(!action->label) { | |
| 226 | - g_message(_("Action \"%s\" doesn't have a label"), action->name); | |
| 227 | - return NULL; | |
| 228 | - } | |
| 229 | - | |
| 230 | - debug("Action: %s icon: %s", action->name, action->icon); | |
| 231 | - | |
| 232 | - GtkToolItem * item = gtk_tool_button_new(gtk_image_new_from_icon_name(action->icon,GTK_ICON_SIZE_LARGE_TOOLBAR),gettext(action->label)); | |
| 233 | - gtk_tool_button_set_use_underline(GTK_TOOL_BUTTON(item),TRUE); | |
| 234 | - | |
| 235 | - gtk_widget_set_name(GTK_WIDGET(item), action->name); | |
| 236 | - | |
| 237 | - if(action->summary) | |
| 238 | - gtk_tool_item_set_tooltip_text(item,gettext(action->summary)); | |
| 239 | - | |
| 240 | - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, pos); | |
| 241 | - | |
| 242 | - return GTK_WIDGET(item); | |
| 243 | - } | |
| 244 | - | |
| 245 | - gboolean popup_context_menu(GtkToolbar *widget, gint x, gint y, gint button_number) { | |
| 246 | - | |
| 247 | - pw3270ToolBar * toolbar = PW3270_TOOLBAR(widget); | |
| 248 | - | |
| 249 | - debug("%s button_number=%d",__FUNCTION__,button_number); | |
| 250 | - | |
| 251 | - if(toolbar->popup_menu) { | |
| 252 | - gtk_menu_popup_at_pointer(GTK_MENU(toolbar->popup_menu),NULL); | |
| 253 | - } | |
| 254 | - | |
| 255 | - | |
| 256 | - return TRUE; | |
| 257 | - | |
| 258 | - } |
src/widgets/toolbar/private.h
| ... | ... | @@ -1,47 +0,0 @@ |
| 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 | -#ifndef PRIVATE_H_INCLUDED | |
| 31 | - | |
| 32 | - #define PRIVATE_H_INCLUDED | |
| 33 | - | |
| 34 | - #include <config.h> | |
| 35 | - | |
| 36 | - #ifndef GETTEXT_PACKAGE | |
| 37 | - #define GETTEXT_PACKAGE PACKAGE_NAME | |
| 38 | - #endif | |
| 39 | - | |
| 40 | - #include <libintl.h> | |
| 41 | - #include <glib/gi18n.h> | |
| 42 | - #include <gtk/gtk.h> | |
| 43 | - | |
| 44 | - #include <pw3270/toolbar.h> | |
| 45 | - #include <lib3270/log.h> | |
| 46 | - | |
| 47 | -#endif // PRIVATE_H_INCLUDED |
src/widgets/toolbar/testprogram/testprogram.c
| ... | ... | @@ -1,110 +0,0 @@ |
| 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. Registro no INPI sob | |
| 5 | - * o nome G3270. | |
| 6 | - * | |
| 7 | - * Copyright (C) <2008> <Banco do Brasil S.A.> | |
| 8 | - * | |
| 9 | - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
| 10 | - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
| 11 | - * Free Software Foundation. | |
| 12 | - * | |
| 13 | - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
| 14 | - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
| 15 | - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
| 16 | - * obter mais detalhes. | |
| 17 | - * | |
| 18 | - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
| 19 | - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
| 20 | - * St, Fifth Floor, Boston, MA 02110-1301 USA | |
| 21 | - * | |
| 22 | - * Este programa está nomeado como testprogram.c e possui - linhas de código. | |
| 23 | - * | |
| 24 | - * Contatos: | |
| 25 | - * | |
| 26 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
| 27 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
| 28 | - * | |
| 29 | - */ | |
| 30 | - | |
| 31 | - #include <config.h> | |
| 32 | - #include <pw3270/toolbar.h> | |
| 33 | - #include <v3270.h> | |
| 34 | - #include <v3270/trace.h> | |
| 35 | - #include <lib3270/log.h> | |
| 36 | - | |
| 37 | - /*---[ Implement ]----------------------------------------------------------------------------------*/ | |
| 38 | - | |
| 39 | - static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) { | |
| 40 | - | |
| 41 | - GtkWidget * window = gtk_application_window_new(app); | |
| 42 | - GtkWidget * terminal = v3270_new(); | |
| 43 | - GtkWidget * vBox = gtk_box_new(GTK_ORIENTATION_VERTICAL,2); | |
| 44 | - GtkWidget * notebook = gtk_notebook_new(); | |
| 45 | - GtkWidget * toolbar = pw3270_toolbar_new(); | |
| 46 | - | |
| 47 | - { | |
| 48 | - // Setup toolbar | |
| 49 | - static const char * action_names[] = { | |
| 50 | - "reconnect", | |
| 51 | - "disconnect", | |
| 52 | - "selectall", | |
| 53 | - "unselect" | |
| 54 | - }; | |
| 55 | - | |
| 56 | - size_t ix; | |
| 57 | - | |
| 58 | - for(ix = 0; ix < G_N_ELEMENTS(action_names); ix++) { | |
| 59 | - pw3270_toolbar_insert_lib3270_action(toolbar, lib3270_action_get_by_name(action_names[ix]), -1); | |
| 60 | - } | |
| 61 | - | |
| 62 | - } | |
| 63 | - | |
| 64 | - gtk_box_pack_start(GTK_BOX(vBox),toolbar,FALSE,TRUE,0); | |
| 65 | - gtk_box_pack_start(GTK_BOX(vBox),notebook,TRUE,TRUE,0); | |
| 66 | - | |
| 67 | - // Create Terminal window | |
| 68 | - { | |
| 69 | - gtk_widget_set_can_default(terminal,TRUE); | |
| 70 | - | |
| 71 | - gtk_notebook_append_page(GTK_NOTEBOOK(notebook),terminal,gtk_label_new("Terminal")); | |
| 72 | - | |
| 73 | -#ifdef _WIN32 | |
| 74 | - v3270_set_font_family(terminal,"Droid Sans Mono"); | |
| 75 | -#endif // _WIN32 | |
| 76 | - | |
| 77 | - } | |
| 78 | - | |
| 79 | - // Create trace window | |
| 80 | - gtk_notebook_append_page(GTK_NOTEBOOK(notebook),v3270_trace_new(terminal),gtk_label_new("Trace")); | |
| 81 | - | |
| 82 | - // Setup and show main window | |
| 83 | - gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER); | |
| 84 | - gtk_window_set_default_size (GTK_WINDOW (window), 800, 500); | |
| 85 | - gtk_container_add(GTK_CONTAINER(window),vBox); | |
| 86 | - gtk_widget_show_all(window); | |
| 87 | - | |
| 88 | - gtk_widget_grab_focus(terminal); | |
| 89 | - | |
| 90 | -} | |
| 91 | - | |
| 92 | -int main (int argc, char **argv) { | |
| 93 | - | |
| 94 | - GtkApplication *app; | |
| 95 | - int status; | |
| 96 | - | |
| 97 | - app = gtk_application_new ("br.com.bb.pw3270",G_APPLICATION_FLAGS_NONE); | |
| 98 | - | |
| 99 | - g_signal_connect (app, "activate", G_CALLBACK(activate), NULL); | |
| 100 | - | |
| 101 | - status = g_application_run (G_APPLICATION (app), argc, argv); | |
| 102 | - g_object_unref (app); | |
| 103 | - | |
| 104 | - g_message("rc=%d",status); | |
| 105 | - | |
| 106 | - return 0; | |
| 107 | - | |
| 108 | -} | |
| 109 | - | |
| 110 | - |
src/widgets/toolbar/toolbar.cbp
| ... | ... | @@ -1,55 +0,0 @@ |
| 1 | -<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | |
| 2 | -<CodeBlocks_project_file> | |
| 3 | - <FileVersion major="1" minor="6" /> | |
| 4 | - <Project> | |
| 5 | - <Option title="pw3270 V5.2 toolbar" /> | |
| 6 | - <Option pch_mode="2" /> | |
| 7 | - <Option compiler="gcc" /> | |
| 8 | - <Build> | |
| 9 | - <Target title="Debug"> | |
| 10 | - <Option output=".bin/Debug/toolbar" prefix_auto="1" extension_auto="1" /> | |
| 11 | - <Option object_output=".obj/Debug/" /> | |
| 12 | - <Option type="1" /> | |
| 13 | - <Option compiler="gcc" /> | |
| 14 | - <Compiler> | |
| 15 | - <Add option="-g" /> | |
| 16 | - <Add option="-DDEBUG=1" /> | |
| 17 | - </Compiler> | |
| 18 | - </Target> | |
| 19 | - <Target title="Release"> | |
| 20 | - <Option output=".bin/Release/pw3270 V5" prefix_auto="1" extension_auto="1" /> | |
| 21 | - <Option object_output=".obj/Release/" /> | |
| 22 | - <Option type="1" /> | |
| 23 | - <Option compiler="gcc" /> | |
| 24 | - <Compiler> | |
| 25 | - <Add option="-O2" /> | |
| 26 | - <Add option="-DNDEBUG=1" /> | |
| 27 | - </Compiler> | |
| 28 | - <Linker> | |
| 29 | - <Add option="-s" /> | |
| 30 | - </Linker> | |
| 31 | - </Target> | |
| 32 | - </Build> | |
| 33 | - <Compiler> | |
| 34 | - <Add option="-Wall" /> | |
| 35 | - <Add option="`pkg-config --cflags gtk+-3.0 lib3270 libv3270`" /> | |
| 36 | - <Add directory="../../include" /> | |
| 37 | - </Compiler> | |
| 38 | - <Linker> | |
| 39 | - <Add option="`pkg-config --libs gtk+-3.0 lib3270 libv3270`" /> | |
| 40 | - </Linker> | |
| 41 | - <Unit filename="../../include/pw3270/toolbar.h" /> | |
| 42 | - <Unit filename="core.c"> | |
| 43 | - <Option compilerVar="CC" /> | |
| 44 | - </Unit> | |
| 45 | - <Unit filename="private.h" /> | |
| 46 | - <Unit filename="testprogram/testprogram.c"> | |
| 47 | - <Option compilerVar="CC" /> | |
| 48 | - </Unit> | |
| 49 | - <Extensions> | |
| 50 | - <code_completion /> | |
| 51 | - <envvars /> | |
| 52 | - <debugger /> | |
| 53 | - </Extensions> | |
| 54 | - </Project> | |
| 55 | -</CodeBlocks_project_file> |
src/widgets/window/init.c
| ... | ... | @@ -1,64 +0,0 @@ |
| 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 "private.h" | |
| 31 | - #include <pw3270/toolbar.h> | |
| 32 | - | |
| 33 | - G_DEFINE_TYPE(pw3270ApplicationWindow, pw3270ApplicationWindow, GTK_TYPE_APPLICATION_WINDOW); | |
| 34 | - | |
| 35 | - static void pw3270ApplicationWindow_class_init(pw3270ApplicationWindowClass *klass) { | |
| 36 | - | |
| 37 | - } | |
| 38 | - | |
| 39 | - static void pw3270ApplicationWindow_init(pw3270ApplicationWindow *widget) { | |
| 40 | - | |
| 41 | - GtkBox * vBox = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL,0)); | |
| 42 | - | |
| 43 | - widget->notebook = GTK_NOTEBOOK(gtk_notebook_new()); | |
| 44 | - widget->terminal = pw3270_terminal_new(GTK_WIDGET(widget)); | |
| 45 | - widget->toolbar = GTK_TOOLBAR(pw3270_toolbar_new()); | |
| 46 | - | |
| 47 | - gtk_notebook_set_show_tabs(widget->notebook,FALSE); | |
| 48 | - gtk_notebook_set_show_border(widget->notebook, FALSE); | |
| 49 | - | |
| 50 | - gtk_box_pack_start(vBox,GTK_WIDGET(widget->toolbar),FALSE,TRUE,0); | |
| 51 | - gtk_box_pack_start(vBox,GTK_WIDGET(widget->notebook),TRUE,TRUE,0); | |
| 52 | - | |
| 53 | - gtk_container_add(GTK_CONTAINER(widget),GTK_WIDGET(vBox)); | |
| 54 | - gtk_widget_show_all(GTK_WIDGET(widget)); | |
| 55 | - | |
| 56 | - } | |
| 57 | - | |
| 58 | - GtkWidget * pw3270_application_window_new(GtkApplication * application) { | |
| 59 | - | |
| 60 | - g_return_val_if_fail(GTK_IS_APPLICATION(application), NULL); | |
| 61 | - return g_object_new(PW3270_TYPE_APPLICATION_WINDOW, "application", application, NULL); | |
| 62 | - | |
| 63 | - } | |
| 64 | - |
src/widgets/window/private.h
| ... | ... | @@ -1,65 +0,0 @@ |
| 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 | -#ifndef PRIVATE_H_INCLUDED | |
| 31 | - | |
| 32 | - #define PRIVATE_H_INCLUDED | |
| 33 | - | |
| 34 | - #include <config.h> | |
| 35 | - | |
| 36 | - #ifndef GETTEXT_PACKAGE | |
| 37 | - #define GETTEXT_PACKAGE PACKAGE_NAME | |
| 38 | - #endif | |
| 39 | - | |
| 40 | - #include <libintl.h> | |
| 41 | - #include <glib/gi18n.h> | |
| 42 | - #include <gtk/gtk.h> | |
| 43 | - | |
| 44 | - #include <pw3270/window.h> | |
| 45 | - #include <v3270.h> | |
| 46 | - #include <lib3270.h> | |
| 47 | - #include <lib3270/log.h> | |
| 48 | - | |
| 49 | - struct _pw3270ApplicationWindow { | |
| 50 | - | |
| 51 | - GtkApplicationWindow parent; | |
| 52 | - | |
| 53 | - GtkWidget * terminal; | |
| 54 | - GtkNotebook * notebook; | |
| 55 | - GtkToolbar * toolbar; | |
| 56 | - | |
| 57 | - }; | |
| 58 | - | |
| 59 | - struct _pw3270ApplicationWindowClass { | |
| 60 | - | |
| 61 | - GtkApplicationWindowClass parent_class; | |
| 62 | - | |
| 63 | - }; | |
| 64 | - | |
| 65 | -#endif // PRIVATE_H_INCLUDED |
src/widgets/window/terminal.c
| ... | ... | @@ -1,81 +0,0 @@ |
| 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 "private.h" | |
| 31 | - #include <pw3270/actions.h> | |
| 32 | - | |
| 33 | - static void session_changed(GtkWidget *terminal, GtkWidget *label) { | |
| 34 | - | |
| 35 | - gtk_label_set_text(GTK_LABEL(label),v3270_get_session_name(terminal)); | |
| 36 | - | |
| 37 | - // Do I have to change the window title? | |
| 38 | - GtkWidget * toplevel = gtk_widget_get_toplevel(terminal); | |
| 39 | - if(PW3270_IS_APPLICATION_WINDOW(toplevel)) { | |
| 40 | - | |
| 41 | - pw3270ApplicationWindow * window = PW3270_APPLICATION_WINDOW(toplevel); | |
| 42 | - | |
| 43 | - if(window->terminal == terminal) { | |
| 44 | - g_autofree gchar * title = v3270_get_session_title(terminal); | |
| 45 | - gtk_window_set_title(GTK_WINDOW(window), title); | |
| 46 | - } | |
| 47 | - | |
| 48 | - } | |
| 49 | - | |
| 50 | - } | |
| 51 | - | |
| 52 | - static gboolean on_terminal_focus(GtkWidget *terminal, GdkEvent *event, pw3270ApplicationWindow * window) { | |
| 53 | - | |
| 54 | - // Store the active terminal widget. | |
| 55 | - window->terminal = terminal; | |
| 56 | - | |
| 57 | - // Change window title | |
| 58 | - g_autofree gchar * title = v3270_get_session_title(terminal); | |
| 59 | - gtk_window_set_title(GTK_WINDOW(window), title); | |
| 60 | - | |
| 61 | - return FALSE; | |
| 62 | - } | |
| 63 | - | |
| 64 | - GtkWidget * pw3270_terminal_new(GtkWidget *widget) { | |
| 65 | - | |
| 66 | - g_return_val_if_fail(PW3270_IS_APPLICATION_WINDOW(widget),NULL); | |
| 67 | - | |
| 68 | - pw3270ApplicationWindow * window = PW3270_APPLICATION_WINDOW(widget); | |
| 69 | - GtkWidget * terminal = v3270_new(); | |
| 70 | - GtkWidget * label = gtk_label_new(v3270_get_session_name(terminal)); | |
| 71 | - | |
| 72 | - g_signal_connect(G_OBJECT(terminal), "focus-in-event", G_CALLBACK(on_terminal_focus), widget); | |
| 73 | - g_signal_connect(G_OBJECT(terminal), "session_changed", G_CALLBACK(session_changed),label); | |
| 74 | - | |
| 75 | - gtk_notebook_append_page(GTK_NOTEBOOK(window->notebook),terminal,label); | |
| 76 | - gtk_notebook_set_show_tabs(GTK_NOTEBOOK(window->notebook),gtk_notebook_get_n_pages(GTK_NOTEBOOK(window->notebook)) > 1); | |
| 77 | - | |
| 78 | - return terminal; | |
| 79 | - | |
| 80 | - } | |
| 81 | - |
src/widgets/window/testprogram/testprogram.c
| ... | ... | @@ -1,106 +0,0 @@ |
| 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. Registro no INPI sob | |
| 5 | - * o nome G3270. | |
| 6 | - * | |
| 7 | - * Copyright (C) <2008> <Banco do Brasil S.A.> | |
| 8 | - * | |
| 9 | - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
| 10 | - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
| 11 | - * Free Software Foundation. | |
| 12 | - * | |
| 13 | - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
| 14 | - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
| 15 | - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
| 16 | - * obter mais detalhes. | |
| 17 | - * | |
| 18 | - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
| 19 | - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
| 20 | - * St, Fifth Floor, Boston, MA 02110-1301 USA | |
| 21 | - * | |
| 22 | - * Este programa está nomeado como testprogram.c e possui - linhas de código. | |
| 23 | - * | |
| 24 | - * Contatos: | |
| 25 | - * | |
| 26 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
| 27 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
| 28 | - * | |
| 29 | - */ | |
| 30 | - | |
| 31 | - #include <config.h> | |
| 32 | - #include <pw3270/window.h> | |
| 33 | - #include <pw3270/toolbar.h> | |
| 34 | - #include <v3270.h> | |
| 35 | - #include <v3270/trace.h> | |
| 36 | - #include <lib3270/log.h> | |
| 37 | - | |
| 38 | - /*---[ Implement ]----------------------------------------------------------------------------------*/ | |
| 39 | - | |
| 40 | - static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) { | |
| 41 | - | |
| 42 | - GtkWidget * window = pw3270_application_window_new(app); | |
| 43 | - | |
| 44 | - // Create terminal widget | |
| 45 | - pw3270_terminal_new(window); | |
| 46 | - pw3270_terminal_new(window); | |
| 47 | - | |
| 48 | - // Setup and show main window | |
| 49 | - gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER); | |
| 50 | - gtk_window_set_default_size (GTK_WINDOW (window), 800, 500); | |
| 51 | - gtk_widget_show_all(window); | |
| 52 | - | |
| 53 | -} | |
| 54 | - | |
| 55 | -GtkWidget * pw3270_toolbar_new(void) { | |
| 56 | - | |
| 57 | - static const struct _item { | |
| 58 | - const gchar *icon; | |
| 59 | - const gchar *label; | |
| 60 | - } itens[] = { | |
| 61 | - | |
| 62 | - { | |
| 63 | - "gtk-connect", | |
| 64 | - "_Connect" | |
| 65 | - }, | |
| 66 | - | |
| 67 | - { | |
| 68 | - "gtk-disconnect", | |
| 69 | - "_Disconnect" | |
| 70 | - } | |
| 71 | - | |
| 72 | - }; | |
| 73 | - | |
| 74 | - GtkWidget * toolbar = gtk_toolbar_new(); | |
| 75 | - size_t item; | |
| 76 | - | |
| 77 | - for(item = 0; item < G_N_ELEMENTS(itens); item++) { | |
| 78 | - | |
| 79 | - GtkToolItem * button = gtk_tool_button_new(gtk_image_new_from_icon_name(itens[item].icon,GTK_ICON_SIZE_LARGE_TOOLBAR),itens[item].label); | |
| 80 | - gtk_tool_button_set_use_underline(GTK_TOOL_BUTTON(button),TRUE); | |
| 81 | - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), button, -1); | |
| 82 | - | |
| 83 | - } | |
| 84 | - | |
| 85 | - return toolbar; | |
| 86 | -} | |
| 87 | - | |
| 88 | -int main (int argc, char **argv) { | |
| 89 | - | |
| 90 | - GtkApplication *app; | |
| 91 | - int status; | |
| 92 | - | |
| 93 | - app = gtk_application_new ("br.com.bb.pw3270",G_APPLICATION_FLAGS_NONE); | |
| 94 | - | |
| 95 | - g_signal_connect (app, "activate", G_CALLBACK(activate), NULL); | |
| 96 | - | |
| 97 | - status = g_application_run (G_APPLICATION (app), argc, argv); | |
| 98 | - g_object_unref (app); | |
| 99 | - | |
| 100 | - g_message("rc=%d",status); | |
| 101 | - | |
| 102 | - return 0; | |
| 103 | - | |
| 104 | -} | |
| 105 | - | |
| 106 | - |
src/widgets/window/window.cbp
| ... | ... | @@ -1,61 +0,0 @@ |
| 1 | -<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | |
| 2 | -<CodeBlocks_project_file> | |
| 3 | - <FileVersion major="1" minor="6" /> | |
| 4 | - <Project> | |
| 5 | - <Option title="PW3270 Application Window" /> | |
| 6 | - <Option pch_mode="2" /> | |
| 7 | - <Option compiler="gcc" /> | |
| 8 | - <Build> | |
| 9 | - <Target title="Debug"> | |
| 10 | - <Option output=".bin/Debug/PW3270 Application Window" prefix_auto="1" extension_auto="1" /> | |
| 11 | - <Option object_output=".obj/Debug/" /> | |
| 12 | - <Option type="1" /> | |
| 13 | - <Option compiler="gcc" /> | |
| 14 | - <Compiler> | |
| 15 | - <Add option="-g" /> | |
| 16 | - <Add option="-DDEBUG=1" /> | |
| 17 | - </Compiler> | |
| 18 | - </Target> | |
| 19 | - <Target title="Release"> | |
| 20 | - <Option output=".bin/Release/PW3270 Application Window" prefix_auto="1" extension_auto="1" /> | |
| 21 | - <Option object_output=".obj/Release/" /> | |
| 22 | - <Option type="1" /> | |
| 23 | - <Option compiler="gcc" /> | |
| 24 | - <Compiler> | |
| 25 | - <Add option="-O2" /> | |
| 26 | - <Add option="-DNDEBUG=1" /> | |
| 27 | - </Compiler> | |
| 28 | - <Linker> | |
| 29 | - <Add option="-s" /> | |
| 30 | - </Linker> | |
| 31 | - </Target> | |
| 32 | - </Build> | |
| 33 | - <Compiler> | |
| 34 | - <Add option="-Wall" /> | |
| 35 | - <Add option="`pkg-config --cflags gtk+-3.0 libv3270`" /> | |
| 36 | - <Add directory="../../include" /> | |
| 37 | - </Compiler> | |
| 38 | - <Linker> | |
| 39 | - <Add option="`pkg-config --libs gtk+-3.0 libv3270`" /> | |
| 40 | - </Linker> | |
| 41 | - <Unit filename="../../include/pw3270/actions.h" /> | |
| 42 | - <Unit filename="../../include/pw3270/toolbar.h" /> | |
| 43 | - <Unit filename="../../include/pw3270/window.h" /> | |
| 44 | - <Unit filename="init.c"> | |
| 45 | - <Option compilerVar="CC" /> | |
| 46 | - </Unit> | |
| 47 | - <Unit filename="private.h" /> | |
| 48 | - <Unit filename="terminal.c"> | |
| 49 | - <Option compilerVar="CC" /> | |
| 50 | - </Unit> | |
| 51 | - <Unit filename="testprogram/testprogram.c"> | |
| 52 | - <Option compilerVar="CC" /> | |
| 53 | - </Unit> | |
| 54 | - <Extensions> | |
| 55 | - <code_completion /> | |
| 56 | - <envvars /> | |
| 57 | - <debugger /> | |
| 58 | - <lib_finder disable_auto="1" /> | |
| 59 | - </Extensions> | |
| 60 | - </Project> | |
| 61 | -</CodeBlocks_project_file> |