Commit 81d5a6c6ee2ad0e7997267753287b061ceecb4d8
1 parent
b7b8a75e
Exists in
master
and in
4 other branches
Refactoring the open session/url from command line.
Showing
3 changed files
with
27 additions
and
17 deletions
Show diff stats
src/include/pw3270/window.h
... | ... | @@ -62,9 +62,6 @@ |
62 | 62 | /// @brief Create a new terminal tab. |
63 | 63 | GtkWidget * pw3270_application_window_new_tab(GtkWidget *window, const gchar *session_file); |
64 | 64 | |
65 | - /// @brief Get the active terminal widget. | |
66 | - GtkWidget * pw3270_window_get_terminal_widget(GtkWidget *window); | |
67 | - | |
68 | 65 | /// @brief Get the active session handle. |
69 | 66 | H3270 * pw3270_window_get_session_handle(GtkWidget *window); |
70 | 67 | ... | ... |
src/objects/application/open.c
... | ... | @@ -31,33 +31,45 @@ |
31 | 31 | |
32 | 32 | void pw3270_application_open(GApplication *application, GFile **files, gint n_files, const gchar G_GNUC_UNUSED(*hint)) { |
33 | 33 | |
34 | - GtkWindow * window = gtk_application_get_active_window(GTK_APPLICATION(application)); | |
34 | + GtkWidget * window = GTK_WIDGET(gtk_application_get_active_window(GTK_APPLICATION(application))); | |
35 | 35 | |
36 | 36 | gint file; |
37 | - gint last = -1; | |
38 | 37 | |
39 | 38 | for(file = 0; file < n_files; file++) { |
40 | 39 | |
40 | + g_autofree gchar *path = g_file_get_path(files[file]); | |
41 | + GtkWidget * terminal = NULL; | |
41 | 42 | |
42 | - } | |
43 | + if(!window) { | |
44 | + window = pw3270_application_window_new(GTK_APPLICATION(application), path); | |
45 | + terminal = gtk_window_get_default_widget(GTK_WINDOW(window)); | |
46 | + } else { | |
47 | + terminal = pw3270_application_window_new_tab(window,path); | |
48 | + } | |
43 | 49 | |
44 | - /* | |
50 | + if(!path) { | |
45 | 51 | |
46 | - debug("%s was called with %d files (active_window=%p)", __FUNCTION__, n_files, window); | |
52 | + // It's not a session file descriptor, is it an URL? | |
53 | + g_autofree gchar * scheme = g_file_get_uri_scheme(files[file]); | |
47 | 54 | |
48 | - if(!window) | |
49 | - window = GTK_WINDOW(pw3270_application_window_new(GTK_APPLICATION(application))); | |
55 | + if(!(g_ascii_strcasecmp(scheme,"tn3270") && g_ascii_strcasecmp(scheme,"tn3270s"))) { | |
50 | 56 | |
51 | - // Add tabs to the window | |
52 | - last = pw3270_window_append_page(GTK_WIDGET(window), files[file]); | |
53 | - } | |
57 | + g_autofree gchar * uri = g_file_get_uri(files[file]); | |
58 | + size_t sz = strlen(uri); | |
59 | + | |
60 | + if(sz > 0 && uri[sz-1] == '/') | |
61 | + uri[sz-1] = 0; | |
54 | 62 | |
63 | + v3270_set_url(terminal,uri); | |
55 | 64 | |
56 | - if(last != -1) | |
57 | - pw3270_window_set_current_page(GTK_WIDGET(window),last); | |
65 | + } | |
66 | + | |
67 | + } | |
68 | + | |
69 | + } | |
58 | 70 | |
59 | - */ | |
71 | + if(window) | |
72 | + gtk_window_present(GTK_WINDOW(window)); | |
60 | 73 | |
61 | - gtk_window_present(window); | |
62 | 74 | } |
63 | 75 | ... | ... |