Index: thunar/thunar-location-button.c =================================================================== --- thunar/thunar-location-button.c (revision 21839) +++ thunar/thunar-location-button.c (working copy) @@ -73,6 +73,8 @@ guint time); static void thunar_location_button_file_changed (ThunarLocationButton *location_button, ThunarFile *file); +static void thunar_location_button_file_destroy (ThunarLocationButton *location_button, + ThunarFile *file); static gboolean thunar_location_button_button_press_event (GtkWidget *button, GdkEventButton *event, ThunarLocationButton *location_button); @@ -463,6 +465,20 @@ +static void +thunar_location_button_file_destroy (ThunarLocationButton *location_button, + ThunarFile *file) +{ + g_return_if_fail (THUNAR_IS_LOCATION_BUTTON (location_button)); + g_return_if_fail (location_button->file == file); + g_return_if_fail (THUNAR_IS_FILE (file)); + + /* the file is gone, no need to keep the button around anymore */ + gtk_widget_destroy (GTK_WIDGET (location_button)); +} + + + static gboolean thunar_location_button_button_press_event (GtkWidget *button, GdkEventButton *event, @@ -868,6 +884,7 @@ thunar_file_unwatch (location_button->file); /* disconnect signals and release reference */ + g_signal_handlers_disconnect_by_func (G_OBJECT (location_button->file), thunar_location_button_file_destroy, location_button); g_signal_handlers_disconnect_by_func (G_OBJECT (location_button->file), thunar_location_button_file_changed, location_button); g_object_unref (G_OBJECT (location_button->file)); } @@ -886,6 +903,7 @@ /* stay informed about changes to the file */ g_signal_connect_swapped (G_OBJECT (file), "changed", G_CALLBACK (thunar_location_button_file_changed), location_button); + g_signal_connect_swapped (G_OBJECT (file), "destroy", G_CALLBACK (thunar_location_button_file_destroy), location_button); /* update our internal state for the new file (if realized) */ if (GTK_WIDGET_REALIZED (location_button)) Index: thunar/thunar-location-buttons.c =================================================================== --- thunar/thunar-location-buttons.c (revision 21839) +++ thunar/thunar-location-buttons.c (working copy) @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -91,9 +90,6 @@ 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); @@ -144,8 +140,6 @@ GtkWidget *left_slider; GtkWidget *right_slider; - ThunarFileMonitor *file_monitor; - ThunarFile *current_directory; gint slider_width; @@ -308,10 +302,6 @@ buttons->action_group = gtk_action_group_new ("ThunarLocationButtons"); gtk_action_group_add_actions (buttons->action_group, action_entries, G_N_ELEMENTS (action_entries), buttons); - /* 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); @@ -369,10 +359,6 @@ /* 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)); - /* release our action group */ g_object_unref (G_OBJECT (buttons->action_group)); @@ -925,48 +911,6 @@ -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 (thunar_location_button_get_active (THUNAR_LOCATION_BUTTON (lp->data))) - { - lp = NULL; - break; - } - - /* check if the button is for the destroyed file */ - if (thunar_location_button_get_file (THUNAR_LOCATION_BUTTON (lp->data)) == 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) {