Esempio n. 1
0
        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.
                }
            }
        }
Esempio n. 2
0
        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.
                }
            }
        }
Esempio n. 3
0
        public MainWindow()
            : base(Gtk.WindowType.Toplevel)
        {
            Build ();

            Requisition req = new Requisition ();
            req.Height = 600;
            req.Width = 800;
            drawingarea1.Requisition = req;

            // Initialize interface things
            PintaCore.Actions.AccelGroup = new AccelGroup ();
            this.AddAccelGroup (PintaCore.Actions.AccelGroup);

            progress_dialog = new ProgressDialog ();

            PintaCore.Initialize (tooltoolbar, label5, drawingarea1, history_treeview, this, progress_dialog, (Gtk.Viewport)table1.Parent);
            colorpalettewidget1.Initialize ();

            PintaCore.Chrome.StatusBarTextChanged += new EventHandler<TextChangedEventArgs> (Chrome_StatusBarTextChanged);
            PintaCore.Workspace.CanvasInvalidated += new EventHandler<CanvasInvalidatedEventArgs> (Workspace_CanvasInvalidated);
            PintaCore.Workspace.CanvasSizeChanged += new EventHandler (Workspace_CanvasSizeChanged);
            CreateToolBox ();

            PintaCore.Actions.CreateMainMenu (menubar1);
            PintaCore.Actions.CreateToolBar (toolbar1);
            PintaCore.Actions.Layers.CreateLayerWindowToolBar (toolbar4);
            PintaCore.Actions.Edit.CreateHistoryWindowToolBar (toolbar2);

            Gtk.Image i = new Gtk.Image (PintaCore.Resources.GetIcon ("StatusBar.CursorXY.png"));
            i.Show ();

            statusbar1.Add (i);
            Gtk.Box.BoxChild box = (Gtk.Box.BoxChild)statusbar1[i];
            box.Position = 2;
            box.Fill = false;
            box.Expand = false;

            this.Icon = PintaCore.Resources.GetIcon ("Pinta.png");

            dialog_handler = new DialogHandlers (this);

            // Create a blank document
            Layer background = PintaCore.Layers.AddNewLayer ("Background");

            using (Cairo.Context g = new Cairo.Context (background.Surface)) {
                g.SetSourceRGB (255, 255, 255);
                g.Paint ();
            }

            PintaCore.Workspace.Filename = "Untitled1";
            PintaCore.History.PushNewItem (new BaseHistoryItem ("gtk-new", "New Image"));
            PintaCore.Workspace.IsDirty = false;
            PintaCore.Workspace.Invalidate ();

            //History
            history_treeview.Model = PintaCore.History.ListStore;
            history_treeview.HeadersVisible = false;
            history_treeview.Selection.Mode = SelectionMode.Single;
            history_treeview.Selection.SelectFunction = HistoryItemSelected;

            Gtk.TreeViewColumn icon_column = new Gtk.TreeViewColumn ();
            Gtk.CellRendererPixbuf icon_cell = new Gtk.CellRendererPixbuf ();
            icon_column.PackStart (icon_cell, true);

            Gtk.TreeViewColumn text_column = new Gtk.TreeViewColumn ();
            Gtk.CellRendererText text_cell = new Gtk.CellRendererText ();
            text_column.PackStart (text_cell, true);

            text_column.SetCellDataFunc (text_cell, new Gtk.TreeCellDataFunc (HistoryRenderText));
            icon_column.SetCellDataFunc (icon_cell, new Gtk.TreeCellDataFunc (HistoryRenderIcon));

            history_treeview.AppendColumn (icon_column);
            history_treeview.AppendColumn (text_column);

            PintaCore.History.HistoryItemAdded += new EventHandler<HistoryItemAddedEventArgs> (OnHistoryItemsChanged);
            PintaCore.History.ActionUndone += new EventHandler (OnHistoryItemsChanged);
            PintaCore.History.ActionRedone += new EventHandler (OnHistoryItemsChanged);

            PintaCore.Actions.View.ZoomToWindow.Activated += new EventHandler (ZoomToWindow_Activated);
            DeleteEvent += new DeleteEventHandler (MainWindow_DeleteEvent);

            PintaCore.LivePreview.RenderUpdated += LivePreview_RenderUpdated;

            WindowAction.Visible = false;

            hruler = new HRuler ();
            hruler.Metric = MetricType.Pixels;
            table1.Attach (hruler, 1, 2, 0, 1, AttachOptions.Shrink | AttachOptions.Fill, AttachOptions.Shrink | AttachOptions.Fill, 0, 0);

            vruler = new VRuler ();
            vruler.Metric = MetricType.Pixels;
            table1.Attach (vruler, 0, 1, 1, 2, AttachOptions.Shrink | AttachOptions.Fill, AttachOptions.Shrink | AttachOptions.Fill, 0, 0);

            UpdateRulerRange ();

            PintaCore.Actions.View.ZoomComboBox.ComboBox.Changed += HandlePintaCoreActionsViewZoomComboBoxComboBoxChanged;

            gr = new GridRenderer (cr);

            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 = menubar1;
                    /*
                    //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, Mono.Unix.Catalog.GetString ("About"));

                    menubar1.Hide ();
                } catch {
                    // If things don't work out, just use a normal menu.
                }
            }
        }