Fixed #374055:Only the first "tag" is detected in digikam.
[beagle.git] / Best / Best.cs
blob2c9d2f33d72101846dfab69b31b7816b7b7ba1b7
1 //
2 // Best.cs
3 // Bleeding Edge Search Tool: Beagle search GUI
4 //
5 // Nat Friedman <nat@novell.com>
6 //
7 // Copyright (C) 2004 Novell, Inc.
8 //
10 using System;
12 using Gtk;
13 using GtkSharp;
14 using Gnome;
16 using Mono.Unix;
18 using Beagle;
19 using Beagle.Util;
21 namespace Best {
23 class Best {
25 static public string DefaultWindowTitle = "Beagle Search (beta)";
27 static void PrintUsageAndExit ()
29 string usage =
30 "best: GUI interface to the Beagle search system.\n" +
31 "Web page: http://www.gnome.org/projects/beagle\n" +
32 "Copyright (C) 2004-2005 Novell, Inc.\n\n";
34 usage +=
35 "Usage: best [OPTIONS] [<query string>]\n\n" +
36 "Options:\n" +
37 " --no-tray\t\t\tDo not create a notification area applet.\n" +
38 " --show-window\t\t\tDisplay a search window.\n" +
39 " --help\t\t\tPrint this usage message.\n";
41 Console.WriteLine (usage);
43 System.Environment.Exit (0);
46 static string query = "";
47 static bool doTray = true;
48 static bool showWindow = false;
49 static bool autostarted = false;
51 static void ParseArgs (String[] args)
53 int i = 0;
54 while (i < args.Length) {
55 switch (args [i]) {
56 case "--no-tray":
57 doTray = false;
58 break;
60 case "--show-window":
61 showWindow = true;
62 break;
64 case "--help":
65 case "--usage":
66 PrintUsageAndExit ();
67 return;
69 // Ignore session management
70 case "--sm-config-prefix":
71 case "--sm-client-id":
72 case "--screen":
73 // These all take an argument, so
74 // increment i
75 i++;
76 break;
78 case "--autostarted":
79 if (! Conf.Searching.Autostart){
80 Console.WriteLine ("Autostarting is disabled, not starting");
81 Environment.Exit (0);
83 autostarted = true;
84 break;
86 default:
87 if (args [i].Length < 2 || args [i].Substring (0, 2) != "--") {
88 if (query.Length != 0)
89 query += " ";
90 query += args [i];
92 break;
95 i ++;
99 static void NoTrayWindowDeleteEvent (object o, Gtk.DeleteEventArgs args)
101 BestWindow win = (BestWindow) o;
102 win.StoreSettingsInConf (false);
103 Application.Quit ();
106 static void Main (String[] args)
108 ParseArgs (args);
110 Program best = new Program ("best", "0.0", Modules.UI, args);
112 try {
113 GeckoUtils.Init ();
114 } catch (DllNotFoundException) {
115 // We might get this exception if there are
116 // missing symbols from the Mozilla runtime if
117 // the user did a Firefox 1.0 -> 1.5 upgrade.
118 // There's nothing we can do about this, it's
119 // an ABI change, so tell the user this is
120 // probably what's wrong.
121 Console.WriteLine (Catalog.GetString ("Best cannot initialize Mozilla's Gecko runtime environment.\n" +
122 "Have you upgraded Mozilla or Firefox recently? If so, you\n" +
123 "probably need to rebuild beagle against this new version.\n" +
124 "See http://bugzilla.gnome.org/show_bug.cgi?id=326503 for\n" +
125 "more information."));
126 Environment.Exit (1);
129 GeckoUtils.SetSystemFonts ();
131 // I18N
132 Catalog.Init ("beagle", ExternalStringsHack.LocaleDir);
134 // Create the window.
135 BestWindow win;
136 if (query != "") {
137 win = new BestWindow (query);
138 win.Show ();
139 } else {
140 win = new BestWindow ();
141 if (showWindow)
142 win.Show ();
145 // Create the tray icon.
146 BestTray icon;
147 if (doTray) {
148 icon = new BestTray (win, autostarted);
149 icon.Show ();
150 Console.WriteLine (Catalog.GetString ("If you're wondering whether Best is working check " +
151 "your notification area (system tray)"));
152 } else {
153 win.Show ();
154 win.Present ();
155 win.FocusEntry ();
156 win.DeleteEvent += new Gtk.DeleteEventHandler (NoTrayWindowDeleteEvent);
159 best.Run ();