summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErnestas Kulik <ernestask@gnome.org>2018-05-18 14:16:19 +0300
committerCarlos Soriano <csoriano1618@gmail.com>2018-05-18 14:39:23 +0000
commit1de2ec116d063c83bfe38c8f95418955d165b20c (patch)
tree52f2c78daeeb4a4129188b5e33fd069e88e1f6f3
parentcfa26f0cfe827e84d4ae0501e80fa65b190ff0ee (diff)
downloadnautilus-1de2ec116d063c83bfe38c8f95418955d165b20c.tar.gz
eel: glib-extensions: Move functions to Nautilus
They’re only used once, so why not.
-rw-r--r--eel/eel-glib-extensions.c105
-rw-r--r--eel/eel-glib-extensions.h8
-rw-r--r--eel/meson.build1
-rw-r--r--src/nautilus-file.c22
-rw-r--r--src/nautilus-files-view.c52
5 files changed, 72 insertions, 116 deletions
diff --git a/eel/eel-glib-extensions.c b/eel/eel-glib-extensions.c
deleted file mode 100644
index 32ec12155..000000000
--- a/eel/eel-glib-extensions.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/* eel-glib-extensions.c - implementation of new functions that conceptually
- * belong in glib. Perhaps some of these will be
- * actually rolled into glib someday.
- *
- * Copyright (C) 2000 Eazel, Inc.
- *
- * The Gnome Library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * The Gnome Library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with the Gnome Library; see the file COPYING.LIB. If not,
- * see <http://www.gnu.org/licenses/>.
- *
- * Authors: John Sullivan <sullivan@eazel.com>
- */
-
-#include <config.h>
-#include "eel-glib-extensions.h"
-
-#include "eel-debug.h"
-#include "eel-lib-self-check-functions.h"
-#include "eel-string.h"
-#include <glib-object.h>
-#include <math.h>
-#include <stdlib.h>
-
-gboolean
-eel_g_strv_equal (char **a,
- char **b)
-{
- int i;
-
- if (g_strv_length (a) != g_strv_length (b))
- {
- return FALSE;
- }
-
- for (i = 0; a[i] != NULL; i++)
- {
- if (strcmp (a[i], b[i]) != 0)
- {
- return FALSE;
- }
- }
- return TRUE;
-}
-
-static int
-compare_pointers (gconstpointer pointer_1,
- gconstpointer pointer_2)
-{
- if ((const char *) pointer_1 < (const char *) pointer_2)
- {
- return -1;
- }
- if ((const char *) pointer_1 > (const char *) pointer_2)
- {
- return +1;
- }
- return 0;
-}
-
-gboolean
-eel_g_lists_sort_and_check_for_intersection (GList **list_1,
- GList **list_2)
-{
- GList *node_1, *node_2;
- int compare_result;
-
- *list_1 = g_list_sort (*list_1, compare_pointers);
- *list_2 = g_list_sort (*list_2, compare_pointers);
-
- node_1 = *list_1;
- node_2 = *list_2;
-
- while (node_1 != NULL && node_2 != NULL)
- {
- compare_result = compare_pointers (node_1->data, node_2->data);
- if (compare_result == 0)
- {
- return TRUE;
- }
- if (compare_result <= 0)
- {
- node_1 = node_1->next;
- }
- if (compare_result >= 0)
- {
- node_2 = node_2->next;
- }
- }
-
- return FALSE;
-}
-
-#if !defined (EEL_OMIT_SELF_CHECK)
-
-#endif /* !EEL_OMIT_SELF_CHECK */
diff --git a/eel/eel-glib-extensions.h b/eel/eel-glib-extensions.h
index 8b09cbd10..3b0ea0dfc 100644
--- a/eel/eel-glib-extensions.h
+++ b/eel/eel-glib-extensions.h
@@ -28,11 +28,3 @@
/* A gboolean variant for bit fields. */
typedef guint eel_boolean_bit;
-
-/* GList functions. */
-gboolean eel_g_lists_sort_and_check_for_intersection (GList **list_a,
- GList **list_b);
-
-/* NULL terminated string arrays (strv). */
-gboolean eel_g_strv_equal (char **a,
- char **b); \ No newline at end of file
diff --git a/eel/meson.build b/eel/meson.build
index 2f577a981..ba06203d4 100644
--- a/eel/meson.build
+++ b/eel/meson.build
@@ -8,7 +8,6 @@ libeel_2_sources = [
'eel-debug.h',
'eel-debug.c',
'eel-glib-extensions.h',
- 'eel-glib-extensions.c',
'eel-graphic-effects.h',
'eel-graphic-effects.c',
'eel-gtk-extensions.h',
diff --git a/src/nautilus-file.c b/src/nautilus-file.c
index d3ba8c841..a735fc0f0 100644
--- a/src/nautilus-file.c
+++ b/src/nautilus-file.c
@@ -330,6 +330,26 @@ metadata_hash_free (GHashTable *hash)
}
static gboolean
+_g_strv_equal (GStrv a,
+ GStrv b)
+{
+ if (g_strv_length (a) != g_strv_length (b))
+ {
+ return FALSE;
+ }
+
+ for (int i = 0; a[i] != NULL; i++)
+ {
+ if (strcmp (a[i], b[i]) != 0)
+ {
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
+static gboolean
metadata_hash_equal (GHashTable *hash1,
GHashTable *hash2)
{
@@ -364,7 +384,7 @@ metadata_hash_equal (GHashTable *hash1,
id = GPOINTER_TO_UINT (key1);
if (id & METADATA_ID_IS_LIST_MASK)
{
- if (!eel_g_strv_equal ((char **) value1, (char **) value2))
+ if (!_g_strv_equal ((char **) value1, (char **) value2))
{
return FALSE;
}
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index 5b6aae8ff..9f6eabde7 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -4029,6 +4029,56 @@ on_end_file_changes (NautilusFilesView *view)
}
}
+static int
+compare_pointers (gconstpointer pointer_1,
+ gconstpointer pointer_2)
+{
+ if (pointer_1 < pointer_2)
+ {
+ return -1;
+ }
+ else if (pointer_1 > pointer_2)
+ {
+ return +1;
+ }
+
+ return 0;
+}
+
+static gboolean
+_g_lists_sort_and_check_for_intersection (GList **list_1,
+ GList **list_2)
+{
+ GList *node_1;
+ GList *node_2;
+ int compare_result;
+
+ *list_1 = g_list_sort (*list_1, compare_pointers);
+ *list_2 = g_list_sort (*list_2, compare_pointers);
+
+ node_1 = *list_1;
+ node_2 = *list_2;
+
+ while (node_1 != NULL && node_2 != NULL)
+ {
+ compare_result = compare_pointers (node_1->data, node_2->data);
+ if (compare_result == 0)
+ {
+ return TRUE;
+ }
+ if (compare_result <= 0)
+ {
+ node_1 = node_1->next;
+ }
+ if (compare_result >= 0)
+ {
+ node_2 = node_2->next;
+ }
+ }
+
+ return FALSE;
+}
+
static void
process_old_files (NautilusFilesView *view)
{
@@ -4099,7 +4149,7 @@ process_old_files (NautilusFilesView *view)
g_autolist (NautilusFile) selection = NULL;
selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
files = file_and_directory_list_to_files (files_changed);
- send_selection_change = eel_g_lists_sort_and_check_for_intersection
+ send_selection_change = _g_lists_sort_and_check_for_intersection
(&files, &selection);
nautilus_file_list_free (files);
}