Gui: rework resource loading to make the application fully relocatable

This commit is contained in:
Fischlurch 2011-02-07 00:54:16 +01:00
parent 87c70d0b1f
commit 65d28b4018
15 changed files with 281 additions and 210 deletions

View file

@ -42,7 +42,7 @@ srcConf = 'data/config'
buildExe = '#$TARGDIR' buildExe = '#$TARGDIR'
buildLib = '#$TARGDIR/modules' buildLib = '#$TARGDIR/modules'
buildPlug = '#$TARGDIR/modules' buildPlug = '#$TARGDIR/modules'
buildIcon = '#$TARGDIR/icons' buildIcon = '#$TARGDIR/gui/icons'
buildUIRes = '#$TARGDIR/' buildUIRes = '#$TARGDIR/'
buildConf = '#$TARGDIR/config' buildConf = '#$TARGDIR/config'
installExe = '#$DESTDIR/lib/lumiera' installExe = '#$DESTDIR/lib/lumiera'

View file

@ -11,4 +11,12 @@
gui = gtk_gui.lum gui = gtk_gui.lum
modulepath = $ORIGIN/modules modulepath = $ORIGIN/modules
configpath = /usr/share/lumiera/config:~/.lumiera configpath = /usr/share/lumiera/config:~/.lumiera
title = Lumiera
version = 0.pre.01 version = 0.pre.01
website = http://www.lumiera.org
authors = Joel Holdsworth|Christian Thäter|Hermann Voßeler|[Other Authors Here]
[Gui]
stylesheet = lumiera_ui.rc
iconpath = $ORIGIN/../../share/lumiera/icons:$ORIGIN/gui/icons:~/.lumiera/icons
resourcepath = $ORIGIN/../../share/lumiera/gui:$ORIGIN/gui

View file

@ -83,15 +83,27 @@ namespace lumiera {
"search path for extended configuration. " "search path for extended configuration. "
"Extended Config system not yet implemented " "Extended Config system not yet implemented "
"Ignored as of 2/2011") "Ignored as of 2/2011")
("Lumiera.title", opt::value<string>(),
"title of the Lumiera Application, e.g. for windows")
("Lumiera.version", opt::value<string>(), ("Lumiera.version", opt::value<string>(),
"Application version string") "Application version string")
("Lumiera.website", opt::value<string>(),
"URL of the Lumiera website")
("Lumiera.authors", opt::value<string>(),
"names of Lumiera authors, for 'about' dialog. Separated by '|'")
("Gui.stylesheet", opt::value<string>(),
"name of the GTK stylesheet to use. Will be searched in resource path")
("Gui.iconpath", opt::value<string>(),
"search path for icons")
("Gui.resourcepath", opt::value<string>(),
"general search path for UI resources")
; ;
ifstream configIn (resolve(bootstrapIni).c_str()); ifstream configIn (resolve(bootstrapIni).c_str());
opt::parsed_options parsed = opt::parsed_options parsed = opt::parse_config_file (configIn, syntax);
opt::parse_config_file (configIn, syntax);
opt::store (parsed, settings); opt::store (parsed, settings);
opt::notify(settings); opt::notify(settings);

View file

@ -132,7 +132,7 @@ extern "C" { /* ==== implementation C interface for accessing setup.ini =======
// fetch plugin search path from setup.ini and expand any $ORIGIN token // fetch plugin search path from setup.ini and expand any $ORIGIN token
SearchPathSplitter pathElement(Config::get (KEY_PLUGIN_PATH)); SearchPathSplitter pathElement(Config::get (KEY_PLUGIN_PATH));
while (pathElement) while (pathElement)
pathSpec += pathElement.fetch() +":"; pathSpec += pathElement.next() +":";
} }
return cStr(pathSpec); return cStr(pathSpec);

View file

@ -27,21 +27,45 @@
#include "gui/controller/controller.hpp" #include "gui/controller/controller.hpp"
#include "gui/model/project.hpp" #include "gui/model/project.hpp"
#include "lib/singleton.hpp" #include "lib/singleton.hpp"
#include "lib/symbol.hpp"
#include "include/config-facade.h"
using namespace Gtk; #include <boost/algorithm/string/classification.hpp>
using namespace Glib; #include <boost/algorithm/string/split.hpp>
using namespace gui; #include <vector>
using namespace gui::workspace;
using namespace gui::model;
using namespace gui::controller;
using namespace std;
namespace gui { namespace gui {
using namespace Gtk;
using namespace Glib;
using namespace gui::model;
using namespace gui::workspace;
using namespace gui::controller;
using boost::algorithm::is_any_of;
using boost::algorithm::split;
using lumiera::Config;
using lib::Literal;
typedef std::vector<uString> UVector;
namespace { namespace {
/** storage for the Main Application object */ /** storage for the Main Application object */
lib::Singleton<GtkLumiera> theApplicationInstance; lib::Singleton<GtkLumiera> theApplicationInstance;
Literal KEY_TITLE = "Lumiera.title";
Literal KEY_VERSION = "Lumiera.version";
Literal KEY_WEBSITE = "Lumiera.website";
Literal KEY_AUTHORS = "Lumiera.authors";
Literal KEY_STYLESHEET = "Gui.stylesheet";
Literal KEY_UIRES_PATH = "Gui.resourcepath";
Literal KEY_ICON_PATH = "Gui.iconpath";
} }
@ -62,68 +86,63 @@ GtkLumiera::main (int argc, char *argv[])
Main kit(argc, argv); Main kit(argc, argv);
Glib::set_application_name (get_app_title()); Glib::set_application_name (getAppTitle());
Project project; Project project;
Controller controller(project); Controller controller(project);
windowManagerInstance_.init(); windowManagerInstance_.init (Config::get (KEY_ICON_PATH), Config::get (KEY_UIRES_PATH));
windowManagerInstance_.set_theme ("lumiera_ui.rc"); windowManagerInstance_.setTheme (Config::get (KEY_STYLESHEET));
windowManagerInstance_.new_window (project, controller);
kit.run(); windowManagerInstance_.newWindow (project, controller);
kit.run(); // GTK event loop
} }
WindowManager& WindowManager&
GtkLumiera::windowManager() GtkLumiera::windowManager()
{ {
return windowManagerInstance_; return windowManagerInstance_;
} }
Glib::ustring
GtkLumiera::get_home_data_path() cuString
GtkLumiera::getAppTitle()
{ {
const ustring app_name("lumiera"); return Config::get (KEY_TITLE);
const ustring path(Glib::get_home_dir());
return ustring::compose("%1/.%2", path, app_name);
} }
const Glib::ustring
GtkLumiera::get_app_title() cuString
GtkLumiera::getAppVersion()
{ {
return "Lumiera"; return Config::get (KEY_VERSION);
} }
const Glib::ustring
GtkLumiera::get_app_version() cuString
GtkLumiera::getCopyright()
{ {
return "0.pre.01"; return _("© 2012 The Lumiera Team");
} }
const Glib::ustring GtkLumiera::get_app_copyright()
cuString
GtkLumiera::getLumieraWebsite()
{ {
return _("© 2008 The Lumiera Team"); return Config::get (KEY_WEBSITE);
} }
const Glib::ustring GtkLumiera::get_app_website()
{
return "http://www.lumiera.org";
}
const std::vector<Glib::ustring> const UVector
GtkLumiera::get_app_authors() GtkLumiera::getLumieraAuthors()
{ {
const gchar* app_authors[] = { string authors = Config::get (KEY_AUTHORS);
"Joel Holdsworth", UVector authorsList;
"Christian Thaeter",
"Hermann Vosseler",
"[Other Authors Here]"};
const int count = sizeof(app_authors) / sizeof(gchar*); split (authorsList, authors, is_any_of (",|"));
std::vector<Glib::ustring> list(count); return authorsList;
for(int i = 0; i < count; i++)
list[i] = app_authors[i];
return list;
} }

View file

@ -19,10 +19,32 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/** @file gtk-lumiera.hpp /** @file gtk-lumiera.hpp
** This file contains application wide global definitions ** The main application object.
** user actions. ** Invoking the GtkLumiera::main() function brings up the GUI; this
** @see gtk-lumiera.cpp ** function will block in the GTK event thread until the Application gets
** closed by user interaction or by triggering a shutdown via the GuiNotificationFacade.
** GtkLumiera is a singleton and owns the central WindowManager instance used for
** opening all windows and registering and loading icons and resources.
**
** \par configuration and resource search
** The GUI object retrieves the necessary configuration values from lumiera::Config,
** the config facade in the application core. Currently as of 2/2011 these values are
** loaded from setup.ini, because the full-blown config system is not yet implemented.
** Amongst others, this configuration defines a <i>search path</i> for icons and a
** separate search path for resources. These path specs may use the token \c $ORIGIN
** to refer to the installation directory of the currently executing program.
** This allows for a relocatable Lumiera installation bundle.
**
** @see guistart.cpp the plugin to pull up this GUI
** @see gui::GuiFacade access point for starting the GUI
** @see gui::GuiNotification interface for communication with the gui from the lower layers
** @see lumiera::Config
** @see lumiera::BasicSetup definition of the acceptable configuration values
** @see lumiera::AppState general Lumiera application main
**
*/ */
#ifndef GUI_GTK_LUMIERA_H #ifndef GUI_GTK_LUMIERA_H

View file

@ -24,6 +24,12 @@
#include "gui/window-manager.hpp" #include "gui/window-manager.hpp"
#include "gui/gtk-lumiera.hpp" #include "gui/gtk-lumiera.hpp"
#include "gui/workspace/workspace-window.hpp" #include "gui/workspace/workspace-window.hpp"
#include "lib/searchpath.hpp"
#include "lib/util.hpp"
#include <boost/filesystem.hpp>
using util::cStr;
using namespace Gtk; using namespace Gtk;
using namespace Glib; using namespace Glib;
@ -31,21 +37,37 @@ using namespace boost;
using namespace std; using namespace std;
using namespace gui::workspace; using namespace gui::workspace;
namespace fsys = boost::filesystem;
namespace gui { namespace gui {
IconSize WindowManager::GiantIconSize = ICON_SIZE_INVALID; IconSize WindowManager::GiantIconSize = ICON_SIZE_INVALID;
IconSize WindowManager::MenuIconSize = ICON_SIZE_INVALID; IconSize WindowManager::MenuIconSize = ICON_SIZE_INVALID;
void void
WindowManager::init() WindowManager::init (string const& iconPath, string const& resourcePath)
{ {
this->iconSearchPath_ = iconPath;
this->resourceSerachPath_ = resourcePath;
register_app_icon_sizes(); register_app_icon_sizes();
register_stock_items(); register_stock_items();
} }
void void
WindowManager::new_window(gui::model::Project &source_project, WindowManager::setTheme (string const& stylesheetName)
gui::controller::Controller &source_controller) {
gtk_rc_parse (cStr(lib::resolveModulePath (stylesheetName, resourceSerachPath_)));
gtk_rc_reset_styles (gtk_settings_get_default());
}
void
WindowManager::newWindow (gui::model::Project& source_project,
gui::controller::Controller &source_controller)
{ {
shared_ptr<WorkspaceWindow> window( shared_ptr<WorkspaceWindow> window(
new WorkspaceWindow(source_project, source_controller)); new WorkspaceWindow(source_project, source_controller));
@ -61,25 +83,9 @@ WindowManager::new_window(gui::model::Project &source_project,
update_close_window_in_menus(); update_close_window_in_menus();
} }
bool
WindowManager::set_theme(Glib::ustring path)
{
if(access(path.c_str(), R_OK))
{
// gdk defines 'ERROR' need to prefix it with 'NOBUG_' here
NOBUG_ERROR(gui, "WindowManger: Unable to load rc file \"%s\"",
path.c_str());
return false;
}
gtk_rc_parse(path.c_str());
gtk_rc_reset_styles (gtk_settings_get_default());
return true;
}
bool bool
WindowManager::on_window_closed(GdkEventAny* event) WindowManager::on_window_closed (GdkEventAny* event)
{ {
REQUIRE(event); REQUIRE(event);
REQUIRE(event->window); REQUIRE(event->window);
@ -87,7 +93,7 @@ WindowManager::on_window_closed(GdkEventAny* event)
list< shared_ptr<WorkspaceWindow> >::iterator iterator = list< shared_ptr<WorkspaceWindow> >::iterator iterator =
windowList.begin(); windowList.begin();
while(iterator != windowList.end()) while (iterator != windowList.end())
{ {
shared_ptr<WorkspaceWindow> workspace_window(*iterator); shared_ptr<WorkspaceWindow> workspace_window(*iterator);
REQUIRE(workspace_window); REQUIRE(workspace_window);
@ -103,7 +109,7 @@ WindowManager::on_window_closed(GdkEventAny* event)
iterator++; iterator++;
} }
if(windowList.empty()) if (windowList.empty())
{ {
// All windows have been closed - we should exit // All windows have been closed - we should exit
Main *main = Main::instance(); Main *main = Main::instance();
@ -117,6 +123,7 @@ WindowManager::on_window_closed(GdkEventAny* event)
return false; return false;
} }
void void
WindowManager::update_close_window_in_menus() WindowManager::update_close_window_in_menus()
{ {
@ -135,10 +142,11 @@ WindowManager::update_close_window_in_menus()
} }
} }
Cairo::RefPtr<Cairo::SolidPattern> Cairo::RefPtr<Cairo::SolidPattern>
WindowManager::read_style_colour_property ( WindowManager::read_style_colour_property (Gtk::Widget& widget,
Gtk::Widget &widget, const gchar *property_name, const gchar *property_name,
guint16 red, guint16 green, guint16 blue) guint16 red, guint16 green, guint16 blue)
{ {
REQUIRE (property_name); REQUIRE (property_name);
@ -164,6 +172,7 @@ WindowManager::read_style_colour_property (
return pattern; return pattern;
} }
void void
WindowManager::register_app_icon_sizes() WindowManager::register_app_icon_sizes()
{ {
@ -173,34 +182,35 @@ WindowManager::register_app_icon_sizes()
MenuIconSize = IconSize::register_new ("menu", 16, 16); MenuIconSize = IconSize::register_new ("menu", 16, 16);
} }
void void
WindowManager::register_stock_items() WindowManager::register_stock_items()
{ {
Glib::RefPtr<IconFactory> factory = IconFactory::create(); Glib::RefPtr<IconFactory> factory = IconFactory::create();
add_stock_icon_set(factory, "panel-assets", "panel_assets", _("_Assets")); add_stock_icon_set(factory, "panel-assets", "panel_assets", _("_Assets"));
add_stock_icon_set(factory, "panel-timeline", "panel_timeline", _("_Timeline")); add_stock_icon_set(factory, "panel-timeline", "panel_timeline",_("_Timeline"));
add_stock_icon_set(factory, "panel-viewer", "panel_viewer", _("_Viewer")); add_stock_icon_set(factory, "panel-viewer", "panel_viewer", _("_Viewer"));
add_stock_icon_set(factory, "window-new", "new_window", _("New _Window")); add_stock_icon_set(factory, "window-new", "new_window", _("New _Window"));
add_stock_icon_set(factory, "tool-arrow", "tool_arrow", _("_Arrow")); add_stock_icon_set(factory, "tool-arrow", "tool_arrow", _("_Arrow"));
add_stock_icon_set(factory, "tool-i-beam", "tool_i_beam", _("_I-Beam")); add_stock_icon_set(factory, "tool-i-beam", "tool_i_beam", _("_I-Beam"));
add_stock_icon_set(factory, "track-disabled", "track_disabled", _("Track Disabled")); add_stock_icon_set(factory, "track-disabled", "track_disabled",_("Track Disabled"));
add_stock_icon_set(factory, "track-enabled", "track_enabled", _("Track Enabled")); add_stock_icon_set(factory, "track-enabled", "track_enabled", _("Track Enabled"));
add_stock_icon_set(factory, "track-locked", "track_locked", _("Track Locked")); add_stock_icon_set(factory, "track-locked", "track_locked", _("Track Locked"));
add_stock_icon_set(factory, "track-unlocked", "track_unlocked", _("Track Unlocked")); add_stock_icon_set(factory, "track-unlocked", "track_unlocked",_("Track Unlocked"));
factory->add_default(); //Add factory to list of factories. factory->add_default(); //Add factory to list of factories.
} }
bool bool
WindowManager::add_stock_icon_set( WindowManager::add_stock_icon_set (Glib::RefPtr<IconFactory> const& factory,
const Glib::RefPtr<IconFactory>& factory, cuString& icon_name,
const Glib::ustring& icon_name, cuString& id,
const Glib::ustring& id, cuString& label)
const Glib::ustring& label)
{ {
Gtk::IconSet icon_set; Gtk::IconSet icon_set;
@ -221,7 +231,7 @@ WindowManager::add_stock_icon_set(
if(no_icons) if(no_icons)
{ {
// No icons were loaded // No icons were loaded
ERROR(gui, "Unable to load icon \"%s\"", icon_name.c_str()); ERROR (gui, "Unable to load icon '%s'", cStr(icon_name));
return false; return false;
} }
@ -232,31 +242,36 @@ WindowManager::add_stock_icon_set(
return true; return true;
} }
bool bool
WindowManager::add_stock_icon(Gtk::IconSet &icon_set, WindowManager::add_stock_icon (Gtk::IconSet &icon_set,
const Glib::ustring& icon_name, Gtk::IconSize size, bool wildcard) cuString& icon_name,
Gtk::IconSize size,
bool wildcard)
{ {
// Try the icon theme // Try the icon theme
if(add_theme_icon_source(icon_set, icon_name, size, wildcard)) if(add_theme_icon_source(icon_set, icon_name, size, wildcard))
return true; return true;
// Try the ~/.lumiera/icons folder
if(add_non_theme_icon_source(icon_set, ustring::compose("%1/%2",
GtkLumiera::get_home_data_path(), ustring("icons")),
icon_name, size, wildcard))
return true;
// Try the local directory // Try to resolve the icon via the configured search path
if(add_non_theme_icon_source( lib::SearchPathSplitter iconLocations (iconSearchPath_);
icon_set, get_current_dir(), icon_name, size, wildcard)) while (iconLocations)
return true; if (add_non_theme_icon_source (icon_set
,iconLocations.next()
return false; ,icon_name
,size
,wildcard))
return true;
return false; // icon not found
} }
bool bool
WindowManager::add_theme_icon_source(Gtk::IconSet &icon_set, WindowManager::add_theme_icon_source (Gtk::IconSet &icon_set,
const Glib::ustring& icon_name, Gtk::IconSize size, bool wildcard) cuString& icon_name,
Gtk::IconSize size,
bool wildcard)
{ {
// Get the size // Get the size
int width = 0, height = 0; int width = 0, height = 0;
@ -269,22 +284,19 @@ WindowManager::add_theme_icon_source(Gtk::IconSet &icon_set,
REQUIRE(theme); REQUIRE(theme);
TODO ("find out how IconInfo could be made const. For example, GTKmm 2.10.10 is missing the const on operator bool() in iconinfo.h"); TODO ("find out how IconInfo could be made const. For example, GTKmm 2.10.10 is missing the const on operator bool() in iconinfo.h");
IconInfo info = theme->lookup_icon(icon_name, width, IconInfo info = theme->lookup_icon(icon_name, width, (IconLookupFlags)0);
(IconLookupFlags)0);
if(info) if (!info) return false; // unable to resolve Icon
{
const ustring path(info.get_filename()); cuString path(info.get_filename());
if(add_stock_icon_from_path(path, icon_set, size, wildcard)) return add_stock_icon_from_path(path, icon_set, size, wildcard);
return true;
}
return false;
} }
bool bool
WindowManager::add_non_theme_icon_source(Gtk::IconSet &icon_set, WindowManager::add_non_theme_icon_source (Gtk::IconSet &icon_set,
const Glib::ustring& base_dir, const Glib::ustring& icon_name, cuString& base_dir, cuString& icon_name,
Gtk::IconSize size, bool wildcard) Gtk::IconSize size, bool wildcard)
{ {
// Get the size // Get the size
int width = 0, height = 0; int width = 0, height = 0;
@ -293,33 +305,37 @@ WindowManager::add_non_theme_icon_source(Gtk::IconSet &icon_set,
REQUIRE(width > 0); REQUIRE(width > 0);
// Try to load the icon // Try to load the icon
const ustring path(ustring::compose("%1/%2x%3/%4.png", cuString path(ustring::compose("%1/%2x%3/%4.png",
base_dir, width, height, icon_name)); base_dir, width, height, icon_name));
return add_stock_icon_from_path(path, icon_set, size, wildcard); return add_stock_icon_from_path(path, icon_set, size, wildcard);
} }
bool bool
WindowManager::add_stock_icon_from_path(Glib::ustring path, WindowManager::add_stock_icon_from_path (string path,
Gtk::IconSet &icon_set, Gtk::IconSize size, bool wildcard) Gtk::IconSet &icon_set,
Gtk::IconSize size,
bool wildcard)
{ {
Gtk::IconSource source; if (!fsys::exists (path)) return false;
try try {
{ Gtk::IconSource source;
// This throws an exception if the file is not found:
source.set_pixbuf(Gdk::Pixbuf::create_from_file(path)); source.set_pixbuf(Gdk::Pixbuf::create_from_file(path));
source.set_size_wildcarded(wildcard);
source.set_size(size);
icon_set.add_source(source);
return true;
} }
catch(const Glib::Exception& ex)
catch(Glib::Exception const& ex)
{ {
WARN (gui, "Failure when accessing icon '%s'. Problem: %s", cStr(path), cStr(ex.what()));
return false; return false;
} }
source.set_size(size);
source.set_size_wildcarded(wildcard);
icon_set.add_source(source);
return true;
} }
} // namespace gui } // namespace gui

View file

@ -41,51 +41,55 @@
#include <boost/noncopyable.hpp> #include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <cairomm/cairomm.h> #include <cairomm/cairomm.h>
#include <string>
namespace gui { namespace gui {
using std::string;
namespace model {
class Project;
} // model
namespace controller { namespace model { class Project; }
class Controller; namespace controller { class Controller; }
} // model namespace workspace { class WorkspaceWindow;}
namespace workspace {
class WorkspaceWindow;
}
/** /**
* The centralised manager of all lumiera-gui's windows. * The centralised manager of all the windows,
* icons and resources within Lumiera's GUI.
*/ */
class WindowManager class WindowManager
: boost::noncopyable : boost::noncopyable
{ {
string iconSearchPath_;
string resourceSerachPath_;
public: public:
/** /**
* Initialise the window manager on application start. * Initialise the window manager on application start.
* Register the icon configuration and sizes. * Register the icon configuration and sizes and lookup
* all the icons -- either from the default theme of via
* the given Lumiera icon search paths (see \c setup.ini ).
* @see lumiera::Config
*/ */
void init(); void init (string const& iconPath, string const& resourcePath);
/** /**
* Creates a new window connected to a specified project and * Creates a new window connected to a specified project and controller
* controller
* @param source_project The project to connect the window to. * @param source_project The project to connect the window to.
* @param source_controller The controller to connect the window to. * @param source_controller The controller to connect the window to.
*/ */
void new_window(gui::model::Project &source_project, void newWindow (gui::model::Project&, gui::controller::Controller&);
gui::controller::Controller &source_controller);
/** /**
* Sets the theme of the lumiera-gui's. * Sets the theme to use for the Lumiera GUI.
* @param path This string must specify a path where a GTK stylesheet * @param stylesheetName GTK stylesheet to load from the resourceSearchPath_
* will be found. * @throw error::Config if this stylesheet can't be resolved on the searchpath
* @see #init
* @see lumiera::Config
*/ */
bool set_theme(Glib::ustring path); void setTheme (string const& stylesheetName);
/** /**
* A utility function which reads a colour style from the GTK Style. * A utility function which reads a colour style from the GTK Style.
@ -102,9 +106,7 @@ public:
private: private:
/** /** Event handler for when a window has been closed */
* An event handler for when a window has been closed.
*/
bool on_window_closed(GdkEventAny* event); bool on_window_closed(GdkEventAny* event);
private: private:
@ -134,14 +136,14 @@ private:
* @param icon_name The file name of the icon to add. * @param icon_name The file name of the icon to add.
* @param id The id name of the icon. * @param id The id name of the icon.
* @param label The user readable icon name for this icon. * @param label The user readable icon name for this icon.
* @return Returns true if the icon was successfully loaded, returns * @return \c true if the icon was successfully loaded,
* false otherwise. * returns \c false otherwise.
*/ */
bool add_stock_icon_set( bool add_stock_icon_set(
const Glib::RefPtr<Gtk::IconFactory>& factory, const Glib::RefPtr<Gtk::IconFactory>& factory,
const Glib::ustring& icon_name, cuString& icon_name,
const Glib::ustring& id, cuString& id,
const Glib::ustring& label); cuString& label);
/** /**
* Loads an icon, searching standard icon locations, * Loads an icon, searching standard icon locations,
@ -149,24 +151,22 @@ private:
* @param icon_set The icon set to add the icon to. * @param icon_set The icon set to add the icon to.
* @param icon_name The file name of the icon to load. * @param icon_name The file name of the icon to load.
* @param size The size of the icon to load. * @param size The size of the icon to load.
* @param wildcard This value is set to true if this icon is * @param wildcard \c true if this icon is to be wildcarded.
* wildcarded. * @return \c true if the icon was loaded successfully.
* @return Returns true if the icon was loaded successfully.
*/ */
bool add_stock_icon(Gtk::IconSet &icon_set, bool add_stock_icon(Gtk::IconSet &icon_set,
const Glib::ustring& icon_name, Gtk::IconSize size, bool wildcard); cuString& icon_name, Gtk::IconSize size, bool wildcard);
/** /**
* Loads an icon from a the icon theme * Loads an icon from a the icon theme
* @param icon_set The icon set to add the icon to. * @param icon_set The icon set to add the icon to.
* @param icon_name The name of the icon to load. * @param icon_name The name of the icon to load.
* @param size The size of the icon to load. * @param size The size of the icon to load.
* @param wildcard This value is set to true if this icon is * @param wildcard \c true if this icon is to be wildcarded.
* wildcarded. * @return \c true if the icon was loaded successfully.
* @return Returns true if the icon was loaded successfully.
*/ */
bool add_theme_icon_source(Gtk::IconSet &icon_set, bool add_theme_icon_source(Gtk::IconSet &icon_set,
const Glib::ustring& icon_name, Gtk::IconSize size, bool wildcard); cuString& icon_name, Gtk::IconSize size, bool wildcard);
/** /**
* Loads an icon from a non theme set. * Loads an icon from a non theme set.
@ -174,12 +174,11 @@ private:
* @param base_dir The root icons directory to load from. * @param base_dir The root icons directory to load from.
* @param icon_name The file name of the icon to load. * @param icon_name The file name of the icon to load.
* @param size The size of the icon to load. * @param size The size of the icon to load.
* @param wildcard This value is set to true if this icon is * @param wildcard \c true if this icon is to be wildcarded.
* wildcarded. * @return \c true if the icon was loaded successfully.
* @return Returns true if the icon was loaded successfully.
*/ */
bool add_non_theme_icon_source(Gtk::IconSet &icon_set, bool add_non_theme_icon_source(Gtk::IconSet &icon_set,
const Glib::ustring& base_dir, const Glib::ustring& icon_name, cuString& base_dir, cuString& icon_name,
Gtk::IconSize size, bool wildcard); Gtk::IconSize size, bool wildcard);
/** /**
@ -187,13 +186,13 @@ private:
* @param path The path to load from. * @param path The path to load from.
* @param icon_set The icon set to add the icon to. * @param icon_set The icon set to add the icon to.
* @param size The size of the icon to load. * @param size The size of the icon to load.
* @param wildcard This value is set to true if this icon is * @param wildcard \c true if this icon is to be wildcarded.
* wildcarded. * @return \c true if the icon was loaded successfully.
* @return Returns true if the icon was loaded successfully.
*/ */
bool add_stock_icon_from_path(Glib::ustring path, bool add_stock_icon_from_path(string path,
Gtk::IconSet &icon_set, Gtk::IconSize size, bool wildcard); Gtk::IconSet &icon_set, Gtk::IconSize size, bool wildcard);
private: private:
std::list< boost::shared_ptr<workspace::WorkspaceWindow> > windowList; std::list< boost::shared_ptr<workspace::WorkspaceWindow> > windowList;

View file

@ -58,13 +58,13 @@ Actions::populate_main_actions(Glib::RefPtr<Gtk::UIManager> uiManager)
// File menu // File menu
actionGroup->add(Action::create("FileMenu", _("_File"))); actionGroup->add(Action::create("FileMenu", _("_File")));
actionGroup->add(Action::create("FileNewProject", Stock::NEW, _("_New Project...")), actionGroup->add(Action::create("FileNewProject", Stock::NEW, _("_New Project...")),
mem_fun(*this, &Actions::on_menu_file_new_project)); mem_fun(*this, &Actions::on_menu_file_new_project));
actionGroup->add(Action::create("FileOpenProject", Stock::OPEN, _("_Open Project...")), actionGroup->add(Action::create("FileOpenProject", Stock::OPEN, _("_Open Project...")),
mem_fun(*this, &Actions::on_menu_file_open_project)); mem_fun(*this, &Actions::on_menu_file_open_project));
actionGroup->add(Action::create("FileSaveProject", Stock::SAVE, _("_Save Project")), actionGroup->add(Action::create("FileSaveProject", Stock::SAVE, _("_Save Project")),
mem_fun(*this, &Actions::on_menu_others)); mem_fun(*this, &Actions::on_menu_others));
actionGroup->add(Action::create("FileSaveProjectAs", Stock::SAVE_AS, _("_Save Project As...")), actionGroup->add(Action::create("FileSaveProjectAs",Stock::SAVE_AS, _("_Save Project As...")),
mem_fun(*this, &Actions::on_menu_others)); mem_fun(*this, &Actions::on_menu_others));
actionGroup->add(Action::create("FileRender", _("_Render...")), actionGroup->add(Action::create("FileRender", _("_Render...")),
AccelKey("<shift>R"), AccelKey("<shift>R"),
@ -78,11 +78,11 @@ Actions::populate_main_actions(Glib::RefPtr<Gtk::UIManager> uiManager)
mem_fun(*this, &Actions::on_menu_others)); mem_fun(*this, &Actions::on_menu_others));
actionGroup->add(Action::create("EditRedo", Stock::REDO), actionGroup->add(Action::create("EditRedo", Stock::REDO),
mem_fun(*this, &Actions::on_menu_others)); mem_fun(*this, &Actions::on_menu_others));
actionGroup->add(Action::create("EditCut", Stock::CUT), actionGroup->add(Action::create("EditCut", Stock::CUT),
mem_fun(*this, &Actions::on_menu_others)); mem_fun(*this, &Actions::on_menu_others));
actionGroup->add(Action::create("EditCopy", Stock::COPY), actionGroup->add(Action::create("EditCopy", Stock::COPY),
mem_fun(*this, &Actions::on_menu_others)); mem_fun(*this, &Actions::on_menu_others));
actionGroup->add(Action::create("EditPaste", Stock::PASTE), actionGroup->add(Action::create("EditPaste",Stock::PASTE),
mem_fun(*this, &Actions::on_menu_others)); mem_fun(*this, &Actions::on_menu_others));
actionGroup->add(Action::create("EditPreferences", Stock::PREFERENCES), actionGroup->add(Action::create("EditPreferences", Stock::PREFERENCES),
mem_fun(*this, &Actions::on_menu_edit_preferences)); mem_fun(*this, &Actions::on_menu_edit_preferences));
@ -360,9 +360,8 @@ Actions::on_menu_help_about()
// Configure the about dialog // Configure the about dialog
AboutDialog dialog; AboutDialog dialog;
//dialog.set_program_name(AppTitle); dialog.set_program_name(GtkLumiera::getAppTitle());
dialog.set_version(GtkLumiera::getAppVersion()); dialog.set_version(GtkLumiera::getAppVersion());
//dialog.set_version(AppState::get("version"));
dialog.set_copyright(GtkLumiera::getCopyright()); dialog.set_copyright(GtkLumiera::getCopyright());
dialog.set_website(GtkLumiera::getLumieraWebsite()); dialog.set_website(GtkLumiera::getLumieraWebsite());
dialog.set_authors(GtkLumiera::getLumieraAuthors()); dialog.set_authors(GtkLumiera::getLumieraAuthors());

View file

@ -84,7 +84,7 @@ WorkspaceWindow::create_ui()
//set_default_direction (TEXT_DIR_RTL); //set_default_direction (TEXT_DIR_RTL);
//----- Configure the Window -----// //----- Configure the Window -----//
set_title(GtkLumiera::get_app_title()); set_title(GtkLumiera::getAppTitle());
set_default_size(1024, 768); set_default_size(1024, 768);
//----- Set up the UI Manager -----// //----- Set up the UI Manager -----//

View file

@ -27,18 +27,12 @@
#include "include/logging.h" #include "include/logging.h"
#include <boost/regex.hpp> #include <boost/regex.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/join.hpp> #include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/classification.hpp>
using boost::algorithm::split;
using boost::algorithm::join;
using boost::algorithm::is_any_of;
using boost::algorithm::token_compress_on;
using boost::regex; using boost::regex;
using boost::smatch; using boost::smatch;
using boost::regex_search; using boost::regex_search;
using boost::algorithm::join;
using util::noneg; using util::noneg;

View file

@ -80,7 +80,7 @@ namespace lib {
// try / continue search path // try / continue search path
if (searchLocation.isValid()) if (searchLocation.isValid())
modulePathName = fsys::path() / searchLocation.fetch() / moduleName; modulePathName = fsys::path() / searchLocation.next() / moduleName;
else else
throw error::Config ("Module \""+moduleName+"\" not found" throw error::Config ("Module \""+moduleName+"\" not found"
+ (searchPath.empty()? ".":" in search path: "+searchPath)); + (searchPath.empty()? ".":" in search path: "+searchPath));

View file

@ -27,7 +27,6 @@
#include "lib/error.hpp" #include "lib/error.hpp"
#include "lib/bool-checkable.hpp" #include "lib/bool-checkable.hpp"
#include <boost/program_options.hpp>
#include <boost/noncopyable.hpp> #include <boost/noncopyable.hpp>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <boost/regex.hpp> #include <boost/regex.hpp>
@ -88,7 +87,7 @@ namespace lib {
} }
string string
fetch () next ()
{ {
if (!isValid()) if (!isValid())
throw error::Logic ("Search path exhausted." throw error::Logic ("Search path exhausted."
@ -133,11 +132,13 @@ namespace lib {
/** helper to establish the location to search for loadable modules. /** helper to establish the location to search for loadable modules,
* This is a simple demonstration of the basic technique used in the * configuration files, icons and further resources. After first trying
* real application source to establish a plugin search path, based * the moduleName directly, the given search path is walked using the
* on the actual executable position plus compiled in and configured * SearchPathSplitter, until encountering an existing file with the
* relative and absolute path specifications. * given name.
* @return the absolute pathname of the module file found
* @throws error::Config when the resolution fails
*/ */
string resolveModulePath (string moduleName, string searchPath = ""); string resolveModulePath (string moduleName, string searchPath = "");

View file

@ -2,7 +2,8 @@
Time - Utilities for handling time Time - Utilities for handling time
Copyright (C) Lumiera.org Copyright (C) Lumiera.org
2011, Christian Thaeter <ct@pipapo.org> 2008, Christian Thaeter <ct@pipapo.org>
2011, Hermann Vosseler <Ichthyostega@web.de>
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as modify it under the terms of the GNU General Public License as

View file

@ -66,7 +66,7 @@ namespace test {
walk ("/usr/bin:/usr/lib"); walk ("/usr/bin:/usr/lib");
SearchPathSplitter sp(""); SearchPathSplitter sp("");
VERIFY_ERROR (ITER_EXHAUST, sp.fetch() ); VERIFY_ERROR (ITER_EXHAUST, sp.next() );
} }
void void
@ -74,7 +74,7 @@ namespace test {
{ {
SearchPathSplitter path(spec); SearchPathSplitter path(spec);
while (path) while (path)
cout << "➢➢" << path.fetch() << endl; cout << "➢➢" << path.next() << endl;
} }
@ -86,9 +86,9 @@ namespace test {
string expected = (exePath.remove_leaf() / "modules").string(); string expected = (exePath.remove_leaf() / "modules").string();
SearchPathSplitter sp("xyz:$ORIGIN/modules:abc"); SearchPathSplitter sp("xyz:$ORIGIN/modules:abc");
CHECK ("xyz" == sp.fetch()); CHECK ("xyz" == sp.next());
CHECK (sp.fetch() == expected); CHECK (sp.next() == expected);
CHECK ("abc" == sp.fetch()); CHECK ("abc" == sp.next());
CHECK (!sp.isValid()); CHECK (!sp.isValid());
} }
}; };