Example #1
0
        private void Activated(object sender, EventArgs e)
        {
            NewImageDialog dialog = new NewImageDialog ();

            Gtk.Clipboard cb = Gtk.Clipboard.Get (Gdk.Atom.Intern ("CLIPBOARD", false));
            if (cb.WaitIsImageAvailable ()) {
                Gdk.Pixbuf image = cb.WaitForImage ();
                dialog.NewImageWidth = image.Width;
                dialog.NewImageHeight = image.Height;
            } else {
                dialog.NewImageWidth = PintaCore.Settings.GetSetting<int> ("new-image-width", 800);
                dialog.NewImageHeight = PintaCore.Settings.GetSetting<int> ("new-image-height", 600);
            }

            dialog.WindowPosition = Gtk.WindowPosition.CenterOnParent;

            int response = dialog.Run ();

            if (response == (int)Gtk.ResponseType.Ok) {
                PintaCore.Workspace.NewDocument (new Gdk.Size (dialog.NewImageWidth, dialog.NewImageHeight), false);

                PintaCore.Settings.PutSetting ("new-image-width", dialog.NewImageWidth);
                PintaCore.Settings.PutSetting ("new-image-height", dialog.NewImageHeight);
                PintaCore.Settings.SaveSettings ();
            }

            dialog.Destroy ();
        }
Example #2
0
		private void Activated (object sender, EventArgs e)
		{
			int imgWidth = 0;
			int imgHeight = 0;
			var bg_type = NewImageDialog.BackgroundType.White;
            var using_clipboard = true;
			
			// Try to get the dimensions of an image on the clipboard
			// for the initial width and height values on the NewImageDialog
			if (!GetClipboardImageSize (out imgWidth, out imgHeight))
			{
				// An image was not on the clipboard,
				// so use saved dimensions from settings
				imgWidth = PintaCore.Settings.GetSetting<int> ("new-image-width", 800);
				imgHeight = PintaCore.Settings.GetSetting<int> ("new-image-height", 600);
				bg_type = PintaCore.Settings.GetSetting<NewImageDialog.BackgroundType> (
					"new-image-bg", NewImageDialog.BackgroundType.White);
                using_clipboard = false;
            }

			var dialog = new NewImageDialog (imgWidth, imgHeight, bg_type, using_clipboard);

			int response = dialog.Run ();

			if (response == (int)Gtk.ResponseType.Ok) {
				PintaCore.Workspace.NewDocument (new Gdk.Size (dialog.NewImageWidth, dialog.NewImageHeight), dialog.NewImageBackground);

				PintaCore.Settings.PutSetting ("new-image-width", dialog.NewImageWidth);
				PintaCore.Settings.PutSetting ("new-image-height", dialog.NewImageHeight);
				PintaCore.Settings.PutSetting ("new-image-bg", dialog.NewImageBackgroundType);
				PintaCore.Settings.SaveSettings ();
			}

			dialog.Destroy ();
		}
Example #3
0
        private void Activated(object sender, EventArgs e)
        {
            int imgWidth        = 0;
            int imgHeight       = 0;
            var bg_type         = NewImageDialog.BackgroundType.White;
            var using_clipboard = true;

            // Try to get the dimensions of an image on the clipboard
            // for the initial width and height values on the NewImageDialog
            if (!GetClipboardImageSize(out imgWidth, out imgHeight))
            {
                // An image was not on the clipboard,
                // so use saved dimensions from settings
                imgWidth  = PintaCore.Settings.GetSetting <int> ("new-image-width", 800);
                imgHeight = PintaCore.Settings.GetSetting <int> ("new-image-height", 600);
                bg_type   = PintaCore.Settings.GetSetting <NewImageDialog.BackgroundType> (
                    "new-image-bg", NewImageDialog.BackgroundType.White);
                using_clipboard = false;
            }

            using var dialog = new NewImageDialog(imgWidth, imgHeight, bg_type, using_clipboard);

            int response = dialog.Run();

            if (response == (int)Gtk.ResponseType.Ok)
            {
                PintaCore.Workspace.NewDocument(new Gdk.Size(dialog.NewImageWidth, dialog.NewImageHeight), dialog.NewImageBackground);

                PintaCore.Settings.PutSetting("new-image-width", dialog.NewImageWidth);
                PintaCore.Settings.PutSetting("new-image-height", dialog.NewImageHeight);
                PintaCore.Settings.PutSetting("new-image-bg", dialog.NewImageBackgroundType);
            }
        }
Example #4
0
        private void Activated(object sender, EventArgs e)
        {
            NewImageDialog dialog = new NewImageDialog();

            if (!TryUseClipboardImageSize(dialog))
            {
                dialog.NewImageWidth  = PintaCore.Settings.GetSetting <int> ("new-image-width", 800);
                dialog.NewImageHeight = PintaCore.Settings.GetSetting <int> ("new-image-height", 600);
            }

            dialog.WindowPosition = Gtk.WindowPosition.CenterOnParent;

            int response = dialog.Run();

            if (response == (int)Gtk.ResponseType.Ok)
            {
                PintaCore.Workspace.NewDocument(new Gdk.Size(dialog.NewImageWidth, dialog.NewImageHeight), false);

                PintaCore.Settings.PutSetting("new-image-width", dialog.NewImageWidth);
                PintaCore.Settings.PutSetting("new-image-height", dialog.NewImageHeight);
                PintaCore.Settings.SaveSettings();
            }

            dialog.Destroy();
        }
Example #5
0
        private void Activated(object sender, EventArgs e)
        {
            NewImageDialog dialog = new NewImageDialog();

            Gtk.Clipboard cb = Gtk.Clipboard.Get(Gdk.Atom.Intern("CLIPBOARD", false));
            if (cb.WaitIsImageAvailable())
            {
                Gdk.Pixbuf image = cb.WaitForImage();
                dialog.NewImageWidth  = image.Width;
                dialog.NewImageHeight = image.Height;
            }
            else
            {
                dialog.NewImageWidth  = PintaCore.Settings.GetSetting <int> ("new-image-width", 800);
                dialog.NewImageHeight = PintaCore.Settings.GetSetting <int> ("new-image-height", 600);
            }

            dialog.WindowPosition = Gtk.WindowPosition.CenterOnParent;

            int response = dialog.Run();

            if (response == (int)Gtk.ResponseType.Ok)
            {
                PintaCore.Workspace.NewDocument(new Gdk.Size(dialog.NewImageWidth, dialog.NewImageHeight), false);

                PintaCore.Settings.PutSetting("new-image-width", dialog.NewImageWidth);
                PintaCore.Settings.PutSetting("new-image-height", dialog.NewImageHeight);
                PintaCore.Settings.SaveSettings();
            }

            dialog.Destroy();
        }
Example #6
0
        private void Activated(object sender, EventArgs e)
        {
            int imgWidth  = 0;
            int imgHeight = 0;

            // Try to get the dimensions of an image on the clipboard
            // for the initial width and height values on the NewImageDialog
            if (!GetClipboardImageSize(out imgWidth, out imgHeight))
            {
                // An image was not on the clipboard,
                // so use saved dimensions from settings
                imgWidth  = PintaCore.Settings.GetSetting <int> ("new-image-width", 800);
                imgHeight = PintaCore.Settings.GetSetting <int> ("new-image-height", 600);
            }

            NewImageDialog dialog = new NewImageDialog(imgWidth, imgHeight);

            dialog.WindowPosition = Gtk.WindowPosition.CenterOnParent;

            int response = dialog.Run();

            if (response == (int)Gtk.ResponseType.Ok)
            {
                PintaCore.Workspace.NewDocument(new Gdk.Size(dialog.NewImageWidth, dialog.NewImageHeight), false);

                PintaCore.Settings.PutSetting("new-image-width", dialog.NewImageWidth);
                PintaCore.Settings.PutSetting("new-image-height", dialog.NewImageHeight);
                PintaCore.Settings.SaveSettings();
            }

            dialog.Destroy();
        }
Example #7
0
        /// <summary>
        /// Sets the dialog to use the clipboard image's dimensions, if possible.
        /// </summary>
        /// <returns>True if an image was on the clipboard, false otherwise.</returns>
        private static bool TryUseClipboardImageSize(NewImageDialog dialog)
        {
            bool clipboardUsed = false;

            Gtk.Clipboard cb = Gtk.Clipboard.Get(Gdk.Atom.Intern("CLIPBOARD", false));
            if (cb.WaitIsImageAvailable())
            {
                Gdk.Pixbuf image = cb.WaitForImage();
                if (image != null)
                {
                    clipboardUsed         = true;
                    dialog.NewImageWidth  = image.Width;
                    dialog.NewImageHeight = image.Height;
                    image.Dispose();
                }
            }

            cb.Dispose();

            return(clipboardUsed);
        }
Example #8
0
        /// <summary>
        /// Sets the dialog to use the clipboard image's dimensions, if possible.
        /// </summary>
        /// <returns>True if an image was on the clipboard, false otherwise.</returns>
        private static bool TryUseClipboardImageSize(NewImageDialog dialog)
        {
            bool clipboardUsed = false;

            Gtk.Clipboard cb = Gtk.Clipboard.Get (Gdk.Atom.Intern ("CLIPBOARD", false));
            if (cb.WaitIsImageAvailable ())
            {
                Gdk.Pixbuf image = cb.WaitForImage ();
                if (image != null)
                {
                    clipboardUsed = true;
                    dialog.NewImageWidth = image.Width;
                    dialog.NewImageHeight = image.Height;
                    image.Dispose ();
                }
            }

            cb.Dispose ();

            return clipboardUsed;
        }
Example #9
0
        private void Activated(object sender, EventArgs e)
        {
            NewImageDialog dialog = new NewImageDialog ();

            if (!TryUseClipboardImageSize (dialog))
            {
                dialog.NewImageWidth = PintaCore.Settings.GetSetting<int> ("new-image-width", 800);
                dialog.NewImageHeight = PintaCore.Settings.GetSetting<int> ("new-image-height", 600);
            }

            dialog.WindowPosition = Gtk.WindowPosition.CenterOnParent;

            int response = dialog.Run ();

            if (response == (int)Gtk.ResponseType.Ok) {
                PintaCore.Workspace.NewDocument (new Gdk.Size (dialog.NewImageWidth, dialog.NewImageHeight), false);

                PintaCore.Settings.PutSetting ("new-image-width", dialog.NewImageWidth);
                PintaCore.Settings.PutSetting ("new-image-height", dialog.NewImageHeight);
                PintaCore.Settings.SaveSettings ();
            }

            dialog.Destroy ();
        }
Example #10
0
        private void Activated(object sender, EventArgs e)
        {
            int imgWidth = 0;
            int imgHeight = 0;

            // Try to get the dimensions of an image on the clipboard
            // for the initial width and height values on the NewImageDialog
            if (!GetClipboardImageSize (out imgWidth, out imgHeight))
            {
                // An image was not on the clipboard,
                // so use saved dimensions from settings
                imgWidth = PintaCore.Settings.GetSetting<int> ("new-image-width", 800);
                imgHeight = PintaCore.Settings.GetSetting<int> ("new-image-height", 600);
            }

            NewImageDialog dialog = new NewImageDialog (imgWidth, imgHeight);

            dialog.WindowPosition = Gtk.WindowPosition.CenterOnParent;

            int response = dialog.Run ();

            if (response == (int)Gtk.ResponseType.Ok) {
                PintaCore.Workspace.NewDocument (new Gdk.Size (dialog.NewImageWidth, dialog.NewImageHeight), false);

                PintaCore.Settings.PutSetting ("new-image-width", dialog.NewImageWidth);
                PintaCore.Settings.PutSetting ("new-image-height", dialog.NewImageHeight);
                PintaCore.Settings.SaveSettings ();
            }

            dialog.Destroy ();
        }