1. Andreas Tscharner
  2. lrc

Commits

Andreas Tscharner  committed 34c08c4

gui: Added signal handlers for [Add] and [Remove] buttons

* Declaration and definition of signal handlers in new class
* Preliminary call the file chooser dialog if user clicks [Add]
* Some GUI updates

  • Participants
  • Parent commits b15668b
  • Branches default

Comments (0)

Files changed (6)

File src/gui/AddRemoveHandlers.cxx

View file
+/*
+ * AddRemoveHandlers.cxx
+ *
+ * Copyright 2012 Andreas Tscharner <andy@vis.ethz.ch>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+
+#include <gtkmm/builder.h>
+#include <gtkmm/button.h>
+#include "AddRemoveHandlers.hxx"
+
+
+void AddRemoveHandlers::on_add_button_clicked(void)
+{
+	int dlgRet;
+
+
+	dlgRet = m_addFilesDlg->run();
+	m_addFilesDlg->hide();
+}
+
+void AddRemoveHandlers::on_remove_button_clicked(void)
+{
+}
+
+AddRemoveHandlers::AddRemoveHandlers(Glib::RefPtr<Gtk::Builder> p_refBuilder)
+{
+	p_refBuilder->get_widget("bnAdd", m_addButton);
+	m_addButton->signal_clicked().connect(sigc::mem_fun(*this,
+	                                         &AddRemoveHandlers::on_add_button_clicked));
+
+	p_refBuilder->get_widget("bnRemove", m_removeButton);
+	m_removeButton->signal_clicked().connect(sigc::mem_fun(*this,
+	                                            &AddRemoveHandlers::on_remove_button_clicked));
+
+	p_refBuilder->get_widget("dlgAddFiles", m_addFilesDlg);
+}
+
+AddRemoveHandlers::~AddRemoveHandlers(void)
+{
+	delete m_addFilesDlg;
+	delete m_removeButton;
+	delete m_addButton;
+}

File src/gui/AddRemoveHandlers.hxx

View file
+/*
+ * AddRemoveHandlers.hxx
+ *
+ * Copyright 2012 Andreas Tscharner <andy@vis.ethz.ch>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+
+/*! \file AddRemoveHandlers.hxx
+ *
+ * This file contains the AddRemoveHandlers class. This class is responsible
+ * for the actions if the user clicks the "Add" or "Remove" button on the
+ * main window
+ *
+ * \author Andreas Tscharner
+ * \date 2012-06-10
+ */
+
+
+#ifndef __ADDREMOVEHANDLERS_HXX__
+#define __ADDREMOVEHANDLERS_HXX__
+
+
+#include <gtkmm/button.h>
+#include <gtkmm/builder.h>
+#include <gtkmm/filechooserdialog.h>
+
+
+/*! \class AddRemoveHandlers
+ *  \brief Class to handle the two main buttons
+ *
+ * Class that handles the clicks on the "Add" and the "Remove" button on the
+ * main window
+ */
+class AddRemoveHandlers
+{
+	private:
+		Gtk::Button *m_addButton;      //!< Reference to "Add" button
+		Gtk::Button *m_removeButton;   //!< Reference to "Remove" button
+		Gtk::FileChooserDialog *m_addFilesDlg;   //!< Reference to "Add Files" dialog
+
+	protected:
+		/*! \brief Signal handler for "Add" button
+		 *
+		 * This method is the actual signal handler for the "Add" button. It
+		 * shows the file selection window and adds all selected files to
+		 * the list of resource files
+		 */
+		void on_add_button_clicked(void);
+		/*! \brief Signal handler for "Remove" button
+		 *
+		 * This method is the actual sognal handler for the "Remove" button.
+		 * It removes all selected files from the list of resource files.
+		 */
+		void on_remove_button_clicked(void);
+
+	public:
+		/*! \brief Constructor
+		 *
+		 * The constructor connects the "clicked" signals of the "Add" and
+		 * "Remove" buttons with the corresponding singnal handler methods
+		 *
+		 * \param[in] p_refBuilder Reference to the builder that loaded the
+		 *                         glade GUI file
+		 */
+		AddRemoveHandlers(Glib::RefPtr<Gtk::Builder>);
+		/*! \brief Destructor
+		 *
+		 * Frees all the used memory
+		 */
+		~AddRemoveHandlers(void);
+};
+
+
+#endif /* __ADDREMOVEHANDLERS_HXX__ */

File src/gui/MainWindow.cxx

View file
 
 
 #include "MainWindow.hxx"
+#include "AddRemoveHandlers.hxx"
 
 
 MainWindow::MainWindow(Gtk::Window *p_mainWin, Glib::RefPtr<Gtk::Builder> p_refBuilder)
 {
 	m_mainWindow = p_mainWin;
 	m_refBuilder = p_refBuilder;
+
+	m_addRemove = new AddRemoveHandlers(m_refBuilder);
 }
 
 MainWindow::~MainWindow()
 {
+	delete m_addRemove;
+
 	m_mainWindow = nullptr;
 }

File src/gui/MainWindow.hxx

View file
 // Include files
 #include <gtkmm/builder.h>
 #include <gtkmm/window.h>
+#include "AddRemoveHandlers.hxx"
 
 
 /*! \class MainWindow
 		Gtk::Window *m_mainWindow;     //!< Reference to main window class
 		Glib::RefPtr<Gtk::Builder> m_refBuilder;     //!< Reference to builder that created the UI from XML
 
+		AddRemoveHandlers *m_addRemove;//!< Class instance to handle the "Add" and "Remove" button
+
 	public:
 		/*! \brief Constructor
 		 *

File src/gui/Makefile.am

View file
 
 #
 # Define source files for main program
-lrcResourceEditor_SOURCES = MainWindow.hxx MainWindow.cxx \
+lrcResourceEditor_SOURCES = MainWindow.hxx MainWindow.cxx               \
+                            AddRemoveHandlers.hxx AddRemoveHandlers.cxx \
                             lrcResourceEditor.cxx
 
 #

File src/gui/ResourceEditor.glade

View file
     <property name="default_width">440</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">
       </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="can_focus">False</property>
             <property name="layout_style">end</property>
             <child>
-              <placeholder/>
+              <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>
-              <placeholder/>
+              <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>
         </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>
         <col id="0">open</col>
         <col id="1">single</col>
         <col id="2">single</col>
-        <col id="3"></col>
+        <col id="3"/>
       </row>
     </data>
   </object>