private void ShowWindow() { Application.Init(); Glade.XML gxml = new Glade.XML(null, "ImLogViewer.glade", "imviewer", null); gxml.Autoconnect(this); imviewer.Icon = IconTheme.Default.LoadIcon("system-search", 16, IconLookupFlags.NoSvg); conversation.PixelsAboveLines = 3; conversation.LeftMargin = 4; conversation.RightMargin = 4; TextTag boldtag = new TextTag("bold"); boldtag.Weight = Pango.Weight.Bold; conversation.Buffer.TagTable.Add(boldtag); TextTag highlight = new TextTag("highlight"); highlight.Background = "yellow"; conversation.Buffer.TagTable.Add(highlight); tree_store = new TreeStore(new Type[] { typeof(string), typeof(string), typeof(object) }); timelinetree.Model = tree_store; timelinetree.AppendColumn("Date", new CellRendererText(), "markup", 0); timelinetree.AppendColumn("Snippet", new CellRendererText(), "text", 1); timelinetree.Selection.Changed += OnConversationSelected; if (highlight_text != null) { search_entry.Text = highlight_text; } if (search_text != null) { Search(search_text); } search_entry.Activated += OnSearchClicked; search_button.Clicked += OnSearchClicked; clear_button.Clicked += OnClearClicked; imviewer.DeleteEvent += new DeleteEventHandler(OnWindowDelete); AccelGroup accel_group = new AccelGroup(); GlobalKeybinder global_keys = new GlobalKeybinder(accel_group); global_keys.AddAccelerator(OnWindowClose, (uint)Gdk.Key.Escape, 0, Gtk.AccelFlags.Visible); imviewer.AddAccelGroup(accel_group); // Index the logs index_thread_notify = new ThreadNotify(new ReadyEvent(RepopulateTimeline)); Thread t = new Thread(new ThreadStart(IndexLogs)); t.Start(); Application.Run(); }
private void CreateWindow(string query) { Title = Best.DefaultWindowTitle; DeleteEvent += new DeleteEventHandler(this.DoDelete); MapEvent += new MapEventHandler(MapIt); UnmapEvent += new UnmapEventHandler(UnmapIt); Icon = Images.GetPixbuf("best.png"); Widget content = CreateContents(); VBox main = new VBox(false, 3); main.PackStart(content, true, true, 3); content.Show(); Add(main); main.Show(); main.Realize(); canvas.Realize(); root = new SimpleRootTile(); canvas.Root = root; DefaultWidth = 600; DefaultHeight = 675; accel_group = new Gtk.AccelGroup(); this.AddAccelGroup(accel_group); global_keys = new GlobalKeybinder(accel_group); // Close window (Ctrl-W) global_keys.AddAccelerator(new EventHandler(this.HideWindowHandler), (uint)Gdk.Key.w, Gdk.ModifierType.ControlMask, Gtk.AccelFlags.Visible); // Close window (Escape) global_keys.AddAccelerator(new EventHandler(this.HideWindowHandler), (uint)Gdk.Key.Escape, 0, Gtk.AccelFlags.Visible); // Show source (Ctrl+U) global_keys.AddAccelerator(new EventHandler(this.ShowSource), (uint)Gdk.Key.U, Gdk.ModifierType.ControlMask, Gtk.AccelFlags.Visible); // Focus Entry (Ctrl+L) global_keys.AddAccelerator(new EventHandler(this.FocusEntryHandler), (uint)Gdk.Key.L, Gdk.ModifierType.ControlMask, Gtk.AccelFlags.Visible); // Previous Page (PageUp) global_keys.AddAccelerator(new EventHandler(this.PageBackHandler), (uint)Gdk.Key.Page_Up, 0, Gtk.AccelFlags.Visible); // Next Page (PageDown) global_keys.AddAccelerator(new EventHandler(this.PageForwardHandler), (uint)Gdk.Key.Page_Down, 0, Gtk.AccelFlags.Visible); UpdateFromConf(); UpdatePage(); if (query != null) { Search(query); } }
// // Construct a window to display a note // // Currently a toolbar with Link, Search, Text, Delete buttons // and a Gtk.TextView as the body. // public NoteWindow (Note note) : base (note.Title) { this.note = note; this.IconName = "tomboy"; this.SetDefaultSize (450, 360); Resizable = true; accel_group = new Gtk.AccelGroup (); AddAccelGroup (accel_group); text_menu = new NoteTextMenu (accel_group, note.Buffer, note.Buffer.Undoer); // Add the Find menu item to the toolbar Text menu. It // should only show up in the toplevel Text menu, since // the context menu already has a Find submenu. Gtk.SeparatorMenuItem spacer = new Gtk.SeparatorMenuItem (); spacer.Show (); text_menu.Append (spacer); Gtk.ImageMenuItem find_item = new Gtk.ImageMenuItem (Catalog.GetString("Find in This Note")); find_item.Image = new Gtk.Image (Gtk.Stock.Find, Gtk.IconSize.Menu); find_item.Activated += FindActivate; find_item.AddAccelerator ("activate", accel_group, (uint) Gdk.Key.f, Gdk.ModifierType.ControlMask, Gtk.AccelFlags.Visible); find_item.Show (); text_menu.Append (find_item); plugin_menu = MakePluginMenu (); toolbar = MakeToolbar (); toolbar.Show (); template_widget = MakeTemplateBar (); // The main editor widget editor = new NoteEditor (note.Buffer); editor.PopulatePopup += OnPopulatePopup; editor.Show (); // Sensitize the Link toolbar button on text selection mark_set_timeout = new InterruptableTimeout(); mark_set_timeout.Timeout += UpdateLinkButtonSensitivity; note.Buffer.MarkSet += OnSelectionMarkSet; // FIXME: I think it would be really nice to let the // window get bigger up till it grows more than // 60% of the screen, and then show scrollbars. editor_window = new Gtk.ScrolledWindow (); editor_window.HscrollbarPolicy = Gtk.PolicyType.Automatic; editor_window.VscrollbarPolicy = Gtk.PolicyType.Automatic; editor_window.Add (editor); editor_window.Show (); FocusChild = editor; find_bar = new NoteFindBar (note); find_bar.Visible = false; find_bar.NoShowAll = true; find_bar.Hidden += FindBarHidden; Gtk.VBox box = new Gtk.VBox (false, 2); box.PackStart (toolbar, false, false, 0); box.PackStart (template_widget, false, false, 0); box.PackStart (editor_window, true, true, 0); box.PackStart (find_bar, false, false, 0); box.Show (); // Don't set up Ctrl-W or Ctrl-N if Emacs is in use bool using_emacs = false; string gtk_key_theme = (string) Preferences.Get ("/desktop/gnome/interface/gtk_key_theme"); if (gtk_key_theme != null && gtk_key_theme.CompareTo ("Emacs") == 0) using_emacs = true; // NOTE: Since some of our keybindings are only // available in the context menu, and the context menu // is created on demand, register them with the // global keybinder global_keys = new GlobalKeybinder (accel_group); // Close window (Ctrl-W) if (!using_emacs) global_keys.AddAccelerator (new EventHandler (CloseWindowHandler), (uint) Gdk.Key.w, Gdk.ModifierType.ControlMask, Gtk.AccelFlags.Visible); // Escape has been moved to be handled by a KeyPress Handler so that // Escape can be used to close the FindBar. // Close all windows on current Desktop (Ctrl-Q) global_keys.AddAccelerator (new EventHandler (CloseAllWindowsHandler), (uint) Gdk.Key.q, Gdk.ModifierType.ControlMask, Gtk.AccelFlags.Visible); // Find Next (Ctrl-G) global_keys.AddAccelerator (new EventHandler (FindNextActivate), (uint) Gdk.Key.g, Gdk.ModifierType.ControlMask, Gtk.AccelFlags.Visible); // Find Previous (Ctrl-Shift-G) global_keys.AddAccelerator (new EventHandler (FindPreviousActivate), (uint) Gdk.Key.g, (Gdk.ModifierType.ControlMask | Gdk.ModifierType.ShiftMask), Gtk.AccelFlags.Visible); // Open Help (F1) global_keys.AddAccelerator (new EventHandler (OpenHelpActivate), (uint) Gdk.Key.F1, 0, 0); // Create a new note if (!using_emacs) global_keys.AddAccelerator (new EventHandler (CreateNewNote), (uint) Gdk.Key.n, Gdk.ModifierType.ControlMask, Gtk.AccelFlags.Visible); // Have Esc key close the find bar or note window KeyPressEvent += KeyPressed; // Increase Indent global_keys.AddAccelerator (new EventHandler (ChangeDepthRightHandler), (uint) Gdk.Key.Right, Gdk.ModifierType.Mod1Mask, Gtk.AccelFlags.Visible); // Decrease Indent global_keys.AddAccelerator (new EventHandler (ChangeDepthLeftHandler), (uint) Gdk.Key.Left, Gdk.ModifierType.Mod1Mask, Gtk.AccelFlags.Visible); this.Add (box); }
void InitWindow() { int height; int width; this.Icon = Utilities.GetIcon ("tasque", 48); // Update the window title Title = string.Format ("Tasque"); width = application.Preferences.GetInt("MainWindowWidth"); height = application.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; taskListComboBox = new ComboBox (); taskListComboBox.Accessible.Description = "ITaskList Selection"; taskListComboBox.WidthRequest = 150; taskListComboBox.WrapWidth = 1; taskListComboBox.Sensitive = false; CellRendererText comboBoxRenderer = new Gtk.CellRendererText (); comboBoxRenderer.WidthChars = 20; comboBoxRenderer.Ellipsize = Pango.EllipsizeMode.End; taskListComboBox.PackStart (comboBoxRenderer, true); taskListComboBox.SetCellDataFunc (comboBoxRenderer, new Gtk.CellLayoutDataFunc (TaskListComboBoxDataFunc)); taskListComboBox.Show (); topHBox.PackStart (taskListComboBox, false, false, 0); // Space the addTaskButton and the taskListComboBox // 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) { application.Exit (); }, (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; innerEb.ButtonPressEvent += OnTargetVBoxButtonPress; 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; application.BackendManager.BackendInitialized += OnBackendInitialized; // FIXME: if the backend is already initialized, go ahead... initialize OnBackendInitialized (null, null); application.Preferences.SettingChanged += OnSettingChanged; }