diff --git a/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp b/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp index d1928d471b..76f49ccd5c 100644 --- a/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp @@ -104,8 +104,7 @@ bool Get( } #endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION if (const auto integration = GtkIntegration::Instance()) { - if (integration->fileDialogSupported() - && integration->useFileDialog(type)) { + if (integration->useFileDialog(type)) { return integration->getFileDialog( parent, files, diff --git a/Telegram/SourceFiles/platform/linux/linux_gtk_file_dialog.cpp b/Telegram/SourceFiles/platform/linux/linux_gtk_file_dialog.cpp index 35c46f9177..2648e9057a 100644 --- a/Telegram/SourceFiles/platform/linux/linux_gtk_file_dialog.cpp +++ b/Telegram/SourceFiles/platform/linux/linux_gtk_file_dialog.cpp @@ -69,6 +69,42 @@ QStringList cleanFilterList(const QString &filter) { return f.split(QLatin1Char(' '), base::QStringSkipEmptyParts); } +bool Supported() { + return internal::GdkHelperLoaded() + && (gtk_widget_hide_on_delete != nullptr) + && (gtk_clipboard_store != nullptr) + && (gtk_clipboard_get != nullptr) + && (gtk_widget_destroy != nullptr) + && (gtk_dialog_get_type != nullptr) + && (gtk_dialog_run != nullptr) + && (gtk_widget_realize != nullptr) + && (gdk_window_set_modal_hint != nullptr) + && (gtk_widget_show != nullptr) + && (gdk_window_focus != nullptr) + && (gtk_widget_hide != nullptr) + && (gtk_widget_hide_on_delete != nullptr) + && (gtk_file_chooser_dialog_new != nullptr) + && (gtk_file_chooser_get_type != nullptr) + && (gtk_file_chooser_set_current_folder != nullptr) + && (gtk_file_chooser_get_current_folder != nullptr) + && (gtk_file_chooser_set_current_name != nullptr) + && (gtk_file_chooser_select_filename != nullptr) + && (gtk_file_chooser_get_filenames != nullptr) + && (gtk_file_chooser_set_filter != nullptr) + && (gtk_file_chooser_get_filter != nullptr) + && (gtk_window_get_type != nullptr) + && (gtk_window_set_title != nullptr) + && (gtk_file_chooser_set_local_only != nullptr) + && (gtk_file_chooser_set_action != nullptr) + && (gtk_file_chooser_set_select_multiple != nullptr) + && (gtk_file_chooser_set_do_overwrite_confirmation != nullptr) + && (gtk_file_chooser_remove_filter != nullptr) + && (gtk_file_filter_set_name != nullptr) + && (gtk_file_filter_add_pattern != nullptr) + && (gtk_file_chooser_add_filter != nullptr) + && (gtk_file_filter_new != nullptr); +} + bool PreviewSupported() { return (gdk_pixbuf_new_from_file_at_size != nullptr); } @@ -602,43 +638,11 @@ void GtkFileDialog::setNameFilters(const QStringList &filters) { } // namespace -bool Supported() { - return internal::GdkHelperLoaded() - && (gtk_widget_hide_on_delete != nullptr) - && (gtk_clipboard_store != nullptr) - && (gtk_clipboard_get != nullptr) - && (gtk_widget_destroy != nullptr) - && (gtk_dialog_get_type != nullptr) - && (gtk_dialog_run != nullptr) - && (gtk_widget_realize != nullptr) - && (gdk_window_set_modal_hint != nullptr) - && (gtk_widget_show != nullptr) - && (gdk_window_focus != nullptr) - && (gtk_widget_hide != nullptr) - && (gtk_widget_hide_on_delete != nullptr) - && (gtk_file_chooser_dialog_new != nullptr) - && (gtk_file_chooser_get_type != nullptr) - && (gtk_file_chooser_set_current_folder != nullptr) - && (gtk_file_chooser_get_current_folder != nullptr) - && (gtk_file_chooser_set_current_name != nullptr) - && (gtk_file_chooser_select_filename != nullptr) - && (gtk_file_chooser_get_filenames != nullptr) - && (gtk_file_chooser_set_filter != nullptr) - && (gtk_file_chooser_get_filter != nullptr) - && (gtk_window_get_type != nullptr) - && (gtk_window_set_title != nullptr) - && (gtk_file_chooser_set_local_only != nullptr) - && (gtk_file_chooser_set_action != nullptr) - && (gtk_file_chooser_set_select_multiple != nullptr) - && (gtk_file_chooser_set_do_overwrite_confirmation != nullptr) - && (gtk_file_chooser_remove_filter != nullptr) - && (gtk_file_filter_set_name != nullptr) - && (gtk_file_filter_add_pattern != nullptr) - && (gtk_file_chooser_add_filter != nullptr) - && (gtk_file_filter_new != nullptr); -} - bool Use(Type type) { + if (!Supported()) { + return false; + } + return qEnvironmentVariableIsSet("TDESKTOP_USE_GTK_FILE_DIALOG") || DesktopEnvironment::IsGtkBased(); } diff --git a/Telegram/SourceFiles/platform/linux/linux_gtk_file_dialog.h b/Telegram/SourceFiles/platform/linux/linux_gtk_file_dialog.h index 7f3c5ffb44..070bfd74ac 100644 --- a/Telegram/SourceFiles/platform/linux/linux_gtk_file_dialog.h +++ b/Telegram/SourceFiles/platform/linux/linux_gtk_file_dialog.h @@ -15,7 +15,6 @@ namespace Gtk { using Type = ::FileDialog::internal::Type; -bool Supported(); bool Use(Type type = Type::ReadFile); bool Get( QPointer parent, diff --git a/Telegram/SourceFiles/platform/linux/linux_gtk_integration.cpp b/Telegram/SourceFiles/platform/linux/linux_gtk_integration.cpp index 2762db0a89..e61be4910c 100644 --- a/Telegram/SourceFiles/platform/linux/linux_gtk_integration.cpp +++ b/Telegram/SourceFiles/platform/linux/linux_gtk_integration.cpp @@ -158,10 +158,6 @@ std::optional GtkIntegration::scaleFactor() const { return gdk_monitor_get_scale_factor(monitor); } -bool GtkIntegration::fileDialogSupported() const { - return FileDialog::Gtk::Supported(); -} - bool GtkIntegration::useFileDialog(FileDialogType type) const { return FileDialog::Gtk::Use(type); } diff --git a/Telegram/SourceFiles/platform/linux/linux_gtk_integration.h b/Telegram/SourceFiles/platform/linux/linux_gtk_integration.h index f981ab3abe..623db14981 100644 --- a/Telegram/SourceFiles/platform/linux/linux_gtk_integration.h +++ b/Telegram/SourceFiles/platform/linux/linux_gtk_integration.h @@ -21,7 +21,6 @@ public: [[nodiscard]] std::optional scaleFactor() const; using FileDialogType = ::FileDialog::internal::Type; - [[nodiscard]] bool fileDialogSupported() const; [[nodiscard]] bool useFileDialog( FileDialogType type = FileDialogType::ReadFile) const; [[nodiscard]] bool getFileDialog( diff --git a/Telegram/SourceFiles/platform/linux/linux_gtk_integration_dummy.cpp b/Telegram/SourceFiles/platform/linux/linux_gtk_integration_dummy.cpp index ac83bf3bed..f5b5695e62 100644 --- a/Telegram/SourceFiles/platform/linux/linux_gtk_integration_dummy.cpp +++ b/Telegram/SourceFiles/platform/linux/linux_gtk_integration_dummy.cpp @@ -24,10 +24,6 @@ std::optional GtkIntegration::scaleFactor() const { return std::nullopt; } -bool GtkIntegration::fileDialogSupported() const { - return false; -} - bool GtkIntegration::useFileDialog(FileDialogType type) const { return false; }