[Xfce4-commits] <thunar:master> Make ThunarFile structure private.

Nick Schermer noreply at xfce.org
Wed Oct 3 22:04:01 CEST 2012


Updating branch refs/heads/master
         to 956b0f8960c39e939c6915edab5b425c07dc815e (commit)
       from 2172fa840c7606cd18e6758456e8dc40e5845adf (commit)

commit 956b0f8960c39e939c6915edab5b425c07dc815e
Author: Nick Schermer <nick at xfce.org>
Date:   Wed Oct 3 21:54:47 2012 +0200

    Make ThunarFile structure private.
    
    Not used, only through macros. This gives better type
    checking esp with debugging enabled.

 thunar/thunar-file.c |   91 +++++++++++++++++++++++++++++++++++++++++++++++++-
 thunar/thunar-file.h |   72 ++++-----------------------------------
 2 files changed, 98 insertions(+), 65 deletions(-)

diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c
index 2ceff15..dfd2977 100644
--- a/thunar/thunar-file.c
+++ b/thunar/thunar-file.c
@@ -137,6 +137,32 @@ static guint              file_signals[LAST_SIGNAL];
 
 
 
+struct _ThunarFileClass
+{
+  GObjectClass __parent__;
+
+  /* signals */
+  void (*destroy) (ThunarFile *file);
+};
+
+struct _ThunarFile
+{
+  GObject        __parent__;
+
+  /*< private >*/
+  GFileMonitor  *monitor;
+  GFileInfo     *info;
+  GFile         *gfile;
+  gchar         *custom_icon_name;
+  gchar         *display_name;
+  gchar         *basename;
+  gchar         *thumbnail_path;
+  guint          flags;
+  guint          is_mounted : 1;
+};
+
+
+
 G_DEFINE_TYPE_WITH_CODE (ThunarFile, thunar_file, G_TYPE_OBJECT,
     G_IMPLEMENT_INTERFACE (THUNARX_TYPE_FILE_INFO, thunar_file_info_init))
 
@@ -327,7 +353,7 @@ thunar_file_info_get_name (ThunarxFileInfo *file_info)
 static gchar*
 thunar_file_info_get_uri (ThunarxFileInfo *file_info)
 {
-  return thunar_file_dup_uri (file_info);
+  return thunar_file_dup_uri (THUNAR_FILE (file_info));
 }
 
 
@@ -910,6 +936,51 @@ thunar_file_load (ThunarFile   *file,
     }
 }
 
+
+/**
+ * thunar_file_get_file:
+ * @file : a #ThunarFile instance.
+ *
+ * Returns the #GFile that refers to the location of @file.
+ *
+ * The returned #GFile is owned by @file and must not be released
+ * with g_object_unref().
+ * 
+ * Return value: the #GFile corresponding to @file.
+ **/
+GFile *
+thunar_file_get_file (const ThunarFile *file)
+{
+  _thunar_return_val_if_fail (THUNAR_IS_FILE (file), NULL);
+  _thunar_return_val_if_fail (G_IS_FILE (file->gfile), NULL);
+  return file->gfile;
+}
+
+
+
+/**
+ * thunar_file_get_info:
+ * @file : a #ThunarFile instance.
+ *
+ * Returns the #GFileInfo for @file.
+ *
+ * Note, that there's no reference taken for the caller on the
+ * returned #GFileInfo, so if you need the object for a longer
+ * perioud, you'll need to take a reference yourself using the
+ * g_object_ref() method.
+ *
+ * Return value: the #GFileInfo for @file or %NULL.
+ **/
+GFileInfo *
+thunar_file_get_info (const ThunarFile *file)
+{
+  _thunar_return_val_if_fail (THUNAR_IS_FILE (file), NULL);
+  _thunar_return_val_if_fail (file->info == NULL || G_IS_FILE_INFO (file->info), NULL);
+  return file->info;
+}
+
+
+
 /**
  * thunar_file_get_parent:
  * @file  : a #ThunarFile instance.
@@ -2845,6 +2916,24 @@ thunar_file_get_thumbnail_path (ThunarFile *file)
 
 
 /**
+ * thunar_file_get_thumb_state:
+ * @file : a #ThunarFile.
+ *
+ * Returns the current #ThunarFileThumbState for @file. This
+ * method is intended to be used by #ThunarIconFactory only.
+ *
+ * Return value: the #ThunarFileThumbState for @file.
+ **/
+ThunarFileThumbState
+thunar_file_get_thumb_state (const ThunarFile *file)
+{
+  _thunar_return_val_if_fail (THUNAR_IS_FILE (file), THUNAR_FILE_THUMB_STATE_UNKNOWN);
+  return (file->flags & THUNAR_FILE_THUMB_STATE_MASK);
+}
+
+
+
+/**
  * thunar_file_set_thumb_state:
  * @file        : a #ThunarFile.
  * @thumb_state : the new #ThunarFileThumbState.
diff --git a/thunar/thunar-file.h b/thunar/thunar-file.h
index 0c8085f..76db5d4 100644
--- a/thunar/thunar-file.h
+++ b/thunar/thunar-file.h
@@ -98,29 +98,7 @@ typedef enum /*< flags >*/
 #define THUNAR_FILE_EMBLEM_NAME_CANT_WRITE "emblem-nowrite"
 #define THUNAR_FILE_EMBLEM_NAME_DESKTOP "emblem-desktop"
 
-struct _ThunarFileClass
-{
-  GObjectClass __parent__;
-
-  /* signals */
-  void (*destroy) (ThunarFile *file);
-};
 
-struct _ThunarFile
-{
-  GObject        __parent__;
-
-  /*< private >*/
-  GFileMonitor  *monitor;
-  GFileInfo     *info;
-  GFile         *gfile;
-  gchar         *custom_icon_name;
-  gchar         *display_name;
-  gchar         *basename;
-  gchar         *thumbnail_path;
-  guint          flags;
-  guint          is_mounted : 1;
-};
 
 GType             thunar_file_get_type             (void) G_GNUC_CONST;
 
@@ -129,6 +107,10 @@ ThunarFile       *thunar_file_get                  (GFile                  *file
 ThunarFile       *thunar_file_get_for_uri          (const gchar            *uri,
                                                     GError                **error);
 
+GFile            *thunar_file_get_file             (const ThunarFile       *file);
+
+GFileInfo        *thunar_file_get_info             (const ThunarFile       *file);
+
 ThunarFile       *thunar_file_get_parent           (const ThunarFile       *file,
                                                     GError                **error);
 
@@ -218,6 +200,7 @@ gboolean          thunar_file_set_custom_icon      (ThunarFile              *fil
                                                     GError                 **error);
 
 const gchar     *thunar_file_get_thumbnail_path    (ThunarFile              *file);
+ThunarFileThumbState thunar_file_get_thumb_state   (const ThunarFile        *file);
 void             thunar_file_set_thumb_state       (ThunarFile              *file, 
                                                     ThunarFileThumbState     state);
 GIcon            *thunar_file_get_preview_icon     (const ThunarFile        *file);
@@ -254,7 +237,7 @@ gboolean         thunar_file_is_desktop              (const ThunarFile *file);
  *
  * Return value: %TRUE if @file is the root directory.
  **/
-#define thunar_file_is_root(file) (thunar_g_file_is_root (THUNAR_FILE ((file))->gfile))
+#define thunar_file_is_root(file) (thunar_g_file_is_root (thunar_file_get_file (file)))
 
 /**
  * thunar_file_has_parent:
@@ -268,34 +251,6 @@ gboolean         thunar_file_is_desktop              (const ThunarFile *file);
 #define thunar_file_has_parent(file) (!thunar_file_is_root (THUNAR_FILE ((file))))
 
 /**
- * thunar_file_get_info:
- * @file : a #ThunarFile instance.
- *
- * Returns the #GFileInfo for @file.
- *
- * Note, that there's no reference taken for the caller on the
- * returned #GFileInfo, so if you need the object for a longer
- * perioud, you'll need to take a reference yourself using the
- * g_object_ref() method.
- *
- * Return value: the #GFileInfo for @file.
- **/
-#define thunar_file_get_info(file) (THUNAR_FILE ((file))->info)
-
-/**
- * thunar_file_get_file:
- * @file : a #ThunarFile instance.
- *
- * Returns the #GFile that refers to the location of @file.
- *
- * The returned #GFile is owned by @file and must not be released
- * with g_object_unref().
- * 
- * Return value: the #GFile corresponding to @file.
- **/
-#define thunar_file_get_file(file) (THUNAR_FILE ((file))->gfile)
-
-/**
  * thunar_file_dup_uri:
  * @file : a #ThunarFile instance.
  *
@@ -304,7 +259,7 @@ gboolean         thunar_file_is_desktop              (const ThunarFile *file);
  *
  * Return value: the URI for @file.
  **/
-#define thunar_file_dup_uri(file) (g_file_get_uri (THUNAR_FILE ((file))->gfile))
+#define thunar_file_dup_uri(file) (g_file_get_uri (thunar_file_get_file (file)))
 
 /**
  * thunar_file_has_uri_scheme:
@@ -315,7 +270,7 @@ gboolean         thunar_file_is_desktop              (const ThunarFile *file);
  *
  * Return value: TRUE, if the schemes match, FALSE otherwise.
  **/
-#define thunar_file_has_uri_scheme(file, uri_scheme) (g_file_has_uri_scheme (THUNAR_FILE ((file))->gfile, (uri_scheme)))
+#define thunar_file_has_uri_scheme(file, uri_scheme) (g_file_has_uri_scheme (thunar_file_get_file (file), (uri_scheme)))
 
 /**
  * thunar_file_changed:
@@ -330,17 +285,6 @@ G_STMT_START{                                             \
 }G_STMT_END
 
 /**
- * thunar_file_get_thumb_state:
- * @file : a #ThunarFile.
- *
- * Returns the current #ThunarFileThumbState for @file. This
- * method is intended to be used by #ThunarIconFactory only.
- *
- * Return value: the #ThunarFileThumbState for @file.
- **/
-#define thunar_file_get_thumb_state(file) (THUNAR_FILE ((file))->flags & THUNAR_FILE_THUMB_STATE_MASK)
-
-/**
  * thunar_file_list_copy:
  * @file_list : a list of #ThunarFile<!---->s.
  *


More information about the Xfce4-commits mailing list