private Gtk.Alignment InteriorOverlay;
public PluginManager Plugins;
+ public SearchHandler Search;
[DllImport ("SoupSettings.dll")]
private static extern void soup_settings();
Plugins = new PluginManager(this);
Plugins.Load();
+ // Load Search Handlers
+ Search = new SearchHandler(this);
+
// Create a new, default WebThingView if one has not already
// been created.
if (Tabs.NPages == 0)
- OpenUriTab("http://dominionofawesome.com/");
+ OpenTab("http://dominionofawesome.com/");
WebView.GrabFocus();
Application.Run();
}
// Uri loading
- public string FixUri(string Uri) {
- if (!Regex.IsMatch(Uri, @"://")) {
- return String.Format("http://{0}", Uri);
+ private string GetUri(string query) {
+ Uri u;
+ try {
+ u = new Uri(query);
+ return u.ToString();
+ } catch(UriFormatException) {
+ try {
+ u = new Uri(String.Format("http://{0}", query));
+ return u.ToString();
+ } catch (UriFormatException) {
+ return Search.Transform(query);
+ }
}
- return Uri;
}
- public void OpenUri(string Uri) {
- wv.Open(FixUri(Uri));
+ public bool Open(string query) {
+ string uri = GetUri(query);
+ if (uri == null) return false;
+
+ wv.Open(uri);
+ return true;
}
- public void OpenUriTab(string Uri) {
+ public bool OpenTab(string query) {
WebThingView wtv = NewTab();
- wtv.WebView.Open(FixUri(Uri));
+ string uri = GetUri(query);
+ if (uri == null) return false;
+
+ wtv.WebView.Open(uri);
+ return true;
}
}
}