From: Jon A. Cruz Date: Thu, 7 Jan 2010 09:19:48 +0000 (-0800) Subject: Added UXManager. Cleaning up toolbox creation. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=433e54b5225e91c2fd97807151d436160261f5a6;p=inkscape.git Added UXManager. Cleaning up toolbox creation. --- diff --git a/src/ui/Makefile_insert b/src/ui/Makefile_insert index 3eb6c6b13..eb8966d11 100644 --- a/src/ui/Makefile_insert +++ b/src/ui/Makefile_insert @@ -9,4 +9,6 @@ ink_common_sources += \ ui/previewable.h \ ui/previewfillable.h \ ui/previewholder.cpp \ - ui/previewholder.h + ui/previewholder.h \ + ui/uxmanager.cpp \ + ui/uxmanager.h diff --git a/src/ui/uxmanager.cpp b/src/ui/uxmanager.cpp new file mode 100644 index 000000000..5f0021ef6 --- /dev/null +++ b/src/ui/uxmanager.cpp @@ -0,0 +1,68 @@ +/** \file + * Desktop widget implementation + */ +/* Authors: + * Jon A. Cruz + * + * Copyright (C) 2010 Jon A. Cruz + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "uxmanager.h" +#include "util/ege-tags.h" +#include "widgets/toolbox.h" + +namespace Inkscape { +namespace UI { + +UXManager* instance = 0; + +UXManager* UXManager::getInstance() +{ + if (!instance) { + instance = new UXManager(); + } + return instance; +} + + +UXManager::UXManager() +{ + ege::TagSet tags; + tags.setLang("en"); + + tags.addTag(ege::Tag("General")); + tags.addTag(ege::Tag("Icons")); +} + +UXManager::~UXManager() +{ +} + + +void UXManager::connectToDesktop( std::vector const & toolboxes, SPDesktop *desktop ) +{ + for (std::vector::const_iterator it = toolboxes.begin(); it != toolboxes.end(); ++it ) { + sp_toolbox_set_desktop( *it, desktop ); + } +} + + +} // namespace UI +} // namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/ui/uxmanager.h b/src/ui/uxmanager.h new file mode 100644 index 000000000..c8b077a57 --- /dev/null +++ b/src/ui/uxmanager.h @@ -0,0 +1,47 @@ +#ifndef SEEN_UI_UXMANAGER_H +#define SEEN_UI_UXMANAGER_H +/* + * A simple interface for previewing representations. + * + * Authors: + * Jon A. Cruz + * + * Copyright (C) 2010 Jon A. Cruz + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include + +typedef struct _GtkWidget GtkWidget; +class SPDesktop; + +namespace Inkscape { +namespace UI { + +class UXManager +{ +public: + static UXManager* getInstance(); + virtual ~UXManager(); + + void connectToDesktop( std::vector const & toolboxes, SPDesktop *desktop ); + +private: + UXManager(); +}; + +} // namespace UI +} // namespace Inkscape + +#endif // SEEN_UI_UXMANAGER_H +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/util/Makefile_insert b/src/util/Makefile_insert index b76a4dcdb..87a974768 100644 --- a/src/util/Makefile_insert +++ b/src/util/Makefile_insert @@ -4,6 +4,8 @@ ink_common_sources += \ util/compose.hpp \ util/ucompose.hpp \ util/enums.h \ + util/ege-tags.h \ + util/ege-tags.cpp \ util/filter-list.h \ util/fixed_point.h \ util/format.h \ diff --git a/src/util/ege-tags.cpp b/src/util/ege-tags.cpp new file mode 100644 index 000000000..5d33c85a3 --- /dev/null +++ b/src/util/ege-tags.cpp @@ -0,0 +1,178 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is EGE Tagging Support. + * + * The Initial Developer of the Original Code is + * Jon A. Cruz. + * Portions created by the Initial Developer are Copyright (C) 2009 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif // HAVE_CONFIG_H + +#if HAVE_LIBINTL_H +#include +#endif // HAVE_LIBINTL_H + +#if !defined(_) +#define _(s) gettext(s) +#endif // !defined(_) + +#include +#include +#include + +#include "ege-tags.h" + +#include + +namespace ege +{ + +Label::Label(std::string const& lang, std::string const& value) : + lang(lang), + value(value) +{ +} + +Label::~Label() +{ +} + +// ========================================================================= + +Tag::~Tag() +{ +} + +Tag::Tag(std::string const& key) : + key(key) +{ +} + +// ========================================================================= + +TagSet::TagSet() : + lang(), + tags(), + counts() +{ +} + +TagSet::~TagSet() +{ +} + +void TagSet::setLang(std::string const& lang) +{ + if (lang != this->lang) { + this->lang = lang; + } +} + + +struct sameLang : public std::binary_function { + bool operator()(Label const& x, Label const& y) const { return (x.lang == y.lang); } +}; + + +bool TagSet::addTag(Tag const& tag) +{ + bool present = false; + + for ( std::vector::iterator it = tags.begin(); (it != tags.end()) && !present; ++it ) { + if (tag.key == it->key) { + present = true; + + for ( std::vector