background: Sort Pictures in order of most recently modified
In the picture browser you see the most recently modified pictures first. https://bugzilla.gnome.org/show_bug.cgi?id=691800
This commit is contained in:
parent
3c0af77abb
commit
c3446cccdc
3 changed files with 33 additions and 7 deletions
|
@ -144,8 +144,8 @@ sort_func (GtkTreeModel *model,
|
||||||
{
|
{
|
||||||
CcBackgroundItem *item_a;
|
CcBackgroundItem *item_a;
|
||||||
CcBackgroundItem *item_b;
|
CcBackgroundItem *item_b;
|
||||||
const char *name_a;
|
guint64 modified_a;
|
||||||
const char *name_b;
|
guint64 modified_b;
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
gtk_tree_model_get (model, a,
|
gtk_tree_model_get (model, a,
|
||||||
|
@ -155,10 +155,10 @@ sort_func (GtkTreeModel *model,
|
||||||
1, &item_b,
|
1, &item_b,
|
||||||
-1);
|
-1);
|
||||||
|
|
||||||
name_a = cc_background_item_get_name (item_a);
|
modified_a = cc_background_item_get_modified (item_a);
|
||||||
name_b = cc_background_item_get_name (item_b);
|
modified_b = cc_background_item_get_modified (item_b);
|
||||||
|
|
||||||
retval = g_utf8_collate (name_a, name_b);
|
retval = modified_b - modified_a;
|
||||||
|
|
||||||
g_object_unref (item_a);
|
g_object_unref (item_a);
|
||||||
g_object_unref (item_b);
|
g_object_unref (item_b);
|
||||||
|
|
|
@ -50,6 +50,7 @@ struct CcBackgroundItemPrivate
|
||||||
gboolean is_deleted;
|
gboolean is_deleted;
|
||||||
gboolean needs_download;
|
gboolean needs_download;
|
||||||
CcBackgroundItemFlags flags;
|
CcBackgroundItemFlags flags;
|
||||||
|
guint64 modified;
|
||||||
|
|
||||||
/* internal */
|
/* internal */
|
||||||
GnomeBG *bg;
|
GnomeBG *bg;
|
||||||
|
@ -71,7 +72,8 @@ enum {
|
||||||
PROP_SOURCE_XML,
|
PROP_SOURCE_XML,
|
||||||
PROP_FLAGS,
|
PROP_FLAGS,
|
||||||
PROP_SIZE,
|
PROP_SIZE,
|
||||||
PROP_NEEDS_DOWNLOAD
|
PROP_NEEDS_DOWNLOAD,
|
||||||
|
PROP_MODIFIED
|
||||||
};
|
};
|
||||||
|
|
||||||
static void cc_background_item_class_init (CcBackgroundItemClass *klass);
|
static void cc_background_item_class_init (CcBackgroundItemClass *klass);
|
||||||
|
@ -285,6 +287,7 @@ update_info (CcBackgroundItem *item,
|
||||||
item->priv->name = g_strdup (g_file_info_get_display_name (info));
|
item->priv->name = g_strdup (g_file_info_get_display_name (info));
|
||||||
|
|
||||||
item->priv->mime_type = g_strdup (g_file_info_get_content_type (info));
|
item->priv->mime_type = g_strdup (g_file_info_get_content_type (info));
|
||||||
|
item->priv->modified = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info != NULL)
|
if (info != NULL)
|
||||||
|
@ -503,6 +506,14 @@ cc_background_item_get_needs_download (CcBackgroundItem *item)
|
||||||
return item->priv->needs_download;
|
return item->priv->needs_download;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
guint64
|
||||||
|
cc_background_item_get_modified (CcBackgroundItem *item)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (CC_IS_BACKGROUND_ITEM (item), 0);
|
||||||
|
|
||||||
|
return item->priv->modified;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cc_background_item_set_property (GObject *object,
|
cc_background_item_set_property (GObject *object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
|
@ -600,6 +611,9 @@ cc_background_item_get_property (GObject *object,
|
||||||
case PROP_NEEDS_DOWNLOAD:
|
case PROP_NEEDS_DOWNLOAD:
|
||||||
g_value_set_boolean (value, self->priv->needs_download);
|
g_value_set_boolean (value, self->priv->needs_download);
|
||||||
break;
|
break;
|
||||||
|
case PROP_MODIFIED:
|
||||||
|
g_value_set_uint64 (value, self->priv->modified);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
@ -725,6 +739,16 @@ cc_background_item_class_init (CcBackgroundItemClass *klass)
|
||||||
TRUE,
|
TRUE,
|
||||||
G_PARAM_READWRITE));
|
G_PARAM_READWRITE));
|
||||||
|
|
||||||
|
g_object_class_install_property (object_class,
|
||||||
|
PROP_MODIFIED,
|
||||||
|
g_param_spec_uint64 ("modified",
|
||||||
|
"modified",
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
G_MAXUINT64,
|
||||||
|
0,
|
||||||
|
G_PARAM_READABLE));
|
||||||
|
|
||||||
|
|
||||||
g_type_class_add_private (klass, sizeof (CcBackgroundItemPrivate));
|
g_type_class_add_private (klass, sizeof (CcBackgroundItemPrivate));
|
||||||
}
|
}
|
||||||
|
@ -742,6 +766,7 @@ cc_background_item_init (CcBackgroundItem *item)
|
||||||
item->priv->secondary_color = g_strdup ("#000000000000");
|
item->priv->secondary_color = g_strdup ("#000000000000");
|
||||||
item->priv->needs_download = TRUE;
|
item->priv->needs_download = TRUE;
|
||||||
item->priv->flags = 0;
|
item->priv->flags = 0;
|
||||||
|
item->priv->modified = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -871,6 +896,7 @@ cc_background_item_dump (CcBackgroundItem *item)
|
||||||
if (priv->mime_type)
|
if (priv->mime_type)
|
||||||
g_debug ("mime-type:\t\t%s", priv->mime_type);
|
g_debug ("mime-type:\t\t%s", priv->mime_type);
|
||||||
g_debug ("dimensions:\t\t%d x %d", priv->width, priv->height);
|
g_debug ("dimensions:\t\t%d x %d", priv->width, priv->height);
|
||||||
|
g_debug ("modified: %u", priv->modified);
|
||||||
g_debug (" ");
|
g_debug (" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,10 +93,10 @@ const char * cc_background_item_get_scolor (CcBackgroundItem *i
|
||||||
const char * cc_background_item_get_name (CcBackgroundItem *item);
|
const char * cc_background_item_get_name (CcBackgroundItem *item);
|
||||||
const char * cc_background_item_get_size (CcBackgroundItem *item);
|
const char * cc_background_item_get_size (CcBackgroundItem *item);
|
||||||
gboolean cc_background_item_get_needs_download (CcBackgroundItem *item);
|
gboolean cc_background_item_get_needs_download (CcBackgroundItem *item);
|
||||||
|
guint64 cc_background_item_get_modified (CcBackgroundItem *item);
|
||||||
|
|
||||||
gboolean cc_background_item_compare (CcBackgroundItem *saved,
|
gboolean cc_background_item_compare (CcBackgroundItem *saved,
|
||||||
CcBackgroundItem *configured);
|
CcBackgroundItem *configured);
|
||||||
|
|
||||||
void cc_background_item_dump (CcBackgroundItem *item);
|
void cc_background_item_dump (CcBackgroundItem *item);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue