本文整理汇总了C#中Gtk.Entry.GrabFocus方法的典型用法代码示例。如果您正苦于以下问题:C# Gtk.Entry.GrabFocus方法的具体用法?C# Gtk.Entry.GrabFocus怎么用?C# Gtk.Entry.GrabFocus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.Entry
的用法示例。
在下文中一共展示了Gtk.Entry.GrabFocus方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddClicked
void AddClicked (object sender, EventArgs args)
{
Gtk.FileChooserDialog dialog = new Gtk.FileChooserDialog (
Catalog.GetString ("Select an icon..."),
null, Gtk.FileChooserAction.Open, new object[] {});
dialog.AddButton (Gtk.Stock.Cancel, Gtk.ResponseType.Cancel);
dialog.AddButton (Gtk.Stock.Open, Gtk.ResponseType.Ok);
dialog.DefaultResponse = Gtk.ResponseType.Ok;
dialog.LocalOnly = true;
dialog.SetCurrentFolder (last_opened_dir);
Gtk.FileFilter filter = new Gtk.FileFilter ();
filter.AddPixbufFormats ();
dialog.Filter = filter;
// Extra Widget
Gtk.Label l = new Gtk.Label (Catalog.GetString ("_Host name:"));
Gtk.Entry host_entry = new Gtk.Entry ();
l.MnemonicWidget = host_entry;
Gtk.HBox hbox = new Gtk.HBox (false, 6);
hbox.PackStart (l, false, false, 0);
hbox.PackStart (host_entry, true, true, 0);
hbox.ShowAll ();
dialog.ExtraWidget = hbox;
int response;
string icon_file;
string host;
run_add_dialog:
response = dialog.Run ();
icon_file = dialog.Filename;
host = host_entry.Text.Trim ();
if (response == (int) Gtk.ResponseType.Ok
&& host == String.Empty) {
// Let the user know that they
// have to specify a host name.
HIGMessageDialog warn =
new HIGMessageDialog (
null,
Gtk.DialogFlags.DestroyWithParent,
Gtk.MessageType.Warning,
Gtk.ButtonsType.Ok,
Catalog.GetString ("No host name specified"),
Catalog.GetString ("You must specify the Bugzilla " +
"host name to use with this icon."));
warn.Run ();
warn.Destroy ();
host_entry.GrabFocus ();
goto run_add_dialog;
} else if (response != (int) Gtk.ResponseType.Ok) {
dialog.Destroy ();
return;
}
// Keep track of the last directory the user had open
last_opened_dir = dialog.CurrentFolder;
dialog.Destroy ();
// Copy the file to the BugzillaIcons directory
string err_msg;
if (!CopyToBugizllaIconsDir (icon_file, host, out err_msg)) {
HIGMessageDialog err =
new HIGMessageDialog (
null,
Gtk.DialogFlags.DestroyWithParent,
Gtk.MessageType.Error,
Gtk.ButtonsType.Ok,
Catalog.GetString ("Error saving icon"),
Catalog.GetString ("Could not save the icon file.") +
" " +
err_msg);
err.Run ();
err.Destroy ();
}
UpdateIconStore ();
}