コード例 #1
0
ファイル: nemo-bookmark-list.c プロジェクト: City-busz/nemo
static NemoBookmark *
new_bookmark_from_uri (const char *uri, const char *label, NemoBookmarkMetadata *md)
{
	NemoBookmark *new_bookmark;
	GFile *location;

	location = NULL;
	if (uri) {
		location = g_file_new_for_uri (uri);
	}
	
	new_bookmark = NULL;

	if (location) {
		new_bookmark = nemo_bookmark_new (location, label, NULL, md);
		g_object_unref (location);
	}

	return new_bookmark;
}
コード例 #2
0
static void
update_bookmark_from_text (void)
{
	if (text_changed) {
		NemoBookmark *bookmark, *bookmark_in_list;
		const char *name;
		GIcon *icon;
		guint selected_row;
		GtkTreeIter iter;
		GFile *location;

		g_assert (GTK_IS_ENTRY (name_field));
		g_assert (GTK_IS_ENTRY (uri_field));

		if (gtk_entry_get_text_length (GTK_ENTRY (uri_field)) == 0) {
			return;
		}

		location = g_file_parse_name 
			(gtk_entry_get_text (GTK_ENTRY (uri_field)));
		
		bookmark = nemo_bookmark_new (location,
						  name_text_changed ? gtk_entry_get_text (GTK_ENTRY (name_field)) : NULL,
						  NULL);
		
		g_object_unref (location);

		selected_row = get_selected_row ();

		/* turn off list updating 'cuz otherwise the list-reordering code runs
		 * after repopulate(), thus reordering the correctly-ordered list.
		 */
		g_signal_handler_block (bookmarks, 
					bookmark_list_changed_signal_id);
		nemo_bookmark_list_delete_item_at (bookmarks, selected_row);
		nemo_bookmark_list_insert_item (bookmarks, bookmark, selected_row);
		g_signal_handler_unblock (bookmarks, 
					  bookmark_list_changed_signal_id);
		g_object_unref (bookmark);

		/* We also have to update the bookmark pointer in the list
		   store. */
		gtk_tree_selection_get_selected (bookmark_selection,
						 NULL, &iter);
		g_signal_handler_block (bookmark_list_store,
					row_changed_signal_id);

		bookmark_in_list = nemo_bookmark_list_item_at (bookmarks,
								   selected_row);

		name = nemo_bookmark_get_name (bookmark_in_list);
		icon = nemo_bookmark_get_icon (bookmark_in_list);

		gtk_list_store_set (bookmark_list_store, &iter,
				    BOOKMARK_LIST_COLUMN_BOOKMARK, bookmark_in_list,
				    BOOKMARK_LIST_COLUMN_NAME, name,
				    BOOKMARK_LIST_COLUMN_ICON, icon,
				    -1);
		g_signal_handler_unblock (bookmark_list_store,
					  row_changed_signal_id);

		g_object_unref (icon);
	}
}