本文整理汇总了C#中Gtk.Entry.GrabFocus方法的典型用法代码示例。如果您正苦于以下问题:C# Entry.GrabFocus方法的具体用法?C# Entry.GrabFocus怎么用?C# Entry.GrabFocus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.Entry
的用法示例。
在下文中一共展示了Entry.GrabFocus方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RecentFileListWindow
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 ();
}
示例2: MemberListWindow
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 ();
}
示例3: rename_category
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();
}
示例4: BuildControl
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();
}
示例5: rename_label
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();
}
示例6: add_new_label
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();
}
示例7: BuildSignIn
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 ();
}
示例8: ShowPage
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;
//.........这里部分代码省略.........
示例9: Initialize
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 ();
}
示例10: ShowAdd1Page
//.........这里部分代码省略.........
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();
}
示例11: ShowCustomizePage
//.........这里部分代码省略.........
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);
}
示例12: ShowAdd1Page
//.........这里部分代码省略.........
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();
}
示例13: ShowAdd1Page
//.........这里部分代码省略.........
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 ();
}
示例14: ShowCustomizePage
//.........这里部分代码省略.........
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);
}
示例15: ShowPage
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;
//.........这里部分代码省略.........