public RecentFileListWindow(string title, Gtk.Window parent, DialogFlags flags, params object[] button_data) : base(title, parent, flags, button_data) { _searchView = new Gtk.Entry (""); _searchView.SetSizeRequest (500, 40); _searchView.Changed += _searchView_Changed; _searchView.KeyReleaseEvent += HandleSearchViewKeyReleaseEvent; _searchView.KeyPressEvent += HandleKeyPressEvent; _searchView.FocusOutEvent += HandleFocusOutEvent; VBox.Add (_searchView); CreateTree (); VBox.Add (_treeView); _pathLabel = new Gtk.Label (); _pathLabel.SetSizeRequest (500, 40); VBox.Add (_pathLabel); MemberExtensionsHelper.Instance.IsDirty = true; UpdateDocuments (); this.SetSizeRequest (500, 700); CanFocus = true; _searchView.CanFocus = true; _searchView.IsEditable = true; _searchView.GrabFocus (); ShowAll (); }
public void OnEditFind(object sender, EventArgs args) { findlabel.Text = String.Empty; OnFindEntryChange(sender, args); findbar.Visible = true; findentry.GrabFocus(); }
public MemberListWindow(string title, Gtk.Window parent, DialogFlags flags, params object[] button_data) : base(title, parent, flags, button_data) { if (IdeApp.Workbench == null) { return; } var rootWindow = IdeApp.Workbench.RootWindow; _searchView = new Gtk.Entry (""); _searchView.SetSizeRequest (500, 40); _searchView.Changed += _searchView_Changed; _searchView.KeyReleaseEvent += HandleSearchViewKeyReleaseEvent; _searchView.KeyPressEvent += HandleKeyPressEvent; _searchView.FocusOutEvent += HandleFocusOutEvent; VBox.Add (_searchView); CreateTree (); VBox.Add (_treeView); MemberExtensionsHelper.Instance.IsDirty = true; UpdateMembers (); var editor = IdeApp.Workbench.ActiveDocument.Editor; var visualInsertLocation = editor.LogicalToVisualLocation (editor.Caret.Location); var targetView = IdeApp.Workbench.RootWindow; this.SetSizeRequest (500, 700); CanFocus = true; _searchView.CanFocus = true; _searchView.IsEditable = true; _searchView.GrabFocus (); ShowAll (); }
public void rename_category(bool is_create) { Gtk.Entry rename_entry = new Gtk.Entry(); rename_entry.Text = category.metalabel.label; rename_entry.Name = "rename_cat"; rename_entry.AddEvents((int)Gdk.EventMask.KeyReleaseMask); rename_entry.KeyReleaseEvent += delegate (object sender, Gtk.KeyReleaseEventArgs e) { on_rename_cat_key_release(e, is_create); }; int pos = 0; foreach (Widget w in representation) { if (w.Name == category.metalabel.label) { w.Destroy(); break; } else ++pos; } representation.PackStart(rename_entry, false, false, 6); representation.ReorderChild(rename_entry, pos); representation.ShowAll(); rename_entry.GrabFocus(); }
public RecentFileListWindow(string title, Gtk.Window parent, DialogFlags flags, params object[] button_data) : base(title, parent, flags, button_data) { _searchView = new Gtk.Entry(""); _searchView.SetSizeRequest(500, 40); _searchView.Changed += _searchView_Changed; _searchView.KeyReleaseEvent += HandleSearchViewKeyReleaseEvent; _searchView.KeyPressEvent += HandleKeyPressEvent; _searchView.FocusOutEvent += HandleFocusOutEvent; VBox.Add(_searchView); CreateTree(); _scrolledWindow = new Gtk.ScrolledWindow(); _scrolledWindow.SetSizeRequest(500, 600); _scrolledWindow.Add(_treeView); VBox.Add(_scrolledWindow); _pathLabel = new Gtk.Label(); _pathLabel.SetSizeRequest(500, 40); VBox.Add(_pathLabel); MemberExtensionsHelper.Instance.IsDirty = true; UpdateDocuments(); VBox.SetSizeRequest(500, 700); this.SetSizeRequest(500, 700); CanFocus = true; _searchView.CanFocus = true; _searchView.IsEditable = true; _searchView.GrabFocus(); ShowAll(); }
///<summary>Load the widget with data from the DataView's selection</summary> public void LoadWithSelection(DataView dv) { // load selection only if it isn't very large if (dv.Selection.Size > 0) { Bless.Util.Range sel = dv.Selection; FromEntry.Text = sel.Start.ToString(); ToEntry.Text = sel.End.ToString(); } else { FromEntry.Text = dv.CursorOffset.ToString(); } FromEntry.GrabFocus(); }
private void OnFilterItemSelected(object sender, EventArgs a) { if (!FilterBar.Visible) { FilterBar.Show(); } FilterEntry.GrabFocus(); }
public GMan() { Application.Init(); window = new Gtk.Window("GMan"); window.SetDefaultSize(800, 600); window.DeleteEvent += new DeleteEventHandler(OnWindowDelete); // FIXME: we should remember where we were when we last ran. window.WindowPosition = WindowPosition.Center; VBox vbox = new VBox(false, 2); window.Add(vbox); vbox.PackStart(MakeMenuBar(), false, false, 1); HBox hbox = new HBox(false, 1); Label label = new Label("Search:"); entry = new Gtk.Entry(""); entry.Activated += new EventHandler(OnEntryActivated); Button button = new Button("!"); button.Clicked += new EventHandler(OnButtonClicked); Button backButton = new Button(Stock.GoBack); Button forwardButton = new Button(Stock.GoForward); hbox.PackStart(backButton, false, false, 1); hbox.PackStart(forwardButton, false, false, 1); hbox.PackStart(label, false, false, 1); hbox.PackStart(entry, true, true, 1); hbox.PackStart(button, false, false, 1); vbox.PackStart(hbox, false, false, 1); ScrolledWindow sw = new ScrolledWindow(); sw.VscrollbarPolicy = PolicyType.Always; sw.HscrollbarPolicy = PolicyType.Always; vbox.PackStart(sw, true, true, 1); statusBar = new Gtk.Statusbar(); vbox.PackStart(statusBar, false, false, 1); html = new HTML(); html.LinkClicked += new LinkClickedHandler(OnLinkClicked); html.OnUrl += new OnUrlHandler(OnOnUrl); html.TitleChanged += new TitleChangedHandler(OnTitleChanged); sw.Add(html); window.ShowAll(); entry.GrabFocus(); Application.Run(); }
// These are UI elements dependent of the game status public void ActiveInputControls(bool active) { bool answer, next, tip, can_pause; can_pause = answer = next = tip = active; if (active == true && session.CurrentGame != null && session.CurrentGame.ButtonsActive == true && String.IsNullOrEmpty(session.CurrentGame.Tip) == false) { tip = true; } else { tip = false; } switch (session.Status) { case GameSession.SessionStatus.NotPlaying: case GameSession.SessionStatus.Finished: answer = false; next = false; tip = false; can_pause = false; break; case GameSession.SessionStatus.Playing: if (session.CurrentGame != null) { can_pause = session.CurrentGame.ButtonsActive; } else { can_pause = true; } break; case GameSession.SessionStatus.Answered: answer = false; tip = false; can_pause = false; break; } answer_button.Sensitive = answer; answer_entry.Sensitive = answer; answer_label.Sensitive = answer; next_button.Sensitive = next; tip_button.Sensitive = tip; pause_menuitem.Sensitive = toolbar.PauseButton.Sensitive = can_pause; if (answer == true) { answer_entry.GrabFocus(); } }
void OnWidgetShown(object o, EventArgs args) { // when the dialog is shown, select and give the focus // to the previously focused widget if (previouslyFocused != null) { previouslyFocused.GrabFocus(); } else { SearchPatternEntry.GrabFocus(); } }
private void Initialize() { Dialog.Title = Catalog.GetString("New Smart Playlist"); builder = new BansheeQueryBox(); builder.Show(); builder.Spacing = 4; builder_box.PackStart(builder, true, true, 0); name_entry.Changed += HandleNameChanged; // Model is Name, SmartPlaylistDefinition ListStore list_model = new ListStore(typeof(string), typeof(SmartPlaylistDefinition)); bool have_any_predefined = false; foreach (SmartPlaylistDefinition def in primary_source.PredefinedSmartPlaylists) { list_model.AppendValues( String.Format("<b>{0}</b>\n<small>{1}</small>", def.Name, def.Description), def ); have_any_predefined = true; } adv_tree_view.Selection.Mode = SelectionMode.Multiple; adv_tree_view.Model = list_model; CellRendererText renderer = new CellRendererText(); renderer.Ellipsize = Pango.EllipsizeMode.End; adv_tree_view.AppendColumn("title", renderer, "markup", 0); adv_tree_view.Selection.Changed += HandleAdvSelectionChanged; UpdateAdvButtons(0); adv_add_button.Clicked += HandleAdvAdd; adv_use_button.Clicked += HandleAdvUse; if (!have_any_predefined) { advanced_expander.NoShowAll = true; advanced_expander.Hide(); } Update(); name_entry.GrabFocus(); }
private void BuildControl(string textEntry, string textLabel, bool onlyInt,Gtk.Window parent) { this.onlyInt =onlyInt; this.TransientFor = parent; HBox hbox = new HBox(false, 8); hbox.BorderWidth = 8; this.VBox.PackStart(hbox, false, false, 0); Image stock = new Image(Stock.DialogQuestion, IconSize.Dialog); hbox.PackStart(stock, false, false, 0); Table table = new Table(2, 2, false); table.RowSpacing = 4; table.ColumnSpacing = 4; hbox.PackStart(table, true, true, 0); Label label = new Label(textLabel); table.Attach(label, 0, 1, 0, 1); if (!onlyInt){ localEntry1 = new Entry(); localEntry1.Text = textEntry;//textEntry; //localEntry1.Changed += delegate(object sender, EventArgs e) { textEntry = localEntry1.Text; }; table.Attach(localEntry1, 1, 2, 0, 1); label.MnemonicWidget = localEntry1; localEntry1.KeyPressEvent+= new KeyPressEventHandler(OnKeyPress); localEntry1.GrabFocus(); } else { localSpin = new SpinButton(1,10000,10); localSpin.Digits = 0; localSpin.Numeric = true; localSpin.KeyPressEvent+= new KeyPressEventHandler(OnKeyPress); table.Attach(localSpin, 1, 2, 0, 1); label.MnemonicWidget = localSpin; localSpin.GrabFocus(); } this.AddButton(MainClass.Languages.Translate("cancel"), ResponseType.Cancel); this.AddButton(MainClass.Languages.Translate("ok"), ResponseType.Ok); this.ShowAll(); }
void OnValueEditing(object s, Gtk.EditingStartedArgs args) { TreeIter it; if (!store.GetIterFromString(out it, args.Path)) { return; } Gtk.Entry e = (Gtk.Entry)args.Editable; ObjectValue val = store.GetValue(it, ObjectCol) as ObjectValue; string strVal = val.Value; if (!string.IsNullOrEmpty(strVal)) { e.Text = strVal; } e.GrabFocus(); OnStartEditing(args); }
public MemberListWindow(string title, Gtk.Window parent, DialogFlags flags, IUnresolvedEntity selectedEntry, params object[] button_data) : base(title, parent, flags, button_data) { if (IdeApp.Workbench == null) { return; } SelectedEntity = selectedEntry; _searchView = new Gtk.Entry(""); _searchView.SetSizeRequest(500, 40); _searchView.Changed += _searchView_Changed; _searchView.KeyReleaseEvent += HandleSearchViewKeyReleaseEvent; _searchView.KeyPressEvent += HandleKeyPressEvent; _searchView.FocusOutEvent += HandleFocusOutEvent; VBox.Add(_searchView); CreateTree(); _scrolledWindow = new Gtk.ScrolledWindow(); _scrolledWindow.SetSizeRequest(500, 600); _scrolledWindow.Add(_treeView); VBox.Add(_scrolledWindow); MemberExtensionsHelper.Instance.IsDirty = true; UpdateMembers(); var editor = IdeApp.Workbench.ActiveDocument.Editor; var visualInsertLocation = editor.LogicalToVisualLocation(editor.Caret.Location); var targetView = IdeApp.Workbench.RootWindow; this.SetSizeRequest(500, 700); CanFocus = true; _searchView.CanFocus = true; _searchView.IsEditable = true; _searchView.GrabFocus(); ShowAll(); }
private void ShowAdd1Page() { Header = CmisSync.Properties_Resources.ResourceManager.GetString("Where", CultureInfo.CurrentCulture); VBox layout_vertical = new VBox (false, 12); HBox layout_fields = new HBox (true, 12); VBox layout_address = new VBox (true, 0); HBox layout_address_help = new HBox(false, 3); VBox layout_user = new VBox (true, 0); VBox layout_password = new VBox (true, 0); // Address Label address_label = new Label() { UseMarkup = true, Xalign = 0, Markup = "<b>" + CmisSync.Properties_Resources.ResourceManager.GetString("EnterWebAddress", CultureInfo.CurrentCulture) + "</b>" }; Entry address_entry = new Entry () { Text = Controller.PreviousAddress, ActivatesDefault = false }; Label address_help_label = new Label() { Xalign = 0, UseMarkup = true, Markup = "<span foreground=\"#808080\" size=\"small\">" + CmisSync.Properties_Resources.ResourceManager.GetString("Help", CultureInfo.CurrentCulture) + ": " + "</span>" }; EventBox address_help_urlbox = new EventBox(); Label address_help_urllabel = new Label() { Xalign = 0, UseMarkup = true, Markup = "<span foreground=\"blue\" underline=\"single\" size=\"small\">" + CmisSync.Properties_Resources.ResourceManager.GetString("WhereToFind", CultureInfo.CurrentCulture) + "</span>" }; address_help_urlbox.Add(address_help_urllabel); address_help_urlbox.ButtonPressEvent += delegate(object o, ButtonPressEventArgs args) { Process process = new Process(); process.StartInfo.FileName = "xdg-open"; process.StartInfo.Arguments = "https://github.com/nicolas-raoul/CmisSync/wiki/What-address"; process.Start (); }; address_help_urlbox.EnterNotifyEvent += delegate(object o, EnterNotifyEventArgs args) { address_help_urlbox.GdkWindow.Cursor = hand_cursor; }; Label address_error_label = new Label() { Xalign = 0, UseMarkup = true, Markup = "" }; address_error_label.Hide(); // User Entry user_entry = new Entry () { Text = Controller.PreviousPath, ActivatesDefault = false }; // Password Entry password_entry = new Entry () { Text = Controller.PreviousPath, Visibility = false, ActivatesDefault = true }; Controller.ChangeAddressFieldEvent += delegate (string text, string example_text) { Application.Invoke (delegate { address_entry.Text = text; }); }; Controller.ChangeUserFieldEvent += delegate (string text, string example_text) { Application.Invoke (delegate { user_entry.Text = text; }); }; Controller.ChangePasswordFieldEvent += delegate (string text, string example_text) { Application.Invoke (delegate { password_entry.Text = text; }); }; address_entry.Changed += delegate { string error = Controller.CheckAddPage(address_entry.Text); if (!String.IsNullOrEmpty(error)) { address_error_label.Markup = "<span foreground=\"red\">" + CmisSync.Properties_Resources.ResourceManager.GetString(error, CultureInfo.CurrentCulture) + "</span>"; address_error_label.Show(); } else { address_error_label.Hide(); } }; // Address layout_address_help.PackStart(address_help_label, false, false, 0); layout_address_help.PackStart(address_help_urlbox, false, false, 0); layout_address.PackStart (address_label, true, true, 0); layout_address.PackStart (address_entry, true, true, 0); layout_address.PackStart (layout_address_help, true, true, 0); layout_address.PackStart (address_error_label, true, true, 0); // User layout_user.PackStart (new Label () { Markup = "<b>" + CmisSync.Properties_Resources.ResourceManager.GetString("User", CultureInfo.CurrentCulture) + ":</b>", Xalign = 0 }, true, true, 0); layout_user.PackStart (user_entry, false, false, 0); // Password layout_password.PackStart (new Label () { Markup = "<b>" + CmisSync.Properties_Resources.ResourceManager.GetString("Password", CultureInfo.CurrentCulture) + ":</b>", Xalign = 0 }, true, true, 0); layout_password.PackStart (password_entry, false, false, 0); layout_fields.PackStart (layout_user); layout_fields.PackStart (layout_password); layout_vertical.PackStart (new Label (""), false, false, 0); layout_vertical.PackStart (layout_address, false, false, 0); layout_vertical.PackStart (layout_fields, false, false, 0); Add (layout_vertical); // Cancel button Button cancel_button = new Button (cancelText); cancel_button.Clicked += delegate { Controller.PageCancelled (); }; // Continue button Button continue_button = new Button (continueText) { Sensitive = false }; continue_button.Clicked += delegate { // Show wait cursor this.GdkWindow.Cursor = wait_cursor; // Try to find the CMIS server (asynchronous using a delegate) GetRepositoriesFuzzyDelegate dlgt = new GetRepositoriesFuzzyDelegate(CmisUtils.GetRepositoriesFuzzy); IAsyncResult ar = dlgt.BeginInvoke(new Uri(address_entry.Text), user_entry.Text, password_entry.Text, null, null); while (!ar.AsyncWaitHandle.WaitOne(100)) { while (Application.EventsPending()) { Application.RunIteration(); } } CmisServer cmisServer = dlgt.EndInvoke(ar); Controller.repositories = cmisServer.Repositories; address_entry.Text = cmisServer.Url.ToString(); // Hide wait cursor this.GdkWindow.Cursor = default_cursor; if (Controller.repositories == null) { // Show warning address_error_label.Markup = "<span foreground=\"red\">" + CmisSync.Properties_Resources.ResourceManager.GetString("Sorry", CultureInfo.CurrentCulture) + "</span>"; address_error_label.Show(); } else { // Continue to folder selection Controller.Add1PageCompleted( address_entry.Text, user_entry.Text, password_entry.Text); } }; Controller.UpdateAddProjectButtonEvent += delegate (bool button_enabled) { Application.Invoke (delegate { continue_button.Sensitive = button_enabled; }); }; AddButton (continue_button); AddButton (cancel_button); address_entry.GrabFocus(); }
private void BuildSignIn () { signup_button.Visible = sign_in_state != SignInState.SignedIn; profile_page_button.Visible = sign_in_state == SignInState.SignedIn; var children = sign_in_box.Children; foreach (var child in children) { sign_in_box.Remove (child); } var oauth_explain = Catalog.GetString ("Open Last.fm in a browser, giving you the option to authorize Banshee to work with your account"); switch (sign_in_state) { case SignInState.SignedOut: case SignInState.Failed: need_authorization_checked = true; var username_entry = new Entry () { Text = username_preference.Value }; username_entry.Changed += (o, e) => username_preference.Value = username_entry.Text; username_entry.GrabFocus (); var sign_in_button = new Button (Catalog.GetString ("Log in to Last.fm")) { TooltipText = oauth_explain }; sign_in_button.Clicked += OnSignInClicked; sign_in_box.Attach (new Label (Catalog.GetString ("_Username")), 0, 1, 0, 1, AttachOptions.Shrink, AttachOptions.Shrink, 0, 0); sign_in_box.Attach (username_entry, 1, 2, 0, 1, AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Shrink, 0, 0); sign_in_box.Attach (sign_in_button, 2, 3, 0, 1, AttachOptions.Shrink, AttachOptions.Shrink, 0, 0); if (sign_in_state == SignInState.Failed) { sign_in_box.Attach (new Hyena.Widgets.WrapLabel () { Markup = String.Format ("<i>{0}</i>", GLib.Markup.EscapeText ( RadioConnection.ErrorMessageFor (last_sign_in_error))) }, 1, 3, 1, 2, AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Shrink, 0, 0); } break; case SignInState.NeedAuthorization: sign_in_box.Attach (new Hyena.Widgets.WrapLabel () { Markup = String.Format ("<i>{0}</i>", GLib.Markup.EscapeText ( Catalog.GetString ("You need to allow Banshee to access your Last.fm account."))), }, 0, 1, 0, 2, AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Shrink, 0, 0); var r = need_authorization_checked ? 1u : 0u; sign_in_box.Attach (new Image (Stock.GoForward, IconSize.Button), 1, 2, r, r + 1, AttachOptions.Shrink, AttachOptions.Shrink, 0, 0); sign_in_box.Attach (new Image (Stock.GoBack, IconSize.Button), 3, 4, r, r + 1, AttachOptions.Shrink, AttachOptions.Shrink, 0, 0); var check_auth_button = new Button (Catalog.GetString ("Finish Logging In")); check_auth_button.Clicked += OnFinishSignInClicked; sign_in_box.Attach (check_auth_button, 2, 3, 0, 1, AttachOptions.Fill, AttachOptions.Shrink, 0, 0); var try_again_button = new Button (Catalog.GetString ("Try Again")) { TooltipText = oauth_explain }; try_again_button.Clicked += OnSignInClicked; sign_in_box.Attach (try_again_button, 2, 3, 1, 2, AttachOptions.Fill, AttachOptions.Shrink, 0, 0); break; case SignInState.SignedIn: sign_in_box.Attach (new Hyena.Widgets.WrapLabel () { Markup = String.Format (Catalog.GetString ("You are logged in to Last.fm as the user <i>{0}</i>."), source.Account.UserName) }, 0, 1, 0, 1, AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Shrink, 0, 0); var log_out_button = new Button (Catalog.GetString ("Log out of Last.fm")); log_out_button.Clicked += OnSignOutClicked; sign_in_box.Attach (log_out_button, 1, 2, 0, 1, AttachOptions.Shrink, AttachOptions.Shrink, 0, 0); break; } sign_in_box.ShowAll (); }
public void ShowPage (PageType type, string [] warnings) { if (type == PageType.Setup) { Header = "Welcome to SparkleShare!"; Description = "First off, what’s your name and email?\n(visible only to team members)"; Table table = new Table (2, 3, true) { RowSpacing = 6, ColumnSpacing = 6 }; Label name_label = new Label ("<b>" + "Full Name:" + "</b>") { UseMarkup = true, Xalign = 1 }; Entry name_entry = new Entry () { Xalign = 0, ActivatesDefault = true }; try { UnixUserInfo user_info = UnixUserInfo.GetRealUser (); if (user_info != null && user_info.RealName != null) // Some systems append a series of "," for some reason name_entry.Text = user_info.RealName.TrimEnd (",".ToCharArray ()); } catch (ArgumentException) { // No username, not a big deal } Entry email_entry = new Entry () { Xalign = 0, ActivatesDefault = true }; Label email_label = new Label ("<b>" + "Email:" + "</b>") { UseMarkup = true, Xalign = 1 }; table.Attach (name_label, 0, 1, 0, 1); table.Attach (name_entry, 1, 2, 0, 1); table.Attach (email_label, 0, 1, 1, 2); table.Attach (email_entry, 1, 2, 1, 2); VBox wrapper = new VBox (false, 9); wrapper.PackStart (table, true, false, 0); Button cancel_button = new Button ("Cancel"); Button continue_button = new Button ("Continue") { Sensitive = false }; Controller.UpdateSetupContinueButtonEvent += delegate (bool button_enabled) { Application.Invoke (delegate { continue_button.Sensitive = button_enabled; }); }; name_entry.Changed += delegate { Controller.CheckSetupPage (name_entry.Text, email_entry.Text); }; email_entry.Changed += delegate { Controller.CheckSetupPage (name_entry.Text, email_entry.Text); }; cancel_button.Clicked += delegate { Controller.SetupPageCancelled (); }; continue_button.Clicked += delegate { Controller.SetupPageCompleted (name_entry.Text, email_entry.Text); }; AddButton (cancel_button); AddButton (continue_button); Add (wrapper); Controller.CheckSetupPage (name_entry.Text, email_entry.Text); if (name_entry.Text.Equals ("")) name_entry.GrabFocus (); else email_entry.GrabFocus (); } if (type == PageType.Add) { Header = "Where’s your project hosted?"; VBox layout_vertical = new VBox (false, 16); HBox layout_fields = new HBox (true, 32); VBox layout_address = new VBox (true, 0); VBox layout_path = new VBox (true, 0); ListStore store = new ListStore (typeof (string), typeof (Gdk.Pixbuf), typeof (string), typeof (SparklePlugin)); SparkleTreeView tree_view = new SparkleTreeView (store) { HeadersVisible = false }; ScrolledWindow scrolled_window = new ScrolledWindow () { ShadowType = ShadowType.In }; scrolled_window.SetPolicy (PolicyType.Never, PolicyType.Automatic); // Padding column tree_view.AppendColumn ("Padding", new Gtk.CellRendererText (), "text", 0); tree_view.Columns [0].Cells [0].Xpad = 4; // Icon column tree_view.AppendColumn ("Icon", new Gtk.CellRendererPixbuf (), "pixbuf", 1); tree_view.Columns [1].Cells [0].Xpad = 4; // Service column TreeViewColumn service_column = new TreeViewColumn () { Title = "Service" }; CellRendererText service_cell = new CellRendererText () { Ypad = 8 }; service_column.PackStart (service_cell, true); service_column.SetCellDataFunc (service_cell, new TreeCellDataFunc (RenderServiceColumn)); foreach (SparklePlugin plugin in Controller.Plugins) { store.AppendValues ("", new Gdk.Pixbuf (plugin.ImagePath), "<span size=\"small\"><b>" + plugin.Name + "</b>\n" + "<span fgcolor=\"" + Program.UI.SecondaryTextColor + "\">" + plugin.Description + "</span>" + "</span>", plugin); } tree_view.AppendColumn (service_column); scrolled_window.Add (tree_view); Entry address_entry = new Entry () { Text = Controller.PreviousAddress, Sensitive = (Controller.SelectedPlugin.Address == null), ActivatesDefault = true }; Entry path_entry = new Entry () { Text = Controller.PreviousPath, Sensitive = (Controller.SelectedPlugin.Path == null), ActivatesDefault = true }; Label address_example = new Label () { Xalign = 0, UseMarkup = true, Markup = "<span size=\"small\" fgcolor=\"" + Program.UI.SecondaryTextColor + "\">" + Controller.SelectedPlugin.AddressExample + "</span>" }; Label path_example = new Label () { Xalign = 0, UseMarkup = true, Markup = "<span size=\"small\" fgcolor=\"" + Program.UI.SecondaryTextColor + "\">" + Controller.SelectedPlugin.PathExample + "</span>" }; TreeSelection default_selection = tree_view.Selection; TreePath default_path = new TreePath ("" + Controller.SelectedPluginIndex); default_selection.SelectPath (default_path); tree_view.Model.Foreach (new TreeModelForeachFunc ( delegate (ITreeModel model, TreePath path, TreeIter iter) { string address; try { address = (model.GetValue (iter, 2) as SparklePlugin).Address; } catch (NullReferenceException) { address = ""; } if (!string.IsNullOrEmpty (address) && address.Equals (Controller.PreviousAddress)) { tree_view.SetCursor (path, service_column, false); SparklePlugin plugin = (SparklePlugin) model.GetValue (iter, 2); if (plugin.Address != null) address_entry.Sensitive = false; if (plugin.Path != null) path_entry.Sensitive = false; return true; } else { return false; } } )); layout_address.PackStart (new Label () { Markup = "<b>" + "Address" + "</b>", Xalign = 0 }, true, true, 0); layout_address.PackStart (address_entry, false, false, 0); layout_address.PackStart (address_example, false, false, 0); path_entry.Changed += delegate { Controller.CheckAddPage (address_entry.Text, path_entry.Text, tree_view.SelectedRow); }; layout_path.PackStart (new Label () { Markup = "<b>" + "Remote Path" + "</b>", Xalign = 0 }, true, true, 0); layout_path.PackStart (path_entry, false, false, 0); layout_path.PackStart (path_example, false, false, 0); layout_fields.PackStart (layout_address, true, true, 0); layout_fields.PackStart (layout_path, true, true, 0); layout_vertical.PackStart (new Label (""), false, false, 0); layout_vertical.PackStart (scrolled_window, true, true, 0); layout_vertical.PackStart (layout_fields, false, false, 0); tree_view.ScrollToCell (new TreePath ("" + Controller.SelectedPluginIndex), null, true, 0, 0); Add (layout_vertical); if (string.IsNullOrEmpty (path_entry.Text)) { address_entry.GrabFocus (); address_entry.Position = -1; } else { path_entry.GrabFocus (); path_entry.Position = -1; } Button cancel_button = new Button ("Cancel"); Button add_button = new Button ("Add") { Sensitive = false }; Controller.ChangeAddressFieldEvent += delegate (string text, string example_text, FieldState state) { Application.Invoke (delegate { address_entry.Text = text; address_entry.Sensitive = (state == FieldState.Enabled); address_example.Markup = "<span size=\"small\" fgcolor=\"" + Program.UI.SecondaryTextColor + "\">" + example_text + "</span>"; }); }; Controller.ChangePathFieldEvent += delegate (string text, string example_text, FieldState state) { Application.Invoke (delegate { path_entry.Text = text; path_entry.Sensitive = (state == FieldState.Enabled); path_example.Markup = "<span size=\"small\" fgcolor=\"" + Program.UI.SecondaryTextColor + "\">" + example_text + "</span>"; }); }; Controller.UpdateAddProjectButtonEvent += delegate (bool button_enabled) { Application.Invoke (delegate { add_button.Sensitive = button_enabled; }); }; tree_view.CursorChanged += delegate (object sender, EventArgs e) { Controller.SelectedPluginChanged (tree_view.SelectedRow); }; address_entry.Changed += delegate { Controller.CheckAddPage (address_entry.Text, path_entry.Text, tree_view.SelectedRow); }; cancel_button.Clicked += delegate { Controller.PageCancelled (); }; add_button.Clicked += delegate { Controller.AddPageCompleted (address_entry.Text, path_entry.Text); }; CheckButton check_button = new CheckButton ("Fetch prior revisions") { Active = true }; check_button.Toggled += delegate { Controller.HistoryItemChanged (check_button.Active); }; AddOption (check_button); AddButton (cancel_button); AddButton (add_button); Controller.HistoryItemChanged (check_button.Active); Controller.CheckAddPage (address_entry.Text, path_entry.Text, 1); } if (type == PageType.Invite) { Header = "You’ve received an invite!"; Description = "Do you want to add this project to SparkleShare?"; Table table = new Table (2, 3, true) { RowSpacing = 6, ColumnSpacing = 6 }; Label address_label = new Label ("Address:") { Xalign = 1 }; Label path_label = new Label ("Remote Path:") { Xalign = 1 }; Label address_value = new Label ("<b>" + Controller.PendingInvite.Address + "</b>") { UseMarkup = true, Xalign = 0 }; Label path_value = new Label ("<b>" + Controller.PendingInvite.RemotePath + "</b>") { UseMarkup = true, Xalign = 0 }; table.Attach (address_label, 0, 1, 0, 1); table.Attach (address_value, 1, 2, 0, 1); table.Attach (path_label, 0, 1, 1, 2); table.Attach (path_value, 1, 2, 1, 2); VBox wrapper = new VBox (false, 9); wrapper.PackStart (table, true, false, 0); Button cancel_button = new Button ("Cancel"); Button add_button = new Button ("Add"); cancel_button.Clicked += delegate { Controller.PageCancelled (); }; add_button.Clicked += delegate { Controller.InvitePageCompleted (); }; AddButton (cancel_button); AddButton (add_button); Add (wrapper); } if (type == PageType.Syncing) { Header = String.Format ("Adding project ‘{0}’…", Controller.SyncingFolder); Description = "This may take a while for large projects.\nIsn’t it coffee-o’clock?"; ProgressBar progress_bar = new ProgressBar (); progress_bar.Fraction = Controller.ProgressBarPercentage / 100; Button cancel_button = new Button () { Label = "Cancel" }; Button finish_button = new Button ("Finish") { Sensitive = false }; Label progress_label = new Label ("Preparing to fetch files…") { Justify = Justification.Right, Xalign = 1 }; Controller.UpdateProgressBarEvent += delegate (double percentage, string speed) { Application.Invoke (delegate { progress_bar.Fraction = percentage / 100; progress_label.Text = speed; }); }; cancel_button.Clicked += delegate { Controller.SyncingCancelled (); }; VBox bar_wrapper = new VBox (false, 0); bar_wrapper.PackStart (progress_bar, false, false, 21); bar_wrapper.PackStart (progress_label, false, true, 0); Add (bar_wrapper); AddButton (cancel_button); AddButton (finish_button); } if (type == PageType.Error) { Header = "Oops! Something went wrong" + "…"; VBox points = new VBox (false, 0); Image list_point_one = new Image (SparkleUIHelpers.GetIcon ("list-point", 16)); Image list_point_two = new Image (SparkleUIHelpers.GetIcon ("list-point", 16)); Image list_point_three = new Image (SparkleUIHelpers.GetIcon ("list-point", 16)); Label label_one = new Label () { Markup = "<b>" + Controller.PreviousUrl + "</b> is the address we’ve compiled. " + "Does this look alright?", Wrap = true, Xalign = 0 }; Label label_two = new Label () { Text = "Is this computer’s Client ID known by the host?", Wrap = true, Xalign = 0 }; points.PackStart (new Label ("Please check the following:") { Xalign = 0 }, false, false, 6); HBox point_one = new HBox (false, 0); point_one.PackStart (list_point_one, false, false, 0); point_one.PackStart (label_one, true, true, 12); points.PackStart (point_one, false, false, 12); HBox point_two = new HBox (false, 0); point_two.PackStart (list_point_two, false, false, 0); point_two.PackStart (label_two, true, true, 12); points.PackStart (point_two, false, false, 12); if (warnings.Length > 0) { string warnings_markup = ""; foreach (string warning in warnings) warnings_markup += "\n<b>" + warning + "</b>"; Label label_three = new Label () { Markup = "Here’s the raw error message:" + warnings_markup, Wrap = true, Xalign = 0 }; HBox point_three = new HBox (false, 0); point_three.PackStart (list_point_three, false, false, 0); point_three.PackStart (label_three, true, true, 12); points.PackStart (point_three, false, false, 12); } points.PackStart (new Label (""), true, true, 0); Button cancel_button = new Button ("Cancel"); Button try_again_button = new Button ("Try Again…") { Sensitive = true }; cancel_button.Clicked += delegate { Controller.PageCancelled (); }; try_again_button.Clicked += delegate { Controller.ErrorPageCompleted (); }; AddButton (cancel_button); AddButton (try_again_button); Add (points); } if (type == PageType.CryptoSetup || type == PageType.CryptoPassword) { if (type == PageType.CryptoSetup) { Header = "Set up file encryption"; Description = "Please a provide a strong password that you don’t use elsewhere."; } else { Header = "This project contains encrypted files"; Description = "Please enter the password to see their contents."; } Label password_label = new Label ("<b>" + "Password" + "</b>") { UseMarkup = true, Xalign = 1 }; Entry password_entry = new Entry () { Xalign = 0, Visibility = false, ActivatesDefault = true }; CheckButton show_password_check_button = new CheckButton ("Show password") { Active = false, Xalign = 0, }; Table table = new Table (2, 3, true) { RowSpacing = 6, ColumnSpacing = 6 }; table.Attach (password_label, 0, 1, 0, 1); table.Attach (password_entry, 1, 2, 0, 1); table.Attach (show_password_check_button, 1, 2, 1, 2); VBox wrapper = new VBox (false, 9); wrapper.PackStart (table, true, false, 0); Image warning_image = new Image ( SparkleUIHelpers.GetIcon ("dialog-information", 24)); Label warning_label = new Label () { Xalign = 0, Wrap = true, Text = "This password can’t be changed later, and your files can’t be recovered if it’s forgotten." }; HBox warning_layout = new HBox (false, 0); warning_layout.PackStart (warning_image, false, false, 15); warning_layout.PackStart (warning_label, true, true, 0); VBox warning_wrapper = new VBox (false, 0); warning_wrapper.PackStart (warning_layout, false, false, 15); if (type == PageType.CryptoSetup) wrapper.PackStart (warning_wrapper, false, false, 0); Button cancel_button = new Button ("Cancel"); Button continue_button = new Button ("Continue") { Sensitive = false }; Controller.UpdateCryptoSetupContinueButtonEvent += delegate (bool button_enabled) { Application.Invoke (delegate { continue_button.Sensitive = button_enabled; }); }; Controller.UpdateCryptoPasswordContinueButtonEvent += delegate (bool button_enabled) { Application.Invoke (delegate { continue_button.Sensitive = button_enabled; }); }; show_password_check_button.Toggled += delegate { password_entry.Visibility = !password_entry.Visibility; }; password_entry.Changed += delegate { if (type == PageType.CryptoSetup) Controller.CheckCryptoSetupPage (password_entry.Text); else Controller.CheckCryptoPasswordPage (password_entry.Text); }; cancel_button.Clicked += delegate { Controller.CryptoPageCancelled (); }; continue_button.Clicked += delegate { if (type == PageType.CryptoSetup) Controller.CryptoSetupPageCompleted (password_entry.Text); else Controller.CryptoPasswordPageCompleted (password_entry.Text); }; Add (wrapper); AddButton (cancel_button); AddButton (continue_button); password_entry.GrabFocus (); } if (type == PageType.Finished) { Header = "Your shared project is ready!"; Description = "You can find the files in your SparkleShare folder."; UrgencyHint = true; Button show_files_button = new Button ("Show Files…"); Button finish_button = new Button ("Finish"); show_files_button.Clicked += delegate { Controller.ShowFilesClicked (); }; finish_button.Clicked += delegate { Controller.FinishPageCompleted (); }; if (warnings.Length > 0) { Image warning_image = new Image (SparkleUIHelpers.GetIcon ("dialog-information", 24)); Label warning_label = new Label (warnings [0]) { Xalign = 0, Wrap = true }; HBox warning_layout = new HBox (false, 0); warning_layout.PackStart (warning_image, false, false, 15); warning_layout.PackStart (warning_label, true, true, 0); VBox warning_wrapper = new VBox (false, 0); warning_wrapper.PackStart (warning_layout, false, false, 0); Add (warning_wrapper); } else { Add (null); } AddButton (show_files_button); AddButton (finish_button); } if (type == PageType.Tutorial) { switch (Controller.TutorialPageNumber) { case 1: { Header = "What’s happening next?"; Description = "SparkleShare creates a special folder on your computer " + "that will keep track of your projects."; Button skip_tutorial_button = new Button ("Skip Tutorial"); Button continue_button = new Button ("Continue"); skip_tutorial_button.Clicked += delegate { Controller.TutorialSkipped (); }; continue_button.Clicked += delegate { Controller.TutorialPageCompleted (); }; AddButton (skip_tutorial_button); AddButton (continue_button); break; } case 2: { Header = "Sharing files with others"; Description = "All files added to your project folders are synced automatically with " + "the host and your team members."; Button continue_button = new Button ("Continue"); continue_button.Clicked += delegate { Controller.TutorialPageCompleted (); }; AddButton (continue_button); break; } case 3: { Header = "The status icon helps you"; Description = "It shows the syncing progress, provides easy access to " + "your projects, and lets you view recent changes."; Button continue_button = new Button ("Continue"); continue_button.Clicked += delegate { Controller.TutorialPageCompleted (); }; AddButton (continue_button); break; } case 4: { Header = "Here’s your unique Client ID"; Description = "You’ll need it whenever you want to link this computer to a host. " + "You can also find it in the status icon menu."; Button finish_button = new Button ("Finish"); VBox layout_vertical = new VBox (false, 0) { BorderWidth = 48 }; HBox layout_horizontal = new HBox (false, 6); Entry link_code_entry = new Entry () { Text = Program.Controller.CurrentUser.PublicKey, Sensitive = false }; Button copy_button = new Button (" Copy "); CheckButton check_button = new CheckButton ("Add SparkleShare to startup items"); check_button.Active = true; copy_button.Clicked += delegate { Controller.CopyToClipboardClicked (); }; check_button.Toggled += delegate { Controller.StartupItemChanged (check_button.Active); }; finish_button.Clicked += delegate { Controller.TutorialPageCompleted (); }; layout_horizontal.PackStart (link_code_entry, true, true, 0); layout_horizontal.PackStart (copy_button, false, false, 0); layout_vertical.PackStart (new Label (""), true, true, 0); layout_vertical.PackStart (layout_horizontal, false, false, 0); layout_vertical.PackStart (new Label (""), true, true, 18); Add (layout_vertical); AddOption (check_button); AddButton (finish_button); break; } } if (Controller.TutorialPageNumber < 4) { Image slide = SparkleUIHelpers.GetImage ("tutorial-slide-" + Controller.TutorialPageNumber + ".png"); Add (slide); } } }
public void ShowPage(PageType type, string [] warnings) { if (type == PageType.Setup) { Header = "Welcome to SparkleShare!"; Description = "First off, what’s your name and email?\n(visible only to team members)"; Table table = new Table (2, 3, true) { RowSpacing = 6, ColumnSpacing = 6 }; Label name_label = new Label ("<b>" + "Your Name:" + "</b>") { UseMarkup = true, Xalign = 1 }; Entry name_entry = new Entry () { Xalign = 0, ActivatesDefault = true }; try { UnixUserInfo user_info = UnixUserInfo.GetRealUser (); if (user_info != null && user_info.RealName != null) // Some systems append a series of "," for some reason, TODO: Report upstream name_entry.Text = user_info.RealName.TrimEnd (",".ToCharArray ()); } catch (ArgumentException) { // No username, not a big deal } Entry email_entry = new Entry () { Xalign = 0, ActivatesDefault = true }; Label email_label = new Label ("<b>" + "Email:" + "</b>") { UseMarkup = true, Xalign = 1 }; table.Attach (name_label, 0, 1, 0, 1); table.Attach (name_entry, 1, 2, 0, 1); table.Attach (email_label, 0, 1, 1, 2); table.Attach (email_entry, 1, 2, 1, 2); VBox wrapper = new VBox (false, 9); wrapper.PackStart (table, true, false, 0); Button cancel_button = new Button ("Cancel"); Button continue_button = new Button ("Continue") { Sensitive = false }; Controller.UpdateSetupContinueButtonEvent += delegate (bool button_enabled) { Application.Invoke (delegate { continue_button.Sensitive = button_enabled; }); }; name_entry.Changed += delegate { Controller.CheckSetupPage (name_entry.Text, email_entry.Text); }; email_entry.Changed += delegate { Controller.CheckSetupPage (name_entry.Text, email_entry.Text); }; cancel_button.Clicked += delegate { Controller.SetupPageCancelled (); }; continue_button.Clicked += delegate { Controller.SetupPageCompleted (name_entry.Text, email_entry.Text); }; AddButton (cancel_button); AddButton (continue_button); Add (wrapper); Controller.CheckSetupPage (name_entry.Text, email_entry.Text); if (name_entry.Text.Equals ("")) name_entry.GrabFocus (); else email_entry.GrabFocus (); } if (type == PageType.Add) { Header = "Where’s your project hosted?"; VBox layout_vertical = new VBox (false, 16); HBox layout_fields = new HBox (true, 32); VBox layout_address = new VBox (true, 0); VBox layout_path = new VBox (true, 0); ListStore store = new ListStore (typeof (string), typeof (Gdk.Pixbuf), typeof (string), typeof (Preset)); SparkleTreeView tree_view = new SparkleTreeView (store) { HeadersVisible = false, SearchColumn = -1, EnableSearch = false }; ScrolledWindow scrolled_window = new ScrolledWindow () { ShadowType = ShadowType.In }; scrolled_window.SetPolicy (PolicyType.Never, PolicyType.Automatic); // Padding column tree_view.AppendColumn ("Padding", new Gtk.CellRendererText (), "text", 0); tree_view.Columns [0].Cells [0].Xpad = 4; // Icon column tree_view.AppendColumn ("Icon", new Gtk.CellRendererPixbuf (), "pixbuf", 1); tree_view.Columns [1].Cells [0].Xpad = 4; // Service column TreeViewColumn service_column = new TreeViewColumn () { Title = "Service" }; CellRendererText service_cell = new CellRendererText () { Ypad = 8 }; service_column.PackStart (service_cell, true); service_column.SetCellDataFunc (service_cell, new TreeCellDataFunc (RenderServiceColumn)); foreach (Preset preset in Controller.Presets) { store.AppendValues ("", new Gdk.Pixbuf (preset.ImagePath), "<span size=\"small\"><b>" + preset.Name + "</b>\n" + "<span fgcolor=\"" + SparkleShare.UI.SecondaryTextColor + "\">" + preset.Description + "</span>" + "</span>", preset); } tree_view.AppendColumn (service_column); scrolled_window.Add (tree_view); Entry address_entry = new Entry () { Text = Controller.PreviousAddress, Sensitive = (Controller.SelectedPreset.Address == null), ActivatesDefault = true }; Entry path_entry = new Entry () { Text = Controller.PreviousPath, Sensitive = (Controller.SelectedPreset.Path == null), ActivatesDefault = true }; tree_view.ButtonReleaseEvent += delegate { path_entry.GrabFocus (); }; Label address_example = new Label () { Xalign = 0, UseMarkup = true, Markup = "<span size=\"small\" fgcolor=\"" + SparkleShare.UI.SecondaryTextColor + "\">" + Controller.SelectedPreset.AddressExample + "</span>" }; Label path_example = new Label () { Xalign = 0, UseMarkup = true, Markup = "<span size=\"small\" fgcolor=\"" + SparkleShare.UI.SecondaryTextColor + "\">" + Controller.SelectedPreset.PathExample + "</span>" }; TreeSelection default_selection = tree_view.Selection; TreePath default_path = new TreePath ("" + Controller.SelectedPresetIndex); default_selection.SelectPath (default_path); tree_view.Model.Foreach (new TreeModelForeachFunc ( delegate (ITreeModel model, TreePath path, TreeIter iter) { string address; try { address = (model.GetValue (iter, 2) as Preset).Address; } catch (NullReferenceException) { address = ""; } if (!string.IsNullOrEmpty (address) && address.Equals (Controller.PreviousAddress)) { tree_view.SetCursor (path, service_column, false); Preset preset = (Preset) model.GetValue (iter, 2); if (preset.Address != null) address_entry.Sensitive = false; if (preset.Path != null) path_entry.Sensitive = false; return true; } else { return false; } } )); layout_address.PackStart (new Label () { Markup = "<b>" + "Address" + "</b>", Xalign = 0 }, true, true, 0); layout_address.PackStart (address_entry, false, false, 0); layout_address.PackStart (address_example, false, false, 0); path_entry.Changed += delegate { Controller.CheckAddPage (address_entry.Text, path_entry.Text, tree_view.SelectedRow); }; layout_path.PackStart (new Label () { Markup = "<b>" + "Remote Path" + "</b>", Xalign = 0 }, true, true, 0); layout_path.PackStart (path_entry, false, false, 0); layout_path.PackStart (path_example, false, false, 0); layout_fields.PackStart (layout_address, true, true, 0); layout_fields.PackStart (layout_path, true, true, 0); layout_vertical.PackStart (scrolled_window, true, true, 0); layout_vertical.PackStart (layout_fields, false, false, 0); tree_view.ScrollToCell (new TreePath ("" + Controller.SelectedPresetIndex), null, true, 0, 0); Add (layout_vertical); if (string.IsNullOrEmpty (path_entry.Text)) { address_entry.GrabFocus (); address_entry.Position = -1; } else { path_entry.GrabFocus (); path_entry.Position = -1; } Button cancel_button = new Button ("Cancel"); Button add_button = new Button ("Add") { Sensitive = false }; Controller.ChangeAddressFieldEvent += delegate (string text, string example_text, FieldState state) { Application.Invoke (delegate { address_entry.Text = text; address_entry.Sensitive = (state == FieldState.Enabled); address_example.Markup = "<span size=\"small\" fgcolor=\"" + SparkleShare.UI.SecondaryTextColor + "\">" + example_text + "</span>"; }); }; Controller.ChangePathFieldEvent += delegate (string text, string example_text, FieldState state) { Application.Invoke (delegate { path_entry.Text = text; path_entry.Sensitive = (state == FieldState.Enabled); path_example.Markup = "<span size=\"small\" fgcolor=\"" + SparkleShare.UI.SecondaryTextColor + "\">" + example_text + "</span>"; }); }; Controller.UpdateAddProjectButtonEvent += delegate (bool button_enabled) { Application.Invoke (delegate { add_button.Sensitive = button_enabled; }); }; tree_view.CursorChanged += delegate (object sender, EventArgs e) { Controller.SelectedPresetChanged (tree_view.SelectedRow); }; address_entry.Changed += delegate { Controller.CheckAddPage (address_entry.Text, path_entry.Text, tree_view.SelectedRow); }; cancel_button.Clicked += delegate { Controller.PageCancelled (); }; add_button.Clicked += delegate { Controller.AddPageCompleted (address_entry.Text, path_entry.Text); }; CheckButton check_button = new CheckButton ("Fetch prior revisions") { Active = false }; check_button.Toggled += delegate { Controller.HistoryItemChanged (check_button.Active); }; AddOption (check_button); AddButton (cancel_button); AddButton (add_button); Controller.HistoryItemChanged (check_button.Active); Controller.CheckAddPage (address_entry.Text, path_entry.Text, 1); } if (type == PageType.Invite) { Header = "You’ve received an invite!"; Description = "Do you want to add this project to SparkleShare?"; Table table = new Table (2, 3, true) { RowSpacing = 6, ColumnSpacing = 6 }; Label address_label = new Label ("Address:") { Xalign = 1 }; Label path_label = new Label ("Remote Path:") { Xalign = 1 }; Label address_value = new Label ("<b>" + Controller.PendingInvite.Address + "</b>") { UseMarkup = true, Xalign = 0 }; Label path_value = new Label ("<b>" + Controller.PendingInvite.RemotePath + "</b>") { UseMarkup = true, Xalign = 0 }; table.Attach (address_label, 0, 1, 0, 1); table.Attach (address_value, 1, 2, 0, 1); table.Attach (path_label, 0, 1, 1, 2); table.Attach (path_value, 1, 2, 1, 2); VBox wrapper = new VBox (false, 9); wrapper.PackStart (table, true, false, 0); Button cancel_button = new Button ("Cancel"); Button add_button = new Button ("Add"); cancel_button.Clicked += delegate { Controller.PageCancelled (); }; add_button.Clicked += delegate { Controller.InvitePageCompleted (); }; AddButton (cancel_button); AddButton (add_button); Add (wrapper); } if (type == PageType.Syncing) { Header = String.Format ("Adding project ‘{0}’…", Controller.SyncingFolder); Description = "This may take a while for large projects.\nIsn’t it coffee-o’clock?"; ProgressBar progress_bar = new ProgressBar (); progress_bar.Fraction = Controller.ProgressBarPercentage / 100; Button cancel_button = new Button () { Label = "Cancel" }; Button finish_button = new Button ("Finish") { Sensitive = false }; Label progress_label = new Label ("Preparing to fetch files…") { Justify = Justification.Right, Xalign = 1 }; Controller.UpdateProgressBarEvent += delegate (double percentage, string speed) { Application.Invoke (delegate { progress_bar.Fraction = percentage / 100; progress_label.Text = speed; }); }; cancel_button.Clicked += delegate { Controller.SyncingCancelled (); }; VBox bar_wrapper = new VBox (false, 0); bar_wrapper.PackStart (progress_bar, false, false, 21); bar_wrapper.PackStart (progress_label, false, true, 0); Add (bar_wrapper); AddButton (cancel_button); AddButton (finish_button); } if (type == PageType.Error) { Header = "Oops! Something went wrong" + "…"; VBox points = new VBox (false, 0); Image list_point_one = new Image (UserInterfaceHelpers.GetIcon ("list-point", 16)); Image list_point_two = new Image (UserInterfaceHelpers.GetIcon ("list-point", 16)); Image list_point_three = new Image (UserInterfaceHelpers.GetIcon ("list-point", 16)); Label label_one = new Label () { Markup = "<b>" + Controller.PreviousUrl + "</b> is the address we’ve compiled. " + "Does this look alright?", Wrap = true, Xalign = 0 }; Label label_two = new Label () { Text = "Is this computer’s Client ID known by the host?", Wrap = true, Xalign = 0 }; points.PackStart (new Label ("Please check the following:") { Xalign = 0 }, false, false, 6); HBox point_one = new HBox (false, 0); point_one.PackStart (list_point_one, false, false, 0); point_one.PackStart (label_one, true, true, 12); points.PackStart (point_one, false, false, 12); HBox point_two = new HBox (false, 0); point_two.PackStart (list_point_two, false, false, 0); point_two.PackStart (label_two, true, true, 12); points.PackStart (point_two, false, false, 12); if (warnings.Length > 0) { string warnings_markup = ""; foreach (string warning in warnings) warnings_markup += "\n<b>" + warning + "</b>"; Label label_three = new Label () { Markup = "Here’s the raw error message:" + warnings_markup, Wrap = true, Xalign = 0 }; HBox point_three = new HBox (false, 0); point_three.PackStart (list_point_three, false, false, 0); point_three.PackStart (label_three, true, true, 12); points.PackStart (point_three, false, false, 12); } points.PackStart (new Label (""), true, true, 0); Button cancel_button = new Button ("Cancel"); Button try_again_button = new Button ("Retry") { Sensitive = true }; cancel_button.Clicked += delegate { Controller.PageCancelled (); }; try_again_button.Clicked += delegate { Controller.ErrorPageCompleted (); }; AddButton (cancel_button); AddButton (try_again_button); Add (points); } if (type == PageType.StorageSetup) { Header = string.Format ("Storage type for ‘{0}’", Controller.SyncingFolder); Description = "What type of storage would you like to use?"; VBox layout_vertical = new VBox (false, 0); VBox layout_radio_buttons = new VBox (false, 0) { BorderWidth = 12 }; foreach (StorageTypeInfo storage_type in SparkleShare.Controller.FetcherAvailableStorageTypes) { RadioButton radio_button = new RadioButton (null, storage_type.Name + "\n" + storage_type.Description); (radio_button.Child as Label).Markup = string.Format( "<b>{0}</b>\n<span fgcolor=\"{1}\">{2}</span>", storage_type.Name, SparkleShare.UI.SecondaryTextColor, storage_type.Description); (radio_button.Child as Label).Xpad = 9; layout_radio_buttons.PackStart (radio_button, false, false, 9); radio_button.Group = (layout_radio_buttons.Children [0] as RadioButton).Group; } layout_vertical.PackStart (new Label (""), true, true, 0); layout_vertical.PackStart (layout_radio_buttons, false, false, 0); layout_vertical.PackStart (new Label (""), true, true, 0); Add (layout_vertical); Button cancel_button = new Button ("Cancel"); Button continue_button = new Button ("Continue"); continue_button.Clicked += delegate { int checkbox_index= 0; foreach (RadioButton radio_button in layout_radio_buttons.Children) { if (radio_button.Active) { StorageTypeInfo selected_storage_type = SparkleShare.Controller.FetcherAvailableStorageTypes [checkbox_index]; Controller.StoragePageCompleted (selected_storage_type.Type); return; } checkbox_index++; } }; cancel_button.Clicked += delegate { Controller.SyncingCancelled (); }; AddButton (cancel_button); AddButton (continue_button); } if (type == PageType.CryptoSetup || type == PageType.CryptoPassword) { if (type == PageType.CryptoSetup) { Header = string.Format ("Encryption password for ‘{0}’", Controller.SyncingFolder); Description = "Please a provide a strong password that you don’t use elsewhere."; } else { Header = string.Format ("‘{0}’ contains encrypted files", Controller.SyncingFolder); Description = "Please enter the password to see their contents."; } Label password_label = new Label ("<b>" + "Password" + "</b>") { UseMarkup = true, Xalign = 1 }; Entry password_entry = new Entry () { Xalign = 0, Visibility = false, ActivatesDefault = true }; CheckButton show_password_check_button = new CheckButton ("Make visible") { Active = false, Xalign = 0, }; Table table = new Table (2, 3, true) { RowSpacing = 6, ColumnSpacing = 6 }; table.Attach (password_label, 0, 1, 0, 1); table.Attach (password_entry, 1, 2, 0, 1); table.Attach (show_password_check_button, 1, 2, 1, 2); VBox wrapper = new VBox (false, 9); wrapper.PackStart (table, true, false, 0); Image warning_image = new Image ( UserInterfaceHelpers.GetIcon ("dialog-information", 24)); Label warning_label = new Label () { Xalign = 0, Wrap = true, Text = "This password can’t be changed later, and your files can’t be recovered if it’s forgotten." }; HBox warning_layout = new HBox (false, 0); warning_layout.PackStart (warning_image, false, false, 15); warning_layout.PackStart (warning_label, true, true, 0); VBox warning_wrapper = new VBox (false, 0); warning_wrapper.PackStart (warning_layout, false, false, 15); if (type == PageType.CryptoSetup) wrapper.PackStart (warning_wrapper, false, false, 0); Button cancel_button = new Button ("Cancel"); Button continue_button = new Button ("Continue") { Sensitive = false }; Controller.UpdateCryptoSetupContinueButtonEvent += delegate (bool button_enabled) { Application.Invoke (delegate { continue_button.Sensitive = button_enabled; }); }; Controller.UpdateCryptoPasswordContinueButtonEvent += delegate (bool button_enabled) { Application.Invoke (delegate { continue_button.Sensitive = button_enabled; }); }; show_password_check_button.Toggled += delegate { password_entry.Visibility = !password_entry.Visibility; }; password_entry.Changed += delegate { if (type == PageType.CryptoSetup) Controller.CheckCryptoSetupPage (password_entry.Text); else Controller.CheckCryptoPasswordPage (password_entry.Text); }; cancel_button.Clicked += delegate { Controller.CryptoPageCancelled (); }; continue_button.Clicked += delegate { if (type == PageType.CryptoSetup) Controller.CryptoSetupPageCompleted (password_entry.Text); else Controller.CryptoPasswordPageCompleted (password_entry.Text); }; Add (wrapper); AddButton (cancel_button); AddButton (continue_button); password_entry.GrabFocus (); } if (type == PageType.Finished) { Header = "Your shared project is ready!"; Description = "You can find the files in your SparkleShare folder."; UrgencyHint = true; Button show_files_button = new Button ("Show Files"); Button finish_button = new Button ("Finish"); show_files_button.Clicked += delegate { Controller.ShowFilesClicked (); }; finish_button.Clicked += delegate { Controller.FinishPageCompleted (); }; if (warnings.Length > 0) { Image warning_image = new Image (UserInterfaceHelpers.GetIcon ("dialog-information", 24)); Label warning_label = new Label (warnings [0]) { Xalign = 0, Wrap = true }; HBox warning_layout = new HBox (false, 0); warning_layout.PackStart (warning_image, false, false, 15); warning_layout.PackStart (warning_label, true, true, 0); VBox warning_wrapper = new VBox (false, 0); warning_wrapper.PackStart (warning_layout, false, false, 0); Add (warning_wrapper); } else { Add (null); } AddButton (show_files_button); AddButton (finish_button); } }
private void Initialize() { Title = Catalog.GetString ("New Smart Playlist"); VBox.Spacing = 8; AddStockButton (Stock.Cancel, ResponseType.Cancel); ok_button = AddStockButton (Stock.Save, ResponseType.Ok, true); var builder_box = new VBox () { BorderWidth = 5, Spacing = 10 }; var name_box = new HBox () { Spacing = 2 }; name_box.PackStart (new Label () { Text = Catalog.GetString ("Playlist _Name:"), UseUnderline = true }, false, false, 0); name_box.PackStart (name_entry = new Entry (), true, true, 0); name_entry.Changed += HandleNameChanged; builder_box.PackStart (name_box, false, false, 0); builder_box.PackStart (builder = new BansheeQueryBox (), true, true, 0); builder.Show (); builder.Spacing = 4; var expander = new Expander (Catalog.GetString ("Predefined Smart Playlists")); var hbox = new HBox () { Spacing = 8 }; var scrolled_window = new ScrolledWindow () { HscrollbarPolicy = PolicyType.Never, VscrollbarPolicy = PolicyType.Automatic, ShadowType = ShadowType.In }; var button_box = new VButtonBox () { Spacing = 2, LayoutStyle = ButtonBoxStyle.Start }; button_box.PackStart (adv_use_button = new Button (Catalog.GetString ("Open in editor")), false, false, 0); button_box.PackStart (adv_add_button = new Button (Catalog.GetString ("Create and save")), false, false, 0); scrolled_window.Add (adv_tree_view = new TreeView () { HeightRequest = 150, HeadersVisible = false }); hbox.PackStart (scrolled_window, true, true, 0); hbox.PackStart (button_box, false, false, 0); expander.Add (hbox); VBox.PackStart (builder_box, true, true, 0); VBox.PackStart (expander, false, false, 0); // Model is Name, SmartPlaylistDefinition ListStore list_model = new ListStore (typeof(string), typeof(SmartPlaylistDefinition)); bool have_any_predefined = false; foreach (SmartPlaylistDefinition def in primary_source.PredefinedSmartPlaylists) { list_model.AppendValues ( String.Format ("<b>{0}</b>\n<small>{1}</small>", def.Name, def.Description), def ); have_any_predefined = true; } adv_tree_view.Selection.Mode = SelectionMode.Multiple; adv_tree_view.Model = list_model; CellRendererText renderer = new CellRendererText (); renderer.Ellipsize = Pango.EllipsizeMode.End; adv_tree_view.AppendColumn ("title", renderer, "markup", 0); adv_tree_view.Selection.Changed += HandleAdvSelectionChanged; UpdateAdvButtons (0); adv_add_button.Clicked += HandleAdvAdd; adv_use_button.Clicked += HandleAdvUse; if (!have_any_predefined) { expander.NoShowAll = true; expander.Hide (); } Update (); name_entry.GrabFocus (); ShowAll (); }
private void rename_label(UserLabel label) { renamed_label = label; Gtk.Entry rename_label = new Gtk.Entry(); rename_label.Text = label.metalabel.label; rename_label.Name = "rename_label"; rename_label.AddEvents((int)Gdk.EventMask.KeyReleaseMask); rename_label.KeyReleaseEvent += on_rename_key_release; int pos = 0; foreach (Widget w in representation) { if (w.Name == label.metalabel.label) { w.Destroy(); break; } else ++pos; } representation.Add(rename_label); representation.ReorderChild(rename_label, pos); representation.ShowAll(); rename_label.GrabFocus(); }
void OnWidgetShown(object o, EventArgs args) { OperandEntry.GrabFocus(); }
/// <summary> /// Event Handler for Cancel Button /// </summary> private void OnCancelSearchButton(object o, EventArgs args) { // Set the text empty. The Changed event handler will do the rest. SearchEntry.Text = ""; SearchEntry.GrabFocus(); }
private bool SaveServerAddress() { string serverAddress = ServerAddressEntry.Text; string username = domain.MemberName; string password = domainController.GetDomainPassword(domain.ID); bServerAddressChanged = false; bool bHostAddressUpdated = false; if (serverAddress == null || serverAddress.Trim().Length == 0) { iFolderMsgDialog dg = new iFolderMsgDialog( this, iFolderMsgDialog.DialogType.Error, iFolderMsgDialog.ButtonSet.Ok, "", Util.GS("Server address cannot be empty"), Util.GS("Please enter an address for the server.")); dg.Run(); dg.Hide(); dg.Destroy(); ServerAddressEntry.Changed -= new EventHandler(OnServerAddressChanged); ServerAddressEntry.Text = GetHostUrl(domain.HostUrl); ServerAddressEntry.Changed += new EventHandler(OnServerAddressChanged); return bHostAddressUpdated; } if (password == null || password.Trim().Length == 0) { Entry tempPasswordEntry = new Entry(); tempPasswordEntry.Visibility = false; iFolderMsgDialog dg = new iFolderMsgDialog( this, iFolderMsgDialog.DialogType.Info, iFolderMsgDialog.ButtonSet.OkCancel, "", Util.GS("Please enter your password"), Util.GS("Your password is required to change the address of the server.")); dg.ExtraWidget = tempPasswordEntry; tempPasswordEntry.GrabFocus(); tempPasswordEntry.ActivatesDefault = true; dg.TransientFor = this; int rc = dg.Run(); password = tempPasswordEntry.Text; dg.Hide(); dg.Destroy(); if ((ResponseType)rc == ResponseType.Cancel) { ServerAddressEntry.Changed -= new EventHandler(OnServerAddressChanged); ServerAddressEntry.Text = GetHostUrl(domain.HostUrl); ServerAddressEntry.Changed += new EventHandler(OnServerAddressChanged); return bHostAddressUpdated; } if (password == null || password.Trim().Length == 0) { ServerAddressEntry.Changed -= new EventHandler(OnServerAddressChanged); ServerAddressEntry.Text = GetHostUrl(domain.HostUrl); ServerAddressEntry.Changed += new EventHandler(OnServerAddressChanged); return bHostAddressUpdated; } } serverAddress = serverAddress.Trim(); Exception hostAddressUpdateException = null; try { if (domainController.UpdateDomainHostAddress(domain.ID, serverAddress, username, password) != null) { bHostAddressUpdated = true; } } catch(Exception e) { hostAddressUpdateException = e; } if (!bHostAddressUpdated) { iFolderMsgDialog dg = new iFolderMsgDialog( this, iFolderMsgDialog.DialogType.Error, iFolderMsgDialog.ButtonSet.Ok, "", Util.GS("Unable to modify the server address"), Util.GS("An error was encountered while attempting to modify the server address. Please verify the address and your password are correct."), hostAddressUpdateException == null ? null : hostAddressUpdateException.Message); dg.Run(); dg.Hide(); dg.Destroy(); ServerAddressEntry.Changed -= new EventHandler(OnServerAddressChanged); ServerAddressEntry.Text = GetHostUrl(domain.HostUrl); ServerAddressEntry.Changed += new EventHandler(OnServerAddressChanged); } return bHostAddressUpdated; }
private void ShowAdd1Page() { this.Present(); Header = CmisSync.Properties_Resources.Where; VBox layout_vertical = new VBox (false, 12); HBox layout_fields = new HBox (true, 12); VBox layout_address = new VBox (true, 0); HBox layout_address_help = new HBox(false, 3); VBox layout_user = new VBox (true, 0); VBox layout_password = new VBox (true, 0); // Address Label address_label = new Label() { UseMarkup = true, Xalign = 0, Markup = "<b>" + CmisSync.Properties_Resources.EnterWebAddress + "</b>" }; Entry address_entry = new Entry () { Text = (Controller.PreviousAddress == null || String.IsNullOrEmpty(Controller.PreviousAddress.ToString()))?"https://":Controller.PreviousAddress.ToString(), ActivatesDefault = false }; Label address_help_label = new Label() { Xalign = 0, UseMarkup = true, Markup = "<span foreground=\"#808080\" size=\"small\">" + CmisSync.Properties_Resources.Help + ": " + "</span>" }; EventBox address_help_urlbox = new EventBox(); Label address_help_urllabel = new Label() { Xalign = 0, UseMarkup = true, Markup = "<span foreground=\"blue\" underline=\"single\" size=\"small\">" + CmisSync.Properties_Resources.WhereToFind + "</span>" }; address_help_urlbox.Add(address_help_urllabel); address_help_urlbox.ButtonPressEvent += delegate(object o, ButtonPressEventArgs args) { Process process = new Process(); process.StartInfo.FileName = "xdg-open"; process.StartInfo.Arguments = "https://github.com/aegif/CmisSync/wiki/What-address"; process.Start (); }; address_help_urlbox.EnterNotifyEvent += delegate(object o, EnterNotifyEventArgs args) { address_help_urlbox.GdkWindow.Cursor = hand_cursor; }; Label address_error_label = new Label() { Xalign = 0, UseMarkup = true, Markup = "" }; address_error_label.Hide(); // User Entry user_entry = new Entry () { Text = Controller.PreviousPath, ActivatesDefault = false }; if(String.IsNullOrEmpty(Controller.saved_user)) { user_entry.Text = Environment.UserName; } else { user_entry.Text = Controller.saved_user; } // Password Entry password_entry = new Entry () { Visibility = false, ActivatesDefault = true }; Controller.ChangeAddressFieldEvent += delegate (string text, string example_text) { Application.Invoke (delegate { address_entry.Text = text; }); }; Controller.ChangeUserFieldEvent += delegate (string text, string example_text) { Application.Invoke (delegate { user_entry.Text = text; }); }; Controller.ChangePasswordFieldEvent += delegate (string text, string example_text) { Application.Invoke (delegate { password_entry.Text = text; }); }; address_entry.Changed += delegate { string error = Controller.CheckAddPage(address_entry.Text); if (!String.IsNullOrEmpty(error)) { address_error_label.Markup = "<span foreground=\"red\">" + CmisSync.Properties_Resources.ResourceManager.GetString(error, CultureInfo.CurrentCulture) + "</span>"; address_error_label.Show(); } else { address_error_label.Hide(); } }; // Address layout_address_help.PackStart(address_help_label, false, false, 0); layout_address_help.PackStart(address_help_urlbox, false, false, 0); layout_address.PackStart (address_label, true, true, 0); layout_address.PackStart (address_entry, true, true, 0); layout_address.PackStart (layout_address_help, true, true, 0); // layout_address.PackStart (address_error_label, true, true, 0); // User layout_user.PackStart (new Label () { Markup = "<b>" + CmisSync.Properties_Resources.User + ":</b>", Xalign = 0 }, true, true, 0); layout_user.PackStart (user_entry, false, false, 0); // Password layout_password.PackStart (new Label () { Markup = "<b>" + CmisSync.Properties_Resources.Password + ":</b>", Xalign = 0 }, true, true, 0); layout_password.PackStart (password_entry, false, false, 0); layout_fields.PackStart (layout_user); layout_fields.PackStart (layout_password); // layout_vertical.PackStart (new Label (""), false, false, 0); layout_vertical.PackStart (layout_address, false, false, 0); layout_vertical.PackStart (layout_fields, false, false, 0); layout_vertical.PackStart (address_error_label, true, true, 0); Add (layout_vertical); // Cancel button Button cancel_button = new Button (cancelText); cancel_button.Clicked += delegate { Controller.PageCancelled (); }; // Continue button Button continue_button = new Button (continueText) { Sensitive = String.IsNullOrEmpty( Controller.CheckAddPage (address_entry.Text)) }; continue_button.Clicked += delegate { // Show wait cursor this.GdkWindow.Cursor = wait_cursor; // Try to find the CMIS server (asynchronous using a delegate) GetRepositoriesFuzzyDelegate dlgt = new GetRepositoriesFuzzyDelegate(CmisUtils.GetRepositoriesFuzzy); ServerCredentials credentials = new ServerCredentials() { UserName = user_entry.Text, Password = password_entry.Text, Address = new Uri(address_entry.Text) }; IAsyncResult ar = dlgt.BeginInvoke(credentials, null, null); while (!ar.AsyncWaitHandle.WaitOne(100)) { while (Application.EventsPending()) { Application.RunIteration(); } } Tuple<CmisServer, Exception> result = dlgt.EndInvoke(ar); CmisServer cmisServer = result.Item1; if(cmisServer != null) { Controller.repositories = cmisServer.Repositories; address_entry.Text = cmisServer.Url.ToString(); } else { Controller.repositories = null; } // Hide wait cursor this.GdkWindow.Cursor = default_cursor; if (Controller.repositories == null) { // Show warning string warning = ""; string message = result.Item2.Message; Exception e = result.Item2; if (e is CmisPermissionDeniedException) { warning = Properties_Resources.LoginFailedForbidden; } // else if (e is CmisServerNotFoundException) // { // warning = Properties_Resources.ConnectFailure; // } else if (e.Message == "SendFailure" && cmisServer.Url.Scheme.StartsWith("https")) { warning = Properties_Resources.SendFailureHttps; } else if (e.Message == "TrustFailure") { warning = Properties_Resources.TrustFailure; } else { warning = message + Environment.NewLine + Properties_Resources.Sorry; } address_error_label.Markup = "<span foreground=\"red\">" + warning + "</span>"; address_error_label.Show(); } else { // Continue to folder selection Controller.Add1PageCompleted( new Uri(address_entry.Text), user_entry.Text, password_entry.Text); } }; Controller.UpdateAddProjectButtonEvent += delegate (bool button_enabled) { Application.Invoke (delegate { continue_button.Sensitive = button_enabled; if(button_enabled) { continue_button.SetFlag(Gtk.WidgetFlags.CanFocus); continue_button.SetFlag(Gtk.WidgetFlags.CanDefault); continue_button.GrabDefault(); } }); }; AddButton (cancel_button); AddButton (continue_button); Controller.CheckAddPage (address_entry.Text); address_entry.GrabFocus (); }
private void ShowCustomizePage() { Header = CmisSync.Properties_Resources.Customize; string localfoldername = Controller.saved_address.Host.ToString(); foreach (KeyValuePair<String, String> repository in Controller.repositories) { if (repository.Key == Controller.saved_repository) { localfoldername += "/" + repository.Value; break; } } Label localfolder_label = new Label() { Xalign = 0, UseMarkup = true, Markup = "<b>" + CmisSync.Properties_Resources.EnterLocalFolderName + "</b>" }; Entry localfolder_entry = new Entry() { Text = localfoldername, ActivatesDefault = false }; Label localrepopath_label = new Label() { Xalign = 0, UseMarkup = true, Markup = "<b>" + CmisSync.Properties_Resources.ChangeRepoPath + "</b>" }; Entry localrepopath_entry = new Entry() { Text = System.IO.Path.Combine(Controller.DefaultRepoPath, localfolder_entry.Text) }; localfolder_entry.Changed += delegate { try{ localrepopath_entry.Text = System.IO.Path.Combine(Controller.DefaultRepoPath, localfolder_entry.Text); }catch(Exception){} }; Label localfolder_error_label = new Label() { Xalign = 0, UseMarkup = true, Markup = "" }; Button cancel_button = new Button(cancelText); Button add_button = new Button( CmisSync.Properties_Resources.Add ); Button back_button = new Button( CmisSync.Properties_Resources.Back ); Controller.UpdateAddProjectButtonEvent += delegate(bool button_enabled) { Gtk.Application.Invoke(delegate { add_button.Sensitive = button_enabled; }); }; string error = Controller.CheckRepoPathAndName(localrepopath_entry.Text, localfolder_entry.Text); if (!String.IsNullOrEmpty(error)) { localfolder_error_label.Markup = "<span foreground=\"#ff8080\">" + error + "</span>"; localfolder_error_label.Show(); } else { localfolder_error_label.Hide(); } localfolder_entry.Changed += delegate { error = Controller.CheckRepoPathAndName(localrepopath_entry.Text, localfolder_entry.Text); if (!String.IsNullOrEmpty(error)) { localfolder_error_label.Markup = "<span foreground=\"#ff8080\">" + error + "</span>"; localfolder_error_label.Show(); } else { localfolder_error_label.Hide(); } }; error = Controller.CheckRepoPathAndName(localrepopath_entry.Text, localfolder_entry.Text); if (!String.IsNullOrEmpty(error)) { localfolder_error_label.Markup = "<span foreground=\"#ff8080\">" + error + "</span>"; localfolder_error_label.Show(); } else { localfolder_error_label.Hide(); } localrepopath_entry.Changed += delegate { error = Controller.CheckRepoPathAndName(localrepopath_entry.Text, localfolder_entry.Text); if (!String.IsNullOrEmpty(error)) { localfolder_error_label.Markup = "<span foreground=\"#ff8080\">" + error + "</span>"; localfolder_error_label.Show(); } else { localfolder_error_label.Hide(); } }; cancel_button.Clicked += delegate { Controller.PageCancelled(); }; back_button.Clicked += delegate { Controller.BackToPage2(); }; add_button.Clicked += delegate { Controller.CustomizePageCompleted(localfolder_entry.Text, localrepopath_entry.Text); }; VBox layout_vertical = new VBox (false, 12); layout_vertical.PackStart (new Label(""), false, false, 0); layout_vertical.PackStart (localfolder_label, true, true, 0); layout_vertical.PackStart (localfolder_entry, true, true, 0); layout_vertical.PackStart (localrepopath_label, true, true, 0); layout_vertical.PackStart (localrepopath_entry, true, true, 0); layout_vertical.PackStart (localfolder_error_label, true, true, 0); Add(layout_vertical); AddButton(back_button); AddButton(cancel_button); AddButton(add_button); // add_button.GrabFocus(); localfolder_entry.GrabFocus(); localfolder_entry.SelectRegion(0, localfolder_entry.Text.Length); }
private void Initialize() { Title = Catalog.GetString("New Smart Playlist"); VBox.Spacing = 8; AddStockButton(Stock.Cancel, ResponseType.Cancel); ok_button = AddStockButton(Stock.Save, ResponseType.Ok, true); var builder_box = new VBox() { BorderWidth = 5, Spacing = 10 }; var name_box = new HBox() { Spacing = 2 }; name_box.PackStart(new Label() { Text = Catalog.GetString("Playlist _Name:"), UseUnderline = true }, false, false, 0); name_box.PackStart(name_entry = new Entry(), true, true, 0); name_entry.Changed += HandleNameChanged; builder_box.PackStart(name_box, false, false, 0); builder_box.PackStart(builder = new BansheeQueryBox(), true, true, 0); builder.Show(); builder.Spacing = 4; var expander = new Expander(Catalog.GetString("Predefined Smart Playlists")); var hbox = new HBox() { Spacing = 8 }; var scrolled_window = new ScrolledWindow() { HscrollbarPolicy = PolicyType.Never, VscrollbarPolicy = PolicyType.Automatic, ShadowType = ShadowType.In }; var button_box = new VButtonBox() { Spacing = 2, LayoutStyle = ButtonBoxStyle.Start }; button_box.PackStart(adv_use_button = new Button(Catalog.GetString("Open in editor")), false, false, 0); button_box.PackStart(adv_add_button = new Button(Catalog.GetString("Create and save")), false, false, 0); scrolled_window.Add(adv_tree_view = new TreeView() { HeightRequest = 150, HeadersVisible = false }); hbox.PackStart(scrolled_window, true, true, 0); hbox.PackStart(button_box, false, false, 0); expander.Add(hbox); VBox.PackStart(builder_box, true, true, 0); VBox.PackStart(expander, false, false, 0); // Model is Name, SmartPlaylistDefinition ListStore list_model = new ListStore(typeof(string), typeof(SmartPlaylistDefinition)); bool have_any_predefined = false; foreach (SmartPlaylistDefinition def in primary_source.PredefinedSmartPlaylists) { list_model.AppendValues( String.Format("<b>{0}</b>\n<small>{1}</small>", def.Name, def.Description), def ); have_any_predefined = true; } adv_tree_view.Selection.Mode = SelectionMode.Multiple; adv_tree_view.Model = list_model; CellRendererText renderer = new CellRendererText(); renderer.Ellipsize = Pango.EllipsizeMode.End; adv_tree_view.AppendColumn("title", renderer, "markup", 0); adv_tree_view.Selection.Changed += HandleAdvSelectionChanged; UpdateAdvButtons(0); adv_add_button.Clicked += HandleAdvAdd; adv_use_button.Clicked += HandleAdvUse; if (!have_any_predefined) { expander.NoShowAll = true; expander.Hide(); } Update(); name_entry.GrabFocus(); ShowAll(); }
private void add_new_label() { System.Console.WriteLine("writing new label"); Gtk.Entry new_label = new Gtk.Entry(); new_label.Name = "new_label"; new_label.AddEvents((int)Gdk.EventMask.KeyReleaseMask); new_label.KeyReleaseEvent += on_new_key_release; representation.Add(new_label); representation.ShowAll(); new_label.GrabFocus(); }
private void ShowCustomizePage() { Header = CmisSync.Properties_Resources.ResourceManager.GetString("Customize", CultureInfo.CurrentCulture); Label localfolder_label = new Label() { Xalign = 0, UseMarkup = true, Markup = "<b>" + CmisSync.Properties_Resources.ResourceManager.GetString("EnterLocalFolderName", CultureInfo.CurrentCulture) + "</b>" }; Entry localfolder_entry = new Entry() { Text = Controller.SyncingReponame, ActivatesDefault = false }; Label localrepopath_label = new Label() { Xalign = 0, UseMarkup = true, Markup = "<b>" + CmisSync.Properties_Resources.ResourceManager.GetString("ChangeRepoPath", CultureInfo.CurrentCulture) + "</b>" }; Entry localrepopath_entry = new Entry() { Text = System.IO.Path.Combine(Controller.DefaultRepoPath, localfolder_entry.Text) }; localfolder_entry.Changed += delegate { localrepopath_entry.Text = System.IO.Path.Combine(Controller.DefaultRepoPath, localfolder_entry.Text); }; Label localfolder_error_label = new Label() { Xalign = 0, UseMarkup = true, Markup = "" }; Button cancel_button = new Button(cancelText); Button add_button = new Button( CmisSync.Properties_Resources.ResourceManager.GetString("Add", CultureInfo.CurrentCulture) ); Button back_button = new Button( CmisSync.Properties_Resources.ResourceManager.GetString("Back", CultureInfo.CurrentCulture) ); Controller.UpdateAddProjectButtonEvent += delegate(bool button_enabled) { Gtk.Application.Invoke(delegate { add_button.Sensitive = button_enabled; }); }; string error = Controller.CheckRepoPathAndName(localrepopath_entry.Text, localfolder_entry.Text); if (!String.IsNullOrEmpty(error)) { localfolder_error_label.Markup = "<span foreground=\"#ff8080\">" + CmisSync.Properties_Resources.ResourceManager.GetString(error, CultureInfo.CurrentCulture) + "</span>"; localfolder_error_label.Show(); } else { localfolder_error_label.Hide(); } localfolder_entry.Changed += delegate { error = Controller.CheckRepoPathAndName(localrepopath_entry.Text, localfolder_entry.Text); if (!String.IsNullOrEmpty(error)) { localfolder_error_label.Markup = "<span foreground=\"#ff8080\">" + CmisSync.Properties_Resources.ResourceManager.GetString(error, CultureInfo.CurrentCulture) + "</span>"; localfolder_error_label.Show(); } else { localfolder_error_label.Hide(); } }; error = Controller.CheckRepoPathAndName(localrepopath_entry.Text, localfolder_entry.Text); if (!String.IsNullOrEmpty(error)) { localfolder_error_label.Markup = "<span foreground=\"#ff8080\">" + CmisSync.Properties_Resources.ResourceManager.GetString(error, CultureInfo.CurrentCulture) + "</span>"; localfolder_error_label.Show(); } else { localfolder_error_label.Hide(); } localrepopath_entry.Changed += delegate { error = Controller.CheckRepoPathAndName(localrepopath_entry.Text, localfolder_entry.Text); if (!String.IsNullOrEmpty(error)) { localfolder_error_label.Markup = "<span foreground=\"#ff8080\">" + CmisSync.Properties_Resources.ResourceManager.GetString(error, CultureInfo.CurrentCulture) + "</span>"; localfolder_error_label.Show(); } else { localfolder_error_label.Hide(); } }; cancel_button.Clicked += delegate { Controller.PageCancelled(); }; back_button.Clicked += delegate { Controller.BackToPage2(); }; add_button.Clicked += delegate { Controller.CustomizePageCompleted(localfolder_entry.Text, localrepopath_entry.Text); }; VBox layout_vertical = new VBox (false, 12); layout_vertical.PackStart (new Label(""), false, false, 0); layout_vertical.PackStart (localfolder_label, true, true, 0); layout_vertical.PackStart (localfolder_entry, true, true, 0); layout_vertical.PackStart (localrepopath_label, true, true, 0); layout_vertical.PackStart (localrepopath_entry, true, true, 0); layout_vertical.PackStart (localfolder_error_label, true, true, 0); Add(layout_vertical); AddButton(back_button); AddButton(add_button); AddButton(cancel_button); // add_button.GrabFocus(); localfolder_entry.GrabFocus(); localfolder_entry.SelectRegion(0, localfolder_entry.Text.Length); }
private void ShowAdd1Page() { this.Present(); this.Header = Properties_Resources.Where; VBox layout_vertical = new VBox(false, 12); HBox layout_fields = new HBox(true, 12); VBox layout_address = new VBox(true, 0); HBox layout_address_help = new HBox(false, 3); VBox layout_user = new VBox(true, 0); VBox layout_password = new VBox(true, 0); // Address Label address_label = new Label() { UseMarkup = true, Xalign = 0, Markup = "<b>" + Properties_Resources.EnterWebAddress + "</b>" }; Entry address_entry = new Entry() { Text = (this.controller.PreviousAddress == null || string.IsNullOrEmpty(this.controller.PreviousAddress.ToString())) ? DefaultEntries.Defaults.Url : this.controller.PreviousAddress.ToString(), IsEditable = DefaultEntries.Defaults.CanModifyUrl, ActivatesDefault = false }; Label address_help_label = new Label() { Xalign = 0, UseMarkup = true, Markup = "<span foreground=\"#808080\" size=\"small\">" + Properties_Resources.Help + ": " + "</span>" }; EventBox address_help_urlbox = new EventBox(); Label address_help_urllabel = new Label() { Xalign = 0, UseMarkup = true, Markup = "<span foreground=\"blue\" underline=\"single\" size=\"small\">" + Properties_Resources.WhereToFind + "</span>" }; address_help_urlbox.Add(address_help_urllabel); address_help_urlbox.ButtonPressEvent += delegate(object o, ButtonPressEventArgs args) { Process process = new Process(); process.StartInfo.FileName = "xdg-open"; process.StartInfo.Arguments = "https://github.com/nicolas-raoul/CmisSync/wiki/What-address"; process.Start(); }; address_help_urlbox.EnterNotifyEvent += delegate(object o, EnterNotifyEventArgs args) { address_help_urlbox.GdkWindow.Cursor = handCursor; }; Label address_error_label = new Label() { Xalign = 0, UseMarkup = true, Markup = string.Empty }; address_error_label.Hide(); // User Entry user_entry = new Entry() { Text = this.controller.PreviousPath, ActivatesDefault = false }; if (string.IsNullOrEmpty(this.controller.saved_user)) { user_entry.Text = DefaultEntries.Defaults.Name; } else { user_entry.Text = this.controller.saved_user; } // Password Entry password_entry = new Entry() { Visibility = false, ActivatesDefault = true }; this.controller.ChangeAddressFieldEvent += delegate(string text, string example_text) { Application.Invoke(delegate { address_entry.Text = text; }); }; this.controller.ChangeUserFieldEvent += delegate(string text, string example_text) { Application.Invoke(delegate { user_entry.Text = text; }); }; this.controller.ChangePasswordFieldEvent += delegate(string text, string example_text) { Application.Invoke(delegate { password_entry.Text = text; }); }; address_entry.Changed += delegate { string error = this.controller.CheckAddPage(address_entry.Text); if (!string.IsNullOrEmpty(error)) { address_error_label.Markup = "<span foreground=\"red\">" + Properties_Resources.ResourceManager.GetString(error, CultureInfo.CurrentCulture) + "</span>"; address_error_label.Show(); } else { address_error_label.Hide(); } }; // Address layout_address_help.PackStart(address_help_label, false, false, 0); layout_address_help.PackStart(address_help_urlbox, false, false, 0); layout_address.PackStart(address_label, true, true, 0); layout_address.PackStart(address_entry, true, true, 0); layout_address.PackStart(layout_address_help, true, true, 0); // User layout_user.PackStart( new Label() { Markup = "<b>" + Properties_Resources.User + ":</b>", Xalign = 0 }, true, true, 0); layout_user.PackStart(user_entry, false, false, 0); // Password layout_password.PackStart( new Label() { Markup = "<b>" + Properties_Resources.Password + ":</b>", Xalign = 0 }, true, true, 0); layout_password.PackStart(password_entry, false, false, 0); layout_fields.PackStart(layout_user); layout_fields.PackStart(layout_password); layout_vertical.PackStart(layout_address, false, false, 0); layout_vertical.PackStart(layout_fields, false, false, 0); layout_vertical.PackStart(address_error_label, true, true, 0); this.Add(layout_vertical); // Cancel button Button cancel_button = new Button(this.cancelText); cancel_button.Clicked += delegate { this.controller.PageCancelled(); }; // Continue button Button continue_button = new Button(this.continueText) { Sensitive = string.IsNullOrEmpty(this.controller.CheckAddPage(address_entry.Text)) }; continue_button.Clicked += delegate { // Show wait cursor this.GdkWindow.Cursor = waitCursor; // Try to find the CMIS server (asynchronous using a delegate) GetRepositoriesDelegate dlgt = new GetRepositoriesDelegate(SetupController.GetRepositories); ServerCredentials credentials = new ServerCredentials() { UserName = user_entry.Text, Password = password_entry.Text, Address = new Uri(address_entry.Text), Binding = this.controller.saved_binding ?? ServerCredentials.BindingBrowser }; IAsyncResult ar = dlgt.BeginInvoke(credentials, null, null); while (!ar.AsyncWaitHandle.WaitOne(100)) { while (Application.EventsPending()) { Application.RunIteration(); } } var result = dlgt.EndInvoke(ar); if (result.Repositories != null) { this.controller.repositories = result.Repositories.WithoutHiddenOnce(); address_entry.Text = result.Credentials.Address.ToString(); } else { this.controller.repositories = null; // Show best found Url address_entry.Text = result.Credentials.Address.ToString(); // Show warning string warning = this.controller.GetConnectionsProblemWarning(result.FailedException); address_error_label.Markup = "<span foreground=\"red\">" + warning + "</span>"; address_error_label.Show(); } // Hide wait cursor this.GdkWindow.Cursor = defaultCursor; if (this.controller.repositories != null) { // Continue to folder selection this.controller.Add1PageCompleted( new Uri(address_entry.Text), result.Credentials.Binding, user_entry.Text, password_entry.Text); } }; this.controller.UpdateAddProjectButtonEvent += delegate(bool button_enabled) { Application.Invoke(delegate { continue_button.Sensitive = button_enabled; if (button_enabled) { continue_button.SetFlag(Gtk.WidgetFlags.CanFocus); continue_button.SetFlag(Gtk.WidgetFlags.CanDefault); continue_button.GrabDefault(); } }); }; this.AddButton(cancel_button); this.AddButton(continue_button); this.controller.CheckAddPage(address_entry.Text); address_entry.GrabFocus(); }
public GMan() { Application.Init(); window = new Gtk.Window("GMan"); window.SetDefaultSize(800, 600); window.DeleteEvent += new DeleteEventHandler(OnWindowDelete); // FIXME: we should remember where we were when we last ran. window.WindowPosition = WindowPosition.Center; VBox vbox = new VBox(false, 2); window.Add(vbox); vbox.PackStart(MakeMenuBar(), false, false, 1); HBox hbox = new HBox(false, 1); Label label = new Label("Search:"); entry = new Gtk.Entry(""); entry.Activated += new EventHandler(OnEntryActivated); Button button = new Button("!"); button.Clicked += new EventHandler(OnButtonClicked); Button backButton = new Button(Stock.GoBack); Button forwardButton = new Button(Stock.GoForward); hbox.PackStart(backButton, false, false, 1); hbox.PackStart(forwardButton, false, false, 1); hbox.PackStart(label, false, false, 1); hbox.PackStart(entry, true, true, 1); hbox.PackStart(button, false, false, 1); vbox.PackStart(hbox, false, false, 1); ScrolledWindow sw = new ScrolledWindow(); sw.VscrollbarPolicy = PolicyType.Always; sw.HscrollbarPolicy = PolicyType.Always; vbox.PackStart(sw, true, true, 1); statusBar = new Gtk.Statusbar(); vbox.PackStart(statusBar, false, false, 1); html = new HTML(); html.LinkClicked += new LinkClickedHandler(OnLinkClicked); html.OnUrl += new OnUrlHandler(OnOnUrl); html.TitleChanged += new TitleChangedHandler(OnTitleChanged); sw.Add(html); window.ShowAll(); entry.GrabFocus(); Application.Run(); }
void OnWidgetShown(object o, EventArgs args) { OffsetEntry.GrabFocus(); }
void HandleFocusOutEvent(object o, FocusOutEventArgs args) { _searchView.GrabFocus(); }
protected override void OnFocusGrabbed() { _entry?.GrabFocus(); }
public LoginRegisterDialog(Gtk.Window parentWindows) { if(parentWindows!=null) this.TransientFor = parentWindows; else this.TransientFor = MainClass.MainWindow; this.BorderWidth = 10; this.WindowPosition = Gtk.WindowPosition.CenterOnParent; notebook1 = new Notebook(); btnInfo = new Button(); btnInfo.Label = "Login"; btnInfo.UseUnderline = true; btnInfo.CanFocus = true; btnClose = new Button(); btnClose.CanDefault = true; btnClose.CanFocus = true; btnClose.Name = "buttonCancel"; btnClose.UseStock = true; btnClose.UseUnderline = true; btnClose.Label = "gtk-cancel"; btnClose.Clicked+= delegate(object sender, EventArgs e) { this.Respond(Gtk.ResponseType.Close); }; entrLoginR = new Entry(); entrPasswordR1 = new Entry(); entrPasswordR1.Visibility = false; entrPasswordR2 = new Entry(); entrPasswordR2.Visibility = false; entrEmailR = new Entry(); entrLogin = new Entry(); entrPassword = new Entry(); entrPassword.Visibility = false; chbRemember = new CheckButton(); chbRemember.Label = MainClass.Languages.Translate("loginDialog_remember"); linkbutton1 = new Components.LinkButton(); linkbutton1.HeightRequest=25; linkbutton1.UseWebStile = true; linkbutton1.LinkUrl = "http://moscrif.com/request-new-password"; linkbutton1.Label = MainClass.Languages.Translate("loginDialog_forgot_password"); Table mainTbl = new Table(2,1,false); mainTbl.RowSpacing = 6; mainTbl.ColumnSpacing = 6; //mainTbl.BorderWidth = 6; this.Title = MainClass.Languages.Translate("moscrif_ide_title_f1"); if(MainClass.Settings.Account != null){ if(!String.IsNullOrEmpty(MainClass.Settings.Account.Login)) entrLogin.Text = MainClass.Settings.Account.Login; chbRemember.Active =MainClass.Settings.Account.Remember; } bannerImage.WidthRequest = 400; bannerImage.HeightRequest = 120; mainTbl.Attach(bannerImage,0,1,0,1,AttachOptions.Fill,AttachOptions.Shrink,0,0); Table tblPage1 = new Table(5,2,false); tblPage1.BorderWidth = 6; tblPage1.ColumnSpacing = 6; tblPage1.RowSpacing = 6; AddControl(ref tblPage1, 0,entrLogin,MainClass.Languages.Translate("loginDialog_login")); AddControl(ref tblPage1, 1,entrPassword,MainClass.Languages.Translate("loginDialog_password")); AddControl(ref tblPage1, 2,chbRemember,""); AddControl(ref tblPage1, 3,linkbutton1,""); notebook1.AppendPage(tblPage1,new Label ("Login")); Table tblPage2 = new Table(5,2,false); tblPage2.ColumnSpacing = 6; tblPage2.RowSpacing = 6; tblPage2.BorderWidth = 6; AddControl(ref tblPage2, 0,entrLoginR,MainClass.Languages.Translate("loginDialog_login")); AddControl(ref tblPage2, 1,entrPasswordR1,MainClass.Languages.Translate("loginDialog_reg_password1")); AddControl(ref tblPage2, 2,entrPasswordR2,MainClass.Languages.Translate("loginDialog_reg_password2")); AddControl(ref tblPage2, 3,entrEmailR,MainClass.Languages.Translate("loginDialog_reg_email")); notebook1.AppendPage(tblPage2,new Label ("Register")); Gtk.Notebook.NotebookChild nchT1 = (Gtk.Notebook.NotebookChild)this.notebook1[tblPage1]; nchT1.TabExpand = true; nchT1.TabFill = false; Gtk.Notebook.NotebookChild nchT2 = (Gtk.Notebook.NotebookChild)this.notebook1[tblPage2]; nchT2.TabExpand = true; nchT2.TabFill = false; mainTbl.Attach(notebook1,0,1,1,2,AttachOptions.Fill|AttachOptions.Expand,AttachOptions.Fill|AttachOptions.Expand,0,0); LoadDefaultBanner(); Thread BannerThread = new Thread(new ThreadStart(BannerThreadLoop)); BannerThread.Name = "BannerThread"; BannerThread.IsBackground = true; BannerThread.Start(); entrPassword.GrabFocus(); //entrLogin.GrabFocus(); this.VBox.Add(mainTbl); this.ActionArea.Add(btnClose); this.ActionArea.Add(btnInfo); btnInfo.Clicked += new System.EventHandler (this.OnBtnInfoClicked); this.notebook1.SwitchPage += new Gtk.SwitchPageHandler (this.OnNotebook1SwitchPage); this.entrPassword.KeyReleaseEvent += new Gtk.KeyReleaseEventHandler (this.OnEntrPasswordKeyReleaseEvent); this.entrLogin.KeyReleaseEvent += new Gtk.KeyReleaseEventHandler (this.OnEntrLoginKeyReleaseEvent); //this.BorderWidth = 6; this.HeightRequest = 370; this.ShowAll(); }