コード例 #1
0
ファイル: NotifyWindow.cs プロジェクト: RoDaniel/featurehouse
  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;
         }
         iconVBox.PackStart(msgImage, false, false, 0);
         VBox messageVBox = new VBox();
         hbox.PackStart(messageVBox, true, true, 0);
         Label l = new Label();
         l.Markup = "<span size=\"small\" weight=\"bold\">" + 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;
         detailsTextView.SizeAllocate(new Gdk.Rectangle(0, 0, messageTextWidth, 600));
         detailsTextView.LinkClicked +=
      new LinkClickedEventHandler(OnLinkClicked);
         messageVBox.PackStart(detailsTextView, false, false, 3);
         Label spacer = new Label();
         spacer.UseMarkup = true;
         spacer.Markup = "<span size=\"xx-small\"> </span>";
         messageVBox.PackEnd(spacer, false, false, 0);
         closeWindowTimeoutID = 0;
  }
コード例 #2
0
ファイル: NotifyWindow.cs プロジェクト: lulzzz/ifolder
        ///
        /// 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;
        }