Commit 022cd8c53645c6676e823487dcebbd5878abf10d

Authored by Perry Werneck
1 parent c10ef04b

Moving generic tools to libv3270.

src/include/pw3270/tools.h
... ... @@ -1,53 +0,0 @@
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   -/**
31   - * @brief Tool methods.
32   - *
33   - */
34   -
35   -#ifndef PW3270_TOOLS_H_INCLUDED
36   -
37   - #define PW3270_TOOLS_H_INCLUDED
38   -
39   - #include <gtk/gtk.h>
40   -
41   - G_BEGIN_DECLS
42   -
43   - /// @brief Release ptr on 'destroy' signal.
44   - void gtk_widget_bind_ptr(GtkWidget *widget, gpointer ptr);
45   -
46   - /// @brief Bind a GtkEntry to a file chooser dialog.
47   - void gtk_entry_bind_to_filechooser(GtkWidget *entry, GtkFileChooserAction action, const gchar *title, const gchar *icon_name, const gchar *pattern, const gchar *name);
48   -
49   -
50   -
51   - G_END_DECLS
52   -
53   -#endif // PW3270_TOOLS_H_INCLUDED
src/objects/actions/save.c
... ... @@ -37,7 +37,7 @@
37 37 #include <v3270/keyfile.h>
38 38 #include <pw3270.h>
39 39 #include <pw3270/application.h>
40   - #include <pw3270/tools.h>
  40 + #include <v3270/tools.h>
41 41 #include <v3270/settings.h>
42 42  
43 43 static GtkWidget * factory(V3270SimpleAction *action, GtkWidget *terminal);
... ...
src/objects/keypad/element.c
... ... @@ -159,12 +159,12 @@
159 159  
160 160 }
161 161  
162   - static void KeypadElement_init(KeypadElement *object) {
  162 + static void KeypadElement_init(KeypadElement G_GNUC_UNUSED(*object)) {
163 163  
164 164  
165 165 }
166 166  
167   - static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) {
  167 + static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec G_GNUC_UNUSED(*pspec)) {
168 168  
169 169 KeypadElement * element = PW_KEYPAD_ELEMENT(object);
170 170  
... ... @@ -203,7 +203,7 @@
203 203  
204 204 }
205 205  
206   - static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) {
  206 + static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec G_GNUC_UNUSED(*pspec)) {
207 207  
208 208 KeypadElement * element = PW_KEYPAD_ELEMENT(object);
209 209  
... ...
src/objects/os/linux/savedesktopicon.c
... ... @@ -41,7 +41,7 @@
41 41 #include <lib3270.h>
42 42 #include <lib3270/log.h>
43 43 #include <lib3270/properties.h>
44   - #include <pw3270/tools.h>
  44 + #include <v3270/tools.h>
45 45  
46 46 static GtkWidget * factory(V3270SimpleAction *action, GtkWidget *terminal);
47 47 static void response(GtkWidget *dialog, gint response_id, GtkWidget *terminal);
... ...
src/tools/entry.c
... ... @@ -1,144 +0,0 @@
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   - /**
31   - * @brief Implement Linux version of the save desktop icon action.
32   - *
33   - */
34   -
35   - #include <pw3270/tools.h>
36   - #include <pw3270/application.h>
37   - #include <v3270/actions.h>
38   - #include <v3270/keyfile.h>
39   - #include <v3270/settings.h>
40   - #include <lib3270.h>
41   - #include <lib3270/log.h>
42   - #include <lib3270/properties.h>
43   - #include <pw3270.h>
44   -
45   - struct FileEntry {
46   - GtkFileChooserAction action;
47   - const gchar * title;
48   - const gchar * pattern;
49   - const gchar * name;
50   - const gchar * accept;
51   - };
52   -
53   - static void icon_response(GtkDialog *dialog, int response_id, GtkEntry *entry) {
54   -
55   - if(response_id == GTK_RESPONSE_ACCEPT) {
56   - g_autofree gchar * filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
57   - gtk_entry_set_text(entry,filename ? filename : "");
58   - }
59   -
60   - gtk_widget_destroy(GTK_WIDGET(dialog));
61   -
62   - }
63   -
64   - static void icon_press(GtkWidget *entry, G_GNUC_UNUSED GtkEntryIconPosition icon_pos, G_GNUC_UNUSED GdkEvent *event, const struct FileEntry *descr) {
65   -
66   - GtkWidget * dialog =
67   - gtk_file_chooser_dialog_new(
68   - gettext(descr->title),
69   - GTK_WINDOW(gtk_widget_get_toplevel(entry)),
70   - descr->action,
71   - _("Cancel"), GTK_RESPONSE_CANCEL,
72   - descr->accept, GTK_RESPONSE_ACCEPT,
73   - NULL
74   - );
75   -
76   - {
77   - GtkFileFilter *filter;
78   -
79   - // Standard filter
80   - filter = gtk_file_filter_new();
81   - gtk_file_filter_add_pattern (filter, descr->pattern);
82   - gtk_file_filter_set_name(filter, gettext(descr->name));
83   - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog),filter);
84   -
85   - // All files
86   - filter = gtk_file_filter_new();
87   - gtk_file_filter_add_pattern (filter, "*.*");
88   - gtk_file_filter_set_name(filter, _("All files"));
89   - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog),filter);
90   -
91   - }
92   -
93   - gtk_window_set_modal(GTK_WINDOW(dialog),TRUE);
94   - gtk_window_set_deletable(GTK_WINDOW(dialog),FALSE);
95   -
96   - const gchar *filename = gtk_entry_get_text(GTK_ENTRY(entry));
97   -
98   - if(filename && *filename)
99   - gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog),filename);
100   -
101   - g_signal_connect(dialog,"close",G_CALLBACK(gtk_widget_destroy),NULL);
102   - g_signal_connect(dialog,"response",G_CALLBACK(icon_response),entry);
103   -
104   - gtk_widget_show_all(dialog);
105   -
106   -
107   - }
108   -
109   - static void release_ptr(GtkWidget *object, gpointer ptr) {
110   - g_free(ptr);
111   - }
112   -
113   - void gtk_widget_bind_ptr(GtkWidget *widget, gpointer ptr) {
114   - g_signal_connect(widget,"destroy",G_CALLBACK(release_ptr),ptr);
115   - }
116   -
117   - void gtk_entry_bind_to_filechooser(GtkWidget *widget, GtkFileChooserAction action, const gchar *title, const gchar *icon_name, const gchar *pattern, const gchar *name) {
118   -
119   - gtk_entry_set_icon_from_icon_name(
120   - GTK_ENTRY(widget),
121   - GTK_ENTRY_ICON_SECONDARY,
122   - icon_name ? icon_name : "document-open"
123   - );
124   -
125   - // Store data
126   - gsize szEntry = sizeof(struct FileEntry) + strlen(title) + strlen(pattern) + strlen(name) + 4;
127   - struct FileEntry * entry = (struct FileEntry *) g_malloc0(szEntry);
128   - gtk_widget_bind_ptr(widget,entry);
129   -
130   - entry->action = action;
131   - entry->accept = _("Continue");
132   -
133   - entry->title = (const char *) (entry+1);
134   - strcpy((char *) entry->title,title);
135   -
136   - entry->pattern = entry->title + strlen(entry->title) +1;
137   - strcpy((char *) entry->pattern,pattern);
138   -
139   - entry->name = entry->pattern + strlen(entry->pattern) + 1;
140   - strcpy((char *) entry->name,name);
141   -
142   - g_signal_connect(widget,"icon_press",G_CALLBACK(icon_press),(gpointer) entry);
143   -
144   - }