[gtk/drop-file-system: 2/7] Reduce includes of gtkfilesystem.h



commit 0210850e8681c30579d0890112c8310ec4ba0947
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jul 11 18:11:32 2020 -0400

    Reduce includes of gtkfilesystem.h
    
    Move a few non-filesystem helpers to gtkfileutils.h,
    and drop the include in all the places where it isn't needed.

 gtk/gtkfilechooserdialog.c       |  1 -
 gtk/gtkfilechooserentry.c        |  2 +-
 gtk/gtkfilechooserentry.h        |  1 -
 gtk/gtkfilechoosernative.c       |  1 -
 gtk/gtkfilechoosernativeportal.c |  1 -
 gtk/gtkfilechoosernativequartz.c |  1 -
 gtk/gtkfilechoosernativewin32.c  |  1 -
 gtk/gtkfilechooserutils.c        | 73 +++++++++++++++++++++++++++++++++++++++
 gtk/gtkfilechooserutils.h        |  7 ++++
 gtk/gtkfilesystem.c              | 74 ----------------------------------------
 gtk/gtkfilesystem.h              | 13 +------
 gtk/gtkfilesystemmodel.c         |  2 +-
 gtk/gtknativedialog.c            |  1 -
 gtk/gtkplacessidebar.c           |  2 +-
 14 files changed, 84 insertions(+), 96 deletions(-)
---
diff --git a/gtk/gtkfilechooserdialog.c b/gtk/gtkfilechooserdialog.c
index a7bc1dd15f..d27ba8e3c0 100644
--- a/gtk/gtkfilechooserdialog.c
+++ b/gtk/gtkfilechooserdialog.c
@@ -26,7 +26,6 @@
 #include "gtkfilechooserwidgetprivate.h"
 #include "gtkfilechooserutils.h"
 #include "gtkfilechooserembed.h"
-#include "gtkfilesystem.h"
 #include "gtksizerequest.h"
 #include "gtktypebuiltins.h"
 #include "gtkintl.h"
diff --git a/gtk/gtkfilechooserentry.c b/gtk/gtkfilechooserentry.c
index 695d3db352..97e36f0994 100644
--- a/gtk/gtkfilechooserentry.c
+++ b/gtk/gtkfilechooserentry.c
@@ -25,7 +25,7 @@
 #include "gtkcelllayout.h"
 #include "gtkcellrenderertext.h"
 #include "gtkentryprivate.h"
-#include "gtkfilesystemmodel.h"
+#include "gtkfilechooserutils.h"
 #include "gtklabel.h"
 #include "gtkmain.h"
 #include "gtksizerequest.h"
diff --git a/gtk/gtkfilechooserentry.h b/gtk/gtkfilechooserentry.h
index fb6725e9c9..e1ed9f7304 100644
--- a/gtk/gtkfilechooserentry.h
+++ b/gtk/gtkfilechooserentry.h
@@ -19,7 +19,6 @@
 #ifndef __GTK_FILE_CHOOSER_ENTRY_H__
 #define __GTK_FILE_CHOOSER_ENTRY_H__
 
-#include "gtkfilesystem.h"
 #include "gtkfilechooser.h"
 
 G_BEGIN_DECLS
diff --git a/gtk/gtkfilechoosernative.c b/gtk/gtkfilechoosernative.c
index b6f7a9b01b..d157dfa002 100644
--- a/gtk/gtkfilechoosernative.c
+++ b/gtk/gtkfilechoosernative.c
@@ -29,7 +29,6 @@
 #include "gtkfilechooserwidgetprivate.h"
 #include "gtkfilechooserutils.h"
 #include "gtkfilechooserembed.h"
-#include "gtkfilesystem.h"
 #include "gtksizerequest.h"
 #include "gtktypebuiltins.h"
 #include "gtkintl.h"
diff --git a/gtk/gtkfilechoosernativeportal.c b/gtk/gtkfilechoosernativeportal.c
index d14a28cb34..1aafd3d9fc 100644
--- a/gtk/gtkfilechoosernativeportal.c
+++ b/gtk/gtkfilechoosernativeportal.c
@@ -29,7 +29,6 @@
 #include "gtkfilechooserwidgetprivate.h"
 #include "gtkfilechooserutils.h"
 #include "gtkfilechooserembed.h"
-#include "gtkfilesystem.h"
 #include "gtksizerequest.h"
 #include "gtktypebuiltins.h"
 #include "gtkintl.h"
diff --git a/gtk/gtkfilechoosernativequartz.c b/gtk/gtkfilechoosernativequartz.c
index d7cf4113a4..1726942b97 100644
--- a/gtk/gtkfilechoosernativequartz.c
+++ b/gtk/gtkfilechoosernativequartz.c
@@ -29,7 +29,6 @@
 #include "gtkfilechooserwidgetprivate.h"
 #include "gtkfilechooserutils.h"
 #include "gtkfilechooserembed.h"
-#include "gtkfilesystem.h"
 #include "gtksizerequest.h"
 #include "gtktypebuiltins.h"
 #include "gtkintl.h"
diff --git a/gtk/gtkfilechoosernativewin32.c b/gtk/gtkfilechoosernativewin32.c
index 66157ccd69..9b43506042 100644
--- a/gtk/gtkfilechoosernativewin32.c
+++ b/gtk/gtkfilechoosernativewin32.c
@@ -35,7 +35,6 @@
 #include "gtkfilechooserwidgetprivate.h"
 #include "gtkfilechooserutils.h"
 #include "gtkfilechooserembed.h"
-#include "gtkfilesystem.h"
 #include "gtksizerequest.h"
 #include "gtktypebuiltins.h"
 #include "gtkintl.h"
diff --git a/gtk/gtkfilechooserutils.c b/gtk/gtkfilechooserutils.c
index 0c62e8d590..4f5891fca8 100644
--- a/gtk/gtkfilechooserutils.c
+++ b/gtk/gtkfilechooserutils.c
@@ -411,3 +411,76 @@ delegate_get_choice (GtkFileChooser  *chooser,
 {
   return gtk_file_chooser_get_choice (get_delegate (chooser), id);
 }
+
+gboolean
+_gtk_file_info_consider_as_directory (GFileInfo *info)
+{
+  GFileType type = g_file_info_get_file_type (info);
+
+  return (type == G_FILE_TYPE_DIRECTORY ||
+          type == G_FILE_TYPE_MOUNTABLE ||
+          type == G_FILE_TYPE_SHORTCUT);
+}
+
+gboolean
+_gtk_file_has_native_path (GFile *file)
+{
+  char *local_file_path;
+  gboolean has_native_path;
+
+  /* Don't use g_file_is_native(), as we want to support FUSE paths if available */
+  local_file_path = g_file_get_path (file);
+  has_native_path = (local_file_path != NULL);
+  g_free (local_file_path);
+
+  return has_native_path;
+}
+
+gboolean
+_gtk_file_consider_as_remote (GFile *file)
+{
+  GFileInfo *info;
+  gboolean is_remote;
+
+  info = g_file_query_filesystem_info (file, G_FILE_ATTRIBUTE_FILESYSTEM_REMOTE, NULL, NULL);
+  if (info)
+    {
+      is_remote = g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_FILESYSTEM_REMOTE);
+
+      g_object_unref (info);
+    }
+  else
+    is_remote = FALSE;
+
+  return is_remote;
+}
+
+GIcon *
+_gtk_file_info_get_icon (GFileInfo *info,
+                         int        icon_size,
+                         int        scale)
+{
+  GIcon *icon;
+  GdkPixbuf *pixbuf;
+  const gchar *thumbnail_path;
+
+  thumbnail_path = g_file_info_get_attribute_byte_string (info, G_FILE_ATTRIBUTE_THUMBNAIL_PATH);
+
+  if (thumbnail_path)
+    {
+      pixbuf = gdk_pixbuf_new_from_file_at_size (thumbnail_path,
+                                                 icon_size*scale, icon_size*scale,
+                                                 NULL);
+
+      if (pixbuf != NULL)
+        return G_ICON (pixbuf);
+    }
+
+  icon = g_file_info_get_icon (info);
+  if (icon)
+    return g_object_ref (icon);
+
+  /* Use general fallback for all files without icon */
+  icon = g_themed_icon_new ("text-x-generic");
+  return icon;
+}
diff --git a/gtk/gtkfilechooserutils.h b/gtk/gtkfilechooserutils.h
index 3ca736c996..43041e2885 100644
--- a/gtk/gtkfilechooserutils.h
+++ b/gtk/gtkfilechooserutils.h
@@ -49,6 +49,13 @@ GSettings *_gtk_file_chooser_get_settings_for_widget (GtkWidget *widget);
 
 gchar * _gtk_file_chooser_label_for_file (GFile *file);
 
+gboolean        _gtk_file_info_consider_as_directory (GFileInfo *info);
+gboolean        _gtk_file_has_native_path (GFile *file);
+gboolean        _gtk_file_consider_as_remote (GFile *file);
+GIcon *               _gtk_file_info_get_icon    (GFileInfo *info,
+                                                  int        icon_size,
+                                                  int        scale);
+
 G_END_DECLS
 
 #endif /* __GTK_FILE_CHOOSER_UTILS_H__ */
diff --git a/gtk/gtkfilesystem.c b/gtk/gtkfilesystem.c
index 4e71446d69..c7bdc0e68f 100644
--- a/gtk/gtkfilesystem.c
+++ b/gtk/gtkfilesystem.c
@@ -747,77 +747,3 @@ _gtk_file_system_volume_unref (GtkFileSystemVolume *volume)
       G_IS_DRIVE (volume))
     g_object_unref (volume);
 }
-
-/* GFileInfo helper functions */
-GIcon *
-_gtk_file_info_get_icon (GFileInfo *info,
-                        int        icon_size,
-                         int        scale)
-{
-  GIcon *icon;
-  GdkPixbuf *pixbuf;
-  const gchar *thumbnail_path;
-
-  thumbnail_path = g_file_info_get_attribute_byte_string (info, G_FILE_ATTRIBUTE_THUMBNAIL_PATH);
-
-  if (thumbnail_path)
-    {
-      pixbuf = gdk_pixbuf_new_from_file_at_size (thumbnail_path,
-                                                icon_size*scale, icon_size*scale,
-                                                NULL);
-
-      if (pixbuf != NULL)
-        return G_ICON (pixbuf);
-    }
-
-  icon = g_file_info_get_icon (info);
-  if (icon)
-    return g_object_ref (icon);
-
-  /* Use general fallback for all files without icon */
-  icon = g_themed_icon_new ("text-x-generic");
-  return icon;
-}
-
-gboolean
-_gtk_file_info_consider_as_directory (GFileInfo *info)
-{
-  GFileType type = g_file_info_get_file_type (info);
-  
-  return (type == G_FILE_TYPE_DIRECTORY ||
-          type == G_FILE_TYPE_MOUNTABLE ||
-          type == G_FILE_TYPE_SHORTCUT);
-}
-
-gboolean
-_gtk_file_has_native_path (GFile *file)
-{
-  char *local_file_path;
-  gboolean has_native_path;
-
-  /* Don't use g_file_is_native(), as we want to support FUSE paths if available */
-  local_file_path = g_file_get_path (file);
-  has_native_path = (local_file_path != NULL);
-  g_free (local_file_path);
-
-  return has_native_path;
-}
-
-gboolean
-_gtk_file_consider_as_remote (GFile *file)
-{
-  GFileInfo *info;
-  gboolean is_remote;
-
-  info = g_file_query_filesystem_info (file, G_FILE_ATTRIBUTE_FILESYSTEM_REMOTE, NULL, NULL);
-  if (info)
-    {
-      is_remote = g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_FILESYSTEM_REMOTE);
-
-      g_object_unref (info);
-    }
-  else
-    is_remote = FALSE;
-
-  return is_remote;
-}
diff --git a/gtk/gtkfilesystem.h b/gtk/gtkfilesystem.h
index c734dfcede..62a82d6537 100644
--- a/gtk/gtkfilesystem.h
+++ b/gtk/gtkfilesystem.h
@@ -99,18 +99,7 @@ GIcon *               _gtk_file_system_volume_get_icon          (GtkFileSystemVo
 GtkFileSystemVolume  *_gtk_file_system_volume_ref              (GtkFileSystemVolume *volume);
 void                  _gtk_file_system_volume_unref            (GtkFileSystemVolume *volume);
 
-/* GFileInfo helper functions */
-GIcon *               _gtk_file_info_get_icon    (GFileInfo *info,
-                                                  int        icon_size,
-                                                  int        scale);
-
-gboolean       _gtk_file_info_consider_as_directory (GFileInfo *info);
-
-/* GFile helper functions */
-gboolean       _gtk_file_has_native_path (GFile *file);
-
-gboolean        _gtk_file_consider_as_remote (GFile *file);
-
 G_END_DECLS
 
 #endif /* __GTK_FILE_SYSTEM_H__ */
+
diff --git a/gtk/gtkfilesystemmodel.c b/gtk/gtkfilesystemmodel.c
index 006cb1252b..a541b88ba9 100644
--- a/gtk/gtkfilesystemmodel.c
+++ b/gtk/gtkfilesystemmodel.c
@@ -23,7 +23,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "gtkfilesystem.h"
+#include "gtkfilechooserutils.h"
 #include "gtkintl.h"
 #include "gtkmarshalers.h"
 #include "gtktreedatalist.h"
diff --git a/gtk/gtknativedialog.c b/gtk/gtknativedialog.c
index 784455e118..1ba13798c5 100644
--- a/gtk/gtknativedialog.c
+++ b/gtk/gtknativedialog.c
@@ -28,7 +28,6 @@
 #include "gtkfilechooserwidgetprivate.h"
 #include "gtkfilechooserutils.h"
 #include "gtkfilechooserembed.h"
-#include "gtkfilesystem.h"
 #include "gtksizerequest.h"
 #include "gtktypebuiltins.h"
 #include "gtkintl.h"
diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c
index 1131668f58..7c528252e2 100644
--- a/gtk/gtkplacessidebar.c
+++ b/gtk/gtkplacessidebar.c
@@ -33,7 +33,7 @@
 #include "gdk/gdkkeysyms.h"
 #include "gtkbookmarksmanagerprivate.h"
 #include "gtkcelllayout.h"
-#include "gtkfilesystem.h"
+#include "gtkfilechooserutils.h"
 #include "gtkicontheme.h"
 #include "gtkintl.h"
 #include "gtkmain.h"


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