diff --git a/src/include/pw3270/window.h b/src/include/pw3270/window.h index a770a14..7034186 100644 --- a/src/include/pw3270/window.h +++ b/src/include/pw3270/window.h @@ -40,18 +40,30 @@ G_BEGIN_DECLS - #define PW3270_TYPE_APPLICATION_WINDOW (pw3270ApplicationWindow_get_type()) - #define PW3270_APPLICATION_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PW3270_TYPE_APPLICATION_WINDOW, pw3270ApplicationWindow)) - #define PW3270_APPLICATION_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PW3270_TYPE_APPLICATION_WINDOW, pw3270ApplicationWindowClass)) - #define PW3270_IS_APPLICATION_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PW3270_TYPE_APPLICATION_WINDOW)) - #define PW3270_IS_APPLICATION_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PW3270_TYPE_APPLICATION_WINDOW)) - #define PW3270_APPLICATION_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PW3270_TYPE_APPLICATION_WINDOW, pw3270ApplicationWindowClass)) + #define PW3270_TYPE_APPLICATION_WINDOW (pw3270ApplicationWindow_get_type ()) + #define PW3270_APPLICATION_WINDOW(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ + PW3270_TYPE_APPLICATION_WINDOW, pw3270ApplicationWindow)) + #define PW3270_APPLICATION_WINDOW_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \ + PW3270_TYPE_APPLICATION_WINDOW, pw3270ApplicationWindowClass)) + #define PW3270_IS_APPLICATION_WINDOW(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \ + PW3270_TYPE_APPLICATION_WINDOW)) + #define PW3270_IS_APPLICATION_WINDOW_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \ + PW3270_TYPE_APPLICATION_WINDOW)) + #define PW3270_APPLICATION_WINDOW_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \ + GTK_TYPE_APPLICATION_WINDOW, pw3270ApplicationWindowClass)) - typedef struct _pw3270ApplicationWindow pw3270ApplicationWindow; - typedef struct _pw3270ApplicationWindowClass pw3270ApplicationWindowClass; - GtkWidget * pw3270_application_window_new(GtkApplication * app); + typedef struct _pw3270ApplicationWindowClass pw3270ApplicationWindowClass; + typedef struct _pw3270ApplicationWindow pw3270ApplicationWindow; + + GType pw3270ApplicationWindow_get_type(); + GtkWidget * pw3270_application_window_new(GtkApplication * app); + + /// @brief Create a new terminal tab. + GtkWidget * pw3270_terminal_new(GtkWidget *window); + G_END_DECLS + #endif // PW3270_WINDOW_H_INCLUDED diff --git a/src/widgets/window/core.c b/src/widgets/window/core.c new file mode 100644 index 0000000..4a22dd1 --- /dev/null +++ b/src/widgets/window/core.c @@ -0,0 +1,58 @@ +/* + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a + * aplicativos mainframe. Registro no INPI sob o nome G3270. + * + * Copyright (C) <2008> + * + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela + * Free Software Foundation. + * + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para + * obter mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin + * St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Este programa está nomeado como - e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * + */ + + #include "private.h" + + G_DEFINE_TYPE(pw3270ApplicationWindow, pw3270ApplicationWindow, GTK_TYPE_APPLICATION_WINDOW); + + static void pw3270ApplicationWindow_class_init(pw3270ApplicationWindowClass *klass) { + + } + + static void pw3270ApplicationWindow_init(pw3270ApplicationWindow *widget) { + + widget->notebook = GTK_NOTEBOOK(gtk_notebook_new()); + + gtk_notebook_set_show_tabs(widget->notebook,FALSE); + gtk_notebook_set_show_border(widget->notebook, FALSE); + + widget->terminal = pw3270_terminal_new(GTK_WIDGET(widget)); + + gtk_container_add(GTK_CONTAINER(widget),GTK_WIDGET(widget->notebook)); + gtk_widget_show_all(GTK_WIDGET(widget)); + + } + + GtkWidget * pw3270_application_window_new(GtkApplication * application) { + + g_return_val_if_fail(GTK_IS_APPLICATION(application), NULL); + return g_object_new(PW3270_TYPE_APPLICATION_WINDOW, "application", application, NULL); + + } + diff --git a/src/widgets/window/private.h b/src/widgets/window/private.h index 79cc78b..ce41e15 100644 --- a/src/widgets/window/private.h +++ b/src/widgets/window/private.h @@ -42,7 +42,23 @@ #include #include + #include + #include #include + struct _pw3270ApplicationWindow { + + GtkApplicationWindow parent; + + GtkWidget * terminal; + GtkNotebook * notebook; + + }; + + struct _pw3270ApplicationWindowClass { + + GtkApplicationWindowClass parent_class; + + }; #endif // PRIVATE_H_INCLUDED diff --git a/src/widgets/window/terminal.c b/src/widgets/window/terminal.c new file mode 100644 index 0000000..3ee1b9e --- /dev/null +++ b/src/widgets/window/terminal.c @@ -0,0 +1,50 @@ +/* + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a + * aplicativos mainframe. Registro no INPI sob o nome G3270. + * + * Copyright (C) <2008> + * + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela + * Free Software Foundation. + * + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para + * obter mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin + * St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Este programa está nomeado como - e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * + */ + + #include "private.h" + + static gboolean on_terminal_focus(GtkWidget *terminal, GdkEvent *event, pw3270ApplicationWindow * window) { + + debug("Focus on terminal %p", terminal); + window->terminal = terminal; + + return FALSE; + } + + GtkWidget * pw3270_terminal_new(GtkWidget *window) { + + GtkWidget * terminal = v3270_new(); + g_signal_connect(G_OBJECT(terminal), "focus-in-event", G_CALLBACK(on_terminal_focus), window); + + gtk_notebook_append_page(PW3270_APPLICATION_WINDOW(window)->notebook,terminal,NULL); + + return terminal; + + } + diff --git a/src/widgets/window/testprogram/testprogram.c b/src/widgets/window/testprogram/testprogram.c new file mode 100644 index 0000000..9d0ee17 --- /dev/null +++ b/src/widgets/window/testprogram/testprogram.c @@ -0,0 +1,68 @@ +/* + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a + * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob + * o nome G3270. + * + * Copyright (C) <2008> + * + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela + * Free Software Foundation. + * + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para + * obter mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin + * St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Este programa está nomeado como testprogram.c e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * + */ + + #include + #include + #include + #include + #include + + /*---[ Implement ]----------------------------------------------------------------------------------*/ + + static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) { + + GtkWidget * window = pw3270_application_window_new(app); + + // Setup and show main window + gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER); + gtk_window_set_default_size (GTK_WINDOW (window), 800, 500); + gtk_widget_show_all(window); + +} + +int main (int argc, char **argv) { + + GtkApplication *app; + int status; + + app = gtk_application_new ("br.com.bb.pw3270",G_APPLICATION_FLAGS_NONE); + + g_signal_connect (app, "activate", G_CALLBACK(activate), NULL); + + status = g_application_run (G_APPLICATION (app), argc, argv); + g_object_unref (app); + + g_message("rc=%d",status); + + return 0; + +} + + diff --git a/src/widgets/window/window.cbp b/src/widgets/window/window.cbp index 94088c5..cf43400 100644 --- a/src/widgets/window/window.cbp +++ b/src/widgets/window/window.cbp @@ -13,6 +13,7 @@