diff --git a/ChangeLog b/ChangeLog index 77ebb830408be295c9e040b4669ce8cfa2ca7c6d..6d7a5490068d67135be4603c4a045599ce7269af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2006-02-14 Benedikt Meurer <benny@xfce.org> + + * thunar/thunar-file.c(thunar_file_get_emblem_names): Use "cant-write" + emblem for non-writable files owned by the user, to make it obvious + why an application will not be able to save the file (unless the + application uses a write to temporary, rename, unlink temporary + procedure). + * thunar/thunar-location-buttons.c(thunar_location_buttons_forall): Do + not include the slider buttons unless include_internals is TRUE. + * thunar/thunar-location-buttons.c: Remove buttons from the path bar + whenever a displayed directory is deleted. Bug #1451. + 2006-02-14 Benedikt Meurer <benny@xfce.org> * thunar-vfs/thunar-vfs-creat-job.c, thunar-vfs/thunar-vfs-info.c, diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c index acd9d0789a681505b1b8fcb7c35e662bb1590c2a..e3ff3bfb531dc413b4e5e4000d5cee7297b92bfe 100644 --- a/thunar/thunar-file.c +++ b/thunar/thunar-file.c @@ -1478,6 +1478,13 @@ thunar_file_get_emblem_names (ThunarFile *file) { emblems = g_list_prepend (emblems, THUNAR_FILE_EMBLEM_NAME_CANT_READ); } + else if (G_UNLIKELY (file->info->uid == effective_user_id && !thunar_file_is_writable (file))) + { + /* we own the file, but we cannot write to it, that's why we mark it as "cant-write", so + * users won't be surprised when opening the file in a text editor, but are unable to save. + */ + emblems = g_list_prepend (emblems, THUNAR_FILE_EMBLEM_NAME_CANT_WRITE); + } return emblems; } diff --git a/thunar/thunar-location-buttons.c b/thunar/thunar-location-buttons.c index 32c90716d5bd85576e65841ed0d83ce5e2cb25f3..d220caba1dd8babbec2a97667ec6bb519ebecad1 100644 --- a/thunar/thunar-location-buttons.c +++ b/thunar/thunar-location-buttons.c @@ -32,6 +32,7 @@ #endif #include <thunar/thunar-dnd.h> +#include <thunar/thunar-file-monitor.h> #include <thunar/thunar-gobject-extensions.h> #include <thunar/thunar-icon-factory.h> #include <thunar/thunar-location-buttons.h> @@ -91,6 +92,9 @@ static GtkWidget *thunar_location_buttons_make_button (ThunarLoca ThunarFile *file); static void thunar_location_buttons_remove_1 (GtkContainer *container, GtkWidget *widget); +static void thunar_location_buttons_file_destroyed (ThunarFileMonitor *file_monitor, + ThunarFile *file, + ThunarLocationButtons *buttons); static gboolean thunar_location_buttons_scroll_timeout (gpointer user_data); static void thunar_location_buttons_scroll_timeout_destroy (gpointer user_data); static void thunar_location_buttons_stop_scrolling (ThunarLocationButtons *buttons); @@ -156,27 +160,29 @@ struct _ThunarLocationButtons { GtkContainer __parent__; - GtkWidget *left_slider; - GtkWidget *right_slider; + GtkWidget *left_slider; + GtkWidget *right_slider; + + ThunarFileMonitor *file_monitor; - ThunarFile *current_directory; + ThunarFile *current_directory; - gint slider_width; - gboolean ignore_click : 1; + gint slider_width; + gboolean ignore_click : 1; - GList *list; - GList *first_scrolled_button; + GList *list; + GList *first_scrolled_button; - gint scroll_timeout_id; + gint scroll_timeout_id; /* enter directories using DnD */ - GtkWidget *enter_button; - gint enter_timeout_id; + GtkWidget *enter_button; + gint enter_timeout_id; /* Drop support for the buttons */ - GList *drop_path_list; - guint drop_data_ready : 1; - guint drop_occurred : 1; + GList *drop_path_list; + guint drop_data_ready : 1; + guint drop_occurred : 1; }; @@ -312,6 +318,10 @@ thunar_location_buttons_init (ThunarLocationButtons *buttons) { GtkWidget *arrow; + /* connect to the file monitor */ + buttons->file_monitor = thunar_file_monitor_get_default (); + g_signal_connect (G_OBJECT (buttons->file_monitor), "file-destroyed", G_CALLBACK (thunar_location_buttons_file_destroyed), buttons); + GTK_WIDGET_SET_FLAGS (buttons, GTK_NO_WINDOW); gtk_widget_set_redraw_on_allocate (GTK_WIDGET (buttons), FALSE); @@ -373,6 +383,10 @@ thunar_location_buttons_finalize (GObject *object) /* release from the current_directory */ thunar_navigator_set_current_directory (THUNAR_NAVIGATOR (buttons), NULL); + /* disconnect from the file monitor */ + g_signal_handlers_disconnect_by_func (G_OBJECT (buttons->file_monitor), thunar_location_buttons_file_destroyed, buttons); + g_object_unref (G_OBJECT (buttons->file_monitor)); + (*G_OBJECT_CLASS (thunar_location_buttons_parent_class)->finalize) (object); } @@ -863,10 +877,10 @@ thunar_location_buttons_forall (GtkContainer *container, (*callback) (child, callback_data); } - if (buttons->left_slider != NULL) + if (buttons->left_slider != NULL && include_internals) (*callback) (buttons->left_slider, callback_data); - if (buttons->right_slider != NULL) + if (buttons->right_slider != NULL && include_internals) (*callback) (buttons->right_slider, callback_data); } @@ -960,6 +974,48 @@ thunar_location_buttons_remove_1 (GtkContainer *container, +static void +thunar_location_buttons_file_destroyed (ThunarFileMonitor *file_monitor, + ThunarFile *file, + ThunarLocationButtons *buttons) +{ + GList *children; + GList *lp; + + g_return_if_fail (THUNAR_IS_FILE (file)); + g_return_if_fail (THUNAR_IS_LOCATION_BUTTONS (buttons)); + g_return_if_fail (THUNAR_IS_FILE_MONITOR (file_monitor)); + + /* check all buttons whether one of them refers to the destroyed file, + * remember the children list is in reversed order. That is, the last + * button displayed in the path bar, is the first entry in the child + * list. + */ + children = gtk_container_get_children (GTK_CONTAINER (buttons)); + for (lp = children; lp != NULL; lp = lp->next) + { + /* stop as soon as we reach the current-directory button */ + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (lp->data))) + { + lp = NULL; + break; + } + + /* check if the button is for the destroyed file */ + if (g_object_get_qdata (G_OBJECT (lp->data), thunar_file_quark) == file) + break; + } + + /* remove all buttons after (and including) the destroyed file */ + for (; lp != NULL; lp = lp->prev) + gtk_widget_destroy (GTK_WIDGET (lp->data)); + + /* release the list of children */ + g_list_free (children); +} + + + static gboolean thunar_location_buttons_scroll_timeout (gpointer user_data) {