summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog44
-rw-r--r--libnautilus-private/apps_nautilus_preferences.schemas.in15
-rw-r--r--libnautilus-private/nautilus-desktop-link-monitor.c191
-rw-r--r--libnautilus-private/nautilus-desktop-link.c10
-rw-r--r--libnautilus-private/nautilus-desktop-link.h3
-rw-r--r--libnautilus-private/nautilus-global-preferences.h1
-rw-r--r--src/file-manager/fm-icon-container.c12
7 files changed, 200 insertions, 76 deletions
diff --git a/ChangeLog b/ChangeLog
index 0b388d15a..f3c8b6263 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,47 @@
+2005-12-09 Federico Mena Quintero <federico@ximian.com>
+
+ Fixes bug #322957:
+
+ Add a "Network Servers" icon on the desktop, which takes you to network:///
+
+ * libnautilus-private/nautilus-global-preferences.h
+ (NAUTILUS_PREFERENCES_DESKTOP_NETWORK_VISIBLE): New preference
+ name. This determines whether we show the "Network Servers" icon.
+
+ * libnautilus-private/apps_nautilus_preferences.schemas.in: Add a
+ schema for /apps/nautilus/desktop/network_visible; the default is true.
+
+ * libnautilus-private/nautilus-desktop-link.h
+ (NautilusDesktopLinkType): Add a NAUTILUS_DESKTOP_LINK_NETWORK type.
+
+ * libnautilus-private/nautilus-desktop-link.c
+ (nautilus_desktop_link_new): Support NAUTILUS_DESKTOP_LINK_NETWORK.
+
+ * libnautilus-private/nautilus-desktop-link-monitor.c
+ (NautilusDesktopLinkMonitorDetails): Added a network_link field.
+ (nautilus_desktop_link_monitor_delete_link): Don't delete
+ NAUTILUS_DESKTOP_LINK_NETWORK links.
+ (update_link_visibility): New helper function.
+ (desktop_home_visible_changed): Use update_link_visibility(), to
+ avoid duplicated code.
+ (desktop_computer_visible_changed): Likewise.
+ (desktop_trash_visible_changed): Likewise.
+ (desktop_network_visible_changed): New function.
+ (create_link_and_add_preference): New helper function.
+ (nautilus_desktop_link_monitor_init): Use
+ create_link_and_add_preference() to avoid duplicated code. Also,
+ create the network_link.
+ (desktop_link_monitor_finalize): Unref the network_link.
+ (remove_link_and_preference): New helper function.
+ (desktop_link_monitor_finalize): Use remove_link_and_preference()
+ to avoid duplicated code. Also, free the network_link.
+
+ * src/file-manager/fm-icon-container.c (SortCategory): Add a
+ SORT_NETWORK_LINK category right before SORT_MOUNT_LINK, so that
+ the "Network Servers" icon appears before mounts.
+ (get_sort_category): Use SORT_NETWORK_LINK as the category for
+ NAUTILUS_DESKTOP_LINK_NETWORK.
+
2005-12-09 Alexander Larsson <alexl@redhat.com>
* libnautilus-private/nautilus-emblem-utils.c:
diff --git a/libnautilus-private/apps_nautilus_preferences.schemas.in b/libnautilus-private/apps_nautilus_preferences.schemas.in
index 8e0dd807b..a31cee3da 100644
--- a/libnautilus-private/apps_nautilus_preferences.schemas.in
+++ b/libnautilus-private/apps_nautilus_preferences.schemas.in
@@ -810,6 +810,21 @@ most cases, this should be left alone. -->Sans 10</default>
</schema>
<schema>
+ <key>/schemas/apps/nautilus/desktop/network_visible</key>
+ <applyto>/apps/nautilus/desktop/network_visible</applyto>
+ <owner>nautilus</owner>
+ <type>bool</type>
+ <default>true</default>
+ <locale name="C">
+ <short>Network Servers icon visible on the desktop</short>
+ <long>
+ If this is set to true, an icon linking to the Network Servers view
+ will be put on the desktop.
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
<key>/schemas/apps/nautilus/desktop/computer_icon_name</key>
<applyto>/apps/nautilus/desktop/computer_icon_name</applyto>
<owner>nautilus</owner>
diff --git a/libnautilus-private/nautilus-desktop-link-monitor.c b/libnautilus-private/nautilus-desktop-link-monitor.c
index d9ea28b6b..8eae55491 100644
--- a/libnautilus-private/nautilus-desktop-link-monitor.c
+++ b/libnautilus-private/nautilus-desktop-link-monitor.c
@@ -50,6 +50,7 @@ struct NautilusDesktopLinkMonitorDetails {
NautilusDesktopLink *home_link;
NautilusDesktopLink *computer_link;
NautilusDesktopLink *trash_link;
+ NautilusDesktopLink *network_link;
gulong mount_id;
gulong unmount_id;
@@ -149,6 +150,7 @@ nautilus_desktop_link_monitor_delete_link (NautilusDesktopLinkMonitor *monitor,
case NAUTILUS_DESKTOP_LINK_HOME:
case NAUTILUS_DESKTOP_LINK_COMPUTER:
case NAUTILUS_DESKTOP_LINK_TRASH:
+ case NAUTILUS_DESKTOP_LINK_NETWORK:
/* just ignore. We don't allow you to delete these */
break;
default:
@@ -249,6 +251,23 @@ volume_unmounted_callback (GnomeVFSVolumeMonitor *volume_monitor,
}
}
+static void
+update_link_visibility (NautilusDesktopLinkMonitor *monitor,
+ NautilusDesktopLink **link_ref,
+ NautilusDesktopLinkType link_type,
+ const char *preference_key)
+{
+ if (eel_preferences_get_boolean (preference_key)) {
+ if (*link_ref == NULL) {
+ *link_ref = nautilus_desktop_link_new (link_type);
+ }
+ } else {
+ if (*link_ref != NULL) {
+ g_object_unref (*link_ref);
+ *link_ref = NULL;
+ }
+ }
+}
static void
desktop_home_visible_changed (gpointer callback_data)
@@ -257,16 +276,10 @@ desktop_home_visible_changed (gpointer callback_data)
monitor = NAUTILUS_DESKTOP_LINK_MONITOR (callback_data);
- if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_DESKTOP_HOME_VISIBLE)) {
- if (monitor->details->home_link == NULL) {
- monitor->details->home_link = nautilus_desktop_link_new (NAUTILUS_DESKTOP_LINK_HOME);
- }
- } else {
- if (monitor->details->home_link != NULL) {
- g_object_unref (monitor->details->home_link);
- monitor->details->home_link = NULL;
- }
- }
+ update_link_visibility (NAUTILUS_DESKTOP_LINK_MONITOR (monitor),
+ &monitor->details->home_link,
+ NAUTILUS_DESKTOP_LINK_HOME,
+ NAUTILUS_PREFERENCES_DESKTOP_HOME_VISIBLE);
}
static void
@@ -276,16 +289,10 @@ desktop_computer_visible_changed (gpointer callback_data)
monitor = NAUTILUS_DESKTOP_LINK_MONITOR (callback_data);
- if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_DESKTOP_COMPUTER_VISIBLE)) {
- if (monitor->details->computer_link == NULL) {
- monitor->details->computer_link = nautilus_desktop_link_new (NAUTILUS_DESKTOP_LINK_COMPUTER);
- }
- } else {
- if (monitor->details->computer_link != NULL) {
- g_object_unref (monitor->details->computer_link);
- monitor->details->computer_link = NULL;
- }
- }
+ update_link_visibility (NAUTILUS_DESKTOP_LINK_MONITOR (callback_data),
+ &monitor->details->computer_link,
+ NAUTILUS_DESKTOP_LINK_COMPUTER,
+ NAUTILUS_PREFERENCES_DESKTOP_COMPUTER_VISIBLE);
}
static void
@@ -295,16 +302,23 @@ desktop_trash_visible_changed (gpointer callback_data)
monitor = NAUTILUS_DESKTOP_LINK_MONITOR (callback_data);
- if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_DESKTOP_TRASH_VISIBLE)) {
- if (monitor->details->trash_link == NULL) {
- monitor->details->trash_link = nautilus_desktop_link_new (NAUTILUS_DESKTOP_LINK_TRASH);
- }
- } else {
- if (monitor->details->trash_link != NULL) {
- g_object_unref (monitor->details->trash_link);
- monitor->details->trash_link = NULL;
- }
- }
+ update_link_visibility (NAUTILUS_DESKTOP_LINK_MONITOR (callback_data),
+ &monitor->details->trash_link,
+ NAUTILUS_DESKTOP_LINK_TRASH,
+ NAUTILUS_PREFERENCES_DESKTOP_TRASH_VISIBLE);
+}
+
+static void
+desktop_network_visible_changed (gpointer callback_data)
+{
+ NautilusDesktopLinkMonitor *monitor;
+
+ monitor = NAUTILUS_DESKTOP_LINK_MONITOR (callback_data);
+
+ update_link_visibility (NAUTILUS_DESKTOP_LINK_MONITOR (callback_data),
+ &monitor->details->network_link,
+ NAUTILUS_DESKTOP_LINK_NETWORK,
+ NAUTILUS_PREFERENCES_DESKTOP_NETWORK_VISIBLE);
}
static void
@@ -334,6 +348,20 @@ desktop_volumes_visible_changed (gpointer callback_data)
}
static void
+create_link_and_add_preference (NautilusDesktopLink **link_ref,
+ NautilusDesktopLinkType link_type,
+ const char *preference_key,
+ EelPreferencesCallback callback,
+ gpointer callback_data)
+{
+ if (eel_preferences_get_boolean (preference_key)) {
+ *link_ref = nautilus_desktop_link_new (link_type);
+ }
+
+ eel_preferences_add_callback (preference_key, callback, callback_data);
+}
+
+static void
nautilus_desktop_link_monitor_init (gpointer object, gpointer klass)
{
NautilusDesktopLinkMonitor *monitor;
@@ -350,17 +378,33 @@ nautilus_desktop_link_monitor_init (gpointer object, gpointer klass)
/* We keep around a ref to the desktop dir */
monitor->details->desktop_dir = nautilus_directory_get (EEL_DESKTOP_URI);
- if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_DESKTOP_HOME_VISIBLE)) {
- monitor->details->home_link = nautilus_desktop_link_new (NAUTILUS_DESKTOP_LINK_HOME);
- }
-
- if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_DESKTOP_COMPUTER_VISIBLE)) {
- monitor->details->computer_link = nautilus_desktop_link_new (NAUTILUS_DESKTOP_LINK_COMPUTER);
- }
+ /* Default links */
+
+ create_link_and_add_preference (&monitor->details->home_link,
+ NAUTILUS_DESKTOP_LINK_HOME,
+ NAUTILUS_PREFERENCES_DESKTOP_HOME_VISIBLE,
+ desktop_home_visible_changed,
+ monitor);
+
+ create_link_and_add_preference (&monitor->details->computer_link,
+ NAUTILUS_DESKTOP_LINK_COMPUTER,
+ NAUTILUS_PREFERENCES_DESKTOP_COMPUTER_VISIBLE,
+ desktop_computer_visible_changed,
+ monitor);
- if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_DESKTOP_TRASH_VISIBLE)) {
- monitor->details->trash_link = nautilus_desktop_link_new (NAUTILUS_DESKTOP_LINK_TRASH);
- }
+ create_link_and_add_preference (&monitor->details->trash_link,
+ NAUTILUS_DESKTOP_LINK_TRASH,
+ NAUTILUS_PREFERENCES_DESKTOP_TRASH_VISIBLE,
+ desktop_trash_visible_changed,
+ monitor);
+
+ create_link_and_add_preference (&monitor->details->network_link,
+ NAUTILUS_DESKTOP_LINK_NETWORK,
+ NAUTILUS_PREFERENCES_DESKTOP_NETWORK_VISIBLE,
+ desktop_network_visible_changed,
+ monitor);
+
+ /* Volume links */
volume_monitor = gnome_vfs_get_volume_monitor ();
@@ -372,15 +416,6 @@ nautilus_desktop_link_monitor_init (gpointer object, gpointer klass)
}
g_list_free (volumes);
- eel_preferences_add_callback (NAUTILUS_PREFERENCES_DESKTOP_HOME_VISIBLE,
- desktop_home_visible_changed,
- monitor);
- eel_preferences_add_callback (NAUTILUS_PREFERENCES_DESKTOP_COMPUTER_VISIBLE,
- desktop_computer_visible_changed,
- monitor);
- eel_preferences_add_callback (NAUTILUS_PREFERENCES_DESKTOP_TRASH_VISIBLE,
- desktop_trash_visible_changed,
- monitor);
eel_preferences_add_callback (NAUTILUS_PREFERENCES_DESKTOP_VOLUMES_VISIBLE,
desktop_volumes_visible_changed,
monitor);
@@ -390,7 +425,21 @@ nautilus_desktop_link_monitor_init (gpointer object, gpointer klass)
monitor->details->unmount_id = g_signal_connect_object (volume_monitor, "volume_unmounted",
G_CALLBACK (volume_unmounted_callback), monitor, 0);
-}
+}
+
+static void
+remove_link_and_preference (NautilusDesktopLink **link_ref,
+ const char *preference_key,
+ EelPreferencesCallback callback,
+ gpointer callback_data)
+{
+ if (*link_ref != NULL) {
+ g_object_unref (*link_ref);
+ *link_ref = NULL;
+ }
+
+ eel_preferences_remove_callback (preference_key, callback, callback_data);
+}
static void
desktop_link_monitor_finalize (GObject *object)
@@ -399,20 +448,29 @@ desktop_link_monitor_finalize (GObject *object)
monitor = NAUTILUS_DESKTOP_LINK_MONITOR (object);
- if (monitor->details->home_link != NULL) {
- g_object_unref (monitor->details->home_link);
- monitor->details->home_link = NULL;
- }
+ /* Default links */
- if (monitor->details->computer_link != NULL) {
- g_object_unref (monitor->details->computer_link);
- monitor->details->computer_link = NULL;
- }
+ remove_link_and_preference (&monitor->details->home_link,
+ NAUTILUS_PREFERENCES_DESKTOP_HOME_VISIBLE,
+ desktop_home_visible_changed,
+ monitor);
- if (monitor->details->trash_link != NULL) {
- g_object_unref (monitor->details->trash_link);
- monitor->details->trash_link = NULL;
- }
+ remove_link_and_preference (&monitor->details->computer_link,
+ NAUTILUS_PREFERENCES_DESKTOP_COMPUTER_VISIBLE,
+ desktop_computer_visible_changed,
+ monitor);
+
+ remove_link_and_preference (&monitor->details->trash_link,
+ NAUTILUS_PREFERENCES_DESKTOP_TRASH_VISIBLE,
+ desktop_trash_visible_changed,
+ monitor);
+
+ remove_link_and_preference (&monitor->details->network_link,
+ NAUTILUS_PREFERENCES_DESKTOP_NETWORK_VISIBLE,
+ desktop_network_visible_changed,
+ monitor);
+
+ /* Volumes */
g_list_foreach (monitor->details->volume_links, (GFunc)g_object_unref, NULL);
g_list_free (monitor->details->volume_links);
@@ -421,15 +479,6 @@ desktop_link_monitor_finalize (GObject *object)
nautilus_directory_unref (monitor->details->desktop_dir);
monitor->details->desktop_dir = NULL;
- eel_preferences_remove_callback (NAUTILUS_PREFERENCES_DESKTOP_HOME_VISIBLE,
- desktop_home_visible_changed,
- monitor);
- eel_preferences_remove_callback (NAUTILUS_PREFERENCES_DESKTOP_COMPUTER_VISIBLE,
- desktop_computer_visible_changed,
- monitor);
- eel_preferences_remove_callback (NAUTILUS_PREFERENCES_DESKTOP_TRASH_VISIBLE,
- desktop_trash_visible_changed,
- monitor);
eel_preferences_remove_callback (NAUTILUS_PREFERENCES_DESKTOP_VOLUMES_VISIBLE,
desktop_volumes_visible_changed,
monitor);
diff --git a/libnautilus-private/nautilus-desktop-link.c b/libnautilus-private/nautilus-desktop-link.c
index d0ddd7683..458103d85 100644
--- a/libnautilus-private/nautilus-desktop-link.c
+++ b/libnautilus-private/nautilus-desktop-link.c
@@ -174,6 +174,14 @@ nautilus_desktop_link_new (NautilusDesktopLinkType type)
g_signal_connect_object (nautilus_trash_monitor_get (), "trash_state_changed",
G_CALLBACK (trash_state_changed_callback), link, 0);
break;
+
+ case NAUTILUS_DESKTOP_LINK_NETWORK:
+ link->details->filename = g_strdup ("network");
+ link->details->display_name = _("Network Servers");
+ link->details->activation_uri = g_strdup ("network:///");
+ link->details->icon = g_strdup ("gnome-fs-network");
+ break;
+
default:
case NAUTILUS_DESKTOP_LINK_VOLUME:
g_assert_not_reached();
@@ -379,7 +387,7 @@ desktop_link_finalize (GObject *object)
trash_name_changed,
link);
}
-
+
if (link->details->type == NAUTILUS_DESKTOP_LINK_VOLUME) {
gnome_vfs_volume_unref (link->details->volume);
}
diff --git a/libnautilus-private/nautilus-desktop-link.h b/libnautilus-private/nautilus-desktop-link.h
index fd55bae01..578e592a2 100644
--- a/libnautilus-private/nautilus-desktop-link.h
+++ b/libnautilus-private/nautilus-desktop-link.h
@@ -54,7 +54,8 @@ typedef enum {
NAUTILUS_DESKTOP_LINK_HOME,
NAUTILUS_DESKTOP_LINK_COMPUTER,
NAUTILUS_DESKTOP_LINK_TRASH,
- NAUTILUS_DESKTOP_LINK_VOLUME
+ NAUTILUS_DESKTOP_LINK_VOLUME,
+ NAUTILUS_DESKTOP_LINK_NETWORK
} NautilusDesktopLinkType;
GType nautilus_desktop_link_get_type (void);
diff --git a/libnautilus-private/nautilus-global-preferences.h b/libnautilus-private/nautilus-global-preferences.h
index 14611e71d..dc2704ed8 100644
--- a/libnautilus-private/nautilus-global-preferences.h
+++ b/libnautilus-private/nautilus-global-preferences.h
@@ -182,6 +182,7 @@ typedef enum
#define NAUTILUS_PREFERENCES_DESKTOP_TRASH_VISIBLE "desktop/trash_icon_visible"
#define NAUTILUS_PREFERENCES_DESKTOP_TRASH_NAME "desktop/trash_icon_name"
#define NAUTILUS_PREFERENCES_DESKTOP_VOLUMES_VISIBLE "desktop/volumes_visible"
+#define NAUTILUS_PREFERENCES_DESKTOP_NETWORK_VISIBLE "desktop/network_visible"
void nautilus_global_preferences_init (void);
char *nautilus_global_preferences_get_default_folder_viewer_preference_as_iid (void);
diff --git a/src/file-manager/fm-icon-container.c b/src/file-manager/fm-icon-container.c
index 6650a75b6..c6edf0233 100644
--- a/src/file-manager/fm-icon-container.c
+++ b/src/file-manager/fm-icon-container.c
@@ -337,14 +337,17 @@ fm_icon_container_get_icon_text (NautilusIconContainer *container,
}
/* Sort as follows:
+ * 0) computer link
* 1) home link
- * 2) mount links
- * 3) other
- * 4) trash link
+ * 2) network link
+ * 3) mount links
+ * 4) other
+ * 5) trash link
*/
typedef enum {
SORT_COMPUTER_LINK,
SORT_HOME_LINK,
+ SORT_NETWORK_LINK,
SORT_MOUNT_LINK,
SORT_OTHER,
SORT_TRASH_LINK
@@ -374,6 +377,9 @@ get_sort_category (NautilusFile *file)
case NAUTILUS_DESKTOP_LINK_TRASH:
category = SORT_TRASH_LINK;
break;
+ case NAUTILUS_DESKTOP_LINK_NETWORK:
+ category = SORT_NETWORK_LINK;
+ break;
default:
category = SORT_OTHER;
break;