Commit 766bb64619c07af48ee51603cf26e9a7166c25e0
1 parent
7449e7af
Exists in
master
and in
4 other branches
Adjusting setcolors dialog.
Showing
2 changed files
with
128 additions
and
10 deletions
Show diff stats
... | ... | @@ -0,0 +1,124 @@ |
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 Implements PW3270 Dialog Action. | |
32 | + * | |
33 | + */ | |
34 | + | |
35 | + #include "private.h" | |
36 | + #include <v3270.h> | |
37 | + #include <v3270/settings.h> | |
38 | + | |
39 | + static void pw3270DialogAction_class_init(pw3270DialogActionClass *klass); | |
40 | + static void pw3270DialogAction_init(pw3270DialogAction *action); | |
41 | + static void activate(GAction G_GNUC_UNUSED(*action), GVariant G_GNUC_UNUSED(*parameter), GtkWidget *terminal); | |
42 | + | |
43 | + struct _pw3270DialogAction { | |
44 | + | |
45 | + pw3270SimpleAction parent; | |
46 | + | |
47 | + GtkWidget * dialog; | |
48 | + GtkWidget * (*factory)(GtkWidget *); | |
49 | + | |
50 | + }; | |
51 | + | |
52 | + struct _pw3270DialogActionClass { | |
53 | + | |
54 | + pw3270SimpleActionClass parent_class; | |
55 | + | |
56 | + }; | |
57 | + | |
58 | + G_DEFINE_TYPE(pw3270DialogAction, pw3270DialogAction, PW3270_TYPE_SIMPLE_ACTION); | |
59 | + | |
60 | + static gboolean get_enabled(GAction *action, GtkWidget *terminal) { | |
61 | + | |
62 | + if((PW3270_DIALOG_ACTION(action)->dialog)) { | |
63 | + return FALSE; | |
64 | + } | |
65 | + | |
66 | + if(terminal) { | |
67 | + return lib3270_action_group_get_activatable(v3270_get_session(terminal),PW3270_SIMPLE_ACTION(action)->group.id); | |
68 | + } | |
69 | + | |
70 | + return FALSE; | |
71 | + | |
72 | + } | |
73 | + | |
74 | + static void pw3270DialogAction_class_init(pw3270DialogActionClass *klass) { | |
75 | + klass->parent_class.parent_class.get_enabled = get_enabled; | |
76 | + } | |
77 | + | |
78 | + static void pw3270DialogAction_init(pw3270DialogAction *action) { | |
79 | + | |
80 | + action->dialog = NULL; | |
81 | + action->parent.parent.activate = activate; | |
82 | + | |
83 | + } | |
84 | + | |
85 | + pw3270SimpleAction * pw3270_dialog_action_new(GtkWidget * (*factory)(GtkWidget *)) { | |
86 | + | |
87 | + pw3270DialogAction * action = (pw3270DialogAction *) g_object_new(PW3270_TYPE_DIALOG_ACTION, NULL); | |
88 | + action->factory = factory; | |
89 | + return PW3270_SIMPLE_ACTION(action); | |
90 | + | |
91 | + } | |
92 | + | |
93 | + static void on_destroy(GtkWidget *dialog, pw3270DialogAction *action) { | |
94 | + | |
95 | + if(action->dialog == dialog) { | |
96 | + action->dialog = NULL; | |
97 | + pw3270_action_notify_enabled(G_ACTION(action)); | |
98 | + } | |
99 | + | |
100 | + } | |
101 | + | |
102 | + void activate(GAction *object, GVariant G_GNUC_UNUSED(*parameter), GtkWidget *terminal) { | |
103 | + | |
104 | + if(!GTK_IS_V3270(terminal)) | |
105 | + return; | |
106 | + | |
107 | + pw3270DialogAction * action = PW3270_DIALOG_ACTION(object); | |
108 | + | |
109 | + if(action->dialog || !action->factory) | |
110 | + return; | |
111 | + | |
112 | + action->dialog = action->factory(terminal); | |
113 | + pw3270_action_notify_enabled(G_ACTION(action)); | |
114 | + | |
115 | + if(action->dialog) { | |
116 | + | |
117 | + g_signal_connect(action->dialog,"destroy",G_CALLBACK(on_destroy),action); | |
118 | + g_signal_connect(action->dialog,"close",G_CALLBACK(gtk_widget_destroy),NULL); | |
119 | + gtk_widget_show_all(GTK_WIDGET(action->dialog)); | |
120 | + | |
121 | + } | |
122 | + | |
123 | + } | |
124 | + | ... | ... |
src/objects/window/actions/setcolors.c
... | ... | @@ -34,13 +34,12 @@ |
34 | 34 | #include <v3270/dialogs.h> |
35 | 35 | #include <v3270/colorscheme.h> |
36 | 36 | |
37 | - static void activate(GAction G_GNUC_UNUSED(*action), GVariant G_GNUC_UNUSED(*parameter), GtkWidget *terminal); | |
37 | + static GtkWidget * factory(GtkWidget *terminal); | |
38 | 38 | |
39 | 39 | GAction * pw3270_set_color_action_new(void) { |
40 | 40 | |
41 | - pw3270SimpleAction * action = pw3270_simple_action_new(); | |
41 | + pw3270SimpleAction * action = pw3270_dialog_action_new(factory); | |
42 | 42 | |
43 | - action->parent.activate = activate; | |
44 | 43 | action->parent.name = "set.colors"; |
45 | 44 | action->icon_name = "gtk-select-color"; |
46 | 45 | action->label = N_("Colors"); |
... | ... | @@ -49,18 +48,13 @@ |
49 | 48 | |
50 | 49 | } |
51 | 50 | |
52 | - void activate(GAction G_GNUC_UNUSED(*action), GVariant G_GNUC_UNUSED(*parameter), GtkWidget *terminal) { | |
53 | - | |
54 | - g_return_if_fail(GTK_IS_V3270(terminal)); | |
51 | + GtkWidget * factory(GtkWidget *terminal) { | |
55 | 52 | |
56 | 53 | GtkWidget * dialog = v3270_settings_dialog_new(terminal, v3270_color_selection_new()); |
57 | - | |
58 | 54 | v3270_dialog_setup(dialog,_("Color setup"),_("_Save")); |
59 | - | |
60 | - g_signal_connect(dialog,"close",G_CALLBACK(gtk_widget_destroy),NULL); | |
61 | 55 | g_signal_connect(dialog,"response",G_CALLBACK(gtk_widget_destroy),NULL); |
62 | 56 | |
63 | - gtk_widget_show_all(dialog); | |
57 | + return dialog; | |
64 | 58 | |
65 | 59 | } |
66 | 60 | ... | ... |