Commit 3a197dd92673b6f405b5add8044691760cf622fe
1 parent
e74b82b8
Exists in
master
and in
4 other branches
Implementing main window.
Showing
6 changed files
with
229 additions
and
9 deletions
Show diff stats
src/include/pw3270/window.h
... | ... | @@ -40,18 +40,30 @@ |
40 | 40 | |
41 | 41 | G_BEGIN_DECLS |
42 | 42 | |
43 | - #define PW3270_TYPE_APPLICATION_WINDOW (pw3270ApplicationWindow_get_type()) | |
44 | - #define PW3270_APPLICATION_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PW3270_TYPE_APPLICATION_WINDOW, pw3270ApplicationWindow)) | |
45 | - #define PW3270_APPLICATION_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PW3270_TYPE_APPLICATION_WINDOW, pw3270ApplicationWindowClass)) | |
46 | - #define PW3270_IS_APPLICATION_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PW3270_TYPE_APPLICATION_WINDOW)) | |
47 | - #define PW3270_IS_APPLICATION_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PW3270_TYPE_APPLICATION_WINDOW)) | |
48 | - #define PW3270_APPLICATION_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PW3270_TYPE_APPLICATION_WINDOW, pw3270ApplicationWindowClass)) | |
43 | + #define PW3270_TYPE_APPLICATION_WINDOW (pw3270ApplicationWindow_get_type ()) | |
44 | + #define PW3270_APPLICATION_WINDOW(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ | |
45 | + PW3270_TYPE_APPLICATION_WINDOW, pw3270ApplicationWindow)) | |
46 | + #define PW3270_APPLICATION_WINDOW_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \ | |
47 | + PW3270_TYPE_APPLICATION_WINDOW, pw3270ApplicationWindowClass)) | |
48 | + #define PW3270_IS_APPLICATION_WINDOW(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \ | |
49 | + PW3270_TYPE_APPLICATION_WINDOW)) | |
50 | + #define PW3270_IS_APPLICATION_WINDOW_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \ | |
51 | + PW3270_TYPE_APPLICATION_WINDOW)) | |
52 | + #define PW3270_APPLICATION_WINDOW_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \ | |
53 | + GTK_TYPE_APPLICATION_WINDOW, pw3270ApplicationWindowClass)) | |
49 | 54 | |
50 | - typedef struct _pw3270ApplicationWindow pw3270ApplicationWindow; | |
51 | - typedef struct _pw3270ApplicationWindowClass pw3270ApplicationWindowClass; | |
52 | 55 | |
53 | - GtkWidget * pw3270_application_window_new(GtkApplication * app); | |
56 | + typedef struct _pw3270ApplicationWindowClass pw3270ApplicationWindowClass; | |
57 | + typedef struct _pw3270ApplicationWindow pw3270ApplicationWindow; | |
58 | + | |
59 | + GType pw3270ApplicationWindow_get_type(); | |
60 | + GtkWidget * pw3270_application_window_new(GtkApplication * app); | |
61 | + | |
62 | + /// @brief Create a new terminal tab. | |
63 | + GtkWidget * pw3270_terminal_new(GtkWidget *window); | |
64 | + | |
54 | 65 | |
55 | 66 | G_END_DECLS |
56 | 67 | |
68 | + | |
57 | 69 | #endif // PW3270_WINDOW_H_INCLUDED | ... | ... |
... | ... | @@ -0,0 +1,58 @@ |
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 | + G_DEFINE_TYPE(pw3270ApplicationWindow, pw3270ApplicationWindow, GTK_TYPE_APPLICATION_WINDOW); | |
33 | + | |
34 | + static void pw3270ApplicationWindow_class_init(pw3270ApplicationWindowClass *klass) { | |
35 | + | |
36 | + } | |
37 | + | |
38 | + static void pw3270ApplicationWindow_init(pw3270ApplicationWindow *widget) { | |
39 | + | |
40 | + widget->notebook = GTK_NOTEBOOK(gtk_notebook_new()); | |
41 | + | |
42 | + gtk_notebook_set_show_tabs(widget->notebook,FALSE); | |
43 | + gtk_notebook_set_show_border(widget->notebook, FALSE); | |
44 | + | |
45 | + widget->terminal = pw3270_terminal_new(GTK_WIDGET(widget)); | |
46 | + | |
47 | + gtk_container_add(GTK_CONTAINER(widget),GTK_WIDGET(widget->notebook)); | |
48 | + gtk_widget_show_all(GTK_WIDGET(widget)); | |
49 | + | |
50 | + } | |
51 | + | |
52 | + GtkWidget * pw3270_application_window_new(GtkApplication * application) { | |
53 | + | |
54 | + g_return_val_if_fail(GTK_IS_APPLICATION(application), NULL); | |
55 | + return g_object_new(PW3270_TYPE_APPLICATION_WINDOW, "application", application, NULL); | |
56 | + | |
57 | + } | |
58 | + | ... | ... |
src/widgets/window/private.h
... | ... | @@ -42,7 +42,23 @@ |
42 | 42 | #include <gtk/gtk.h> |
43 | 43 | |
44 | 44 | #include <pw3270/window.h> |
45 | + #include <v3270.h> | |
46 | + #include <lib3270.h> | |
45 | 47 | #include <lib3270/log.h> |
46 | 48 | |
49 | + struct _pw3270ApplicationWindow { | |
50 | + | |
51 | + GtkApplicationWindow parent; | |
52 | + | |
53 | + GtkWidget * terminal; | |
54 | + GtkNotebook * notebook; | |
55 | + | |
56 | + }; | |
57 | + | |
58 | + struct _pw3270ApplicationWindowClass { | |
59 | + | |
60 | + GtkApplicationWindowClass parent_class; | |
61 | + | |
62 | + }; | |
47 | 63 | |
48 | 64 | #endif // PRIVATE_H_INCLUDED | ... | ... |
... | ... | @@ -0,0 +1,50 @@ |
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 on_terminal_focus(GtkWidget *terminal, GdkEvent *event, pw3270ApplicationWindow * window) { | |
33 | + | |
34 | + debug("Focus on terminal %p", terminal); | |
35 | + window->terminal = terminal; | |
36 | + | |
37 | + return FALSE; | |
38 | + } | |
39 | + | |
40 | + GtkWidget * pw3270_terminal_new(GtkWidget *window) { | |
41 | + | |
42 | + GtkWidget * terminal = v3270_new(); | |
43 | + g_signal_connect(G_OBJECT(terminal), "focus-in-event", G_CALLBACK(on_terminal_focus), window); | |
44 | + | |
45 | + gtk_notebook_append_page(PW3270_APPLICATION_WINDOW(window)->notebook,terminal,NULL); | |
46 | + | |
47 | + return terminal; | |
48 | + | |
49 | + } | |
50 | + | ... | ... |
... | ... | @@ -0,0 +1,68 @@ |
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 = pw3270_application_window_new(app); | |
42 | + | |
43 | + // Setup and show main window | |
44 | + gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER); | |
45 | + gtk_window_set_default_size (GTK_WINDOW (window), 800, 500); | |
46 | + gtk_widget_show_all(window); | |
47 | + | |
48 | +} | |
49 | + | |
50 | +int main (int argc, char **argv) { | |
51 | + | |
52 | + GtkApplication *app; | |
53 | + int status; | |
54 | + | |
55 | + app = gtk_application_new ("br.com.bb.pw3270",G_APPLICATION_FLAGS_NONE); | |
56 | + | |
57 | + g_signal_connect (app, "activate", G_CALLBACK(activate), NULL); | |
58 | + | |
59 | + status = g_application_run (G_APPLICATION (app), argc, argv); | |
60 | + g_object_unref (app); | |
61 | + | |
62 | + g_message("rc=%d",status); | |
63 | + | |
64 | + return 0; | |
65 | + | |
66 | +} | |
67 | + | |
68 | + | ... | ... |
src/widgets/window/window.cbp
... | ... | @@ -13,6 +13,7 @@ |
13 | 13 | <Option compiler="gcc" /> |
14 | 14 | <Compiler> |
15 | 15 | <Add option="-g" /> |
16 | + <Add option="-DDEBUG=1" /> | |
16 | 17 | </Compiler> |
17 | 18 | </Target> |
18 | 19 | <Target title="Release"> |
... | ... | @@ -22,6 +23,7 @@ |
22 | 23 | <Option compiler="gcc" /> |
23 | 24 | <Compiler> |
24 | 25 | <Add option="-O2" /> |
26 | + <Add option="-DNDEBUG=1" /> | |
25 | 27 | </Compiler> |
26 | 28 | <Linker> |
27 | 29 | <Add option="-s" /> |
... | ... | @@ -30,9 +32,23 @@ |
30 | 32 | </Build> |
31 | 33 | <Compiler> |
32 | 34 | <Add option="-Wall" /> |
35 | + <Add option="`pkg-config --cflags gtk+-3.0 libv3270`" /> | |
36 | + <Add directory="../../include" /> | |
33 | 37 | </Compiler> |
38 | + <Linker> | |
39 | + <Add option="`pkg-config --libs gtk+-3.0 libv3270`" /> | |
40 | + </Linker> | |
34 | 41 | <Unit filename="../../include/pw3270/window.h" /> |
42 | + <Unit filename="core.c"> | |
43 | + <Option compilerVar="CC" /> | |
44 | + </Unit> | |
35 | 45 | <Unit filename="private.h" /> |
46 | + <Unit filename="terminal.c"> | |
47 | + <Option compilerVar="CC" /> | |
48 | + </Unit> | |
49 | + <Unit filename="testprogram/testprogram.c"> | |
50 | + <Option compilerVar="CC" /> | |
51 | + </Unit> | |
36 | 52 | <Extensions> |
37 | 53 | <code_completion /> |
38 | 54 | <envvars /> | ... | ... |