4 using System
.Diagnostics
;
8 public enum ScopeType
{
18 public enum SortType
{
24 public class UIManager
: Gtk
.UIManager
{
26 private Gtk
.ActionGroup actions
;
27 private Gtk
.RadioActionEntry
[] scope_entries
, sort_entries
;
29 public UIManager (Gtk
.Window mainWindow
)
31 actions
= new ActionGroup ("Actions");
33 Gtk
.ActionEntry
[] entries
= new ActionEntry
[] {
34 new ActionEntry ("Search", null,
35 Catalog
.GetString ("_Search"),
37 new ActionEntry ("Actions", null,
38 Catalog
.GetString ("_Actions"),
40 new ActionEntry ("SortBy", null,
41 Catalog
.GetString ("Sor_t"),
43 new ActionEntry ("Help", null,
44 Catalog
.GetString ("_Help"),
47 new ActionEntry ("Quit", Gtk
.Stock
.Quit
,
49 Catalog
.GetString ("Exit Desktop Search"),
51 new ActionEntry ("Preferences", Gtk
.Stock
.Preferences
,
53 Catalog
.GetString ("Exit Desktop Search"),
55 new ActionEntry ("Contents", Gtk
.Stock
.Help
,
56 Catalog
.GetString ("_Contents"),
58 Catalog
.GetString ("Help - Table of Contents"),
60 new ActionEntry ("About", Gnome
.Stock
.About
,
62 Catalog
.GetString ("About Desktop Search"),
64 new ActionEntry ("QuickTips", null,
65 Catalog
.GetString ("Quick Tips"),
66 null, null, QuickTips
),
67 new ActionEntry ("FocusSearchEntry", null, "",
71 actions
.Add (entries
);
73 scope_entries
= new RadioActionEntry
[] {
74 new RadioActionEntry ("Everywhere", null,
75 Catalog
.GetString ("_Everywhere"),
77 Catalog
.GetString ("Search everywhere"),
78 (int)ScopeType
.Everywhere
),
79 new RadioActionEntry ("Applications", null,
80 Catalog
.GetString ("_Applications"),
82 Catalog
.GetString ("Search applications"),
83 (int)ScopeType
.Applications
),
84 new RadioActionEntry ("Contacts", null,
85 Catalog
.GetString ("_Contacts"),
87 Catalog
.GetString ("Search contacts"),
88 (int)ScopeType
.Contacts
),
89 new RadioActionEntry ("Documents", null,
90 Catalog
.GetString ("_Documents"),
92 Catalog
.GetString ("Search documents"),
93 (int)ScopeType
.Documents
),
94 new RadioActionEntry ("Conversations", null,
95 Catalog
.GetString ("Conve_rsations"),
97 Catalog
.GetString ("Search E-Mail and Instant Messaging logs"),
98 (int)ScopeType
.Conversations
),
99 new RadioActionEntry ("Images", null,
100 Catalog
.GetString ("Images"),
102 Catalog
.GetString ("Search images"),
103 (int)ScopeType
.Images
),
104 new RadioActionEntry ("Media", null,
105 Catalog
.GetString ("Media"),
107 Catalog
.GetString ("Search sound and video files"),
108 (int)ScopeType
.Media
),
110 actions
.Add (scope_entries
, (int)ScopeType
.Everywhere
, OnScopeChanged
);
112 sort_entries
= new RadioActionEntry
[] {
113 new RadioActionEntry ("Modified", null,
114 Catalog
.GetString ("Date _Modified"), null,
115 Catalog
.GetString ("Sort the most-recently-modified matches first"),
116 (int)SortType
.Modified
),
117 new RadioActionEntry ("Name", null,
118 Catalog
.GetString ("_Name"), null,
119 Catalog
.GetString ("Sort matches by name"),
121 new RadioActionEntry ("Relevance", null,
122 Catalog
.GetString ("_Relevance"), null,
123 Catalog
.GetString ("Sort the best matches first"),
124 (int)SortType
.Relevance
),
126 actions
.Add (sort_entries
, (int)SortType
.Modified
, OnSortChanged
);
128 InsertActionGroup (actions
, 0);
129 mainWindow
.AddAccelGroup (AccelGroup
);
130 AddUiFromString (ui_def
);
133 public Gtk
.MenuBar MenuBar
{
135 return (Gtk
.MenuBar
)GetWidget ("/MenuBar");
139 private bool sensitive
= true;
140 public bool Sensitive
{
141 get { return this.sensitive; }
143 this.sensitive
= value;
145 actions
["QuickTips"].Sensitive
= value;
147 foreach (Gtk
.RadioActionEntry rae
in scope_entries
)
148 actions
[rae
.name
].Sensitive
= value;
150 foreach (Gtk
.RadioActionEntry rae
in sort_entries
)
151 actions
[rae
.name
].Sensitive
= value;
155 private const string ui_def
=
157 " <menubar name='MenuBar'>" +
158 " <menu action='Search'>" +
159 " <menuitem action='Everywhere'/>" +
160 " <menuitem action='Applications'/>" +
161 " <menuitem action='Contacts'/>" +
162 " <menuitem action='Documents'/>" +
163 " <menuitem action='Conversations'/>" +
164 " <menuitem action='Images'/>" +
165 " <menuitem action='Media'/>" +
167 " <menuitem action='Preferences'/>" +
168 " <menuitem action='Quit'/>" +
170 " <menu action='Actions'>" +
172 " <menu action='SortBy'>" +
173 " <menuitem action='Modified'/>" +
174 " <menuitem action='Name'/>" +
175 " <menuitem action='Relevance'/>" +
177 " <menu action='Help'>" +
178 " <menuitem action='Contents'/>" +
179 " <menuitem action='QuickTips'/>" +
180 " <menuitem action='About'/>" +
183 " <accelerator action='FocusSearchEntry'/>" +
186 private void Preferences (object obj
, EventArgs args
)
188 Process p
= new Process ();
189 p
.StartInfo
.UseShellExecute
= false;
190 p
.StartInfo
.FileName
= "beagle-settings";
194 } catch (Exception e
) {
195 Console
.WriteLine ("Could not start beagle-settings: {0}", e
);
199 public delegate void ShowQuickTipsDelegate ();
200 public event ShowQuickTipsDelegate ShowQuickTips
;
202 private void QuickTips (object obj
, EventArgs args
)
204 if (ShowQuickTips
!= null)
208 private void Quit (object obj
, EventArgs args
)
210 Gtk
.Application
.Quit ();
213 private void Help (object obj
, EventArgs args
)
215 Gnome
.Url
.Show ("http://www.beagle-project.org/Getting_Started");
218 private void About (object obj
, EventArgs args
)
220 Gdk
.Pixbuf logo
= Beagle
.Images
.GetPixbuf ("system-search.png");
222 string[] people
= new string[] { "Anna Dirks <anna@novell.com>",
223 "Fredrik Hedberg <fredrik@avafan.com>",
224 "Lukas Lipka <lukas@pmad.net>",
225 "Joe Shaw <joeshaw@novell.com>",
226 "Jakub Steiner <jimmac@novell.com",
227 "Dan Winship <danw@novell.com>" };
229 #pragma warning disable 612 // don't warn that Gnome.About is deprecated
230 Gnome
.About about
= new Gnome
.About ("Beagle Search",
231 Beagle
.Util
.ExternalStringsHack
.Version
,
232 "Copyright 2005-2006 Novell, Inc.",
233 null, people
, null, null,
237 #pragma warning restore 612
240 private void OnFocusSearchEntry (object obj
, EventArgs args
)
242 if (FocusSearchEntry
!= null)
246 public delegate void FocusSearchEntryDelegate ();
247 public event FocusSearchEntryDelegate FocusSearchEntry
;
249 private void OnScopeChanged (object obj
, Gtk
.ChangedArgs args
)
251 if (ScopeChanged
!= null)
252 ScopeChanged ((ScopeType
)args
.Current
.CurrentValue
);
255 public delegate void ScopeChangedDelegate (ScopeType scope
);
256 public event ScopeChangedDelegate ScopeChanged
;
258 private void OnSortChanged (object obj
, Gtk
.ChangedArgs args
)
260 if (SortChanged
!= null)
261 SortChanged ((SortType
)args
.Current
.CurrentValue
);
264 public delegate void SortChangedDelegate (SortType scope
);
265 public event SortChangedDelegate SortChanged
;