[gthumb] made get_nearest_entry_point function public



commit 36dd5f35d1dccfe49b88ad81a54b82b578af6c7b
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Fri Nov 1 06:51:37 2019 +0100

    made get_nearest_entry_point function public

 gthumb/gth-browser.c | 52 +---------------------------------------------------
 gthumb/gth-main.c    | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 gthumb/gth-main.h    |  1 +
 3 files changed, 52 insertions(+), 51 deletions(-)
---
diff --git a/gthumb/gth-browser.c b/gthumb/gth-browser.c
index 00ba013b..e6b7c595 100644
--- a/gthumb/gth-browser.c
+++ b/gthumb/gth-browser.c
@@ -1614,56 +1614,6 @@ _gth_browser_load_ready_cb (GthFileSource *file_source,
 }
 
 
-static GFile *
-get_nearest_entry_point (GFile *file)
-{
-       GList *list;
-       GList *scan;
-       GList *entries;
-       char  *nearest_uri;
-       char  *uri;
-       int    file_uri_len;
-       int    min_diff;
-       GFile *nearest;
-
-       entries = NULL;
-       list = gth_main_get_all_entry_points ();
-       for (scan = list; scan; scan = scan->next) {
-               GthFileData *entry_point = scan->data;
-
-               if (g_file_equal (file, entry_point->file) || _g_file_has_prefix (file, entry_point->file))
-                       entries = g_list_prepend (entries, g_file_get_uri (entry_point->file));
-       }
-
-       nearest_uri = NULL;
-       uri = g_file_get_uri (file);
-       file_uri_len = strlen (uri);
-       min_diff = 0;
-       for (scan = entries; scan; scan = scan->next) {
-               char *entry_uri = scan->data;
-               int   entry_len;
-               int   diff;
-
-               entry_len = strlen (entry_uri);
-               diff = abs (entry_len - file_uri_len);
-               if ((scan == entries) || (diff < min_diff)) {
-                       min_diff = diff;
-                       nearest_uri = entry_uri;
-               }
-       }
-       g_free (uri);
-
-       nearest = NULL;
-       if (nearest_uri != NULL)
-               nearest = g_file_new_for_uri (nearest_uri);
-
-       _g_string_list_free (entries);
-       _g_object_list_unref (list);
-
-       return nearest;
-}
-
-
 static void
 mount_volume_ready_cb (GObject      *source_object,
                       GAsyncResult *result,
@@ -1741,7 +1691,7 @@ _gth_browser_load (GthBrowser *browser,
                break;
        }
 
-       entry_point = get_nearest_entry_point (location);
+       entry_point = gth_main_get_nearest_entry_point (location);
        load_data = load_data_new (browser,
                                   location,
                                   file_to_select,
diff --git a/gthumb/gth-main.c b/gthumb/gth-main.c
index a0e86431..d47508d7 100644
--- a/gthumb/gth-main.c
+++ b/gthumb/gth-main.c
@@ -310,6 +310,56 @@ gth_main_get_all_entry_points (void)
 }
 
 
+GFile *
+gth_main_get_nearest_entry_point (GFile *file)
+{
+       GList *list;
+       GList *scan;
+       GList *entries;
+       char  *nearest_uri;
+       char  *uri;
+       int    file_uri_len;
+       int    min_diff;
+       GFile *nearest;
+
+       entries = NULL;
+       list = gth_main_get_all_entry_points ();
+       for (scan = list; scan; scan = scan->next) {
+               GthFileData *entry_point = scan->data;
+
+               if (g_file_equal (file, entry_point->file) || _g_file_has_prefix (file, entry_point->file))
+                       entries = g_list_prepend (entries, g_file_get_uri (entry_point->file));
+       }
+
+       nearest_uri = NULL;
+       uri = g_file_get_uri (file);
+       file_uri_len = strlen (uri);
+       min_diff = 0;
+       for (scan = entries; scan; scan = scan->next) {
+               char *entry_uri = scan->data;
+               int   entry_len;
+               int   diff;
+
+               entry_len = strlen (entry_uri);
+               diff = abs (entry_len - file_uri_len);
+               if ((scan == entries) || (diff < min_diff)) {
+                       min_diff = diff;
+                       nearest_uri = entry_uri;
+               }
+       }
+       g_free (uri);
+
+       nearest = NULL;
+       if (nearest_uri != NULL)
+               nearest = g_file_new_for_uri (nearest_uri);
+
+       _g_string_list_free (entries);
+       _g_object_list_unref (list);
+
+       return nearest;
+}
+
+
 char *
 gth_main_get_gio_uri (const char *uri)
 {
diff --git a/gthumb/gth-main.h b/gthumb/gth-main.h
index 8ba74d9d..b9fba344 100644
--- a/gthumb/gth-main.h
+++ b/gthumb/gth-main.h
@@ -69,6 +69,7 @@ GthFileSource *        gth_main_get_file_source_for_uri       (const char
 GthFileSource *        gth_main_get_file_source               (GFile                *file);
 GList *                gth_main_get_all_file_sources          (void);
 GList *                gth_main_get_all_entry_points          (void);
+GFile *                gth_main_get_nearest_entry_point       (GFile                *file);
 char *                 gth_main_get_gio_uri                   (const char           *uri);
 GFile *                gth_main_get_gio_file                  (GFile                *file);
 void                   gth_main_register_metadata_category    (GthMetadataCategory  *metadata_category);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]