Commit e9b0d2f1a60d4621ee1ce52f4831759cacf7cc6e
1 parent
817d865e
Exists in
master
and in
1 other branch
Starting file save dialog.
Showing
6 changed files
with
185 additions
and
36 deletions
Show diff stats
src/dialogs/save/private.h
... | ... | @@ -28,54 +28,31 @@ |
28 | 28 | */ |
29 | 29 | |
30 | 30 | #include <v3270.h> |
31 | + #include <save.h> | |
31 | 32 | #include <v3270/print.h> |
32 | 33 | #include <lib3270/log.h> |
33 | 34 | #include <lib3270/trace.h> |
34 | 35 | |
35 | 36 | /*--[ Widget definition ]----------------------------------------------------------------------------*/ |
36 | 37 | |
37 | - struct _V3270PrintOperationClass | |
38 | + struct _V3270SaveDialog | |
38 | 39 | { |
39 | - GtkPrintOperationClass parent_class; | |
40 | + GtkDialog parent; | |
40 | 41 | |
41 | - }; | |
42 | + GtkWidget * terminal; | |
43 | + GtkWidget * filename; | |
44 | + LIB3270_CONTENT_OPTION mode; | |
42 | 45 | |
43 | - typedef struct _column | |
44 | - { | |
45 | - unsigned char c; | |
46 | - unsigned short attr; | |
47 | - } column; | |
46 | + }; | |
48 | 47 | |
49 | - struct _V3270PrintOperation | |
48 | + struct _V3270SaveDialogClass | |
50 | 49 | { |
51 | - GtkPrintOperation parent; | |
52 | - GdkRGBA colors[V3270_COLOR_COUNT]; | |
53 | - LIB3270_CONTENT_OPTION mode; | |
54 | - v3270 * widget; | |
55 | - H3270 * session; | |
56 | - | |
57 | - size_t lpp; ///< @brief Lines per page (in rows). | |
58 | - size_t pages; ///< @brief Number of pages. | |
59 | - gboolean show_selection; ///< @brief Print selection box? | |
60 | - | |
61 | - struct | |
62 | - { | |
63 | - size_t width; ///< @brief Width of the contents (in columns); | |
64 | - size_t height; ///< @brief Height of the contents (in rows); | |
65 | - column **text; ///< @brief Report contents. | |
66 | - } contents; | |
67 | - | |
68 | - struct | |
69 | - { | |
70 | - gchar * name; | |
71 | - v3270FontInfo info; | |
72 | - } font; | |
50 | + GtkDialogClass parent_class; | |
51 | + int dummy; | |
73 | 52 | |
74 | 53 | }; |
75 | 54 | |
76 | 55 | /*--[ Prototypes ]-----------------------------------------------------------------------------------*/ |
77 | 56 | |
78 | - G_GNUC_INTERNAL void V3270PrintOperation_begin_print(GtkPrintOperation *prt, GtkPrintContext *context); | |
79 | - G_GNUC_INTERNAL void V3270PrintOperation_draw_page(GtkPrintOperation *prt, GtkPrintContext *context, gint page); | |
80 | 57 | |
81 | 58 | ... | ... |
src/dialogs/save/save.c
... | ... | @@ -28,8 +28,95 @@ |
28 | 28 | */ |
29 | 29 | |
30 | 30 | #include "private.h" |
31 | + #include <limits.h> | |
32 | + | |
33 | +/*--[ GTK Requires ]---------------------------------------------------------------------------------*/ | |
34 | + | |
35 | + G_DEFINE_TYPE(V3270SaveDialog, V3270SaveDialog, GTK_TYPE_DIALOG); | |
31 | 36 | |
32 | 37 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
33 | 38 | |
39 | + static void V3270SaveDialog_finalize(V3270SaveDialog *object) | |
40 | + { | |
41 | + V3270SaveDialog *dialog = V3270_SAVE_DIALOG(object); | |
42 | + } | |
43 | + | |
44 | + static void V3270SaveDialog_class_init(V3270SaveDialogClass *klass) | |
45 | + { | |
46 | + | |
47 | + debug("%s",__FUNCTION__); | |
48 | + G_OBJECT_CLASS(klass)->finalize = V3270SaveDialog_finalize; | |
49 | + | |
50 | + } | |
51 | + | |
52 | + static void V3270SaveDialog_init(V3270SaveDialog *dialog) | |
53 | + { | |
54 | + dialog->mode = LIB3270_CONTENT_ALL; | |
55 | + | |
56 | + // Setup visual elements | |
57 | + // https://developer.gnome.org/hig/stable/visual-layout.html.en | |
58 | + GtkWidget *widget; | |
59 | + | |
60 | + GtkBox * box = GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))); | |
61 | + gtk_window_set_resizable(GTK_WINDOW(dialog),FALSE); | |
62 | + gtk_container_set_border_width(GTK_CONTAINER(box),18); | |
63 | + | |
64 | + GtkGrid * grid = GTK_GRID(gtk_grid_new()); | |
65 | + gtk_grid_set_row_spacing(GTK_GRID(grid),6); | |
66 | + gtk_grid_set_column_spacing(GTK_GRID(grid),12); | |
67 | + gtk_box_pack_start(box,GTK_WIDGET(grid),TRUE,TRUE,2); | |
68 | + | |
69 | + dialog->filename = GTK_ENTRY(gtk_entry_new()); | |
70 | + gtk_widget_set_hexpand(GTK_WIDGET(dialog->filename),TRUE); | |
71 | + | |
72 | + widget = gtk_label_new_with_mnemonic("_Filename:"); | |
73 | + gtk_widget_set_halign(widget,GTK_ALIGN_END); | |
74 | + gtk_widget_set_valign(widget,GTK_ALIGN_CENTER); | |
75 | + gtk_grid_attach(grid,GTK_WIDGET(widget),0,0,1,1); | |
76 | + gtk_label_set_mnemonic_widget(GTK_LABEL(widget),dialog->filename); | |
77 | + | |
78 | +#ifdef WIN32 | |
79 | + widget = gtk_button_new_from_icon_name("document-open",GTK_ICON_SIZE_BUTTON); | |
80 | + //g_signal_connect(G_OBJECT(widget),"clicked",G_CALLBACK(select_local_file),dialog); | |
81 | + gtk_grid_attach(grid,widget,2,0,1,1); | |
82 | +#else | |
83 | + gtk_entry_set_icon_from_icon_name(dialog->filename,GTK_ENTRY_ICON_SECONDARY,"document-open"); | |
84 | + gtk_entry_set_icon_activatable(dialog->filename,GTK_ENTRY_ICON_SECONDARY,TRUE); | |
85 | + gtk_entry_set_icon_tooltip_text(dialog->filename,GTK_ENTRY_ICON_SECONDARY,_("Select file")); | |
86 | + // g_signal_connect(G_OBJECT(dialog->filename),"icon-press",G_CALLBACK(icon_press),dialog); | |
87 | +#endif // WIN32 | |
88 | + | |
89 | + gtk_entry_set_width_chars(dialog->filename,60); | |
90 | + gtk_entry_set_max_length(dialog->filename,PATH_MAX); | |
91 | + gtk_grid_attach(grid,GTK_WIDGET(dialog->filename),1,0,1,1); | |
92 | + | |
93 | + | |
94 | + } | |
95 | + | |
96 | + GtkWidget * v3270_save_dialog_new(GtkWidget *widget, LIB3270_CONTENT_OPTION mode, const gchar *filename) | |
97 | + { | |
98 | + V3270SaveDialog * dialog = V3270_SAVE_DIALOG(g_object_new(GTK_TYPE_V3270SaveDialog, NULL)); | |
99 | + dialog->mode = mode; | |
100 | + | |
101 | + if(filename) | |
102 | + gtk_entry_set_text(GTK_ENTRY(dialog->filename),filename); | |
103 | + | |
104 | + gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(gtk_widget_get_toplevel(widget))); | |
105 | + gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); | |
106 | + gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE); | |
107 | + | |
108 | + // https://developer.gnome.org/hig/stable/visual-layout.html.en | |
109 | + GtkGrid * grid = GTK_GRID(gtk_grid_new()); | |
110 | + gtk_grid_set_row_spacing(GTK_GRID(grid),6); | |
111 | + gtk_grid_set_column_spacing(GTK_GRID(grid),12); | |
112 | + | |
113 | + | |
114 | + return GTK_WIDGET(dialog); | |
115 | + } | |
116 | + | |
117 | + void v3270_save_dialog_run(GtkWidget *widget) | |
118 | + { | |
119 | + gtk_dialog_run(GTK_DIALOG(widget)); | |
120 | + } | |
34 | 121 | |
35 | 122 | ... | ... |
src/include/hostselect.h
... | ... | @@ -18,7 +18,7 @@ |
18 | 18 | * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin |
19 | 19 | * St, Fifth Floor, Boston, MA 02110-1301 USA |
20 | 20 | * |
21 | - * Este programa está nomeado como hostdialog.h e possui - linhas de código. | |
21 | + * Este programa está nomeado como - e possui - linhas de código. | |
22 | 22 | * |
23 | 23 | * Contatos: |
24 | 24 | * |
... | ... | @@ -29,6 +29,8 @@ |
29 | 29 | |
30 | 30 | #ifndef V3270HOST_H_INCLUDED |
31 | 31 | |
32 | + #define V3270HOST_H_INCLUDED 1 | |
33 | + | |
32 | 34 | #include <config.h> |
33 | 35 | #define ENABLE_NLS |
34 | 36 | |
... | ... | @@ -41,8 +43,6 @@ |
41 | 43 | #include <gtk/gtk.h> |
42 | 44 | #include <lib3270.h> |
43 | 45 | |
44 | - #define V3270FT_H_INCLUDED 1 | |
45 | - | |
46 | 46 | G_BEGIN_DECLS |
47 | 47 | |
48 | 48 | /*--[ Progress widget ]------------------------------------------------------------------------------*/ | ... | ... |
... | ... | @@ -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 - 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 | +#ifndef V3270SAVE_H_INCLUDED | |
31 | + | |
32 | + #define V3270SAVE_H_INCLUDED 1 | |
33 | + | |
34 | + #include <config.h> | |
35 | + #define ENABLE_NLS | |
36 | + | |
37 | + #ifndef GETTEXT_PACKAGE | |
38 | + #define GETTEXT_PACKAGE PACKAGE_NAME | |
39 | + #endif | |
40 | + | |
41 | + #include <libintl.h> | |
42 | + #include <glib/gi18n.h> | |
43 | + #include <gtk/gtk.h> | |
44 | + #include <lib3270.h> | |
45 | + | |
46 | + G_BEGIN_DECLS | |
47 | + | |
48 | +/*--[ Progress widget ]------------------------------------------------------------------------------*/ | |
49 | + | |
50 | + #define GTK_TYPE_V3270SaveDialog (V3270SaveDialog_get_type ()) | |
51 | + #define V3270_SAVE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_V3270SaveDialog, V3270SaveDialog)) | |
52 | + #define V3270SaveDialog_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_V3270SaveDialog, V3270SaveDialogClass)) | |
53 | + #define IS_V3270SaveDialog(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_V3270SaveDialog)) | |
54 | + #define IS_V3270SaveDialog_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_V3270SaveDialog)) | |
55 | + #define V3270SaveDialog_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_V3270SaveDialog, V3270SaveDialogClass)) | |
56 | + | |
57 | + typedef struct _V3270SaveDialog V3270SaveDialog; | |
58 | + typedef struct _V3270SaveDialogClass V3270SaveDialogClass; | |
59 | + | |
60 | +/*--[ Prototipes ]-----------------------------------------------------------------------------------*/ | |
61 | + | |
62 | + GtkWidget * v3270_save_dialog_new(GtkWidget *widget, LIB3270_CONTENT_OPTION mode, const gchar *filename); | |
63 | + void v3270_save_dialog_run(GtkWidget *widget); | |
64 | + | |
65 | + G_END_DECLS | |
66 | + | |
67 | +#endif // V3270SAVE_H_INCLUDED | ... | ... |
src/terminal/callbacks.c
... | ... | @@ -35,6 +35,7 @@ |
35 | 35 | |
36 | 36 | #include <terminal.h> |
37 | 37 | #include <internals.h> |
38 | + #include <save.h> | |
38 | 39 | |
39 | 40 | #include <gtk/gtk.h> |
40 | 41 | #include <libintl.h> |
... | ... | @@ -356,6 +357,21 @@ static int print(H3270 *session, LIB3270_CONTENT_OPTION mode) |
356 | 357 | return 0; |
357 | 358 | } |
358 | 359 | |
360 | +static int save(H3270 *session, LIB3270_CONTENT_OPTION mode, const char *filename) | |
361 | +{ | |
362 | + GtkWidget * widget = GTK_WIDGET(lib3270_get_user_data(session)); | |
363 | + | |
364 | + if(!GTK_IS_V3270(widget)) | |
365 | + return EINVAL; | |
366 | + | |
367 | + GtkWidget *dialog = v3270_save_dialog_new(widget,mode,filename); | |
368 | + gtk_widget_show_all(dialog); | |
369 | + v3270_save_dialog_run(dialog); | |
370 | + gtk_widget_destroy(dialog); | |
371 | + | |
372 | + return 0; | |
373 | +} | |
374 | + | |
359 | 375 | static void popup_handler(H3270 *session, LIB3270_NOTIFY type, const char *title, const char *msg, const char *fmt, va_list args) |
360 | 376 | { |
361 | 377 | GtkWidget *terminal = (GtkWidget *) lib3270_get_user_data(session); |
... | ... | @@ -501,6 +517,7 @@ static void popup_handler(H3270 *session, LIB3270_NOTIFY type, const char *title |
501 | 517 | cbk->message = message; |
502 | 518 | cbk->update_ssl = update_ssl; |
503 | 519 | cbk->print = print; |
520 | + cbk->save = save; | |
504 | 521 | cbk->popup_ssl_error = popup_ssl_error; |
505 | 522 | |
506 | 523 | } | ... | ... |
v3270.cbp
... | ... | @@ -142,6 +142,7 @@ |
142 | 142 | <Unit filename="src/include/config.h.in" /> |
143 | 143 | <Unit filename="src/include/hostselect.h" /> |
144 | 144 | <Unit filename="src/include/internals.h" /> |
145 | + <Unit filename="src/include/save.h" /> | |
145 | 146 | <Unit filename="src/include/terminal.h" /> |
146 | 147 | <Unit filename="src/include/v3270.h" /> |
147 | 148 | <Unit filename="src/include/v3270/accessible.h" /> | ... | ... |