Esempio n. 1
0
static void
nemo_bookmark_connect_file (NemoBookmark *bookmark)
{
    if (bookmark->details->file != NULL) {
        DEBUG ("%s: file already connected, returning",
               nemo_bookmark_get_name (bookmark));
        return;
    }

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

        bookmark->details->file = nemo_file_get (bookmark->details->location);
        g_assert (!nemo_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) {
        nemo_bookmark_set_icon_to_default (bookmark);
    }

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

    if (bookmark->details->name == NULL) {
        bookmark->details->name = nemo_compute_title_for_location (bookmark->details->location);
    }
}
Esempio n. 2
0
static void
bookmark_file_changed_callback (NemoFile *file,
				NemoBookmark *bookmark)
{
	GFile *location;

	g_assert (file == bookmark->details->file);

	DEBUG ("%s: file changed", nemo_bookmark_get_name (bookmark));

	location = nemo_file_get_location (file);

	if (!g_file_equal (bookmark->details->location, location) &&
	    !nemo_file_is_in_trash (file)) {
		DEBUG ("%s: file got moved", nemo_bookmark_get_name (bookmark));

		g_object_unref (bookmark->details->location);
		bookmark->details->location = g_object_ref (location);

		g_object_notify_by_pspec (G_OBJECT (bookmark), properties[PROP_LOCATION]);
		g_signal_emit (bookmark, signals[CONTENTS_CHANGED], 0);
	}

	g_object_unref (location);

	if (nemo_file_is_gone (file) ||
	    nemo_file_is_in_trash (file)) {
		/* The file we were monitoring has been trashed, deleted,
		 * or moved in a way that we didn't notice. We should make
		 * a spanking new NemoFile object for this
		 * location so if a new file appears in this place
		 * we will notice. However, we can't immediately do so
		 * because creating a new NemoFile directly as a result
		 * of noticing a file goes away may trigger i/o on that file
		 * again, noticeing it is gone, leading to a loop.
		 * So, the new NemoFile is created when the bookmark
		 * is used again. However, this is not really a problem, as
		 * we don't want to change the icon or anything about the
		 * bookmark just because its not there anymore.
		 */
		DEBUG ("%s: trashed", nemo_bookmark_get_name (bookmark));
		nemo_bookmark_disconnect_file (bookmark);
        nemo_bookmark_set_icon_to_default (bookmark);
	} else {
		nemo_bookmark_update_icon (bookmark);
		bookmark_set_name_from_ready_file (bookmark, file);

        if (metadata_changed (bookmark)) {
            g_signal_emit (bookmark, signals[CONTENTS_CHANGED], 0);
        }
	}
}
Esempio n. 3
0
static void
nemo_bookmark_set_exists (NemoBookmark *bookmark,
                  gboolean exists)
{
    if (bookmark->details->exists == exists) {
        return;
    }

    bookmark->details->exists = exists;
    DEBUG ("%s: setting bookmark to exist: %d\n",
           nemo_bookmark_get_name (bookmark), exists);

    /* refresh icon */
    nemo_bookmark_set_icon_to_default (bookmark);
}