]> spindle.queued.net Git - midori/commitdiff
Provide default search engines
authorChristian Dywan <christian@twotoasts.de>
Sat, 31 Jan 2009 18:07:27 +0000 (19:07 +0100)
committerChristian Dywan <christian@twotoasts.de>
Sat, 31 Jan 2009 18:07:27 +0000 (19:07 +0100)
data/search [new file with mode: 0644]
midori/main.c
wscript

diff --git a/data/search b/data/search
new file mode 100644 (file)
index 0000000..b650d9f
--- /dev/null
@@ -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
index 96df6faef56bd5391486edf3b9d61a246de65b28..8f4c6bb1aa6c95a208aa673c02bcfdcc1bc1039b 100644 (file)
@@ -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 70def3c46260fa6289871665913d866aedca1453..96dde91b617f709218cf237d4a8423ec3fabfefc 100644 (file)
--- 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):