From c71fc4b12fcbf7bb9f5b764c7317d557b6278ec7 Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Sat, 16 Mar 2024 11:59:04 +0100 Subject: set window title when loading file from drag drop --- src/export.cpp | 10 +++++----- src/import.cpp | 11 +++++------ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/export.cpp b/src/export.cpp index fea14af..b020b77 100644 --- a/src/export.cpp +++ b/src/export.cpp @@ -271,6 +271,11 @@ export_result ts_export_result(ts_search_result* result, const utf8_int8_t* path if (result->is_saving) return EXPORT_SAVE_PENDING; result->is_saving = true; + // Set titlebar name. + utf8_int8_t new_name[MAX_INPUT_LENGTH]; + snprintf(new_name, MAX_INPUT_LENGTH, "Text-Search > %s", path); + ts_platform_set_window_title(new_name); + struct t_export_thread_args* args = (struct t_export_thread_args*)malloc(sizeof(struct t_export_thread_args)); if (!args) exit_oom(); args->result = result; @@ -288,11 +293,6 @@ void ts_create_export_popup(int window_w, int window_h) { std::string res = ifd::FileDialog::Instance().GetResult().u8string(); last_export_result = ts_export_result(current_search_result, (const utf8_int8_t *)res.c_str()); utf8ncpy(save_path, (const utf8_int8_t *)res.c_str(), sizeof(save_path)); - - // Set titlebar name. - utf8_int8_t new_name[MAX_INPUT_LENGTH]; - snprintf(new_name, MAX_INPUT_LENGTH, "Text-Search > %s", res.c_str()); - ts_platform_set_window_title(new_name); } ifd::FileDialog::Instance().Close(); } diff --git a/src/import.cpp b/src/import.cpp index 89a0f8f..254050d 100644 --- a/src/import.cpp +++ b/src/import.cpp @@ -154,6 +154,11 @@ ts_search_result* ts_import_result(const utf8_int8_t* path) { res->search_completed = false; res->cancel_search = false; + // Set titlebar name. + utf8_int8_t new_name[MAX_INPUT_LENGTH]; + snprintf(new_name, MAX_INPUT_LENGTH, "Text-Search > %s", path); + ts_platform_set_window_title(new_name); + if (res->prev_result) res->prev_result->cancel_search = true; current_search_result = res; // set this now because old result will be destroyed in import thread. @@ -174,12 +179,6 @@ void ts_create_import_popup(int window_w, int window_h) { if (ifd::FileDialog::Instance().HasResult()) { std::string res = ifd::FileDialog::Instance().GetResult().u8string(); utf8ncpy(save_path, (const utf8_int8_t *)res.c_str(), sizeof(save_path)); - - // Set titlebar name. - utf8_int8_t new_name[MAX_INPUT_LENGTH]; - snprintf(new_name, MAX_INPUT_LENGTH, "Text-Search > %s", res.c_str()); - ts_platform_set_window_title(new_name); - current_search_result = ts_import_result(save_path); } ifd::FileDialog::Instance().Close(); -- cgit v1.2.3-70-g09d2