[gedit] Utils: use tepl_utils_replace_home_dir_with_tilde()
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] Utils: use tepl_utils_replace_home_dir_with_tilde()
- Date: Mon, 18 Nov 2019 16:03:43 +0000 (UTC)
commit 494677bfc7737d3d96f8b7b735f08505d43b2ac0
Author: Sébastien Wilmet <swilmet gnome org>
Date: Mon Nov 18 16:52:01 2019 +0100
Utils: use tepl_utils_replace_home_dir_with_tilde()
docs/reference/gedit-sections.txt | 2 +-
gedit/gedit-tab.c | 2 +-
gedit/gedit-utils.c | 50 +++++++--------------------------------
gedit/gedit-utils.h | 3 ++-
4 files changed, 13 insertions(+), 44 deletions(-)
---
diff --git a/docs/reference/gedit-sections.txt b/docs/reference/gedit-sections.txt
index e5ce03854..1814fdf4c 100644
--- a/docs/reference/gedit-sections.txt
+++ b/docs/reference/gedit-sections.txt
@@ -358,7 +358,6 @@ gedit_utils_set_atk_name_description
gedit_utils_set_atk_relation
gedit_warning
gedit_utils_make_valid_utf8
-gedit_utils_replace_home_dir_with_tilde
gedit_utils_get_current_workspace
gedit_utils_get_window_workspace
gedit_utils_basename_for_display
@@ -371,4 +370,5 @@ gedit_utils_location_get_dirname_for_display
gedit_utils_set_direct_save_filename
gedit_utils_str_end_truncate
gedit_utils_newline_type_to_string
+gedit_utils_replace_home_dir_with_tilde
</SECTION>
diff --git a/gedit/gedit-tab.c b/gedit/gedit-tab.c
index 3c0065a6b..9aa5964d3 100644
--- a/gedit/gedit-tab.c
+++ b/gedit/gedit-tab.c
@@ -1520,7 +1520,7 @@ _gedit_tab_get_tooltip (GeditTab *tab)
uri = gedit_document_get_uri_for_display (doc);
g_return_val_if_fail (uri != NULL, NULL);
- ruri = gedit_utils_replace_home_dir_with_tilde (uri);
+ ruri = tepl_utils_replace_home_dir_with_tilde (uri);
g_free (uri);
ruri_markup = g_markup_printf_escaped ("<i>%s</i>", ruri);
diff --git a/gedit/gedit-utils.c b/gedit/gedit-utils.c
index 2a94fb2fe..705d2fd0a 100644
--- a/gedit/gedit-utils.c
+++ b/gedit/gedit-utils.c
@@ -277,7 +277,7 @@ uri_get_dirname (const gchar *uri)
return NULL;
}
- res = gedit_utils_replace_home_dir_with_tilde (str);
+ res = tepl_utils_replace_home_dir_with_tilde (str);
g_free (str);
@@ -358,49 +358,17 @@ gedit_utils_location_get_dirname_for_display (GFile *location)
return res;
}
+/**
+ * gedit_utils_replace_home_dir_with_tilde:
+ * @uri:
+ *
+ * Returns:
+ * Deprecated: 3.36: Use tepl_utils_replace_home_dir_with_tilde() instead.
+ */
gchar *
gedit_utils_replace_home_dir_with_tilde (const gchar *uri)
{
- gchar *tmp;
- gchar *home;
-
- g_return_val_if_fail (uri != NULL, NULL);
-
- /* Note that g_get_home_dir returns a const string */
- tmp = (gchar *)g_get_home_dir ();
-
- if (tmp == NULL)
- return g_strdup (uri);
-
- home = g_filename_to_utf8 (tmp, -1, NULL, NULL, NULL);
- if (home == NULL)
- return g_strdup (uri);
-
- if (strcmp (uri, home) == 0)
- {
- g_free (home);
-
- return g_strdup ("~/");
- }
-
- tmp = home;
- home = g_strdup_printf ("%s/", tmp);
- g_free (tmp);
-
- if (g_str_has_prefix (uri, home))
- {
- gchar *res;
-
- res = g_strdup_printf ("~/%s", uri + strlen (home));
-
- g_free (home);
-
- return res;
- }
-
- g_free (home);
-
- return g_strdup (uri);
+ return tepl_utils_replace_home_dir_with_tilde (uri);
}
/* the following two functions are courtesy of galeon */
diff --git a/gedit/gedit-utils.h b/gedit/gedit-utils.h
index 4fcd268db..60e102ab3 100644
--- a/gedit/gedit-utils.h
+++ b/gedit/gedit-utils.h
@@ -61,7 +61,6 @@ gchar *gedit_utils_make_valid_utf8 (
gchar *gedit_utils_location_get_dirname_for_display (GFile *location);
-gchar *gedit_utils_replace_home_dir_with_tilde (const gchar *uri);
guint gedit_utils_get_current_workspace (GdkScreen *screen);
guint gedit_utils_get_window_workspace (GtkWindow *gtkwindow);
void gedit_utils_get_current_viewport (GdkScreen *screen,
@@ -86,6 +85,8 @@ GtkSourceCompressionType gedit_utils_get_compression_type_from_content_type (c
gchar *gedit_utils_set_direct_save_filename (GdkDragContext
*context);
const gchar *gedit_utils_newline_type_to_string (GtkSourceNewlineType
newline_type);
+G_DEPRECATED_FOR (tepl_utils_replace_home_dir_with_tilde)
+gchar *gedit_utils_replace_home_dir_with_tilde (const gchar *uri);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]