Commit 949cb22c8960a8cd39ac0ada903f1e2fb7a99ea1
1 parent
c6893aaf
Exists in
master
and in
2 other branches
Reseting to default session before loading of command line URL.
Showing
5 changed files
with
43 additions
and
17 deletions
Show diff stats
src/include/v3270/keyfile.h
src/main/main.c
... | ... | @@ -51,22 +51,9 @@ static gboolean quit_signal(GtkApplication *app) { |
51 | 51 | |
52 | 52 | debug("%s",__FUNCTION__); |
53 | 53 | g_message("Terminating by signal"); |
54 | - | |
55 | - /* | |
56 | - GList *list = gtk_application_get_windows(GTK_APPLICATION(application)); | |
57 | - | |
58 | - while(list) { | |
59 | - | |
60 | - GtkWidget * window = GTK_WIDGET(list->data); | |
61 | - list = list->next; | |
62 | - | |
63 | - gtk_widget_destroy(window); | |
64 | - | |
65 | - } | |
66 | - */ | |
67 | - | |
68 | 54 | g_application_quit(G_APPLICATION(app)); |
69 | 55 | return FALSE; |
56 | + | |
70 | 57 | } |
71 | 58 | #endif // G_OS_UNIX |
72 | 59 | ... | ... |
src/objects/application/application.c
... | ... | @@ -63,8 +63,8 @@ struct _pw3270Application { |
63 | 63 | |
64 | 64 | }; |
65 | 65 | |
66 | -static void startup(GApplication * application); | |
67 | -static void activate(GApplication * application); | |
66 | +static void startup(GApplication * application); | |
67 | +static void activate(GApplication * application); | |
68 | 68 | static void finalize(GObject *object); |
69 | 69 | |
70 | 70 | G_DEFINE_TYPE(pw3270Application, pw3270Application, GTK_TYPE_APPLICATION); | ... | ... |
src/objects/application/open.c
... | ... | @@ -29,6 +29,7 @@ |
29 | 29 | |
30 | 30 | #include "private.h" |
31 | 31 | #include <pw3270/application.h> |
32 | +#include <v3270/keyfile.h> | |
32 | 33 | |
33 | 34 | gchar * v3270_keyfile_find(const gchar *name) { |
34 | 35 | // |
... | ... | @@ -88,6 +89,8 @@ void pw3270_application_open(GApplication *application, GFile **files, gint n_fi |
88 | 89 | |
89 | 90 | if(!(g_ascii_strcasecmp(scheme,"tn3270") && g_ascii_strcasecmp(scheme,"tn3270s"))) { |
90 | 91 | |
92 | + // It's an URL, load it in the default session. | |
93 | + | |
91 | 94 | g_autofree gchar * uri = g_file_get_uri(files[file]); |
92 | 95 | size_t sz = strlen(uri); |
93 | 96 | |
... | ... | @@ -102,7 +105,11 @@ void pw3270_application_open(GApplication *application, GFile **files, gint n_fi |
102 | 105 | window = pw3270_application_window_new_tab(window, NULL); |
103 | 106 | } |
104 | 107 | |
105 | - v3270_set_url(pw3270_application_window_get_active_terminal(window),uri); | |
108 | + // Load default | |
109 | + GtkWidget * terminal = pw3270_application_window_get_active_terminal(window); | |
110 | + | |
111 | + v3270_set_default_session(terminal); | |
112 | + v3270_set_url(terminal,uri); | |
106 | 113 | |
107 | 114 | } |
108 | 115 | ... | ... |
src/objects/window/terminal.c
... | ... | @@ -120,6 +120,37 @@ static gboolean save_popup_response(GtkWidget *widget, const gchar *popup_name, |
120 | 120 | return TRUE; |
121 | 121 | } |
122 | 122 | |
123 | +void v3270_set_default_session(GtkWidget *terminal) { | |
124 | + | |
125 | + GError * error = NULL; | |
126 | + g_autofree gchar * filename = v3270_keyfile_get_default_filename(); | |
127 | + | |
128 | + v3270_key_file_open(terminal,filename,&error); | |
129 | + | |
130 | + if(error) { | |
131 | + | |
132 | + GtkWidget * dialog = gtk_message_dialog_new_with_markup( | |
133 | + GTK_WINDOW(gtk_widget_get_toplevel(terminal)), | |
134 | + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | |
135 | + GTK_MESSAGE_ERROR, | |
136 | + GTK_BUTTONS_CANCEL, | |
137 | + _("Can't use default session file") | |
138 | + ); | |
139 | + | |
140 | + gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",error->message); | |
141 | + | |
142 | + gtk_window_set_title(GTK_WINDOW(dialog),_("Can't load session file")); | |
143 | + | |
144 | + gtk_widget_show_all(dialog); | |
145 | + | |
146 | + g_signal_connect(dialog,"close",G_CALLBACK(gtk_widget_destroy),NULL); | |
147 | + g_signal_connect(dialog,"response",G_CALLBACK(gtk_widget_destroy),NULL); | |
148 | + | |
149 | + g_error_free(error); | |
150 | + | |
151 | + } | |
152 | +} | |
153 | + | |
123 | 154 | GtkWidget * pw3270_terminal_new(const gchar *session_file) { |
124 | 155 | |
125 | 156 | GtkWidget * terminal = v3270_new(); | ... | ... |