[gnome-latex] Use tepl_utils_str_replace()
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-latex] Use tepl_utils_str_replace()
- Date: Mon, 18 Nov 2019 13:47:25 +0000 (UTC)
commit b52a92c3e17ca2201ad7dc260e67e8bf21912686
Author: Sébastien Wilmet <swilmet gnome org>
Date: Mon Nov 18 14:37:00 2019 +0100
Use tepl_utils_str_replace()
docs/reference/gnome-latex-sections.txt | 1 -
src/liblatexila/latexila-build-job.c | 6 ++--
src/liblatexila/latexila-build-tool.c | 8 ++---
src/liblatexila/latexila-latex-commands.c | 4 +--
src/liblatexila/latexila-utils.c | 36 ---------------------
src/liblatexila/latexila-utils.h | 6 ----
tests/Makefile.am | 3 --
tests/test-utils.c | 53 -------------------------------
8 files changed, 9 insertions(+), 108 deletions(-)
---
diff --git a/docs/reference/gnome-latex-sections.txt b/docs/reference/gnome-latex-sections.txt
index 61aa423..15c466f 100644
--- a/docs/reference/gnome-latex-sections.txt
+++ b/docs/reference/gnome-latex-sections.txt
@@ -274,7 +274,6 @@ latexila_utils_show_uri
latexila_utils_get_dialog_component
latexila_utils_join_widgets
latexila_utils_get_pixbuf_from_icon_name
-latexila_utils_str_replace
latexila_utils_register_icons
latexila_utils_migrate_latexila_to_gnome_latex
</SECTION>
diff --git a/src/liblatexila/latexila-build-job.c b/src/liblatexila/latexila-build-job.c
index 116bcbb..11b98c0 100644
--- a/src/liblatexila/latexila-build-job.c
+++ b/src/liblatexila/latexila-build-job.c
@@ -280,16 +280,16 @@ get_command_argv (GTask *task,
if (strstr (argv[i], "$filename") != NULL)
{
- new_arg = latexila_utils_str_replace (argv[i], "$filename", base_filename);
+ new_arg = tepl_utils_str_replace (argv[i], "$filename", base_filename);
}
else if (strstr (argv[i], "$shortname"))
{
- new_arg = latexila_utils_str_replace (argv[i], "$shortname", base_shortname);
+ new_arg = tepl_utils_str_replace (argv[i], "$shortname", base_shortname);
}
else if (strstr (argv[i], "$view"))
{
g_warning ("Build job: the '$view' placeholder is deprecated.");
- new_arg = latexila_utils_str_replace (argv[i], "$view", "xdg-open");
+ new_arg = tepl_utils_str_replace (argv[i], "$view", "xdg-open");
}
if (new_arg != NULL)
diff --git a/src/liblatexila/latexila-build-tool.c b/src/liblatexila/latexila-build-tool.c
index 177ffda..ab3120b 100644
--- a/src/liblatexila/latexila-build-tool.c
+++ b/src/liblatexila/latexila-build-tool.c
@@ -670,13 +670,13 @@ open_file (GTask *task)
if (strstr (file_to_open, "$filename") != NULL)
{
- uri = latexila_utils_str_replace (file_to_open, "$filename", filename);
- uri_for_display = latexila_utils_str_replace (file_to_open, "$filename",
filename_for_display);
+ uri = tepl_utils_str_replace (file_to_open, "$filename", filename);
+ uri_for_display = tepl_utils_str_replace (file_to_open, "$filename", filename_for_display);
}
else if (strstr (file_to_open, "$shortname") != NULL)
{
- uri = latexila_utils_str_replace (file_to_open, "$shortname", shortname);
- uri_for_display = latexila_utils_str_replace (file_to_open, "$shortname",
shortname_for_display);
+ uri = tepl_utils_str_replace (file_to_open, "$shortname", shortname);
+ uri_for_display = tepl_utils_str_replace (file_to_open, "$shortname", shortname_for_display);
}
else
{
diff --git a/src/liblatexila/latexila-latex-commands.c b/src/liblatexila/latexila-latex-commands.c
index 2f817a1..339c4dc 100644
--- a/src/liblatexila/latexila-latex-commands.c
+++ b/src/liblatexila/latexila-latex-commands.c
@@ -434,8 +434,8 @@ insert_text (TeplApplicationWindow *tepl_window,
current_indent = tepl_iter_get_line_indentation (&selection_start);
newline_replacement = g_strdup_printf ("\n%s", current_indent);
- text_before_with_indent = latexila_utils_str_replace (text_before, "\n", newline_replacement);
- text_after_with_indent = latexila_utils_str_replace (text_after, "\n", newline_replacement);
+ text_before_with_indent = tepl_utils_str_replace (text_before, "\n", newline_replacement);
+ text_after_with_indent = tepl_utils_str_replace (text_after, "\n", newline_replacement);
g_free (current_indent);
g_free (newline_replacement);
diff --git a/src/liblatexila/latexila-utils.c b/src/liblatexila/latexila-utils.c
index 1b7195f..bec1866 100644
--- a/src/liblatexila/latexila-utils.c
+++ b/src/liblatexila/latexila-utils.c
@@ -91,42 +91,6 @@ latexila_utils_get_pixbuf_from_icon_name (const gchar *icon_name,
return pixbuf;
}
-/**
- * latexila_utils_str_replace:
- * @string: a string
- * @search: the search string
- * @replacement: the replacement string
- *
- * Replaces all occurences of @search by @replacement.
- *
- * Returns: A newly allocated string with the replacements. Free with g_free().
- */
-gchar *
-latexila_utils_str_replace (const gchar *string,
- const gchar *search,
- const gchar *replacement)
-{
- gchar **chunks;
- gchar *ret;
-
- g_return_val_if_fail (string != NULL, NULL);
- g_return_val_if_fail (search != NULL, NULL);
- g_return_val_if_fail (replacement != NULL, NULL);
-
- chunks = g_strsplit (string, search, -1);
- if (chunks != NULL && chunks[0] != NULL)
- {
- ret = g_strjoinv (replacement, chunks);
- }
- else
- {
- ret = g_strdup (string);
- }
-
- g_strfreev (chunks);
- return ret;
-}
-
/**
* latexila_utils_file_query_exists_async:
* @file: a #GFile.
diff --git a/src/liblatexila/latexila-utils.h b/src/liblatexila/latexila-utils.h
index 8f7e37f..d23b9ef 100644
--- a/src/liblatexila/latexila-utils.h
+++ b/src/liblatexila/latexila-utils.h
@@ -53,12 +53,6 @@ GtkWidget * latexila_utils_join_widgets (GtkWidget *widget_top,
GdkPixbuf * latexila_utils_get_pixbuf_from_icon_name (const gchar *icon_name,
GtkIconSize icon_size);
-/* String utilities */
-
-gchar * latexila_utils_str_replace (const gchar *string,
- const gchar *search,
- const gchar *replacement);
-
/* Others */
void latexila_utils_register_icons (void);
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 1dc417d..3be2bf7 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -23,9 +23,6 @@ UNIT_TEST_PROGS = test-build-tools
test_build_tools_SOURCES = test-build-tools.c
nodist_test_build_tools_SOURCES = build-tools-resources.c
-UNIT_TEST_PROGS += test-utils
-test_utils_SOURCES = test-utils.c
-
noinst_PROGRAMS = $(UNIT_TEST_PROGS)
TESTS = $(UNIT_TEST_PROGS)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]