Esempio n. 1
0
    //Run and destroy a standard confirmation dialog
    public static Gtk.ResponseType RunHigConfirmation(Gtk.Window parent,
                                                      Gtk.DialogFlags flags,
                                                      Gtk.MessageType type,
                                                      string header,
                                                      string msg,
                                                      string ok_caption)
    {
        HigMessageDialog hmd = new HigMessageDialog(parent, flags, type, header, msg, ok_caption);

        try {
            return((Gtk.ResponseType)hmd.Run());
        } finally {
            hmd.Destroy();
        }
    }
Esempio n. 2
0
    //run and destroy a standard dialog
    public static Gtk.ResponseType RunHigMessageDialog(Gtk.Window parent,
                                                       Gtk.DialogFlags flags,
                                                       Gtk.MessageType type,
                                                       Gtk.ButtonsType buttons,
                                                       string header,
                                                       string msg)
    {
        HigMessageDialog hmd = new HigMessageDialog(parent, flags, type, buttons, header, msg);

        try {
            return((Gtk.ResponseType)hmd.Run());
        } finally {
            hmd.Destroy();
        }
    }
Esempio n. 3
0
        public static int ShowMessageDialog(string text, Gtk.Window win, Gtk.MessageType type, Gtk.ButtonsType buttons)
        {
            text = text.Replace(">", "<");
            text = text.Replace("<", "&gt;");
            text = text.Replace("&", "&amp;");

            if (win == null && Gui.MainWindow != null)
            {
                win = Gui.MainWindow.Window;
            }

            MessageDialog md = new MessageDialog(win, Gtk.DialogFlags.DestroyWithParent, type, buttons, String.Empty);

            md.Title          = "Meshwork";
            md.TransientFor   = win;
            md.WindowPosition = WindowPosition.CenterOnParent;
            md.Markup         = text;
            int result = md.Run();

            md.Destroy();
            return(result);
        }
Esempio n. 4
0
        /// <summary>
        /// show a message dialog
        /// </summary>
        /// <returns>
        /// The message.
        /// </returns>
        /// <param name='message'>
        /// Message.
        /// </param>
        /// <param name='parent'>
        /// Parent.
        /// </param>
        /// <param name='flags'>
        /// Flags.
        /// </param>
        /// <param name='messagetype'>
        /// Messagetype.
        /// </param>
        /// <param name='buttonstype'>
        /// Buttonstype.
        /// </param>
        public static ResponseType ShowMessage(String message, Gtk.Window parent, Gtk.DialogFlags flags, Gtk.MessageType messagetype, ButtonsType buttonstype)
        {
            var dialog = new MessageDialog(parent, flags, messagetype, buttonstype, message, new object[0]);

            try
            {
                int res = dialog.Run();
                return((ResponseType)res);
            }
            finally
            {
                dialog.Destroy();
            }
        }
Esempio n. 5
0
File: Util.cs Progetto: MrJoe/lat
        public HIGMessageDialog(Gtk.Window parent,
                                Gtk.DialogFlags flags,
                                Gtk.MessageType type,
                                Gtk.ButtonsType buttons,
                                string header,
                                string msg)
            : base()
        {
            HasSeparator = false;
            BorderWidth  = 5;
            Resizable    = false;
            Title        = "";

            VBox.Spacing      = 12;
            ActionArea.Layout = Gtk.ButtonBoxStyle.End;

            accel_group = new Gtk.AccelGroup();
            AddAccelGroup(accel_group);

            Gtk.HBox hbox = new Gtk.HBox(false, 12);
            hbox.BorderWidth = 5;
            hbox.Show();
            VBox.PackStart(hbox, false, false, 0);

            Gtk.Image image = null;

            switch (type)
            {
            case Gtk.MessageType.Error:
                image = new Gtk.Image(Gtk.Stock.DialogError,
                                      Gtk.IconSize.Dialog);
                break;

            case Gtk.MessageType.Question:
                image = new Gtk.Image(Gtk.Stock.DialogQuestion,
                                      Gtk.IconSize.Dialog);
                break;

            case Gtk.MessageType.Info:
                image = new Gtk.Image(Gtk.Stock.DialogInfo,
                                      Gtk.IconSize.Dialog);
                break;

            case Gtk.MessageType.Warning:
                image = new Gtk.Image(Gtk.Stock.DialogWarning,
                                      Gtk.IconSize.Dialog);
                break;
            }

            image.Show();
            hbox.PackStart(image, false, false, 0);

            Gtk.VBox label_vbox = new Gtk.VBox(false, 0);
            label_vbox.Show();
            hbox.PackStart(label_vbox, true, true, 0);

            string title = String.Format("<span weight='bold' size='larger'>{0}" +
                                         "</span>\n",
                                         header);

            Gtk.Label label;

            label           = new Gtk.Label(title);
            label.UseMarkup = true;
            label.Justify   = Gtk.Justification.Left;
            label.LineWrap  = true;
            label.SetAlignment(0.0f, 0.5f);
            label.Show();
            label_vbox.PackStart(label, false, false, 0);

            label           = new Gtk.Label(msg);
            label.UseMarkup = true;
            label.Justify   = Gtk.Justification.Left;
            label.LineWrap  = true;
            label.SetAlignment(0.0f, 0.5f);
            label.Show();
            label_vbox.PackStart(label, false, false, 0);

            switch (buttons)
            {
            case Gtk.ButtonsType.None:
                break;

            case Gtk.ButtonsType.Ok:
                AddButton(Gtk.Stock.Ok, Gtk.ResponseType.Ok, true);
                break;

            case Gtk.ButtonsType.Close:
                AddButton(Gtk.Stock.Close, Gtk.ResponseType.Close, true);
                break;

            case Gtk.ButtonsType.Cancel:
                AddButton(Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, true);
                break;

            case Gtk.ButtonsType.YesNo:
                AddButton(Gtk.Stock.No, Gtk.ResponseType.No, false);
                AddButton(Gtk.Stock.Yes, Gtk.ResponseType.Yes, true);
                break;

            case Gtk.ButtonsType.OkCancel:
                AddButton(Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, false);
                AddButton(Gtk.Stock.Ok, Gtk.ResponseType.Ok, true);
                break;
            }

            if (parent != null)
            {
                TransientFor = parent;
            }

            if ((int)(flags & Gtk.DialogFlags.Modal) != 0)
            {
                Modal = true;
            }

            if ((int)(flags & Gtk.DialogFlags.DestroyWithParent) != 0)
            {
                DestroyWithParent = true;
            }
        }
Esempio n. 6
0
 internal void ShowMessageDialog(string message, string title, Gtk.ButtonsType buttonsType, Gtk.MessageType messageType)
 {
     Gtk.MessageDialog dlg = new Gtk.MessageDialog(new Gtk.Window("Message"),
                                                   Gtk.DialogFlags.Modal,
                                                   messageType,
                                                   buttonsType, message);
     dlg.Title = title;
     dlg.Run();
     dlg.Destroy();
 }
Esempio n. 7
0
        ///
        /// details: The details of the notification.  Links can be sepecified
        /// using anchor tags similar to those found in HTML.  Each link will
        /// be underlined and made blue.  When users click on the link, they
        /// will cause the LinkClicked event to fire.  An example details
        /// string with links would be:
        ///
        ///		Click <a href="MyLinkID">here</a> to open a new window.
        ///
        /// Multiple links may be specified.
        ///
        /// timeout: Specify the number of milliseconds to leave the popup on
        /// the screen.  Set to 0 to leave on the screen until the user closes
        /// it or the code which launched the window hides and destroys it.
        ///
        public NotifyWindow(Gtk.Widget parent, string message, string details,
                            Gtk.MessageType messageType, uint timeout)
            : base(Gtk.WindowType.Popup)
        {
            this.AppPaintable = true;
            parentWidget      = parent;
            this.timeout      = timeout;

            activeBackgroundColor   = new Gdk.Color(249, 253, 202);
            inactiveBackgroundColor = new Gdk.Color(255, 255, 255);

            Gtk.HBox outBox = new HBox();
            this.Add(outBox);
            outBox.BorderWidth = (uint)wbsize;

            Gtk.VBox closeBox = new VBox();
            closeBox.BorderWidth = 3;
            outBox.PackEnd(closeBox, true, true, 0);
            EventBox eBox = new EventBox();

            eBox.ButtonPressEvent +=
                new ButtonPressEventHandler(OnCloseEvent);
            Gtk.Image closeImg = new Gtk.Image();
            closeImg.SetFromStock(Gtk.Stock.Close,
                                  IconSize.Menu);
            eBox.Add(closeImg);
            closeBox.PackStart(eBox, false, false, 0);

            Label padder = new Label("");

            outBox.PackStart(padder, false, false, 5);

            Gtk.VBox vbox = new VBox();
            outBox.PackStart(vbox, true, true, 0);
            vbox.BorderWidth = 10;

            Gtk.HBox hbox = new HBox();
            hbox.Spacing = 5;
            vbox.PackStart(hbox, false, false, 0);

            VBox iconVBox = new VBox();

            hbox.PackStart(iconVBox, false, false, 0);

            Gtk.Image msgImage = new Gtk.Image();
            switch (messageType)
            {
            case Gtk.MessageType.Info:
                msgImage.SetFromStock(Gtk.Stock.DialogInfo,
                                      IconSize.Button);
                break;

            case Gtk.MessageType.Warning:
                msgImage.SetFromStock(Gtk.Stock.DialogWarning,
                                      IconSize.Button);
                break;

            case Gtk.MessageType.Question:
                msgImage.SetFromStock(Gtk.Stock.DialogQuestion,
                                      IconSize.Button);
                break;

            case Gtk.MessageType.Error:
                msgImage.SetFromStock(Gtk.Stock.DialogError,
                                      IconSize.Button);
                break;
            }

//			hbox.PackStart(msgImage, false, true, 0);
            iconVBox.PackStart(msgImage, false, false, 0);
//			vbox.Spacing = 5;
            // Fix for Bug #116812: iFolders w/ underscore characters are not
            // displayed correctly in bubble.
            // If we put the text in the constructor of the Label widget,
            // the markup is parsed to look for mnemonics.  If we just set
            // the Markup property later, the underscore character is
            // interpreted correctly.

            VBox messageVBox = new VBox();

            hbox.PackStart(messageVBox, true, true, 0);

            Label l = new Label();

            l.Markup       = "<span size=\"small\" weight=\"bold\">" + GLib.Markup.EscapeText(message) + "</span>";
            l.LineWrap     = false;
            l.UseMarkup    = true;
            l.Selectable   = false;
            l.Xalign       = 0;
            l.Yalign       = 0;
            l.LineWrap     = true;
            l.Wrap         = true;
            l.WidthRequest = messageTextWidth;
            messageVBox.PackStart(l, false, true, 0);

            detailsTextView = new LinkTextView(details);

            detailsTextView.Editable      = false;
            detailsTextView.CursorVisible = false;
            detailsTextView.WrapMode      = WrapMode.Word;

            // Determine how tall to make the TextView by allocating a random
            // height.  This will allow us to see the "optimal" height so that
            // all the text will be displayed without having to make the user
            // scroll through the details of the message.
            detailsTextView.SizeAllocate(new Gdk.Rectangle(0, 0, messageTextWidth, 600));

            detailsTextView.LinkClicked +=
                new LinkClickedEventHandler(OnLinkClicked);
            messageVBox.PackStart(detailsTextView, false, false, 3);

            // This spacer has to be here to make sure that the bottom of the
            // detailsTextView does not get chopped off.  I'm not sure why,
            // it's just another one of those crazy things we do.
            Label spacer = new Label();

            spacer.UseMarkup = true;
            spacer.Markup    = "<span size=\"xx-small\"> </span>";
            messageVBox.PackEnd(spacer, false, false, 0);

            closeWindowTimeoutID = 0;
        }