protected NoteRecentChanges (NoteManager manager) : base (Catalog.GetString ("Search All Notes")) { this.manager = manager; this.IconName = "tomboy"; this.DefaultWidth = 450; this.DefaultHeight = 400; this.current_matches = new Dictionary<string, int> (); this.Resizable = true; selected_tags = new Dictionary<Tag, Tag> (); AddAccelGroup (Tomboy.ActionManager.UI.AccelGroup); menu_bar = CreateMenuBar (); Gtk.Label label = new Gtk.Label (Catalog.GetString ("_Search:")); label.Xalign = 0.0f; find_combo = Gtk.ComboBoxEntry.NewText (); label.MnemonicWidget = find_combo; find_combo.Changed += OnEntryChanged; find_combo.Entry.ActivatesDefault = false; find_combo.Entry.Activated += OnEntryActivated; find_combo.Entry.FocusInEvent += OnEntryFocusIn; if (previous_searches != null) { foreach (string prev in previous_searches) { find_combo.AppendText (prev); } } clear_search_button = new Gtk.Button (new Gtk.Image (Gtk.Stock.Clear, Gtk.IconSize.Menu)); clear_search_button.Sensitive = false; clear_search_button.Clicked += ClearSearchClicked; clear_search_button.Show (); Gtk.Table table = new Gtk.Table (1, 3, false); table.Attach (label, 0, 1, 0, 1, Gtk.AttachOptions.Fill, Gtk.AttachOptions.Expand | Gtk.AttachOptions.Fill, 0, 0); table.Attach (find_combo, 1, 2, 0, 1, Gtk.AttachOptions.Expand | Gtk.AttachOptions.Fill, Gtk.AttachOptions.Expand | Gtk.AttachOptions.Fill, 0, 0); table.Attach (clear_search_button, 2, 3, 0, 1, Gtk.AttachOptions.Fill, Gtk.AttachOptions.Expand | Gtk.AttachOptions.Fill, 0, 0); table.ColumnSpacing = 4; table.ShowAll (); Gtk.HBox hbox = new Gtk.HBox (false, 0); hbox.PackStart (table, true, true, 0); hbox.ShowAll (); // Notebooks Pane Gtk.Widget notebooksPane = MakeNotebooksPane (); notebooksPane.Show (); MakeRecentTree (); tree.Show (); status_bar = new Gtk.Statusbar (); status_bar.HasResizeGrip = true; status_bar.Show (); // Update on changes to notes manager.NoteDeleted += OnNotesDeleted; manager.NoteAdded += OnNotesChanged; manager.NoteRenamed += OnNoteRenamed; manager.NoteSaved += OnNoteSaved; // List all the current notes UpdateResults (); matches_window = new Gtk.ScrolledWindow (); matches_window.ShadowType = Gtk.ShadowType.In; matches_window.HscrollbarPolicy = Gtk.PolicyType.Automatic; matches_window.VscrollbarPolicy = Gtk.PolicyType.Automatic; matches_window.Add (tree); matches_window.Show (); hpaned = new Gtk.HPaned (); hpaned.Position = 150; hpaned.Add1 (notebooksPane); hpaned.Add2 (matches_window); hpaned.Show (); RestorePosition (); Gtk.VBox vbox = new Gtk.VBox (false, 8); vbox.BorderWidth = 6; vbox.PackStart (hbox, false, false, 4); vbox.PackStart (hpaned, true, true, 0); vbox.PackStart (status_bar, false, false, 0); vbox.Show (); // Use another VBox to place the MenuBar // right at thetop of the window. content_vbox = new Gtk.VBox (false, 0); #if !MAC content_vbox.PackStart (menu_bar, false, false, 0); #endif content_vbox.PackStart (vbox, true, true, 0); content_vbox.Show (); this.Add (content_vbox); this.DeleteEvent += OnDelete; this.KeyPressEvent += OnKeyPressed; // For Escape // Watch when notes are added to notebooks so the search // results will be updated immediately instead of waiting // until the note's QueueSave () kicks in. Notebooks.NotebookManager.NoteAddedToNotebook += OnNoteAddedToNotebook; Notebooks.NotebookManager.NoteRemovedFromNotebook += OnNoteRemovedFromNotebook; // Set the focus chain for the top-most containers Bug #512175 Gtk.Widget[] vbox_focus = new Gtk.Widget[2]; vbox_focus[0] = hbox; vbox_focus[1] = hpaned; vbox.FocusChain = vbox_focus; // Set focus chain for sub widgits of first top-most container Gtk.Widget[] table_focus = new Gtk.Widget[2]; table_focus[0] = find_combo; table_focus[1] = matches_window; hbox.FocusChain = table_focus; // set focus chain for sub widgits of seconf top-most container Gtk.Widget[] hpaned_focus = new Gtk.Widget[2]; hpaned_focus[0] = matches_window; hpaned_focus[1] = notebooksPane; hpaned.FocusChain = hpaned_focus; // get back to the beginning of the focus chain Gtk.Widget[] scroll_right = new Gtk.Widget[1]; scroll_right[0] = tree; matches_window.FocusChain = scroll_right; Tomboy.ExitingEvent += OnExitingEvent; }
void InitWindow() { int height; int width; this.Icon = Utilities.GetIcon ("tasque-48", 48); // Update the window title Title = string.Format ("Tasque"); width = GtkApplication.Instance.Preferences.GetInt("MainWindowWidth"); height = GtkApplication.Instance.Preferences.GetInt("MainWindowHeight"); if(width == -1) width = 600; if(height == -1) height = 600; this.DefaultSize = new Gdk.Size( width, height); accelGroup = new AccelGroup (); AddAccelGroup (accelGroup); globalKeys = new GlobalKeybinder (accelGroup); VBox mainVBox = new VBox(); mainVBox.BorderWidth = 0; mainVBox.Show (); this.Add (mainVBox); HBox topHBox = new HBox (false, 0); topHBox.BorderWidth = 4; categoryComboBox = new ComboBox (); categoryComboBox.Accessible.Description = "Category Selection"; categoryComboBox.WidthRequest = 150; categoryComboBox.WrapWidth = 1; categoryComboBox.Sensitive = false; CellRendererText comboBoxRenderer = new Gtk.CellRendererText (); comboBoxRenderer.WidthChars = 20; comboBoxRenderer.Ellipsize = Pango.EllipsizeMode.End; categoryComboBox.PackStart (comboBoxRenderer, true); categoryComboBox.SetCellDataFunc (comboBoxRenderer, new Gtk.CellLayoutDataFunc (CategoryComboBoxDataFunc)); categoryComboBox.Show (); topHBox.PackStart (categoryComboBox, false, false, 0); // Space the addTaskButton and the categoryComboBox // far apart by using a blank label that expands Label spacer = new Label (string.Empty); spacer.Show (); topHBox.PackStart (spacer, true, true, 0); // The new task entry widget addTaskEntry = new Entry (Catalog.GetString ("New task...")); addTaskEntry.Sensitive = false; addTaskEntry.Focused += OnAddTaskEntryFocused; addTaskEntry.Changed += OnAddTaskEntryChanged; addTaskEntry.Activated += OnAddTaskEntryActivated; addTaskEntry.FocusInEvent += OnAddTaskEntryFocused; addTaskEntry.FocusOutEvent += OnAddTaskEntryUnfocused; addTaskEntry.DragDataReceived += OnAddTaskEntryDragDataReceived; addTaskEntry.Show (); topHBox.PackStart (addTaskEntry, true, true, 0); // Use a small add icon so the button isn't mammoth-sized HBox buttonHBox = new HBox (false, 6); Gtk.Image addImage = new Gtk.Image (Gtk.Stock.Add, IconSize.Menu); addImage.Show (); buttonHBox.PackStart (addImage, false, false, 0); Label l = new Label (Catalog.GetString ("_Add")); l.Show (); buttonHBox.PackStart (l, true, true, 0); buttonHBox.Show (); addTaskButton = new MenuToolButton (buttonHBox, Catalog.GetString ("_Add Task")); addTaskButton.UseUnderline = true; // Disactivate the button until the backend is initialized addTaskButton.Sensitive = false; Gtk.Menu addTaskMenu = new Gtk.Menu (); addTaskButton.Menu = addTaskMenu; addTaskButton.Clicked += OnAddTask; addTaskButton.Show (); topHBox.PackStart (addTaskButton, false, false, 0); globalKeys.AddAccelerator (OnGrabEntryFocus, (uint) Gdk.Key.n, Gdk.ModifierType.ControlMask, Gtk.AccelFlags.Visible); globalKeys.AddAccelerator (delegate (object sender, EventArgs e) { GtkApplication.Instance.Quit (); }, (uint) Gdk.Key.q, Gdk.ModifierType.ControlMask, Gtk.AccelFlags.Visible); this.KeyPressEvent += KeyPressed; topHBox.Show (); mainVBox.PackStart (topHBox, false, false, 0); scrolledWindow = new ScrolledWindow (); scrolledWindow.VscrollbarPolicy = PolicyType.Automatic; scrolledWindow.HscrollbarPolicy = PolicyType.Never; scrolledWindow.BorderWidth = 0; scrolledWindow.CanFocus = true; scrolledWindow.Show (); mainVBox.PackStart (scrolledWindow, true, true, 0); innerEb = new EventBox(); innerEb.BorderWidth = 0; Gdk.Color backgroundColor = GetBackgroundColor (); innerEb.ModifyBg (StateType.Normal, backgroundColor); innerEb.ModifyBase (StateType.Normal, backgroundColor); targetVBox = new VBox(); targetVBox.BorderWidth = 5; targetVBox.Show (); innerEb.Add(targetVBox); scrolledWindow.AddWithViewport(innerEb); statusbar = new Gtk.Statusbar (); statusbar.HasResizeGrip = true; statusbar.Show (); mainVBox.PackEnd (statusbar, false, false, 0); // // Delay adding in the TaskGroups until the backend is initialized // Shown += OnWindowShown; DeleteEvent += WindowDeleted; backend.BackendInitialized += OnBackendInitialized; backend.BackendSyncStarted += OnBackendSyncStarted; backend.BackendSyncFinished += OnBackendSyncFinished; // if the backend is already initialized, go ahead... initialize if(backend.Initialized) { OnBackendInitialized(null, null); } GtkApplication.Instance.Preferences.SettingChanged += OnSettingChanged; }