99 static GtkWindow *nsgtk_warning_window;
100 GtkLabel *WarningLabel;
102 NSLOG(netsurf, INFO,
"%s %s", warning, detail ? detail :
"");
105 nsgtk_warning_window = GTK_WINDOW(gtk_builder_get_object(
warning_builder,
"wndWarning"));
109 snprintf(buf,
sizeof(buf),
"%s %s",
messages_get(warning),
110 detail ? detail :
"");
111 buf[
sizeof(buf) - 1] = 0;
113 gtk_label_set_text(WarningLabel, buf);
115 gtk_widget_show_all(GTK_WIDGET(nsgtk_warning_window));
128 switch (key->keyval) {
134 if (key->state & GDK_SHIFT_MASK)
136 else if (key->state & GDK_CONTROL_MASK)
142 if (key->state & GDK_SHIFT_MASK)
144 else if (key->state & GDK_CONTROL_MASK)
157 if (key->state & GDK_CONTROL_MASK)
163 if (key->state & GDK_CONTROL_MASK)
177 if (key->state & GDK_CONTROL_MASK)
184 if (key->state & GDK_CONTROL_MASK)
198 if (key->state & GDK_CONTROL_MASK)
200 return gdk_keyval_to_unicode(key->keyval);
203 if (key->state & GDK_CONTROL_MASK)
205 return gdk_keyval_to_unicode(key->keyval);
208 if (key->state & GDK_CONTROL_MASK)
210 return gdk_keyval_to_unicode(key->keyval);
213 if (key->state & GDK_CONTROL_MASK)
215 return gdk_keyval_to_unicode(key->keyval);
218 if (key->state & GDK_CONTROL_MASK)
220 return gdk_keyval_to_unicode(key->keyval);
224 if (key->state & GDK_CONTROL_MASK)
226 return gdk_keyval_to_unicode(key->keyval);
229 if (key->state & GDK_CONTROL_MASK)
231 return gdk_keyval_to_unicode(key->keyval);
254 return gdk_keyval_to_unicode(key->keyval);
269 int resource_path_len;
270 const gchar *
const *langv;
274 if (config_home != NULL) {
275 resource_path_len = snprintf(NULL, 0,
276 "%s:${NETSURFRES}:%s",
279 resource_path = malloc(resource_path_len + 1);
280 if (resource_path == NULL) {
283 snprintf(resource_path, resource_path_len + 1,
284 "%s:${NETSURFRES}:%s",
288 resource_path_len = snprintf(NULL, 0,
291 resource_path = malloc(resource_path_len + 1);
292 if (resource_path == NULL) {
295 snprintf(resource_path,
296 resource_path_len + 1,
303 langv = g_get_language_names();
322 char *dirname = NULL;
323 struct stat dirname_stat;
333 if (stat(dirname, &dirname_stat) == 0) {
334 if (S_ISDIR(dirname_stat.st_mode)) {
335 if (access(dirname, R_OK | W_OK) == 0) {
336 *dirname_out = dirname;
364 char *xdg_config_dir;
367 home_dir = getenv(
"HOME");
372 if (home_dir != NULL) {
375 NSLOG(netsurf, INFO,
"\"%s\"", config_home);
376 *config_home_out = config_home;
385 xdg_config_dir = getenv(
"XDG_CONFIG_HOME");
387 if ((xdg_config_dir == NULL) || (*xdg_config_dir == 0)) {
400 if (home_dir == NULL) {
404 ret =
check_dirname(home_dir,
".config/netsurf", &config_home);
409 ret =
check_dirname(xdg_config_dir,
"netsurf", &config_home);
415 NSLOG(netsurf, INFO,
"\"%s\"", config_home);
417 *config_home_out = config_home;
424 char *config_home = NULL;
426 char *xdg_config_dir;
429 NSLOG(netsurf, INFO,
"Attempting to create configuration directory");
435 xdg_config_dir = getenv(
"XDG_CONFIG_HOME");
437 if ((xdg_config_dir == NULL) || (*xdg_config_dir == 0)) {
438 home_dir = getenv(
"HOME");
440 if ((home_dir == NULL) || (*home_dir == 0)) {
444 ret =
netsurf_mkpath(&config_home, NULL, 4, home_dir,
".config",
"netsurf",
"/");
449 ret =
netsurf_mkpath(&config_home, NULL, 3, xdg_config_dir,
"netsurf",
"/");
463 config_home[strlen(config_home) - 1] = 0;
465 NSLOG(netsurf, INFO,
"\"%s\"", config_home);
467 *config_home_out = config_home;
495 GtkIconSize tooliconsize;
496 GtkToolbarStyle toolbarstyle;
527 fname = getenv(
"HOME");
538 "Failed initialising default resource paths");
551 settings = gtk_settings_get_default();
553 "gtk-toolbar-icon-size", &tooliconsize,
554 "gtk-toolbar-style", &toolbarstyle, NULL);
556 switch (toolbarstyle) {
557 case GTK_TOOLBAR_ICONS:
558 if (tooliconsize == GTK_ICON_SIZE_SMALL_TOOLBAR) {
565 case GTK_TOOLBAR_TEXT:
569 case GTK_TOOLBAR_BOTH:
570 case GTK_TOOLBAR_BOTH_HORIZ:
580 strdup(
"back/history/forward/reloadstop/url_bar/websearch/openmenu"));
600 char *choices = NULL;
639 const char *messages;
675 xdg_cache_dir = getenv(
"XDG_CACHE_HOME");
677 if ((xdg_cache_dir == NULL) || (*xdg_cache_dir == 0)) {
682 home_dir = getenv(
"HOME");
685 if (home_dir == NULL) {
689 ret =
check_dirname(home_dir,
".cache/netsurf", &cache_home);
700 NSLOG(netsurf, INFO,
"\"%s\"", cache_home);
702 *cache_home_out = cache_home;
712 char *cache_home = NULL;
717 NSLOG(netsurf, INFO,
"Attempting to create cache directory");
723 xdg_cache_dir = getenv(
"XDG_CACHE_HOME");
725 if ((xdg_cache_dir == NULL) || (*xdg_cache_dir == 0)) {
726 home_dir = getenv(
"HOME");
728 if ((home_dir == NULL) || (*home_dir == 0)) {
732 ret =
netsurf_mkpath(&cache_home, NULL, 4, home_dir,
".cache",
"netsurf",
"/");
737 ret =
netsurf_mkpath(&cache_home, NULL, 3, xdg_cache_dir,
"netsurf",
"/");
751 cache_home[strlen(cache_home) - 1] = 0;
753 NSLOG(netsurf, INFO,
"\"%s\"", cache_home);
755 *cache_home_out = cache_home;
776 "Unable to locate a configuration directory.");
781 gtk_init(pargc, pargv);
791 fprintf(stderr,
"Unable to locate resources\n");
798 fprintf(stderr,
"GTK resources failed to initialise (%s)\n",
806 fprintf(stderr,
"Options failed to initialise (%s)\n",
814 fprintf(stderr,
"Unable to load translated messages (%s)\n",
816 NSLOG(netsurf, INFO,
"Unable to load translated messages");
827 NSLOG(netsurf, INFO,
"Unable to locate a cache directory.");
835#if GTK_CHECK_VERSION(3,14,0)
842 gtk_icon_theme_add_resource_path(gtk_icon_theme_get_default(),
843 "/org/netsurf/icons");
858 resnamelen = strlen(prefix) + strlen(name) + 5 + 1 + 4 + 1;
859 resname = malloc(resnamelen);
860 if (resname == NULL) {
863 snprintf(resname, resnamelen,
"icons%s/%s.png", prefix, name);
866 NSLOG(netsurf, DEEPDEBUG,
"%d %s", res, resname);
869 pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB,
false, 8, x, y);
871 gtk_icon_theme_add_builtin_icon(name, y, pixbuf);
914 char *resource_filename;
923 "Unable to load gtk accelerator configuration");
930 NSLOG(netsurf, INFO,
"Unable to initialise warning dialog");
940 NSLOG(netsurf, INFO,
"Seting default window icon");
947 if (resource_filename != NULL) {
948 NSLOG(netsurf, INFO,
"Using '%s' as Search Engines file",
950 free(resource_filename);
964 NSLOG(netsurf, INFO,
"Unable to add named icons to GTK theme.");
971 NSLOG(netsurf, INFO,
"Unable to initialise throbber.");
1003 NSLOG(netsurf, INFO,
"Unable to initialise download window.");
1010 if (stat(argv[1], &fs) == 0) {
1012 char *rp =
realpath(argv[1], NULL);
1016 addrlen =
SLEN(
"file://") + strlen(rp) + 1;
1017 addr = malloc(addrlen);
1018 assert(addr != NULL);
1019 snprintf(addr, addrlen,
"file://%s", rp);
1022 addr = strdup(argv[1]);
1030 addr = strdup(NETSURF_HOMEPAGE);
1058 fd_set read_fd_set, write_fd_set, exc_fd_set;
1060 GPollFD *fd_list[1000];
1061 unsigned int fd_count;
1066 FD_ZERO(&read_fd_set);
1067 FD_ZERO(&write_fd_set);
1068 FD_ZERO(&exc_fd_set);
1070 while (gtk_events_pending())
1071 gtk_main_iteration_do(TRUE);
1075 fetch_fdset(&read_fd_set, &write_fd_set, &exc_fd_set, &max_fd);
1076 for (
int i = 0; i <= max_fd; i++) {
1077 if (FD_ISSET(i, &read_fd_set)) {
1078 GPollFD *fd = malloc(
sizeof *fd);
1080 fd->events = G_IO_IN | G_IO_HUP | G_IO_ERR;
1081 g_main_context_add_poll(0, fd, 0);
1082 fd_list[fd_count++] = fd;
1084 if (FD_ISSET(i, &write_fd_set)) {
1085 GPollFD *fd = malloc(
sizeof *fd);
1087 fd->events = G_IO_OUT | G_IO_ERR;
1088 g_main_context_add_poll(0, fd, 0);
1089 fd_list[fd_count++] = fd;
1091 if (FD_ISSET(i, &exc_fd_set)) {
1092 GPollFD *fd = malloc(
sizeof *fd);
1094 fd->events = G_IO_ERR;
1095 g_main_context_add_poll(0, fd, 0);
1096 fd_list[fd_count++] = fd;
1100 gtk_main_iteration();
1102 for (
unsigned int i = 0; i != fd_count; i++) {
1103 g_main_context_remove_poll(0, fd_list[i]);
1117 NSLOG(netsurf, INFO,
"Quitting GUI");
1126 NSLOG(netsurf, INFO,
"Error finalising cookie viewer: %s",
1132 NSLOG(netsurf, INFO,
1133 "Error finalising local history viewer: %s",
1139 NSLOG(netsurf, INFO,
1140 "Error finalising global history viewer: %s",
1146 NSLOG(netsurf, INFO,
"Error finalising hotlist viewer: %s",
1152 NSLOG(netsurf, INFO,
"Error finalising hotlist: %s",
1158 NSLOG(netsurf, INFO,
"Error finalising save complete: %s",
1184 char *cache_home = NULL;
1202 "NetSurf operation table failed registration (%s)\n",
1210 fprintf(stderr,
"NetSurf gtk failed to initialise (%s)\n",
1219 fprintf(stderr,
"NetSurf core failed to initialise (%s)\n",
1228 fprintf(stderr,
"NetSurf gtk setup failed (%s)\n",
nserror nsgtk_accelerator_init(char **respaths)
int main(int argc, char **argv)
Normal entry point from OS.
int schedule_run(void)
Process events up to current time.
Low-level source data cache backing store interface.
struct gui_llcache_table * filesystem_llcache_table
Browser window creation and manipulation interface.
nserror browser_window_create(enum browser_window_create_flags flags, struct nsurl *url, struct nsurl *referrer, struct browser_window *existing, struct browser_window **bw)
Create and open a new root browser window with the given page.
@ BW_CREATE_HISTORY
this will form a new history node (don't set for back/reload/etc)
Compatibility functions for older GTK versions (interface)
void nsgtk_completion_init(void)
initialise completion list store
Interface to url entry completion.
nserror fetch_fdset(fd_set *read_fd_set, fd_set *write_fd_set, fd_set *except_fd_set, int *maxfd_out)
Get the set of file descriptors the fetchers are currently using.
Fetching of data from a URL (interface).
Unified cookie database public interface.
void urldb_save_cookies(const char *filename)
Save persistent cookies to file.
void urldb_load_cookies(const char *filename)
Load a cookie file into the database.
nserror hotlist_fini(void)
Finalise the hotlist.
nserror hotlist_init(const char *load_path, const char *save_path)
Initialise the hotlist.
nserror search_web_init(const char *provider_fname)
Initialise the web search operations.
nserror search_web_select_provider(const char *selection)
Change the currently selected web search provider.
nserror
Enumeration of error codes.
@ NSERROR_PERMISSION
Permission error.
@ NSERROR_NOT_FOUND
Requested item not found.
@ NSERROR_BAD_PARAMETER
Bad Parameter.
@ NSERROR_NOT_DIRECTORY
Missing directory.
@ NSERROR_NOMEM
Memory exhaustion.
char ** filepath_path_to_strvec(const char *path)
Convert a colon separated list of path elements into a string vector.
char * filepath_find(char **respathv, const char *filename)
Searches an array of resource paths for a file.
char * filepath_sfinddef(char **respathv, char *filepath, const char *filename, const char *def)
Searches an array of resource paths for a file optionally forcing a default.
void filepath_free_strvec(char **pathv)
Free a string vector.
char ** filepath_generate(char *const *pathv, const char *const *langv)
Merge two string vectors into a resource search path vector.
Utility routines to obtain paths to file resources.
struct gui_bitmap_table * nsgtk_bitmap_table
void nsgtk_download_destroy(void)
Destroy download window.
nserror nsgtk_download_init(void)
Initialise download window ready for use.
struct gui_download_table * nsgtk_download_table
download operation table for gtk
void gtk_fetch_filetype_fin(void)
void gtk_fetch_filetype_init(const char *mimefile)
struct gui_fetch_table * nsgtk_fetch_table
nserror nsgtk_global_history_destroy(void)
Destroys the global history window and performs any other necessary cleanup actions.
Interface to GTK global history manager.
nserror nsgtk_hotlist_destroy(void)
Free any resources allocated for the hotlist window.
Interface to GTK bookmarks (hotlist).
nserror nsgtk_local_history_destroy(void)
Destroys the local history window and performs any other necessary cleanup actions.
Interface to GTK local history manager.
static struct print_settings * settings
struct gui_search_table * nsgtk_search_table
free text page search for gtk interface
struct gui_clipboard_table * nsgtk_clipboard_table
nserror nsgtk_cookies_destroy(void)
Free any resources allocated for the cookie window.
struct core_window_table * nsgtk_core_window_table
static void nsgtk_main(void)
Run the gtk event loop.
char ** respaths
resource search path vector
static nserror create_config_home(char **config_home_out)
GdkPixbuf * win_default_icon_pixbuf
default window icon pixbuf
GtkBuilder * warning_builder
bool nsgtk_complete
set when no windows remain open.
static nserror nsgtk_init(int *pargc, char ***pargv, char **cache_home)
GTK specific initialisation.
static nserror set_defaults(struct nsoption_s *defaults)
Set option defaults for gtk frontend.
nserror nsgtk_warning(const char *warning, const char *detail)
Warn the user of an event.
static bool nslog_stream_configure(FILE *fptr)
Ensures output logging stream is correctly configured.
static nserror nsgtk_messages_init(char **respaths)
initialise message translation
static nserror nsgtk_add_named_icons_to_theme(void)
adds named icons into gtk theme
static nserror check_dirname(const char *path, const char *leaf, char **dirname_out)
create directory name and check it is acessible and a directory.
static nserror get_cache_home(char **cache_home_out)
Get the path to the cache directory.
GdkPixbuf * favicon_pixbuf
favicon default pixbuf
char * nsgtk_config_home
Directory where all configuration files are held.
static nserror add_builtin_icon(const char *prefix, const char *name, int x, int y)
static void nsgtk_finalise(void)
finalise the browser
static nserror create_cache_home(char **cache_home_out)
create a cache directory
static nserror nsgtk_setup(int argc, char **argv, char **respath)
setup GTK specific parts of the browser.
uint32_t gtk_gui_gdkkey_to_nskey(GdkEventKey *key)
input conversion.
static char ** nsgtk_init_resource_path(const char *config_home)
Create an array of valid paths to search for resources.
static nserror nsgtk_option_init(int *pargc, char **argv)
Initialise user options.
static nserror get_config_home(char **config_home_out)
Get the path to the config directory.
struct gui_misc_table * nsgtk_misc_table
nserror nsgtk_throbber_init(void)
Initialise global throbber context.
struct gui_window_table * nsgtk_window_table
struct gui_search_web_table * nsgtk_search_web_table
char * realpath(const char *f, char *buf)
Generic bitmap handling interface.
void bitmap_set_format(const bitmap_fmt_t *bitmap_format)
Set client bitmap format.
@ BITMAP_LAYOUT_ARGB8888
32-bit ARGB (0xAARRGGBB).
int browser_get_dpi(void)
Get the browser DPI.
nserror browser_set_dpi(int dpi)
Set the DPI of the browser.
Interface to key press operations.
@ NS_KEY_DELETE_WORD_RIGHT
@ NS_KEY_DELETE_LINE_START
@ NS_KEY_DELETE_WORD_LEFT
struct gui_layout_table * nsgtk_layout_table
Interface to GTK layout handling using pango.
nserror nslog_init(nslog_ensure_t *ensure, int *pargc, char **argv)
Initialise the logging system.
void nslog_finalise(void)
Shut down the logging system.
#define NSLOG(catname, level, logmsg, args...)
nserror messages_add_from_inline(const uint8_t *data, size_t size)
Read keys and values from inline message data into the standard Messages hash.
nserror messages_add_from_file(const char *path)
Read keys and values from messages file into the standard Messages hash.
const char * messages_get_errorcode(nserror code)
lookup of a message by errorcode from the standard Messages hash.
const char * messages_get(const char *key)
Fast lookup of a message by key from the standard Messages hash.
Localised message support (interface).
NetSurf core interface registration, construction and destruction.
void netsurf_exit(void)
Finalise NetSurf core.
nserror netsurf_init(const char *store_path)
Initialise netsurf core.
nserror netsurf_register(struct netsurf_table *table)
Register operation table.
nserror nsurl_create(const char *const url_s, nsurl **url)
Create a NetSurf URL object from a URL string.
void nsurl_unref(nsurl *url)
Drop a reference to a NetSurf URL object.
struct nsurl nsurl
NetSurf URL object.
nserror nsgtk_data_from_resname(const char *resname, const uint8_t **data_out, size_t *data_size_out)
Get direct pointer to resource data.
nserror nsgtk_init_resources(char **respath)
Initialise UI resource table.
nserror nsgtk_builder_new_from_resname(const char *resname, GtkBuilder **builder_out)
Create gtk builder object for the named ui resource.
nserror nsgdk_pixbuf_new_from_resname(const char *resname, GdkPixbuf **pixbuf_out)
Create gdk pixbuf for the named ui resource.
nserror nsgtk_path_from_resname(const char *resname, const char **path_out)
Get path to resource data.
Interface to gtk builtin resource handling.
void save_complete_init(void)
Initialise save complete module.
nserror save_complete_finalise(void)
Finalise save complete module.
Save HTML document with dependencies (interface).
core web search facilities interface.
Interface to utility string handling.
NetSurf operation function table.
struct gui_misc_table * misc
Browser table.
Unified URL information database public interface.
nserror urldb_save(const char *filename)
Export the current database to file.
nserror urldb_load(const char *filename)
Import an URL database from file, replacing any existing database.
nserror netsurf_mkdir_all(const char *fname)
Ensure that all directory elements needed to store a filename exist.
nserror netsurf_mkpath(char **str, size_t *size, size_t nelm,...)
Generate a path from one or more component elemnts.
Default operations table for files.
struct nsoption_s * nsoptions_default
global default option table.
static struct nsoption_s defaults[]
The table of compiled in default options.
nserror nsoption_read(const char *path, struct nsoption_s *opts)
Read choices file and set them in the passed table.
struct nsoption_s * nsoptions
global active option table.
nserror nsoption_commandline(int *pargc, char **argv, struct nsoption_s *opts)
Process commandline and set options approriately.
nserror nsoption_init(nsoption_set_default_t *set_defaults, struct nsoption_s **popts, struct nsoption_s **pdefs)
Initialise option system.
nserror nsoption_finalise(struct nsoption_s *opts, struct nsoption_s *defs)
Finalise option system.
Option reading and saving interface.
#define nsoption_charp(OPTION)
Get the value of a string option.
#define nsoption_setnull_charp(OPTION, VALUE)
set string option in default table if currently unset
#define nsoption_int(OPTION)
Get the value of an integer option.
#define nsoption_set_int(OPTION, VALUE)
set an integer option in the default table
#define nsoption_set_charp(OPTION, VALUE)
set string option in default table
Interface to a number of general purpose functionality.
#define SLEN(x)
Calculate length of constant C string.
static nserror path(const struct redraw_context *ctx, const plot_style_t *pstyle, const float *p, unsigned int n, const float transform[6])
Plots a path.