From 72b31ef927a3f728b4fac27fbe8f4fb14c550c93 Mon Sep 17 00:00:00 2001 From: Alexander Mikhaylenko Date: Wed, 7 Dec 2022 18:00:18 +0400 Subject: file-chooser: Rename to ephy-file-dialog-utils That better reflects what it's about nowadays. Part-of: --- embed/ephy-download.c | 1 - embed/ephy-web-view.c | 2 +- lib/ephy-file-chooser.c | 118 ----------------------------------- lib/ephy-file-chooser.h | 34 ---------- lib/ephy-file-dialog-utils.c | 112 +++++++++++++++++++++++++++++++++ lib/ephy-file-dialog-utils.h | 34 ++++++++++ lib/meson.build | 2 +- po/POTFILES.in | 2 +- src/context-menu-commands.c | 2 +- src/preferences/prefs-general-page.c | 2 +- src/window-commands.c | 2 +- 11 files changed, 152 insertions(+), 159 deletions(-) delete mode 100644 lib/ephy-file-chooser.c delete mode 100644 lib/ephy-file-chooser.h create mode 100644 lib/ephy-file-dialog-utils.c create mode 100644 lib/ephy-file-dialog-utils.h diff --git a/embed/ephy-download.c b/embed/ephy-download.c index 8acea4543..ea8f3f728 100644 --- a/embed/ephy-download.c +++ b/embed/ephy-download.c @@ -25,7 +25,6 @@ #include "ephy-embed.h" #include "ephy-embed-shell.h" #include "ephy-embed-type-builtins.h" -#include "ephy-file-chooser.h" #include "ephy-file-helpers.h" #include "ephy-flatpak-utils.h" #include "ephy-prefs.h" diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c index e30318c28..1372dc3f0 100644 --- a/embed/ephy-web-view.c +++ b/embed/ephy-web-view.c @@ -31,7 +31,7 @@ #include "ephy-embed-utils.h" #include "ephy-embed.h" #include "ephy-favicon-helpers.h" -#include "ephy-file-chooser.h" +#include "ephy-file-dialog-utils.h" #include "ephy-file-helpers.h" #include "ephy-file-monitor.h" #include "ephy-filters-manager.h" diff --git a/lib/ephy-file-chooser.c b/lib/ephy-file-chooser.c deleted file mode 100644 index 3a7b6bb7b..000000000 --- a/lib/ephy-file-chooser.c +++ /dev/null @@ -1,118 +0,0 @@ -/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* - * Copyright © 2003 Marco Pesenti Gritti - * Copyright © 2003, 2004 Christian Persch - * Copyright © 2017 Igalia S.L. - * - * This file is part of Epiphany. - * - * Epiphany is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Epiphany is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Epiphany. If not, see . - */ - -#include "config.h" - -#include "ephy-file-chooser.h" -#include "ephy-file-helpers.h" -#include "ephy-gui.h" -#include "ephy-debug.h" -#include "ephy-settings.h" -#include "ephy-string.h" - -#include -#include -#include - -#include -#include - -static const char *webpage_types[] = { - "text/html", - "application/xhtml+xml", - "text/xml", - "message/rfc822", /* MHTML */ - "multipart/related", /* MHTML */ - "application/x-mimearchive", /* MHTML */ - NULL -}; - -static const char *image_types[] = { - "image/png", - "image/jpeg", - "image/gif", - "image/webp", - NULL -}; - -void -ephy_file_dialog_add_shortcuts (GtkFileDialog *dialog) -{ - g_autofree char *downloads_dir_path = NULL; - g_autoptr (GFile) downloads_dir = NULL; - g_autoptr (GListStore) shortcuts = NULL; - - g_assert (GTK_IS_FILE_DIALOG (dialog)); - - downloads_dir_path = ephy_file_get_downloads_dir (); - downloads_dir = g_file_new_for_path (downloads_dir_path); - - shortcuts = g_list_store_new (G_TYPE_FILE); - g_list_store_append (shortcuts, downloads_dir); - - gtk_file_dialog_set_shortcut_folders (dialog, G_LIST_MODEL (shortcuts)); -} - -void -ephy_file_dialog_add_filters (GtkFileDialog *dialog) -{ - g_autoptr (GListStore) filters = NULL; - g_autoptr (GtkFileFilter) supported_filter = NULL; - g_autoptr (GtkFileFilter) webpages_filter = NULL; - g_autoptr (GtkFileFilter) images_filter = NULL; - g_autoptr (GtkFileFilter) all_filter = NULL; - int i; - - g_assert (GTK_IS_FILE_DIALOG (dialog)); - - filters = g_list_store_new (GTK_TYPE_FILE_FILTER); - - supported_filter = gtk_file_filter_new (); - gtk_file_filter_set_name (supported_filter, _("All supported types")); - g_list_store_append (filters, supported_filter); - - webpages_filter = gtk_file_filter_new (); - gtk_file_filter_set_name (webpages_filter, _("Web pages")); - g_list_store_append (filters, webpages_filter); - - images_filter = gtk_file_filter_new (); - gtk_file_filter_set_name (images_filter, _("Images")); - g_list_store_append (filters, images_filter); - - all_filter = gtk_file_filter_new (); - gtk_file_filter_set_name (all_filter, _("All files")); - gtk_file_filter_add_pattern (all_filter, "*"); - g_list_store_append (filters, all_filter); - - for (i = 0; webpage_types[i]; i++) { - gtk_file_filter_add_mime_type (supported_filter, webpage_types[i]); - gtk_file_filter_add_mime_type (webpages_filter, webpage_types[i]); - } - - for (i = 0; image_types[i]; i++) { - gtk_file_filter_add_mime_type (supported_filter, image_types[i]); - gtk_file_filter_add_mime_type (images_filter, image_types[i]); - } - - gtk_file_dialog_set_filters (dialog, G_LIST_MODEL (filters)); - gtk_file_dialog_set_current_filter (dialog, supported_filter); -} diff --git a/lib/ephy-file-chooser.h b/lib/ephy-file-chooser.h deleted file mode 100644 index e68104b0e..000000000 --- a/lib/ephy-file-chooser.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* - * Copyright © 2003, 2004 Christian Persch - * Copyright © 2017 Igalia S.L. - * - * This file is part of Epiphany. - * - * Epiphany is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Epiphany is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Epiphany. If not, see . - */ - -#pragma once - -#include - -#include - -G_BEGIN_DECLS - -void ephy_file_dialog_add_shortcuts (GtkFileDialog *dialog); - -void ephy_file_dialog_add_filters (GtkFileDialog *dialog); - -G_END_DECLS diff --git a/lib/ephy-file-dialog-utils.c b/lib/ephy-file-dialog-utils.c new file mode 100644 index 000000000..96b64a594 --- /dev/null +++ b/lib/ephy-file-dialog-utils.c @@ -0,0 +1,112 @@ +/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * Copyright © 2003 Marco Pesenti Gritti + * Copyright © 2003, 2004 Christian Persch + * Copyright © 2017 Igalia S.L. + * + * This file is part of Epiphany. + * + * Epiphany is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Epiphany is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Epiphany. If not, see . + */ + +#include "config.h" + +#include "ephy-file-dialog-utils.h" +#include "ephy-file-helpers.h" +#include "ephy-gui.h" +#include "ephy-debug.h" + +#include +#include + +static const char *webpage_types[] = { + "text/html", + "application/xhtml+xml", + "text/xml", + "message/rfc822", /* MHTML */ + "multipart/related", /* MHTML */ + "application/x-mimearchive", /* MHTML */ + NULL +}; + +static const char *image_types[] = { + "image/png", + "image/jpeg", + "image/gif", + "image/webp", + NULL +}; + +void +ephy_file_dialog_add_shortcuts (GtkFileDialog *dialog) +{ + g_autofree char *downloads_dir_path = NULL; + g_autoptr (GFile) downloads_dir = NULL; + g_autoptr (GListStore) shortcuts = NULL; + + g_assert (GTK_IS_FILE_DIALOG (dialog)); + + downloads_dir_path = ephy_file_get_downloads_dir (); + downloads_dir = g_file_new_for_path (downloads_dir_path); + + shortcuts = g_list_store_new (G_TYPE_FILE); + g_list_store_append (shortcuts, downloads_dir); + + gtk_file_dialog_set_shortcut_folders (dialog, G_LIST_MODEL (shortcuts)); +} + +void +ephy_file_dialog_add_filters (GtkFileDialog *dialog) +{ + g_autoptr (GListStore) filters = NULL; + g_autoptr (GtkFileFilter) supported_filter = NULL; + g_autoptr (GtkFileFilter) webpages_filter = NULL; + g_autoptr (GtkFileFilter) images_filter = NULL; + g_autoptr (GtkFileFilter) all_filter = NULL; + int i; + + g_assert (GTK_IS_FILE_DIALOG (dialog)); + + filters = g_list_store_new (GTK_TYPE_FILE_FILTER); + + supported_filter = gtk_file_filter_new (); + gtk_file_filter_set_name (supported_filter, _("All supported types")); + g_list_store_append (filters, supported_filter); + + webpages_filter = gtk_file_filter_new (); + gtk_file_filter_set_name (webpages_filter, _("Web pages")); + g_list_store_append (filters, webpages_filter); + + images_filter = gtk_file_filter_new (); + gtk_file_filter_set_name (images_filter, _("Images")); + g_list_store_append (filters, images_filter); + + all_filter = gtk_file_filter_new (); + gtk_file_filter_set_name (all_filter, _("All files")); + gtk_file_filter_add_pattern (all_filter, "*"); + g_list_store_append (filters, all_filter); + + for (i = 0; webpage_types[i]; i++) { + gtk_file_filter_add_mime_type (supported_filter, webpage_types[i]); + gtk_file_filter_add_mime_type (webpages_filter, webpage_types[i]); + } + + for (i = 0; image_types[i]; i++) { + gtk_file_filter_add_mime_type (supported_filter, image_types[i]); + gtk_file_filter_add_mime_type (images_filter, image_types[i]); + } + + gtk_file_dialog_set_filters (dialog, G_LIST_MODEL (filters)); + gtk_file_dialog_set_current_filter (dialog, supported_filter); +} diff --git a/lib/ephy-file-dialog-utils.h b/lib/ephy-file-dialog-utils.h new file mode 100644 index 000000000..e68104b0e --- /dev/null +++ b/lib/ephy-file-dialog-utils.h @@ -0,0 +1,34 @@ +/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * Copyright © 2003, 2004 Christian Persch + * Copyright © 2017 Igalia S.L. + * + * This file is part of Epiphany. + * + * Epiphany is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Epiphany is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Epiphany. If not, see . + */ + +#pragma once + +#include + +#include + +G_BEGIN_DECLS + +void ephy_file_dialog_add_shortcuts (GtkFileDialog *dialog); + +void ephy_file_dialog_add_filters (GtkFileDialog *dialog); + +G_END_DECLS diff --git a/lib/meson.build b/lib/meson.build index 0649caefd..caabb0e5f 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -15,7 +15,7 @@ libephymisc_sources = [ 'contrib/gnome-languages.c', 'ephy-debug.c', 'ephy-favicon-helpers.c', - 'ephy-file-chooser.c', + 'ephy-file-dialog-utils.c', 'ephy-file-helpers.c', 'ephy-flatpak-utils.c', 'ephy-gui.c', diff --git a/po/POTFILES.in b/po/POTFILES.in index d88fe4f8b..d3f449838 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -18,7 +18,7 @@ embed/ephy-web-view.c embed/web-process-extension/ephy-web-process-extension.c embed/web-process-extension/resources/js/overview.js lib/contrib/gnome-languages.c -lib/ephy-file-chooser.c +lib/ephy-file-dialog-utils.c lib/ephy-file-helpers.c lib/ephy-gui.c lib/ephy-langs.c diff --git a/src/context-menu-commands.c b/src/context-menu-commands.c index 5960aa742..8709b51c3 100644 --- a/src/context-menu-commands.c +++ b/src/context-menu-commands.c @@ -25,7 +25,7 @@ #include "ephy-downloads-manager.h" #include "ephy-embed-container.h" #include "ephy-embed-utils.h" -#include "ephy-file-chooser.h" +#include "ephy-file-dialog-utils.h" #include "ephy-file-helpers.h" #include "ephy-flatpak-utils.h" #include "ephy-prefs.h" diff --git a/src/preferences/prefs-general-page.c b/src/preferences/prefs-general-page.c index 61fadbd3c..fc027ee6d 100644 --- a/src/preferences/prefs-general-page.c +++ b/src/preferences/prefs-general-page.c @@ -24,7 +24,7 @@ #include "prefs-general-page.h" #include "ephy-embed-shell.h" -#include "ephy-file-chooser.h" +#include "ephy-file-dialog-utils.h" #include "ephy-file-helpers.h" #include "ephy-flatpak-utils.h" #include "ephy-lang-row.h" diff --git a/src/window-commands.c b/src/window-commands.c index 6b635a824..5c65c9be4 100644 --- a/src/window-commands.c +++ b/src/window-commands.c @@ -36,7 +36,7 @@ #include "ephy-embed.h" #include "ephy-encoding-dialog.h" #include "ephy-favicon-helpers.h" -#include "ephy-file-chooser.h" +#include "ephy-file-dialog-utils.h" #include "ephy-file-helpers.h" #include "ephy-find-toolbar.h" #include "ephy-flatpak-utils.h" -- cgit v1.2.1