Re: [Nautilus-list] Can't write emblems



On Fri, 5 Oct 2001, Darin Adler wrote:

> on 10/5/01 12:35 PM, Alex Larsson at alexl redhat com wrote:
> 
> > Here is a patch that cuts down on the amount of can't write emblems.
> > You only get an emblem for files that you can't write to if you can write
> > to the directory the file is in. It does make the can't write emblem much
> > more useful in my opinion.
> > 
> > I'm not sure this patch is enough, considering the async nature of
> > NautilusFile. Don't i need to somehow update this when the parents
> > permissions are loaded?
> 
> I have three comments here:
> 
> First, when I was thinking of fixing this, I was going to leave out the
> can't write emblems in context in the directory view because they are
> showing as children of the parent directory. When showing the emblems alone,
> or when computing the emblems for "sort as emblem", I was thinking we would
> still include the can't write emblem. So this would be a special case in
> FMDirectoryView, not in NautilusFile. We could have other "relative emblems"
> that show up only when they differ from the parent if we want.

How about this. It seems to work, except changing the permissions of the
directory you're in from outside Nautilus doesn't get caught, due to a 
fam/dnotify bug (dnotify is a piece of crap).

It behaves in a way that makes the writable emblems a lot more useful.

/ Alex

Index: src/file-manager/fm-directory-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-directory-view.c,v
retrieving revision 1.473
diff -u -p -r1.473 fm-directory-view.c
--- src/file-manager/fm-directory-view.c	2001/10/18 23:31:14	1.473
+++ src/file-manager/fm-directory-view.c	2001/10/25 20:02:02
@@ -4807,7 +4807,15 @@ fm_directory_view_activate_files (FMDire
 static void
 file_changed_callback (NautilusFile *file, gpointer callback_data)
 {
-	schedule_update_menus (FM_DIRECTORY_VIEW (callback_data));
+	FMDirectoryView *view = FM_DIRECTORY_VIEW (callback_data);
+	
+	schedule_update_menus (view);
+
+	/* We might have different capabilities, so we need to update
+	   relative icon emblems . (Writeable etc) */
+	EEL_CALL_METHOD
+		(FM_DIRECTORY_VIEW_CLASS, view,
+		 relative_emblems_changed, (view));
 }
 
 /**
@@ -4872,7 +4880,7 @@ load_directory (FMDirectoryView *view,
 	g_list_free (attributes);
 
 	/* If capabilities change, then we need to update the menus
-	 * because of New Folder.
+	 * because of New Folder, and relative emblems.
 	 */
 	attributes = g_list_prepend (NULL, NAUTILUS_FILE_ATTRIBUTE_CAPABILITIES);
 	nautilus_file_monitor_add (view->details->directory_as_file,
@@ -5008,6 +5016,16 @@ real_get_emblem_names_to_exclude (FMDire
 	g_assert (FM_IS_DIRECTORY_VIEW (view));
 
 	return eel_string_list_new_from_string (NAUTILUS_FILE_EMBLEM_NAME_TRASH, TRUE);
+}
+
+void
+fm_directory_view_add_relative_emblems_to_exclude (FMDirectoryView *view,
+						   EelStringList *list)
+{
+	if (!nautilus_file_can_write (view->details->directory_as_file)) {
+		eel_string_list_prepend (list, NAUTILUS_FILE_EMBLEM_NAME_CANT_WRITE);
+		eel_string_list_remove_duplicates (list);
+	}
 }
 
 /**
Index: src/file-manager/fm-directory-view.h
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-directory-view.h,v
retrieving revision 1.122
diff -u -p -r1.122 fm-directory-view.h
--- src/file-manager/fm-directory-view.h	2001/10/18 23:31:14	1.122
+++ src/file-manager/fm-directory-view.h	2001/10/25 20:02:02
@@ -277,6 +277,8 @@ struct FMDirectoryViewClass {
 	void	(* click_policy_changed)	   (FMDirectoryView *view);
 	void	(* smooth_graphics_mode_changed)   (FMDirectoryView *view);
 	void	(* sort_directories_first_changed) (FMDirectoryView *view);
+
+	void	(* relative_emblems_changed)       (FMDirectoryView *view);
 };
 
 /* GtkObject support */
@@ -347,11 +349,13 @@ void                fm_directory_view_qu
 void                fm_directory_view_notify_selection_changed         (FMDirectoryView  *view);
 Bonobo_UIContainer  fm_directory_view_get_bonobo_ui_container          (FMDirectoryView  *view);
 BonoboControl *     fm_directory_view_get_bonobo_control               (FMDirectoryView  *view);
-EelStringList *fm_directory_view_get_emblem_names_to_exclude      (FMDirectoryView  *view);
+EelStringList *     fm_directory_view_get_emblem_names_to_exclude      (FMDirectoryView  *view);
+void                fm_directory_view_add_relative_emblems_to_exclude  (FMDirectoryView  *view,
+									EelStringList    *list);
 NautilusDirectory  *fm_directory_view_get_model                        (FMDirectoryView  *view);
 GtkWindow	   *fm_directory_view_get_containing_window	       (FMDirectoryView  *view);
 NautilusFile       *fm_directory_view_get_directory_as_file            (FMDirectoryView  *view);
-EelBackground *fm_directory_view_get_background                   (FMDirectoryView  *view);
+EelBackground *     fm_directory_view_get_background                   (FMDirectoryView  *view);
 void                fm_directory_view_pop_up_background_context_menu   (FMDirectoryView  *view,
 									GdkEventButton   *event);
 void                fm_directory_view_pop_up_selection_context_menu    (FMDirectoryView  *view,
Index: src/file-manager/fm-icon-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-icon-view.c,v
retrieving revision 1.217
diff -u -p -r1.217 fm-icon-view.c
--- src/file-manager/fm-icon-view.c	2001/10/18 23:31:14	1.217
+++ src/file-manager/fm-icon-view.c	2001/10/25 20:02:02
@@ -1930,6 +1930,8 @@ get_icon_images_callback (NautilusIconCo
 	if (emblem_icons != NULL) {
 		emblems_to_ignore = fm_directory_view_get_emblem_names_to_exclude 
 			(FM_DIRECTORY_VIEW (icon_view));
+		fm_directory_view_add_relative_emblems_to_exclude (FM_DIRECTORY_VIEW (icon_view),
+								   emblems_to_ignore);
 		*emblem_icons = nautilus_icon_factory_get_emblem_icons_for_file (file, emblems_to_ignore);
 		eel_string_list_free (emblems_to_ignore);
 	}
@@ -2128,6 +2130,14 @@ fm_icon_view_smooth_graphics_mode_change
 }
 
 static void
+fm_icon_view_relative_emblems_changed (FMDirectoryView *directory_view)
+{
+	g_assert (FM_IS_ICON_VIEW (directory_view));
+	
+	nautilus_icon_container_request_update_all (get_icon_container (FM_ICON_VIEW (directory_view)));	
+}
+
+static void
 default_sort_order_changed_callback (gpointer callback_data)
 {
 	FMIconView *icon_view;
@@ -2722,6 +2732,7 @@ fm_icon_view_initialize_class (FMIconVie
         fm_directory_view_class->image_display_policy_changed = fm_icon_view_image_display_policy_changed;
         fm_directory_view_class->merge_menus = fm_icon_view_merge_menus;
         fm_directory_view_class->smooth_graphics_mode_changed = fm_icon_view_smooth_graphics_mode_changed;
+        fm_directory_view_class->relative_emblems_changed = fm_icon_view_relative_emblems_changed;
         fm_directory_view_class->sort_directories_first_changed = fm_icon_view_sort_directories_first_changed;
         fm_directory_view_class->start_renaming_item = fm_icon_view_start_renaming_item;
         fm_directory_view_class->text_attribute_names_changed = fm_icon_view_text_attribute_names_changed;
Index: src/file-manager/fm-list-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-list-view.c,v
retrieving revision 1.141
diff -u -p -r1.141 fm-list-view.c
--- src/file-manager/fm-list-view.c	2001/10/18 23:31:14	1.141
+++ src/file-manager/fm-list-view.c	2001/10/25 20:02:02
@@ -138,6 +138,7 @@ static void                 fm_list_view
 static void                 fm_list_view_sort_items                   (FMListView         *list_view,
 								       int                 column,
 								       gboolean            reversed);
+static void                 fm_list_view_relative_emblems_changed     (FMDirectoryView    *directory_view);
 static void                 fm_list_view_update_smooth_graphics_mode  (FMDirectoryView    *directory_view);
 static void                 fm_list_view_update_click_mode            (FMDirectoryView    *view);
 static void                 fm_list_view_embedded_text_policy_changed (FMDirectoryView    *view);
@@ -226,6 +227,7 @@ fm_list_view_initialize_class (gpointer 
         fm_directory_view_class->embedded_text_policy_changed = fm_list_view_embedded_text_policy_changed;
         fm_directory_view_class->image_display_policy_changed = fm_list_view_image_display_policy_changed;
         fm_directory_view_class->smooth_graphics_mode_changed = fm_list_view_update_smooth_graphics_mode;
+        fm_directory_view_class->relative_emblems_changed = fm_list_view_relative_emblems_changed;
         fm_directory_view_class->sort_directories_first_changed = real_sort_directories_first_changed;
 	fm_directory_view_class->remove_file = fm_list_view_remove_file;
 
@@ -975,6 +977,15 @@ fm_list_view_update_smooth_graphics_mode
 }
 
 static void
+fm_list_view_relative_emblems_changed (FMDirectoryView *directory_view)
+{
+	g_assert (FM_IS_LIST_VIEW (directory_view));
+	
+	update_icons (FM_LIST_VIEW (directory_view));
+}
+
+
+static void
 real_sort_directories_first_changed (FMDirectoryView *directory_view)
 {
 	eel_clist_sort (EEL_CLIST (get_list (FM_LIST_VIEW (directory_view))));
@@ -1968,6 +1979,8 @@ fm_list_view_get_emblem_pixbufs_for_file
 
 	emblems_to_ignore =  fm_directory_view_get_emblem_names_to_exclude 
 		(FM_DIRECTORY_VIEW (list_view));
+	fm_directory_view_add_relative_emblems_to_exclude (FM_DIRECTORY_VIEW (list_view),
+							   emblems_to_ignore);
 	emblem_icons = nautilus_icon_factory_get_emblem_icons_for_file (file, emblems_to_ignore);
 	eel_string_list_free (emblems_to_ignore);
 	





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]