NetSurf
resources.h
Go to the documentation of this file.
1/*
2 * Copyright 2006 Daniel Silverstone <dsilvers@digital-scurf.org>
3 *
4 * This file is part of NetSurf, http://www.netsurf-browser.org/
5 *
6 * NetSurf is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * NetSurf is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19/**
20 * \file
21 * Interface to gtk builtin resource handling.
22 *
23 * This presents a unified interface to the rest of the codebase to
24 * obtain resources. Note this is not anything to do with the resource
25 * scheme handling beyond possibly providing the underlying data.
26 *
27 */
28
29#ifndef NETSURF_GTK_RESOURCES_H
30#define NETSURF_GTK_RESOURCES_H 1
31
32/**
33 * Initialise GTK resources handling.
34 *
35 * Must be called before attempting to retrieve any resources but
36 * after logging is initialised as it logs.
37 *
38 * \param respath A string vector of paths to search for resources.
39 * \return NSERROR_OK if all resources were located else an
40 * appropriate error code.
41 */
42nserror nsgtk_init_resources(char **respath);
43
44/**
45 * Creates a menu cursor from internal resources.
46 *
47 * \return Cursor object or NULL on error.
48 */
49GdkCursor *nsgtk_create_menu_cursor(void);
50
51/**
52 * Create gtk builder object for the named ui resource.
53 *
54 * Creating gtk builder objects from a named resource requires the
55 * source xml resource to be parsed.
56 *
57 * This creates a gtk builder instance using an identifier name which
58 * is mapped to the ui_resource table which must be initialised with
59 * nsgtk_init_resources()
60 *
61 * \param resname The resource name to construct for
62 * \param builder_out The builder result
63 * \return NSERROR_OK and builder_out updated or appropriate error code
64 */
65nserror nsgtk_builder_new_from_resname(const char *resname, GtkBuilder **builder_out);
66
67
68/**
69 * Create gdk pixbuf for the named ui resource.
70 *
71 * This creates a pixbuf using an identifier name which is mapped to
72 * the ui_resource table which must be initialised with
73 * nsgtk_init_resources()
74 *
75 * \param resname The resource name to construct for
76 * \param pixbuf_out The pixbuf result
77 * \return NSERROR_OK and pixbuf_out updated or appropriate error code
78 */
79nserror nsgdk_pixbuf_new_from_resname(const char *resname, GdkPixbuf **pixbuf_out);
80
81/**
82 * Get direct pointer to resource data.
83 *
84 * For a named resource this obtains a direct acesss pointer to the
85 * data and its length.
86 *
87 * The data is read only through this pointer and remains valid until
88 * program exit.
89 *
90 * \param resname The resource name to obtain data for.
91 * \param data_out The resulting data.
92 * \param data_size_out The resulting data size.
93 * \return NSERROR_OK and data_out updated or appropriate error code.
94 */
95nserror nsgtk_data_from_resname(const char *resname, const uint8_t **data_out, size_t *data_size_out);
96
97/**
98 * Get path to resource data.
99 *
100 * For a named resource this obtains the on-disc path to that resource.
101 *
102 * The path is read only and remains valid untill program exit.
103 * \param resname The resource name to obtain path for.
104 * \param path_out The resulting data.
105 * \return NSERROR_OK and path_out updated or appropriate error code.
106 */
107nserror nsgtk_path_from_resname(const char *resname, const char **path_out);
108
109#endif
nserror
Enumeration of error codes.
Definition: errors.h:29
GdkCursor * nsgtk_create_menu_cursor(void)
Creates a menu cursor from internal resources.
Definition: resources.c:148
nserror nsgtk_data_from_resname(const char *resname, const uint8_t **data_out, size_t *data_size_out)
Get direct pointer to resource data.
Definition: resources.c:574
nserror nsgtk_init_resources(char **respath)
Initialise GTK resources handling.
Definition: resources.c:425
nserror nsgtk_builder_new_from_resname(const char *resname, GtkBuilder **builder_out)
Create gtk builder object for the named ui resource.
Definition: resources.c:526
nserror nsgdk_pixbuf_new_from_resname(const char *resname, GdkPixbuf **pixbuf_out)
Create gdk pixbuf for the named ui resource.
Definition: resources.c:470
nserror nsgtk_path_from_resname(const char *resname, const char **path_out)
Get path to resource data.
Definition: resources.c:613