Commit 0f609fc4fc76e1ee431084f0c24e1e4f371e42d2
1 parent
9e4ab834
Exists in
master
and in
4 other branches
Fixing windows build.
Showing
2 changed files
with
179 additions
and
0 deletions
Show diff stats
pw3270.cbp
| ... | ... | @@ -162,6 +162,9 @@ |
| 162 | 162 | <Unit filename="src/objects/window/window.c"> |
| 163 | 163 | <Option compilerVar="CC" /> |
| 164 | 164 | </Unit> |
| 165 | + <Unit filename="src/objects/windows/savedesktopicon.c"> | |
| 166 | + <Option compilerVar="CC" /> | |
| 167 | + </Unit> | |
| 165 | 168 | <Unit filename="ui/application.xml" /> |
| 166 | 169 | <Unit filename="ui/window.xml" /> |
| 167 | 170 | <Extensions> | ... | ... |
| ... | ... | @@ -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 - 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 Windows version of the save desktop icon action. | |
| 32 | + * | |
| 33 | + * References: | |
| 34 | + * | |
| 35 | + * <https://stackoverflow.com/questions/3906974/how-to-programmatically-create-a-shortcut-using-win32> | |
| 36 | + * <https://docs.microsoft.com/pt-br/windows/win32/shell/links?redirectedfrom=MSDN> | |
| 37 | + * | |
| 38 | + */ | |
| 39 | + | |
| 40 | + #include <winsock2.h> | |
| 41 | + #include <windows.h> | |
| 42 | + | |
| 43 | + #include <v3270.h> | |
| 44 | + #include <pw3270.h> | |
| 45 | + #include <pw3270/application.h> | |
| 46 | + #include <v3270/actions.h> | |
| 47 | + #include <lib3270.h> | |
| 48 | + #include <lib3270/log.h> | |
| 49 | + | |
| 50 | + static GtkWidget * factory(V3270SimpleAction *action, GtkWidget *terminal); | |
| 51 | + static void response(GtkWidget *dialog, gint response_id, GtkWidget *terminal); | |
| 52 | + | |
| 53 | + static const struct _entry { | |
| 54 | + | |
| 55 | + const gchar * label; | |
| 56 | + const gchar * tooltip; | |
| 57 | + gint width; | |
| 58 | + | |
| 59 | + } entries[] = { | |
| 60 | + | |
| 61 | + { | |
| 62 | + .label = N_("File name"), | |
| 63 | + .width = 40, | |
| 64 | + }, | |
| 65 | + | |
| 66 | + { | |
| 67 | + .label = N_("Launcher name"), | |
| 68 | + .width = 20, | |
| 69 | + } | |
| 70 | + | |
| 71 | + }; | |
| 72 | + | |
| 73 | + GAction * pw3270_action_save_desktop_icon_new(void) { | |
| 74 | + | |
| 75 | + V3270SimpleAction * action = v3270_dialog_action_new(factory); | |
| 76 | + | |
| 77 | + action->name = "save.launcher"; | |
| 78 | + action->label = _("Save desktop icon"); | |
| 79 | + action->tooltip = _("Create a desktop icon for the current session"); | |
| 80 | + | |
| 81 | + return G_ACTION(action); | |
| 82 | + | |
| 83 | + } | |
| 84 | + | |
| 85 | + GtkWidget * factory(V3270SimpleAction *action, GtkWidget *terminal) { | |
| 86 | + | |
| 87 | + size_t ix; | |
| 88 | + | |
| 89 | + gboolean use_header; | |
| 90 | + g_object_get(gtk_settings_get_default(), "gtk-dialogs-use-header", &use_header, NULL); | |
| 91 | + | |
| 92 | + GtkWidget * dialog = | |
| 93 | + GTK_WIDGET(g_object_new( | |
| 94 | + GTK_TYPE_DIALOG, | |
| 95 | + "use-header-bar", (use_header ? 1 : 0), | |
| 96 | + NULL | |
| 97 | + )); | |
| 98 | + | |
| 99 | + gtk_window_set_modal(GTK_WINDOW(dialog),TRUE); | |
| 100 | + gtk_window_set_title(GTK_WINDOW(dialog),action->label); | |
| 101 | + | |
| 102 | + gtk_dialog_add_buttons( | |
| 103 | + GTK_DIALOG(dialog), | |
| 104 | + _("_Cancel"), GTK_RESPONSE_CANCEL, | |
| 105 | + _("_Save"), GTK_RESPONSE_APPLY, | |
| 106 | + NULL | |
| 107 | + ); | |
| 108 | + | |
| 109 | + g_signal_connect(dialog,"response",G_CALLBACK(response),terminal); | |
| 110 | + | |
| 111 | + // Create entry fields | |
| 112 | + GtkWidget ** inputs = g_new0(GtkWidget *,G_N_ELEMENTS(entries)); | |
| 113 | + g_object_set_data_full(G_OBJECT(dialog),"inputs",inputs,g_free); | |
| 114 | + debug("Dialog=%p inputs=%p",dialog,inputs); | |
| 115 | + | |
| 116 | + GtkGrid * grid = GTK_GRID(gtk_grid_new()); | |
| 117 | + | |
| 118 | + gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),GTK_WIDGET(grid),TRUE,TRUE,0); | |
| 119 | + | |
| 120 | + // https://developer.gnome.org/hig/stable/visual-layout.html.en | |
| 121 | + gtk_container_set_border_width(GTK_CONTAINER(grid),18); | |
| 122 | + gtk_grid_set_row_spacing(GTK_GRID(grid),6); | |
| 123 | + gtk_grid_set_column_spacing(GTK_GRID(grid),12); | |
| 124 | + | |
| 125 | + // https://developer.gnome.org/hig/stable/visual-layout.html.en | |
| 126 | + // gtk_box_set_spacing(GTK_BOX(content_area),18); | |
| 127 | + | |
| 128 | + for(ix = 0; ix < G_N_ELEMENTS(entries); ix++) { | |
| 129 | + | |
| 130 | + GtkWidget * label = gtk_label_new(gettext(entries[ix].label)); | |
| 131 | + gtk_label_set_xalign(GTK_LABEL(label),1); | |
| 132 | + gtk_grid_attach(grid,label,0,ix,1,1); | |
| 133 | + | |
| 134 | + inputs[ix] = gtk_entry_new(); | |
| 135 | + debug("inputs[%u]=%p",(unsigned int) ix, inputs[ix]); | |
| 136 | + | |
| 137 | + gtk_entry_set_width_chars(GTK_ENTRY(inputs[ix]),entries[ix].width); | |
| 138 | +// gtk_entry_set_max_width_chars(GTK_ENTRY(inputs[ix]),entries[ix].n_chars); | |
| 139 | + gtk_widget_set_hexpand(inputs[ix],FALSE); | |
| 140 | + gtk_widget_set_vexpand(inputs[ix],FALSE); | |
| 141 | + | |
| 142 | + gtk_grid_attach(grid,inputs[ix],1,ix,entries[ix].width,1); | |
| 143 | + | |
| 144 | + } | |
| 145 | + | |
| 146 | + /* | |
| 147 | + | |
| 148 | + gtk_entry_set_text(GTK_ENTRY(inputs[0]),filename); | |
| 149 | + | |
| 150 | + gtk_entry_set_placeholder_text(GTK_ENTRY(inputs[1]),G_STRINGIFY(PRODUCT_NAME)); | |
| 151 | + gtk_entry_set_text(GTK_ENTRY(inputs[1]),G_STRINGIFY(PRODUCT_NAME)); | |
| 152 | + | |
| 153 | + gtk_entry_set_placeholder_text(GTK_ENTRY(inputs[2]),G_STRINGIFY(PRODUCT_NAME)); | |
| 154 | + gtk_entry_set_text(GTK_ENTRY(inputs[2]),G_STRINGIFY(PRODUCT_NAME)); | |
| 155 | + | |
| 156 | + gtk_entry_set_placeholder_text(GTK_ENTRY(inputs[3]),v3270_get_url(terminal)); | |
| 157 | + gtk_entry_set_text(GTK_ENTRY(inputs[3]),v3270_get_url(terminal)); | |
| 158 | + gtk_entry_set_input_hints(GTK_ENTRY(inputs[3]),GTK_INPUT_HINT_SPELLCHECK); | |
| 159 | + | |
| 160 | + */ | |
| 161 | + | |
| 162 | + gtk_widget_show_all(GTK_WIDGET(grid)); | |
| 163 | + return dialog; | |
| 164 | + } | |
| 165 | + | |
| 166 | + void response(GtkWidget *dialog, gint response_id, GtkWidget *terminal) { | |
| 167 | + | |
| 168 | + debug("%s(%d)",__FUNCTION__,response_id); | |
| 169 | + | |
| 170 | + if(response_id == GTK_RESPONSE_APPLY) { | |
| 171 | + | |
| 172 | + } | |
| 173 | + | |
| 174 | + gtk_widget_destroy(dialog); | |
| 175 | + | |
| 176 | +} | ... | ... |