Commit a1522c287e1dc44ff4c285727d70c1b4626815e2
1 parent
6fbd46ad
Exists in
master
and in
2 other branches
Fixing windows build.
Showing
1 changed file
with
87 additions
and
12 deletions
Show diff stats
src/objects/os/windows/savedesktopicon.c
@@ -52,6 +52,9 @@ | @@ -52,6 +52,9 @@ | ||
52 | #include <v3270/actions.h> | 52 | #include <v3270/actions.h> |
53 | #include <lib3270.h> | 53 | #include <lib3270.h> |
54 | #include <lib3270/log.h> | 54 | #include <lib3270/log.h> |
55 | + #include <pw3270/tools.h> | ||
56 | + #include <v3270/keyfile.h> | ||
57 | + #include <v3270/settings.h> | ||
55 | 58 | ||
56 | static GtkWidget * factory(V3270SimpleAction *action, GtkWidget *terminal); | 59 | static GtkWidget * factory(V3270SimpleAction *action, GtkWidget *terminal); |
57 | static void response(GtkWidget *dialog, gint response_id, GtkWidget *terminal); | 60 | static void response(GtkWidget *dialog, gint response_id, GtkWidget *terminal); |
@@ -60,18 +63,37 @@ | @@ -60,18 +63,37 @@ | ||
60 | 63 | ||
61 | const gchar * label; | 64 | const gchar * label; |
62 | const gchar * tooltip; | 65 | const gchar * tooltip; |
66 | + gint margin_top; | ||
63 | gint width; | 67 | gint width; |
64 | 68 | ||
65 | } entries[] = { | 69 | } entries[] = { |
66 | 70 | ||
71 | + // 0 - Shorcut file name | ||
67 | { | 72 | { |
68 | - .label = N_("Launcher name"), | 73 | + .label = N_("Shortcut file"), |
74 | + .tooltip = N_("Path for the new shortcut"), | ||
69 | .width = 40, | 75 | .width = 40, |
70 | }, | 76 | }, |
71 | 77 | ||
78 | + // 1 - Shortcut description | ||
72 | { | 79 | { |
73 | .label = N_("Description"), | 80 | .label = N_("Description"), |
74 | .width = 20, | 81 | .width = 20, |
82 | + }, | ||
83 | + | ||
84 | + // 2 = Session name | ||
85 | + { | ||
86 | + .label = N_("Session name"), | ||
87 | + .margin_top = 12, | ||
88 | + .tooltip = N_("The session name used in the window/tab title (empty for default)"), | ||
89 | + .width = 15, | ||
90 | + }, | ||
91 | + | ||
92 | + // 3 = Session file | ||
93 | + { | ||
94 | + .label = N_("Session file"), | ||
95 | + .tooltip = N_("The file with the session preferences for this shortcut"), | ||
96 | + .width = 40, | ||
75 | } | 97 | } |
76 | 98 | ||
77 | }; | 99 | }; |
@@ -141,11 +163,30 @@ | @@ -141,11 +163,30 @@ | ||
141 | gtk_widget_set_hexpand(inputs[ix],FALSE); | 163 | gtk_widget_set_hexpand(inputs[ix],FALSE); |
142 | gtk_widget_set_vexpand(inputs[ix],FALSE); | 164 | gtk_widget_set_vexpand(inputs[ix],FALSE); |
143 | 165 | ||
166 | + if(entries[ix].tooltip) { | ||
167 | + gtk_widget_set_tooltip_markup(GTK_WIDGET(inputs[ix]),gettext(entries[ix].tooltip)); | ||
168 | + } | ||
169 | + | ||
170 | + if(entries[ix].margin_top) { | ||
171 | + gtk_widget_set_margin_top(label,entries[ix].margin_top); | ||
172 | + gtk_widget_set_margin_top(inputs[ix],entries[ix].margin_top); | ||
173 | + } | ||
174 | + | ||
144 | gtk_grid_attach(grid,inputs[ix],1,ix,entries[ix].width,1); | 175 | gtk_grid_attach(grid,inputs[ix],1,ix,entries[ix].width,1); |
145 | 176 | ||
146 | } | 177 | } |
147 | 178 | ||
179 | + // Setup short-cut name entry. | ||
148 | { | 180 | { |
181 | + gtk_entry_bind_to_filechooser( | ||
182 | + inputs[0], | ||
183 | + GTK_FILE_CHOOSER_ACTION_SAVE, | ||
184 | + _("Save to windows shortcut"), | ||
185 | + NULL, | ||
186 | + "*.lnk", | ||
187 | + _("Windows shortcuts") | ||
188 | + ); | ||
189 | + | ||
149 | gchar * filename = g_strdup_printf( | 190 | gchar * filename = g_strdup_printf( |
150 | "%s\\" G_STRINGIFY(PRODUCT_NAME) ".lnk", | 191 | "%s\\" G_STRINGIFY(PRODUCT_NAME) ".lnk", |
151 | g_get_user_special_dir(G_USER_DIRECTORY_DESKTOP) | 192 | g_get_user_special_dir(G_USER_DIRECTORY_DESKTOP) |
@@ -168,11 +209,20 @@ | @@ -168,11 +209,20 @@ | ||
168 | g_free(filename); | 209 | g_free(filename); |
169 | } | 210 | } |
170 | 211 | ||
212 | + gtk_entry_bind_to_filechooser( | ||
213 | + inputs[3], | ||
214 | + GTK_FILE_CHOOSER_ACTION_SAVE, | ||
215 | + _("Save to session filename"), | ||
216 | + NULL, | ||
217 | + "*.3270", | ||
218 | + _("3270 session files") | ||
219 | + ); | ||
220 | + | ||
171 | gtk_widget_show_all(GTK_WIDGET(grid)); | 221 | gtk_widget_show_all(GTK_WIDGET(grid)); |
172 | return dialog; | 222 | return dialog; |
173 | } | 223 | } |
174 | 224 | ||
175 | - static HRESULT CreateShortCut(LPSTR pszTargetfile, LPSTR pszTargetargs, LPSTR pszLinkfile, LPSTR pszDescription, int iShowmode, LPSTR pszCurdir, LPSTR pszIconfile, int iIconindex) { | 225 | + static HRESULT CreateShortCut(const char * pszTargetfile, const char * pszTargetargs, const char * pszLinkfile, const char * pszDescription, int iShowmode, const char * pszCurdir, LPSTR pszIconfile, int iIconindex) { |
176 | 226 | ||
177 | // https://www.codeproject.com/Articles/11467/How-to-create-short-cuts-link-files | 227 | // https://www.codeproject.com/Articles/11467/How-to-create-short-cuts-link-files |
178 | IShellLink* pShellLink; // IShellLink object pointer | 228 | IShellLink* pShellLink; // IShellLink object pointer |
@@ -255,16 +305,41 @@ | @@ -255,16 +305,41 @@ | ||
255 | // Save desktop icon | 305 | // Save desktop icon |
256 | GtkWidget ** inputs = g_object_get_data(G_OBJECT(dialog),"inputs"); | 306 | GtkWidget ** inputs = g_object_get_data(G_OBJECT(dialog),"inputs"); |
257 | 307 | ||
258 | - HRESULT hRes = CreateShortCut( | ||
259 | - NULL, // LPSTR pszTargetfile, | ||
260 | - v3270_key_file_get_file_name(terminal), // LPSTR pszTargetargs, | ||
261 | - gtk_entry_get_text(GTK_ENTRY(inputs[0])), // LPSTR pszLinkfile, | ||
262 | - gtk_entry_get_text(GTK_ENTRY(inputs[1])), //LPSTR pszDescription, | ||
263 | - 0, | ||
264 | - NULL, | ||
265 | - NULL, | ||
266 | - 0 | ||
267 | - ); | 308 | + // Save keyfile |
309 | + GError * error = NULL; | ||
310 | + v3270_key_file_save_to_file( | ||
311 | + terminal, | ||
312 | + gtk_entry_get_text(GTK_ENTRY(inputs[3])), | ||
313 | + &error | ||
314 | + ); | ||
315 | + | ||
316 | + if(!error) { | ||
317 | + | ||
318 | + HRESULT hRes = CreateShortCut( | ||
319 | + NULL, // LPSTR pszTargetfile, | ||
320 | + gtk_entry_get_text(GTK_ENTRY(inputs[3])), // LPSTR pszTargetargs, | ||
321 | + gtk_entry_get_text(GTK_ENTRY(inputs[0])), // LPSTR pszLinkfile, | ||
322 | + gtk_entry_get_text(GTK_ENTRY(inputs[1])), // LPSTR pszDescription, | ||
323 | + 0, | ||
324 | + NULL, | ||
325 | + NULL, | ||
326 | + 0 | ||
327 | + ); | ||
328 | + | ||
329 | + } | ||
330 | + | ||
331 | + if(error) { | ||
332 | + | ||
333 | + g_message("%s",error->message); | ||
334 | + g_error_free(error); | ||
335 | + | ||
336 | + } else { | ||
337 | + | ||
338 | + // Set session name (after save to avoid changes on the old session file). | ||
339 | + v3270_set_session_name(terminal,gtk_entry_get_text(GTK_ENTRY(inputs[2]))); | ||
340 | + v3270_emit_save_settings(terminal,NULL); | ||
341 | + | ||
342 | + } | ||
268 | 343 | ||
269 | } | 344 | } |
270 | 345 |