From 84052f1fabf1a65819afcc449567aad49a7b747b Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Fri, 5 Sep 2008 07:06:46 +0200 Subject: [PATCH] add placeholder gui main to make the compile work --- admin/vgsuppression.c | 5 +- src/gui/gtk-lumiera.cpp | 214 ++++++++++++++++++++++++++++++++++++++++ src/gui/gtk-lumiera.hpp | 163 ++++++++++++++++++++++++++++++ 3 files changed, 378 insertions(+), 4 deletions(-) create mode 100644 src/gui/gtk-lumiera.cpp create mode 100644 src/gui/gtk-lumiera.hpp diff --git a/admin/vgsuppression.c b/admin/vgsuppression.c index cad026e52..514be9ecb 100644 --- a/admin/vgsuppression.c +++ b/admin/vgsuppression.c @@ -23,15 +23,12 @@ just place any problematic calls where valgrind whines about in main (with comments please) */ -#include "lib/safeclib.h" int main () { - /* debian etch glibc is lazy about cleaning up TLS */ - lumiera_tmpbuf_provide (100); - lumiera_tmpbuf_freeall (); + /* dummy placeholder */ return 0; } diff --git a/src/gui/gtk-lumiera.cpp b/src/gui/gtk-lumiera.cpp new file mode 100644 index 000000000..1b7676dd2 --- /dev/null +++ b/src/gui/gtk-lumiera.cpp @@ -0,0 +1,214 @@ +/* + gtk-lumiera.cpp - simple placeholder to make the compile work + +* *****************************************************/ + +#include +#include + +#include + +using namespace Gtk; + + +#ifdef ENABLE_NLS +# include +#endif + +#include +#include +#include +#include +#include + +#include "gtk-lumiera.hpp" + +NOBUG_CPP_DEFINE_FLAG(gui); + +using namespace Gtk; +using namespace Glib; +using namespace sigc; +using namespace lumiera::gui; + +GtkLumiera the_application; + +int +main (int argc, char *argv[]) +{ + return the_application.main(argc, argv); +} + + + +namespace lumiera { +namespace gui { + +int +GtkLumiera::main(int argc, char *argv[]) +{ + NOBUG_INIT; + + Main kit(argc, argv); + + Glib::set_application_name(AppTitle); + + workspace::WorkspaceWindow main_window; + + kit.run(main_window); + + return 23; +} + + +GtkLumiera& +application() +{ + return the_application; +} + + +namespace workspace { + +WorkspaceWindow::WorkspaceWindow() +: actions(*this) +{ + + layout = NULL; + create_ui(); +} + +WorkspaceWindow::~WorkspaceWindow() +{ + REQUIRE(layout != NULL); + g_object_unref(layout); +} + + +void +WorkspaceWindow::create_ui() +{ + //----- Configure the Window -----// + set_title(AppTitle); + set_default_size(1024, 768); + + //----- Set up the UI Manager -----// + // The UI will be nested within a VBox + add(baseContainer); + + uiManager = Gtk::UIManager::create(); + uiManager->insert_action_group(actions.actionGroup); + + //Layout the actions in a menubar and toolbar: + Glib::ustring ui_info = + "" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + ""; + + try + { + uiManager->add_ui_from_string(ui_info); + } + catch(const Glib::Error& ex) + { + ERROR(gui, "Building menus failed: %s", ex.what().data()); + return; + } + + //----- Set up the Menu Bar -----// + Gtk::Widget* menu_bar = uiManager->get_widget("/MenuBar"); + ASSERT(menu_bar != NULL); + baseContainer.pack_start(*menu_bar, Gtk::PACK_SHRINK); + + //----- Set up the Tool Bar -----// + Gtk::Toolbar* toolbar = dynamic_cast( + uiManager->get_widget("/ToolBar")); + ASSERT(toolbar != NULL); + toolbar->set_toolbar_style(TOOLBAR_ICONS); + baseContainer.pack_start(*toolbar, Gtk::PACK_SHRINK); + + + //----- Create the Dock -----// + dock = Glib::wrap(gdl_dock_new()); + layout = gdl_dock_layout_new((GdlDock*)dock->gobj()); + + dockbar = Glib::wrap(gdl_dock_bar_new ((GdlDock*)dock->gobj())); + + dockContainer.pack_start(*dockbar, PACK_SHRINK); + dockContainer.pack_end(*dock, PACK_EXPAND_WIDGET); + baseContainer.pack_start(dockContainer, PACK_EXPAND_WIDGET); + + //----- Create the status bar -----// + statusBar.set_has_resize_grip(); + baseContainer.pack_start(statusBar, PACK_SHRINK); + + show_all_children(); + + +} + + + /* -- Actions -- */ + + +Actions::Actions(WorkspaceWindow &workspace_window) : + workspaceWindow(workspace_window), + is_updating_action_state(false) +{ + workspace_window.signal_show ().connect_notify(mem_fun(this, &Actions::update_action_state)); + + //----- Create the Action Group -----// + actionGroup = ActionGroup::create(); + + // File menu + actionGroup->add(Action::create("FileMenu", _("_File"))); + actionGroup->add(Action::create("FileQuit", Stock::QUIT), + sigc::mem_fun(*this, &Actions::on_menu_file_quit)); + + // Help Menu + actionGroup->add(Action::create("HelpMenu", _("_Help")) ); + actionGroup->add(Action::create("HelpAbout", _("say hello...")), + sigc::mem_fun(*this, &Actions::on_menu_help_about) ); +} + +void +Actions::update_action_state() +{ + is_updating_action_state = true; + is_updating_action_state = false; +} + +/* ===== File Menu Event Handlers ===== */ + +void +Actions::on_menu_file_quit() +{ + workspaceWindow.hide(); // Closes the main window to stop the Gtk::Main::run(). +} + +/* ===== Help Menu Event Handlers ===== */ + +void +Actions::on_menu_help_about() +{ + g_message("Hello Lumi World"); +} + + + +} // namespace workspace + + + +} // namespace gui +} // namespace lumiera + + diff --git a/src/gui/gtk-lumiera.hpp b/src/gui/gtk-lumiera.hpp new file mode 100644 index 000000000..3a20b7731 --- /dev/null +++ b/src/gui/gtk-lumiera.hpp @@ -0,0 +1,163 @@ +/* + gtk-lumiera.cpp - simple placeholder to make the compile work + +* *****************************************************/ + + +#ifndef GTK_LUMIERA_HPP +#define GTK_LUMIERA_HPP + +#include +#include +#include + +#include + +extern "C" { +#include +} + +NOBUG_DECLARE_FLAG(gui); + +#ifdef ENABLE_NLS +# include +# define _(String) gettext (String) +# define gettext_noop(String) String +# define N_(String) gettext_noop (String) +#else +# define _(String) (String) +# define N_(String) String +# define textdomain(Domain) +# define bindtextdomain(Package, Directory) +#endif + +namespace lumiera { + +/** + * The namespace of all GUI code. + */ +namespace gui { + +/* ===== Global Constants ===== */ + +/** + * The name of the application + */ +static const gchar* AppTitle = "Lumiera"; + + + +/* ===== The Application Class ===== */ + +/** + * The main application class. + */ +class GtkLumiera +{ +public: + int main(int argc, char *argv[]); + + +}; + +/** + * Returns a reference to the global application object + */ +GtkLumiera& application(); + + + +namespace workspace { + +class WorkspaceWindow; + +/** +* A helper class which registers and handles +* user action events. +*/ +class Actions +{ +private: + Actions(WorkspaceWindow &workspace_window); + + /* ===== Internals ===== */ +private: + /** + * Updates the state of the menu/toolbar actions + * to reflect the current state of the workspace */ + void update_action_state(); + + /** A reference to the MainWindow */ + WorkspaceWindow &workspaceWindow; + + /* ===== Event Handlers ===== */ +private: + void on_menu_file_quit(); + void on_menu_help_about(); + + // Temporary Junk + void on_menu_others(); + + + /* ===== Actions ===== */ +private: + Glib::RefPtr actionGroup; + + /* ===== Internals ===== */ +private: + bool is_updating_action_state; + + friend class WorkspaceWindow; +}; + + + +/** +* A Mock main window +*/ +class WorkspaceWindow : public Gtk::Window +{ +public: + WorkspaceWindow(); + + ~WorkspaceWindow(); + +private: + void create_ui(); + + + /* ===== UI ===== */ +private: + Glib::RefPtr uiManager; + Gtk::VBox baseContainer; + Gtk::HBox dockContainer; + + //----- Dock Frame -----// + Gtk::Widget *dock; + Gtk::Widget *dockbar; + GdlDockLayout *layout; + + //----- Status Bar -----// + Gtk::Statusbar statusBar; + + /** instance of the actions helper class, which + * registers and handles user action events */ + Actions actions; + + friend class Actions; + +}; + + + + + +} // namespace workspace + + +} // namespace gui +} // namespace lumiera + +#endif // GTK_LUMIERA_HPP + +