Author: post
Date: 2011-02-06 16:41:16 +0100 (Sun, 06 Feb 2011)
New Revision: 3811
Modified:
trunk/src/gtk-interface.c
trunk/src/rs-actions.c
trunk/src/rs-store.c
trunk/src/rs-store.h
Log:
Added more consistent handling of how multiple selected files are handled, and
also when the current image is assumed to be selected. Handles more complex
selections in the iconview and multiimage actions.
Modified: trunk/src/gtk-interface.c
===================================================================
--- trunk/src/gtk-interface.c 2011-02-06 13:59:52 UTC (rev 3810)
+++ trunk/src/gtk-interface.c 2011-02-06 15:41:16 UTC (rev 3811)
@@ -307,7 +307,7 @@
g_list_free(selected);
/* Change priority for currently open photo */
- if (rs->photo)
+ if (rs->photo && rs_store_is_photo_selected(rs->store,
rs->photo->filename))
{
rs->photo->priority = prio;
rs_store_set_flags(rs->store, rs->photo->filename, NULL, &prio,
NULL);
Modified: trunk/src/rs-actions.c
===================================================================
--- trunk/src/rs-actions.c 2011-02-06 13:59:52 UTC (rev 3810)
+++ trunk/src/rs-actions.c 2011-02-06 15:41:16 UTC (rev 3811)
@@ -742,7 +742,7 @@
ACTION(auto_wb)
{
- if (RS_IS_PHOTO(rs->photo))
+ if (RS_IS_PHOTO(rs->photo) && rs_store_is_photo_selected(rs->store,
rs->photo->filename))
{
gui_status_notify(_("Adjusting to auto white balance"));
rs_photo_set_wb_auto(rs->photo, rs->current_setting);
@@ -754,7 +754,7 @@
ACTION(camera_wb)
{
- if (RS_IS_PHOTO(rs->photo))
+ if (RS_IS_PHOTO(rs->photo) && rs_store_is_photo_selected(rs->store,
rs->photo->filename))
{
if (rs->photo->metadata->cam_mul[R] == -1.0)
gui_status_notify(_("No white balance to set from"));
@@ -1026,7 +1026,7 @@
{
GString *gs = g_string_new("");
GList *selected = NULL;
- gint num_selected, cur;
+ gint num_selected, cur, num_added = 0;
gui_set_busy(TRUE);
guint msg = gui_status_push(_("Adding images to batch queue"));
@@ -1035,22 +1035,19 @@
selected = rs_store_get_selected_names(rs->store);
num_selected = g_list_length(selected);
- if (RS_IS_PHOTO(rs->photo) && num_selected == 1)
+ if (RS_IS_PHOTO(rs->photo) && rs_store_is_photo_selected(rs->store,
rs->photo->filename))
{
rs_cache_save(rs->photo, MASK_ALL);
if (rs_batch_add_to_queue(rs->queue, rs->photo->filename,
rs->current_setting))
- g_string_printf(gs, _(" %s added to batch queue"),
rs->photo->filename);
- else
- g_string_printf(gs, _("%s already added to batch
queue"), rs->photo->filename);
+ num_added++;
}
- else
- {
- /* Deal with selected icons */
- for(cur=0;cur<num_selected;cur++)
- rs_batch_add_to_queue(rs->queue,
g_list_nth_data(selected, cur), rs->current_setting);
- g_string_printf(gs, _("%d photos added to batch queue"),
num_selected);
- }
+ /* Deal with selected icons */
+ for(cur=0;cur<num_selected;cur++)
+ if (rs_batch_add_to_queue(rs->queue, g_list_nth_data(selected,
cur), rs->current_setting))
+ num_added++;
+ g_string_printf(gs, _("%d photos added to batch queue"), num_added);
+
g_list_free(selected);
gui_status_notify(gs->str);
g_string_free(gs, TRUE);
@@ -1101,10 +1098,17 @@
GList *selected = NULL;
gint num_selected, i;
- rs_store_get_names(rs->store, NULL, &selected, NULL);
+ gui_set_busy(TRUE);
+ rs_store_get_names(rs->store, &selected, NULL, NULL);
selected = rs_store_sort_selected(selected);
num_selected = g_list_length(selected);
+ if (0 == num_selected && RS_IS_PHOTO(rs->photo))
+ {
+ selected = g_list_append(selected,
g_strdup(rs->photo->filename));
+ num_selected++;
+ }
+
for (i=0;i<num_selected;i++)
{
gchar *fullname = g_list_nth_data(selected, i);
@@ -1130,6 +1134,7 @@
+
((gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cb_b))) ? num_selected : 0)
+
((gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cb_c))) ? num_selected : 0));
+ gui_set_busy(FALSE);
gui_status_notify(gs->str);
}
@@ -1140,14 +1145,31 @@
ACTION(remove_from_batch)
{
- /* FIXME: Deal with mutiple selected photos! */
- if (RS_IS_PHOTO(rs->photo))
+ GList *selected = NULL;
+ GString *gs = g_string_new("");
+ gint num_selected, i, num_removed = 0;
+
+ gui_set_busy(TRUE);
+ guint msg = gui_status_push(_("Removing images from batch queue"));
+ GTK_CATCHUP();
+
+ rs_store_get_names(rs->store, &selected, NULL, NULL);
+ selected = rs_store_sort_selected(selected);
+ num_selected = g_list_length(selected);
+
+ for (i=0;i<num_selected;i++)
{
- if (rs_batch_remove_from_queue(rs->queue, rs->photo->filename,
rs->current_setting))
- gui_status_notify(_("Removed from batch queue"));
- else
- gui_status_notify(_("Not in batch queue"));
+ gchar *fullname = g_list_nth_data(selected, i);
+ if (rs_batch_remove_from_queue(rs->queue, fullname,
rs->current_setting))
+ num_removed++;
}
+ g_list_foreach(selected, (GFunc) g_free, NULL);
+ g_list_free(selected);
+ g_string_printf(gs, _("%d photos removed from batch queue"),
num_removed);
+ gui_set_busy(FALSE);
+ gui_status_pop(msg);
+ gui_status_notify(gs->str);
+ g_string_free(gs, TRUE);
}
/* This is protected by gdk_thread */
@@ -1366,7 +1388,7 @@
/* Batch menu */
{ "AddToBatch", GTK_STOCK_ADD, _("_Add to batch queue"), "<control>B",
NULL, ACTION_CB(add_to_batch) },
- { "AddViewToBatch", NULL, _("_Add current view to queue"), NULL, NULL,
ACTION_CB(add_view_to_batch) },
+ { "AddViewToBatch", NULL, _("_Add view to queue..."), NULL, NULL,
ACTION_CB(add_view_to_batch) },
{ "RemoveFromBatch", GTK_STOCK_REMOVE, _("_Remove from batch queue"),
"<control><alt>B", NULL, ACTION_CB(remove_from_batch) },
{ "ProcessBatch", GTK_STOCK_EXECUTE, _("_Start"), NULL, NULL,
ACTION_CB(ProcessBatch) },
Modified: trunk/src/rs-store.c
===================================================================
--- trunk/src/rs-store.c 2011-02-06 13:59:52 UTC (rev 3810)
+++ trunk/src/rs-store.c 2011-02-06 15:41:16 UTC (rev 3811)
@@ -503,6 +503,30 @@
return open_selected;
}
+extern gboolean
+rs_store_is_photo_selected(RSStore *store, const gchar *filename)
+{
+ if (!RS_IS_STORE(store) || NULL == filename)
+ return FALSE;
+
+ GList *selected = rs_store_get_selected_names(store);
+ GList *current = selected;
+ gboolean ret = FALSE;
+
+ if (NULL == selected)
+ ret = TRUE;
+
+ while (NULL != current)
+ {
+ if (0 == g_strcmp0(current->data, filename))
+ ret = TRUE;
+ current = g_list_next(current);
+ }
+ g_list_foreach(selected, (GFunc) g_free, NULL);
+ g_list_free(selected);
+ return ret;
+}
+
static void
selection_changed(GtkIconView *iconview, gpointer data)
{
Modified: trunk/src/rs-store.h
===================================================================
--- trunk/src/rs-store.h 2011-02-06 13:59:52 UTC (rev 3810)
+++ trunk/src/rs-store.h 2011-02-06 15:41:16 UTC (rev 3811)
@@ -252,4 +252,15 @@
extern gboolean
rs_store_set_open_selected(RSStore *store, gboolean open_selected);
+/**
+ * Return whether the file is assumed to be selected
+ * A special case is if NONE is selected, then we will return TRUE, since this
will
+ * actually assume that the current photo is selected.
+ * @param store A RSStore
+ * @param filename The filename of the photo
+ * @return TRUE if the photo is selected in the store, FALSE otherwise
+ */
+extern gboolean
+rs_store_is_photo_selected(RSStore *store, const gchar *filename);
+
#endif /* RS_STORE_H */
_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit