summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick Storz <eduard.braun2@gmx.de>2019-03-27 18:06:31 +0000
committerPatrick Storz <eduard.braun2@gmx.de>2019-03-27 18:12:20 +0000
commitd21ee683ed80338f958a2d1368727523a89a936d (patch)
tree776f33983787922dbd7f615464f22be67e93ee3f /src
parentPreferences: Remove old function to migrate recent documents (diff)
downloadinkscape-d21ee683ed80338f958a2d1368727523a89a936d.tar.gz
inkscape-d21ee683ed80338f958a2d1368727523a89a936d.zip
Fix adding/lookup of recent files.
Avoid setting an application name as Gtk::RecentManager calls g_get_application_name () internally to determine the default "name" attribute used for new entries in the list of recently used files (recently-used.xbel) Our Gtk::RecentFilter in menubar.cpp expects the name to equal to g_get_prgname () though (which happens to be the fallback of g_get_application_name, but only if no application name is set as in earlier versions) The alternative would be to set metadata manually, but it would require us to set *all* fields manually (including mime type, etc.). See also https://gitlab.gnome.org/GNOME/gtk/issues/1775 Fixes https://gitlab.com/inkscape/inkscape/issues/160
Diffstat (limited to 'src')
-rw-r--r--src/file.cpp26
-rw-r--r--src/inkscape-application.cpp10
2 files changed, 10 insertions, 26 deletions
diff --git a/src/file.cpp b/src/file.cpp
index 70b2b3817..f492017f8 100644
--- a/src/file.cpp
+++ b/src/file.cpp
@@ -98,25 +98,6 @@ using Inkscape::IO::Resource::USER;
void dump_str(gchar const *str, gchar const *prefix);
void dump_ustr(Glib::ustring const &ustr);
-// what gets passed here is not actually an URI... it is an UTF-8 encoded filename (!)
-static void sp_file_add_recent(gchar const *uri)
-{
- if(uri == nullptr) {
- g_warning("sp_file_add_recent: uri == NULL");
- return;
- }
- GtkRecentManager *recent = gtk_recent_manager_get_default();
- gchar *fn = g_filename_from_utf8(uri, -1, nullptr, nullptr, nullptr);
- if (fn) {
- gchar *uri_to_add = g_filename_to_uri(fn, nullptr, nullptr);
- if (uri_to_add) {
- gtk_recent_manager_add_item(recent, uri_to_add);
- g_free(uri_to_add);
- }
- g_free(fn);
- }
-}
-
/*######################
## N E W
@@ -717,7 +698,12 @@ sp_file_save_dialog(Gtk::Window &parentWindow, SPDocument *doc, Inkscape::Extens
success = file_save(parentWindow, doc, fileName, selectionType, TRUE, !is_copy, save_method);
if (success && doc->getDocumentURI()) {
- sp_file_add_recent( doc->getDocumentURI() );
+ // getDocumentURI does not return an actual URI... it is an UTF-8 encoded filename (!)
+ std::string filename = Glib::filename_from_utf8(doc->getDocumentURI());
+ Glib::ustring uri = Glib::filename_to_uri(filename);
+
+ Glib::RefPtr<Gtk::RecentManager> recent = Gtk::RecentManager::get_default();
+ recent->add_item(uri);
}
save_path = Glib::path_get_dirname(fileName);
diff --git a/src/inkscape-application.cpp b/src/inkscape-application.cpp
index 3ab60caa3..3c87130f6 100644
--- a/src/inkscape-application.cpp
+++ b/src/inkscape-application.cpp
@@ -445,7 +445,9 @@ ConcreteInkscapeApplication<T>::ConcreteInkscapeApplication()
Inkscape::initialize_gettext();
#endif
- Glib::set_application_name(N_("Inkscape - A Vector Drawing Program")); // After gettext() init.
+ // Don't set application name for now. We don't use it anywhere but
+ // it overrides the name used for adding recently opened files and breaks the Gtk::RecentFilter
+ // Glib::set_application_name(N_("Inkscape - A Vector Drawing Program")); // After gettext() init.
// ======================== Actions =========================
add_actions_base(this); // actions that are GUI independent
@@ -626,12 +628,8 @@ ConcreteInkscapeApplication<Gtk::Application>::create_window(const Glib::RefPtr<
if (document) {
if (add_to_recent) {
-
auto recentmanager = Gtk::RecentManager::get_default();
- Gtk::RecentManager::Data data;
- data.app_name = g_get_prgname(); // Must match Gtk::RecentFilter in menubar.cpp
- data.mime_type = "image"; // We don't know if we opened an SVG! (image/svg+xml).
- recentmanager->add_item (file->get_uri(), data);
+ recentmanager->add_item (file->get_uri());
}
// TODO Remove this code... handle document replacement elsewhere.