diff options
author | Rodrigo Arias Mallo <rodarima@gmail.com> | 2024-06-09 00:41:02 +0200 |
---|---|---|
committer | Rodrigo Arias Mallo <rodarima@gmail.com> | 2024-06-09 12:06:19 +0200 |
commit | d8cc59e18d6bf90c91e5d9cf1f9c36587f4ab26c (patch) | |
tree | f004320e757660cbefb02559ea7a902575c84e1c /src | |
parent | e89a2293ebb3331dca46f5edf0108231b1007402 (diff) |
Add new_tab_page option
Adds support to load a custom page when a new tab is opened. The current
behavior is set as the default, load a blank page. The location bar is
only selected when the new tab page is the blank page, otherwise the
page loaded gets the focus.
Co-authored-by: Alex <a1ex@dismail.de>
Fixes: https://github.com/dillo-browser/dillo/issues/124
Diffstat (limited to 'src')
-rw-r--r-- | src/prefs.c | 3 | ||||
-rw-r--r-- | src/prefs.h | 1 | ||||
-rw-r--r-- | src/prefsparser.cc | 1 | ||||
-rw-r--r-- | src/uicmd.cc | 5 | ||||
-rw-r--r-- | src/url.c | 5 |
5 files changed, 14 insertions, 1 deletions
diff --git a/src/prefs.c b/src/prefs.c index 8d25ef18..e7f735ed 100644 --- a/src/prefs.c +++ b/src/prefs.c @@ -14,6 +14,7 @@ #define PREFS_START_PAGE "about:splash" #define PREFS_HOME "https://dillo-browser.github.io/" +#define PREFS_NEW_TAB_PAGE "about:blank" #define PREFS_FONT_SERIF "DejaVu Serif" #define PREFS_FONT_SANS_SERIF "DejaVu Sans" #define PREFS_FONT_CURSIVE "DejaVu Sans" @@ -110,6 +111,7 @@ void a_Prefs_init(void) prefs.show_ui_tooltip = TRUE; prefs.small_icons = FALSE; prefs.start_page = a_Url_new(PREFS_START_PAGE, NULL); + prefs.new_tab_page = a_Url_new(PREFS_NEW_TAB_PAGE, NULL); prefs.theme = dStrdup(PREFS_THEME); prefs.ui_button_highlight_color = -1; prefs.ui_fg_color = -1; @@ -155,5 +157,6 @@ void a_Prefs_freeall(void) dFree(dList_nth_data(prefs.search_urls, i)); dList_free(prefs.search_urls); a_Url_free(prefs.start_page); + a_Url_free(prefs.new_tab_page); dFree(prefs.theme); } diff --git a/src/prefs.h b/src/prefs.h index b234176f..97bdecf7 100644 --- a/src/prefs.h +++ b/src/prefs.h @@ -48,6 +48,7 @@ typedef struct { char *no_proxy; DilloUrl *start_page; DilloUrl *home; + DilloUrl *new_tab_page; bool_t allow_white_bg; int32_t white_bg_replacement; int32_t bg_color; diff --git a/src/prefsparser.cc b/src/prefsparser.cc index 40460e52..8755890c 100644 --- a/src/prefsparser.cc +++ b/src/prefsparser.cc @@ -171,6 +171,7 @@ void PrefsParser::parse(FILE *fp) { "fullwindow_start", &prefs.fullwindow_start, PREFS_BOOL, 0 }, { "geometry", NULL, PREFS_GEOMETRY, 0 }, { "home", &prefs.home, PREFS_URL, 0 }, + { "new_tab_page", &prefs.new_tab_page, PREFS_URL, 0 }, { "http_language", &prefs.http_language, PREFS_STRING, 0 }, { "http_max_conns", &prefs.http_max_conns, PREFS_INT32, 0 }, { "http_persistent_conns", &prefs.http_persistent_conns, PREFS_BOOL, 0 }, diff --git a/src/uicmd.cc b/src/uicmd.cc index 88bc9b7d..d7822e47 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -770,6 +770,11 @@ void a_UIcmd_open_url(BrowserWindow *bw, const DilloUrl *url) static void UIcmd_open_url_nbw(BrowserWindow *new_bw, const DilloUrl *url) { + if (!url && prefs.new_tab_page) { + if (strcmp(URL_STR(prefs.new_tab_page), "about:blank") != 0) + url = prefs.new_tab_page; + } + /* When opening a new BrowserWindow (tab or real window) we focus * Location if we don't yet have an URL, main otherwise. */ @@ -2,6 +2,7 @@ * File: url.c * * Copyright (C) 2001-2009 Jorge Arellano Cid <jcid@dillo.org> + * Copyright (C) 2024 Rodrigo Arias Mallo <rodarima@gmail.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -374,7 +375,9 @@ DilloUrl* a_Url_new(const char *url_str, const char *base_url) Dstr *SolvedUrl; int i, n_ic, n_ic_spc; - dReturn_val_if_fail (url_str != NULL, NULL); + /* NULL or empty URL is not valid */ + if (!url_str || url_str[0] == '\0') + return NULL; /* Count illegal characters (0x00-0x1F, 0x7F-0xFF and space) */ n_ic = n_ic_spc = 0; |