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