Exemplo n.º 1
0
static void
update_bookmarks (NemoWindow *window)
{
        NemoBookmarkList *bookmarks;
	NemoBookmark *bookmark;
	guint bookmark_count;
	guint index;
	GtkUIManager *ui_manager;

	g_assert (NEMO_IS_WINDOW (window));
	g_assert (window->details->bookmarks_merge_id == 0);
	g_assert (window->details->bookmarks_action_group == NULL);

	if (window->details->bookmark_list == NULL) {
		window->details->bookmark_list = nemo_bookmark_list_get_default ();
	}

	bookmarks = window->details->bookmark_list;

	ui_manager = nemo_window_get_ui_manager (NEMO_WINDOW (window));
	
	window->details->bookmarks_merge_id = gtk_ui_manager_new_merge_id (ui_manager);
	window->details->bookmarks_action_group = gtk_action_group_new ("BookmarksGroup");
	g_signal_connect (window->details->bookmarks_action_group, "connect-proxy",
			  G_CALLBACK (connect_proxy_cb), NULL);

	gtk_ui_manager_insert_action_group (ui_manager,
					    window->details->bookmarks_action_group,
					    -1);
	g_object_unref (window->details->bookmarks_action_group);

	/* append new set of bookmarks */
	bookmark_count = nemo_bookmark_list_length (bookmarks);
	for (index = 0; index < bookmark_count; ++index) {
		bookmark = nemo_bookmark_list_item_at (bookmarks, index);

		if (!nemo_bookmark_uri_get_exists (bookmark)) {
			continue;
		}

		nemo_menus_append_bookmark_to_menu
			(NEMO_WINDOW (window),
			 bookmark,
			 MENU_PATH_BOOKMARKS_PLACEHOLDER,
			 "dynamic",
			 index,
			 window->details->bookmarks_action_group,
			 window->details->bookmarks_merge_id,
			 G_CALLBACK (refresh_bookmarks_menu), 
			 show_bogus_bookmark_window);
	}
}
Exemplo n.º 2
0
static void
activate_bookmark_in_menu_item (GtkAction *action, gpointer user_data)
{
	NemoWindowSlot *slot;
        BookmarkHolder *holder;
        GFile *location;

        holder = (BookmarkHolder *)user_data;

	if (!nemo_bookmark_uri_get_exists (holder->bookmark)) {
		holder->failed_callback (holder->window, holder->bookmark);
	} else {
	        location = nemo_bookmark_get_location (holder->bookmark);
		slot = nemo_window_get_active_slot (holder->window);
	        nemo_window_slot_go_to (slot, 
					    location, 
					    nemo_event_should_open_in_new_tab ());
	        g_object_unref (location);
        }
}
Exemplo n.º 3
0
static void
nemo_bookmark_set_icon_to_default (NemoBookmark *bookmark)
{
    gchar *icon_name;

    icon_name = construct_default_icon_from_metadata (bookmark);

    if (!nemo_bookmark_uri_get_exists (bookmark)) {
        DEBUG ("%s: file does not exist, use special icon", nemo_bookmark_get_name (bookmark));

        g_clear_pointer (&icon_name, g_free);

        icon_name = g_strdup (NEMO_ICON_SYMBOLIC_MISSING_BOOKMARK);
    }

    DEBUG ("%s: setting icon to default", nemo_bookmark_get_name (bookmark));

    g_object_set (bookmark,
                  "icon-name", icon_name,
                  NULL);

    g_free (icon_name);
}
Exemplo n.º 4
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 (nemo_bookmark_uri_get_exists (bookmark)) {
        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);
	}

	/* Set icon based on available information. */
	nemo_bookmark_update_icon (bookmark);

	if (bookmark->details->icon_name == 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);
	}
}