cheese r897 - in trunk: . src
- From: fargiolas svn gnome org
- To: svn-commits-list gnome org
- Subject: cheese r897 - in trunk: . src
- Date: Tue, 12 Aug 2008 11:20:44 +0000 (UTC)
Author: fargiolas
Date: Tue Aug 12 11:20:43 2008
New Revision: 897
URL: http://svn.gnome.org/viewvc/cheese?rev=897&view=rev
Log:
Test for file existence before moving to trash. Remove item from thumbview if trashing succeeds (don't wait for monitor to notice). Untabify cheese-window.c
Modified:
trunk/ChangeLog
trunk/src/cheese-thumb-view.c
trunk/src/cheese-thumb-view.h
trunk/src/cheese-window.c
Modified: trunk/src/cheese-thumb-view.c
==============================================================================
--- trunk/src/cheese-thumb-view.c (original)
+++ trunk/src/cheese-thumb-view.c Tue Aug 12 11:20:43 2008
@@ -25,7 +25,6 @@
#include <glib.h>
#include <gtk/gtk.h>
-#include <gio/gio.h>
#include <libgnomeui/libgnomeui.h>
#include "cheese-fileutil.h"
@@ -234,17 +233,22 @@
}
}
-static void
+void
cheese_thumb_view_remove_item (CheeseThumbView *thumb_view, GFile *file)
{
CheeseThumbViewPrivate* priv = CHEESE_THUMB_VIEW_GET_PRIVATE (thumb_view);
char *path;
GtkTreeIter iter;
char *filename;
+ gboolean found = FALSE;
filename = g_file_get_path (file);
- gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->store), &iter);
+ if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->store), &iter)) {
+ /* a single item was on the thumbview but it's been already removed */
+ return;
+ }
+
/* check if the selected item is the first, else go through the store */
gtk_tree_model_get (GTK_TREE_MODEL (priv->store), &iter, THUMBNAIL_URL_COLUMN, &path, -1);
if (g_ascii_strcasecmp (path, filename))
@@ -252,12 +256,19 @@
while (gtk_tree_model_iter_next (GTK_TREE_MODEL (priv->store), &iter))
{
gtk_tree_model_get (GTK_TREE_MODEL (priv->store), &iter, THUMBNAIL_URL_COLUMN, &path, -1);
- if (!g_ascii_strcasecmp (path, filename))
+ if (!g_ascii_strcasecmp (path, filename)) {
+ found = TRUE;
break;
+ }
}
+ } else {
+ found = TRUE;
}
g_free (path);
g_free (filename);
+
+ if (!found) return;
+
gboolean valid = gtk_list_store_remove (priv->store, &iter);
if (valid)
{
Modified: trunk/src/cheese-thumb-view.h
==============================================================================
--- trunk/src/cheese-thumb-view.h (original)
+++ trunk/src/cheese-thumb-view.h Tue Aug 12 11:20:43 2008
@@ -23,6 +23,7 @@
#include <glib.h>
#include <gtk/gtk.h>
+#include <gio/gio.h>
G_BEGIN_DECLS
@@ -44,11 +45,12 @@
} CheeseThumbViewClass;
-GType cheese_thumb_view_get_type (void);
+GType cheese_thumb_view_get_type (void);
GtkWidget *cheese_thumb_view_new ();
GList *cheese_thumb_view_get_selected_images_list (CheeseThumbView *thumb_view);
char *cheese_thumb_view_get_selected_image (CheeseThumbView *thumb_view);
guint cheese_thumb_view_get_n_selected (CheeseThumbView *thumbview);
+void cheese_thumb_view_remove_item (CheeseThumbView *thumb_view, GFile *file);
G_END_DECLS
Modified: trunk/src/cheese-window.c
==============================================================================
--- trunk/src/cheese-window.c (original)
+++ trunk/src/cheese-window.c Tue Aug 12 11:20:43 2008
@@ -393,12 +393,12 @@
GtkWidget *error_dialog;
primary = g_strdup (_("Error while deleting"));
secondary = g_strdup_printf (_("The file \"%s\" cannot be deleted. Details: %s"),
- g_file_get_basename (file), message);
+ g_file_get_basename (file), message);
error_dialog = gtk_message_dialog_new (GTK_WINDOW (cheese_window->window),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "%s", primary);
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "%s", primary);
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (error_dialog),
- "%s", secondary);
+ "%s", secondary);
gtk_dialog_run (GTK_DIALOG (error_dialog));
gtk_widget_destroy (error_dialog);
g_free (primary);
@@ -418,17 +418,17 @@
if (batch == FALSE) {
if (list_length > 1) {
primary = g_strdup_printf (_("Are you sure you want to permanently delete the %'d selected items?"),
- list_length);
+ list_length);
} else {
primary = g_strdup_printf (_("Are you sure you want to permanently delete \"%s\"?"),
- g_file_get_basename (files->data));
+ g_file_get_basename (files->data));
}
secondary = g_strdup_printf (_("If you delete an item, it will be permanently lost."));
question_dialog = gtk_message_dialog_new (GTK_WINDOW (cheese_window->window),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, "%s", primary);
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, "%s", primary);
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (question_dialog),
- "%s", secondary);
+ "%s", secondary);
gtk_dialog_add_button (GTK_DIALOG (question_dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
gtk_dialog_add_button (GTK_DIALOG (question_dialog), GTK_STOCK_DELETE, GTK_RESPONSE_ACCEPT);
response = gtk_dialog_run (GTK_DIALOG (question_dialog));
@@ -445,7 +445,7 @@
if (!g_file_delete (l->data, NULL, &error))
{
cheese_window_delete_error_dialog (cheese_window, l->data,
- error != NULL ? error->message : _("Unknown Error"));
+ error != NULL ? error->message : _("Unknown Error"));
g_error_free (error);
error = NULL;
}
@@ -468,24 +468,28 @@
g_print ("received %d items to delete\n", list_length);
for (l = files; l != NULL; l = l->next)
- {
+ {
+ if (!g_file_test (g_file_get_path (l->data), G_FILE_TEST_EXISTS)) {
+ g_object_unref (l->data);
+ break;
+ }
if (!g_file_trash (l->data, NULL, &error))
{
primary = g_strdup (_("Cannot move file to trash, do you want to delete immediately?"));
secondary = g_strdup_printf (_("The file \"%s\" cannot be moved to the trash. Details: %s"),
- g_file_get_basename (l->data), error->message);
+ g_file_get_basename (l->data), error->message);
question_dialog = gtk_message_dialog_new (GTK_WINDOW (cheese_window->window),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, "%s", primary);
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, "%s", primary);
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (question_dialog),
- "%s", secondary);
+ "%s", secondary);
gtk_dialog_add_button (GTK_DIALOG (question_dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
if (list_length > 1)
{
- /* no need for all those buttons we have a single file to delete */
- gtk_dialog_add_button (GTK_DIALOG (question_dialog), CHEESE_BUTTON_SKIP, CHEESE_RESPONSE_SKIP);
- gtk_dialog_add_button (GTK_DIALOG (question_dialog), CHEESE_BUTTON_SKIP_ALL, CHEESE_RESPONSE_SKIP_ALL);
- gtk_dialog_add_button (GTK_DIALOG (question_dialog), CHEESE_BUTTON_DELETE_ALL, CHEESE_RESPONSE_DELETE_ALL);
+ /* no need for all those buttons we have a single file to delete */
+ gtk_dialog_add_button (GTK_DIALOG (question_dialog), CHEESE_BUTTON_SKIP, CHEESE_RESPONSE_SKIP);
+ gtk_dialog_add_button (GTK_DIALOG (question_dialog), CHEESE_BUTTON_SKIP_ALL, CHEESE_RESPONSE_SKIP_ALL);
+ gtk_dialog_add_button (GTK_DIALOG (question_dialog), CHEESE_BUTTON_DELETE_ALL, CHEESE_RESPONSE_DELETE_ALL);
}
gtk_dialog_add_button (GTK_DIALOG (question_dialog), GTK_STOCK_DELETE, GTK_RESPONSE_ACCEPT);
response = gtk_dialog_run (GTK_DIALOG (question_dialog));
@@ -497,25 +501,27 @@
switch (response)
{
case CHEESE_RESPONSE_DELETE_ALL:
- /* forward the list to cmd_delete */
- cheese_window_cmd_delete_file (cheese_window, l, TRUE);
- return;
+ /* forward the list to cmd_delete */
+ cheese_window_cmd_delete_file (cheese_window, l, TRUE);
+ return;
case GTK_RESPONSE_ACCEPT:
- /* create a single file list for cmd_delete */
- d = g_list_append (d, g_object_ref(l->data));
- cheese_window_cmd_delete_file (cheese_window, d, TRUE);
- g_list_free (d);
- break;
+ /* create a single file list for cmd_delete */
+ d = g_list_append (d, g_object_ref(l->data));
+ cheese_window_cmd_delete_file (cheese_window, d, TRUE);
+ g_list_free (d);
+ break;
case CHEESE_RESPONSE_SKIP:
- /* do nothing, skip to the next item */
- break;
+ /* do nothing, skip to the next item */
+ break;
case CHEESE_RESPONSE_SKIP_ALL:
case GTK_RESPONSE_CANCEL:
case GTK_RESPONSE_DELETE_EVENT:
default:
- /* cancel the whole delete operation */
- return;
+ /* cancel the whole delete operation */
+ return;
}
+ } else {
+ cheese_thumb_view_remove_item (CHEESE_THUMB_VIEW (cheese_window->thumb_view), l->data);
}
g_object_unref (l->data);
}
@@ -852,7 +858,7 @@
static void
cheese_window_selection_changed_cb (GtkIconView *iconview,
- CheeseWindow *cheese_window)
+ CheeseWindow *cheese_window)
{
if (cheese_thumb_view_get_n_selected (CHEESE_THUMB_VIEW (cheese_window->thumb_view)) > 0) {
gtk_action_group_set_sensitive (cheese_window->actions_file, TRUE);
@@ -1540,7 +1546,7 @@
g_signal_connect (cheese_window->take_picture, "clicked",
G_CALLBACK (cheese_window_action_button_clicked_cb), cheese_window);
g_signal_connect (cheese_window->thumb_view, "selection_changed",
- G_CALLBACK (cheese_window_selection_changed_cb), cheese_window);
+ G_CALLBACK (cheese_window_selection_changed_cb), cheese_window);
g_signal_connect (cheese_window->thumb_view, "button_press_event",
G_CALLBACK (cheese_window_button_press_event_cb), cheese_window);
}
@@ -1578,12 +1584,12 @@
gdk_threads_enter ();
dialog = gtk_message_dialog_new (NULL,
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- "%s", primary);
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ "%s", primary);
gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog),
- secondary);
+ secondary);
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
g_error_free (error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]