The attached patch makes Nautilus not display permission emblems and permissions in the properties dialog for locations for locations like "computer:///", "network:///" etc. and also adds a "Computer" properties page. My initial plan was to use libgtop, but it turned out to be not that useful, because for in-depth information you always need other apps like "hal-device-manager". Therefore, I've modified Nautilus to display links to these applications on the "Computer" page. The "hal-device-manager" desktop file is in the capplet directory, and therefore requires a GnomeVFS API addition. -- Christian Neumair <chris gnome-de org>
Index: libnautilus-private/nautilus-file.c =================================================================== RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-file.c,v retrieving revision 1.374 diff -u -p -r1.374 nautilus-file.c --- libnautilus-private/nautilus-file.c 20 Oct 2005 15:22:12 -0000 1.374 +++ libnautilus-private/nautilus-file.c 19 Nov 2005 11:08:01 -0000 @@ -1921,11 +1921,13 @@ prepend_automatic_emblem_names (Nautilus names = g_list_prepend (names, g_strdup (NAUTILUS_FILE_EMBLEM_NAME_NOTE)); } - if (!nautilus_file_can_write (file)) { + if (nautilus_file_should_show_permissions (file) && + !nautilus_file_can_write (file)) { names = g_list_prepend (names, g_strdup (NAUTILUS_FILE_EMBLEM_NAME_CANT_WRITE)); } - if (!nautilus_file_can_read (file)) { + if (nautilus_file_should_show_permissions (file) && + !nautilus_file_can_read (file)) { names = g_list_prepend (names, g_strdup (NAUTILUS_FILE_EMBLEM_NAME_CANT_READ)); } @@ -3219,6 +3221,26 @@ nautilus_file_should_show_type (Nautilus ret = ((strcmp (uri, "computer:///") != 0) && (strcmp (uri, "network:///") != 0) && (strcmp (uri, "smb:///") != 0)); + g_free (uri); + + return ret; +} + +gboolean +nautilus_file_should_show_permissions (NautilusFile *file) +{ + char *uri; + gboolean ret; + + g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE); + + uri = nautilus_file_get_uri (file); + ret = ((strcmp (uri, "computer:///") != 0) && + (strcmp (uri, "network:///") != 0) && + (strcmp (uri, "smb:///") != 0) && + (strcmp (uri, "trash:///") != 0) && + (strcmp (uri, "themes:///") != 0) && + (strcmp (uri, "fonts:///") != 0)); g_free (uri); return ret; Index: libnautilus-private/nautilus-file.h =================================================================== RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-file.h,v retrieving revision 1.108 diff -u -p -r1.108 nautilus-file.h --- libnautilus-private/nautilus-file.h 20 Oct 2005 15:22:12 -0000 1.108 +++ libnautilus-private/nautilus-file.h 19 Nov 2005 11:08:01 -0000 @@ -168,6 +170,7 @@ NautilusRequestStatus nautilus_file_ge gboolean force); gboolean nautilus_file_should_show_directory_item_count (NautilusFile *file); gboolean nautilus_file_should_show_type (NautilusFile *file); +gboolean nautilus_file_should_show_permissions (NautilusFile *file); GList * nautilus_file_get_keywords (NautilusFile *file); void nautilus_file_set_keywords (NautilusFile *file, GList *keywords); Index: libnautilus-private/nautilus-program-choosing.c =================================================================== RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-program-choosing.c,v retrieving revision 1.80 diff -u -p -r1.80 nautilus-program-choosing.c --- libnautilus-private/nautilus-program-choosing.c 20 Oct 2005 15:30:42 -0000 1.80 +++ libnautilus-private/nautilus-program-choosing.c 19 Nov 2005 11:08:01 -0000 @@ -685,11 +695,11 @@ nautilus_launch_application (GnomeVFSMim #endif uri = NULL; - if (nautilus_file_is_nautilus_link (file)) { + if (file != NULL && nautilus_file_is_nautilus_link (file)) { uri = nautilus_file_get_activation_uri (file); } - if (uri == NULL) { + if (file != NULL && uri == NULL) { uri = nautilus_file_get_uri (file); } @@ -711,26 +721,34 @@ nautilus_launch_application (GnomeVFSMim { char *name; char *icon; + char *description; sn_context = sn_launcher_context_new (sn_display, screen ? gdk_screen_get_number (screen) : DefaultScreen (gdk_display)); - - name = nautilus_file_get_display_name (file); + + name = NULL; + if (file != NULL) { + name = nautilus_file_get_display_name (file); + description = g_strdup_printf (_("Opening %s"), name); + } else { + name = g_strdup (gnome_vfs_mime_application_get_name (application)); + description = g_strdup_printf (_("Launching %s"), name); + } + if (name != NULL) { - char *description; - sn_launcher_context_set_name (sn_context, name); - - description = g_strdup_printf (_("Opening %s"), name); - sn_launcher_context_set_description (sn_context, description); g_free (name); g_free (description); } - icon = nautilus_icon_factory_get_icon_for_file (file, FALSE); + icon = NULL; + if (file != NULL) { + icon = nautilus_icon_factory_get_icon_for_file (file, FALSE); + } + if (icon != NULL) { sn_launcher_context_set_icon_name (sn_context, icon); g_free (icon); @@ -784,7 +802,11 @@ nautilus_launch_application (GnomeVFSMim break; case GNOME_VFS_ERROR_NOT_SUPPORTED: - uri_scheme = nautilus_file_get_uri_scheme (file); + uri_scheme = NULL; + if (file != NULL) { + uri_scheme = nautilus_file_get_uri_scheme (file); + } + application_cannot_open_location (application, file, uri_scheme, Index: src/file-manager/fm-properties-window.c =================================================================== RCS file: /cvs/gnome/nautilus/src/file-manager/fm-properties-window.c,v retrieving revision 1.221 diff -u -p -r1.221 fm-properties-window.c --- src/file-manager/fm-properties-window.c 14 Nov 2005 15:10:50 -0000 1.221 +++ src/file-manager/fm-properties-window.c 19 Nov 2005 11:08:05 -0000 @@ -78,6 +78,7 @@ #include <libnautilus-private/nautilus-undo-signal-handlers.h> #include <libnautilus-private/nautilus-mime-actions.h> #include <libnautilus-private/nautilus-undo.h> +#include <libnautilus-private/nautilus-program-choosing.h> #include <string.h> #define PREVIEW_IMAGE_WIDTH 96 @@ -420,16 +421,17 @@ get_pixbuf_for_properties_window (FMProp static void -update_properties_window_icon (GtkImage *image) +update_properties_window_icon (FMPropertiesWindow *window) { - GdkPixbuf *pixbuf; - FMPropertiesWindow *window; + GdkPixbuf *pixbuf; + + g_assert (FM_IS_PROPERTIES_WINDOW (window)); - window = g_object_get_data (G_OBJECT (image), "properties_window"); - pixbuf = get_pixbuf_for_properties_window (window); - gtk_image_set_from_pixbuf (image, pixbuf); + if (window->details->icon_image != NULL) { + gtk_image_set_from_pixbuf (GTK_IMAGE (window->details->icon_image), pixbuf); + } gtk_window_set_icon (GTK_WINDOW (window), pixbuf); @@ -576,7 +578,7 @@ create_image_widget (FMPropertiesWindow g_signal_connect_object (nautilus_icon_factory_get (), "icons_changed", G_CALLBACK (update_properties_window_icon), - image, G_CONNECT_SWAPPED); + window, G_CONNECT_SWAPPED); window->details->icon_image = image; window->details->icon_button = button; @@ -1186,9 +1188,11 @@ properties_window_update (FMPropertiesWi if (dirty_original) { update_properties_window_title (window); - update_properties_window_icon (GTK_IMAGE (window->details->icon_image)); + update_properties_window_icon (window); - update_name_field (window); + if (window->details->name_field != NULL) { + update_name_field (window); + } for (l = window->details->emblem_buttons; l != NULL; l = l->next) { emblem_button_update (window, GTK_TOGGLE_BUTTON (l->data)); @@ -2221,7 +2225,8 @@ should_show_file_type (FMPropertiesWindo { /* The trash on the desktop is one-of-a-kind */ if (!is_multi_file_window (window) - && is_merged_trash_directory (get_target_file (window))) { + && (is_merged_trash_directory (get_target_file (window)) + || !nautilus_file_should_show_type (get_target_file (window)))) { return FALSE; } @@ -2398,6 +2403,80 @@ create_basic_page (FMPropertiesWindow *w } } +static void +desktop_launch_button_clicked (GtkButton *button, + GnomeVFSMimeApplication *app) +{ + nautilus_launch_application (app, NULL, GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (button)))); +} + +static GtkWidget * +create_desktop_launch_button (const char *label, + const char *desktop_file_or_id) +{ + GnomeVFSMimeApplication *app; + GtkWidget *button; + GtkWidget *image; + GdkPixbuf *pixbuf; + + button = gtk_button_new_with_mnemonic (label); + +#if GNOME_VFS_API_IN_PLACE + app = gnome_vfs_mime_application_new_from_desktop_file (desktop_file_or_id); +#else + app = NULL; +#endif + + if (app == NULL) { + app = gnome_vfs_mime_application_new_from_desktop_id (desktop_file_or_id); + } + + if (app != NULL) { + pixbuf = nautilus_icon_factory_get_pixbuf_from_name_with_stock_size + (gnome_vfs_mime_application_get_icon (app), + NULL, GTK_ICON_SIZE_BUTTON, NULL); + if (pixbuf != NULL) { + image = gtk_image_new_from_pixbuf (pixbuf); + gtk_button_set_image (GTK_BUTTON (button), image); + gdk_pixbuf_unref (pixbuf); + } + + g_object_set_data_full (G_OBJECT (button), "Nautilus::GnomeVFSMimeApplication", + app, (GDestroyNotify) gnome_vfs_mime_application_free); + g_signal_connect (button, "clicked", + G_CALLBACK (desktop_launch_button_clicked), app); + } + + gtk_widget_set_sensitive (button, app != NULL); + + return button; +} + +static void +create_computer_page (FMPropertiesWindow *window) +{ + GtkWidget *vbox; + GtkWidget *button; + + vbox = create_page_with_vbox (window->details->notebook, + _("Computer")); + gtk_box_set_spacing (GTK_BOX (vbox), 6); + + button = create_desktop_launch_button (_("_View System Log"), "gnome-system-log.desktop"); + gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); + gtk_widget_show (GTK_WIDGET (button)); + + button = create_desktop_launch_button (_("_Launch System Monitor"), "gnome-system-monitor.desktop"); + gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); + gtk_widget_show (GTK_WIDGET (button)); + +#if GNOME_VFS_API_IN_PLACE + button = create_desktop_launch_button ("L_aunch Device Manager", DATADIR "/control-center-2.0/capplets/hal-device-manager.desktop"); + gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); + gtk_widget_show (GTK_WIDGET (button)); +#endif +} + static GHashTable * get_initial_emblems (GList *files) { @@ -3146,13 +3225,27 @@ should_show_emblems (FMPropertiesWindow } static gboolean +should_show_computer (FMPropertiesWindow *window) +{ + char *uri; + gboolean ret; + + ret = FALSE; + if (!is_multi_file_window (window)) { + uri = nautilus_file_get_uri (get_target_file (window)); + ret = gnome_vfs_uris_match (uri, "computer:///"); + g_free (uri); + } + + return ret; +} + +static gboolean should_show_permissions (FMPropertiesWindow *window) { - /* Don't show permissions for the Trash since it's not - * really a file system object. - */ if (!is_multi_file_window (window) - && is_merged_trash_directory (get_target_file (window))) { + && (!nautilus_file_can_get_permissions (get_target_file (window)) + || !nautilus_file_should_show_permissions (get_target_file (window)))) { return FALSE; } @@ -3313,6 +3406,7 @@ create_properties_window (StartupData *s /* Set initial window title */ update_properties_window_title (window); + update_properties_window_icon (window); /* Start monitoring the file attributes we display. Note that some * of the attributes are for the original file, and some for the @@ -3379,7 +3473,11 @@ create_properties_window (StartupData *s TRUE, TRUE, 0); /* Create the pages. */ - create_basic_page (window); + if (should_show_computer (window)) { + create_computer_page (window); + } else { + create_basic_page (window); + } if (should_show_emblems (window)) { create_emblems_page (window); @@ -3699,6 +3797,10 @@ real_destroy (GtkObject *object) g_source_remove (window->details->update_files_timeout_id); window->details->update_files_timeout_id = 0; } + + g_signal_handlers_disconnect_by_func (nautilus_icon_factory_get (), + update_properties_window_icon, + window); GTK_OBJECT_CLASS (parent_class)->destroy (object); }
Attachment:
signature.asc
Description: This is a digitally signed message part