Example #1
0
        public void SelectSizingSide(Gdk.Point localMousePos)
        {
            Gdk.Size windowSize = Gdk.Size.Empty;
            {
                int vw, vh;
                this._window.GdkWindow.GetSize(out vw, out vh);
                windowSize.Width  = vw;
                windowSize.Height = vh;
            }

            _isSizingSide = E_SIZING_SIDE.E_NONE;
            if (localMousePos.X < _marginSize)
            {
                _isSizingSide |= E_SIZING_SIDE.E_LEFT_SIDE;
            }
            else if (localMousePos.X >= windowSize.Width - _marginSize)
            {
                _isSizingSide |= E_SIZING_SIDE.E_RIGHT_SIDE;
            }

            if (localMousePos.Y < _marginSize)
            {
                _isSizingSide |= E_SIZING_SIDE.E_TOP_SIDE;
            }
            else if (localMousePos.Y >= windowSize.Height - _marginSize)
            {
                _isSizingSide |= E_SIZING_SIDE.E_BOTTOM_SIDE;
            }
        }
Example #2
0
            public void Update(Gdk.Size size, Cairo.Color color)
            {
                this.size  = size;
                this.color = color;

                this.QueueDraw();
            }
Example #3
0
        public SparkleAbout() : base("")
        {
            DefaultSize    = new Gdk.Size(360, 260);
            BorderWidth    = 0;
            IconName       = "folder-sparkleshare";
            WindowPosition = WindowPosition.Center;
            Title          = "About SparkleShare";
            Resizable      = false;

            CreateAbout();

            SparkleShare.Controller.NewVersionAvailable += delegate(string new_version) {
                Application.Invoke(delegate {
                    Version.Markup = "<small><span fgcolor='#f57900'>A newer version (" + new_version + ") is available!</span></small>";
                    Version.ShowAll();
                });
            };

            SparkleShare.Controller.VersionUpToDate += delegate {
                Application.Invoke(delegate {
                    Version.Markup = "<small><span fgcolor='#4e9a06'>You are running the latest version.</span></small>";
                    Version.ShowAll();
                });
            };

            SparkleShare.Controller.CheckForNewVersion();
        }
Example #4
0
 private SizeD CalculateNetworkTitleSize(Network network, Cairo.Context gc)
 {
     Pango.Layout layout = new Pango.Layout(this.PangoContext);
     layout.SetText(network.NetworkName);
     Gdk.Size size = GetTextSize(layout);
     return(new SizeD(size.Width, size.Height));
 }
Example #5
0
        public Document NewDocument(Gdk.Size imageSize, Color backgroundColor)
        {
            Document doc = CreateAndActivateDocument(null, imageSize);

            doc.Workspace.CanvasSize = imageSize;

            // Start with an empty white layer
            Layer background = doc.AddNewLayer(Catalog.GetString("Background"));

            if (backgroundColor.A != 0)
            {
                using (Cairo.Context g = new Cairo.Context(background.Surface)) {
                    g.SetSourceColor(backgroundColor);
                    g.Paint();
                }
            }

            doc.Workspace.History.PushNewItem(new BaseHistoryItem(Stock.New, Catalog.GetString("New Image")));
            doc.Workspace.History.SetClean();

            // This ensures these are called after the window is done being created and sized.
            // Without it, we sometimes try to zoom when the window has a size of (0, 0).
            Gtk.Application.Invoke(delegate {
                PintaCore.Actions.View.ActualSize.Activate();
            });

            return(doc);
        }
Example #6
0
        public SparkleAbout()
            : base("")
        {
            DefaultSize    = new Gdk.Size (360, 260);
            BorderWidth    = 0;
            IconName       = "folder-sparkleshare";
            WindowPosition = WindowPosition.Center;
            Title          = "About SparkleShare";
            Resizable      = false;

            CreateAbout ();

            SparkleShare.Controller.NewVersionAvailable += delegate (string new_version) {
                Application.Invoke (delegate {
                    this.version.Markup = "<small><span fgcolor='#f57900'>A newer version (" + new_version + ") is available!</span></small>";
                    this.version.ShowAll ();
                });
            };

            SparkleShare.Controller.VersionUpToDate += delegate {
                Application.Invoke (delegate {
                    this.version.Markup = "<small><span fgcolor='#4e9a06'>You are running the latest version.</span></small>";
                    this.version.ShowAll ();
                });
            };

            SparkleShare.Controller.CheckForNewVersion ();
        }
Example #7
0
        public MainWindow(Gtk.Application application) : base(application)
        {
            storage = GlobalDI.GetService <IDocumentsStorage>();

            // Widget initialization
            DefaultSize  = new Gdk.Size(800, 600);
            DeleteEvent += Window_DeleteEvent;

            // Init children widgets
            header   = new Header();
            Titlebar = header;

            container = new Norka.Widgets.Paned(Orientation.Horizontal, this);

            _docList = container.Sidebar.DocumentsList;
            _docList.SelectedRowsChanged += (sender, args) => DocumentSelected();
            _docList.ItemRenamed         += DocumentRename;
            _editor = container.Editor;
            Add(container);

            container.Sidebar.DocumentsList.RefreshItems();

            var content = new Box(Orientation.Vertical, 0);

            content.PackStart(container, true, true, 0);
            Add(content);

            // Finally connect actins to window
            SetupActions();
        }
Example #8
0
        public AboutWindow(Gtk.Window parent, string[] authors, string[] lines, Gdk.Size size) :
            base(Gtk.WindowType.Toplevel)
        {
            this.Build();

            base.TransientFor = parent;
            base.SetPosition(Gtk.WindowPosition.CenterOnParent);
            base.Decorated = parent.Decorated;
            if (!size.IsEmpty)
            {
                base.SetSizeRequest(size.Width, size.Height);
            }

            Assembly     assembly     = Assembly.GetEntryAssembly();
            AssemblyName assemblyName = assembly.GetName();

            this.textviewAbout.Buffer.Text = String.Format(
                "{0} v{1}.{2}\n",
                assemblyName.Name,
                assemblyName.Version.Major,
                assemblyName.Version.Minor);

            this.textviewAbout.Buffer.Text += "\n*Authors*\n";
            foreach (string author in authors)
            {
                this.textviewAbout.Buffer.Text += String.Format("{0}\n", author);
            }
            foreach (string line in lines)
            {
                this.textviewAbout.Buffer.Text += String.Format("{0}\n", line);
            }
        }
Example #9
0
        public DockBarItem(DockBar bar, DockItem it, int size)
        {
            Events        = Events | Gdk.EventMask.EnterNotifyMask | Gdk.EventMask.LeaveNotifyMask;
            this.size     = size;
            this.bar      = bar;
            this.it       = it;
            VisibleWindow = false;
            UpdateTab();
            lastFrameSize            = bar.Frame.Allocation.Size;
            bar.Frame.SizeAllocated += HandleBarFrameSizeAllocated;

            tracker                 = new MouseTracker(this);
            tracker.TrackMotion     = false;
            tracker.HoveredChanged += (sender, e) => {
                if (crossfade == null)
                {
                    return;
                }

                AnimateHover(tracker.Hovered);
                if (tracker.Hovered)
                {
                    crossfade.ShowSecondary();
                }
                else
                {
                    crossfade.ShowPrimary();
                }
            };
        }
            /// <summary>
            /// Update window size and position stashed for preferences.
            /// </summary>
            /// <returns><c>true</c> if this timer function should continue to be executed.</returns>
            /// <remarks>This is a HACK. Since we get ConfigureEvent updates of intermediate
            /// values during window state transitions to maximize, iconify, etc. we cannot
            /// rely upon those values. We also don't get notifications for simple movement
            /// of the window, either, unlike size requests. And the final straw is that we
            /// also cannot get the 'restore' size and position. So, the HACK is thus:
            /// When a ConfigureEvent arrives, if we haven't already, attach this timer
            /// object to the window. Otherwise, mark the timer's Continue value to <c>true</c>.
            /// When the timer fires, we *MIGHT* update the stored position and size.
            /// The kernel of this HACK is that WindowStateEvent fires in the time between the
            /// last 'valid' ConfigureEvent and the first firing of the timer.</remarks>
            private bool Tick()
            {
                var currentState = (Gdk.WindowState)Window.Data[Properties.Settings.WindowStateSettingName];
                var ignore       = (currentState & (SupportedRestoreStates | Gdk.WindowState.Iconified)) != 0;
                var keepGoing    = Continue && !ignore;

                Continue = false;
                if (!ignore)
                {
                    int width  = 0;
                    int height = 0;
                    Window.GetSize(out width, out height);
                    var newSize = new Gdk.Size(width, height);
                    Window.Data[Properties.Settings.WindowSizeSettingName] = newSize;

                    int top  = 0;
                    int left = 0;
                    Window.GetPosition(out left, out top);
                    var newPosition = new Gdk.Point(left, top);
                    Window.Data[Properties.Settings.WindowPositionSettingName] = newPosition;
                }
                if (!keepGoing)
                {
                    Window.Data.Remove(DataName);
                }
                return(keepGoing);
            }
Example #11
0
        void InitializeComponent()
        {
            DefaultSize = new Gdk.Size(900, 500);

            var mainVbox = new VBox(false, 0);

            MainMenubar = new MenuBar();
            InitMenu(MainMenubar);

            MainToolbar = new Toolbar();
            InitToolbar(MainToolbar);

            var splitCont = new HPaned();

            // list of downloads
            downloadList = new DownloadList();
            var scrolledWindow = new ScrolledWindow();

            scrolledWindow.Child = downloadList;
            splitCont.Add2(scrolledWindow);
            nodeModel = downloadList.Model;

            // categories list
            catList = new CategoryTreeView();
            splitCont.Add1(catList);

            catList.Selection.Changed += CategorySelectionOnChanged;

            mainVbox.PackStart(MainMenubar, false, true, 0);
            mainVbox.PackStart(MainToolbar, false, false, 0);
            mainVbox.PackStart(splitCont);

            Add(mainVbox);
            ShowAll();
        }
Example #12
0
        private void UpdateOrientation()
        {
            if (NewImageWidth < NewImageHeight && !portrait_radio.Active)
            {
                portrait_radio.Activate();
            }
            else if (NewImageWidth > NewImageHeight && !landscape_radio.Active)
            {
                landscape_radio.Activate();
            }

            for (var i = 1; i < preset_combo.GetItemCount(); i++)
            {
                var text = preset_combo.GetValueAt <string> (i);

                if (text == Catalog.GetString("Clipboard") || text == Catalog.GetString("Custom"))
                {
                    continue;
                }

                var text_parts = text.Split('x');
                var width      = int.Parse(text_parts[0].Trim());
                var height     = int.Parse(text_parts[1].Trim());

                var new_size = new Gdk.Size(NewImageWidth < NewImageHeight ? Math.Min(width, height) : Math.Max(width, height), NewImageWidth < NewImageHeight ? Math.Max(width, height) : Math.Min(width, height));
                var new_text = string.Format("{0} x {1}", new_size.Width, new_size.Height);

                preset_combo.SetValueAt(i, new_text);
            }
        }
Example #13
0
        protected override void OnSizeRequested(ref Requisition requisition)
        {
            base.OnSizeRequested(ref requisition);

            Gdk.Size idealSize = GetIdealSize();
            requisition.Width  = idealSize.Width;
            requisition.Height = idealSize.Height;
        }
 public void BuildPreview(FontService fontService)
 {
     tablePreviewBuf = dftUtil.BuildImage (fontService);
     base.SetSizeRequest (tablePreviewBuf.Width, tablePreviewBuf.Height);
     size = new Gdk.Size (tablePreviewBuf.Width, tablePreviewBuf.Height);
     fileSize = dftUtil.CalcFileSize (tablePreviewBuf);
     base.QueueDraw ();
 }
Example #15
0
 public void SetCanvasSize(Gdk.Size size)
 {
     CocoStudioEngineAdapterPINVOKE.CSCanvas_SetCanvasSize(this.swigCPtr, Size.getCPtr(new Size((float)size.Width, (float)size.Height)));
     if (CocoStudioEngineAdapterPINVOKE.SWIGPendingException.Pending)
     {
         throw CocoStudioEngineAdapterPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Example #16
0
 public void BuildPreview(FontService fontService)
 {
     tablePreviewBuf = DftUtil.BuildImage(fontService);
     base.SetSizeRequest(tablePreviewBuf.Width, tablePreviewBuf.Height);
     size     = new Gdk.Size(tablePreviewBuf.Width, tablePreviewBuf.Height);
     FileSize = DftUtil.CalcFileSize(tablePreviewBuf);
     base.QueueDraw();
 }
Example #17
0
		void HandleBarFrameSizeAllocated (object o, SizeAllocatedArgs args)
		{
			if (!lastFrameSize.Equals (args.Allocation.Size)) {
				lastFrameSize = args.Allocation.Size;
				if (autoShowFrame != null)
					bar.Frame.UpdateSize (bar, autoShowFrame);
			}
		}
Example #18
0
        public MainWindow() : base(WindowType.Toplevel)
        {
            DefaultSize = new Gdk.Size(640, 480);

            var scrollWindow = new ScrolledWindow {
                Halign = Align.Fill, Valign = Align.Fill
            };
            var grid = new Grid {
                Halign = Align.Fill, Valign = Align.Fill
            };
            var gridViewport = new Viewport {
                Child = grid, Halign = Align.Fill, Valign = Align.Fill
            };

            scrollWindow.Child = gridViewport;
            Child = scrollWindow;

            var lorem1 = new Label {
                Text         = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ultrices a erat id lacinia. Quisque fringilla, elit at ullamcorper pulvinar, eros lectus convallis risus, et auctor ligula arcu eget augue. Suspendisse potenti. Donec faucibus blandit justo, nec imperdiet velit lobortis quis. Integer finibus sem dui, vitae maximus risus pharetra quis. Quisque venenatis dolor odio, sit amet tempus magna malesuada ac. Integer rhoncus nisi sed rhoncus fermentum. Morbi nulla sem, vulputate et purus eu, gravida feugiat dui. Duis vulputate viverra turpis, id rhoncus purus facilisis at. Donec egestas lacus in semper finibus. Mauris eget rutrum urna. Vestibulum mollis sit amet felis sit amet suscipit.",
                Wrap         = true,
                Halign       = Align.Start,
                MarginBottom = 12
            };

            var lorem2 = new Label {
                Text         = "Aliquam rhoncus interdum nunc. Quisque hendrerit condimentum magna id viverra. In ac est sed enim imperdiet volutpat non et ante. Vivamus aliquam lacinia lobortis. Maecenas aliquet eleifend eros quis tempus. Mauris at nulla pretium, congue nibh at, lobortis orci. Proin volutpat, quam sagittis laoreet mattis, libero neque interdum odio, sit amet feugiat metus augue vitae turpis. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque nec tincidunt tellus, a imperdiet magna. Morbi sit amet purus vel mi venenatis finibus quis et lacus. Quisque aliquam blandit justo et accumsan. Nulla facilisi. Aliquam ac vulputate odio. Donec elit justo, maximus ac purus vehicula, dapibus ultrices quam.",
                Wrap         = true,
                Halign       = Align.Start,
                MarginBottom = 12
            };

            var lorem3 = new Label {
                Text         = "Aliquam sit amet elit mauris. Nulla rutrum, neque ac pretium convallis, erat massa mattis lacus, vel tempus nibh sem eu nulla. Donec vitae ligula convallis, vulputate leo dignissim, pretium eros. Duis eget scelerisque felis. Fusce non leo condimentum, gravida nisi sed, consequat mi. Morbi feugiat nisi id ex pretium accumsan. Vestibulum sollicitudin tortor sed orci porttitor, placerat rutrum leo porttitor. Vivamus rutrum sodales pretium. Donec in nibh id felis finibus feugiat non in est. Nulla ornare sit amet libero ac euismod. Integer eget massa rhoncus, iaculis risus in, malesuada nibh.",
                Wrap         = true,
                Halign       = Align.Start,
                MarginBottom = 12
            };

            var lorem4 = new Label {
                Text         = "Ut rutrum dolor ac iaculis hendrerit. Sed ornare eget tellus ut pellentesque. Aliquam laoreet tempus augue eget varius. Curabitur ac nisl quis orci porttitor pulvinar. Aliquam vel massa sed risus vehicula scelerisque sed id sapien. Phasellus egestas aliquam turpis, ut tempor lacus consectetur vel. Proin id aliquet elit, eget lobortis enim. Maecenas non felis vel nisl sollicitudin bibendum. Aliquam dictum erat non velit egestas aliquet. Cras neque arcu, gravida sit amet leo quis, tempus pretium ex. Mauris rhoncus dapibus laoreet. Integer sollicitudin orci dui, sit amet sollicitudin magna ornare ut.",
                Wrap         = true,
                Halign       = Align.Start,
                MarginBottom = 12
            };

            var lorem5 = new Label {
                Text         = "Nam posuere turpis vitae tortor auctor, et cursus tellus gravida. Praesent congue tristique libero, quis condimentum ligula pharetra eget. Duis maximus eget ligula ac vulputate. Vivamus aliquam ornare volutpat. Donec aliquet semper eros in fermentum. In vel tempor nisi. Nam consequat enim at venenatis tincidunt. Nullam interdum, mauris eu posuere accumsan, mauris leo ornare urna, quis luctus massa metus vel augue. Ut vel sodales quam, vel sagittis erat.",
                Wrap         = true,
                Halign       = Align.Center,
                MarginBottom = 12
            };

            grid.Attach(lorem1, 0, 0, 1, 1);
            grid.Attach(lorem2, 0, 1, 1, 1);
            grid.Attach(lorem3, 0, 2, 1, 1);
            grid.Attach(lorem4, 0, 3, 1, 1);
            grid.Attach(lorem5, 0, 4, 1, 1);
        }
Example #19
0
        /// <summary>
        /// Reset (clear) the Selection.
        /// </summary>
        /// <param name="selectionSurface"></param>
        /// <param name="imageSize"></param>
        public void ResetSelection(Surface selectionSurface, Gdk.Size imageSize)
        {
            using (Cairo.Context g = new Cairo.Context(selectionSurface))
            {
                SelectionPath = g.CreateRectanglePath(new Rectangle(0, 0, imageSize.Width, imageSize.Height));
            }

            SelectionPolygons.Clear();
        }
Example #20
0
        public SparkleAbout()
            : base("")
        {
            DeleteEvent += delegate (object o, DeleteEventArgs args) {
                HideAll ();
                args.RetVal = true;
            };

            DefaultSize    = new Gdk.Size (600, 260);
            Resizable      = false;
            BorderWidth    = 0;
            IconName       = "folder-sparkleshare";
            WindowPosition = WindowPosition.Center;
            Title          = _("About SparkleShare");
            AppPaintable   = true;

            string image_path = new string [] {SparkleUI.AssetsPath,
                 "pixmaps", "about.png"}.Combine ();

            Realize ();
            Gdk.Pixbuf buf = new Gdk.Pixbuf (image_path);
            Gdk.Pixmap map, map2;
            buf.RenderPixmapAndMask (out map, out map2, 255);
            GdkWindow.SetBackPixmap (map, false);

            Controller = new SparkleAboutController ();

            Controller.NewVersionEvent += delegate (string new_version) {
                Application.Invoke (delegate {
                    this.updates.Markup = String.Format ("<span font_size='small' fgcolor='#f57900'>{0}</span>",
                        String.Format (_("A newer version ({0}) is available!"), new_version));

                    this.updates.ShowAll ();
                });
            };

            Controller.VersionUpToDateEvent += delegate {
                Application.Invoke (delegate {
                    this.updates.Markup = String.Format ("<span font_size='small' fgcolor='#4e9a06'>{0}</span>",
                        _("You are running the latest version."));

                    this.updates.ShowAll ();
                });
            };

            Controller.CheckingForNewVersionEvent += delegate {
                Application.Invoke (delegate {
                    this.updates.Markup = String.Format ("<span font_size='small' fgcolor='#4e9a06'>{0}</span>",
                        _("Checking for updates..."));

                    this.updates.ShowAll ();
                });
            };

            this.CreateAbout ();
        }
Example #21
0
        private SizeD CalculateNodeGroupTitleTextSize(NodeGroup ng, Cairo.Context gc)
        {
            Pango.Layout layout = new Pango.Layout(this.PangoContext);
            layout.FontDescription      = this.PangoContext.FontDescription.Copy();
            layout.FontDescription.Size = Pango.Units.FromDouble(NodegroupNameFontSize);
            layout.SetText(ng.Name);

            Gdk.Size size = GetTextSize(layout);
            return(new SizeD(size.Width, size.Height));
        }
Example #22
0
        Gdk.Size GetIdealSize()
        {
            Gdk.Size retVal = new Gdk.Size();
            int      ox, oy;

            GetPosition(out ox, out oy);
            Xwt.Rectangle geometry  = DesktopService.GetUsableMonitorGeometry(Screen.Number, Screen.GetMonitorAtPoint(ox, oy));
            int           maxHeight = (int)geometry.Height * 4 / 5;
            double        startY    = yMargin + ChildAllocation.Y;
            double        y         = startY;

            calculatedItems = 0;
            foreach (var result in results)
            {
                var dataSrc = result.Item2;
                if (dataSrc.Count == 0)
                {
                    continue;
                }

                for (int i = 0; i < maxItems && i < dataSrc.Count; i++)
                {
                    layout.SetMarkup(GetRowMarkup(dataSrc[i]));
                    int w, h;
                    layout.GetPixelSize(out w, out h);
                    if (y + h + itemSeparatorHeight > maxHeight)
                    {
                        break;
                    }
                    y += h + itemSeparatorHeight;
                    calculatedItems++;
                }
            }
            retVal.Width = Math.Min((int)geometry.Width * 4 / 5, 480);
            if (Math.Abs(y - startY) < 1)
            {
                layout.SetMarkup(GettextCatalog.GetString("No matches"));
                int w, h;
                layout.GetPixelSize(out w, out h);
                var realHeight = h + itemSeparatorHeight + 4;
                y += realHeight;
            }
            else
            {
                y -= itemSeparatorHeight;
            }

            var calculatedHeight = Math.Min(
                maxHeight,
                (int)y + yMargin + results.Count(res => res.Item2.Count > 0) * categorySeparatorHeight
                );

            retVal.Height = calculatedHeight;
            return(retVal);
        }
Example #23
0
        public SparkleAbout() : base("")
        {
            DeleteEvent += delegate(object o, DeleteEventArgs args) {
                HideAll();
                args.RetVal = true;
            };

            DefaultSize    = new Gdk.Size(600, 260);
            Resizable      = false;
            BorderWidth    = 0;
            IconName       = "folder-sparkleshare";
            WindowPosition = WindowPosition.Center;
            Title          = _("About SparkleShare");
            AppPaintable   = true;

            string image_path = new string [] { SparkleUI.AssetsPath,
                                                "pixmaps", "about.png" }.Combine();

            Realize();
            Gdk.Pixbuf buf = new Gdk.Pixbuf(image_path);
            Gdk.Pixmap map, map2;
            buf.RenderPixmapAndMask(out map, out map2, 255);
            GdkWindow.SetBackPixmap(map, false);

            Controller = new SparkleAboutController();

            Controller.NewVersionEvent += delegate(string new_version) {
                Application.Invoke(delegate {
                    this.updates.Markup = String.Format("<span font_size='small' fgcolor='#f57900'>{0}</span>",
                                                        String.Format(_("A newer version ({0}) is available!"), new_version));

                    this.updates.ShowAll();
                });
            };

            Controller.VersionUpToDateEvent += delegate {
                Application.Invoke(delegate {
                    this.updates.Markup = String.Format("<span font_size='small' fgcolor='#729fcf'>{0}</span>",
                                                        _("You are running the latest version."));

                    this.updates.ShowAll();
                });
            };

            Controller.CheckingForNewVersionEvent += delegate {
                Application.Invoke(delegate {
                    this.updates.Markup = String.Format("<span font_size='small' fgcolor='#729fcf'>{0}</span>",
                                                        _("Checking for updates..."));

                    this.updates.ShowAll();
                });
            };

            this.CreateAbout();
        }
Example #24
0
 public DockBarItem(DockBar bar, DockItem it, int size)
 {
     Events = Events | Gdk.EventMask.EnterNotifyMask | Gdk.EventMask.LeaveNotifyMask;
     this.size = size;
     this.bar = bar;
     this.it = it;
     VisibleWindow = false;
     UpdateTab ();
     lastFrameSize = bar.Frame.Allocation.Size;
     bar.Frame.SizeAllocated += HandleBarFrameSizeAllocated;
 }
Example #25
0
 void HandleBarFrameSizeAllocated(object o, SizeAllocatedArgs args)
 {
     if (!lastFrameSize.Equals(args.Allocation.Size))
     {
         lastFrameSize = args.Allocation.Size;
         if (autoShowFrame != null)
         {
             bar.Frame.UpdateSize(bar, autoShowFrame);
         }
     }
 }
Example #26
0
        public PryanetAbout()
            : base("")
        {
            DefaultSize    = new Gdk.Size (600, 260);
            Resizable      = false;
            BorderWidth    = 0;
            IconName       = "folder-pryanetshare";
            WindowPosition = WindowPosition.Center;
            Title          = "About PryanetShare";
            AppPaintable   = true;

            string image_path = new string [] { PryanetUI.AssetsPath, "pixmaps", "about.png" }.Combine ();

            Realize ();
            Gdk.Pixbuf buf = new Gdk.Pixbuf (image_path);
            Gdk.Pixmap map, map2;
            buf.RenderPixmapAndMask (out map, out map2, 255);
            GdkWindow.SetBackPixmap (map, false);

            CreateAbout ();

            DeleteEvent += delegate (object o, DeleteEventArgs args) {
                Controller.WindowClosed ();
                args.RetVal = true;
            };

            KeyPressEvent += delegate (object o, KeyPressEventArgs args) {
                if (args.Event.Key == Gdk.Key.Escape ||
                    (args.Event.State == Gdk.ModifierType.ControlMask && args.Event.Key == Gdk.Key.w)) {

                    Controller.WindowClosed ();
                }
            };

            Controller.HideWindowEvent += delegate {
                Application.Invoke (delegate {
                    HideAll ();
                });
            };

            Controller.ShowWindowEvent += delegate {
                Application.Invoke (delegate {
                    ShowAll ();
                    Present ();
                });
            };

            Controller.UpdateLabelEvent += delegate (string text) {
                Application.Invoke (delegate {
                    this.updates.Markup = String.Format ("<span font_size='small' fgcolor='#8cc4ff'>{0}</span>", text);
                    this.updates.ShowAll ();
                });
            };
        }
Example #27
0
 public DockBarItem(DockBar bar, DockItem it, int size)
 {
     Events        = Events | Gdk.EventMask.EnterNotifyMask | Gdk.EventMask.LeaveNotifyMask;
     this.size     = size;
     this.bar      = bar;
     this.it       = it;
     VisibleWindow = false;
     UpdateTab();
     lastFrameSize            = bar.Frame.Allocation.Size;
     bar.Frame.SizeAllocated += HandleBarFrameSizeAllocated;
 }
Example #28
0
        public SparkleAbout() : base("")
        {
            DefaultSize    = new Gdk.Size(600, 260);
            Resizable      = false;
            BorderWidth    = 0;
            IconName       = "folder-sparkleshare";
            WindowPosition = WindowPosition.Center;
            Title          = "About SparkleShare";
            AppPaintable   = true;

            string image_path = new string [] { SparkleUI.AssetsPath, "pixmaps", "about.png" }.Combine();

            Realize();
            Gdk.Pixbuf buf = new Gdk.Pixbuf(image_path);
            Gdk.Pixmap map, map2;
            buf.RenderPixmapAndMask(out map, out map2, 255);
            GdkWindow.SetBackPixmap(map, false);

            CreateAbout();


            DeleteEvent += delegate(object o, DeleteEventArgs args) {
                Controller.WindowClosed();
                args.RetVal = true;
            };

            KeyPressEvent += delegate(object o, KeyPressEventArgs args) {
                if (args.Event.Key == Gdk.Key.Escape ||
                    (args.Event.State == Gdk.ModifierType.ControlMask && args.Event.Key == Gdk.Key.w))
                {
                    Controller.WindowClosed();
                }
            };

            Controller.HideWindowEvent += delegate {
                Application.Invoke(delegate {
                    HideAll();
                });
            };

            Controller.ShowWindowEvent += delegate {
                Application.Invoke(delegate {
                    ShowAll();
                    Present();
                });
            };

            Controller.UpdateLabelEvent += delegate(string text) {
                Application.Invoke(delegate {
                    this.updates.Markup = String.Format("<span font_size='small' fgcolor='#8cc4ff'>{0}</span>", text);
                    this.updates.ShowAll();
                });
            };
        }
Example #29
0
		public TreeModelDemo () : base ("TreeModel demo")
		{
			DefaultSize = new Gdk.Size (640,480);
			ScrolledWindow sw = new ScrolledWindow ();
			TreeView view = new TreeView (new TreeModelAdapter (new MyTreeModel ()));
			view.HeadersVisible = true;
			view.AppendColumn ("Name", new CellRendererText (), "text", 0);
			view.AppendColumn ("Type", new CellRendererText (), "text", 1);
			sw.Add (view);
			sw.ShowAll ();
			Add (sw);
		}
Example #30
0
            protected override bool OnExposeEvent(Gdk.EventExpose evnt)
            {
                base.OnExposeEvent(evnt);

                if (size == Gdk.Size.Empty)
                {
                    return(true);
                }

                var preview_size = Gdk.Size.Empty;
                var widget_size  = GdkWindow.GetBounds();

                // Figure out the dimensions of the preview to draw
                if (size.Width <= max_size && size.Height <= max_size)
                {
                    preview_size = size;
                }
                else if (size.Width > size.Height)
                {
                    preview_size = new Gdk.Size(max_size, (int)(max_size / ((float)size.Width / (float)size.Height)));
                }
                else
                {
                    preview_size = new Gdk.Size((int)(max_size / ((float)size.Height / (float)size.Width)), max_size);
                }

                using (var g = Gdk.CairoHelper.Create(GdkWindow)) {
                    var r = new Cairo.Rectangle((widget_size.Width - preview_size.Width) / 2, (widget_size.Height - preview_size.Height) / 2,
                                                preview_size.Width, preview_size.Height);

                    if (color.A == 0)
                    {
                        // Fill with transparent checkerboard pattern
                        using (var grid = GdkExtensions.CreateTransparentColorSwatch(false))
                            using (var surf = grid.ToSurface())
                                using (var pattern = surf.ToTiledPattern())
                                    g.FillRectangle(r, pattern);
                    }
                    else
                    {
                        // Fill with selected color
                        g.FillRectangle(r, color);
                    }

                    // Draw our canvas drop shadow
                    g.DrawRectangle(new Cairo.Rectangle(r.X - 1, r.Y - 1, r.Width + 2, r.Height + 2), new Cairo.Color(.5, .5, .5), 1);
                    g.DrawRectangle(new Cairo.Rectangle(r.X - 2, r.Y - 2, r.Width + 4, r.Height + 4), new Cairo.Color(.8, .8, .8), 1);
                    g.DrawRectangle(new Cairo.Rectangle(r.X - 3, r.Y - 3, r.Width + 6, r.Height + 6), new Cairo.Color(.9, .9, .9), 1);
                }

                return(true);
            }
Example #31
0
        public TreeModelDemo() : base("TreeModel demo")
        {
            DefaultSize = new Gdk.Size(640, 480);
            ScrolledWindow sw   = new ScrolledWindow();
            TreeView       view = new TreeView(new TreeModelAdapter(new MyTreeModel()));

            view.HeadersVisible = true;
            view.AppendColumn("Name", new CellRendererText(), "text", 0);
            view.AppendColumn("Type", new CellRendererText(), "text", 1);
            sw.Add(view);
            sw.ShowAll();
            Add(sw);
        }
Example #32
0
        protected override bool OnConfigureEvent(Gdk.EventConfigure evnt)
        {
            Gdk.Size newSize = new Gdk.Size(evnt.Width, evnt.Height);

            if (_lastSize != newSize)
            {
                _lastSize = newSize;
                var pageRenderer = Platform.GetRenderer(_application.MainPage);
                pageRenderer?.SetElementSize(new Size(newSize.Width, newSize.Height));
            }

            return(base.OnConfigureEvent(evnt));
        }
Example #33
0
        private void RenderNode(Context gc, Node n, double x, double y)
        {
            double xBelow, yBelow;

            xBelow = Math.Floor(x) + 0.5;
            yBelow = Math.Floor(y) + 0.5;

            Gdk.Pixbuf avatar = Gui.AvatarManager.GetAvatar(n);

            double avatarWidth  = (avatar.Width < 40) ? avatar.Width : 40;
            double avatarHeight = (avatar.Height < 40) ? avatar.Height : 40;

            DrawRoundedRectThumb(gc, xBelow, yBelow, 40, 40, 10, 1, transparent, lightAlphaGray, avatar,
                                 avatarWidth, avatarHeight);


            if (selectedNode == n)
            {
                CreateRoundedRectPath(gc, xBelow, yBelow, 40, 40, 20);
                gc.Color = orangeOverlay;
                gc.Stroke();
            }

            // TODO: This is a mess...
            if (hoverNode == n)
            {
                Pango.Layout layout = new Pango.Layout(this.PangoContext);
                layout.SetText(n.ToString());

                Gdk.Size te = GetTextSize(layout);

                double textX   = xBelow + 20 - (te.Width / 2.0);
                double textY   = yBelow + 20 - (te.Height / 2.0);
                double padding = 3;

                CreateRoundedRectPath(gc, textX - padding, textY - padding, te.Width + (padding * 2.0), te.Height + (padding * 2.0), 20);
                gc.Color = darkGray;
                gc.Fill();

                CreateRoundedRectPath(gc, textX - padding, textY - padding, te.Width + (padding * 2.0), te.Height + (padding * 2.0), 20);
                gc.Color = lightGray;
                gc.Stroke();

                gc.Color = new Cairo.Color(255, 255, 255, 1);
                gc.MoveTo(textX, textY);

                Pango.CairoHelper.ShowLayout(gc, layout);
            }

            n.Properties["position"] = new PointD(x, y);
        }
Example #34
0
        private void RefreshScale9()
        {
            Gdk.Size widgetAutoSize = this.GetInnerWidget().GetWidgetAutoSize();
            int      num1           = this._left < widgetAutoSize.Width - this._right ? this._left : widgetAutoSize.Width - this._right;
            int      num2           = this._left > widgetAutoSize.Width - this._right ? this._left : widgetAutoSize.Width - this._right;
            int      num3           = this._bottom < widgetAutoSize.Height - this._top ? this._bottom : widgetAutoSize.Height - this._top;
            int      num4           = this._bottom > widgetAutoSize.Height - this._top ? this._bottom : widgetAutoSize.Height - this._top;

            this.Scale9OriginX = num1;
            this.Scale9OriginY = widgetAutoSize.Height - num4;
            this.Scale9Width   = num2 - num1;
            this.Scale9Height  = num4 - num3;
            this.GetInnerWidget().SetScale9Rect(this.Scale9OriginX, this.Scale9OriginY, this.Scale9Width, this.Scale9Height);
        }
        private void Activated(object sender, EventArgs e)
        {
            Gtk.Clipboard cb = Gtk.Clipboard.Get (Gdk.Atom.Intern ("CLIPBOARD", false));

            if (cb.WaitIsImageAvailable ()) {
                Gdk.Pixbuf image = cb.WaitForImage ();
                Gdk.Size size = new Gdk.Size (image.Width, image.Height);

                PintaCore.Workspace.NewDocument (size, true);
                PintaCore.Actions.Edit.Paste.Activate ();
            } else {
                ClipboardEmptyError ();
            }
        }
Example #36
0
        public NewImageDialog(int initialWidth, int initialHeight, BackgroundType initial_bg_type, bool isClipboardSize)
            : base(string.Empty, PintaCore.Chrome.MainWindow, DialogFlags.Modal, Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, Gtk.Stock.Ok, Gtk.ResponseType.Ok)
        {
            Title          = Catalog.GetString("New Image");
            WindowPosition = Gtk.WindowPosition.CenterOnParent;

            // We don't show the background color option if it's the same as "White"
            allow_background_color = PintaCore.Palette.SecondaryColor.ToColorBgra() != ColorBgra.White;

            BorderWidth  = 4;
            VBox.Spacing = 4;

            Resizable       = false;
            DefaultResponse = ResponseType.Ok;

            Icon = PintaCore.Resources.GetIcon(Stock.New, 16);
            AlternativeButtonOrder = new int[] { (int)ResponseType.Ok, (int)ResponseType.Cancel };

            has_clipboard  = isClipboardSize;
            clipboard_size = new Gdk.Size(initialWidth, initialHeight);

            InitializePresets();
            BuildDialog();

            if (initial_bg_type == BackgroundType.SecondaryColor && allow_background_color)
            {
                secondary_bg_radio.Active = true;
            }
            else if (initial_bg_type == BackgroundType.Transparent)
            {
                trans_bg_radio.Active = true;
            }
            else
            {
                white_bg_radio.Active = true;
            }

            width_entry.Text  = initialWidth.ToString();
            height_entry.Text = initialHeight.ToString();

            width_entry.GrabFocus();
            width_entry.SelectRegion(0, width_entry.Text.Length);

            WireUpEvents();

            UpdateOrientation();
            UpdatePresetSelection();
            preview.Update(NewImageSize, NewImageBackground);
        }
        /// <summary>Default constructor.</summary>
        internal ApplicationMenu(ApplicationButton Button)
        {
            this.SetFlag (WidgetFlags.NoWindow);

            this.AddEvents ((int)(Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.PointerMotionMask));

            //this.children = new List<Widget> ();

            //Append (new Button ("OK"));

            appBtn = Button;
            items = new List<ApplicationMenuItem> ();
            itemHeight = 32;
            menuSize = new Gdk.Size (240, 320);
        }
Example #38
0
        public MainWindow() : base(WindowType.Toplevel)
        {
            // Setup GUI
            WindowPosition = WindowPosition.Center;
            DefaultSize    = new Gdk.Size(600, 300);

            var provider = new CssProvider();

            provider.LoadFromData(".blue-background { background-image: none; background-color: rgb(240, 248, 255); }");
            Gtk.StyleContext.AddProviderForScreen(Gdk.Screen.Default, provider, 1);


            _sikInterface = new SiKInterface();

            _headerBar = new HeaderBar();
            _headerBar.ShowCloseButton = true;
            _headerBar.Title           = "SiK Radio Configurator";

            _boardIdentifiers  = new BoardIdentifierControls();
            _dataTableControls = new DataTableControls();
            _sikInterface.SiKConfig.PropertyChanged += _boardIdentifiers.SiKConfig_PropertyChanged;
            _dataTableControls.CreateBindings(_sikInterface.SiKConfig);

            _pageLabel = new Label(NOT_CONN_LBL);

            Titlebar   = _headerBar;
            Destroyed += (sender, e) => Application.Quit();

            _notebook      = new Notebook();
            _pageContainer = new Box(Orientation.Vertical, 1);
            _notebook.AppendPage(_pageContainer, _pageLabel);
            _notebook.AppendPage(new Box(Orientation.Vertical, 5), new Label("TBD"));

            Add(_notebook);

            CreatePortSelLine();
            CreateDataTable();
            CreateBoardIdLine();
            CreateButtonsLine();

            // TODO: Fix Statusbar at the bottom
            _statusBar = new Statusbar();
            _pageContainer.Add(_statusBar);
            _cxt = _statusBar.GetContextId("Main page");

            ShowAll();
        }
Example #39
0
            protected override bool OnDrawn(Context cr)
            {
                base.OnDrawn(cr);

                if (size == Gdk.Size.Empty)
                {
                    return(true);
                }

                var preview_size = Gdk.Size.Empty;
                var widget_size  = Window.GetBounds();

                // Figure out the dimensions of the preview to draw
                if (size.Width <= max_size && size.Height <= max_size)
                {
                    preview_size = size;
                }
                else if (size.Width > size.Height)
                {
                    preview_size = new Gdk.Size(max_size, (int)(max_size / ((float)size.Width / (float)size.Height)));
                }
                else
                {
                    preview_size = new Gdk.Size((int)(max_size / ((float)size.Height / (float)size.Width)), max_size);
                }

                var r = new Cairo.Rectangle((widget_size.Width - preview_size.Width) / 2, (widget_size.Height - preview_size.Height) / 2, preview_size.Width, preview_size.Height);

                if (color.A == 0)
                {
                    // Fill with transparent checkerboard pattern
                    using (var pattern = CairoExtensions.CreateTransparentBackgroundPattern(16))
                        cr.FillRectangle(r, pattern);
                }
                else
                {
                    // Fill with selected color
                    cr.FillRectangle(r, color);
                }

                // Draw our canvas drop shadow
                cr.DrawRectangle(new Cairo.Rectangle(r.X - 1, r.Y - 1, r.Width + 2, r.Height + 2), new Cairo.Color(.5, .5, .5), 1);
                cr.DrawRectangle(new Cairo.Rectangle(r.X - 2, r.Y - 2, r.Width + 4, r.Height + 4), new Cairo.Color(.8, .8, .8), 1);
                cr.DrawRectangle(new Cairo.Rectangle(r.X - 3, r.Y - 3, r.Width + 6, r.Height + 6), new Cairo.Color(.9, .9, .9), 1);

                return(true);
            }
Example #40
0
		public NodeViewDemo () : base ("NodeView demo")
		{
			DeleteEvent += new DeleteEventHandler (DeleteCB);
			DefaultSize = new Gdk.Size (640,480);

			ScrolledWindow sw = new ScrolledWindow ();
			Add (sw);

			NodeView view = new NodeView (Store);
			view.HeadersVisible = true;
			view.AppendColumn ("Name", new CellRendererText (), "text", 0);
			view.AppendColumn ("Type", new CellRendererText (), new NodeCellDataFunc (DataCallback));

			sw.Add (view);
			
			dialog.Destroy ();
			dialog = null;
		}
Example #41
0
        private void Activated(object sender, EventArgs e)
        {
            Gtk.Clipboard cb = Gtk.Clipboard.Get (Gdk.Atom.Intern ("CLIPBOARD", false));

            if (cb.WaitIsImageAvailable ()) {
                using (Gdk.Pixbuf image = cb.WaitForImage ()) {
                    if (image != null) {
                        Gdk.Size size = new Gdk.Size (image.Width, image.Height);

                        PintaCore.Workspace.NewDocument (size, true);
                        PintaCore.Actions.Edit.Paste.Activate ();
                        PintaCore.Actions.Edit.Deselect.Activate ();
                        return;
                    }
                }
            }

            Pinta.Core.Document.ShowClipboardEmptyDialog ();
        }
Example #42
0
        public NewImageDialog (int initialWidth, int initialHeight, BackgroundType initial_bg_type, bool isClipboardSize)
            : base (string.Empty, PintaCore.Chrome.MainWindow, DialogFlags.Modal, Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, Gtk.Stock.Ok, Gtk.ResponseType.Ok)
        {
            Title = Catalog.GetString ("New Image");
            WindowPosition = Gtk.WindowPosition.CenterOnParent;

            // We don't show the background color option if it's the same as "White"
            allow_background_color = PintaCore.Palette.SecondaryColor.ToColorBgra () != ColorBgra.White;

            BorderWidth = 4;
            VBox.Spacing = 4;

            Resizable = false;
            DefaultResponse = ResponseType.Ok;

            Icon = PintaCore.Resources.GetIcon (Stock.New, 16);
            AlternativeButtonOrder = new int[] { (int)ResponseType.Ok, (int)ResponseType.Cancel };
            
            has_clipboard = isClipboardSize;
            clipboard_size = new Gdk.Size (initialWidth, initialHeight);

            InitializePresets ();
            BuildDialog ();

            if (initial_bg_type == BackgroundType.SecondaryColor && allow_background_color)
                secondary_bg_radio.Active = true;
            else if (initial_bg_type == BackgroundType.Transparent)
                trans_bg_radio.Active = true;
            else
                white_bg_radio.Active = true;

            width_entry.Text = initialWidth.ToString ();
            height_entry.Text = initialHeight.ToString ();

            width_entry.GrabFocus ();
            width_entry.SelectRegion (0, width_entry.Text.Length);

            WireUpEvents ();

            UpdateOrientation ();
            UpdatePresetSelection ();
            preview.Update (NewImageSize, NewImageBackground);
        }
Example #43
0
		public MainWindow () : base (Catalog.GetString ("Mono Visual Profiler"))
		{
			history = History.Load ();
			history.LogFiles.Changed += UpdateRecentLogs;
			history.Configs.Changed += UpdateRepeatSessions;
			DefaultSize = new Gdk.Size (800, 600);
			Gtk.Box box = new Gtk.VBox (false, 0);
			Gtk.UIManager uim = BuildUIManager ();
 			box.PackStart (uim.GetWidget ("/Menubar"), false, false, 0);
 			box.PackStart (uim.GetWidget ("/Toolbar"), false, false, 0);
			UpdateRecentLogs (null, null);
			UpdateRepeatSessions (null, null);
			content_area = new Gtk.VBox (false, 0);
			content_area.Show ();
			box.PackStart (content_area, true, true, 0);
			StartPage start_page = new StartPage (history);
			start_page.Activated += OnStartPageActivated;
			start_page.Show ();
			View = start_page;
			box.ShowAll ();
			Add (box);
		}
		Gdk.Size GetIdealSize ()
		{
			Gdk.Size retVal = new Gdk.Size ();
			int ox, oy;
			GetPosition (out ox, out oy);
			Gdk.Rectangle geometry = DesktopService.GetUsableMonitorGeometry (Screen, Screen.GetMonitorAtPoint (ox, oy));
			var maxHeight = geometry.Height * 4 / 5;
			double startY = yMargin + ChildAllocation.Y;
			double y = startY;
			calculatedItems = 0;
			foreach (var result in results) {
				var dataSrc = result.Item2;
				if (dataSrc.ItemCount == 0)
					continue;
				
				for (int i = 0; i < maxItems && i < dataSrc.ItemCount; i++) {
					layout.SetMarkup (GetRowMarkup (dataSrc, i));
					int w, h;
					layout.GetPixelSize (out w, out h);
					if (y + h + itemSeparatorHeight > maxHeight)
						break;
					y += h + itemSeparatorHeight;
					calculatedItems++;
				}
			}
			retVal.Width = Math.Min (geometry.Width * 4 / 5, 480);
			if (Math.Abs (y - startY) < 1) {
				layout.SetMarkup (GettextCatalog.GetString ("No matches"));
				int w, h;
				layout.GetPixelSize (out w, out h);
				var realHeight = h + itemSeparatorHeight + 4;
				y += realHeight;
			} else {
				y -= itemSeparatorHeight;
			}

			var calculatedHeight = Math.Min (
				maxHeight, 
				(int)y + yMargin + results.Count (res => res.Item2.ItemCount > 0) * categorySeparatorHeight
			);
			retVal.Height = calculatedHeight;
			return retVal;
		}
Example #45
0
		private void RestorePosition ()
		{
			object x = Preferences.Get (Preferences.SEARCH_WINDOW_X_POS);
			object y = Preferences.Get (Preferences.SEARCH_WINDOW_Y_POS);
			object width = Preferences.Get (Preferences.SEARCH_WINDOW_WIDTH);
			object height = Preferences.Get (Preferences.SEARCH_WINDOW_HEIGHT);
			object splitter_pos = Preferences.Get (Preferences.SEARCH_WINDOW_SPLITTER_POS);

			if (x == null || !(x is int)
				|| y == null || !(y is int)
				|| width == null || !(width is int)
				|| height == null || !(height is int)
				|| splitter_pos == null || !(splitter_pos is int))
			return;
		
			DefaultSize =
				new Gdk.Size ((int) width, (int) height);
			Move ((int) x, (int) y);
			hpaned.Position = (int) splitter_pos;
		}
Example #46
0
        private void UpdateOrientation ()
        {
            if (NewImageWidth < NewImageHeight && !portrait_radio.Active)
                portrait_radio.Activate ();
            else if (NewImageWidth > NewImageHeight && !landscape_radio.Active)
                landscape_radio.Activate ();

            for (var i = 1; i < preset_combo.GetItemCount (); i++) {
                var text = preset_combo.GetValueAt<string> (i);

                if (text == Catalog.GetString ("Clipboard") || text == Catalog.GetString ("Custom"))
                    continue;

                var text_parts = text.Split ('x');
                var width = int.Parse (text_parts[0].Trim ());
                var height = int.Parse (text_parts[1].Trim ());

                var new_size = new Gdk.Size (NewImageWidth < NewImageHeight ? Math.Min (width, height) : Math.Max (width, height), NewImageWidth < NewImageHeight ? Math.Max (width, height) : Math.Min (width, height));
                var new_text = string.Format ("{0} x {1}", new_size.Width, new_size.Height);

                preset_combo.SetValueAt (i, new_text);
            }
        }
Example #47
0
        protected override void Initialize()
        {
            new Cubano.NowPlaying.NowPlayingSource ();

            Hyena.Gui.Theming.ThemeEngine.SetCurrentTheme<CubanoTheme> ();

            BuildPrimaryLayout ();
            ConnectEvents ();

            //ActionService.SourceActions.SourceView = this;

            composite_view.TrackView.HasFocus = true;

            InitialShowPresent ();

            DefaultSize = new Gdk.Size (WidthSchema.Get (), HeightSchema.Get ());
        }
Example #48
0
        private void HandlerPintaCoreActionsEditPasteIntoNewImageActivated(object sender, EventArgs e)
        {
            Gtk.Clipboard cb = Gtk.Clipboard.Get(Gdk.Atom.Intern("CLIPBOARD", false));

            if (cb.WaitIsImageAvailable())
            {
                bool canceled = false;

                Gdk.Pixbuf image = cb.WaitForImage();

                Gdk.Size size = new Gdk.Size(image.Width, image.Height);

                if (PintaCore.Workspace.IsDirty)
                {
                    var primary = Catalog.GetString("Save the changes to image \"{0}\" before creating a new image?");
                    var secondary = Catalog.GetString("If you don't save, all changes will be permanently lost.");
                    var markup = "<span weight=\"bold\" size=\"larger\">{0}</span>\n\n{1}\n";
                    markup = string.Format(markup, primary, secondary);

                    var md = new MessageDialog(PintaCore.Chrome.MainWindow, DialogFlags.Modal,
                                                MessageType.Question, ButtonsType.None, true,
                                                markup,
                                                System.IO.Path.GetFileName(PintaCore.Workspace.Filename));

                    md.AddButton(Catalog.GetString("Close without saving"), ResponseType.No);
                    md.AddButton(Stock.Cancel, ResponseType.Cancel);
                    md.AddButton(Stock.Save, ResponseType.Yes);

                    // so that user won't accidentally overwrite
                    md.DefaultResponse = ResponseType.Cancel;

                    ResponseType response = (ResponseType)md.Run();
                    md.Destroy();

                    if (response == ResponseType.Yes)
                    {
                        PintaCore.Actions.File.Save.Activate();
                    }
                    else
                    {
                        canceled = response == ResponseType.Cancel;
                    }

                    PintaCore.Actions.File.NewFile(size);
                }
                else
                {
                    PintaCore.Workspace.ResizeImage(image.Width, image.Height);
                }

                PintaCore.Layers.FinishSelection();

                Cairo.ImageSurface old = PintaCore.Layers.CurrentLayer.Surface.Clone();

                Path p;

                using (Cairo.Context g = new Cairo.Context(PintaCore.Layers.CurrentLayer.Surface))
                {
                    g.DrawPixbuf(image, new Cairo.Point(0, 0));
                    p = g.CreateRectanglePath(new Rectangle(0, 0, image.Width, image.Height));
                }

                PintaCore.Workspace.Invalidate();

                PintaCore.History.PushNewItem(new SimpleHistoryItem(Stock.Paste, Catalog.GetString("Paste into new image"), old, PintaCore.Layers.CurrentLayerIndex));
            }
            else
            {
                ClipboardEmptyError();
            }
        }
Example #49
0
 public WorkspaceManager()
 {
     ActiveDocument = Document = new Document ();
     CanvasSize = new Gdk.Size (800, 600);
     ImageSize = new Gdk.Size (800, 600);
 }
Example #50
0
            protected override bool OnExposeEvent (Gdk.EventExpose evnt)
            {
                base.OnExposeEvent (evnt);

                if (size == Gdk.Size.Empty)
                    return true;

                var preview_size = Gdk.Size.Empty;
                var widget_size = GdkWindow.GetBounds ();

                // Figure out the dimensions of the preview to draw
                if (size.Width <= max_size && size.Height <= max_size)
                    preview_size = size;
                else if (size.Width > size.Height)
                    preview_size = new Gdk.Size (max_size, (int)(max_size / ((float)size.Width / (float)size.Height)));
                else
                    preview_size = new Gdk.Size ((int)(max_size / ((float)size.Height / (float)size.Width)), max_size);

                using (var g = Gdk.CairoHelper.Create (GdkWindow)) {
                    var r = new Cairo.Rectangle ((widget_size.Width - preview_size.Width) / 2, (widget_size.Height - preview_size.Height) / 2, preview_size.Width, preview_size.Height);

                    if (color.A == 0) {
                        // Fill with transparent checkerboard pattern
                        using (var grid = GdkExtensions.CreateTransparentColorSwatch (false))
                        using (var surf = grid.ToSurface ())
                        using (var pattern = surf.ToTiledPattern ())
                            g.FillRectangle (r, pattern);
                    } else {
                        // Fill with selected color
                        g.FillRectangle (r, color);
                    }

                    // Draw our canvas drop shadow
                    g.DrawRectangle (new Cairo.Rectangle (r.X - 1, r.Y - 1, r.Width + 2, r.Height + 2), new Cairo.Color (.5, .5, .5), 1);
                    g.DrawRectangle (new Cairo.Rectangle (r.X - 2, r.Y - 2, r.Width + 4, r.Height + 4), new Cairo.Color (.8, .8, .8), 1);
                    g.DrawRectangle (new Cairo.Rectangle (r.X - 3, r.Y - 3, r.Width + 6, r.Height + 6), new Cairo.Color (.9, .9, .9), 1);
                }

                return true;
            }
Example #51
0
        void set_default_size()
        {
            Gdk.Screen screen;

            screen = Gdk.Screen.Default;
            DefaultSize = new Gdk.Size ((int) (screen.Width * 0.75), (int) (screen.Height * 0.75));
        }
Example #52
0
		private void RestorePosition ()
		{
			object x = Preferences.Get (Preferences.SEARCH_WINDOW_X_POS);
			object y = Preferences.Get (Preferences.SEARCH_WINDOW_Y_POS);
			object width = Preferences.Get (Preferences.SEARCH_WINDOW_WIDTH);
			object height = Preferences.Get (Preferences.SEARCH_WINDOW_HEIGHT);
			object splitter_pos = Preferences.Get (Preferences.SEARCH_WINDOW_SPLITTER_POS);
			object mon = Preferences.Get (Preferences.SEARCH_WINDOW_MONITOR_NUM);
			int new_mon, new_x, new_y;

			if (x == null || !(x is int)
				|| y == null || !(y is int)
				|| width == null || !(width is int)
				|| height == null || !(height is int)
				|| splitter_pos == null || !(splitter_pos is int)
				|| mon == null || !(mon is int))
			return;

			new_mon = Screen.GetMonitorAtPoint ((int) x, (int) y);
			Gdk.Rectangle new_mon_geom = Screen.GetMonitorGeometry (new_mon);
			Logger.Info ("Monitor number returned by GetMonitorAtPoint (actual) is: {0}", new_mon);
			Logger.Info ("Saved monitor number is: {0}", mon);
			Logger.Info ("Saved Search window position is {0} x {1}", (int) x, (int) y);

			// If saved monitor number doesn't match the one returned by GetMonitorAtPoint for saved coords
			// then it means that something has changed in the monitors layout and saved coordinates may not be valid.
			// Therefore we'll restore the window to the center of the monitor closest to the saved coordinates.
			/// It will be returned by the same GetMonitorAtPoint call.
			/// However if the saved monitor number matches the current one, there's still a chance we'll
			/// have wrong coordinates saved due to e.g. different monitors (with different resolution)
			/// used at different times in single-monitor config, also see e.g. bgo#688296 when no explanation was found
			bool restore_as_is = true;
			if (new_mon == (int) mon) {
				Logger.Info ("Saved monitor number does match the actual one...");
				if (new_mon_geom.Contains((int) x, (int) y)) {
					Logger.Info("...and saved window position is within it - restoring as-is.");
				} else {
					Logger.Info("...but saved window position is NOT within it - restoring to the center.");
					restore_as_is = false;
				}
			} else {
				Logger.Info ("Saved monitor number does NOT match the actual one - restoring to the center.");
				restore_as_is = false;
			}

			if (restore_as_is) {
				new_x = (int) x;
				new_y = (int) y;
			} else {
				//center of the screen
				new_x = new_mon_geom.Right/2 - (int) width/2;
				new_y = new_mon_geom.Bottom/2 - (int) height/2;
			}
			Logger.Info ("Restoring Search window to position {0} x {1} at monitor {2}", new_x, new_y, new_mon);
			DefaultSize =
				new Gdk.Size ((int) width, (int) height);
			Move (new_x, new_y);
			hpaned.Position = (int) splitter_pos;

		}
Example #53
0
		public DockBarItem (DockBar bar, DockItem it, int size)
		{
			Events = Events | Gdk.EventMask.EnterNotifyMask | Gdk.EventMask.LeaveNotifyMask;
			this.size = size;
			this.bar = bar;
			this.it = it;
			VisibleWindow = false;
			UpdateTab ();
			lastFrameSize = bar.Frame.Allocation.Size;
			bar.Frame.SizeAllocated += HandleBarFrameSizeAllocated;

			tracker = new MouseTracker (this);
			tracker.TrackMotion = false;
			tracker.HoveredChanged += (sender, e) => {

				if (crossfade == null)
					return;
	
				AnimateHover (tracker.Hovered);
				if (tracker.Hovered)
					crossfade.ShowSecondary ();
				else
					crossfade.ShowPrimary ();
			};

			Styles.Changed += UpdateStyle;
		}
Example #54
0
		public StatusDialog () : base ()
		{

			Title = "Loading data from assemblies...";
			AddButton (Stock.Cancel, 1);
			Response += new ResponseHandler (ResponseCB);
			DefaultSize = new Gdk.Size (480, 100);
					
			HBox hbox = new HBox (false, 4);
			VBox.PackStart (hbox, true, true, 0);
				
			Gtk.Image icon = new Gtk.Image (Stock.DialogInfo, IconSize.Dialog);
			hbox.PackStart (icon, false, false, 0);
			dialog_label = new Label ("");
			hbox.PackStart (dialog_label, false, false, 0);
			ShowAll ();
		}
Example #55
0
            public void Update (Gdk.Size size)
            {
                this.size = size;

                this.QueueDraw ();
            }
Example #56
0
		private void RestorePosition ()
		{
			object x = Preferences.Get (Preferences.SEARCH_WINDOW_X_POS);
			object y = Preferences.Get (Preferences.SEARCH_WINDOW_Y_POS);
			object width = Preferences.Get (Preferences.SEARCH_WINDOW_WIDTH);
			object height = Preferences.Get (Preferences.SEARCH_WINDOW_HEIGHT);
			object splitter_pos = Preferences.Get (Preferences.SEARCH_WINDOW_SPLITTER_POS);
			object mon = Preferences.Get (Preferences.SEARCH_WINDOW_MONITOR_NUM);
			int new_mon, new_x, new_y;

			if (x == null || !(x is int)
				|| y == null || !(y is int)
				|| width == null || !(width is int)
				|| height == null || !(height is int)
				|| splitter_pos == null || !(splitter_pos is int)
				|| mon == null || !(mon is int))
			return;

			new_mon = Screen.GetMonitorAtPoint ((int) x, (int) y);
			Logger.Info ("Monitor number returned by GetMonitorAtPoint (actual) is: {0}", new_mon);
			Logger.Info ("Saved monitor number is: {0}", mon);
			Logger.Info ("Saved Search window position is {0} x {1}", (int) x, (int) y);

			// If saved monitor number doesn't match the one returned by GetMonitorAtPoint for saved coords
			// then it means that something has changed in the monitors layout and saved coordinates may not be valid.
			// Therefore we'll restore the window to the center of the monitor closest to the saved coordinates.
			/// It will be returned by the same GetMonitorAtPoint call.
			if (new_mon == (int) mon) {
				Logger.Info ("Saved monitor number does match the actual one - restoring as-is");
				new_x = (int) x;
				new_y = (int) y;
			} else {
				Logger.Info ("Saved monitor number does NOT match the actual one - restoring to the center");
				//getting the monitor size to calculate the center
				Gdk.Rectangle new_mon_geom = Screen.GetMonitorGeometry (new_mon);
				new_x = new_mon_geom.Right/2 - (int) width/2;
				new_y = new_mon_geom.Bottom/2 - (int) height/2;
			}

			Logger.Info ("Restoring Search window to position {0} x {1} at monitor {2}", new_x, new_y, new_mon);
			DefaultSize =
				new Gdk.Size ((int) width, (int) height);
			Move (new_x, new_y);
			hpaned.Position = (int) splitter_pos;

		}
Example #57
0
        public About () : base ("")
        {
            DeleteEvent += delegate (object o, DeleteEventArgs args) {
                Controller.WindowClosed ();
                args.RetVal = true;
            };

            DefaultSize    = new Gdk.Size (600, 260);
            Resizable      = false;
            BorderWidth    = 0;
            IconName       = "folder-cmissync";
            WindowPosition = WindowPosition.Center;
            Title          = Properties_Resources.About;
            AppPaintable   = true;

            string image_path = System.IO.Path.Combine(GUI.AssetsPath, "pixmaps", "about.png");

            Realize ();
            Gdk.Pixbuf buf = new Gdk.Pixbuf (image_path);
            Gdk.Pixmap map, map2;
            buf.RenderPixmapAndMask (out map, out map2, 255);
            GdkWindow.SetBackPixmap (map, false);

            CreateAbout ();

            Controller.HideWindowEvent += delegate {
                Application.Invoke (delegate {
                        HideAll ();
                        });
            };

            Controller.ShowWindowEvent += delegate {
                Application.Invoke (delegate {
                        ShowAll ();
                        Present ();
                        });
            };

            Controller.NewVersionEvent += delegate (string new_version) {
                Application.Invoke (delegate {
                        this.updates.Markup = String.Format ("<span font_size='small' fgcolor='#729fcf'>{0}</span>",
                            string.Format (Properties_Resources.NewVersionAvailable, new_version));

                        this.updates.ShowAll ();
                        });
            };

            Controller.VersionUpToDateEvent += delegate {
                Application.Invoke (delegate {
                        this.updates.Markup = String.Format ("<span font_size='small' fgcolor='#729fcf'>{0}</span>",
                            Properties_Resources.RunningLatestVersion);

                        this.updates.ShowAll ();
                        });
            };

            Controller.CheckingForNewVersionEvent += delegate {
                Application.Invoke (delegate {
                        // this.updates.Markup = String.Format ("<span font_size='small' fgcolor='#729fcf'>{0}</span>",
                        //    "Checking for updates...");

                        this.updates.ShowAll ();
                        });
            };
        }
		void UpdateSize ()
		{
			if (Canvas == null)
				return;

			if (cachedLayout != null) {
				cachedLayout.Dispose ();
				cachedLayout = null;
			}

			int w, h;
			GetLayout ().GetPixelSize (out w, out h);
			SetPreferedSize (w, h);

			pixelSize = new Gdk.Size (w, h);
		}
Example #59
0
        public void ResizeImage(int width, int height)
        {
            if (ImageSize.Width == width && ImageSize.Height == height)
                return;

            PintaCore.Layers.FinishSelection ();

            ResizeHistoryItem hist = new ResizeHistoryItem (ImageSize.Width, ImageSize.Height);
            hist.TakeSnapshotOfImage ();

            ImageSize = new Gdk.Size (width, height);
            CanvasSize = new Gdk.Size (width, height);

            foreach (var layer in PintaCore.Layers)
                layer.Resize (width, height);

            PintaCore.History.PushNewItem (hist);

            PintaCore.Layers.ResetSelectionPath ();
            PintaCore.Workspace.Invalidate ();
        }
Example #60
0
            public void Update (Gdk.Size size, Cairo.Color color)
            {
                this.size = size;
                this.color = color;

                this.QueueDraw ();
            }