add placeholder gui main to make the compile work

This commit is contained in:
Fischlurch 2008-09-05 07:06:46 +02:00
parent f2c9e67fbc
commit 84052f1fab
3 changed files with 378 additions and 4 deletions

View file

@ -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;
}

214
src/gui/gtk-lumiera.cpp Normal file
View file

@ -0,0 +1,214 @@
/*
gtk-lumiera.cpp - simple placeholder to make the compile work
* *****************************************************/
#include <gtkmm.h>
#include <nobug.h>
#include <gtkmm/stock.h>
using namespace Gtk;
#ifdef ENABLE_NLS
# include <libintl.h>
#endif
#include <libgdl-1.0/gdl/gdl-tools.h>
#include <libgdl-1.0/gdl/gdl-dock.h>
#include <libgdl-1.0/gdl/gdl-dock-item.h>
#include <libgdl-1.0/gdl/gdl-dock-placeholder.h>
#include <libgdl-1.0/gdl/gdl-dock-bar.h>
#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 =
"<ui>"
" <menubar name='MenuBar'>"
" <menu action='FileMenu'>"
" <menuitem action='FileQuit'/>"
" </menu>"
" <menu action='HelpMenu'>"
" <menuitem action='HelpAbout'/>"
" </menu>"
" </menubar>"
" <toolbar name='ToolBar'>"
" </toolbar>"
"</ui>";
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<Gtk::Toolbar*>(
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

163
src/gui/gtk-lumiera.hpp Normal file
View file

@ -0,0 +1,163 @@
/*
gtk-lumiera.cpp - simple placeholder to make the compile work
* *****************************************************/
#ifndef GTK_LUMIERA_HPP
#define GTK_LUMIERA_HPP
#include <gtkmm.h>
#include <nobug.h>
#include <vector>
#include <libgdl-1.0/gdl/gdl-dock-layout.h>
extern "C" {
#include <gavl/gavltime.h>
}
NOBUG_DECLARE_FLAG(gui);
#ifdef ENABLE_NLS
# include <libintl.h>
# 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<Gtk::ActionGroup> 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<Gtk::UIManager> 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