From 2bd663e0db1f365595aa9f04a8423ca85b9a1063 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 7 Jan 2010 08:05:35 +0100 Subject: Migrated from Glade to GtkBuilder --- src/Gui/AspectFrame.h | 4 ++-- src/Gui/RenderArea.cpp | 2 +- src/Gui/RenderArea.h | 4 ++-- src/Gui/Window.cpp | 16 +++++++++++----- src/Gui/Window.h | 4 ++-- src/Instance.cpp | 26 +++++++------------------- src/Instance.h | 4 ++-- 7 files changed, 27 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/Gui/AspectFrame.h b/src/Gui/AspectFrame.h index 0831956..1008464 100644 --- a/src/Gui/AspectFrame.h +++ b/src/Gui/AspectFrame.h @@ -21,7 +21,7 @@ #define ZOOMEDIT_GUI_ASPECTFRAME_H_ #include -#include +#include namespace ZoomEdit { namespace Gui { @@ -40,7 +40,7 @@ class AspectFrame : public Gtk::AspectFrame { } public: - AspectFrame(BaseObjectType *cobject, const Glib::RefPtr&) + AspectFrame(BaseObjectType *cobject, const Glib::RefPtr&) : Gtk::AspectFrame(cobject), width(-1) { signal_size_allocate().connect(sigc::mem_fun(this, &AspectFrame::onSizeAllocate)); } diff --git a/src/Gui/RenderArea.cpp b/src/Gui/RenderArea.cpp index 0fcc9ce..8065dc3 100644 --- a/src/Gui/RenderArea.cpp +++ b/src/Gui/RenderArea.cpp @@ -29,7 +29,7 @@ namespace Gui { GdkGLConfig *RenderArea::glconfig = 0; -RenderArea::RenderArea(BaseObjectType *cobject, const Glib::RefPtr&) +RenderArea::RenderArea(BaseObjectType *cobject, const Glib::RefPtr&) : Gtk::DrawingArea(cobject), view(0), inWindow(false) { if(!glconfig) { glconfig = gdk_gl_config_new_by_mode((GdkGLConfigMode)(GDK_GL_MODE_RGB | GDK_GL_MODE_DOUBLE)); diff --git a/src/Gui/RenderArea.h b/src/Gui/RenderArea.h index d42a352..ea3f815 100644 --- a/src/Gui/RenderArea.h +++ b/src/Gui/RenderArea.h @@ -20,9 +20,9 @@ #ifndef ZOOMEDIT_GUI_RENDERAREA_H_ #define ZOOMEDIT_GUI_RENDERAREA_H_ +#include #include #include -#include #include namespace ZoomEdit { @@ -35,7 +35,7 @@ namespace Gui { class RenderArea : public Gtk::DrawingArea { public: - RenderArea(BaseObjectType *cobject, const Glib::RefPtr&); + RenderArea(BaseObjectType *cobject, const Glib::RefPtr&); View::View* getView() const {return view;} void setView(View::View *view0); diff --git a/src/Gui/Window.cpp b/src/Gui/Window.cpp index 6d614fb..dcc8f45 100644 --- a/src/Gui/Window.cpp +++ b/src/Gui/Window.cpp @@ -21,16 +21,22 @@ #include "RenderArea.h" #include "AspectFrame.h" +#include + namespace ZoomEdit { namespace Gui { -Window::Window(BaseObjectType *cobject, const Glib::RefPtr &xml) +Window::Window(BaseObjectType *cobject, const Glib::RefPtr &builder) : Gtk::Window(cobject) { - xml->connect_clicked("MenuItemQuit", sigc::mem_fun(this, &Window::hide)); - xml->get_widget_derived("RenderArea", renderArea); - xml->get_widget_derived("MapArea", mapArea); - xml->get_widget_derived("AspectFrameMap", aspectFrameMap); + Glib::RefPtr itemQuit = Glib::RefPtr::cast_dynamic(builder->get_object("MenuItemQuit")); + if(itemQuit) { + itemQuit->signal_activate().connect(sigc::mem_fun(this, &Window::hide)); + } + + builder->get_widget_derived("RenderArea", renderArea); + builder->get_widget_derived("MapArea", mapArea); + builder->get_widget_derived("AspectFrameMap", aspectFrameMap); } Window::~Window() { diff --git a/src/Gui/Window.h b/src/Gui/Window.h index a0934f5..97ebcda 100644 --- a/src/Gui/Window.h +++ b/src/Gui/Window.h @@ -20,8 +20,8 @@ #ifndef ZOOMEDIT_GUI_WINDOW_H_ #define ZOOMEDIT_GUI_WINDOW_H_ +#include #include -#include namespace ZoomEdit { namespace Gui { @@ -35,7 +35,7 @@ class Window : public Gtk::Window { AspectFrame *aspectFrameMap; public: - Window(BaseObjectType *cobject, const Glib::RefPtr &xml); + Window(BaseObjectType *cobject, const Glib::RefPtr &builder); virtual ~Window(); RenderArea* getRenderArea() const {return renderArea;} diff --git a/src/Instance.cpp b/src/Instance.cpp index 351a6d7..ce0d239 100644 --- a/src/Instance.cpp +++ b/src/Instance.cpp @@ -35,29 +35,17 @@ guint Instance::instances = 0; Instance::Instance(const Glib::ustring &file) : window(0), levelXml(0), level(0), view(0) { instances++; -#ifdef GLIBMM_EXCEPTIONS_ENABLED - try - { - xml = Gnome::Glade::Xml::create("zoomedit.glade"); + try { + builder = Gtk::Builder::create_from_file("zoomedit.ui"); } - catch(const Gnome::Glade::XmlError& ex) - { + catch(const Glib::Exception& ex) { std::cerr << ex.what() << std::endl; return; } -#else - std::auto_ptr error; - xml = Gnome::Glade::Xml::create("zoomedit.glade", "", "", error); - if(error.get()) - { - std::cerr << error->what() << std::endl; - return; - } -#endif - xml->get_widget_derived("WindowMain", window); + builder->get_widget_derived("WindowMain", window); if(!window) { - xml.clear(); + builder.clear(); return; } @@ -70,10 +58,10 @@ Instance::Instance(const Glib::ustring &file) : window(0), levelXml(0), level(0) window->getMapArea()->setView(mapView); Gtk::ToolButton *button; - xml->get_widget("ToolButtonZoomIn", button); + builder->get_widget("ToolButtonZoomIn", button); button->signal_clicked().connect(sigc::bind(sigc::mem_fun(view, &View::TopView::zoom), 2, 0, 0)); - xml->get_widget("ToolButtonZoomOut", button); + builder->get_widget("ToolButtonZoomOut", button); button->signal_clicked().connect(sigc::bind(sigc::mem_fun(view, &View::TopView::zoom), -2, 0, 0)); if(file.empty()) diff --git a/src/Instance.h b/src/Instance.h index 679ccbe..090e2f1 100644 --- a/src/Instance.h +++ b/src/Instance.h @@ -20,8 +20,8 @@ #ifndef ZOOMEDIT_INSTANCE_H_ #define ZOOMEDIT_INSTANCE_H_ +#include #include -#include #include namespace ZoomEdit { @@ -52,7 +52,7 @@ class Instance { private: static guint instances; - Glib::RefPtr xml; + Glib::RefPtr builder; Gui::Window *window; xmlpp::DomParser *levelXml; -- cgit v1.2.3