/* nautilus_window_slot_update_title:
 * 
 * Re-calculate the slot title.
 * Called when the location or view has changed.
 * @slot: The NautilusWindowSlot in question.
 * 
 */
void
nautilus_window_slot_update_title (NautilusWindowSlot *slot)
{
	NautilusWindow *window;
	char *title;
	gboolean do_sync = FALSE;

	title = nautilus_compute_title_for_location (slot->location);
	window = nautilus_window_slot_get_window (slot);

	if (g_strcmp0 (title, slot->title) != 0) {
		do_sync = TRUE;

		g_free (slot->title);
		slot->title = title;
		title = NULL;
	}

	if (strlen (slot->title) > 0 &&
	    slot->current_location_bookmark != NULL) {
		do_sync = TRUE;
	}

	if (do_sync) {
		nautilus_window_sync_title (window, slot);
	}

	if (title != NULL) {
		g_free (title);
	}
}
static void
nautilus_bookmark_connect_file (NautilusBookmark *bookmark)
{
	if (bookmark->details->file != NULL) {
		DEBUG ("%s: file already connected, returning",
		       nautilus_bookmark_get_name (bookmark));
		return;
	}

	if (bookmark->details->exists) {
		DEBUG ("%s: creating file", nautilus_bookmark_get_name (bookmark));

		bookmark->details->file = nautilus_file_get (bookmark->details->location);
		g_assert (!nautilus_file_is_gone (bookmark->details->file));

		g_signal_connect_object (bookmark->details->file, "changed",
					 G_CALLBACK (bookmark_file_changed_callback), bookmark, 0);
	}

	if (bookmark->details->icon == NULL ||
	    bookmark->details->symbolic_icon == NULL) {
		nautilus_bookmark_set_icon_to_default (bookmark);
	}

	if (bookmark->details->file != NULL &&
	    nautilus_file_check_if_ready (bookmark->details->file, NAUTILUS_FILE_ATTRIBUTE_INFO)) {
		bookmark_set_name_from_ready_file (bookmark, bookmark->details->file);
	}

	if (bookmark->details->name == NULL) {
		bookmark->details->name = nautilus_compute_title_for_location (bookmark->details->location);
	}
}
static NautilusBookmark *
new_bookmark_from_uri (const char *uri, const char *label)
{
	NautilusBookmark *new_bookmark;
	NautilusFile *file;
	char *name;
	GIcon *icon;
	gboolean has_label;
	GFile *location;
	gboolean native;

	location = NULL;
	if (uri) {
		location = g_file_new_for_uri (uri);
	}
	
	has_label = FALSE;
	if (!label) { 
		name = nautilus_compute_title_for_location (location);
	} else {
		name = g_strdup (label);
		has_label = TRUE;
	}

	new_bookmark = NULL;
	
	if (uri) {
		native = g_file_is_native (location);
		file = nautilus_file_get (location);

		icon = NULL;
		if (nautilus_file_check_if_ready (file,
						  NAUTILUS_FILE_ATTRIBUTES_FOR_ICON)) {
			icon = nautilus_file_get_gicon (file, 0);
		}
		nautilus_file_unref (file);
		
		if (icon == NULL) {
			icon = native ? g_themed_icon_new (NAUTILUS_ICON_FOLDER) :
				g_themed_icon_new (NAUTILUS_ICON_FOLDER_REMOTE);
		}

		new_bookmark = nautilus_bookmark_new (location, name, has_label, icon);

		g_object_unref (icon);

	}
	g_free (name);
	g_object_unref (location);
	return new_bookmark;
}