【问题标题】:Gtk widget to receive and display one Image at a timeGtk 小部件一次接收和显示一个图像
【发布时间】:2015-11-28 21:36:18
【问题描述】:

如何创建应用程序的简单 vala Gtk 代码来打开文件夹的图像并一次显示一个?

我必须创建一个 Vala 应用程序来打开一个图像文件夹并一次显示一个图像。

我有一个 Gtk.Stack 来显示为 Gtk.FileChooserDialog 接收的一个图像,但我无法使用 Gtk.Filechooser.Dialog 来接收更多元素并显示它们。

谢谢

【问题讨论】:

  • 你能把你的问题说得更清楚一点吗?我不太明白你的问题。
  • 对不起,我想做一个应用程序来打开一个图像文件夹并一次显示一个图像。
  • 您可以选择文件夹本身,而不是文件。

标签: gtk vala


【解决方案1】:

有两种解决方案:

  1. 您想从同一个文件夹中选择多个文件:然后只需执行chooser.select_multiple = true;,您将通过chooser.get_uris()获得文件URI的SList

  2. 您只需选择文件夹:然后使用正确的操作创建您的 FileChooserDialog (Gtk.FileChooserAction.SELECT_FOLDER):

    var chooser = new Gtk.FileChooserDialog (
                "Pick the folder to load the images", this, 
                Gtk.FileChooserAction.SELECT_FOLDER,
                "_Cancel",
                Gtk.ResponseType.CANCEL,
                "_Open",
                Gtk.ResponseType.ACCEPT);
    

    当你得到正确的文件夹时:

    if (chooser.run () == Gtk.ResponseType.ACCEPT) {
        var folder = File.new_from_uri (chooser.get_uri ());
        if (folder.query_exists() && folder.query_file_type (0) == FileType.DIRECTORY) {
        // It's a directory and exists, so enumerate the children and do you stuff   
        }
    }
    chooser.close ();
    

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-04-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多