[Xfce4-commits] [xfce/thunar] 02/04: Improvements after comments by Andrzej

noreply at xfce.org noreply at xfce.org
Sat Dec 20 01:36:56 CET 2014


This is an automated email from the git hooks/post-receive script.

andrzejr pushed a commit to branch master
in repository xfce/thunar.

commit 2ed192eafad68ecc653070ec4050fdd6ecb5c6e7
Author: Andre Miranda <andreldm1989 at gmail.com>
Date:   Thu Dec 18 22:42:27 2014 -0300

    Improvements after comments by Andrzej
---
 thunar/thunar-dialogs.c            |    6 +-
 thunar/thunar-file.c               |   29 +++-
 thunar/thunar-file.h               |  280 ++++++++++++++++++------------------
 thunar/thunar-list-model.c         |   86 ++++++++++-
 thunar/thunar-preferences-dialog.c |    2 +-
 thunar/thunar-standard-view.c      |    1 +
 6 files changed, 249 insertions(+), 155 deletions(-)

diff --git a/thunar/thunar-dialogs.c b/thunar/thunar-dialogs.c
index 99b9e54..7cee548 100644
--- a/thunar/thunar-dialogs.c
+++ b/thunar/thunar-dialogs.c
@@ -519,6 +519,7 @@ thunar_dialogs_show_job_ask_replace (GtkWindow  *parent,
   gchar             *size_string;
   gchar             *text;
   gint               response;
+  gboolean           file_size_binary;
 
   _thunar_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), THUNAR_JOB_RESPONSE_CANCEL);
   _thunar_return_val_if_fail (THUNAR_IS_FILE (src_file), THUNAR_JOB_RESPONSE_CANCEL);
@@ -527,6 +528,7 @@ thunar_dialogs_show_job_ask_replace (GtkWindow  *parent,
   /* determine the style used to format dates */
   preferences = thunar_preferences_get ();
   g_object_get (G_OBJECT (preferences), "misc-date-style", &date_style, NULL);
+  g_object_get (G_OBJECT (preferences), "misc-file-size-binary", &file_size_binary, NULL);
   g_object_unref (G_OBJECT (preferences));
 
   /* setup the confirmation dialog */
@@ -613,7 +615,7 @@ thunar_dialogs_show_job_ask_replace (GtkWindow  *parent,
   g_object_unref (G_OBJECT (icon));
   gtk_widget_show (image);
 
-  size_string = thunar_file_get_size_string (dst_file);
+  size_string = thunar_file_get_size_string_formatted (dst_file, file_size_binary);
   date_string = thunar_file_get_date_string (dst_file, THUNAR_FILE_DATE_MODIFIED, date_style);
   text = g_strdup_printf ("%s %s\n%s %s", _("Size:"), size_string, _("Modified:"), date_string);
   label = gtk_label_new (text);
@@ -644,7 +646,7 @@ thunar_dialogs_show_job_ask_replace (GtkWindow  *parent,
   g_object_unref (G_OBJECT (icon));
   gtk_widget_show (image);
 
-  size_string = thunar_file_get_size_string (src_file);
+  size_string = thunar_file_get_size_string_formatted (src_file, file_size_binary);
   date_string = thunar_file_get_date_string (src_file, THUNAR_FILE_DATE_MODIFIED, date_style);
   text = g_strdup_printf ("%s %s\n%s %s", _("Size:"), size_string, _("Modified:"), date_string);
   label = gtk_label_new (text);
diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c
index 080f202..25567df 100644
--- a/thunar/thunar-file.c
+++ b/thunar/thunar-file.c
@@ -2161,16 +2161,31 @@ thunar_file_get_mode_string (const ThunarFile *file)
 gchar *
 thunar_file_get_size_string (const ThunarFile *file)
 {
-  ThunarPreferences *preferences;
-  gboolean           file_size_binary;
-
   _thunar_return_val_if_fail (THUNAR_IS_FILE (file), NULL);
+  return g_format_size (thunar_file_get_size (file));
+}
 
-  preferences = thunar_preferences_get ();
-  g_object_get (preferences, "misc-file-size-binary", &file_size_binary, NULL);
-  g_object_unref (preferences);
 
-  return g_format_size_full (thunar_file_get_size (file), file_size_binary ? G_FORMAT_SIZE_IEC_UNITS : G_FORMAT_SIZE_DEFAULT);
+
+/**
+ * thunar_file_get_size_string_formatted:
+ * @file             : a #ThunarFile instance.
+ * @file_size_binary : indicates if file size format
+ *                     should be binary or not.
+ *
+ * Returns the size of the file as text in a human readable
+ * format in decimal or binary format. You'll need to free
+ * the result using g_free() if you're done with it.
+ *
+ * Return value: the size of @file in a human readable
+ *               format.
+ **/
+gchar *
+thunar_file_get_size_string_formatted (const ThunarFile *file, const gboolean file_size_binary)
+{
+  _thunar_return_val_if_fail (THUNAR_IS_FILE (file), NULL);
+  return g_format_size_full (thunar_file_get_size (file),
+                             file_size_binary ? G_FORMAT_SIZE_IEC_UNITS : G_FORMAT_SIZE_DEFAULT);
 }
 
 
diff --git a/thunar/thunar-file.h b/thunar/thunar-file.h
index 74ed6f8..d7a09d2 100644
--- a/thunar/thunar-file.h
+++ b/thunar/thunar-file.h
@@ -114,145 +114,147 @@ typedef void (*ThunarFileGetFunc) (GFile      *location,
 
 
 
-GType             thunar_file_get_type             (void) G_GNUC_CONST;
-
-ThunarFile       *thunar_file_get                  (GFile                  *file,
-                                                    GError                **error);
-ThunarFile       *thunar_file_get_with_info        (GFile                  *file,
-                                                    GFileInfo              *info,
-                                                    gboolean                not_mounted);
-ThunarFile       *thunar_file_get_for_uri          (const gchar            *uri,
-                                                    GError                **error);
-void              thunar_file_get_async            (GFile                  *location,
-                                                    GCancellable           *cancellable,
-                                                    ThunarFileGetFunc       func,
-                                                    gpointer                user_data);
-
-GFile            *thunar_file_get_file             (const ThunarFile       *file) G_GNUC_PURE;
-
-GFileInfo        *thunar_file_get_info             (const ThunarFile       *file) G_GNUC_PURE;
-
-ThunarFile       *thunar_file_get_parent           (const ThunarFile       *file,
-                                                    GError                **error);
-
-gboolean          thunar_file_check_loaded         (ThunarFile             *file);
-
-gboolean          thunar_file_execute              (ThunarFile             *file,
-                                                    GFile                  *working_directory,
-                                                    gpointer                parent,
-                                                    GList                  *path_list,
-                                                    GError                **error);
-
-gboolean          thunar_file_launch               (ThunarFile             *file,
-                                                    gpointer                parent,
-                                                    const gchar            *startup_id,
-                                                    GError                **error);
-
-gboolean          thunar_file_rename               (ThunarFile             *file,
-                                                    const gchar            *name,
-                                                    GCancellable           *cancellable,
-                                                    gboolean                called_from_job,
-                                                    GError                **error);
-
-GdkDragAction     thunar_file_accepts_drop         (ThunarFile             *file,
-                                                    GList                  *path_list,
-                                                    GdkDragContext         *context,
-                                                    GdkDragAction          *suggested_action_return);
-
-guint64           thunar_file_get_date             (const ThunarFile       *file,
-                                                    ThunarFileDateType      date_type) G_GNUC_PURE;
-
-gchar            *thunar_file_get_date_string      (const ThunarFile       *file,
-                                                    ThunarFileDateType      date_type,
-                                                    ThunarDateStyle         date_style) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
-gchar            *thunar_file_get_mode_string      (const ThunarFile       *file) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
-gchar            *thunar_file_get_size_string      (const ThunarFile       *file) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
-
-GVolume          *thunar_file_get_volume           (const ThunarFile       *file);
-
-ThunarGroup      *thunar_file_get_group            (const ThunarFile       *file);
-ThunarUser       *thunar_file_get_user             (const ThunarFile       *file);
-
-const gchar      *thunar_file_get_content_type     (ThunarFile             *file);
-gboolean          thunar_file_load_content_type    (ThunarFile             *file);
-const gchar      *thunar_file_get_symlink_target   (const ThunarFile       *file);
-const gchar      *thunar_file_get_basename         (const ThunarFile       *file) G_GNUC_CONST;
-gboolean          thunar_file_is_symlink           (const ThunarFile       *file);
-guint64           thunar_file_get_size             (const ThunarFile       *file);
-GAppInfo         *thunar_file_get_default_handler  (const ThunarFile       *file);
-GFileType         thunar_file_get_kind             (const ThunarFile       *file) G_GNUC_PURE;
-GFile            *thunar_file_get_target_location  (const ThunarFile       *file);
-ThunarFileMode    thunar_file_get_mode             (const ThunarFile       *file);
-gboolean          thunar_file_is_mounted           (const ThunarFile       *file);
-gboolean          thunar_file_exists               (const ThunarFile       *file);
-gboolean          thunar_file_is_directory         (const ThunarFile       *file) G_GNUC_PURE;
-gboolean          thunar_file_is_shortcut          (const ThunarFile       *file) G_GNUC_PURE;
-gboolean          thunar_file_is_mountable         (const ThunarFile       *file) G_GNUC_PURE;
-gboolean          thunar_file_is_local             (const ThunarFile       *file);
-gboolean          thunar_file_is_parent            (const ThunarFile       *file,
-                                                    const ThunarFile       *child);
-gboolean          thunar_file_is_gfile_ancestor    (const ThunarFile       *file, 
-                                                    GFile                  *ancestor);
-gboolean          thunar_file_is_ancestor          (const ThunarFile       *file, 
-                                                    const ThunarFile       *ancestor);
-gboolean          thunar_file_is_executable        (const ThunarFile       *file);
-gboolean          thunar_file_is_writable          (const ThunarFile       *file);
-gboolean          thunar_file_is_hidden            (const ThunarFile       *file);
-gboolean          thunar_file_is_home              (const ThunarFile       *file);
-gboolean          thunar_file_is_regular           (const ThunarFile       *file) G_GNUC_PURE;
-gboolean          thunar_file_is_trashed           (const ThunarFile       *file);
-gboolean          thunar_file_is_desktop_file      (const ThunarFile       *file,
-                                                    gboolean               *is_secure);
-const gchar      *thunar_file_get_display_name     (const ThunarFile       *file) G_GNUC_CONST;
-
-gchar            *thunar_file_get_deletion_date    (const ThunarFile       *file,
-                                                    ThunarDateStyle         date_style) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
-const gchar      *thunar_file_get_original_path    (const ThunarFile       *file);
-guint32           thunar_file_get_item_count       (const ThunarFile       *file);
-
-gboolean          thunar_file_is_chmodable         (const ThunarFile       *file);
-gboolean          thunar_file_is_renameable        (const ThunarFile       *file);
-gboolean          thunar_file_can_be_trashed       (const ThunarFile       *file);
-
-GList            *thunar_file_get_emblem_names     (ThunarFile              *file);
-void              thunar_file_set_emblem_names     (ThunarFile              *file,
-                                                    GList                   *emblem_names);
-
-const gchar      *thunar_file_get_custom_icon      (const ThunarFile        *file);
-gboolean          thunar_file_set_custom_icon      (ThunarFile              *file,
-                                                    const gchar             *custom_icon,
-                                                    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);
-GFilesystemPreviewType thunar_file_get_preview_type (const ThunarFile *file);
-const gchar      *thunar_file_get_icon_name        (ThunarFile              *file,
-                                                    ThunarFileIconState     icon_state,
-                                                    GtkIconTheme           *icon_theme);
-
-void              thunar_file_watch                (ThunarFile             *file);
-void              thunar_file_unwatch              (ThunarFile             *file);
-
-void              thunar_file_reload               (ThunarFile             *file);
-
-void              thunar_file_destroy              (ThunarFile             *file);
-
-
-gint              thunar_file_compare_by_name      (const ThunarFile       *file_a,
-                                                    const ThunarFile       *file_b,
-                                                    gboolean                case_sensitive) G_GNUC_PURE;
-
-ThunarFile       *thunar_file_cache_lookup         (const GFile            *file);
-gchar            *thunar_file_cached_display_name  (const GFile            *file);
-
-
-GList            *thunar_file_list_get_applications  (GList *file_list);
-GList            *thunar_file_list_to_thunar_g_file_list    (GList *file_list);
-
-gboolean          thunar_file_is_desktop           (const ThunarFile *file);
+GType             thunar_file_get_type                   (void) G_GNUC_CONST;
+
+ThunarFile       *thunar_file_get                        (GFile                  *file,
+                                                          GError                **error);
+ThunarFile       *thunar_file_get_with_info              (GFile                  *file,
+                                                          GFileInfo              *info,
+                                                          gboolean                not_mounted);
+ThunarFile       *thunar_file_get_for_uri                (const gchar            *uri,
+                                                          GError                **error);
+void              thunar_file_get_async                  (GFile                  *location,
+                                                          GCancellable           *cancellable,
+                                                          ThunarFileGetFunc       func,
+                                                          gpointer                user_data);
+
+GFile            *thunar_file_get_file                   (const ThunarFile       *file) G_GNUC_PURE;
+
+GFileInfo        *thunar_file_get_info                   (const ThunarFile       *file) G_GNUC_PURE;
+
+ThunarFile       *thunar_file_get_parent                 (const ThunarFile       *file,
+                                                          GError                **error);
+
+gboolean          thunar_file_check_loaded               (ThunarFile             *file);
+
+gboolean          thunar_file_execute                    (ThunarFile             *file,
+                                                          GFile                  *working_directory,
+                                                          gpointer                parent,
+                                                          GList                  *path_list,
+                                                          GError                **error);
+
+gboolean          thunar_file_launch                     (ThunarFile             *file,
+                                                          gpointer                parent,
+                                                          const gchar            *startup_id,
+                                                          GError                **error);
+
+gboolean          thunar_file_rename                     (ThunarFile             *file,
+                                                          const gchar            *name,
+                                                          GCancellable           *cancellable,
+                                                          gboolean                called_from_job,
+                                                          GError                **error);
+
+GdkDragAction     thunar_file_accepts_drop               (ThunarFile             *file,
+                                                          GList                  *path_list,
+                                                          GdkDragContext         *context,
+                                                          GdkDragAction          *suggested_action_return);
+
+guint64           thunar_file_get_date                   (const ThunarFile       *file,
+                                                          ThunarFileDateType      date_type) G_GNUC_PURE;
+
+gchar            *thunar_file_get_date_string            (const ThunarFile       *file,
+                                                          ThunarFileDateType      date_type,
+                                                          ThunarDateStyle         date_style) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
+gchar            *thunar_file_get_mode_string            (const ThunarFile       *file) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
+gchar            *thunar_file_get_size_string            (const ThunarFile       *file) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
+gchar            *thunar_file_get_size_string_formatted  (const ThunarFile       *file, 
+                                                          const gboolean          file_size_binary);
+
+GVolume          *thunar_file_get_volume                 (const ThunarFile       *file);
+
+ThunarGroup      *thunar_file_get_group                  (const ThunarFile       *file);
+ThunarUser       *thunar_file_get_user                   (const ThunarFile       *file);
+
+const gchar      *thunar_file_get_content_type           (ThunarFile             *file);
+gboolean          thunar_file_load_content_type          (ThunarFile             *file);
+const gchar      *thunar_file_get_symlink_target         (const ThunarFile       *file);
+const gchar      *thunar_file_get_basename               (const ThunarFile       *file) G_GNUC_CONST;
+gboolean          thunar_file_is_symlink                 (const ThunarFile       *file);
+guint64           thunar_file_get_size                   (const ThunarFile       *file);
+GAppInfo         *thunar_file_get_default_handler        (const ThunarFile       *file);
+GFileType         thunar_file_get_kind                   (const ThunarFile       *file) G_GNUC_PURE;
+GFile            *thunar_file_get_target_location        (const ThunarFile       *file);
+ThunarFileMode    thunar_file_get_mode                   (const ThunarFile       *file);
+gboolean          thunar_file_is_mounted                 (const ThunarFile       *file);
+gboolean          thunar_file_exists                     (const ThunarFile       *file);
+gboolean          thunar_file_is_directory               (const ThunarFile       *file) G_GNUC_PURE;
+gboolean          thunar_file_is_shortcut                (const ThunarFile       *file) G_GNUC_PURE;
+gboolean          thunar_file_is_mountable               (const ThunarFile       *file) G_GNUC_PURE;
+gboolean          thunar_file_is_local                   (const ThunarFile       *file);
+gboolean          thunar_file_is_parent                  (const ThunarFile       *file,
+                                                          const ThunarFile       *child);
+gboolean          thunar_file_is_gfile_ancestor          (const ThunarFile       *file, 
+                                                          GFile                  *ancestor);
+gboolean          thunar_file_is_ancestor                (const ThunarFile       *file, 
+                                                          const ThunarFile       *ancestor);
+gboolean          thunar_file_is_executable              (const ThunarFile       *file);
+gboolean          thunar_file_is_writable                (const ThunarFile       *file);
+gboolean          thunar_file_is_hidden                  (const ThunarFile       *file);
+gboolean          thunar_file_is_home                    (const ThunarFile       *file);
+gboolean          thunar_file_is_regular                 (const ThunarFile       *file) G_GNUC_PURE;
+gboolean          thunar_file_is_trashed                 (const ThunarFile       *file);
+gboolean          thunar_file_is_desktop_file            (const ThunarFile       *file,
+                                                          gboolean               *is_secure);
+const gchar      *thunar_file_get_display_name           (const ThunarFile       *file) G_GNUC_CONST;
+
+gchar            *thunar_file_get_deletion_date          (const ThunarFile       *file,
+                                                          ThunarDateStyle         date_style) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
+const gchar      *thunar_file_get_original_path          (const ThunarFile       *file);
+guint32           thunar_file_get_item_count             (const ThunarFile       *file);
+
+gboolean          thunar_file_is_chmodable               (const ThunarFile       *file);
+gboolean          thunar_file_is_renameable              (const ThunarFile       *file);
+gboolean          thunar_file_can_be_trashed             (const ThunarFile       *file);
+
+GList            *thunar_file_get_emblem_names           (ThunarFile              *file);
+void              thunar_file_set_emblem_names           (ThunarFile              *file,
+                                                          GList                   *emblem_names);
+
+const gchar      *thunar_file_get_custom_icon            (const ThunarFile        *file);
+gboolean          thunar_file_set_custom_icon            (ThunarFile              *file,
+                                                          const gchar             *custom_icon,
+                                                          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);
+GFilesystemPreviewType thunar_file_get_preview_type      (const ThunarFile *file);
+const gchar      *thunar_file_get_icon_name              (ThunarFile              *file,
+                                                          ThunarFileIconState      icon_state,
+                                                          GtkIconTheme            *icon_theme);
+
+void              thunar_file_watch                      (ThunarFile              *file);
+void              thunar_file_unwatch                    (ThunarFile              *file);
+
+void              thunar_file_reload                     (ThunarFile              *file);
+
+void              thunar_file_destroy                    (ThunarFile              *file);
+
+
+gint              thunar_file_compare_by_name            (const ThunarFile        *file_a,
+                                                          const ThunarFile        *file_b,
+                                                          gboolean                 case_sensitive) G_GNUC_PURE;
+
+ThunarFile       *thunar_file_cache_lookup               (const GFile             *file);
+gchar            *thunar_file_cached_display_name        (const GFile             *file);
+
+
+GList            *thunar_file_list_get_applications      (GList                  *file_list);
+GList            *thunar_file_list_to_thunar_g_file_list (GList                  *file_list);
+
+gboolean          thunar_file_is_desktop                 (const ThunarFile *file);
 
 /**
  * thunar_file_is_root:
diff --git a/thunar/thunar-list-model.c b/thunar/thunar-list-model.c
index eb06c95..9684758 100644
--- a/thunar/thunar-list-model.c
+++ b/thunar/thunar-list-model.c
@@ -50,6 +50,7 @@ enum
   PROP_FOLDERS_FIRST,
   PROP_NUM_FILES,
   PROP_SHOW_HIDDEN,
+  PROP_FILE_SIZE_BINARY,
   N_PROPERTIES
 };
 
@@ -184,6 +185,9 @@ static void               thunar_list_model_set_date_style        (ThunarListMod
 static gint               thunar_list_model_get_num_files         (ThunarListModel        *store);
 static gboolean           thunar_list_model_get_folders_first     (ThunarListModel        *store);
 
+static gboolean           thunar_list_model_get_file_size_binary  (ThunarListModel        *store);
+static void               thunar_list_model_set_file_size_binary  (ThunarListModel        *store,
+                                                                   gboolean                file_size_binary);
 
 struct _ThunarListModelClass
 {
@@ -210,6 +214,7 @@ struct _ThunarListModel
   GSList         *hidden;
   ThunarFolder   *folder;
   gboolean        show_hidden : 1;
+  gboolean        file_size_binary : 1;
   ThunarDateStyle date_style;
 
   /* Use the shared ThunarFileMonitor instance, so we
@@ -328,6 +333,18 @@ thunar_list_model_class_init (ThunarListModelClass *klass)
                             FALSE,
                             EXO_PARAM_READWRITE);
 
+  /**
+   * ThunarListModel::misc-file-size-binary:
+   *
+   * Tells whether to format file size in binary.
+   **/
+  list_model_props[PROP_FILE_SIZE_BINARY] =
+      g_param_spec_boolean ("file-size-binary",
+                            "file-size-binary",
+                            "file-size-binary",
+                            FALSE,
+                            EXO_PARAM_READWRITE);
+
   /* install properties */
   g_object_class_install_properties (gobject_class, N_PROPERTIES, list_model_props);
 
@@ -479,6 +496,10 @@ thunar_list_model_get_property (GObject    *object,
       g_value_set_boolean (value, thunar_list_model_get_show_hidden (store));
       break;
 
+    case PROP_FILE_SIZE_BINARY:
+      g_value_set_boolean (value, thunar_list_model_get_file_size_binary (store));
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -517,6 +538,10 @@ thunar_list_model_set_property (GObject      *object,
       thunar_list_model_set_show_hidden (store, g_value_get_boolean (value));
       break;
 
+    case PROP_FILE_SIZE_BINARY:
+      thunar_list_model_set_file_size_binary (store, g_value_get_boolean (value));
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -716,7 +741,7 @@ thunar_list_model_get_value (GtkTreeModel *model,
 
     case THUNAR_COLUMN_SIZE:
       g_value_init (value, G_TYPE_STRING);
-      g_value_take_string (value, thunar_file_get_size_string (file));
+      g_value_take_string (value, thunar_file_get_size_string_formatted (file, THUNAR_LIST_MODEL (model)->file_size_binary));
       break;
 
     case THUNAR_COLUMN_TYPE:
@@ -1966,6 +1991,57 @@ thunar_list_model_set_show_hidden (ThunarListModel *store,
 
 
 /**
+ * thunar_list_model_get_file_size_binary:
+ * @store : a valid #ThunarListModel object.
+ *
+ * Returns %TRUE if the file size should be formatted
+ * as binary.
+ *
+ * Return value: %TRUE if file size format is binary.
+ **/
+static gboolean
+thunar_list_model_get_file_size_binary (ThunarListModel *store)
+{
+  _thunar_return_val_if_fail (THUNAR_IS_LIST_MODEL (store), FALSE);
+  return store->file_size_binary;
+}
+
+
+
+/**
+ * thunar_list_model_set_file_size_binary:
+ * @store            : a valid #ThunarListModel object.
+ * @file_size_binary : %TRUE to format file size as binary.
+ *
+ * If @file_size_binary is %TRUE the file size should be
+ * formatted as binary.
+ **/
+static void
+thunar_list_model_set_file_size_binary (ThunarListModel *store,
+                                        gboolean         file_size_binary)
+{
+  _thunar_return_if_fail (THUNAR_IS_LIST_MODEL (store));
+
+  /* normalize the setting */
+  file_size_binary = !!file_size_binary;
+
+  /* check if we have a new setting */
+  if (store->file_size_binary != file_size_binary)
+    {
+      /* apply the new setting */
+      store->file_size_binary = file_size_binary;
+
+      /* resort the model with the new setting */
+      thunar_list_model_sort (store);
+
+      /* notify listeners */
+      g_object_notify_by_pspec (G_OBJECT (store), list_model_props[PROP_FILE_SIZE_BINARY]);
+    }
+}
+
+
+
+/**
  * thunar_list_model_get_file:
  * @store : a #ThunarListModel.
  * @iter  : a valid #GtkTreeIter for @store.
@@ -2165,9 +2241,7 @@ thunar_list_model_get_statusbar_text (ThunarListModel *store,
 
   _thunar_return_val_if_fail (THUNAR_IS_LIST_MODEL (store), NULL);
 
-  preferences = thunar_preferences_get ();
-  g_object_get (preferences, "misc-file-size-binary", &file_size_binary, NULL);
-  g_object_unref (preferences);
+  file_size_binary = thunar_list_model_get_file_size_binary(store);
 
   if (selected_items == NULL)
     {
@@ -2236,7 +2310,7 @@ thunar_list_model_get_statusbar_text (ThunarListModel *store,
         }
       else if (G_UNLIKELY (thunar_file_is_symlink (file)))
         {
-          size_string = thunar_file_get_size_string (file);
+          size_string = thunar_file_get_size_string_formatted (file, file_size_binary);
           text = g_strdup_printf (_("\"%s\" (%s) link to %s"), thunar_file_get_display_name (file),
                                   size_string, thunar_file_get_symlink_target (file));
           g_free (size_string);
@@ -2252,7 +2326,7 @@ thunar_list_model_get_statusbar_text (ThunarListModel *store,
       else if (thunar_file_is_regular (file))
         {
           description = g_content_type_get_description (content_type);
-          size_string = thunar_file_get_size_string (file);
+          size_string = thunar_file_get_size_string_formatted (file, file_size_binary);
           /* I18N, first %s is the display name of the file, 2nd the file size, 3rd the content type */
           text = g_strdup_printf (_("\"%s\" (%s) %s"), thunar_file_get_display_name (file),
                                   size_string, description);
diff --git a/thunar/thunar-preferences-dialog.c b/thunar/thunar-preferences-dialog.c
index a7ed452..c893142 100644
--- a/thunar/thunar-preferences-dialog.c
+++ b/thunar/thunar-preferences-dialog.c
@@ -300,7 +300,7 @@ thunar_preferences_dialog_init (ThunarPreferencesDialog *dialog)
   gtk_table_attach (GTK_TABLE (table), button, 0, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
   gtk_widget_show (button);
 
-  button = gtk_check_button_new_with_mnemonic (_("Show file size in binary"));
+  button = gtk_check_button_new_with_mnemonic (_("Show file size in binary format"));
   exo_mutual_binding_new (G_OBJECT (dialog->preferences), "misc-file-size-binary", G_OBJECT (button), "active");
   gtk_widget_set_tooltip_text (button, _("Select this option to show file size in binary format instead of decimal."));
   gtk_table_attach (GTK_TABLE (table), button, 0, 2, 3, 4, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
diff --git a/thunar/thunar-standard-view.c b/thunar/thunar-standard-view.c
index 6d5dd48..f428e3d 100644
--- a/thunar/thunar-standard-view.c
+++ b/thunar/thunar-standard-view.c
@@ -693,6 +693,7 @@ thunar_standard_view_init (ThunarStandardView *standard_view)
   exo_binding_new (G_OBJECT (standard_view->preferences), "misc-case-sensitive", G_OBJECT (standard_view->model), "case-sensitive");
   exo_binding_new (G_OBJECT (standard_view->preferences), "misc-date-style", G_OBJECT (standard_view->model), "date-style");
   exo_binding_new (G_OBJECT (standard_view->preferences), "misc-folders-first", G_OBJECT (standard_view->model), "folders-first");
+  exo_binding_new (G_OBJECT (standard_view->preferences), "misc-file-size-binary", G_OBJECT (standard_view->model), "file-size-binary");
 
   /* setup the icon renderer */
   standard_view->icon_renderer = thunar_icon_renderer_new ();

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list