gnome-utils r7896 - in trunk/baobab: . src
- From: pborelli svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-utils r7896 - in trunk/baobab: . src
- Date: Thu, 1 May 2008 15:04:27 +0100 (BST)
Author: pborelli
Date: Thu May 1 14:04:26 2008
New Revision: 7896
URL: http://svn.gnome.org/viewvc/gnome-utils?rev=7896&view=rev
Log:
2008-05-01 Paolo Borelli <pborelli katamail com>
* src/baobab-utils.c:
* src/baobab-treeview.c:
* src/callbacks.c:
Factor out a can_trash_file util and use the proper display name
when showing an error about failed trashing of a file.
Modified:
trunk/baobab/ChangeLog
trunk/baobab/src/baobab-treeview.c
trunk/baobab/src/baobab-utils.c
trunk/baobab/src/baobab-utils.h
trunk/baobab/src/callbacks.c
Modified: trunk/baobab/src/baobab-treeview.c
==============================================================================
--- trunk/baobab/src/baobab-treeview.c (original)
+++ trunk/baobab/src/baobab-treeview.c Thu May 1 14:04:26 2008
@@ -133,31 +133,20 @@
/* right-click */
if (event->button == 3) {
- GFile * file;
- GFileInfo *info;
- gboolean isTrashable = FALSE;
-
+ GFile *file;
+
if (baobab.is_local) {
- file = g_file_new_for_path(baobab.selected_path);
+ file = g_file_new_for_path (baobab.selected_path);
}
else {
- file = g_file_new_for_uri(baobab.selected_path);
- }
-
- info = g_file_query_info (file, "standard::*",
- G_FILE_QUERY_INFO_NONE,
- NULL,
- NULL);
- if (info) {
- if (g_file_info_get_attribute_boolean (info,
- "access::can-trash"))
- isTrashable = FALSE;
-
+ file = g_file_new_for_uri (baobab.selected_path);
}
- popupmenu_list (path, event, isTrashable);
+
+ popupmenu_list (path, event, can_trash_file (file));
+
gtk_tree_path_free (path);
g_object_unref (file);
- if (info) g_object_unref (info);
+
return FALSE;
}
Modified: trunk/baobab/src/baobab-utils.c
==============================================================================
--- trunk/baobab/src/baobab-utils.c (original)
+++ trunk/baobab/src/baobab-utils.c Thu May 1 14:04:26 2008
@@ -494,29 +494,64 @@
}
gboolean
-trash_file (const gchar *filename)
+can_trash_file (GFile *file)
{
- GError *error = NULL;
- GFile *file;
- gchar *str = NULL;
+ GFileInfo *info;
+ gboolean can_trash = FALSE;
- file = g_file_new_for_path (filename);
+ info = g_file_query_info (file, "standard::*",
+ G_FILE_QUERY_INFO_NONE,
+ NULL,
+ NULL);
+
+ if (info) {
+ if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH)) {
+ can_trash = g_file_info_get_attribute_boolean (info,
+ G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH);
+ }
- if (!g_file_trash(file, NULL, &error)) {
- gchar *mess;
+ g_object_unref (info);
+ }
+
+ return can_trash;
+}
+
+gboolean
+trash_file (GFile *file)
+{
+ GError *error = NULL;
+
+ if (!g_file_trash (file, NULL, &error)) {
+ GFileInfo *info;
+ char *str = NULL;
+ char *mess;
+
+ info = g_file_query_info (file, "standard::*",
+ G_FILE_QUERY_INFO_NONE,
+ NULL,
+ NULL);
+
+ if (info) {
+ const char *displayname = g_file_info_get_display_name (info);
+ if (displayname)
+ str = g_strdup_printf (_("Could not move \"%s\" to the Trash"),
+ displayname);
+
+ g_object_unref (info);
+ }
+
+ /* fallback */
+ if (str == NULL)
+ str = g_strdup (_("Could not move file to the Trash"));
- str = g_strdup_printf (_("Could not move \"%s\" to the Trash"), g_path_get_basename (filename));
mess = g_strdup_printf (_("Details: %s"), error->message);
message (str, mess, GTK_MESSAGE_ERROR, baobab.window);
g_free (str);
g_free (mess);
g_error_free (error);
- g_object_unref (file);
- return FALSE;
-
- }
- g_object_unref (file);
+ return FALSE;
+ }
return TRUE;
}
Modified: trunk/baobab/src/baobab-utils.h
==============================================================================
--- trunk/baobab/src/baobab-utils.h (original)
+++ trunk/baobab/src/baobab-utils.h Thu May 1 14:04:26 2008
@@ -42,7 +42,8 @@
void set_label_scan (baobab_fs *);
void show_label (void);
void open_file_with_application (GFile *file);
-gboolean trash_file (const gchar *filename);
+gboolean can_trash_file (GFile *file);
+gboolean trash_file (GFile *file);
void contents_changed (void);
void set_glade_widget_sens (const gchar *name, gboolean sens);
gchar *baobab_gconf_get_string_with_default (GConfClient *client, const gchar *key, const gchar *def);
Modified: trunk/baobab/src/callbacks.c
==============================================================================
--- trunk/baobab/src/callbacks.c (original)
+++ trunk/baobab/src/callbacks.c Thu May 1 14:04:26 2008
@@ -243,10 +243,19 @@
void
trash_dir_cb (GtkMenuItem *pmenu, gpointer dummy)
{
+ GFile *file;
+
g_assert (!dummy);
g_assert (baobab.selected_path);
- if (trash_file (baobab.selected_path)) {
+ if (baobab.is_local) {
+ file = g_file_new_for_path (baobab.selected_path);
+ }
+ else {
+ file = g_file_new_for_uri (baobab.selected_path);
+ }
+
+ if (trash_file (file)) {
GtkTreeIter iter;
guint64 filesize;
GtkTreeSelection *selection;
@@ -262,6 +271,8 @@
if (baobab.bbEnableHomeMonitor)
contents_changed ();
}
+
+ g_object_unref (file);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]