public MainWindow() : base(WindowType.Toplevel) { CreateWindow (); // Initialize interface things this.AddAccelGroup (PintaCore.Actions.AccelGroup); progress_dialog = new ProgressDialog (); PintaCore.Initialize (tool_toolbar, canvas, this, progress_dialog); color.Initialize (); Compose (); LoadPaintBrushes (); LoadToolBox (); LoadEffects (); //CreateStatusBar (); this.Icon = PintaCore.Resources.GetIcon ("Pinta.png"); canvas.IsFocus = true; UpdateRulerRange (); dialog_handler = new DialogHandlers (this); PintaCore.Actions.View.ZoomToWindow.Activated += new EventHandler (ZoomToWindow_Activated); DeleteEvent += new DeleteEventHandler (MainWindow_DeleteEvent); PintaCore.Actions.File.BeforeQuit += delegate { dock.SaveLayouts (System.IO.Path.Combine (PintaCore.Settings.GetUserSettingsDirectory (), "layouts.xml")); PintaCore.Settings.PutSetting ("window-size-width", this.GdkWindow.GetSize ().Width); PintaCore.Settings.PutSetting ("window-size-height", this.GdkWindow.GetSize ().Height); PintaCore.Settings.PutSetting ("window-maximized", (this.GdkWindow.State & Gdk.WindowState.Maximized) != 0); PintaCore.Settings.PutSetting ("ruler-metric", (int) hruler.Metric); PintaCore.Settings.PutSetting ("ruler-show", PintaCore.Actions.View.Rulers.Active); PintaCore.Settings.SaveSettings (); }; ChangeRulersUnit ((MetricType) PintaCore.Settings.GetSetting ("ruler-metric", (int) MetricType.Pixels)); PintaCore.Actions.View.Rulers.Active = PintaCore.Settings.GetSetting ("ruler-show", false); dialog_handler.UpdateRulerVisibility (); PintaCore.Actions.Help.About.Activated += new EventHandler (About_Activated); PintaCore.Workspace.ActiveDocumentChanged += ActiveDocumentChanged; PintaCore.Workspace.DocumentCreated += new EventHandler<DocumentEventArgs> (Workspace_DocumentCreated); PintaCore.Workspace.DocumentClosed += new EventHandler<DocumentEventArgs> (Workspace_DocumentClosed); if (Platform.GetOS () == Platform.OS.Mac) { try { //enable the global key handler for keyboard shortcuts IgeMacMenu.GlobalKeyHandlerEnabled = true; //Tell the IGE library to use your GTK menu as the Mac main menu IgeMacMenu.MenuBar = main_menu; /* //tell IGE which menu item should be used for the app menu's quit item IgeMacMenu.QuitMenuItem = yourQuitMenuItem; */ //add a new group to the app menu, and add some items to it var appGroup = IgeMacMenu.AddAppMenuGroup (); MenuItem aboutItem = (MenuItem)PintaCore.Actions.Help.About.CreateMenuItem (); appGroup.AddMenuItem (aboutItem, Catalog.GetString ("About")); main_menu.Hide (); } catch { // If things don't work out, just use a normal menu. } } }
public MainWindow() : base(WindowType.Toplevel) { CreateWindow (); // Initialize interface things this.AddAccelGroup (PintaCore.Actions.AccelGroup); progress_dialog = new ProgressDialog (); PintaCore.Initialize (tool_toolbar, canvas, this, progress_dialog); color.Initialize (); Compose (); LoadPaintBrushes (); LoadToolBox (); LoadEffects (); //CreateStatusBar (); canvas.IsFocus = true; UpdateRulerRange (); PintaCore.Chrome.DrawingArea.SizeAllocated += delegate { UpdateRulerRange (); }; dialog_handler = new DialogHandlers (this); PintaCore.Actions.View.ZoomToWindow.Activated += new EventHandler (ZoomToWindow_Activated); PintaCore.Actions.View.ZoomToSelection.Activated += new EventHandler (ZoomToSelection_Activated); DeleteEvent += new DeleteEventHandler (MainWindow_DeleteEvent); PintaCore.Actions.File.BeforeQuit += delegate { dock.SaveLayouts (System.IO.Path.Combine (PintaCore.Settings.GetUserSettingsDirectory (), "layouts.xml")); // Don't store the maximized height if the window is maximized if ((this.GdkWindow.State & Gdk.WindowState.Maximized) == 0) { PintaCore.Settings.PutSetting ("window-size-width", this.GdkWindow.GetSize ().Width); PintaCore.Settings.PutSetting ("window-size-height", this.GdkWindow.GetSize ().Height); } PintaCore.Settings.PutSetting ("window-maximized", (this.GdkWindow.State & Gdk.WindowState.Maximized) != 0); PintaCore.Settings.PutSetting ("ruler-metric", (int) hruler.Metric); PintaCore.Settings.PutSetting ("ruler-show", PintaCore.Actions.View.Rulers.Active); PintaCore.Settings.PutSetting ("toolbar-shown", PintaCore.Actions.View.ToolBar.Active); PintaCore.Settings.SaveSettings (); }; ChangeRulersUnit ((MetricType) PintaCore.Settings.GetSetting ("ruler-metric", (int) MetricType.Pixels)); PintaCore.Actions.View.Rulers.Active = PintaCore.Settings.GetSetting ("ruler-show", false); dialog_handler.UpdateRulerVisibility (); if (PintaCore.Settings.GetSetting <bool> ("window-maximized", false)) this.GdkWindow.Maximize (); PintaCore.Actions.View.ToolBar.Active = PintaCore.Settings.GetSetting ("toolbar-shown", true); ToggleToolbar (PintaCore.Actions.View.ToolBar.Active); PintaCore.Actions.Help.About.Activated += new EventHandler (About_Activated); PintaCore.Workspace.ActiveDocumentChanged += ActiveDocumentChanged; PintaCore.Workspace.DocumentCreated += new EventHandler<DocumentEventArgs> (Workspace_DocumentCreated); PintaCore.Workspace.DocumentClosed += new EventHandler<DocumentEventArgs> (Workspace_DocumentClosed); // We support drag and drop for URIs Gtk.TargetEntry[] targetEntryTypes = new Gtk.TargetEntry[] { new Gtk.TargetEntry ("text/uri-list", 0, 100) }; Gtk.Drag.DestSet (this, Gtk.DestDefaults.Motion | Gtk.DestDefaults.Highlight | Gtk.DestDefaults.Drop, targetEntryTypes, Gdk.DragAction.Copy); this.DragDataReceived += MainWindow_DragDataReceived; if (PintaCore.System.OperatingSystem == OS.Mac) { try { //enable the global key handler for keyboard shortcuts IgeMacMenu.GlobalKeyHandlerEnabled = true; //Tell the IGE library to use your GTK menu as the Mac main menu IgeMacMenu.MenuBar = main_menu; /* //tell IGE which menu item should be used for the app menu's quit item IgeMacMenu.QuitMenuItem = yourQuitMenuItem; */ //add a new group to the app menu, and add some items to it var appGroup = IgeMacMenu.AddAppMenuGroup (); MenuItem aboutItem = (MenuItem)PintaCore.Actions.Help.About.CreateMenuItem (); appGroup.AddMenuItem (aboutItem, Catalog.GetString ("About")); main_menu.Hide (); } catch { // If things don't work out, just use a normal menu. } } }