NetSurf
Functions
resources.h File Reference

Interface to gtk builtin resource handling. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

nserror nsgtk_init_resources (char **respath)
 Initialise GTK resources handling. More...
 
GdkCursor * nsgtk_create_menu_cursor (void)
 Creates a menu cursor from internal resources. More...
 
nserror nsgtk_builder_new_from_resname (const char *resname, GtkBuilder **builder_out)
 Create gtk builder object for the named ui resource. More...
 
nserror nsgdk_pixbuf_new_from_resname (const char *resname, GdkPixbuf **pixbuf_out)
 Create gdk pixbuf for the named ui resource. More...
 
nserror nsgtk_data_from_resname (const char *resname, const uint8_t **data_out, size_t *data_size_out)
 Get direct pointer to resource data. More...
 
nserror nsgtk_path_from_resname (const char *resname, const char **path_out)
 Get path to resource data. More...
 

Detailed Description

Interface to gtk builtin resource handling.

This presents a unified interface to the rest of the codebase to obtain resources. Note this is not anything to do with the resource scheme handling beyond possibly providing the underlying data.

Definition in file resources.h.

Function Documentation

◆ nsgdk_pixbuf_new_from_resname()

nserror nsgdk_pixbuf_new_from_resname ( const char *  resname,
GdkPixbuf **  pixbuf_out 
)

Create gdk pixbuf for the named ui resource.

This creates a pixbuf using an identifier name which is mapped to the ui_resource table which must be initialised with nsgtk_init_resources()

Parameters
resnameThe resource name to construct for
pixbuf_outThe pixbuf result
Returns
NSERROR_OK and pixbuf_out updated or appropriate error code

Definition at line 470 of file resources.c.

References find_resource_from_name(), nsgtk_resource_s::name, NSERROR_INIT_FAILED, NSERROR_NOT_FOUND, NSERROR_OK, NSGTK_RESOURCE_DIRECT, NSGTK_RESOURCE_FILE, NSGTK_RESOURCE_GLIB, NSGTK_RESOURCE_INLINE, NSLOG, nsgtk_resource_s::path, pixbuf_resource, and nsgtk_resource_s::type.

Referenced by add_builtin_icon(), nsgtk_create_menu_cursor(), nsgtk_setup(), and nsgtk_throbber_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nsgtk_builder_new_from_resname()

nserror nsgtk_builder_new_from_resname ( const char *  resname,
GtkBuilder **  builder_out 
)

Create gtk builder object for the named ui resource.

Creating gtk builder objects from a named resource requires the source xml resource to be parsed.

This creates a gtk builder instance using an identifier name which is mapped to the ui_resource table which must be initialised with nsgtk_init_resources()

Parameters
resnameThe resource name to construct for
builder_outThe builder result
Returns
NSERROR_OK and builder_out updated or appropriate error code

Definition at line 526 of file resources.c.

References find_resource_from_name(), nsgtk_resource_s::name, NSERROR_INIT_FAILED, NSERROR_NOT_FOUND, NSERROR_OK, nsgtk_builder_add_from_resource(), NSGTK_RESOURCE_FILE, NSLOG, nsgtk_resource_s::path, nsgtk_resource_s::type, and ui_resource.

Referenced by cutomize_button_clicked_cb(), gui_window_create(), nsgtk_cookies_init(), nsgtk_download_init(), nsgtk_global_history_init(), nsgtk_hotlist_init(), nsgtk_local_history_init(), nsgtk_new_scaffolding(), nsgtk_page_info(), nsgtk_pdf_password(), nsgtk_preferences(), nsgtk_setup(), and window_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nsgtk_create_menu_cursor()

GdkCursor * nsgtk_create_menu_cursor ( void  )

Creates a menu cursor from internal resources.

Returns
Cursor object or NULL on error.

Definition at line 148 of file resources.c.

References NSERROR_OK, and nsgdk_pixbuf_new_from_resname().

Referenced by gui_window_set_pointer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nsgtk_data_from_resname()

nserror nsgtk_data_from_resname ( const char *  resname,
const uint8_t **  data_out,
size_t *  data_size_out 
)

Get direct pointer to resource data.

For a named resource this obtains a direct acesss pointer to the data and its length.

The data is read only through this pointer and remains valid until program exit.

Parameters
resnameThe resource name to obtain data for.
data_outThe resulting data.
data_size_outThe resulting data size.
Returns
NSERROR_OK and data_out updated or appropriate error code.
Todo:
consider adding compiled inline resources for things other than pixbufs.

Definition at line 574 of file resources.c.

References buffer, direct_resource, find_resource_from_name(), nsgtk_resource_s::name, NSERROR_NOMEM, NSERROR_NOT_FOUND, NSERROR_OK, NSGTK_RESOURCE_DIRECT, nsgtk_resource_s::path, and nsgtk_resource_s::type.

Referenced by nsgtk_accelerator_init(), nsgtk_messages_init(), and nsgtk_preferences_comboboxLanguage_realize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nsgtk_init_resources()

nserror nsgtk_init_resources ( char **  respath)

Initialise GTK resources handling.

Must be called before attempting to retrieve any resources but after logging is initialised as it logs.

Parameters
respathA string vector of paths to search for resources.
Returns
NSERROR_OK if all resources were located else an appropriate error code.

Initialise GTK resources handling.

Definition at line 425 of file resources.c.

References direct_resource, init_direct_resource(), init_pixbuf_resource(), init_ui_resource(), nsgtk_resource_s::name, NSERROR_OK, pixbuf_resource, and ui_resource.

Referenced by nsgtk_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nsgtk_path_from_resname()

nserror nsgtk_path_from_resname ( const char *  resname,
const char **  path_out 
)

Get path to resource data.

For a named resource this obtains the on-disc path to that resource.

The path is read only and remains valid untill program exit.

Parameters
resnameThe resource name to obtain path for.
path_outThe resulting data.
Returns
NSERROR_OK and path_out updated or appropriate error code.

Definition at line 613 of file resources.c.

References direct_resource, find_resource_from_name(), nsgtk_resource_s::name, NSERROR_NOT_FOUND, NSERROR_OK, NSGTK_RESOURCE_FILE, nsgtk_resource_s::path, and nsgtk_resource_s::type.

Referenced by nsgtk_accelerator_init(), nsgtk_messages_init(), and nsgtk_preferences_comboboxLanguage_realize().

Here is the call graph for this function:
Here is the caller graph for this function: