public static void LoadIcon(this Gtk.Image image, string iconId, Gtk.IconSize size) { AnimatedImageInfo ainfo = animatedImages.Select(a => (AnimatedImageInfo)a.Target).FirstOrDefault(a => a != null && a.Image == image); if (ainfo != null) { if (ainfo.AnimatedIcon.AnimationSpec == iconId) { return; } UnregisterImageAnimation(ainfo); } if (IsAnimation(iconId, size)) { var anim = GetAnimatedIcon(iconId); ainfo = new AnimatedImageInfo(image, anim); ainfo.Animation = anim.StartAnimation(delegate(Xwt.Drawing.Image pix) { image.Pixbuf = pix.ToPixbuf(); }); animatedImages.Add(new WeakReference(ainfo)); } else { image.SetFromStock(iconId, size); } }
// Methods // Methods :: Private // Methods :: Private :: Sync /// <summary> /// Synchronizes the image with the desired cover. /// </summary> /// <remarks> /// If a cover is located in the database that is associated /// with the same song that we are associated with, use that. /// If we are associated with a song whose cover is currently /// being downloaded, show a temporary cover. If we have no /// associated song, use a default cover. /// </remarks> private void Sync() { // Image if (song != null && song.CoverImage != null) { image.Pixbuf = song.CoverImage; } else if (song != null && Global.CoverDB.Loading) { image.Pixbuf = Global.CoverDB.DownloadingPixbuf; } else { image.SetFromStock ("muine-default-cover", StockIcons.CoverSize); } // DnD Entries TargetEntry [] entries; if (song != null && !Global.CoverDB.Loading) { entries = drag_entries; } else { entries = null; } // DnD Destination Gtk.Drag.DestSet (this, DestDefaults.All, entries, Gdk.DragAction.Copy); }
public ActionMenuItem (TileAction action) : base (action.Name) { this.action_delegate = action.Action; if (action.Stock != null) { Gtk.Image image = new Gtk.Image (); image.SetFromStock (action.Stock, IconSize.Menu); image.Show (); this.Image = image; } }
public ActionMenuItem(TileAction action) : base(action.Name) { this.action_delegate = action.Action; if (action.Stock != null) { Gtk.Image image = new Gtk.Image(); image.SetFromStock(action.Stock, IconSize.Menu); image.Show(); this.Image = image; } }
public static void ErrorAlert(string primary, string secondary, Gtk.Window parent) { Gtk.Image image = new Gtk.Image(); image.SetFromStock(Gtk.Stock.DialogError, Gtk.IconSize.Dialog); Gtk.Dialog dialog = Alert(primary, secondary, image, parent); // prepare error dialog dialog.AddButton(Gtk.Stock.Ok, ResponseType.Ok); dialog.ShowAll(); // run dialog dialog.Run(); dialog.Destroy(); }
public iFolderExceptionDialog( Gtk.Window parent, System.Exception exception) : base() { this.Title = Util.GS("iFolder Error"); this.HasSeparator = true; this.Resizable = false; this.Modal = true; this.ex = exception; if(parent != null) this.TransientFor = parent; HBox h = new HBox(); h.BorderWidth = 10; h.Spacing = 10; Image i = new Image(); i.SetFromStock(Gtk.Stock.DialogError, IconSize.Dialog); i.SetAlignment(0.5F, 0); h.PackStart(i, false, false, 0); VBox v = new VBox(); v.BorderWidth = 10; v.Spacing = 10; Label l = new Label("<span weight=\"bold\" size=\"larger\">" + GLib.Markup.EscapeText(exception.Message) + "</span>"); l.LineWrap = true; l.UseMarkup = true; l.UseUnderline = false; l.Selectable = true; l.Xalign = 0; l.Yalign = 0; v.PackStart(l); dButton = new Button(Util.GS("Show Details")); dButton.Clicked += new EventHandler(ButtonPressed); HBox bhbox = new HBox(); bhbox.PackStart(dButton, false, false, 0); v.PackEnd(bhbox, false, false, 0); details = new Label(Util.GS("Click \"Show Details\" below to get the full message returned with this error")); details.LineWrap = true; details.Selectable = true; details.Xalign = 0; details.Yalign = 0; v.PackEnd(details); h.PackEnd(v); h.ShowAll(); this.VBox.Add(h); this.AddButton(Stock.Close, ResponseType.Ok); }
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; }
protected void TrocaLabel(object sender, System.EventArgs e) { Image img = new Image(); img.SetFromStock(Stock.SortAscending, IconSize.Button); if (botaoOrdena.Label == "Ordem natural") { vetor = JanelaPrincipal.copiaBruta; botaoOrdena.Label = "Ordenar lista"; botaoOrdena.Image = img; vetorEscolhido = 'C'; } else { vetor = JanelaPrincipal.vetorDT; botaoOrdena.Label = "Ordem natural"; botaoOrdena.Image = img; vetorEscolhido = 'V'; } Atualiza(); }
internal void Init(Gtk.Window parent, DialogType type, ButtonSet buttonSet, string title, string statement, string secondaryStatement, string details) { this.Title = title; this.HasSeparator = false; this.Resizable = false; this.Modal = true; if(parent != null) this.TransientFor = parent; HBox h = new HBox(); h.BorderWidth = 10; h.Spacing = 10; dialogImage = new Image(); switch(type) { case DialogType.Error: dialogImage.SetFromStock(Gtk.Stock.DialogError, IconSize.Dialog); break; case DialogType.Question: dialogImage.SetFromStock(Gtk.Stock.DialogQuestion, IconSize.Dialog); break; case DialogType.Warning: dialogImage.SetFromStock(Gtk.Stock.DialogWarning, IconSize.Dialog); break; default: case DialogType.Info: dialogImage.SetFromStock(Gtk.Stock.DialogInfo, IconSize.Dialog); break; } dialogImage.SetAlignment(0.5F, 0); h.PackStart(dialogImage, false, false, 0); VBox v = new VBox(); v.Spacing = 10; Label l = new Label(); l.LineWrap = true; l.UseMarkup = true; l.Selectable = false; l.CanFocus = false; l.Xalign = 0; l.Yalign = 0; l.Markup = "<span weight=\"bold\" size=\"larger\">" + GLib.Markup.EscapeText(statement) + "</span>"; v.PackStart(l); l = new Label(secondaryStatement); l.LineWrap = true; l.Selectable = false; l.CanFocus = false; l.Xalign = 0; l.Yalign = 0; v.PackStart(l, true, true, 8); if (details != null) { detailsExpander = new Expander(Util.GS("_Details")); v.PackStart(detailsExpander, false, false, 0); TextView textView = new TextView(); textView.Editable = false; textView.WrapMode = WrapMode.Char; TextBuffer textBuffer = textView.Buffer; textBuffer.Text = details; showDetailsScrolledWindow = new ScrolledWindow(); detailsExpander.Add(showDetailsScrolledWindow); showDetailsScrolledWindow.AddWithViewport(textView); showDetailsScrolledWindow.Visible = false; } extraWidgetVBox = new VBox(false, 0); v.PackStart(extraWidgetVBox, false, false, 0); extraWidgetVBox.NoShowAll = true; extraWidget = null; h.PackEnd(v); h.ShowAll(); this.VBox.Add(h); Widget defaultButton; switch(buttonSet) { default: case ButtonSet.Ok: defaultButton = this.AddButton(Stock.Ok, ResponseType.Ok); break; case ButtonSet.OkCancel: this.AddButton(Stock.Cancel, ResponseType.Cancel); defaultButton = this.AddButton(Stock.Ok, ResponseType.Ok); break; case ButtonSet.YesNo: this.AddButton(Stock.No, ResponseType.No); defaultButton = this.AddButton(Stock.Yes, ResponseType.Yes); break; } defaultButton.CanDefault = true; defaultButton.GrabFocus(); }
public RemoveAccountDialog(DomainInformation domainInfo) : base() { this.Title = ""; this.Resizable = false; this.HasSeparator = false; HBox h = new HBox(); h.BorderWidth = 10; h.Spacing = 10; Image i = new Image(); i.SetFromStock(Gtk.Stock.DialogQuestion, IconSize.Dialog); i.SetAlignment(0.5F, 0); h.PackStart(i, false, false, 0); VBox v = new VBox(); Label l = new Label("<span weight=\"bold\" size=\"larger\">" + Util.GS("Remove this iFolder account?") + "</span>"); l.LineWrap = true; l.UseMarkup = true; l.Selectable = false; l.Xalign = 0; l.Yalign = 0; v.PackStart(l, false, false, 10); Table table = new Table(3, 2, false); table.RowSpacing = 0; table.ColumnSpacing = 10; table.Homogeneous = false; l = new Label(Util.GS("System Name:")); l.Xalign = 1; table.Attach(l, 0,1, 0,1, AttachOptions.Shrink | AttachOptions.Fill, 0,0,0); l = new Label(domainInfo.Name); l.UseUnderline = false; l.Xalign = 0; table.Attach(l, 1,2, 0,1, AttachOptions.Fill | AttachOptions.Expand, 0,0,0); l = new Label(Util.GS("Server:")); l.Xalign = 1; table.Attach(l, 0,1, 1,2, AttachOptions.Shrink | AttachOptions.Fill, 0,0,0); l = new Label(domainInfo.Host); l.Xalign = 0; table.Attach(l, 1,2, 1,2, AttachOptions.Fill | AttachOptions.Expand, 0,0,0); l = new Label(Util.GS("Username:"******"_Remove my iFolders and files from the server")); this.VBox.PackStart(cbutton, false, false, 10); cbutton.Toggled += new EventHandler(OnRemoveiFoldersToggled); if (!domainInfo.Active || !domainInfo.Authenticated) { cbutton.Sensitive = false; } this.VBox.ShowAll(); Button noButton = new Button(Stock.No); noButton.CanFocus = true; noButton.CanDefault = true; noButton.ShowAll(); this.AddActionWidget(noButton, ResponseType.No); this.AddButton(Stock.Yes, ResponseType.Yes); this.DefaultResponse = ResponseType.No; this.FocusChild = noButton; }
/// /// 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; }
public GtkAlertDialog(MessageDescription message) { Init(); this.buttons = message.Buttons.ToArray(); string primaryText; string secondaryText; if (string.IsNullOrEmpty(message.SecondaryText)) { secondaryText = message.Text; primaryText = null; } else { primaryText = message.Text; secondaryText = message.SecondaryText; } image.SetFromStock(Util.ToGtkStock(message.Icon), Gtk.IconSize.Dialog); StringBuilder markup = new StringBuilder(@"<span weight=""bold"" size=""larger"">"); markup.Append(GLib.Markup.EscapeText(primaryText)); markup.Append("</span>"); if (!String.IsNullOrEmpty(secondaryText)) { if (!String.IsNullOrEmpty(primaryText)) { markup.AppendLine(); markup.AppendLine(); } markup.Append(GLib.Markup.EscapeText(secondaryText)); } label.Markup = markup.ToString(); label.Selectable = true; label.CanFocus = false; foreach (Command button in message.Buttons) { Gtk.Button newButton = new Gtk.Button(); newButton.Label = button.Label; newButton.UseUnderline = true; newButton.UseStock = button.IsStockButton; if (!String.IsNullOrEmpty(button.Icon)) { newButton.Image = new Gtk.Image(Util.ToGtkStock(button.Icon), Gtk.IconSize.Button); } newButton.Clicked += ButtonClicked; ActionArea.Add(newButton); } foreach (var op in message.Options) { CheckButton check = new CheckButton(op.Text); check.Active = op.Value; labelsBox.PackStart(check, false, false, 0); check.Toggled += delegate { message.SetOptionValue(op.Id, check.Active); }; } if (message.AllowApplyToAll) { CheckButton check = new CheckButton("Apply to all"); labelsBox.PackStart(check, false, false, 0); check.Toggled += delegate { ApplyToAll = check.Active; }; } //don't show this yet, let the consumer decide when this.Child.ShowAll(); }
void HandleGeneratebuttonClicked(object sender, EventArgs e) { Dialog d = new Dialog ("Generate Seed", this.window, DialogFlags.DestroyWithParent, Stock.Ok, ResponseType.Ok, Stock.Cancel, ResponseType.Cancel); HBox hbox1 = new HBox (false, 0); Image icon = new Image (); icon.SetFromStock (Stock.DialogQuestion, IconSize.Dialog); Label l1 = new Label (); l1.Text = "<span weight=\"bold\" size=\"x-large\">Enter in a seed for the random name generator below.</span>"; l1.UseMarkup = true; hbox1.PackStart (icon, false, true, 0); hbox1.PackEnd (l1, false, true, 0); HBox hbox2 = new HBox (false, 0); Random r = new Random (DateTime.Now.Millisecond); Entry entry = new Entry (r.Next ().ToString ()); hbox2.PackStart (new Label ("Enter seed integer:"), false, true, 0); hbox2.PackEnd (entry); d.VBox.PackStart (hbox1, false, true, 0); d.VBox.PackEnd (hbox2, true, true, 0); d.ShowAll (); int result = d.Run (); if ((ResponseType)result == ResponseType.Ok) { try { int seed = Convert.ToInt32 (entry.Text); this.HandleGenerateName (seed); } catch (ArgumentNullException ex) { this.ReportError (ex); } catch (FormatException ex) { this.ReportError (ex); } catch (OverflowException ex) { this.ReportError (ex); } } d.Hide (); d.Destroy (); }
public void ReportError(Exception ex) { Dialog d = new Dialog (ex.GetType ().ToString (), this.window, DialogFlags.DestroyWithParent, Stock.Ok, ResponseType.Ok); Image icon = new Image (); icon.SetFromStock (Stock.DialogError, IconSize.Dialog); Label l1 = new Label (); l1.Text = "<span weight=\"bold\" size=\"x-large\">" + ex.GetType ().ToString () + "</span>"; l1.UseMarkup = true; HBox hbox = new HBox (false, 0); hbox.PackStart (icon, false, true, 0); hbox.PackEnd (l1, true, true, 0); d.VBox.PackStart (hbox, false, true, 0); d.VBox.PackStart (new Label (ex.Message), false, true, 0); d.VBox.PackStart (new Label (ex.Source), false, true, 0); ScrolledWindow sw = new ScrolledWindow (); TextView tv = new TextView (); tv.Editable = false; tv.Buffer.Text = ex.StackTrace; sw.Add (tv); d.VBox.PackEnd (sw, true, true, 0); d.ShowAll (); d.Run (); d.Hide (); d.Destroy (); }
// Methods :: Private :: UpdateImage private void UpdateImage() { string icon = (playing) ? "muine-tray-playing" : "muine-tray-paused"; image.SetFromStock(icon, IconSize.Menu); }