Example #1
0
void
gth_browser_activate_action_bookmarks_add (GtkAction  *action,
					   GthBrowser *browser)
{
	GBookmarkFile *bookmarks;
	GFile         *location;
	char          *uri;

	location = gth_browser_get_location (browser);
	if (location == NULL)
		return;

	bookmarks = gth_main_get_default_bookmarks ();
	uri = g_file_get_uri (location);
	_g_bookmark_file_add_uri (bookmarks, uri);
	gth_main_bookmarks_changed ();

	g_free (uri);
}
Example #2
0
static void
_gth_browser_update_bookmark_list (GthBrowser *browser)
{
    BrowserData    *data;
    GBookmarkFile  *bookmarks;
    char          **uris;
    int             i;

    data = g_object_get_data (G_OBJECT (browser), BROWSER_DATA_KEY);
    g_return_if_fail (data != NULL);

    g_menu_remove_all (data->bookmarks_menu);

    bookmarks = gth_main_get_default_bookmarks ();
    uris = g_bookmark_file_get_uris (bookmarks, NULL);

    for (i = 0; uris[i] != NULL; i++) {
        GFile     *file;
        char      *name;
        GMenuItem *item;

        file = g_file_new_for_uri (uris[i]);
        name = g_bookmark_file_get_title (bookmarks, uris[i], NULL);
        item = _g_menu_item_new_for_file (file, name);
        g_menu_item_set_action_and_target (item, "win.go-to-location", "s", uris[i]);
        g_menu_append_item (data->bookmarks_menu, item);

        g_object_unref (item);
        g_free (name);
        g_object_unref (file);
    }

    _gth_browser_update_system_bookmark_list (browser);

    g_strfreev (uris);
}