Commit be19220374723fd6d8af730c8927678a92d5fefd

Authored by perry.werneck@gmail.com
1 parent ddad4e2c

Iniciando implementação do novo diálogo de transferência de arquivos

src/pw3270/ft/ft.cbp 0 → 100644
... ... @@ -0,0 +1,54 @@
  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 FT Dialogs" />
  6 + <Option pch_mode="2" />
  7 + <Option compiler="gcc" />
  8 + <Build>
  9 + <Target title="Debug">
  10 + <Option output=".bin/Debug/PW3270 FT Dialogs" 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 FT Dialogs" 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 + </Compiler>
  27 + <Linker>
  28 + <Add option="-s" />
  29 + </Linker>
  30 + </Target>
  31 + </Build>
  32 + <Compiler>
  33 + <Add option="-Wall" />
  34 + <Add option="`pkg-config --cflags gtk+-3.0`" />
  35 + <Add directory="../../include" />
  36 + </Compiler>
  37 + <Linker>
  38 + <Add option="`pkg-config --libs gtk+-3.0`" />
  39 + </Linker>
  40 + <Unit filename="ftdialog.c">
  41 + <Option compilerVar="CC" />
  42 + </Unit>
  43 + <Unit filename="testprogram.c">
  44 + <Option compilerVar="CC" />
  45 + </Unit>
  46 + <Unit filename="v3270ft.h" />
  47 + <Extensions>
  48 + <code_completion />
  49 + <envvars />
  50 + <debugger />
  51 + <lib_finder disable_auto="1" />
  52 + </Extensions>
  53 + </Project>
  54 +</CodeBlocks_project_file>
... ...
src/pw3270/ft/ftdialog.c 0 → 100644
... ... @@ -0,0 +1,176 @@
  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 ftdialog.c 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 "v3270ft.h"
  31 +
  32 +/*--[ Widget definition ]----------------------------------------------------------------------------*/
  33 +
  34 + enum _filename
  35 + {
  36 + FILENAME_LOCAL,
  37 + FILENAME_HOST,
  38 +
  39 + FILENAME_COUNT
  40 + };
  41 +
  42 + struct _v3270FTD
  43 + {
  44 + GtkDialog parent;
  45 + GtkWidget * filename[FILENAME_COUNT]; /**< Filenames for the transfer */
  46 + LIB3270_FT_OPTION options;
  47 + };
  48 +
  49 + struct _v3270FTDClass
  50 + {
  51 + GtkDialogClass parent_class;
  52 +
  53 + int dummy;
  54 + };
  55 +
  56 + G_DEFINE_TYPE(v3270FTD, v3270FTD, GTK_TYPE_DIALOG);
  57 +
  58 +/*--[ Globals ]--------------------------------------------------------------------------------------*/
  59 +
  60 +static void v3270FTD_class_init(v3270FTDClass *klass)
  61 +{
  62 +// GtkDialogClass * widget_class = GTK_DIALOG_CLASS(klass);
  63 +
  64 +#if GTK_CHECK_VERSION(3,0,0)
  65 +
  66 +#else
  67 +
  68 + #error Implementar
  69 +
  70 +#endif // GTK_CHECK_VERSION
  71 +
  72 +}
  73 +
  74 +static void v3270FTD_init(v3270FTD *widget)
  75 +{
  76 +}
  77 +
  78 +static void browse_file(GtkButton *button,v3270FTD *parent)
  79 +{
  80 + gboolean recv = (parent->options & LIB3270_FT_OPTION_RECEIVE);
  81 + GtkWidget * dialog = gtk_file_chooser_dialog_new
  82 + (
  83 + recv ? _( "Select file to receive" ) : _( "Select file to send" ),
  84 + GTK_WINDOW(parent),
  85 + GTK_FILE_CHOOSER_ACTION_OPEN,
  86 + _("_Cancel" ), GTK_RESPONSE_CANCEL,
  87 + recv ? _("_Save") : _("_Send"), GTK_RESPONSE_ACCEPT,
  88 + NULL
  89 + );
  90 +
  91 + if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
  92 + {
  93 + gchar *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
  94 + gtk_entry_set_text(GTK_ENTRY(parent->filename[FILENAME_LOCAL]),filename);
  95 + g_free(filename);
  96 + }
  97 +
  98 + gtk_widget_destroy(dialog);
  99 +
  100 +
  101 +}
  102 +
  103 +GtkWidget * v3270_dialog_ft_new(LIB3270_FT_OPTION options)
  104 +{
  105 + v3270FTD *dialog = g_object_new(GTK_TYPE_V3270FTD, NULL);
  106 +
  107 + // Set defaults
  108 + dialog->options = options;
  109 +
  110 + // Filename entry
  111 + int f;
  112 +
  113 + GtkWidget * label[FILENAME_COUNT] =
  114 + {
  115 + gtk_label_new_with_mnemonic( _( "_Local file name:" ) ),
  116 + gtk_label_new_with_mnemonic( _( "_Host file name:" ) )
  117 + };
  118 +
  119 + for(f=0;f<FILENAME_COUNT;f++)
  120 + {
  121 + dialog->filename[f] = gtk_entry_new();
  122 + gtk_label_set_mnemonic_widget(GTK_LABEL(label[f]),dialog->filename[f]);
  123 + gtk_widget_set_hexpand(dialog->filename[f],TRUE);
  124 + }
  125 +
  126 + GtkGrid *grid = GTK_GRID(gtk_grid_new());
  127 + gtk_grid_set_row_homogeneous(grid,FALSE);
  128 + gtk_grid_set_column_homogeneous(grid,FALSE);
  129 + gtk_grid_set_column_spacing(grid,5);
  130 + gtk_grid_set_row_spacing(grid,5);
  131 +
  132 +// GtkButton * browse = GTK_BUTTON(gtk_button_new_with_mnemonic(_( "_Browse")));
  133 + GtkButton * browse = GTK_BUTTON(gtk_button_new_from_icon_name("text-x-generic",GTK_ICON_SIZE_BUTTON));
  134 + gtk_button_set_focus_on_click(browse,FALSE);
  135 + gtk_widget_set_tooltip_text(GTK_WIDGET(browse),_("Select file"));
  136 + g_signal_connect(G_OBJECT(browse),"clicked",G_CALLBACK(browse_file),dialog);
  137 +
  138 + if(options & LIB3270_FT_OPTION_RECEIVE)
  139 + {
  140 + // It's receiving file first host filename, then local filename
  141 + gtk_window_set_title(GTK_WINDOW(dialog),_( "Receive file from host" ));
  142 +
  143 + gtk_grid_attach(grid,label[FILENAME_HOST],0,0,1,1);
  144 + gtk_grid_attach(grid,label[FILENAME_LOCAL],0,1,1,1);
  145 +
  146 + gtk_grid_attach(grid,dialog->filename[FILENAME_HOST],1,0,3,1);
  147 + gtk_grid_attach(grid,dialog->filename[FILENAME_LOCAL],1,1,3,1);
  148 + gtk_grid_attach(grid,GTK_WIDGET(browse),5,1,1,1);
  149 +
  150 + gtk_widget_set_tooltip_text(dialog->filename[FILENAME_HOST],_("Name of the origin file on the host"));
  151 + gtk_widget_set_tooltip_text(dialog->filename[FILENAME_LOCAL],_("Where to save the received file"));
  152 +
  153 + }
  154 + else
  155 + {
  156 + // It's sending file first local filename, then hostfilename
  157 + gtk_window_set_title(GTK_WINDOW(dialog),_( "Send file to host" ));
  158 +
  159 + gtk_grid_attach(grid,dialog->filename[FILENAME_LOCAL],0,0,1,1);
  160 + gtk_grid_attach(grid,dialog->filename[FILENAME_HOST],0,1,1,1);
  161 +
  162 + gtk_grid_attach(grid,dialog->filename[FILENAME_LOCAL],1,0,3,1);
  163 + gtk_grid_attach(grid,dialog->filename[FILENAME_HOST],1,1,3,1);
  164 +
  165 + gtk_widget_set_tooltip_text(dialog->filename[FILENAME_HOST],_("Name of the target file on the host"));
  166 + gtk_widget_set_tooltip_text(dialog->filename[FILENAME_LOCAL],_("Path of the local file to send"));
  167 +
  168 + }
  169 +
  170 + gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),GTK_WIDGET(grid),FALSE,TRUE,2);
  171 +
  172 + // File transfer options
  173 +
  174 + return GTK_WIDGET(dialog);
  175 +}
  176 +
... ...
src/pw3270/ft/testprogram.c 0 → 100644
... ... @@ -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 testprogram.c 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 <gtk/gtk.h>
  31 + #include "v3270ft.h"
  32 +
  33 +/*--[ Implement ]------------------------------------------------------------------------------------*/
  34 +
  35 +int main (int argc, char *argv[])
  36 +{
  37 + GtkWidget *win;
  38 +
  39 + gtk_init (&argc, &argv);
  40 + win = v3270_dialog_ft_new(LIB3270_FT_OPTION_RECEIVE);
  41 +
  42 +
  43 + gtk_widget_show_all (win);
  44 + gtk_main ();
  45 + return 0;
  46 +
  47 +}
... ...
src/pw3270/ft/v3270ft.h 0 → 100644
... ... @@ -0,0 +1,67 @@
  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 v3270ft.h 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 + * licinio@bb.com.br (Licínio Luis Branco)
  28 + * kraucer@bb.com.br (Kraucer Fernandes Mazuco)
  29 + *
  30 + */
  31 +
  32 +#ifndef V3270FT_H_INCLUDED
  33 +
  34 + #define ENABLE_NLS
  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 + #include <lib3270.h>
  44 + #include <lib3270/filetransfer.h>
  45 +
  46 + #define V3270FT_H_INCLUDED 1
  47 +
  48 + G_BEGIN_DECLS
  49 +
  50 + #define GTK_TYPE_V3270FTD (v3270FTD_get_type ())
  51 + #define GTK_V3270FTD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_V3270FTD, v3270FTD))
  52 + #define GTK_V3270FTD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_V3270FTD, v3270FTDClass))
  53 + #define GTK_IS_V3270FTD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_V3270FTD))
  54 + #define GTK_IS_V3270FTD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_V3270FTD))
  55 + #define GTK_V3270FTD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_V3270FTD, v3270FTDClass))
  56 +
  57 + typedef struct _v3270FTD v3270FTD;
  58 + typedef struct _v3270FTDClass v3270FTDClass;
  59 +
  60 + // Prototipes
  61 + GtkWidget * v3270_dialog_ft_new(LIB3270_FT_OPTION options);
  62 +
  63 +
  64 +
  65 + G_END_DECLS
  66 +
  67 +#endif // V3270_H_INCLUDED
... ...