[tepl] File loading: add URI to recent manager
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tepl] File loading: add URI to recent manager
- Date: Sun, 8 Oct 2017 12:08:11 +0000 (UTC)
commit a34abc353d2d95d2321f739116c7b4a2739b53e5
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sun Oct 8 14:00:52 2017 +0200
File loading: add URI to recent manager
docs/reference/tepl-3.0-sections.txt | 1 +
tepl/tepl-file.c | 36 ++++++++++++++++++++++++++++++++++
tepl/tepl-file.h | 2 +
tepl/tepl-tab.c | 5 +--
4 files changed, 41 insertions(+), 3 deletions(-)
---
diff --git a/docs/reference/tepl-3.0-sections.txt b/docs/reference/tepl-3.0-sections.txt
index bfa5322..bb45e96 100644
--- a/docs/reference/tepl-3.0-sections.txt
+++ b/docs/reference/tepl-3.0-sections.txt
@@ -291,6 +291,7 @@ tepl_file_is_externally_modified
tepl_file_is_deleted
tepl_file_is_readonly
tepl_file_set_mount_operation_factory
+tepl_file_add_uri_to_recent_manager
<SUBSECTION Standard>
TeplFileClass
TEPL_TYPE_FILE
diff --git a/tepl/tepl-file.c b/tepl/tepl-file.c
index bc954d7..49c2557 100644
--- a/tepl/tepl-file.c
+++ b/tepl/tepl-file.c
@@ -999,3 +999,39 @@ tepl_file_is_readonly (TeplFile *file)
priv = tepl_file_get_instance_private (file);
return priv->readonly;
}
+
+/**
+ * tepl_file_add_uri_to_recent_manager:
+ * @file: a #TeplFile.
+ *
+ * If the #TeplFile:location isn't %NULL, adds its URI to the default
+ * #GtkRecentManager with gtk_recent_manager_add_item().
+ *
+ * Since: 3.2
+ */
+
+/* In the future a vfunc could be added for this function if it is desirable to
+ * customize it in an application.
+ */
+void
+tepl_file_add_uri_to_recent_manager (TeplFile *file)
+{
+ TeplFilePrivate *priv;
+ GtkRecentManager *recent_manager;
+ gchar *uri;
+
+ g_return_if_fail (TEPL_IS_FILE (file));
+
+ priv = tepl_file_get_instance_private (file);
+
+ if (priv->location == NULL)
+ {
+ return;
+ }
+
+ recent_manager = gtk_recent_manager_get_default ();
+
+ uri = g_file_get_uri (priv->location);
+ gtk_recent_manager_add_item (recent_manager, uri);
+ g_free (uri);
+}
diff --git a/tepl/tepl-file.h b/tepl/tepl-file.h
index 4ab5271..e3fdd2c 100644
--- a/tepl/tepl-file.h
+++ b/tepl/tepl-file.h
@@ -128,6 +128,8 @@ gboolean tepl_file_is_deleted (TeplFile *file);
gboolean tepl_file_is_readonly (TeplFile *file);
+void tepl_file_add_uri_to_recent_manager (TeplFile *file);
+
G_GNUC_INTERNAL
void _tepl_file_set_encoding (TeplFile *file,
const TeplEncoding *encoding);
diff --git a/tepl/tepl-tab.c b/tepl/tepl-tab.c
index 86326a7..eb887d6 100644
--- a/tepl/tepl-tab.c
+++ b/tepl/tepl-tab.c
@@ -480,10 +480,9 @@ load_file_content_cb (GObject *source_object,
TeplFile *file;
TeplFileMetadata *metadata;
- // TODO
- //tepl_file_add_uri_to_recent_manager (buffer);
-
file = tepl_buffer_get_file (buffer);
+ tepl_file_add_uri_to_recent_manager (file);
+
metadata = tepl_file_get_file_metadata (file);
tepl_file_metadata_load_async (metadata,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]