Commits

Andreas Tscharner  committed b15668b

gui: Change to gtkmm-3.0 (from gtkmm-2.4)

* This implies a change from libglade to Gtk::Builder
* This is the first version where the GUI is actually displayed

  • Participants
  • Parent commits dcc6548

Comments (0)

Files changed (4)

File configure.in

 PKG_CHECK_EXISTS([libcryptopp], [CRYPTOPP_ok="yes"], [CRYPTOPP_ok="no (using internal)"])
 PKG_CHECK_EXISTS([libcrypto++], [PPCRYPTO_ok="yes"], [PPCRYPTO_ok="no (using internal)"])
 PKG_CHECK_MODULES([GUI_DEPS],
-                  [glibmm-2.4 >= 2.32.0 gtkmm-2.4 >= 2.24.2 libglademm-2.4 >= 2.6.7],
+                  [glibmm-2.4 >= 2.32.0 gtkmm-3.0 >= 3.4.0],
                   [GUI_DEPS_ok="yes"],
                   [GUI_DEPS_ok="no (do not build the gui"])
 

File src/gui/MainWindow.cxx

 #include "MainWindow.hxx"
 
 
-MainWindow::MainWindow(Gtk::Window *p_mainWin, Glib::RefPtr<Gnome::Glade::Xml> p_xmlRef)
+MainWindow::MainWindow(Gtk::Window *p_mainWin, Glib::RefPtr<Gtk::Builder> p_refBuilder)
 {
 	m_mainWindow = p_mainWin;
-	m_xmlRef = p_xmlRef;
+	m_refBuilder = p_refBuilder;
 }
 
 MainWindow::~MainWindow()

File src/gui/MainWindow.hxx

  * classes
  *
  * \author Andreas Tscharner
- * \date 2012-05-27
+ * \date 2012-06-09
  */
 
 
 
 
 // Include files
-#include <gtkmm.h>
-#include <libglademm/xml.h>
+#include <gtkmm/builder.h>
+#include <gtkmm/window.h>
 
 
 /*! \class MainWindow
 {
 	private:
 		Gtk::Window *m_mainWindow;     //!< Reference to main window class
-		Glib::RefPtr<Gnome::Glade::Xml> m_xmlRef;     //!< Reference to XML decribing the GUI of the application
+		Glib::RefPtr<Gtk::Builder> m_refBuilder;     //!< Reference to builder that created the UI from XML
 
 	public:
 		/*! \brief Constructor
 		 * the window and a reference pointer to the glade file as parameters
 		 *
 		 * \param[in] p_mainWin Pointer to GTK window
-		 * \param[in] p_xmlRef Reference pointer to loaded glade file
+		 * \param[in] p_refBuilder Reference pointer to builder that loaded
+		 *                         the glade file
 		 */
-		MainWindow(Gtk::Window *, Glib::RefPtr<Gnome::Glade::Xml>);
+		MainWindow(Gtk::Window *, Glib::RefPtr<Gtk::Builder>);
 		/*! \brief Destructor
 		 *
 		 * The destructor cleans up any used memory from this class

File src/gui/lrcResourceEditor.cxx

  */
 
 
-#include <libglademm/xml.h>
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
+#include <gtkmm/builder.h>
 #include <gtkmm/window.h>
+#include <glibmm/fileutils.h>
+#include <glibmm/markup.h>
 #include <iostream>
 #include "MainWindow.hxx"
 
 int main(int argc, char **argv)
 {
-	Glib::RefPtr<Gnome::Glade::Xml> xmlRef;
+	Glib::RefPtr<Gtk::Application> mainApp;
+	Glib::RefPtr<Gtk::Builder> builder;
 	Gtk::Window *mainWin = nullptr;
 	MainWindow *mainWinTasks;
 
 
-	Gtk::Main mainPrg(argc, argv);
-
+	mainApp = Gtk::Application::create(argc, argv, "ch.blackmoon.lrcResEdit");
 	try {
-		xmlRef = Gnome::Glade::Xml::create("ResourceEditor.glade");
-	} catch (Gnome::Glade::XmlError &xmlErr) {
-		std::cout << "Loading the ResourceEditor.glade failed for the following reason: " << xmlErr.what() << std::endl;
+		builder = Gtk::Builder::create_from_file("ResourceEditor.glade");
+	} catch (const Glib::FileError &fErr) {
+		std::cout << "Loading the ResourceEditor.glade failed with a FileError: " << fErr.what() << std::endl;
+		return -1;
+	} catch (const Glib::MarkupError &mErr) {
+		std::cout << "Loading the ResourceEditor.glade failed with a MarkupError: " << mErr.what() << std::endl;
+		return -1;
+	} catch (const Gtk::BuilderError &bErr) {
+		std::cout << "Loading the ResourceEditor.glade failed with a BuilderError: " << bErr.what() << std::endl;
 		return -1;
 	};
-	mainWin = xmlRef->get_widget("MainWindow", mainWin);
 
-	mainWinTasks = new MainWindow(mainWin, xmlRef);
+	builder->get_widget("MainWindow", mainWin);
+	mainWinTasks = new MainWindow(mainWin, builder);
 
-	mainPrg.run(*mainWin);
-	mainWin->hide_all();
+	mainApp->run(*mainWin);
 
 	delete mainWinTasks;
+	delete mainWin;
 
 	return 0;
 }