[Rawstudio-commit] r1893 - trunk/src
Anders Kvist
anders at kvistmail.dk
Tue Jul 22 12:40:31 CEST 2008
Author: akv
Date: 2008-07-22 12:40:30 +0200 (Tue, 22 Jul 2008)
New Revision: 1893
Modified:
trunk/src/rs-actions.c
trunk/src/rs-store.c
trunk/src/ui.xml
Log:
Added rs_store_auto_group().
Modified: trunk/src/rs-actions.c
===================================================================
--- trunk/src/rs-actions.c 2008-07-22 02:06:29 UTC (rev 1892)
+++ trunk/src/rs-actions.c 2008-07-22 10:40:30 UTC (rev 1893)
@@ -99,6 +99,7 @@
#ifndef EXPERIMENTAL
rs_core_action_group_set_visibility("Group", FALSE);
rs_core_action_group_set_visibility("Ungroup", FALSE);
+ rs_core_action_group_set_visibility("AutoGroup", FALSE);
#endif
g_list_free(selected);
}
@@ -550,6 +551,11 @@
rs_store_ungroup_photos(rs->store);
}
+ACTION(auto_group_photos)
+{
+ rs_store_auto_group(rs->store);
+}
+
ACTION(previous_photo)
{
gchar *current_filename = NULL;
@@ -826,6 +832,7 @@
{ "Unstraighten", NULL, _("_Unstraighten"), NULL, NULL, ACTION_CB(unstraighten) },
{ "Group", NULL, _("_Group"), NULL, NULL, ACTION_CB(group_photos) },
{ "Ungroup", NULL, _("_Ungroup"), NULL, NULL, ACTION_CB(ungroup_photos) },
+ { "AutoGroup", NULL, _("_Auto group"), NULL, NULL, ACTION_CB(auto_group_photos) },
/* View menu */
{ "PreviousPhoto", GTK_STOCK_GO_BACK, _("_Previous photo"), "<control>Left", NULL, ACTION_CB(previous_photo) },
Modified: trunk/src/rs-store.c
===================================================================
--- trunk/src/rs-store.c 2008-07-22 02:06:29 UTC (rev 1892)
+++ trunk/src/rs-store.c 2008-07-22 10:40:30 UTC (rev 1893)
@@ -1793,3 +1793,53 @@
{
return g_list_sort(selected, (GCompareFunc) g_utf8_collate);
}
+
+void
+rs_store_auto_group(RSStore *store)
+{
+ RS_FILETYPE *filetype = NULL;
+ gchar *filename = NULL;
+ gint timestamp = 0, timestamp_old = 0;
+ gint exposure;
+ RS_METADATA *meta;
+ GList *filenames = NULL;
+ GtkTreeIter iter;
+
+ // TODO: remove all existing groups in iconview.
+
+ gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store->store), &iter);
+ do
+ {
+ gtk_tree_model_get (GTK_TREE_MODEL(store->store), &iter, FULLNAME_COLUMN, &filename, -1);
+ filetype = rs_filetype_get(filename, TRUE);
+ if (filetype)
+ {
+ if(filetype->load_meta)
+ {
+ meta = rs_metadata_new();
+ filetype->load_meta(filename, meta);
+
+ if (!meta->timestamp)
+ return;
+
+ timestamp = meta->timestamp;
+ exposure = (1/meta->shutterspeed);
+
+ if (timestamp > timestamp_old + 1)
+ {
+ if (g_list_length(filenames) > 1)
+ store_group_photos_by_filenames(store->store, filenames);
+ g_list_free(filenames);
+ filenames = NULL;
+ }
+ timestamp_old = timestamp + exposure;
+ g_free(meta);
+ }
+ }
+ filenames = g_list_append(filenames, filename);
+ } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(store->store), &iter));
+
+ store_group_photos_by_filenames(store->store, filenames);
+ g_list_free(filenames);
+ filenames = NULL;
+}
Modified: trunk/src/ui.xml
===================================================================
--- trunk/src/ui.xml 2008-07-22 02:06:29 UTC (rev 1892)
+++ trunk/src/ui.xml 2008-07-22 10:40:30 UTC (rev 1893)
@@ -35,6 +35,7 @@
<menuitem action="Unstraighten" />
<menuitem action="Group" />
<menuitem action="Ungroup" />
+ <menuitem action="AutoGroup" />
</menu>
<menu action="ViewMenu">
<menuitem action="PreviousPhoto" />
More information about the Rawstudio-commit
mailing list