你能在 Glade 中为 Gtk 对话框设置文件过滤器吗?
在我的代码中,我有这样的行:
Builder builder = new Builder();
builder.AddFromFile(gladefile);
FileChooserDialog dialog =
(FileChooserDialog) builder.GetObject("dialog");
FileFilter[] filters = new FileFilter[2];
filters[0] = new FileFilter();
filters[0].Name = "Some filter";
filters[0].AddPattern("*.someextension");
filters[1] = new FileFilter();
filters[1].Name = "All files";
filters[1].AddPattern("*");
foreach (FileFilter filter in filters)
dialog.AddFilter(filter);
dialog.Filter = filters[0];
dialog.SetFilename(defaultFile);
有没有办法在 Glade 中设置这些过滤器,而不是手动执行?
In my code, I have lines like this:
Builder builder = new Builder();
builder.AddFromFile(gladefile);
FileChooserDialog dialog =
(FileChooserDialog) builder.GetObject("dialog");
FileFilter[] filters = new FileFilter[2];
filters[0] = new FileFilter();
filters[0].Name = "Some filter";
filters[0].AddPattern("*.someextension");
filters[1] = new FileFilter();
filters[1].Name = "All files";
filters[1].AddPattern("*");
foreach (FileFilter filter in filters)
dialog.AddFilter(filter);
dialog.Filter = filters[0];
dialog.SetFilename(defaultFile);
Is there a way to set up these filters in Glade, rather than doing it manually?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
现在有可能了。代码片段可能看起来像这样:
It is possible now. The code snippet should probably look something like this:
不可以。您可以在glade(3.6 及更高版本)中创建一个文件过滤器对象并将其添加到对话框中,但由于您无法实际设置文件过滤器的名称或模式,因此它相当无用。
No. You can create a file filter object in glade (version 3.6 and up) and add it to the dialog, but since you can't actually set the name or pattern of the file filter, it's fairly useless.