public DemoSpinner () : base ("Spinner", null, DialogFlags.DestroyWithParent) { Resizable = false; VBox vbox = new VBox (false, 5); vbox.BorderWidth = 5; ContentArea.PackStart (vbox, true, true, 0); /* Sensitive */ HBox hbox = new HBox (false, 5); spinner_sensitive = new Spinner (); hbox.Add (spinner_sensitive); hbox.Add (new Entry ()); vbox.Add (hbox); /* Disabled */ hbox = new HBox (false, 5); spinner_unsensitive = new Spinner (); spinner_unsensitive.Sensitive = false; hbox.Add (spinner_unsensitive); hbox.Add (new Entry ()); vbox.Add (hbox); Button btn_play = new Button (); btn_play.Label = "Play"; btn_play.Clicked += OnPlayClicked; vbox.Add (btn_play); Button btn_stop = new Button (); btn_stop.Label = "Stop"; btn_stop.Clicked += OnStopClicked; vbox.Add (btn_stop); AddButton (Stock.Close, ResponseType.Close); OnPlayClicked (null, null); ShowAll (); Run (); Destroy (); }
public SparkleEventLog () : base ("Recent Changes") { SetWmclass ("SparkleShare", "SparkleShare"); Gdk.Rectangle monitor_0_rect = Gdk.Screen.Default.GetMonitorGeometry (0); SetSizeRequest (480, (int) (monitor_0_rect.Height * 0.8)); IconName = "sparkleshare"; this.pos_x = (int) (monitor_0_rect.Width * 0.61); this.pos_y = (int) (monitor_0_rect.Height * 0.5 - (HeightRequest * 0.5)); this.size_label = new Label () { Xalign = 0, Markup = "<b>Size:</b> …" }; this.history_label = new Label () { Xalign = 0, Markup = "<b>History:</b> …" }; this.size_label.SetSizeRequest (100, 24); HBox layout_sizes = new HBox (false, 0); layout_sizes.PackStart (this.size_label, false, false, 12); layout_sizes.PackStart (this.history_label, false, false, 0); VBox layout_vertical = new VBox (false, 0); this.spinner = new Spinner (); this.spinner_wrapper = new VBox (); this.content_wrapper = new EventBox (); this.scrolled_window = new ScrolledWindow (); this.content_wrapper.OverrideBackgroundColor (StateFlags.Normal, new Gdk.RGBA () { Red = 1, Green = 1, Blue=1, Alpha = 1 }); this.web_view = new WebView () { Editable = false }; this.web_view.NavigationRequested += WebViewNavigationRequested; this.scrolled_window.Add (this.web_view); this.spinner_wrapper = new VBox (false, 0); this.spinner_wrapper.PackStart (new Label(""), true, true, 0); this.spinner_wrapper.PackStart (this.spinner, false, false, 0); this.spinner_wrapper.PackStart (new Label(""), true, true, 0); this.spinner.SetSizeRequest (24, 24); this.spinner.Start (); this.content_wrapper.Add (this.spinner_wrapper); this.layout_horizontal = new HBox (false, 0); this.layout_horizontal.PackStart (layout_sizes, true, true, 12); layout_vertical.PackStart (this.layout_horizontal, false, false, 0); layout_vertical.PackStart (new HSeparator (), false, false, 0); layout_vertical.PackStart (this.content_wrapper, true, true, 0); Add (layout_vertical); Controller.HideWindowEvent += delegate { Application.Invoke (delegate { Hide (); if (this.content_wrapper.Child != null) this.content_wrapper.Remove (this.content_wrapper.Child); }); }; Controller.ShowWindowEvent += delegate { Application.Invoke (delegate { Move (this.pos_x, this.pos_y); ShowAll (); Present (); }); }; Controller.ShowSaveDialogEvent += delegate (string file_name, string target_folder_path) { Application.Invoke (delegate { FileChooserDialog dialog = new FileChooserDialog ("Restore from History", this, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save", ResponseType.Ok); dialog.CurrentName = file_name; dialog.DoOverwriteConfirmation = true; dialog.SetCurrentFolder (target_folder_path); if (dialog.Run () == (int) ResponseType.Ok) Controller.SaveDialogCompleted (dialog.Filename); else Controller.SaveDialogCancelled (); dialog.Destroy (); }); }; Controller.UpdateChooserEvent += delegate (string [] folders) { Application.Invoke (delegate { UpdateChooser (folders); }); }; Controller.UpdateChooserEnablementEvent += delegate (bool enabled) { Application.Invoke (delegate { this.combo_box.Sensitive = enabled; }); }; Controller.UpdateContentEvent += delegate (string html) { Application.Invoke (delegate { UpdateContent (html); }); }; Controller.ContentLoadingEvent += delegate { Application.Invoke (delegate { if (this.content_wrapper.Child != null) this.content_wrapper.Remove (this.content_wrapper.Child); this.content_wrapper.Add (this.spinner_wrapper); this.spinner.Start (); }); }; Controller.UpdateSizeInfoEvent += delegate (string size, string history_size) { Application.Invoke (delegate { this.size_label.Markup = "<b>Size</b> " + size; this.history_label.Markup = "<b>History</b> " + history_size; }); }; 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 (); } }; }
public EventLog () : base ("Recent Changes") { SetWmclass ("SparkleShare", "SparkleShare"); TypeHint = Gdk.WindowTypeHint.Dialog; IconName = "org.sparkleshare.SparkleShare"; SetSizeRequest (480, 640); Gdk.Rectangle monitor_0_rect = Gdk.Screen.Default.GetMonitorGeometry (0); pos_x = (int) (monitor_0_rect.Width * 0.61); pos_y = (int) (monitor_0_rect.Height * 0.5 - (HeightRequest * 0.5)); Resize (480, (int) (monitor_0_rect.Height * 0.8)); this.size_label = new Label () { Xalign = 0, Markup = "<b>Size:</b> …" }; this.history_label = new Label () { Xalign = 0, Markup = "<b>History:</b> …" }; this.size_label.SetSizeRequest (100, 24); HBox layout_sizes = new HBox (false, 0); layout_sizes.PackStart (this.size_label, false, false, 12); layout_sizes.PackStart (this.history_label, false, false, 0); VBox layout_vertical = new VBox (false, 0); this.spinner = new Spinner (); this.spinner_wrapper = new VBox (); this.content_wrapper = new EventBox (); this.scrolled_window = new ScrolledWindow (); CssProvider css_provider = new CssProvider (); css_provider.LoadFromData ("GtkEventBox { background-color: #ffffff; }"); this.content_wrapper.StyleContext.AddProvider (css_provider, 800); this.web_view = CreateWebView (); this.scrolled_window.Add (this.web_view); this.spinner_wrapper = new VBox (false, 0); this.spinner_wrapper.PackStart (new Label(""), true, true, 0); this.spinner_wrapper.PackStart (this.spinner, false, false, 0); this.spinner_wrapper.PackStart (new Label(""), true, true, 0); this.spinner.SetSizeRequest (24, 24); this.spinner.Start (); this.content_wrapper.Add (this.spinner_wrapper); layout_vertical.PackStart (this.content_wrapper, true, true, 0); Add (layout_vertical); Controller.HideWindowEvent += delegate { Application.Invoke (delegate { Hide (); if (this.content_wrapper.Child != null) this.content_wrapper.Remove (this.content_wrapper.Child); }); }; Controller.ShowWindowEvent += delegate { Application.Invoke (delegate { Move (pos_x, pos_y); ShowAll (); Present (); }); }; Controller.ShowSaveDialogEvent += delegate (string file_name, string target_folder_path) { Application.Invoke (delegate { FileChooserDialog dialog = new FileChooserDialog ("Restore from History", this, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save", ResponseType.Ok); dialog.CurrentName = file_name; dialog.DoOverwriteConfirmation = true; dialog.SetCurrentFolder (target_folder_path); if (dialog.Run () == (int) ResponseType.Ok) Controller.SaveDialogCompleted (dialog.Filename); else Controller.SaveDialogCancelled (); dialog.Destroy (); }); }; Controller.UpdateContentEvent += delegate (string html) { Application.Invoke (delegate { UpdateContent (html); }); }; Controller.ContentLoadingEvent += delegate { Application.Invoke (delegate { if (this.content_wrapper.Child != null) this.content_wrapper.Remove (this.content_wrapper.Child); this.content_wrapper.Add (this.spinner_wrapper); this.spinner.Start (); }); }; Controller.UpdateSizeInfoEvent += delegate (string size, string history_size) { Application.Invoke (delegate { this.size_label.Markup = "<b>Size</b> " + size; this.history_label.Markup = "<b>History</b> " + history_size; }); }; 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 (); } }; }