如何正确使用GtkFileChooserDialog在Glade中打开文件?

时间:2018-12-09 20:19:45

标签: c gtk3 glade

如何使用Glade在GtkFileChooserDialog中的GtkHeaderBar中添加打开按钮?我在Glade中找不到单个选项,这使我可以执行此基本操作。有人知道如何找到这个选项吗?我在互联网上找不到单个示例。

添加GtkFileChooserDialog时,它看起来像这样(我在底部添加了一个额外的按钮,但是想像它不存在)

enter image description here

但是它应该像这样 enter image description here

2 个答案:

答案 0 :(得分:0)

关于您的问题:

要使程序能够从文件或用户中读取

要读取文件:

myprogram  < myfile  

要向用户阅读:

myprogram

然后总是从stdin读取实际程序

答案 1 :(得分:0)

以下是一个Glade文件,其中显示了一个示例:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
  <requires lib="gtk+" version="3.20"/>
  <object class="GtkFileChooserDialog">
    <property name="can_focus">False</property>
    <property name="type_hint">dialog</property>
    <child type="titlebar">
      <object class="GtkHeaderBar">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <child>
          <object class="GtkButton">
            <property name="label" translatable="yes">button</property>
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">True</property>
          </object>
        </child>
        <child>
          <object class="GtkButton">
            <property name="label" translatable="yes">button</property>
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">True</property>
          </object>
          <packing>
            <property name="pack_type">end</property>
            <property name="position">1</property>
          </packing>
        </child>
      </object>
    </child>
    <child internal-child="vbox">
      <object class="GtkBox">
        <property name="can_focus">False</property>
        <property name="orientation">vertical</property>
        <property name="spacing">2</property>
        <child internal-child="action_area">
          <object class="GtkButtonBox">
            <property name="can_focus">False</property>
            <property name="layout_style">end</property>
            <child>
              <object class="GtkComboBoxText">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <items>
                  <item translatable="yes">option 1</item>
                  <item translatable="yes">option 2</item>
                </items>
              </object>
              <packing>
                <property name="expand">True</property>
                <property name="fill">True</property>
                <property name="position">0</property>
              </packing>
            </child>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">False</property>
            <property name="position">0</property>
          </packing>
        </child>
      </object>
    </child>
  </object>
</interface>