diff --git a/src/include/v3270/filetransfer.h b/src/include/v3270/filetransfer.h index e9edd8b..4d6cc0a 100644 --- a/src/include/v3270/filetransfer.h +++ b/src/include/v3270/filetransfer.h @@ -94,6 +94,20 @@ LIB3270_EXPORT GtkWidget * v3270_ft_settings_new(); + // FT Dialog widget + #define GTK_TYPE_V3270_FT_DIALOG (V3270FTDialog_get_type ()) + #define GTK_V3270_FT_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_V3270_FT_DIALOG, V3270FTDialog)) + #define GTK_V3270_FT_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_V3270_FT_DIALOG, V3270FTDialogClass)) + #define GTK_IS_V3270_FT_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_V3270_FT_DIALOG)) + #define GTK_IS_V3270_FT_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_V3270_FT_DIALOG)) + #define GTK_V3270_FT_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_V3270_FT_DIALOG, V3270FTDialogClass)) + + typedef struct _V3270FTDialog V3270FTDialog; + typedef struct _V3270FTDialogClass V3270FTDialogClass; + + LIB3270_EXPORT GtkWidget * v3270_ft_dialog_new(GtkWidget *parent); + + G_END_DECLS #endif // V3270FT_H_INCLUDED diff --git a/src/testprogram/testprogram.c b/src/testprogram/testprogram.c index 4a86146..a28500e 100644 --- a/src/testprogram/testprogram.c +++ b/src/testprogram/testprogram.c @@ -149,20 +149,7 @@ static void disconnect_clicked(GtkButton G_GNUC_UNUSED(*button), GtkWidget *term static void ft_clicked(GtkButton G_GNUC_UNUSED(*button), GtkWidget *terminal) { - GtkWidget * dialog = gtk_dialog_new_with_buttons( - _("FT Settings"), - GTK_WINDOW(gtk_widget_get_toplevel(terminal)), - GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, - _( "_Close" ), GTK_RESPONSE_ACCEPT, - NULL - ); - - gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),v3270_ft_settings_new(),TRUE,TRUE,2); - - /* - GtkWidget * dialog = v3270ft_new(); - gtk_window_set_transient_for(GTK_WINDOW(dialog),GTK_WINDOW(gtk_widget_get_toplevel(terminal))); - */ + GtkWidget * dialog = v3270_ft_dialog_new(terminal); gtk_widget_show_all(dialog); gtk_dialog_run(GTK_DIALOG(dialog)); diff --git a/src/v3270ft/dialog.c b/src/v3270ft/dialog.c new file mode 100644 index 0000000..654ec6b --- /dev/null +++ b/src/v3270ft/dialog.c @@ -0,0 +1,152 @@ +/* + * "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 + #include + #include "private.h" + +/*--[ Widget definition ]----------------------------------------------------------------------------*/ + + struct _V3270FTDialog + { + GtkDialog parent; + + GtkWidget * settings; + // GtkWidget * buttons[FT_BUTTON_COUNT]; + + }; + + struct _V3270FTDialogClass + { + GtkDialogClass parent_class; + }; + + G_DEFINE_TYPE(V3270FTDialog, V3270FTDialog, GTK_TYPE_DIALOG); + +/*--[ Implement ]------------------------------------------------------------------------------------*/ + +static void V3270FTDialog_class_init(G_GNUC_UNUSED V3270FTDialogClass *klass) +{ +} + +/* +static void apply_clicked(GtkButton G_GNUC_UNUSED(*button), GtkWidget *dialog) +{ + gtk_dialog_response(GTK_DIALOG(dialog),GTK_RESPONSE_APPLY); +} + +static void cancel_clicked(GtkButton G_GNUC_UNUSED(*button), GtkWidget *dialog) +{ + gtk_dialog_response(GTK_DIALOG(dialog),GTK_RESPONSE_CANCEL); +} +*/ + +/* +static GtkWidget * create_button(V3270FTDialog *widget, FT_BUTTON id, const gchar *icon, const gchar *tooltip, GCallback callback) +{ + widget->buttons[id] = gtk_button_new_from_icon_name(icon,GTK_ICON_SIZE_BUTTON); + gtk_widget_set_tooltip_markup(widget->buttons[id],tooltip); + + // g_signal_connect(widget->buttons[id],"clicked",callback,widget); + + return widget->buttons[id]; +} +*/ + +static void V3270FTDialog_init(V3270FTDialog *widget) +{ + widget->settings = v3270_ft_settings_new(); + + gtk_window_set_title(GTK_WINDOW(widget),_( "3270 File transfer")); + + // https://developer.gnome.org/hig/stable/visual-layout.html.en + gtk_container_set_border_width(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(widget))),18); + + // Create box + GtkWidget * container = gtk_box_new(GTK_ORIENTATION_VERTICAL,6); + gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(widget))),container,TRUE,TRUE,0); + + // Pack settings widget + gtk_widget_set_halign(GTK_WIDGET(widget->settings),GTK_ALIGN_START); + gtk_widget_set_hexpand(GTK_WIDGET(widget->settings),FALSE); + gtk_widget_set_vexpand(GTK_WIDGET(widget->settings),FALSE); + gtk_box_pack_start(GTK_BOX(container),widget->settings,FALSE,FALSE,0); + + + // Create file list view + { + GtkTreeModel * model = GTK_TREE_MODEL(gtk_tree_store_new(1,G_TYPE_STRING)); + GtkWidget * files = gtk_tree_view_new_with_model(model); + + gtk_widget_set_tooltip_markup(files,_("Files to transfer")); + + gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(files),TRUE); + gtk_tree_view_insert_column_with_attributes( + GTK_TREE_VIEW(files), + -1, + _( "Local file name" ),gtk_cell_renderer_text_new(),"text", + 0, NULL + ); + + // Put the view inside a scrolled window. + GtkWidget * scrolled = gtk_scrolled_window_new(NULL,NULL); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC); + gtk_container_add(GTK_CONTAINER(scrolled),files); + + gtk_widget_set_vexpand(scrolled,TRUE); + gtk_widget_set_hexpand(scrolled,TRUE); + + gtk_box_pack_start(GTK_BOX(container),scrolled,TRUE,TRUE,0); + } + + +} + +LIB3270_EXPORT GtkWidget * v3270_ft_dialog_new(GtkWidget *parent) +{ + gboolean use_header; + g_object_get(gtk_settings_get_default(), "gtk-dialogs-use-header", &use_header, NULL); + + GtkWidget * dialog = + GTK_WIDGET(g_object_new( + GTK_TYPE_V3270_FT_DIALOG, + "use-header-bar", 0, // (use_header ? 1 : 0), + NULL + )); + + if(parent) + { + gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(gtk_widget_get_toplevel(parent))); + gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); + gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE); + } + + return dialog; +} + diff --git a/src/v3270ft/ftdialog.cbp b/src/v3270ft/ftdialog.cbp deleted file mode 100644 index 071cacf..0000000 --- a/src/v3270ft/ftdialog.cbp +++ /dev/null @@ -1,140 +0,0 @@ - - - - - - diff --git a/src/v3270ft/settings.c b/src/v3270ft/settings.c index 67a8400..cd244c5 100644 --- a/src/v3270ft/settings.c +++ b/src/v3270ft/settings.c @@ -180,6 +180,7 @@ static void open_select_file_dialog(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconP } else { + debug("%s option selected","LIB3270_FT_OPTION_SEND"); gtk_widget_set_sensitive(widget->recordFormatBox,TRUE); @@ -199,6 +200,9 @@ static void open_select_file_dialog(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconP gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget->options[ix]),(options & ft_option[ix].opt) == ft_option[ix].opt); } + gtk_widget_set_sensitive(GTK_WIDGET(widget->file.local),TRUE); + gtk_widget_set_sensitive(GTK_WIDGET(widget->file.remote),TRUE); + } static void transfer_type_changed(GtkComboBox *widget, V3270FTSettings *dialog) @@ -208,7 +212,14 @@ static void open_select_file_dialog(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconP debug("Transfer type=%u", (unsigned int) selected); if(selected >= 0) + { set_options(dialog,ft_type[selected].opt); + } + else + { + gtk_widget_set_sensitive(GTK_WIDGET(dialog->file.local),FALSE); + gtk_widget_set_sensitive(GTK_WIDGET(dialog->file.remote),FALSE); + } } @@ -343,6 +354,9 @@ static void open_select_file_dialog(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconP } + gtk_widget_set_sensitive(GTK_WIDGET(widget->file.local),FALSE); + gtk_widget_set_sensitive(GTK_WIDGET(widget->file.remote),FALSE); + } LIB3270_EXPORT GtkWidget * v3270_ft_settings_new() diff --git a/v3270.cbp b/v3270.cbp index 213b7b7..017a0d5 100644 --- a/v3270.cbp +++ b/v3270.cbp @@ -141,6 +141,9 @@ + + -- libgit2 0.21.2