Commits

Andreas Tscharner committed 9c9780b

gui: Create FileChooserDialog programmatically instead via glade

The one glade provided neither had the filter drop down box nor the [add]
and [remove] sign to add and remove favorite folders

Comments (0)

Files changed (2)

src/gui/AddRemoveHandlers.cxx

 
 #include <gtkmm/builder.h>
 #include <gtkmm/button.h>
+#include <gtkmm/stock.h>
 #include "AddRemoveHandlers.hxx"
 
 
 
 AddRemoveHandlers::AddRemoveHandlers(Glib::RefPtr<Gtk::Builder> p_refBuilder)
 {
+	Gtk::Window *mainWin;
+	Glib::RefPtr<Gtk::FileFilter> anyFile = Gtk::FileFilter::create();
+
+
 	p_refBuilder->get_widget("bnAdd", m_addButton);
 	m_addButton->signal_clicked().connect(sigc::mem_fun(*this,
 	                                         &AddRemoveHandlers::on_add_button_clicked));
 	m_removeButton->signal_clicked().connect(sigc::mem_fun(*this,
 	                                            &AddRemoveHandlers::on_remove_button_clicked));
 
-	p_refBuilder->get_widget("dlgAddFiles", m_addFilesDlg);
+	p_refBuilder->get_widget("MainWindow", mainWin);
+	m_addFilesDlg = new Gtk::FileChooserDialog(*mainWin, "Dateien für Resourcen auswählen",
+	                                           Gtk::FILE_CHOOSER_ACTION_OPEN);
+
+	m_addFilesDlg->set_select_multiple(true);
+	m_addFilesDlg->set_has_resize_grip(false);
+	m_addFilesDlg->set_create_folders(false);
+
+	m_addFilesDlg->add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
+	m_addFilesDlg->add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
+
+	anyFile->set_name("Any file");
+	anyFile->add_pattern("*");
+	m_addFilesDlg->add_filter(anyFile);
 }
 
 AddRemoveHandlers::~AddRemoveHandlers(void)

src/gui/ResourceEditor.glade

 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <!-- interface-requires gtk+ 3.0 -->
+  <object class="GtkListStore" id="lstResourceFiles"/>
   <object class="GtkWindow" id="MainWindow">
     <property name="can_focus">False</property>
     <property name="title" translatable="yes">lrc Resource Editor</property>
     <property name="default_height">250</property>
     <property name="icon">icon/lrc.png</property>
     <property name="has_resize_grip">False</property>
-    <signal name="destroy" handler="on_window_destroy" swapped="no"/>
     <child>
       <object class="GtkBox" id="box1">
         <property name="visible">True</property>
       </object>
     </child>
   </object>
-  <object class="GtkFileFilter" id="dlgAddFilesFilter">
-    <patterns>
-      <pattern>*</pattern>
-    </patterns>
-  </object>
-  <object class="GtkFileChooserDialog" id="dlgAddFiles">
-    <property name="can_focus">False</property>
-    <property name="border_width">5</property>
-    <property name="title" translatable="yes">Dateien für Resourcen auswählen</property>
-    <property name="modal">True</property>
-    <property name="window_position">mouse</property>
-    <property name="type_hint">dialog</property>
-    <property name="has_resize_grip">False</property>
-    <property name="create_folders">False</property>
-    <property name="filter">dlgAddFilesFilter</property>
-    <property name="select_multiple">True</property>
-    <child internal-child="vbox">
-      <object class="GtkBox" id="filechooserdialog-vbox1">
-        <property name="can_focus">False</property>
-        <property name="orientation">vertical</property>
-        <property name="spacing">2</property>
-        <child internal-child="action_area">
-          <object class="GtkButtonBox" id="filechooserdialog-action_area1">
-            <property name="can_focus">False</property>
-            <property name="layout_style">end</property>
-            <child>
-              <object class="GtkButton" id="bnDlgCancel">
-                <property name="label">gtk-cancel</property>
-                <property name="use_action_appearance">False</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="bnDlgOpen">
-                <property name="label">gtk-open</property>
-                <property name="use_action_appearance">False</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="pack_type">end</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-      </object>
-    </child>
-    <action-widgets>
-      <action-widget response="-1">bnDlgCancel</action-widget>
-      <action-widget response="0">bnDlgOpen</action-widget>
-    </action-widgets>
-  </object>
-  <object class="GtkListStore" id="lstResourceFiles">
-    <columns>
-      <!-- column-name resFileSelection -->
-      <column type="GtkFileChooserAction"/>
-      <!-- column-name compressionType -->
-      <column type="GtkSelectionMode"/>
-      <!-- column-name encryptionType -->
-      <column type="GtkSelectionMode"/>
-      <!-- column-name resPassword -->
-      <column type="gchar"/>
-    </columns>
-    <data>
-      <row>
-        <col id="0">open</col>
-        <col id="1">single</col>
-        <col id="2">single</col>
-        <col id="3"/>
-      </row>
-    </data>
-  </object>
 </interface>