[gtk+/filesystemmodel] use the file system model accessors unconditionally in sort functions
- From: Benjamin Otte <otte src gnome org>
- To: svn-commits-list gnome org
- Subject: [gtk+/filesystemmodel] use the file system model accessors unconditionally in sort functions
- Date: Thu, 25 Jun 2009 13:51:58 +0000 (UTC)
commit b1aaaa191120e5e805397ad744d7e3ab2d5b7461
Author: Benjamin Otte <otte gnome org>
Date: Thu Jun 25 13:15:54 2009 +0200
use the file system model accessors unconditionally in sort functions
gtk/gtkfilechooserdefault.c | 56 +++++++------------------------------------
1 files changed, 9 insertions(+), 47 deletions(-)
---
diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c
index 5f70006..9bb74a8 100644
--- a/gtk/gtkfilechooserdefault.c
+++ b/gtk/gtkfilechooserdefault.c
@@ -6020,19 +6020,11 @@ install_list_model_filter (GtkFileChooserDefault *impl)
#define COMPARE_DIRECTORIES \
GtkFileChooserDefault *impl = user_data; \
- GtkFileSystemModel *fs_model = GTK_IS_FILE_SYSTEM_MODEL (model) ? GTK_FILE_SYSTEM_MODEL (model) : NULL; \
+ GtkFileSystemModel *fs_model = GTK_FILE_SYSTEM_MODEL (model); \
gboolean dir_a, dir_b; \
\
- if (fs_model) \
- { \
- dir_a = g_value_get_boolean (_gtk_file_system_model_get_value (fs_model, a, MODEL_COL_IS_FOLDER)); \
- dir_b = g_value_get_boolean (_gtk_file_system_model_get_value (fs_model, b, MODEL_COL_IS_FOLDER)); \
- } \
- else \
- { \
- gtk_tree_model_get (model, a, MODEL_COL_IS_FOLDER, &dir_a, -1); \
- gtk_tree_model_get (model, b, MODEL_COL_IS_FOLDER, &dir_b, -1); \
- } \
+ dir_a = g_value_get_boolean (_gtk_file_system_model_get_value (fs_model, a, MODEL_COL_IS_FOLDER)); \
+ dir_b = g_value_get_boolean (_gtk_file_system_model_get_value (fs_model, b, MODEL_COL_IS_FOLDER)); \
\
if (dir_a != dir_b) \
return impl->list_sort_ascending ? (dir_a ? -1 : 1) : (dir_a ? 1 : -1) /* Directories *always* go first */
@@ -6050,16 +6042,8 @@ name_sort_func (GtkTreeModel *model,
const char *key_a, *key_b;
gint result;
- if (fs_model)
- {
- key_a = g_value_get_string (_gtk_file_system_model_get_value (fs_model, a, MODEL_COL_NAME_COLLATED));
- key_b = g_value_get_string (_gtk_file_system_model_get_value (fs_model, b, MODEL_COL_NAME_COLLATED));
- }
- else
- {
- gtk_tree_model_get (model, a, MODEL_COL_NAME_COLLATED, &key_a, -1);
- gtk_tree_model_get (model, b, MODEL_COL_NAME_COLLATED, &key_b, -1);
- }
+ key_a = g_value_get_string (_gtk_file_system_model_get_value (fs_model, a, MODEL_COL_NAME_COLLATED));
+ key_b = g_value_get_string (_gtk_file_system_model_get_value (fs_model, b, MODEL_COL_NAME_COLLATED));
if (key_a && key_b)
result = strcmp (key_a, key_b);
@@ -6070,12 +6054,6 @@ name_sort_func (GtkTreeModel *model,
else
result = 0;
- if (!fs_model)
- {
- g_free ((char *) key_a);
- g_free ((char *) key_b);
- }
-
return result;
}
}
@@ -6092,16 +6070,8 @@ size_sort_func (GtkTreeModel *model,
{
gint64 size_a, size_b;
- if (fs_model)
- {
- size_a = g_value_get_int64 (_gtk_file_system_model_get_value (fs_model, a, MODEL_COL_SIZE));
- size_b = g_value_get_int64 (_gtk_file_system_model_get_value (fs_model, b, MODEL_COL_SIZE));
- }
- else
- {
- gtk_tree_model_get (model, a, MODEL_COL_SIZE, &size_a, -1);
- gtk_tree_model_get (model, b, MODEL_COL_SIZE, &size_b, -1);
- }
+ size_a = g_value_get_int64 (_gtk_file_system_model_get_value (fs_model, a, MODEL_COL_SIZE));
+ size_b = g_value_get_int64 (_gtk_file_system_model_get_value (fs_model, b, MODEL_COL_SIZE));
return size_a > size_b ? -1 : (size_a == size_b ? 0 : 1);
}
@@ -6119,16 +6089,8 @@ mtime_sort_func (GtkTreeModel *model,
{
glong ta, tb;
- if (fs_model)
- {
- ta = g_value_get_long (_gtk_file_system_model_get_value (fs_model, a, MODEL_COL_MTIME));
- tb = g_value_get_long (_gtk_file_system_model_get_value (fs_model, b, MODEL_COL_MTIME));
- }
- else
- {
- gtk_tree_model_get (model, a, MODEL_COL_MTIME, &ta, -1);
- gtk_tree_model_get (model, b, MODEL_COL_MTIME, &tb, -1);
- }
+ ta = g_value_get_long (_gtk_file_system_model_get_value (fs_model, a, MODEL_COL_MTIME));
+ tb = g_value_get_long (_gtk_file_system_model_get_value (fs_model, b, MODEL_COL_MTIME));
return ta > tb ? -1 : (ta == tb ? 0 : 1);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]