NetSurf
|
#include <assert.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <gtk/gtk.h>
#include "utils/filepath.h"
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/utils.h"
#include "utils/file.h"
#include "utils/nsoption.h"
#include "netsurf/keypress.h"
#include "netsurf/url_db.h"
#include "netsurf/cookie_db.h"
#include "netsurf/browser.h"
#include "netsurf/browser_window.h"
#include "netsurf/netsurf.h"
#include "netsurf/bitmap.h"
#include "content/fetch.h"
#include "content/backing_store.h"
#include "desktop/save_complete.h"
#include "desktop/searchweb.h"
#include "desktop/hotlist.h"
#include "gtk/compat.h"
#include "gtk/warn.h"
#include "gtk/completion.h"
#include "gtk/cookies.h"
#include "gtk/download.h"
#include "gtk/fetch.h"
#include "gtk/gui.h"
#include "gtk/local_history.h"
#include "gtk/global_history.h"
#include "gtk/hotlist.h"
#include "gtk/throbber.h"
#include "gtk/toolbar_items.h"
#include "gtk/scaffolding.h"
#include "gtk/window.h"
#include "gtk/corewindow.h"
#include "gtk/schedule.h"
#include "gtk/selection.h"
#include "gtk/search.h"
#include "gtk/bitmap.h"
#include "gtk/misc.h"
#include "gtk/resources.h"
#include "gtk/layout_pango.h"
#include "gtk/accelerator.h"
Go to the source code of this file.
Functions | |
nserror | nsgtk_warning (const char *warning, const char *detail) |
Warn the user of an event. More... | |
uint32_t | gtk_gui_gdkkey_to_nskey (GdkEventKey *key) |
input conversion. More... | |
static char ** | nsgtk_init_resource_path (const char *config_home) |
Create an array of valid paths to search for resources. More... | |
static nserror | check_dirname (const char *path, const char *leaf, char **dirname_out) |
create directory name and check it is acessible and a directory. More... | |
static nserror | get_config_home (char **config_home_out) |
Get the path to the config directory. More... | |
static nserror | create_config_home (char **config_home_out) |
static bool | nslog_stream_configure (FILE *fptr) |
Ensures output logging stream is correctly configured. More... | |
static nserror | set_defaults (struct nsoption_s *defaults) |
Set option defaults for gtk frontend. More... | |
static nserror | nsgtk_option_init (int *pargc, char **argv) |
Initialise user options. More... | |
static nserror | nsgtk_messages_init (char **respaths) |
initialise message translation More... | |
static nserror | get_cache_home (char **cache_home_out) |
Get the path to the cache directory. More... | |
static nserror | create_cache_home (char **cache_home_out) |
create a cache directory More... | |
static nserror | nsgtk_init (int *pargc, char ***pargv, char **cache_home) |
GTK specific initialisation. More... | |
static nserror | add_builtin_icon (const char *prefix, const char *name, int x, int y) |
static nserror | nsgtk_add_named_icons_to_theme (void) |
adds named icons into gtk theme More... | |
static nserror | nsgtk_setup (int argc, char **argv, char **respath) |
setup GTK specific parts of the browser. More... | |
static void | nsgtk_main (void) |
Run the gtk event loop. More... | |
static void | nsgtk_finalise (void) |
finalise the browser More... | |
int | main (int argc, char **argv) |
Main entry point from OS. More... | |
Variables | |
bool | nsgtk_complete = false |
set when no windows remain open. More... | |
char * | nsgtk_config_home |
Directory where all configuration files are held. More... | |
GdkPixbuf * | favicon_pixbuf |
favicon default pixbuf More... | |
GdkPixbuf * | win_default_icon_pixbuf |
default window icon pixbuf More... | |
GtkBuilder * | warning_builder |
char ** | respaths |
resource search path vector More... | |
|
static |
Definition at line 850 of file gui.c.
References NSERROR_NOMEM, NSERROR_OK, nsgdk_pixbuf_new_from_resname(), and NSLOG.
Referenced by nsgtk_add_named_icons_to_theme().
|
static |
create directory name and check it is acessible and a directory.
Definition at line 319 of file gui.c.
References netsurf_mkpath(), NSERROR_NOT_DIRECTORY, NSERROR_NOT_FOUND, NSERROR_OK, NSERROR_PERMISSION, and path().
Referenced by get_cache_home(), and get_config_home().
|
static |
create a cache directory
Definition at line 710 of file gui.c.
References netsurf_mkdir_all(), netsurf_mkpath(), NSERROR_NOT_DIRECTORY, NSERROR_OK, and NSLOG.
Referenced by nsgtk_init().
|
static |
Definition at line 422 of file gui.c.
References netsurf_mkdir_all(), netsurf_mkpath(), NSERROR_NOT_DIRECTORY, NSERROR_OK, and NSLOG.
Referenced by nsgtk_init().
|
static |
Get the path to the cache directory.
cache_home_out | Path to cache directory. |
Definition at line 664 of file gui.c.
References check_dirname(), NSERROR_NOT_DIRECTORY, NSERROR_OK, and NSLOG.
Referenced by nsgtk_init().
|
static |
Get the path to the config directory.
config_home_out | Path to configuration directory. |
Definition at line 360 of file gui.c.
References check_dirname(), NSERROR_NOT_DIRECTORY, NSERROR_OK, and NSLOG.
Referenced by nsgtk_init().
uint32_t gtk_gui_gdkkey_to_nskey | ( | GdkEventKey * | key | ) |
input conversion.
Definition at line 122 of file gui.c.
References GDK_KEY, NS_KEY_COPY_SELECTION, NS_KEY_CUT_SELECTION, NS_KEY_DELETE_LEFT, NS_KEY_DELETE_LINE, NS_KEY_DELETE_LINE_END, NS_KEY_DELETE_LINE_START, NS_KEY_DELETE_RIGHT, NS_KEY_DELETE_WORD_LEFT, NS_KEY_DELETE_WORD_RIGHT, NS_KEY_DOWN, NS_KEY_ESCAPE, NS_KEY_LEFT, NS_KEY_LINE_END, NS_KEY_LINE_START, NS_KEY_PAGE_DOWN, NS_KEY_PAGE_UP, NS_KEY_PASTE, NS_KEY_REDO, NS_KEY_RIGHT, NS_KEY_SELECT_ALL, NS_KEY_TAB, NS_KEY_TEXT_END, NS_KEY_TEXT_START, NS_KEY_UNDO, NS_KEY_UP, NS_KEY_WORD_LEFT, and NS_KEY_WORD_RIGHT.
Referenced by nsgtk_cw_keypress_event(), and nsgtk_window_keypress_event().
int main | ( | int | argc, |
char ** | argv | ||
) |
Main entry point from OS.
Normal entry point from OS.
Definition at line 1181 of file gui.c.
References filesystem_llcache_table, messages_get_errorcode(), netsurf_table::misc, netsurf_init(), netsurf_register(), NSERROR_OK, nsgtk_bitmap_table, nsgtk_clipboard_table, nsgtk_core_window_table, nsgtk_download_table, nsgtk_fetch_table, nsgtk_finalise(), nsgtk_init(), nsgtk_layout_table, nsgtk_main(), nsgtk_misc_table, nsgtk_search_table, nsgtk_search_web_table, nsgtk_setup(), nsgtk_window_table, and respaths.
|
static |
adds named icons into gtk theme
Definition at line 880 of file gui.c.
References add_builtin_icon(), and NSERROR_OK.
Referenced by nsgtk_setup().
|
static |
finalise the browser
Definition at line 1113 of file gui.c.
References gtk_fetch_filetype_fin(), hotlist_fini(), messages_get_errorcode(), netsurf_exit(), NSERROR_OK, nsgtk_config_home, nsgtk_cookies_destroy(), nsgtk_download_destroy(), nsgtk_global_history_destroy(), nsgtk_hotlist_destroy(), nsgtk_local_history_destroy(), NSLOG, nslog_finalise(), nsoption_charp, nsoption_finalise(), nsoptions, nsoptions_default, save_complete_finalise(), urldb_save(), and urldb_save_cookies().
Referenced by main().
|
static |
GTK specific initialisation.
Definition at line 764 of file gui.c.
References create_cache_home(), create_config_home(), get_cache_home(), get_config_home(), messages_get_errorcode(), NSERROR_NOT_FOUND, NSERROR_OK, nsgtk_config_home, nsgtk_init_resource_path(), nsgtk_init_resources(), nsgtk_messages_init(), nsgtk_option_init(), NSLOG, nslog_init(), nslog_stream_configure(), and respaths.
Referenced by main().
|
static |
Create an array of valid paths to search for resources.
The idea is that all the complex path computation to find resources is performed here, once, rather than every time a resource is searched for.
Definition at line 266 of file gui.c.
References filepath_free_strvec(), filepath_generate(), and filepath_path_to_strvec().
Referenced by nsgtk_init().
|
static |
Run the gtk event loop.
The same as the standard gtk_main loop except this ensures active FD are added to the gtk poll event set.
Definition at line 1056 of file gui.c.
References fetch_fdset(), nsgtk_complete, and schedule_run().
Referenced by main().
|
static |
initialise message translation
Definition at line 637 of file gui.c.
References messages_add_from_file(), messages_add_from_inline(), NSERROR_OK, nsgtk_data_from_resname(), and nsgtk_path_from_resname().
Referenced by nsgtk_init().
|
static |
Initialise user options.
Initialise the browser configuration options. These are set by:
Definition at line 597 of file gui.c.
References netsurf_mkpath(), NSERROR_OK, nsgtk_config_home, nsoption_commandline(), nsoption_init(), nsoption_int, nsoption_read(), nsoption_set_int, nsoptions, nsoptions_default, and set_defaults().
Referenced by nsgtk_init().
|
static |
setup GTK specific parts of the browser.
argc | The number of arguments on the command line |
argv | A string vector of command line arguments. \respath A string vector of the path elements of resources |
Definition at line 911 of file gui.c.
References BITMAP_LAYOUT_ARGB8888, bitmap_set_format(), browser_get_dpi(), browser_set_dpi(), browser_window_create(), BW_CREATE_HISTORY, favicon_pixbuf, filepath_find(), filepath_sfinddef(), gtk_fetch_filetype_init(), hotlist_init(), NSERROR_OK, nsgdk_pixbuf_new_from_resname(), nsgtk_accelerator_init(), nsgtk_add_named_icons_to_theme(), nsgtk_builder_new_from_resname(), nsgtk_completion_init(), nsgtk_download_init(), nsgtk_throbber_init(), NSLOG, nsoption_charp, nsurl_create(), nsurl_unref(), PATH_MAX, realpath(), respaths, save_complete_init(), search_web_init(), search_web_select_provider(), SLEN, urldb_load(), urldb_load_cookies(), warning_builder, and win_default_icon_pixbuf.
Referenced by main().
nserror nsgtk_warning | ( | const char * | warning, |
const char * | detail | ||
) |
Warn the user of an event.
[in] | warning | A warning looked up in the message translation table |
[in] | detail | Additional text to be displayed or NULL. |
Definition at line 96 of file gui.c.
References messages_get(), NSERROR_OK, NSLOG, and warning_builder.
Referenced by about_open(), contents_button_clicked_cb(), customisation_toolbar_drag_drop_cb(), debugboxtree_button_clicked_cb(), debugdomtree_button_clicked_cb(), editor_init(), gui_launch_url(), gui_window_create(), guide_button_clicked_cb(), home_button_clicked_cb(), info_button_clicked_cb(), newtab_button_clicked_cb(), newwindow_button_clicked_cb(), nsgtk_completion_match_select(), nsgtk_download_dialog_show(), nsgtk_menu_developer_submenu(), nsgtk_menu_edit_submenu(), nsgtk_menu_export_submenu(), nsgtk_menu_file_submenu(), nsgtk_menu_help_submenu(), nsgtk_menu_nav_submenu(), nsgtk_menu_scaleview_submenu(), nsgtk_menu_tabs_submenu(), nsgtk_menu_toolbars_submenu(), nsgtk_menu_tools_submenu(), nsgtk_menu_view_submenu(), nsgtk_on_link_opentab_activate_menu(), nsgtk_on_link_openwin_activate_menu(), nsgtk_on_savelink_activate_menu(), openfile_button_clicked_cb(), print_button_clicked_cb(), savepage_button_clicked_cb(), tab_init(), url_entry_activate_cb(), viewsource_button_clicked_cb(), and websearch_entry_activate_cb().
|
static |
Ensures output logging stream is correctly configured.
Definition at line 476 of file gui.c.
Referenced by nsgtk_init().
|
static |
Set option defaults for gtk frontend.
defaults | The option table to update. |
Definition at line 491 of file gui.c.
References netsurf_mkpath(), NSERROR_BAD_PARAMETER, NSERROR_OK, nsgtk_config_home, NSLOG, nsoption_charp, nsoption_set_charp, nsoption_set_int, nsoption_setnull_charp, and settings.
Referenced by nsgtk_option_init().
GdkPixbuf* favicon_pixbuf |
favicon default pixbuf
Definition at line 84 of file gui.c.
Referenced by cutomize_button_clicked_cb(), gui_window_create(), gui_window_set_icon(), and nsgtk_setup().
bool nsgtk_complete = false |
set when no windows remain open.
Definition at line 78 of file gui.c.
Referenced by nsgtk_main(), and scaffolding_window_destroy().
char* nsgtk_config_home |
Directory where all configuration files are held.
Definition at line 81 of file gui.c.
Referenced by nsgtk_finalise(), nsgtk_init(), nsgtk_option_init(), nsgtk_preferences_dialogPreferences_deleteevent(), nsgtk_preferences_dialogPreferences_destroy(), nsgtk_preferences_dialogPreferences_response(), nsgtk_toolbar_customisation_save(), print_button_clicked_cb(), savewindowsize_button_clicked_cb(), and set_defaults().
char** respaths |
resource search path vector
Definition at line 92 of file gui.c.
Referenced by main(), nsgtk_init(), and nsgtk_setup().
GtkBuilder* warning_builder |
Definition at line 89 of file gui.c.
Referenced by nsgtk_setup(), and nsgtk_warning().
GdkPixbuf* win_default_icon_pixbuf |