From 135b1be01e2b4e6d8dfaf1f721e18ab1703eeeed Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Sat, 31 Jan 2009 19:07:27 +0100 Subject: [PATCH] Provide default search engines --- data/search | 21 +++++++++++++++++++++ midori/main.c | 27 ++++++++++++++++++++++++--- wscript | 6 +++++- 3 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 data/search diff --git a/data/search b/data/search new file mode 100644 index 00000000..b650d9f9 --- /dev/null +++ b/data/search @@ -0,0 +1,21 @@ + +[Google] +name=Google +text=Web Search +uri=http://www.google.com/search?q=%s +icon= +token=g + +[Wikipedia] +name=Wikipedia +text=The free encyclopedia +uri=http://en.wikipedia.org/wiki/%s +icon= +token=wp + +[TheFreeDictionary] +name=The Free Dictionary +text=Dictionary, Encyclopedia and Thesaurus +uri=http://www.thefreedictionary.com/%s +icon= +token=fd diff --git a/midori/main.c b/midori/main.c index 96df6fae..8f4c6bb1 100644 --- a/midori/main.c +++ b/midori/main.c @@ -2166,13 +2166,34 @@ main (int argc, katze_assign (config_file, build_config_filename ("search")); error = NULL; search_engines = search_engines_new_from_file (config_file, &error); - if (error) + if (!error && katze_array_is_empty (search_engines)) + { + const gchar* const * config_dirs = g_get_system_config_dirs (); + i = 0; + while (config_dirs[i]) + { + g_object_unref (search_engines); + katze_assign (config_file, + g_build_filename (config_dirs[i], PACKAGE_NAME, "search", NULL)); + search_engines = search_engines_new_from_file (config_file, NULL); + if (!katze_array_is_empty (search_engines)) + continue; + i++; + } + if (katze_array_is_empty (search_engines)) + { + g_object_unref (search_engines); + katze_assign (config_file, + g_build_filename (SYSCONFDIR, "xdg", PACKAGE_NAME, "search", NULL)); + search_engines = search_engines_new_from_file (config_file, NULL); + } + } + else if (error) { - /* FIXME: We may have a "file empty" error, how do we recognize that? if (error->code != G_FILE_ERROR_NOENT) g_string_append_printf (error_messages, _("The search engines couldn't be loaded. %s\n"), - error->message); */ + error->message); g_error_free (error); } bookmarks = katze_array_new (KATZE_TYPE_ARRAY); diff --git a/wscript b/wscript index 70def3c4..96dde91b 100644 --- a/wscript +++ b/wscript @@ -86,9 +86,10 @@ def configure (conf): nls = 'no ' conf.define ('ENABLE_NLS', [0,1][nls == 'yes']) - dirname_default ('LIBDIR', os.path.join (conf.env['PREFIX'], 'lib')) dirname_default ('DATADIR', os.path.join (conf.env['PREFIX'], 'share')) dirname_default ('DOCDIR', os.path.join (conf.env['DATADIR'], 'doc')) + dirname_default ('LIBDIR', os.path.join (conf.env['PREFIX'], 'lib')) + dirname_default ('SYSCONFDIR', os.path.join (conf.env['PREFIX'], 'etc')) if option_enabled ('apidocs'): conf.find_program ('gtkdoc-scan', var='GTKDOC_SCAN') @@ -291,6 +292,9 @@ def build (bld): bld.install_files ('${DOCDIR}/' + APPNAME + '/', \ 'AUTHORS ChangeLog COPYING EXPAT README TRANSLATE') + # Install default configuration + bld.install_files ('${SYSCONFDIR}/xdg/' + APPNAME + '/', 'data/search') + if bld.env['RST2HTML']: # FIXME: Build only if needed if not os.access (blddir, os.F_OK): -- 2.39.5