Commit 8f6ff45890823105c4d2409e08ee37d23553011d
1 parent
b5274932
Exists in
master
and in
2 other branches
Disabling tabs from command line option.
Showing
3 changed files
with
34 additions
and
7 deletions
Show diff stats
src/include/pw3270/application.h
... | ... | @@ -87,6 +87,8 @@ GtkBuilder * pw3270_application_get_builder(const gchar *name); |
87 | 87 | |
88 | 88 | void gtk_container_remove_all(GtkContainer *container); |
89 | 89 | |
90 | +gboolean pw3270_application_allow_tabs(GApplication *application); | |
91 | + | |
90 | 92 | // Actions |
91 | 93 | void pw3270_application_print_copy_activated(GAction *action, GVariant *parameter, GtkWidget *terminal); |
92 | 94 | void pw3270_application_save_copy_activated(GAction *action, GVariant *parameter, GtkWidget *terminal); | ... | ... |
src/objects/application/application.c
... | ... | @@ -54,11 +54,11 @@ struct _pw3270ApplicationClass { |
54 | 54 | struct _pw3270Application { |
55 | 55 | GtkApplication parent; |
56 | 56 | |
57 | - GSettings * settings; | |
58 | - GList * keypads; | |
59 | - | |
60 | - GSList * plugins; ///< @brief Handlers of the loaded plugins. | |
57 | + GSettings * settings; | |
58 | + GList * keypads; | |
59 | + gboolean allow_tabs; ///< @brief Always open window. | |
61 | 60 | |
61 | + GSList * plugins; ///< @brief Handlers of the loaded plugins. | |
62 | 62 | PW3270_UI_STYLE ui_style; |
63 | 63 | |
64 | 64 | }; |
... | ... | @@ -123,7 +123,6 @@ static void window_removed(GtkApplication *application, GtkWindow *window) { |
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
126 | - | |
127 | 126 | GTK_APPLICATION_CLASS(pw3270Application_parent_class)->window_removed(application,window); |
128 | 127 | |
129 | 128 | } |
... | ... | @@ -218,15 +217,36 @@ static gboolean on_user_interface(const gchar G_GNUC_UNUSED(*option), const gcha |
218 | 217 | |
219 | 218 | } |
220 | 219 | |
220 | +static gboolean on_log_file(const gchar G_GNUC_UNUSED(*option), const gchar *value, gpointer G_GNUC_UNUSED(dunno), GError **error) { | |
221 | + pw3270Application *app = PW3270_APPLICATION(g_application_get_default()); | |
222 | + | |
223 | + return TRUE; | |
224 | +} | |
225 | + | |
226 | +static gboolean on_allow_tabs(const gchar G_GNUC_UNUSED(*option), const gchar *value, gpointer G_GNUC_UNUSED(dunno), GError **error) { | |
227 | + pw3270Application *app = PW3270_APPLICATION(g_application_get_default()); | |
228 | + app->allow_tabs = (g_ascii_strcasecmp(value,"no") != 0); | |
229 | + if(app->allow_tabs) { | |
230 | + g_message("Opening new sessions on tabs"); | |
231 | + } else { | |
232 | + g_message("Opening new sessions on windows"); | |
233 | + } | |
234 | + return TRUE; | |
235 | +} | |
236 | + | |
221 | 237 | static void pw3270Application_init(pw3270Application *app) { |
222 | 238 | |
223 | 239 | static GOptionEntry cmd_options[] = { |
224 | 240 | |
225 | 241 | { "user-interface", 'U', 0, G_OPTION_ARG_CALLBACK, &on_user_interface, N_( "Set the user-interface type" ), NULL }, |
242 | + { "log-filename", 'l', 0, G_OPTION_ARG_CALLBACK, &on_log_file, N_( "Set custom log file for the active session" ), NULL }, | |
243 | + { "allow-tabs", 'T', 0, G_OPTION_ARG_CALLBACK, &on_allow_tabs, N_( "If 'no' allways open a window" ), NULL }, | |
226 | 244 | { NULL } |
227 | 245 | |
228 | 246 | }; |
229 | 247 | |
248 | + app->allow_tabs = TRUE; | |
249 | + | |
230 | 250 | g_application_add_main_option_entries(G_APPLICATION(app), cmd_options); |
231 | 251 | |
232 | 252 | #ifdef _WIN32 |
... | ... | @@ -519,6 +539,11 @@ void pw3270_application_plugin_foreach(GApplication *app, GFunc func, gpointer u |
519 | 539 | |
520 | 540 | } |
521 | 541 | |
542 | +gboolean pw3270_application_allow_tabs(GApplication *app) { | |
543 | + g_return_val_if_fail(PW3270_IS_APPLICATION(app),TRUE); | |
544 | + return PW3270_APPLICATION(app)->allow_tabs; | |
545 | +} | |
546 | + | |
522 | 547 | void pw3270_application_plugin_call(GApplication *app, const gchar *method, gpointer user_data) { |
523 | 548 | |
524 | 549 | g_return_if_fail(PW3270_IS_APPLICATION(app)); | ... | ... |
src/objects/application/open.c
... | ... | @@ -97,7 +97,7 @@ void pw3270_application_open(GApplication *application, GFile **files, gint n_fi |
97 | 97 | if(sz > 0 && uri[sz-1] == '/') |
98 | 98 | uri[sz-1] = 0; |
99 | 99 | |
100 | - if(!window) { | |
100 | + if(!(window && pw3270_application_allow_tabs(application))) { | |
101 | 101 | debug("%s: Creating new window",__FUNCTION__); |
102 | 102 | window = pw3270_application_window_new(GTK_APPLICATION(application), NULL); |
103 | 103 | } else { |
... | ... | @@ -122,7 +122,7 @@ void pw3270_application_open(GApplication *application, GFile **files, gint n_fi |
122 | 122 | // The file exists, use it. |
123 | 123 | debug("%s: Loading '%s'",__FUNCTION__,path); |
124 | 124 | |
125 | - if(!window) { | |
125 | + if(!(window && pw3270_application_allow_tabs(application))) { | |
126 | 126 | debug("%s: Creating new window",__FUNCTION__); |
127 | 127 | window = pw3270_application_window_new(GTK_APPLICATION(application), path); |
128 | 128 | } else { | ... | ... |