diff --git a/src/include/pw3270/application.h b/src/include/pw3270/application.h index bda31ce..a5a6250 100644 --- a/src/include/pw3270/application.h +++ b/src/include/pw3270/application.h @@ -90,8 +90,6 @@ GtkBuilder * pw3270_application_get_builder(const gchar *name); void gtk_container_remove_all(GtkContainer *container); -gboolean pw3270_application_allow_tabs(GApplication *application); - // Actions void pw3270_application_print_copy_activated(GAction *action, GVariant *parameter, GtkWidget *terminal); void pw3270_application_save_copy_activated(GAction *action, GVariant *parameter, GtkWidget *terminal); diff --git a/src/objects/application/application.c b/src/objects/application/application.c index 2459d7d..4dc3478 100644 --- a/src/objects/application/application.c +++ b/src/objects/application/application.c @@ -57,8 +57,6 @@ struct _pw3270Application { GSettings * settings; GList * keypads; gchar * logfile; - gboolean allow_tabs; ///< @brief Always open window. - GSList * plugins; ///< @brief Handlers of the loaded plugins. PW3270_UI_STYLE ui_style; @@ -230,17 +228,6 @@ static gboolean on_user_interface(const gchar G_GNUC_UNUSED(*option), const gcha } -static gboolean on_allow_tabs(const gchar G_GNUC_UNUSED(*option), const gchar *value, gpointer G_GNUC_UNUSED(dunno), GError **error) { - pw3270Application *app = PW3270_APPLICATION(g_application_get_default()); - app->allow_tabs = (g_ascii_strcasecmp(value,"no") != 0); - if(app->allow_tabs) { - g_message("Opening new sessions on tabs"); - } else { - g_message("Opening new sessions on windows"); - } - return TRUE; -} - static gboolean on_logfile(const gchar G_GNUC_UNUSED(*option), const gchar *value, gpointer G_GNUC_UNUSED(dunno), GError **error) { pw3270_application_set_log_filename(g_application_get_default(),value); return TRUE; @@ -251,14 +238,11 @@ static void pw3270Application_init(pw3270Application *app) { static GOptionEntry cmd_options[] = { { "user-interface", 'U', 0, G_OPTION_ARG_CALLBACK, &on_user_interface, N_( "Set the user-interface type" ), NULL }, - { "allow-tabs", 'T', 0, G_OPTION_ARG_CALLBACK, &on_allow_tabs, N_( "If 'no' allways open a window" ), NULL }, { "logfile", 'l', 0, G_OPTION_ARG_CALLBACK, &on_logfile, N_( "Set default log file name" ), NULL }, { NULL } }; - app->allow_tabs = TRUE; - g_application_add_main_option_entries(G_APPLICATION(app), cmd_options); #ifdef _WIN32 @@ -558,11 +542,6 @@ void pw3270_application_plugin_foreach(GApplication *app, GFunc func, gpointer u } -gboolean pw3270_application_allow_tabs(GApplication *app) { - g_return_val_if_fail(PW3270_IS_APPLICATION(app),TRUE); - return PW3270_APPLICATION(app)->allow_tabs; -} - void pw3270_application_plugin_call(GApplication *app, const gchar *method, gpointer user_data) { g_return_if_fail(PW3270_IS_APPLICATION(app)); diff --git a/src/objects/application/open.c b/src/objects/application/open.c index b532a84..fe269a3 100644 --- a/src/objects/application/open.c +++ b/src/objects/application/open.c @@ -70,16 +70,70 @@ gchar * v3270_keyfile_find(const gchar *name) { } -void pw3270_application_open(GApplication *application, GFile **files, gint n_files, const gchar G_GNUC_UNUSED(*hint)) { +/// @brief Open session file +static void open(GtkApplication *application, const gchar *filename) { + + g_message("Opening '%s'",filename); + + GtkWindow *window = GTK_WINDOW(pw3270_application_window_new(application, filename)); + gtk_window_present(window); + +} + +void pw3270_application_open_file(GtkApplication *application, GFile *file) { + +// GtkWidget * window = gtk_application_get_active_window(application); + g_autofree gchar * scheme = g_file_get_uri_scheme(file); + + if(g_ascii_strcasecmp(scheme,"file") == 0) { + + // It's a file scheme. + if(g_file_query_exists(file,NULL)) { + + // The file exists, load it. + g_autofree gchar *filename = g_file_get_path(file); + open(application,filename); + + } else { + + // The file doesn't exist, search for. + g_autofree gchar * basename = g_file_get_basename(file); + g_autofree gchar * filename = v3270_keyfile_find(basename); + + if(filename) { + open(application,filename); + } else { + g_warning("Cant find session '%s'",basename); + } + + } + + } else if(g_ascii_strcasecmp(scheme,"tn3270") == 0 || g_ascii_strcasecmp(scheme,"tn3270s") == 0) { + + + } else { + + g_warning("Don't know how to handle '%s' scheme",scheme); + + } + + + +} - GtkWidget * window = GTK_WIDGET(gtk_application_get_active_window(GTK_APPLICATION(application))); +void pw3270_application_open(GApplication *application, GFile **files, gint n_files, const gchar G_GNUC_UNUSED(*hint)) { gint file; - debug("%s files=%d",__FUNCTION__,n_files); + debug("\n\n%s files=%d",__FUNCTION__,n_files); for(file = 0; file < n_files; file++) { + debug("%s(%d,%p)",__FUNCTION__,file,files[file]); + pw3270_application_open_file(GTK_APPLICATION(application),files[file]); + + /* + g_autofree gchar *path = g_file_get_path(files[file]); if(!path) { @@ -152,10 +206,11 @@ void pw3270_application_open(GApplication *application, GFile **files, gint n_fi } + */ } - if(window) - gtk_window_present(GTK_WINDOW(window)); +// if(window) +// gtk_window_present(GTK_WINDOW(window)); } -- libgit2 0.21.2