NetSurf
gui.c
Go to the documentation of this file.
1/*
2 * Copyright 2004-2010 James Bursa <bursa@users.sourceforge.net>
3 * Copyright 2010-2016 Vincent Sanders <vince@netsurf-browser.org>
4 * Copyright 2004-2009 John-Mark Bell <jmb@netsurf-browser.org>
5 * Copyright 2009 Paul Blokus <paul_pl@users.sourceforge.net>
6 * Copyright 2006-2009 Daniel Silverstone <dsilvers@netsurf-browser.org>
7 * Copyright 2006-2008 Rob Kendrick <rjek@netsurf-browser.org>
8 * Copyright 2008 John Tytgat <joty@netsurf-browser.org>
9 * Copyright 2008 Adam Blokus <adamblokus@gmail.com>
10 *
11 * This file is part of NetSurf, http://www.netsurf-browser.org/
12 *
13 * NetSurf is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; version 2 of the License.
16 *
17 * NetSurf is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 */
25
26#include <assert.h>
27#include <stdbool.h>
28#include <stdlib.h>
29#include <string.h>
30#include <unistd.h>
31#include <sys/stat.h>
32#include <sys/types.h>
33#include <gtk/gtk.h>
34
35#include "utils/filepath.h"
36#include "utils/log.h"
37#include "utils/messages.h"
38#include "utils/utils.h"
39#include "utils/file.h"
40#include "utils/nsoption.h"
41#include "netsurf/keypress.h"
42#include "netsurf/url_db.h"
43#include "netsurf/cookie_db.h"
44#include "netsurf/browser.h"
46#include "netsurf/netsurf.h"
47#include "netsurf/bitmap.h"
48#include "content/fetch.h"
51#include "desktop/searchweb.h"
52#include "desktop/hotlist.h"
53
54#include "gtk/compat.h"
55#include "gtk/warn.h"
56#include "gtk/completion.h"
57#include "gtk/cookies.h"
58#include "gtk/download.h"
59#include "gtk/fetch.h"
60#include "gtk/gui.h"
61#include "gtk/local_history.h"
62#include "gtk/global_history.h"
63#include "gtk/hotlist.h"
64#include "gtk/throbber.h"
65#include "gtk/toolbar_items.h"
66#include "gtk/scaffolding.h"
67#include "gtk/window.h"
68#include "gtk/schedule.h"
69#include "gtk/selection.h"
70#include "gtk/search.h"
71#include "gtk/bitmap.h"
72#include "gtk/misc.h"
73#include "gtk/resources.h"
74#include "gtk/layout_pango.h"
75#include "gtk/accelerator.h"
76
77bool nsgtk_complete = false;
78
79/* exported global defined in gtk/gui.h */
81
82/** favicon default pixbuf */
83GdkPixbuf *favicon_pixbuf;
84
85/** default window icon pixbuf */
87
88GtkBuilder *warning_builder;
89
90/** resource search path vector */
91char **respaths;
92
93
94/* exported function documented in gtk/warn.h */
95nserror nsgtk_warning(const char *warning, const char *detail)
96{
97 char buf[300]; /* 300 is the size the RISC OS GUI uses */
98 static GtkWindow *nsgtk_warning_window;
99 GtkLabel *WarningLabel;
100
101 NSLOG(netsurf, INFO, "%s %s", warning, detail ? detail : "");
102 fflush(stdout);
103
104 nsgtk_warning_window = GTK_WINDOW(gtk_builder_get_object(warning_builder, "wndWarning"));
105 WarningLabel = GTK_LABEL(gtk_builder_get_object(warning_builder,
106 "labelWarning"));
107
108 snprintf(buf, sizeof(buf), "%s %s", messages_get(warning),
109 detail ? detail : "");
110 buf[sizeof(buf) - 1] = 0;
111
112 gtk_label_set_text(WarningLabel, buf);
113
114 gtk_widget_show_all(GTK_WIDGET(nsgtk_warning_window));
115
116 return NSERROR_OK;
117}
118
119
120/* exported interface documented in gtk/gui.h */
121uint32_t gtk_gui_gdkkey_to_nskey(GdkEventKey *key)
122{
123 /* this function will need to become much more complex to support
124 * everything that the RISC OS version does. But this will do for
125 * now. I hope.
126 */
127 switch (key->keyval) {
128
129 case GDK_KEY(Tab):
130 return NS_KEY_TAB;
131
132 case GDK_KEY(BackSpace):
133 if (key->state & GDK_SHIFT_MASK)
135 else if (key->state & GDK_CONTROL_MASK)
137 else
138 return NS_KEY_DELETE_LEFT;
139
140 case GDK_KEY(Delete):
141 if (key->state & GDK_SHIFT_MASK)
143 else if (key->state & GDK_CONTROL_MASK)
145 else
146 return NS_KEY_DELETE_RIGHT;
147
148 case GDK_KEY(Linefeed):
149 return 13;
150
151 case GDK_KEY(Return):
152 return 10;
153
154 case GDK_KEY(Left):
155 case GDK_KEY(KP_Left):
156 if (key->state & GDK_CONTROL_MASK)
157 return NS_KEY_WORD_LEFT;
158 return NS_KEY_LEFT;
159
160 case GDK_KEY(Right):
161 case GDK_KEY(KP_Right):
162 if (key->state & GDK_CONTROL_MASK)
163 return NS_KEY_WORD_RIGHT;
164 return NS_KEY_RIGHT;
165
166 case GDK_KEY(Up):
167 case GDK_KEY(KP_Up):
168 return NS_KEY_UP;
169
170 case GDK_KEY(Down):
171 case GDK_KEY(KP_Down):
172 return NS_KEY_DOWN;
173
174 case GDK_KEY(Home):
175 case GDK_KEY(KP_Home):
176 if (key->state & GDK_CONTROL_MASK)
177 return NS_KEY_LINE_START;
178 else
179 return NS_KEY_TEXT_START;
180
181 case GDK_KEY(End):
182 case GDK_KEY(KP_End):
183 if (key->state & GDK_CONTROL_MASK)
184 return NS_KEY_LINE_END;
185 else
186 return NS_KEY_TEXT_END;
187
188 case GDK_KEY(Page_Up):
189 case GDK_KEY(KP_Page_Up):
190 return NS_KEY_PAGE_UP;
191
192 case GDK_KEY(Page_Down):
193 case GDK_KEY(KP_Page_Down):
194 return NS_KEY_PAGE_DOWN;
195
196 case 'a':
197 if (key->state & GDK_CONTROL_MASK)
198 return NS_KEY_SELECT_ALL;
199 return gdk_keyval_to_unicode(key->keyval);
200
201 case 'u':
202 if (key->state & GDK_CONTROL_MASK)
203 return NS_KEY_DELETE_LINE;
204 return gdk_keyval_to_unicode(key->keyval);
205
206 case 'c':
207 if (key->state & GDK_CONTROL_MASK)
209 return gdk_keyval_to_unicode(key->keyval);
210
211 case 'v':
212 if (key->state & GDK_CONTROL_MASK)
213 return NS_KEY_PASTE;
214 return gdk_keyval_to_unicode(key->keyval);
215
216 case 'x':
217 if (key->state & GDK_CONTROL_MASK)
219 return gdk_keyval_to_unicode(key->keyval);
220
221 case 'Z':
222 case 'y':
223 if (key->state & GDK_CONTROL_MASK)
224 return NS_KEY_REDO;
225 return gdk_keyval_to_unicode(key->keyval);
226
227 case 'z':
228 if (key->state & GDK_CONTROL_MASK)
229 return NS_KEY_UNDO;
230 return gdk_keyval_to_unicode(key->keyval);
231
232 case GDK_KEY(Escape):
233 return NS_KEY_ESCAPE;
234
235 /* Modifiers - do nothing for now */
236 case GDK_KEY(Shift_L):
237 case GDK_KEY(Shift_R):
238 case GDK_KEY(Control_L):
239 case GDK_KEY(Control_R):
240 case GDK_KEY(Caps_Lock):
241 case GDK_KEY(Shift_Lock):
242 case GDK_KEY(Meta_L):
243 case GDK_KEY(Meta_R):
244 case GDK_KEY(Alt_L):
245 case GDK_KEY(Alt_R):
246 case GDK_KEY(Super_L):
247 case GDK_KEY(Super_R):
248 case GDK_KEY(Hyper_L):
249 case GDK_KEY(Hyper_R):
250 return 0;
251
252 }
253 return gdk_keyval_to_unicode(key->keyval);
254}
255
256
257/**
258 * Create an array of valid paths to search for resources.
259 *
260 * The idea is that all the complex path computation to find resources
261 * is performed here, once, rather than every time a resource is
262 * searched for.
263 */
264static char **
265nsgtk_init_resource_path(const char *config_home)
266{
267 char *resource_path;
268 int resource_path_len;
269 const gchar * const *langv;
270 char **pathv; /* resource path string vector */
271 char **respath; /* resource paths vector */
272
273 if (config_home != NULL) {
274 resource_path_len = snprintf(NULL, 0,
275 "%s:${NETSURFRES}:%s",
276 config_home,
277 GTK_RESPATH);
278 resource_path = malloc(resource_path_len + 1);
279 if (resource_path == NULL) {
280 return NULL;
281 }
282 snprintf(resource_path, resource_path_len + 1,
283 "%s:${NETSURFRES}:%s",
284 config_home,
285 GTK_RESPATH);
286 } else {
287 resource_path_len = snprintf(NULL, 0,
288 "${NETSURFRES}:%s",
289 GTK_RESPATH);
290 resource_path = malloc(resource_path_len + 1);
291 if (resource_path == NULL) {
292 return NULL;
293 }
294 snprintf(resource_path,
295 resource_path_len + 1,
296 "${NETSURFRES}:%s",
297 GTK_RESPATH);
298 }
299
300 pathv = filepath_path_to_strvec(resource_path);
301
302 langv = g_get_language_names();
303
304 respath = filepath_generate(pathv, langv);
305
307
308 free(resource_path);
309
310 return respath;
311}
312
313
314/**
315 * create directory name and check it is acessible and a directory.
316 */
317static nserror
318check_dirname(const char *path, const char *leaf, char **dirname_out)
319{
320 nserror ret;
321 char *dirname = NULL;
322 struct stat dirname_stat;
323
324 ret = netsurf_mkpath(&dirname, NULL, 2, path, leaf);
325 if (ret != NSERROR_OK) {
326 return ret;
327 }
328
329 /* ensure access is possible and the entry is actualy
330 * a directory.
331 */
332 if (stat(dirname, &dirname_stat) == 0) {
333 if (S_ISDIR(dirname_stat.st_mode)) {
334 if (access(dirname, R_OK | W_OK) == 0) {
335 *dirname_out = dirname;
336 return NSERROR_OK;
337 } else {
338 ret = NSERROR_PERMISSION;
339 }
340 } else {
342 }
343 } else {
344 ret = NSERROR_NOT_FOUND;
345 }
346
347 free(dirname);
348
349 return ret;
350}
351
352
353/**
354 * Get the path to the config directory.
355 *
356 * @param config_home_out Path to configuration directory.
357 * @return NSERROR_OK on sucess and \a config_home_out updated else error code.
358 */
359static nserror get_config_home(char **config_home_out)
360{
361 nserror ret;
362 char *home_dir;
363 char *xdg_config_dir;
364 char *config_home;
365
366 home_dir = getenv("HOME");
367
368 /* The old $HOME/.netsurf/ directory should be used if it
369 * exists and is accessible.
370 */
371 if (home_dir != NULL) {
372 ret = check_dirname(home_dir, ".netsurf", &config_home);
373 if (ret == NSERROR_OK) {
374 NSLOG(netsurf, INFO, "\"%s\"", config_home);
375 *config_home_out = config_home;
376 return ret;
377 }
378 }
379
380 /* $XDG_CONFIG_HOME defines the base directory
381 * relative to which user specific configuration files
382 * should be stored.
383 */
384 xdg_config_dir = getenv("XDG_CONFIG_HOME");
385
386 if ((xdg_config_dir == NULL) || (*xdg_config_dir == 0)) {
387 /* If $XDG_CONFIG_HOME is either not set or empty, a
388 * default equal to $HOME/.config should be used.
389 */
390
391 /** @todo the meaning of empty is never defined so I
392 * am assuming it is a zero length string but is it
393 * supposed to mean "whitespace" and if so what counts
394 * as whitespace? (are tabs etc. counted or should
395 * isspace() be used)
396 */
397
398 /* the HOME envvar is required */
399 if (home_dir == NULL) {
401 }
402
403 ret = check_dirname(home_dir, ".config/netsurf", &config_home);
404 if (ret != NSERROR_OK) {
405 return ret;
406 }
407 } else {
408 ret = check_dirname(xdg_config_dir, "netsurf", &config_home);
409 if (ret != NSERROR_OK) {
410 return ret;
411 }
412 }
413
414 NSLOG(netsurf, INFO, "\"%s\"", config_home);
415
416 *config_home_out = config_home;
417 return NSERROR_OK;
418}
419
420
421static nserror create_config_home(char **config_home_out)
422{
423 char *config_home = NULL;
424 char *home_dir;
425 char *xdg_config_dir;
426 nserror ret;
427
428 NSLOG(netsurf, INFO, "Attempting to create configuration directory");
429
430 /* $XDG_CONFIG_HOME defines the base directory
431 * relative to which user specific configuration files
432 * should be stored.
433 */
434 xdg_config_dir = getenv("XDG_CONFIG_HOME");
435
436 if ((xdg_config_dir == NULL) || (*xdg_config_dir == 0)) {
437 home_dir = getenv("HOME");
438
439 if ((home_dir == NULL) || (*home_dir == 0)) {
441 }
442
443 ret = netsurf_mkpath(&config_home, NULL, 4, home_dir, ".config","netsurf", "/");
444 if (ret != NSERROR_OK) {
445 return ret;
446 }
447 } else {
448 ret = netsurf_mkpath(&config_home, NULL, 3, xdg_config_dir, "netsurf", "/");
449 if (ret != NSERROR_OK) {
450 return ret;
451 }
452 }
453
454 /* ensure all elements of path exist (the trailing / is required) */
455 ret = netsurf_mkdir_all(config_home);
456 if (ret != NSERROR_OK) {
457 free(config_home);
458 return ret;
459 }
460
461 /* strip the trailing separator */
462 config_home[strlen(config_home) - 1] = 0;
463
464 NSLOG(netsurf, INFO, "\"%s\"", config_home);
465
466 *config_home_out = config_home;
467
468 return NSERROR_OK;
469}
470
471
472/**
473 * Ensures output logging stream is correctly configured
474 */
475static bool nslog_stream_configure(FILE *fptr)
476{
477 /* set log stream to be non-buffering */
478 setbuf(fptr, NULL);
479
480 return true;
481}
482
483
484/**
485 * Set option defaults for gtk frontend.
486 *
487 * \param defaults The option table to update.
488 * \return error status.
489 */
491{
492 char *fname;
493 GtkSettings *settings;
494 GtkIconSize tooliconsize;
495 GtkToolbarStyle toolbarstyle;
496
497 /* cookie file default */
498 fname = NULL;
499 netsurf_mkpath(&fname, NULL, 2, nsgtk_config_home, "Cookies");
500 if (fname != NULL) {
501 nsoption_setnull_charp(cookie_file, fname);
502 }
503
504 /* cookie jar default */
505 fname = NULL;
506 netsurf_mkpath(&fname, NULL, 2, nsgtk_config_home, "Cookies");
507 if (fname != NULL) {
508 nsoption_setnull_charp(cookie_jar, fname);
509 }
510
511 /* url database default */
512 fname = NULL;
513 netsurf_mkpath(&fname, NULL, 2, nsgtk_config_home, "URLs");
514 if (fname != NULL) {
515 nsoption_setnull_charp(url_file, fname);
516 }
517
518 /* bookmark database default */
519 fname = NULL;
520 netsurf_mkpath(&fname, NULL, 2, nsgtk_config_home, "Hotlist");
521 if (fname != NULL) {
522 nsoption_setnull_charp(hotlist_path, fname);
523 }
524
525 /* download directory default */
526 fname = getenv("HOME");
527 if (fname != NULL) {
528 nsoption_setnull_charp(downloads_directory, strdup(fname));
529 }
530
531 if ((nsoption_charp(cookie_file) == NULL) ||
532 (nsoption_charp(cookie_jar) == NULL) ||
533 (nsoption_charp(url_file) == NULL) ||
534 (nsoption_charp(hotlist_path) == NULL) ||
535 (nsoption_charp(downloads_directory) == NULL)) {
536 NSLOG(netsurf, INFO,
537 "Failed initialising default resource paths");
539 }
540
541 /* set default font names */
542 nsoption_set_charp(font_sans, strdup("Sans"));
543 nsoption_set_charp(font_serif, strdup("Serif"));
544 nsoption_set_charp(font_mono, strdup("Monospace"));
545 nsoption_set_charp(font_cursive, strdup("Serif"));
546 nsoption_set_charp(font_fantasy, strdup("Serif"));
547
548 /* Default toolbar button type to system defaults */
549
550 settings = gtk_settings_get_default();
551 g_object_get(settings,
552 "gtk-toolbar-icon-size", &tooliconsize,
553 "gtk-toolbar-style", &toolbarstyle, NULL);
554
555 switch (toolbarstyle) {
556 case GTK_TOOLBAR_ICONS:
557 if (tooliconsize == GTK_ICON_SIZE_SMALL_TOOLBAR) {
558 nsoption_set_int(button_type, 1);
559 } else {
560 nsoption_set_int(button_type, 2);
561 }
562 break;
563
564 case GTK_TOOLBAR_TEXT:
565 nsoption_set_int(button_type, 4);
566 break;
567
568 case GTK_TOOLBAR_BOTH:
569 case GTK_TOOLBAR_BOTH_HORIZ:
570 /* no labels in default configuration */
571 default:
572 /* No system default, so use large icons */
573 nsoption_set_int(button_type, 2);
574 break;
575 }
576
577 /* set default items in toolbar */
578 nsoption_set_charp(toolbar_items,
579 strdup("back/history/forward/reloadstop/url_bar/websearch/openmenu"));
580
581 /* set default for menu and tool bar visibility */
582 nsoption_set_charp(bar_show, strdup("tool"));
583
584 return NSERROR_OK;
585}
586
587
588/**
589 * Initialise user options
590 *
591 * Initialise the browser configuration options. These are set by:
592 * - set generic defaults suitable for the gtk frontend
593 * - user choices loaded from Choices file
594 * - command line parameters
595 */
596static nserror nsgtk_option_init(int *pargc, char** argv)
597{
598 nserror ret;
599 char *choices = NULL;
600
601 /* user options setup */
603 if (ret != NSERROR_OK) {
604 return ret;
605 }
606
607 /* Attempt to load the user choices */
608 ret = netsurf_mkpath(&choices, NULL, 2, nsgtk_config_home, "Choices");
609 if (ret == NSERROR_OK) {
610 nsoption_read(choices, nsoptions);
611 free(choices);
612 }
613
614 /* overide loaded options with those from commandline */
615 nsoption_commandline(pargc, argv, nsoptions);
616
617 /* ensure all options fall within sensible bounds */
618
619 /* Attempt to handle nonsense status bar widths. These may exist
620 * in people's Choices as the GTK front end used to abuse the
621 * status bar width option by using it for an absolute value in px.
622 * The GTK front end now correctly uses it as a proportion of window
623 * width. Here we assume that a value of less than 15% is wrong
624 * and set to the default two thirds. */
625 if (nsoption_int(toolbar_status_size) < 1500) {
626 nsoption_set_int(toolbar_status_size, 6667);
627 }
628
629 return NSERROR_OK;
630}
631
632
633/**
634 * initialise message translation
635 */
637{
638 const char *messages;
639 nserror ret;
640 const uint8_t *data;
641 size_t data_size;
642
643 ret = nsgtk_data_from_resname("Messages", &data, &data_size);
644 if (ret == NSERROR_OK) {
645 ret = messages_add_from_inline(data, data_size);
646 } else {
647 /* Obtain path to messages */
648 ret = nsgtk_path_from_resname("Messages", &messages);
649 if (ret == NSERROR_OK) {
650 ret = messages_add_from_file(messages);
651 }
652 }
653 return ret;
654}
655
656
657/**
658 * Get the path to the cache directory.
659 *
660 * @param cache_home_out Path to cache directory.
661 * @return NSERROR_OK on sucess and \a cache_home_out updated else error code.
662 */
663static nserror get_cache_home(char **cache_home_out)
664{
665 nserror ret;
666 char *xdg_cache_dir;
667 char *cache_home;
668 char *home_dir;
669
670 /* $XDG_CACHE_HOME defines the base directory relative to
671 * which user specific non-essential data files should be
672 * stored.
673 */
674 xdg_cache_dir = getenv("XDG_CACHE_HOME");
675
676 if ((xdg_cache_dir == NULL) || (*xdg_cache_dir == 0)) {
677 /* If $XDG_CACHE_HOME is either not set or empty, a
678 * default equal to $HOME/.cache should be used.
679 */
680
681 home_dir = getenv("HOME");
682
683 /* the HOME envvar is required */
684 if (home_dir == NULL) {
686 }
687
688 ret = check_dirname(home_dir, ".cache/netsurf", &cache_home);
689 if (ret != NSERROR_OK) {
690 return ret;
691 }
692 } else {
693 ret = check_dirname(xdg_cache_dir, "netsurf", &cache_home);
694 if (ret != NSERROR_OK) {
695 return ret;
696 }
697 }
698
699 NSLOG(netsurf, INFO, "\"%s\"", cache_home);
700
701 *cache_home_out = cache_home;
702 return NSERROR_OK;
703}
704
705
706/**
707 * create a cache directory
708 */
709static nserror create_cache_home(char **cache_home_out)
710{
711 char *cache_home = NULL;
712 char *home_dir;
713 char *xdg_cache_dir;
714 nserror ret;
715
716 NSLOG(netsurf, INFO, "Attempting to create cache directory");
717
718 /* $XDG_CACHE_HOME defines the base directory
719 * relative to which user specific cache files
720 * should be stored.
721 */
722 xdg_cache_dir = getenv("XDG_CACHE_HOME");
723
724 if ((xdg_cache_dir == NULL) || (*xdg_cache_dir == 0)) {
725 home_dir = getenv("HOME");
726
727 if ((home_dir == NULL) || (*home_dir == 0)) {
729 }
730
731 ret = netsurf_mkpath(&cache_home, NULL, 4, home_dir, ".cache", "netsurf", "/");
732 if (ret != NSERROR_OK) {
733 return ret;
734 }
735 } else {
736 ret = netsurf_mkpath(&cache_home, NULL, 3, xdg_cache_dir, "netsurf", "/");
737 if (ret != NSERROR_OK) {
738 return ret;
739 }
740 }
741
742 /* ensure all elements of path exist (the trailing / is required) */
743 ret = netsurf_mkdir_all(cache_home);
744 if (ret != NSERROR_OK) {
745 free(cache_home);
746 return ret;
747 }
748
749 /* strip the trailing separator */
750 cache_home[strlen(cache_home) - 1] = 0;
751
752 NSLOG(netsurf, INFO, "\"%s\"", cache_home);
753
754 *cache_home_out = cache_home;
755
756 return NSERROR_OK;
757}
758
759
760/**
761 * GTK specific initialisation
762 */
763static nserror nsgtk_init(int *pargc, char ***pargv, char **cache_home)
764{
765 nserror ret;
766
767 /* Locate the correct user configuration directory path */
769 if (ret == NSERROR_NOT_FOUND) {
770 /* no config directory exists yet so try to create one */
772 }
773 if (ret != NSERROR_OK) {
774 NSLOG(netsurf, INFO,
775 "Unable to locate a configuration directory.");
776 nsgtk_config_home = NULL;
777 }
778
779 /* Initialise gtk */
780 gtk_init(pargc, pargv);
781
782 /* initialise logging. Not fatal if it fails but not much we
783 * can do about it either.
784 */
785 nslog_init(nslog_stream_configure, pargc, *pargv);
786
787 /* build the common resource path list */
789 if (respaths == NULL) {
790 fprintf(stderr, "Unable to locate resources\n");
791 return 1;
792 }
793
794 /* initialise the gtk resource handling */
796 if (ret != NSERROR_OK) {
797 fprintf(stderr, "GTK resources failed to initialise (%s)\n",
799 return ret;
800 }
801
802 /* Initialise user options */
803 ret = nsgtk_option_init(pargc, *pargv);
804 if (ret != NSERROR_OK) {
805 fprintf(stderr, "Options failed to initialise (%s)\n",
807 return ret;
808 }
809
810 /* Initialise translated messages */
812 if (ret != NSERROR_OK) {
813 fprintf(stderr, "Unable to load translated messages (%s)\n",
815 NSLOG(netsurf, INFO, "Unable to load translated messages");
816 /** \todo decide if message load faliure should be fatal */
817 }
818
819 /* Locate the correct user cache directory path */
820 ret = get_cache_home(cache_home);
821 if (ret == NSERROR_NOT_FOUND) {
822 /* no cache directory exists yet so try to create one */
823 ret = create_cache_home(cache_home);
824 }
825 if (ret != NSERROR_OK) {
826 NSLOG(netsurf, INFO, "Unable to locate a cache directory.");
827 }
828
829
830 return NSERROR_OK;
831}
832
833
834#if GTK_CHECK_VERSION(3,14,0)
835
836/**
837 * adds named icons into gtk theme
838 */
840{
841 gtk_icon_theme_add_resource_path(gtk_icon_theme_get_default(),
842 "/org/netsurf/icons");
843 return NSERROR_OK;
844}
845
846#else
847
848static nserror
849add_builtin_icon(const char *prefix, const char *name, int x, int y)
850{
851 GdkPixbuf *pixbuf;
852 nserror res;
853 char *resname;
854 int resnamelen;
855
856 /* resource name string length allowing for / .png and termination */
857 resnamelen = strlen(prefix) + strlen(name) + 5 + 1 + 4 + 1;
858 resname = malloc(resnamelen);
859 if (resname == NULL) {
860 return NSERROR_NOMEM;
861 }
862 snprintf(resname, resnamelen, "icons%s/%s.png", prefix, name);
863
864 res = nsgdk_pixbuf_new_from_resname(resname, &pixbuf);
865 NSLOG(netsurf, DEEPDEBUG, "%d %s", res, resname);
866 free(resname);
867 if (res != NSERROR_OK) {
868 pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, false, 8, x, y);
869 }
870 gtk_icon_theme_add_builtin_icon(name, y, pixbuf);
871
872 return NSERROR_OK;
873}
874
875
876/**
877 * adds named icons into gtk theme
878 */
880{
881 /* these must also be in gtk/resources.c pixbuf_resource *and*
882 * gtk/res/netsurf.gresource.xml
883 */
884 add_builtin_icon("", "local-history", 8, 32);
885 add_builtin_icon("", "show-cookie", 24, 24);
886 add_builtin_icon("/24x24/actions", "page-info-insecure", 24, 24);
887 add_builtin_icon("/24x24/actions", "page-info-internal", 24, 24);
888 add_builtin_icon("/24x24/actions", "page-info-local", 24, 24);
889 add_builtin_icon("/24x24/actions", "page-info-secure", 24, 24);
890 add_builtin_icon("/24x24/actions", "page-info-warning", 24, 24);
891 add_builtin_icon("/48x48/actions", "page-info-insecure", 48, 48);
892 add_builtin_icon("/48x48/actions", "page-info-internal", 48, 48);
893 add_builtin_icon("/48x48/actions", "page-info-local", 48, 48);
894 add_builtin_icon("/48x48/actions", "page-info-secure", 48, 48);
895 add_builtin_icon("/48x48/actions", "page-info-warning", 48, 48);
896
897 return NSERROR_OK;
898}
899
900#endif
901
902
903/**
904 * setup GTK specific parts of the browser.
905 *
906 * \param argc The number of arguments on the command line
907 * \param argv A string vector of command line arguments.
908 * \respath A string vector of the path elements of resources
909 */
910static nserror nsgtk_setup(int argc, char** argv, char **respath)
911{
912 char buf[PATH_MAX];
913 char *resource_filename;
914 char *addr = NULL;
915 nsurl *url;
916 nserror res;
917
918 /* Initialise gtk accelerator table */
920 if (res != NSERROR_OK) {
921 NSLOG(netsurf, INFO,
922 "Unable to load gtk accelerator configuration");
923 /* not fatal if this does not load */
924 }
925
926 /* initialise warning dialog */
928 if (res != NSERROR_OK) {
929 NSLOG(netsurf, INFO, "Unable to initialise warning dialog");
930 return res;
931 }
932
933 gtk_builder_connect_signals(warning_builder, NULL);
934
935 /* set default icon if its available */
936 res = nsgdk_pixbuf_new_from_resname("netsurf.xpm",
938 if (res == NSERROR_OK) {
939 NSLOG(netsurf, INFO, "Seting default window icon");
940 gtk_window_set_default_icon(win_default_icon_pixbuf);
941 }
942
943 /* Search engine sources */
944 resource_filename = filepath_find(respath, "SearchEngines");
945 search_web_init(resource_filename);
946 if (resource_filename != NULL) {
947 NSLOG(netsurf, INFO, "Using '%s' as Search Engines file",
948 resource_filename);
949 free(resource_filename);
950 }
952
953 /* Default favicon */
954 res = nsgdk_pixbuf_new_from_resname("favicon.png", &favicon_pixbuf);
955 if (res != NSERROR_OK) {
956 favicon_pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB,
957 false, 8, 16, 16);
958 }
959
960 /* add named icons to gtk theme */
962 if (res != NSERROR_OK) {
963 NSLOG(netsurf, INFO, "Unable to add named icons to GTK theme.");
964 return res;
965 }
966
967 /* initialise throbber */
968 res = nsgtk_throbber_init();
969 if (res != NSERROR_OK) {
970 NSLOG(netsurf, INFO, "Unable to initialise throbber.");
971 return res;
972 }
973
974 /* Initialise completions - cannot fail */
976
977 /* The tree view system needs to know the screen's DPI, so we
978 * find that out here, rather than when we create a first browser
979 * window.
980 */
981 browser_set_dpi(gdk_screen_get_resolution(gdk_screen_get_default()));
982 NSLOG(netsurf, INFO, "Set CSS DPI to %d", browser_get_dpi());
983
985 .layout = BITMAP_LAYOUT_ARGB8888,
986 .pma = true,
987 });
988
989 filepath_sfinddef(respath, buf, "mime.types", "/etc/");
991
993
994 urldb_load(nsoption_charp(url_file));
996 hotlist_init(nsoption_charp(hotlist_path),
997 nsoption_charp(hotlist_path));
998
999 /* Initialise top level UI elements */
1000 res = nsgtk_download_init();
1001 if (res != NSERROR_OK) {
1002 NSLOG(netsurf, INFO, "Unable to initialise download window.");
1003 return res;
1004 }
1005
1006 /* If there is a url specified on the command line use it */
1007 if (argc > 1) {
1008 struct stat fs;
1009 if (stat(argv[1], &fs) == 0) {
1010 size_t addrlen;
1011 char *rp = realpath(argv[1], NULL);
1012 assert(rp != NULL);
1013
1014 /* calculate file url length including terminator */
1015 addrlen = SLEN("file://") + strlen(rp) + 1;
1016 addr = malloc(addrlen);
1017 assert(addr != NULL);
1018 snprintf(addr, addrlen, "file://%s", rp);
1019 free(rp);
1020 } else {
1021 addr = strdup(argv[1]);
1022 }
1023 }
1024 if (addr != NULL) {
1025 /* managed to set up based on local launch */
1026 } else if (nsoption_charp(homepage_url) != NULL) {
1027 addr = strdup(nsoption_charp(homepage_url));
1028 } else {
1029 addr = strdup(NETSURF_HOMEPAGE);
1030 }
1031
1032 /* create an initial browser window */
1033 res = nsurl_create(addr, &url);
1034 if (res == NSERROR_OK) {
1036 url,
1037 NULL,
1038 NULL,
1039 NULL);
1040 nsurl_unref(url);
1041 }
1042
1043 free(addr);
1044
1045 return res;
1046}
1047
1048
1049/**
1050 * Run the gtk event loop.
1051 *
1052 * The same as the standard gtk_main loop except this ensures active
1053 * FD are added to the gtk poll event set.
1054 */
1055static void nsgtk_main(void)
1056{
1057 fd_set read_fd_set, write_fd_set, exc_fd_set;
1058 int max_fd;
1059 GPollFD *fd_list[1000];
1060 unsigned int fd_count;
1061
1062 while (!nsgtk_complete) {
1063 max_fd = -1;
1064 fd_count = 0;
1065 FD_ZERO(&read_fd_set);
1066 FD_ZERO(&write_fd_set);
1067 FD_ZERO(&exc_fd_set);
1068
1069 while (gtk_events_pending())
1070 gtk_main_iteration_do(TRUE);
1071
1072 schedule_run();
1073
1074 fetch_fdset(&read_fd_set, &write_fd_set, &exc_fd_set, &max_fd);
1075 for (int i = 0; i <= max_fd; i++) {
1076 if (FD_ISSET(i, &read_fd_set)) {
1077 GPollFD *fd = malloc(sizeof *fd);
1078 fd->fd = i;
1079 fd->events = G_IO_IN | G_IO_HUP | G_IO_ERR;
1080 g_main_context_add_poll(0, fd, 0);
1081 fd_list[fd_count++] = fd;
1082 }
1083 if (FD_ISSET(i, &write_fd_set)) {
1084 GPollFD *fd = malloc(sizeof *fd);
1085 fd->fd = i;
1086 fd->events = G_IO_OUT | G_IO_ERR;
1087 g_main_context_add_poll(0, fd, 0);
1088 fd_list[fd_count++] = fd;
1089 }
1090 if (FD_ISSET(i, &exc_fd_set)) {
1091 GPollFD *fd = malloc(sizeof *fd);
1092 fd->fd = i;
1093 fd->events = G_IO_ERR;
1094 g_main_context_add_poll(0, fd, 0);
1095 fd_list[fd_count++] = fd;
1096 }
1097 }
1098
1099 gtk_main_iteration();
1100
1101 for (unsigned int i = 0; i != fd_count; i++) {
1102 g_main_context_remove_poll(0, fd_list[i]);
1103 free(fd_list[i]);
1104 }
1105 }
1106}
1107
1108
1109/**
1110 * finalise the browser
1111 */
1112static void nsgtk_finalise(void)
1113{
1114 nserror res;
1115
1116 NSLOG(netsurf, INFO, "Quitting GUI");
1117
1118 /* Ensure all scaffoldings are destroyed before we go into exit */
1121 urldb_save(nsoption_charp(url_file));
1122
1123 res = nsgtk_cookies_destroy();
1124 if (res != NSERROR_OK) {
1125 NSLOG(netsurf, INFO, "Error finalising cookie viewer: %s",
1127 }
1128
1130 if (res != NSERROR_OK) {
1131 NSLOG(netsurf, INFO,
1132 "Error finalising local history viewer: %s",
1134 }
1135
1137 if (res != NSERROR_OK) {
1138 NSLOG(netsurf, INFO,
1139 "Error finalising global history viewer: %s",
1141 }
1142
1143 res = nsgtk_hotlist_destroy();
1144 if (res != NSERROR_OK) {
1145 NSLOG(netsurf, INFO, "Error finalising hotlist viewer: %s",
1147 }
1148
1149 res = hotlist_fini();
1150 if (res != NSERROR_OK) {
1151 NSLOG(netsurf, INFO, "Error finalising hotlist: %s",
1153 }
1154
1155 res = save_complete_finalise();
1156 if (res != NSERROR_OK) {
1157 NSLOG(netsurf, INFO, "Error finalising save complete: %s",
1159 }
1160
1161 free(nsgtk_config_home);
1162
1164
1165 /* common finalisation */
1166 netsurf_exit();
1167
1168 /* finalise options */
1170
1171 /* finalise logging */
1173
1174}
1175
1176
1177/**
1178 * Main entry point from OS.
1179 */
1180int main(int argc, char** argv)
1181{
1182 nserror res;
1183 char *cache_home = NULL;
1184 struct netsurf_table nsgtk_table = {
1186 .window = nsgtk_window_table,
1187 .clipboard = nsgtk_clipboard_table,
1188 .download = nsgtk_download_table,
1189 .fetch = nsgtk_fetch_table,
1190 .llcache = filesystem_llcache_table,
1191 .search = nsgtk_search_table,
1192 .search_web = nsgtk_search_web_table,
1193 .bitmap = nsgtk_bitmap_table,
1194 .layout = nsgtk_layout_table,
1195 };
1196
1197 res = netsurf_register(&nsgtk_table);
1198 if (res != NSERROR_OK) {
1199 fprintf(stderr,
1200 "NetSurf operation table failed registration (%s)\n",
1202 return 1;
1203 }
1204
1205 /* gtk specific initialisation */
1206 res = nsgtk_init(&argc, &argv, &cache_home);
1207 if (res != NSERROR_OK) {
1208 fprintf(stderr, "NetSurf gtk failed to initialise (%s)\n",
1210 return 2;
1211 }
1212
1213 /* core initialisation */
1214 res = netsurf_init(cache_home);
1215 free(cache_home);
1216 if (res != NSERROR_OK) {
1217 fprintf(stderr, "NetSurf core failed to initialise (%s)\n",
1219 return 3;
1220 }
1221
1222 /* gtk specific initalisation and main run loop */
1223 res = nsgtk_setup(argc, argv, respaths);
1224 if (res != NSERROR_OK) {
1226 fprintf(stderr, "NetSurf gtk setup failed (%s)\n",
1228 return 4;
1229 }
1230
1231 nsgtk_main();
1232
1234
1235 return 0;
1236}
nserror nsgtk_accelerator_init(char **respaths)
Definition: accelerator.c:41
int main(int argc, char **argv)
Normal entry point from OS.
Definition: gui.c:6528
#define PATH_MAX
Definition: gui.h:31
int schedule_run(void)
Process events up to current time.
Definition: schedule.c:137
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)
#define GDK_KEY(symbol)
Definition: compat.h:152
void nsgtk_completion_init(void)
initialise completion list store
Definition: completion.c:127
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.
Definition: fetch.c:385
Fetching of data from a URL (interface).
Unified cookie database public interface.
void urldb_save_cookies(const char *filename)
Save persistent cookies to file.
Definition: urldb.c:4448
void urldb_load_cookies(const char *filename)
Load a cookie file into the database.
Definition: urldb.c:4281
nserror hotlist_fini(void)
Finalise the hotlist.
Definition: hotlist.c:1388
nserror hotlist_init(const char *load_path, const char *save_path)
Initialise the hotlist.
Definition: hotlist.c:1290
nserror search_web_init(const char *provider_fname)
Initialise the web search operations.
Definition: searchweb.c:517
nserror search_web_select_provider(int selection)
Change the currently selected web search provider.
Definition: searchweb.c:397
nserror
Enumeration of error codes.
Definition: errors.h:29
@ NSERROR_PERMISSION
Permission error.
Definition: errors.h:58
@ NSERROR_NOT_FOUND
Requested item not found.
Definition: errors.h:34
@ NSERROR_BAD_PARAMETER
Bad Parameter.
Definition: errors.h:48
@ NSERROR_NOT_DIRECTORY
Missing directory.
Definition: errors.h:35
@ NSERROR_NOMEM
Memory exhaustion.
Definition: errors.h:32
@ NSERROR_OK
No error.
Definition: errors.h:30
char ** filepath_path_to_strvec(const char *path)
Convert a colon separated list of path elements into a string vector.
Definition: filepath.c:313
char * filepath_find(char **respathv, const char *filename)
Searches an array of resource paths for a file.
Definition: filepath.c:129
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.
Definition: filepath.c:152
void filepath_free_strvec(char **pathv)
Free a string vector.
Definition: filepath.c:356
char ** filepath_generate(char *const *pathv, const char *const *langv)
Merge two string vectors into a resource search path vector.
Definition: filepath.c:184
Utility routines to obtain paths to file resources.
struct gui_bitmap_table * nsgtk_bitmap_table
Definition: bitmap.c:294
void nsgtk_download_destroy(void)
Destroy download window.
Definition: download.c:1026
nserror nsgtk_download_init(void)
Initialise download window ready for use.
Definition: download.c:934
struct gui_download_table * nsgtk_download_table
download operation table for gtk
Definition: download.c:930
void gtk_fetch_filetype_fin(void)
Definition: fetch.c:179
void gtk_fetch_filetype_init(const char *mimefile)
Definition: fetch.c:60
struct gui_fetch_table * nsgtk_fetch_table
Definition: fetch.c:273
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.
Definition: hotlist.c:396
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
Definition: print.c:50
struct gui_search_table * nsgtk_search_table
Definition: search.c:221
free text page search for gtk interface
struct gui_clipboard_table * nsgtk_clipboard_table
Definition: selection.c:97
nserror nsgtk_cookies_destroy(void)
Free any resources allocated for the cookie window.
Definition: cookies.c:326
Cookies (interface).
static void nsgtk_main(void)
Run the gtk event loop.
Definition: gui.c:1055
char ** respaths
resource search path vector
Definition: gui.c:91
static nserror create_config_home(char **config_home_out)
Definition: gui.c:421
GdkPixbuf * win_default_icon_pixbuf
default window icon pixbuf
Definition: gui.c:86
GtkBuilder * warning_builder
Definition: gui.c:88
bool nsgtk_complete
set when no windows remain open.
Definition: gui.c:77
static nserror nsgtk_init(int *pargc, char ***pargv, char **cache_home)
GTK specific initialisation.
Definition: gui.c:763
static nserror set_defaults(struct nsoption_s *defaults)
Set option defaults for gtk frontend.
Definition: gui.c:490
nserror nsgtk_warning(const char *warning, const char *detail)
Warn the user of an event.
Definition: gui.c:95
static bool nslog_stream_configure(FILE *fptr)
Ensures output logging stream is correctly configured.
Definition: gui.c:475
static nserror nsgtk_messages_init(char **respaths)
initialise message translation
Definition: gui.c:636
static nserror nsgtk_add_named_icons_to_theme(void)
adds named icons into gtk theme
Definition: gui.c:879
static nserror check_dirname(const char *path, const char *leaf, char **dirname_out)
create directory name and check it is acessible and a directory.
Definition: gui.c:318
static nserror get_cache_home(char **cache_home_out)
Get the path to the cache directory.
Definition: gui.c:663
GdkPixbuf * favicon_pixbuf
favicon default pixbuf
Definition: gui.c:83
char * nsgtk_config_home
Directory where all configuration files are held.
Definition: gui.c:80
static nserror add_builtin_icon(const char *prefix, const char *name, int x, int y)
Definition: gui.c:849
static void nsgtk_finalise(void)
finalise the browser
Definition: gui.c:1112
static nserror create_cache_home(char **cache_home_out)
create a cache directory
Definition: gui.c:709
static nserror nsgtk_setup(int argc, char **argv, char **respath)
setup GTK specific parts of the browser.
Definition: gui.c:910
uint32_t gtk_gui_gdkkey_to_nskey(GdkEventKey *key)
input conversion.
Definition: gui.c:121
static char ** nsgtk_init_resource_path(const char *config_home)
Create an array of valid paths to search for resources.
Definition: gui.c:265
static nserror nsgtk_option_init(int *pargc, char **argv)
Initialise user options.
Definition: gui.c:596
static nserror get_config_home(char **config_home_out)
Get the path to the config directory.
Definition: gui.c:359
struct gui_misc_table * nsgtk_misc_table
Definition: misc.c:192
nserror nsgtk_throbber_init(void)
Initialise global throbber context.
Definition: throbber.c:46
struct gui_window_table * nsgtk_window_table
Definition: window.c:1608
struct gui_search_web_table * nsgtk_search_web_table
Definition: window.c:1581
char * realpath(const char *f, char *buf)
Definition: gui.cpp:230
Generic bitmap handling interface.
void bitmap_set_format(const bitmap_fmt_t *bitmap_format)
Set client bitmap format.
Definition: bitmap.c:118
@ BITMAP_LAYOUT_ARGB8888
32-bit ARGB (0xAARRGGBB).
Definition: bitmap.h:83
Browser interfaces.
int browser_get_dpi(void)
Get the browser DPI.
Definition: browser.c:45
nserror browser_set_dpi(int dpi)
Set the DPI of the browser.
Definition: browser.c:32
Interface to key press operations.
@ NS_KEY_DELETE_WORD_RIGHT
Definition: keypress.h:64
@ NS_KEY_REDO
Definition: keypress.h:71
@ NS_KEY_DELETE_LINE_START
Definition: keypress.h:68
@ NS_KEY_LINE_START
Definition: keypress.h:57
@ NS_KEY_RIGHT
Definition: keypress.h:51
@ NS_KEY_DELETE_WORD_LEFT
Definition: keypress.h:62
@ NS_KEY_LEFT
Definition: keypress.h:50
@ NS_KEY_SELECT_ALL
Definition: keypress.h:32
@ NS_KEY_PASTE
Definition: keypress.h:43
@ NS_KEY_TAB
Definition: keypress.h:36
@ NS_KEY_COPY_SELECTION
Definition: keypress.h:33
@ NS_KEY_DOWN
Definition: keypress.h:53
@ NS_KEY_CUT_SELECTION
Definition: keypress.h:44
@ NS_KEY_WORD_LEFT
Definition: keypress.h:61
@ NS_KEY_DELETE_LINE_END
Definition: keypress.h:67
@ NS_KEY_PAGE_UP
Definition: keypress.h:65
@ NS_KEY_PAGE_DOWN
Definition: keypress.h:66
@ NS_KEY_UNDO
Definition: keypress.h:70
@ NS_KEY_TEXT_START
Definition: keypress.h:59
@ NS_KEY_LINE_END
Definition: keypress.h:58
@ NS_KEY_TEXT_END
Definition: keypress.h:60
@ NS_KEY_DELETE_RIGHT
Definition: keypress.h:55
@ NS_KEY_WORD_RIGHT
Definition: keypress.h:63
@ NS_KEY_DELETE_LINE
Definition: keypress.h:42
@ NS_KEY_DELETE_LEFT
Definition: keypress.h:35
@ NS_KEY_UP
Definition: keypress.h:52
@ NS_KEY_ESCAPE
Definition: keypress.h:47
struct gui_layout_table * nsgtk_layout_table
Definition: layout_pango.c:309
Interface to GTK layout handling using pango.
nserror nslog_init(nslog_ensure_t *ensure, int *pargc, char **argv)
Initialise the logging system.
Definition: log.c:190
void nslog_finalise(void)
Shut down the logging system.
Definition: log.c:299
#define NSLOG(catname, level, logmsg, args...)
Definition: log.h:116
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.
Definition: messages.c:190
nserror messages_add_from_file(const char *path)
Read keys and values from messages file into the standard Messages hash.
Definition: messages.c:177
const char * messages_get_errorcode(nserror code)
lookup of a message by errorcode from the standard Messages hash.
Definition: messages.c:248
const char * messages_get(const char *key)
Fast lookup of a message by key from the standard Messages hash.
Definition: messages.c:241
Localised message support (interface).
NetSurf core interface registration, construction and destruction.
void netsurf_exit(void)
Finalise NetSurf core.
Definition: netsurf.c:232
nserror netsurf_init(const char *store_path)
Initialise netsurf core.
Definition: netsurf.c:107
nserror netsurf_register(struct netsurf_table *table)
Register operation table.
Definition: gui_factory.c:707
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.
Definition: nsurl.h:31
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 UI resource table.
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
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.
Bitmap format specifier.
Definition: bitmap.h:95
NetSurf operation function table.
Definition: gui_table.h:48
struct gui_misc_table * misc
Browser table.
Definition: gui_table.h:57
Unified URL information database public interface.
nserror urldb_save(const char *filename)
Export the current database to file.
Definition: urldb.c:3094
nserror urldb_load(const char *filename)
Import an URL database from file, replacing any existing database.
Definition: urldb.c:2876
nserror netsurf_mkdir_all(const char *fname)
Ensure that all directory elements needed to store a filename exist.
Definition: file.c:313
nserror netsurf_mkpath(char **str, size_t *size, size_t nelm,...)
Generate a path from one or more component elemnts.
Definition: file.c:288
Default operations table for files.
struct nsoption_s * nsoptions_default
global default option table.
Definition: nsoption.c:46
static struct nsoption_s defaults[]
The table of compiled in default options.
Definition: nsoption.c:64
nserror nsoption_read(const char *path, struct nsoption_s *opts)
Read choices file and set them in the passed table.
Definition: nsoption.c:717
struct nsoption_s * nsoptions
global active option table.
Definition: nsoption.c:45
nserror nsoption_commandline(int *pargc, char **argv, struct nsoption_s *opts)
Process commandline and set options approriately.
Definition: nsoption.c:824
nserror nsoption_init(nsoption_set_default_t *set_defaults, struct nsoption_s **popts, struct nsoption_s **pdefs)
Initialise option system.
Definition: nsoption.c:629
nserror nsoption_finalise(struct nsoption_s *opts, struct nsoption_s *defs)
Finalise option system.
Definition: nsoption.c:684
Option reading and saving interface.
#define nsoption_charp(OPTION)
Get the value of a string option.
Definition: nsoption.h:297
#define nsoption_setnull_charp(OPTION, VALUE)
set string option in default table if currently unset
Definition: nsoption.h:342
#define nsoption_int(OPTION)
Get the value of an integer option.
Definition: nsoption.h:279
#define nsoption_set_int(OPTION, VALUE)
set an integer option in the default table
Definition: nsoption.h:314
#define nsoption_set_charp(OPTION, VALUE)
set string option in default table
Definition: nsoption.h:338
Interface to a number of general purpose functionality.
#define SLEN(x)
Calculate length of constant C string.
Definition: utils.h:84
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.
Definition: plot.c:821