Commits

Andreas Tscharner committed 234bffc

gui: Show edit dialog if [Edit] button is clicked

  • Participants
  • Parent commits 8d68b6c

Comments (0)

Files changed (3)

File src/gui/ButtonHandlers.cxx

 	m_listHandler->removeSelected(selectedRes);
 }
 
+void ButtonHandlers::on_edit_button_clicked(void)
+{
+	int dlgRet;
+
+
+	dlgRet = m_editDialog->run();
+	m_editDialog->hide();
+}
+
 ButtonHandlers::ButtonHandlers(Glib::RefPtr<Gtk::Builder> p_refBuilder)
 {
 	Gtk::Window *mainWin;
 
 	p_refBuilder->get_widget("bnAdd", m_addButton);
 	m_addButton->signal_clicked().connect(sigc::mem_fun(*this,
-	                                         &ButtonHandlers::on_add_button_clicked));
-
+	                                      &ButtonHandlers::on_add_button_clicked));
 	p_refBuilder->get_widget("bnRemove", m_removeButton);
 	m_removeButton->signal_clicked().connect(sigc::mem_fun(*this,
-	                                            &ButtonHandlers::on_remove_button_clicked));
+	                                         &ButtonHandlers::on_remove_button_clicked));
+	p_refBuilder->get_widget("bnEdit", m_editButton);
+	m_editButton->signal_clicked().connect(sigc::mem_fun(*this,
+	                                       &ButtonHandlers::on_edit_button_clicked));
 
 	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);
 
+	p_refBuilder->get_widget("dlgEdit", m_editDialog);
+
 	m_listHandler = nullptr;
 }
 
 ButtonHandlers::~ButtonHandlers(void)
 {
+	delete m_editDialog;
 	delete m_addFilesDlg;
+	delete m_editButton;
 	delete m_removeButton;
 	delete m_addButton;
 }

File src/gui/ButtonHandlers.hxx

 		Glib::RefPtr<Gtk::Builder> m_refBuilder; //!< Reference to main builder
 		Gtk::Button *m_addButton;      //!< Reference to "Add" button
 		Gtk::Button *m_removeButton;   //!< Reference to "Remove" button
+		Gtk::Button *m_editButton;     //!< Reference to "Edit" button
 		Gtk::FileChooserDialog *m_addFilesDlg;   //!< Reference to "Add Files" dialog
+		Gtk::Dialog *m_editDialog;     //!< Reference to dialog for editing the selected resource
 		ListHandler *m_listHandler;    //!< Reference to (global) list handler class
 
 	protected:
 		 * It removes all selected files from the list of resource files.
 		 */
 		void on_remove_button_clicked(void);
+		/*! \brief Signal handler for "Edit" button
+		 *
+		 * This method is the actual signal handler for the "Edit" button.
+		 * It allows editing the metadata of the selected resource
+		 */
+		void on_edit_button_clicked(void);
 
 	public:
 		/*! \brief Constructor
 		 *
-		 * The constructor connects the "clicked" signals of the "Add" and
-		 * "Remove" buttons with the corresponding singnal handler methods
+		 * The constructor connects the "clicked" signals of the "Add",
+		 * "Remove" and "Edit" buttons with the corresponding singnal
+		 * handler methods
 		 *
 		 * \param[in] p_refBuilder Reference to the builder that loaded the
 		 *                         glade GUI file

File src/gui/ResourceEditor.glade

                 <property name="position">1</property>
               </packing>
             </child>
+            <child>
+              <object class="GtkButton" id="bnEdit">
+                <property name="label">gtk-edit</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">2</property>
+              </packing>
+            </child>
           </object>
           <packing>
             <property name="expand">False</property>
       </object>
     </child>
   </object>
+  <object class="GtkDialog" id="dlgEdit">
+    <property name="can_focus">False</property>
+    <property name="border_width">5</property>
+    <property name="title" translatable="yes">Resource bearbeiten</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>
+    <child internal-child="vbox">
+      <object class="GtkBox" id="dialog-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="dialog-action_area1">
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="bnOK">
+                <property name="label">gtk-ok</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="bnCancel">
+                <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>
+                <property name="yalign">0.44999998807907104</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>
+          <object class="GtkGrid" id="grid1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="row_spacing">3</property>
+            <child>
+              <object class="GtkLabel" id="lbID">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">1</property>
+                <property name="label" translatable="yes">ID:</property>
+                <property name="justify">right</property>
+                <property name="ellipsize">start</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">0</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="lbFilename">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">1</property>
+                <property name="label" translatable="yes">Dateiname:</property>
+                <property name="justify">right</property>
+                <property name="ellipsize">start</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">1</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="lbCompression">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">1</property>
+                <property name="label" translatable="yes">Komprimierung:</property>
+                <property name="justify">right</property>
+                <property name="ellipsize">start</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">2</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="lbEncryption">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">1</property>
+                <property name="label" translatable="yes">Verschlüsselung:</property>
+                <property name="justify">right</property>
+                <property name="ellipsize">start</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">3</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="lbPassword">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">1</property>
+                <property name="label" translatable="yes">Passwort:</property>
+                <property name="justify">right</property>
+                <property name="ellipsize">start</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">4</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkEntry" id="edID">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="invisible_char">•</property>
+                <property name="primary_icon_tooltip_text" translatable="yes">Eindeutige ID der Resource</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="top_attach">0</property>
+                <property name="width">2</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkEntry" id="edFilename">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="editable">False</property>
+                <property name="invisible_char">•</property>
+                <property name="primary_icon_tooltip_text" translatable="yes">Datei, die als Resource verwendet wird</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="top_attach">1</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="bnSelectFilename">
+                <property name="label">...</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="yalign">0.52999997138977051</property>
+              </object>
+              <packing>
+                <property name="left_attach">2</property>
+                <property name="top_attach">1</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkComboBox" id="cbxCompression">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="top_attach">2</property>
+                <property name="width">2</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkComboBox" id="cbxEncryption">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="top_attach">3</property>
+                <property name="width">2</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkEntry" id="edPassword">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="visibility">False</property>
+                <property name="invisible_char">•</property>
+                <property name="primary_icon_tooltip_text" translatable="yes">Passwort, falss Verschlüsselung aktiv ist</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="top_attach">4</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="bnSelectPasswordFile">
+                <property name="label">...</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>
+              </object>
+              <packing>
+                <property name="left_attach">2</property>
+                <property name="top_attach">4</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="0">bnOK</action-widget>
+      <action-widget response="0">bnCancel</action-widget>
+    </action-widgets>
+  </object>
 </interface>