diff options
| author | Liam P. White <inkscapebrony@gmail.com> | 2014-08-18 20:19:55 +0000 |
|---|---|---|
| committer | Liam P. White <inkscapebrony@gmail.com> | 2014-08-18 20:19:55 +0000 |
| commit | dce3466274e04364e25c47b0b71007a65c9cf9dd (patch) | |
| tree | 37d21bcfbc010d83221de713fb83d6e15e1546cf /src | |
| parent | Fix accidental regression in previous commit (diff) | |
| download | inkscape-dce3466274e04364e25c47b0b71007a65c9cf9dd.tar.gz inkscape-dce3466274e04364e25c47b0b71007a65c9cf9dd.zip | |
Code cleanup.
(bzr r13341.1.145)
Diffstat (limited to 'src')
37 files changed, 804 insertions, 911 deletions
diff --git a/src/attributes.cpp b/src/attributes.cpp index 2474e4abe..526476322 100644 --- a/src/attributes.cpp +++ b/src/attributes.cpp @@ -1,9 +1,4 @@ -#define __SP_ATTRIBUTES_C__ - -/** \file - * Lookup dictionary for attributes/properties. - */ -/* +/** * Author: * Lauris Kaplinski <lauris@kaplinski.com> * @@ -25,6 +20,10 @@ typedef struct { gchar const *name; } SPStyleProp; +/** + * Lookup dictionary for attributes/properties. + */ + static SPStyleProp const props[] = { {SP_ATTR_INVALID, NULL}, /* SPObject */ @@ -539,4 +538,4 @@ sp_attribute_name(unsigned int id) fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/axis-manip.cpp b/src/axis-manip.cpp index 1dfa0e6bf..1240d99e6 100644 --- a/src/axis-manip.cpp +++ b/src/axis-manip.cpp @@ -1,6 +1,4 @@ -#define __AXIS_MANIP_C__ - -/* +/** * Generic auxiliary routines for 3D axes * * Authors: @@ -44,4 +42,4 @@ get_remaining_axes (Axis axis) { fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/display/curve.cpp b/src/display/curve.cpp index 50f4c8954..0a39a8e7f 100644 --- a/src/display/curve.cpp +++ b/src/display/curve.cpp @@ -1,10 +1,4 @@ -#define __CURVE_C__ - -/** \file - * Routines for SPCurve and for its Geom::PathVector - */ - -/* +/** * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * Johan Engelen @@ -14,7 +8,7 @@ * Copyright (C) 2002 Lauris Kaplinski * Copyright (C) 2008 Johan Engelen * - * Released under GNU GPL + * Released under GNU GPL, see file 'COPYING' for more information */ #include "display/curve.h" @@ -25,6 +19,10 @@ #include <2geom/sbasis-to-bezier.h> #include <2geom/point.h> +/** + * Routines for SPCurve and for its Geom::PathVector + */ + /* Constructors */ /** @@ -686,4 +684,4 @@ SPCurve::last_point_additive_move(Geom::Point const & p) fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8: diff --git a/src/display/curve.h b/src/display/curve.h index 4866655c4..b3f1e3702 100644 --- a/src/display/curve.h +++ b/src/display/curve.h @@ -1,8 +1,5 @@ -#ifndef SEEN_DISPLAY_CURVE_H -#define SEEN_DISPLAY_CURVE_H - -/* - * Author: +/** + * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * * Copyright (C) 2000 Lauris Kaplinski @@ -10,17 +7,18 @@ * Copyright (C) 2002 Lauris Kaplinski * Copyright (C) 2008 Johan Engelen * - * Released under GNU GPL + * Released under GNU GPL, see file 'COPYING' for more information */ -#include <glib.h> +#ifndef SEEN_DISPLAY_CURVE_H +#define SEEN_DISPLAY_CURVE_H +#include <glib.h> #include <2geom/forward.h> - #include <boost/optional.hpp> /** - * Wrapper around a Geom::PathVector objects. + * Wrapper around a Geom::PathVector object. */ class SPCurve { public: @@ -90,7 +88,7 @@ private: SPCurve& operator=(const SPCurve&); }; -#endif /* !SEEN_DISPLAY_CURVE_H */ +#endif // !SEEN_DISPLAY_CURVE_H /* Local Variables: @@ -101,4 +99,4 @@ private: fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index f0fd3711b..e7d6e64ce 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -1,28 +1,18 @@ -/** \file - * Code for handling extensions (i.e.\ scripts). - */ -/* +/** + * Code for handling extensions (i.e. scripts). + * * Authors: * Bryce Harrington <bryce@osdl.org> * Ted Gould <ted@gould.cx> * Jon A. Cruz <jon@joncruz.org> * Abhishek Sharma * - * Copyright (C) 2002-2005,2007 Authors + * Copyright (C) 2002-2007 Authors * * Released under GNU GPL, read the file 'COPYING' for more information */ -#define __INKSCAPE_EXTENSION_IMPLEMENTATION_SCRIPT_C__ - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - -#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H -#include <glibmm/threads.h> -#endif - +#include <glibmm.h> #include <gtkmm/messagedialog.h> #include <gtkmm/main.h> #include <gtkmm/scrolledwindow.h> @@ -33,43 +23,37 @@ #include <errno.h> #include <glib.h> -#include <glib/gstdio.h> -#include "ui/view/view.h" #include "desktop-handles.h" #include "desktop.h" -#include "selection.h" -#include "sp-namedview.h" -#include "io/sys.h" -#include "preferences.h" -#include "../system.h" +#include "dialogs/dialog-events.h" #include "extension/effect.h" #include "extension/output.h" #include "extension/input.h" #include "extension/db.h" -#include "script.h" -#include "dialogs/dialog-events.h" #include "inkscape.h" +#include "io/sys.h" +#include "preferences.h" +#include "script.h" +#include "selection.h" +#include "sp-namedview.h" +#include "system.h" +#include "ui/view/view.h" #include "xml/node.h" #include "xml/attribute-record.h" #include "util/glib-list-iterators.h" #include "path-prefix.h" - #ifdef WIN32 #include <windows.h> #include <sys/stat.h> #include "registrytool.h" #endif - - /** This is the command buffer that gets allocated from the stack */ #define BUFSIZE (255) - - /* Namespaces */ namespace Inkscape { namespace Extension { @@ -1063,4 +1047,4 @@ int Script::execute (const std::list<std::string> &in_command, fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/extension/implementation/script.h b/src/extension/implementation/script.h index 270c361af..6a7d0c3b8 100644 --- a/src/extension/implementation/script.h +++ b/src/extension/implementation/script.h @@ -22,81 +22,30 @@ namespace Inkscape { namespace XML { class Node; -} -} +} // namespace XML - -namespace Inkscape { namespace Extension { namespace Implementation { - /** * Utility class used for loading and launching script extensions */ class Script : public Implementation { - public: - /** - * - */ Script(void); - - /** - * - */ virtual ~Script(); - - - /** - * - */ virtual bool load(Inkscape::Extension::Extension *module); - - /** - * - */ virtual void unload(Inkscape::Extension::Extension *module); - - /** - * - */ virtual bool check(Inkscape::Extension::Extension *module); ImplementationDocumentCache * newDocCache(Inkscape::Extension::Extension * ext, Inkscape::UI::View::View * view); - /** - * - */ - virtual Gtk::Widget *prefs_input(Inkscape::Extension::Input *module, - gchar const *filename); - - /** - * - */ - virtual SPDocument *open(Inkscape::Extension::Input *module, - gchar const *filename); - - /** - * - */ + virtual Gtk::Widget *prefs_input(Inkscape::Extension::Input *module, gchar const *filename); + virtual SPDocument *open(Inkscape::Extension::Input *module, gchar const *filename); virtual Gtk::Widget *prefs_output(Inkscape::Extension::Output *module); - - /** - * - */ - virtual void save(Inkscape::Extension::Output *module, - SPDocument *doc, - gchar const *filename); - - /** - * - */ - virtual void effect(Inkscape::Extension::Effect *module, - Inkscape::UI::View::View *doc, - ImplementationDocumentCache * docCache); - + virtual void save(Inkscape::Extension::Output *module, SPDocument *doc, gchar const *filename); + virtual void effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View *doc, ImplementationDocumentCache * docCache); virtual bool cancelProcessing (void); private: @@ -105,7 +54,7 @@ private: Glib::RefPtr<Glib::MainLoop> _main_loop; /** - * The command that has been dirived from + * The command that has been derived from * the configuration file with appropriate directories */ std::list<std::string> command; @@ -117,13 +66,10 @@ private: */ Glib::ustring helper_extension; - std::string solve_reldir (Inkscape::XML::Node *reprin); - bool check_existence (const std::string &command); - void copy_doc (Inkscape::XML::Node * olddoc, - Inkscape::XML::Node * newdoc); - void checkStderr (const Glib::ustring &filename, - Gtk::MessageType type, - const Glib::ustring &message); + std::string solve_reldir(Inkscape::XML::Node *repr_in); + bool check_existence (std::string const& command); + void copy_doc(Inkscape::XML::Node * olddoc, Inkscape::XML::Node * newdoc); + void checkStderr (Glib::ustring const& filename, Gtk::MessageType type, Glib::ustring const& message); class file_listener { Glib::ustring _string; @@ -140,6 +86,7 @@ private: bool isDead () { return _dead; } + // TODO move these definitions into script.cpp void init (int fd, Glib::RefPtr<Glib::MainLoop> main) { _channel = Glib::IOChannel::create_from_fd(fd); _channel->set_encoding(); @@ -202,11 +149,6 @@ private: std::string resolveInterpreterExecutable(const Glib::ustring &interpNameArg); }; // class Script - - - - - } // namespace Implementation } // namespace Extension } // namespace Inkscape diff --git a/src/help.cpp b/src/help.cpp index 02a1930f4..60e57abfc 100644 --- a/src/help.cpp +++ b/src/help.cpp @@ -1,6 +1,4 @@ -#define __SP_HELP_C__ - -/* +/** * Help/About window * * Authors: @@ -13,24 +11,19 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif +#include <glib.h> -#include "ui/dialog/aboutbox.h" -#include "path-prefix.h" -#include "help.h" #include "file.h" +#include "help.h" +#include "path-prefix.h" +#include "ui/dialog/aboutbox.h" - -void -sp_help_about (void) +void sp_help_about() { Inkscape::UI::Dialog::AboutBox::show_about(); } -void -sp_help_open_tutorial(GtkMenuItem *, gpointer data) +void sp_help_open_tutorial(GtkMenuItem *, void* data) { gchar const *name = static_cast<gchar const *>(data); gchar *c = g_build_filename(INKSCAPE_TUTORIALSDIR, name, NULL); diff --git a/src/help.h b/src/help.h index 3fce65fef..3f83e3367 100644 --- a/src/help.h +++ b/src/help.h @@ -1,6 +1,4 @@ -#ifndef SEEN_HELP_H -#define SEEN_HELP_H -/* +/** * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * @@ -10,18 +8,18 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <glib.h> -#include <gtk/gtk.h> +#ifndef SEEN_HELP_H +#define SEEN_HELP_H + +typedef struct _GtkMenuItem GtkMenuItem; /** * Help/About window. */ -void sp_help_about(void); - -void sp_help_open_tutorial(GtkMenuItem *menuitem, gpointer data); - +void sp_help_about(); +void sp_help_open_tutorial(GtkMenuItem * /*unused*/, void* data); -#endif /* !SEEN_HELP_H */ +#endif // !SEEN_HELP_H /* Local Variables: @@ -32,4 +30,4 @@ void sp_help_open_tutorial(GtkMenuItem *menuitem, gpointer data); fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/helper/gnome-utils.cpp b/src/helper/gnome-utils.cpp index 957b7ea5e..3d2b333a2 100644 --- a/src/helper/gnome-utils.cpp +++ b/src/helper/gnome-utils.cpp @@ -1,9 +1,7 @@ -#define __GNOME_UTILS_C__ - -/* +/** * Helpers * - * Author: + * Authors: * Mitsuru Oka * Lauris Kaplinski <lauris@kaplinski.com> * @@ -25,49 +23,48 @@ * Returns a GList containing strings allocated with g_malloc * that have been splitted from @uri-list. */ -GList* -gnome_uri_list_extract_uris (const gchar* uri_list) +GList *gnome_uri_list_extract_uris(const gchar *uri_list) { - const gchar *p, *q; - gchar *retval; - GList *result = NULL; - - g_return_val_if_fail (uri_list != NULL, NULL); - - p = uri_list; - - /* We don't actually try to validate the URI according to RFC - * 2396, or even check for allowed characters - we just ignore - * comments and trim whitespace off the ends. We also - * allow LF delimination as well as the specified CRLF. - */ - while (p) { - if (*p != '#') { - while (isspace(*p)) - p++; - - q = p; - while (*q && (*q != '\n') && (*q != '\r')) - q++; - - if (q > p) { - q--; - while (q > p && isspace(*q)) - q--; - - retval = (gchar*)g_malloc (q - p + 2); - strncpy (retval, p, q - p + 1); - retval[q - p + 1] = '\0'; - - result = g_list_prepend (result, retval); - } - } - p = strchr (p, '\n'); - if (p) - p++; - } - - return g_list_reverse (result); + const gchar *p, *q; + gchar *retval; + GList *result = NULL; + + g_return_val_if_fail(uri_list != NULL, NULL); + + p = uri_list; + + /* We don't actually try to validate the URI according to RFC + * 2396, or even check for allowed characters - we just ignore + * comments and trim whitespace off the ends. We also + * allow LF delimination as well as the specified CRLF. + */ + while (p) { + if (*p != '#') { + while (isspace(*p)) + p++; + + q = p; + while (*q && (*q != '\n') && (*q != '\r')) + q++; + + if (q > p) { + q--; + while (q > p && isspace(*q)) + q--; + + retval = (gchar *)g_malloc(q - p + 2); + strncpy(retval, p, q - p + 1); + retval[q - p + 1] = '\0'; + + result = g_list_prepend(result, retval); + } + } + p = strchr(p, '\n'); + if (p) + p++; + } + + return g_list_reverse(result); } /** @@ -80,29 +77,40 @@ gnome_uri_list_extract_uris (const gchar* uri_list) * Note that unlike gnome_uri_list_extract_uris() function, this * will discard any non-file uri from the result value. */ -GList* -gnome_uri_list_extract_filenames (const gchar* uri_list) +GList *gnome_uri_list_extract_filenames(const gchar *uri_list) { - g_return_val_if_fail (uri_list != NULL, NULL); - - GList *result = gnome_uri_list_extract_uris (uri_list); - - GList *tmp_list = result; - while (tmp_list) { - gchar *s = (gchar*)tmp_list->data; - - GList *node = tmp_list; - tmp_list = tmp_list->next; - - if (!strncmp (s, "file:", 5)) { - node->data = g_filename_from_uri (s, NULL, NULL); - /* not sure if this fallback is useful at all */ - if (!node->data) node->data = g_strdup (s+5); - } else { - result = g_list_remove_link(result, node); - g_list_free_1 (node); - } - g_free (s); - } - return result; + g_return_val_if_fail(uri_list != NULL, NULL); + + GList *result = gnome_uri_list_extract_uris(uri_list); + + GList *tmp_list = result; + while (tmp_list) { + gchar *s = (gchar *)tmp_list->data; + + GList *node = tmp_list; + tmp_list = tmp_list->next; + + if (!strncmp(s, "file:", 5)) { + node->data = g_filename_from_uri(s, NULL, NULL); + /* not sure if this fallback is useful at all */ + if (!node->data) + node->data = g_strdup(s + 5); + } else { + result = g_list_remove_link(result, node); + g_list_free_1(node); + } + g_free(s); + } + return result; } + +/* + 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:fileencoding=utf-8 : diff --git a/src/helper/gnome-utils.h b/src/helper/gnome-utils.h index 3502b28df..6f2f28223 100644 --- a/src/helper/gnome-utils.h +++ b/src/helper/gnome-utils.h @@ -1,7 +1,7 @@ -/* +/** * GNOME Utils - Migration helper * - * Author: + * Authors: * GNOME Developer * Mitsuru Oka <oka326@parkcity.ne.jp> * Lauris Kaplinski <lauris@ximian.com> @@ -11,17 +11,15 @@ * Released under GNU GPL */ - -#ifndef __GNOME_UTILS_H__ -#define __GNOME_UTILS_H__ +#ifndef SEEN_GNOME_UTILS_H +#define SEEN_GNOME_UTILS_H #include <glib.h> GList *gnome_uri_list_extract_uris(gchar const *uri_list); - GList *gnome_uri_list_extract_filenames(gchar const *uri_list); -#endif /* __GNOME_UTILS_H__ */ +#endif // !SEEN_GNOME_UTILS_H /* Local Variables: @@ -32,4 +30,4 @@ GList *gnome_uri_list_extract_filenames(gchar const *uri_list); fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/helper/window.cpp b/src/helper/window.cpp index 98fbef170..98e886a38 100644 --- a/src/helper/window.cpp +++ b/src/helper/window.cpp @@ -1,6 +1,4 @@ -#define __SP_WINDOW_C__ - -/* +/** * Generic window implementation * * Author: @@ -9,61 +7,61 @@ * This code is in public domain */ -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - -#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H -#include <glibmm/threads.h> -#endif - +#include <glibmm.h> #include <gtkmm/window.h> +#include "desktop.h" #include "inkscape.h" #include "shortcuts.h" -#include "desktop.h" #include "ui/tools/tool-base.h" #include "window.h" -#include <gtk/gtk.h> static bool on_window_key_press(GdkEventKey* event) { - unsigned int shortcut; - shortcut = Inkscape::UI::Tools::get_group0_keyval (event) | + unsigned shortcut = 0; + // FIXME why? + shortcut = Inkscape::UI::Tools::get_group0_keyval (event) | ( event->state & GDK_SHIFT_MASK ? SP_SHORTCUT_SHIFT_MASK : 0 ) | ( event->state & GDK_CONTROL_MASK ? SP_SHORTCUT_CONTROL_MASK : 0 ) | ( event->state & GDK_MOD1_MASK ? SP_SHORTCUT_ALT_MASK : 0 ); - return sp_shortcut_invoke (shortcut, SP_ACTIVE_DESKTOP); + return sp_shortcut_invoke (shortcut, SP_ACTIVE_DESKTOP); } -Gtk::Window * -Inkscape::UI::window_new (const gchar *title, unsigned int resizeable) +Gtk::Window * Inkscape::UI::window_new (const gchar *title, unsigned int resizeable) { - Gtk::Window *window = new Gtk::Window(Gtk::WINDOW_TOPLEVEL); - window->set_title (title); - window->set_resizable (resizeable); - window->signal_key_press_event().connect(sigc::ptr_fun(&on_window_key_press)); + Gtk::Window *window = new Gtk::Window(Gtk::WINDOW_TOPLEVEL); + window->set_title (title); + window->set_resizable (resizeable); + window->signal_key_press_event().connect(sigc::ptr_fun(&on_window_key_press)); - return window; + return window; } -static gboolean -sp_window_key_press(GtkWidget */*widget*/, GdkEventKey *event) +static gboolean sp_window_key_press(GtkWidget *, GdkEventKey *event) { return on_window_key_press(event); } -GtkWidget * -sp_window_new (const gchar *title, unsigned int resizeable) +GtkWidget * sp_window_new (const gchar *title, unsigned int resizeable) { - GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_title ((GtkWindow *) window, title); - gtk_window_set_resizable ((GtkWindow *) window, resizeable); - g_signal_connect_after ((GObject *) window, "key_press_event", (GCallback) sp_window_key_press, NULL); + GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + gtk_window_set_title ((GtkWindow *) window, title); + gtk_window_set_resizable ((GtkWindow *) window, resizeable); + g_signal_connect_after ((GObject *) window, "key_press_event", (GCallback) sp_window_key_press, NULL); - return window; + return window; } +/* + 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:fileencoding=utf-8 : diff --git a/src/helper/window.h b/src/helper/window.h index c6807f9e5..a0efcd292 100644 --- a/src/helper/window.h +++ b/src/helper/window.h @@ -1,7 +1,7 @@ -#ifndef __SP_WINDOW_H__ -#define __SP_WINDOW_H__ +#ifndef SEEN_SP_WINDOW_H +#define SEEN_SP_WINDOW_H -/* +/** * Generic window implementation * * Author: @@ -17,10 +17,11 @@ namespace Gtk { class Window; } -/* - * This function is deprecated. Use Inkscape::UI::window_new instead. - */ -GtkWidget *sp_window_new (const gchar *title, unsigned int resizeable); +// Can we just get rid of this altogether? +#if defined(GCC_VERSION) || defined(__clang__) +__attribute__((deprecated)) +#endif +GtkWidget * sp_window_new (const gchar *title, unsigned int resizeable); namespace Inkscape { namespace UI { @@ -30,7 +31,7 @@ Gtk::Window *window_new (const gchar *title, unsigned int resizeable); } } -#endif +#endif // !SEEN_SP_WINDOW_H /* Local Variables: @@ -41,4 +42,4 @@ Gtk::Window *window_new (const gchar *title, unsigned int resizeable); fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/libnrtype/nr-type-primitives.cpp b/src/libnrtype/nr-type-primitives.cpp index 63a3abcc5..3ad4a3771 100644 --- a/src/libnrtype/nr-type-primitives.cpp +++ b/src/libnrtype/nr-type-primitives.cpp @@ -1,6 +1,4 @@ -#define __NR_TYPE_PRIMITIVES_C__ - -/* +/** * Typeface and script library * * Authors: @@ -12,26 +10,27 @@ /* This should be enough for approximately 10000 fonts */ #define NR_DICTSIZE 2777 -#include <stdlib.h> +#include <cstdlib> #include <string.h> #include <glib.h> + #include "nr-type-primitives.h" /** * An entry in a list of key->value pairs */ struct NRTDEntry { - NRTDEntry *next; - const gchar *key; - void *val; + NRTDEntry *next; + const gchar *key; + void *val; }; /** * Type Dictionary, consisting of size number of key-value entries */ struct NRTypeDict { - unsigned int size; - NRTDEntry **entries; + unsigned int size; + NRTDEntry **entries; }; static NRTDEntry *nr_td_entry_new (void); @@ -42,17 +41,17 @@ static NRTDEntry *nr_td_entry_new (void); void nr_name_list_release (NRNameList *list) { - if (list->destructor) { - list->destructor (list); - } + if (list->destructor) { + list->destructor (list); + } } void nr_style_list_release (NRStyleList *list) { - if (list->destructor) { - list->destructor (list); - } + if (list->destructor) { + list->destructor (list); + } } /** @@ -62,18 +61,18 @@ nr_style_list_release (NRStyleList *list) NRTypeDict * nr_type_dict_new (void) { - NRTypeDict *td; - int i; + NRTypeDict *td; + int i; - td = g_new (NRTypeDict, 1); + td = g_new (NRTypeDict, 1); - td->size = NR_DICTSIZE; - td->entries = g_new (NRTDEntry *, td->size); - for (i = 0; i < NR_DICTSIZE; i++) { - td->entries[i] = NULL; - } + td->size = NR_DICTSIZE; + td->entries = g_new (NRTDEntry *, td->size); + for (i = 0; i < NR_DICTSIZE; i++) { + td->entries[i] = NULL; + } - return td; + return td; } /** @@ -82,15 +81,15 @@ nr_type_dict_new (void) static unsigned int nr_str_hash (const gchar *p) { - unsigned int h; + unsigned int h; - h = *p; + h = *p; - if (h != 0) { - for (p += 1; *p; p++) h = (h << 5) - h + *p; - } + if (h != 0) { + for (p += 1; *p; p++) h = (h << 5) - h + *p; + } - return h; + return h; } /** @@ -99,25 +98,25 @@ nr_str_hash (const gchar *p) void nr_type_dict_insert (NRTypeDict *td, const gchar *key, void *val) { - if (key) { - NRTDEntry *tde; - unsigned int hval; - - hval = nr_str_hash (key) % td->size; - - for (tde = td->entries[hval]; tde; tde = tde->next) { - if (!strcmp (key, tde->key)) { - tde->val = val; - return; - } - } - - tde = nr_td_entry_new (); - tde->next = td->entries[hval]; - tde->key = key; - tde->val = val; - td->entries[hval] = tde; - } + if (key) { + NRTDEntry *tde; + unsigned int hval; + + hval = nr_str_hash (key) % td->size; + + for (tde = td->entries[hval]; tde; tde = tde->next) { + if (!strcmp (key, tde->key)) { + tde->val = val; + return; + } + } + + tde = nr_td_entry_new (); + tde->next = td->entries[hval]; + tde->key = key; + tde->val = val; + td->entries[hval] = tde; + } } /** @@ -126,16 +125,16 @@ nr_type_dict_insert (NRTypeDict *td, const gchar *key, void *val) void * nr_type_dict_lookup (NRTypeDict *td, const gchar *key) { - if (key) { - NRTDEntry *tde; - unsigned int hval; - hval = nr_str_hash (key) % td->size; - for (tde = td->entries[hval]; tde; tde = tde->next) { - if (!strcmp (key, tde->key)) return tde->val; - } - } - - return NULL; + if (key) { + NRTDEntry *tde; + unsigned int hval; + hval = nr_str_hash (key) % td->size; + for (tde = td->entries[hval]; tde; tde = tde->next) { + if (!strcmp (key, tde->key)) return tde->val; + } + } + + return NULL; } #define NR_TDE_BLOCK_SIZE 32 @@ -148,20 +147,30 @@ static NRTDEntry *nr_tde_free_list; static NRTDEntry * nr_td_entry_new (void) { - NRTDEntry *tde; + NRTDEntry *tde; - if (!nr_tde_free_list) { - int i; - nr_tde_free_list = g_new (NRTDEntry, NR_TDE_BLOCK_SIZE); - for (i = 0; i < (NR_TDE_BLOCK_SIZE - 1); i++) { - nr_tde_free_list[i].next = nr_tde_free_list + i + 1; - } - nr_tde_free_list[i].next = NULL; - } + if (!nr_tde_free_list) { + int i; + nr_tde_free_list = g_new (NRTDEntry, NR_TDE_BLOCK_SIZE); + for (i = 0; i < (NR_TDE_BLOCK_SIZE - 1); i++) { + nr_tde_free_list[i].next = nr_tde_free_list + i + 1; + } + nr_tde_free_list[i].next = NULL; + } - tde = nr_tde_free_list; - nr_tde_free_list = tde->next; + tde = nr_tde_free_list; + nr_tde_free_list = tde->next; - return tde; + return tde; } +/* + 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:fileencoding=utf-8 : diff --git a/src/libnrtype/nr-type-primitives.h b/src/libnrtype/nr-type-primitives.h index 9bb181c4b..863803433 100644 --- a/src/libnrtype/nr-type-primitives.h +++ b/src/libnrtype/nr-type-primitives.h @@ -1,12 +1,12 @@ -#ifndef __NR_TYPE_PRIMITIVES_H__ -#define __NR_TYPE_PRIMITIVES_H__ +#ifndef SEEN_NR_TYPE_PRIMITIVES_H +#define SEEN_NR_TYPE_PRIMITIVES_H -/* +/** * Typeface and script library * * Authors: * Lauris Kaplinski <lauris@kaplinski.com> - * g++ port: Nathan Hurst <njh@mail.csse.monash.edu.au> + * c++ port: Nathan Hurst <njh@mail.csse.monash.edu.au> * * This code is in public domain */ @@ -47,4 +47,15 @@ void nr_type_dict_insert (NRTypeDict *td, const gchar *key, void *val); void *nr_type_dict_lookup (NRTypeDict *td, const gchar *key); -#endif +#endif // !SEEN_NR_TYPE_PRIMITIVES_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:fileencoding=utf-8 : diff --git a/src/macros.h b/src/macros.h index b221ebdc2..cbb9bca78 100644 --- a/src/macros.h +++ b/src/macros.h @@ -1,7 +1,7 @@ -#ifndef __MACROS_H__ -#define __MACROS_H__ +#ifndef SEEN_MACROS_H +#define SEEN_MACROS_H -/* +/** * Useful macros for inkscape * * Author: @@ -12,6 +12,9 @@ * Released under GNU GPL */ +// I'm of the opinion that this file should be removed, so I will in the future take the necessary steps to wipe it out. +// Macros are not in general bad, but these particular ones are rather ugly. Especially that sp_round one. --Liam + #ifdef SP_MACROS_SILENT #define SP_PRINT_MATRIX(s,m) #define SP_PRINT_TRANSFORM(s,t) @@ -51,4 +54,4 @@ fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/perspective-line.cpp b/src/perspective-line.cpp index 4fd68f8ed..e6c78403b 100644 --- a/src/perspective-line.cpp +++ b/src/perspective-line.cpp @@ -1,6 +1,4 @@ -#define __PERSPECTIVE_LINE_C__ - -/* +/** * Perspective line for 3D perspectives * * Authors: @@ -40,4 +38,4 @@ PerspectiveLine::PerspectiveLine (Geom::Point const &pt, Proj::Axis const axis, fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/proj_pt.cpp b/src/proj_pt.cpp index 28286948d..f5cca8fca 100644 --- a/src/proj_pt.cpp +++ b/src/proj_pt.cpp @@ -1,6 +1,4 @@ -#define __PROJ_PT_C__ - -/* +/** * 3x4 transformation matrix to map points from projective 3-space into the projective plane * * Authors: @@ -117,4 +115,4 @@ Pt3::coord_string() { fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/proj_pt.h b/src/proj_pt.h index 90b9df201..226c182cc 100644 --- a/src/proj_pt.h +++ b/src/proj_pt.h @@ -1,7 +1,4 @@ -#ifndef __PROJ_PT_H__ -#define __PROJ_PT_H__ - -/* +/** * 3x4 transformation matrix to map points from projective 3-space into the projective plane * * Authors: @@ -12,6 +9,9 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#ifndef SEEN_PROJ_PT_H +#define SEEN_PROJ_PT_H + #include <2geom/point.h> #include <gtk/gtk.h> @@ -157,7 +157,7 @@ private: } // namespace Proj -#endif /* __PROJ_PT_H__ */ +#endif // !SEEN_PROJ_PT_H /* Local Variables: @@ -168,4 +168,4 @@ private: fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp index cda59e057..b5c6e4af8 100644 --- a/src/sp-ellipse.cpp +++ b/src/sp-ellipse.cpp @@ -14,26 +14,25 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "svg/svg.h" -#include "svg/path-string.h" -#include "xml/repr.h" -#include "attributes.h" -#include "style.h" -#include "display/curve.h" +#include <glibmm.h> #include <glibmm/i18n.h> + #include <2geom/angle.h> #include <2geom/ellipse.h> -#include <2geom/transforms.h> -#include <2geom/pathvector.h> #include <2geom/path-sink.h> +#include <2geom/pathvector.h> +#include <2geom/transforms.h> + +#include "attributes.h" +#include "display/curve.h" #include "document.h" -#include "sp-ellipse.h" #include "preferences.h" #include "snap-candidate.h" +#include "sp-ellipse.h" +#include "style.h" +#include "svg/svg.h" +#include "svg/path-string.h" +#include "xml/repr.h" #include "sp-factory.h" @@ -42,21 +41,21 @@ SPObject *create_ellipse() { SPGenericEllipse *ellipse = new SPGenericEllipse(); ellipse->type = SP_GENERIC_ELLIPSE_ELLIPSE; - return (SPObject*)ellipse; + return ellipse; } SPObject *create_circle() { SPGenericEllipse *circle = new SPGenericEllipse(); circle->type = SP_GENERIC_ELLIPSE_CIRCLE; - return (SPObject*)circle; + return circle; } SPObject *create_arc() { SPGenericEllipse *arc = new SPGenericEllipse(); arc->type = SP_GENERIC_ELLIPSE_ARC; - return (SPObject*)arc; + return arc; } bool ellipse_registered = SPFactory::instance().registerObject("svg:ellipse", create_ellipse); @@ -695,4 +694,4 @@ bool SPGenericEllipse::_isSlice() const fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/sp-ellipse.h b/src/sp-ellipse.h index cb988b8bb..e575b8761 100644 --- a/src/sp-ellipse.h +++ b/src/sp-ellipse.h @@ -1,7 +1,4 @@ -#ifndef __SP_ELLIPSE_H__ -#define __SP_ELLIPSE_H__ - -/* +/** * SVG <ellipse> and related implementations * * Authors: @@ -16,12 +13,15 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#ifndef SEEN_SP_ELLIPSE_H +#define SEEN_SP_ELLIPSE_H + #include "svg/svg-length.h" #include "sp-shape.h" /* Common parent class */ -#define SP_GENERICELLIPSE(obj) (dynamic_cast<SPGenericEllipse*>((SPObject*)obj)) -#define SP_IS_GENERICELLIPSE(obj) (dynamic_cast<const SPGenericEllipse*>((SPObject*)obj) != NULL) +#define SP_GENERICELLIPSE(obj) (dynamic_cast<SPGenericEllipse*>(obj)) +#define SP_IS_GENERICELLIPSE(obj) (dynamic_cast<const SPGenericEllipse*>((obj)) != NULL) enum GenericEllipseType { SP_GENERIC_ELLIPSE_UNDEFINED, @@ -98,4 +98,4 @@ protected: fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/sp-glyph-kerning.cpp b/src/sp-glyph-kerning.cpp index be47c7621..f33d3c509 100644 --- a/src/sp-glyph-kerning.cpp +++ b/src/sp-glyph-kerning.cpp @@ -1,18 +1,12 @@ -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - -#define __SP_ANCHOR_C__ - -/* +/** * SVG <hkern> and <vkern> elements implementation * W3C SVG 1.1 spec, page 476, section 20.7 * - * Author: + * Authors: * Felipe C. da S. Sanches <juca@members.fsf.org> * Abhishek Sharma * - * Copyright (C) 2008, Felipe C. da S. Sanches + * Copyright (C) 2008 Authors * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -26,45 +20,49 @@ #include <cstring> -SPGlyphKerning::SPGlyphKerning() : SPObject() { +SPGlyphKerning::SPGlyphKerning() + : SPObject() //TODO: correct these values: - this->u1 = NULL; - this->g1 = NULL; - this->u2 = NULL; - this->g2 = NULL; - this->k = 0; -} - -SPGlyphKerning::~SPGlyphKerning() { + , u1(NULL) + , g1(NULL) + , u2(NULL) + , g2(NULL) + , k(0) +{ } -void SPGlyphKerning::build(SPDocument *document, Inkscape::XML::Node *repr) { - SPObject::build(document, repr); +void SPGlyphKerning::build(SPDocument *document, Inkscape::XML::Node *repr) +{ + SPObject::build(document, repr); - this->readAttr( "u1" ); - this->readAttr( "g1" ); - this->readAttr( "u2" ); - this->readAttr( "g2" ); - this->readAttr( "k" ); + this->readAttr( "u1" ); + this->readAttr( "g1" ); + this->readAttr( "u2" ); + this->readAttr( "g2" ); + this->readAttr( "k" ); } -void SPGlyphKerning::release() { - SPObject::release(); +void SPGlyphKerning::release() +{ + SPObject::release(); } -GlyphNames::GlyphNames(const gchar* value){ +GlyphNames::GlyphNames(const gchar* value) +{ if (value) { - this->names = strdup(value); + names = g_strdup(value); } } -GlyphNames::~GlyphNames(){ - if (this->names) { - g_free(this->names); +GlyphNames::~GlyphNames() +{ + if (names) { + g_free(names); } } -bool GlyphNames::contains(const char* name){ +bool GlyphNames::contains(const char* name) +{ if (!(this->names) || !name) { return false; } @@ -75,14 +73,15 @@ bool GlyphNames::contains(const char* name){ while (is >> str) { if (str == s) { - return true; + return true; } } return false; } -void SPGlyphKerning::set(unsigned int key, const gchar *value) { +void SPGlyphKerning::set(unsigned int key, const gchar *value) +{ switch (key) { case SP_ATTR_U1: { @@ -143,15 +142,16 @@ void SPGlyphKerning::set(unsigned int key, const gchar *value) { } /** - * * Receives update notifications. - * */ -void SPGlyphKerning::update(SPCtx *ctx, guint flags) { + * Receives update notifications. + */ +void SPGlyphKerning::update(SPCtx *ctx, guint flags) +{ if (flags & SP_OBJECT_MODIFIED_FLAG) { /* do something to trigger redisplay, updates? */ - this->readAttr( "u1" ); - this->readAttr( "u2" ); - this->readAttr( "g2" ); - this->readAttr( "k" ); + this->readAttr( "u1" ); + this->readAttr( "u2" ); + this->readAttr( "g2" ); + this->readAttr( "k" ); } SPObject::update(ctx, flags); @@ -159,37 +159,26 @@ void SPGlyphKerning::update(SPCtx *ctx, guint flags) { #define COPY_ATTR(rd,rs,key) (rd)->setAttribute((key), rs->attribute(key)); -Inkscape::XML::Node* SPGlyphKerning::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { - repr = xml_doc->createElement("svg:glyphkerning");//fix this! - } - - /* I am commenting out this part because I am not certain how does it work. I will have to study it later. Juca - repr->setAttribute("unicode", glyph->unicode); - repr->setAttribute("glyph-name", glyph->glyph_name); - repr->setAttribute("d", glyph->d); - sp_repr_set_svg_double(repr, "orientation", (double) glyph->orientation); - sp_repr_set_svg_double(repr, "arabic-form", (double) glyph->arabic_form); - repr->setAttribute("lang", glyph->lang); - sp_repr_set_svg_double(repr, "horiz-adv-x", glyph->horiz_adv_x); - sp_repr_set_svg_double(repr, "vert-origin-x", glyph->vert_origin_x); - sp_repr_set_svg_double(repr, "vert-origin-y", glyph->vert_origin_y); - sp_repr_set_svg_double(repr, "vert-adv-y", glyph->vert_adv_y); - */ - if (repr != this->getRepr()) { - // All the COPY_ATTR functions below use - // XML Tree directly, while they shouldn't. - COPY_ATTR(repr, this->getRepr(), "u1"); - COPY_ATTR(repr, this->getRepr(), "g1"); - COPY_ATTR(repr, this->getRepr(), "u2"); - COPY_ATTR(repr, this->getRepr(), "g2"); - COPY_ATTR(repr, this->getRepr(), "k"); - } - - SPObject::write(xml_doc, repr, flags); - - return repr; +Inkscape::XML::Node* SPGlyphKerning::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) +{ + if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { + repr = xml_doc->createElement("svg:glyphkerning"); // fix this! + } + + if (repr != this->getRepr()) { + // All the COPY_ATTR functions below use + // XML Tree directly, while they shouldn't. + COPY_ATTR(repr, this->getRepr(), "u1"); + COPY_ATTR(repr, this->getRepr(), "g1"); + COPY_ATTR(repr, this->getRepr(), "u2"); + COPY_ATTR(repr, this->getRepr(), "g2"); + COPY_ATTR(repr, this->getRepr(), "k"); + } + SPObject::write(xml_doc, repr, flags); + + return repr; } + /* Local Variables: mode:c++ diff --git a/src/sp-glyph-kerning.h b/src/sp-glyph-kerning.h index 5cae6b9dd..52413f8a7 100644 --- a/src/sp-glyph-kerning.h +++ b/src/sp-glyph-kerning.h @@ -1,10 +1,3 @@ -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - -#ifndef __SP_GLYPH_KERNING_H__ -#define __SP_GLYPH_KERNING_H__ - /* * SVG <hkern> and <vkern> elements implementation * @@ -16,41 +9,35 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#ifndef SEEN_SP_GLYPH_KERNING_H +#define SEEN_SP_GLYPH_KERNING_H + #include "sp-object.h" #include "unicoderange.h" -//#define SP_HKERN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_HKERN, SPHkern)) -//#define SP_HKERN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_HKERN, SPGlyphKerningClass)) -//#define SP_IS_HKERN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_HKERN)) -//#define SP_IS_HKERN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_HKERN)) +#define SP_HKERN(obj) (dynamic_cast<SPHkern*>(obj)) +#define SP_IS_HKERN(obj) (dynamic_cast<const SPHkern*>(obj) != NULL) -#define SP_HKERN(obj) (dynamic_cast<SPHkern*>((SPObject*)obj)) -#define SP_IS_HKERN(obj) (dynamic_cast<const SPHkern*>((SPObject*)obj) != NULL) - -//#define SP_VKERN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_VKERN, SPVkern)) -//#define SP_VKERN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_VKERN, SPGlyphKerningClass)) -//#define SP_IS_VKERN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_VKERN)) -//#define SP_IS_VKERN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_VKERN)) - -#define SP_VKERN(obj) (dynamic_cast<SPVkern*>((SPObject*)obj)) -#define SP_IS_VKERN(obj) (dynamic_cast<const SPVkern*>((SPObject*)obj) != NULL) +#define SP_VKERN(obj) (dynamic_cast<SPVkern*>(obj)) +#define SP_IS_VKERN(obj) (dynamic_cast<const SPVkern*>(obj) != NULL) // CPPIFY: These casting macros are buggy, as Vkern and Hkern aren't "real" classes. -class GlyphNames{ +class GlyphNames { public: -GlyphNames(const gchar* value); -~GlyphNames(); -bool contains(const char* name); + GlyphNames(const gchar* value); + ~GlyphNames(); + bool contains(const char* name); private: -gchar* names; + gchar* names; }; class SPGlyphKerning : public SPObject { public: - SPGlyphKerning(); - virtual ~SPGlyphKerning(); + SPGlyphKerning(); + virtual ~SPGlyphKerning() {} + // FIXME encapsulation UnicodeRange* u1; GlyphNames* g1; UnicodeRange* u2; @@ -58,22 +45,30 @@ public: double k; protected: - virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); - virtual void release(); - - virtual void set(unsigned int key, const gchar* value); - - virtual void update(SPCtx* ctx, unsigned int flags); - - virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); + virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); + virtual void release(); + virtual void set(unsigned int key, const gchar* value); + virtual void update(SPCtx* ctx, unsigned int flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); }; class SPHkern : public SPGlyphKerning { - + virtual ~SPHkern() {} }; class SPVkern : public SPGlyphKerning { - + virtual ~SPVkern() {} }; -#endif //#ifndef __SP_GLYPH_KERNING_H__ +#endif // !SEEN_SP_GLYPH_KERNING_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:fileencoding=utf-8 : diff --git a/src/sp-glyph.cpp b/src/sp-glyph.cpp index 695af03ba..eaa69d486 100644 --- a/src/sp-glyph.cpp +++ b/src/sp-glyph.cpp @@ -2,8 +2,6 @@ # include <config.h> #endif -#define __SP_GLYPH_C__ - /* * SVG <glyph> element implementation * @@ -25,46 +23,44 @@ #include "sp-factory.h" namespace { - SPObject* createGlyph() { - return new SPGlyph(); - } - - bool glyphRegistered = SPFactory::instance().registerObject("svg:glyph", createGlyph); + SPObject* createGlyph() { + return new SPGlyph(); + } + bool glyphRegistered = SPFactory::instance().registerObject("svg:glyph", createGlyph); } -SPGlyph::SPGlyph() : SPObject() { +SPGlyph::SPGlyph() + : SPObject() //TODO: correct these values: - - this->d = NULL; - this->orientation = GLYPH_ORIENTATION_BOTH; - this->arabic_form = GLYPH_ARABIC_FORM_INITIAL; - this->lang = NULL; - this->horiz_adv_x = 0; - this->vert_origin_x = 0; - this->vert_origin_y = 0; - this->vert_adv_y = 0; -} - -SPGlyph::~SPGlyph() { + , d(NULL) + , orientation(GLYPH_ORIENTATION_BOTH) + , arabic_form(GLYPH_ARABIC_FORM_INITIAL) + , lang(NULL) + , horiz_adv_x(0) + , vert_origin_x(0) + , vert_origin_y(0) + , vert_adv_y(0) +{ } -void SPGlyph::build(SPDocument *document, Inkscape::XML::Node *repr) { - SPObject::build(document, repr); +void SPGlyph::build(SPDocument *document, Inkscape::XML::Node *repr) +{ + SPObject::build(document, repr); - this->readAttr( "unicode" ); - this->readAttr( "glyph-name" ); - this->readAttr( "d" ); - this->readAttr( "orientation" ); - this->readAttr( "arabic-form" ); - this->readAttr( "lang" ); - this->readAttr( "horiz-adv-x" ); - this->readAttr( "vert-origin-x" ); - this->readAttr( "vert-origin-y" ); - this->readAttr( "vert-adv-y" ); + this->readAttr( "unicode" ); + this->readAttr( "glyph-name" ); + this->readAttr( "d" ); + this->readAttr( "orientation" ); + this->readAttr( "arabic-form" ); + this->readAttr( "lang" ); + this->readAttr( "horiz-adv-x" ); + this->readAttr( "vert-origin-x" ); + this->readAttr( "vert-origin-y" ); + this->readAttr( "vert-adv-y" ); } void SPGlyph::release() { - SPObject::release(); + SPObject::release(); } static glyphArabicForm sp_glyph_read_arabic_form(gchar const *value){ @@ -97,7 +93,8 @@ static glyphArabicForm sp_glyph_read_arabic_form(gchar const *value){ return GLYPH_ARABIC_FORM_INITIAL; //TODO: VERIFY DEFAULT! } -static glyphOrientation sp_glyph_read_orientation(gchar const *value){ +static glyphOrientation sp_glyph_read_orientation(gchar const *value) +{ if (!value) { return GLYPH_ORIENTATION_BOTH; } @@ -115,7 +112,8 @@ static glyphOrientation sp_glyph_read_orientation(gchar const *value){ return GLYPH_ORIENTATION_BOTH; } -void SPGlyph::set(unsigned int key, const gchar *value) { +void SPGlyph::set(unsigned int key, const gchar *value) +{ switch (key) { case SP_ATTR_UNICODE: { @@ -228,21 +226,22 @@ void SPGlyph::set(unsigned int key, const gchar *value) { } /** - * * Receives update notifications. - * */ -void SPGlyph::update(SPCtx *ctx, guint flags) { + * Receives update notifications. + */ +void SPGlyph::update(SPCtx *ctx, guint flags) +{ if (flags & SP_OBJECT_MODIFIED_FLAG) { /* do something to trigger redisplay, updates? */ - this->readAttr( "unicode" ); - this->readAttr( "glyph-name" ); - this->readAttr( "d" ); - this->readAttr( "orientation" ); - this->readAttr( "arabic-form" ); - this->readAttr( "lang" ); - this->readAttr( "horiz-adv-x" ); - this->readAttr( "vert-origin-x" ); - this->readAttr( "vert-origin-y" ); - this->readAttr( "vert-adv-y" ); + this->readAttr( "unicode" ); + this->readAttr( "glyph-name" ); + this->readAttr( "d" ); + this->readAttr( "orientation" ); + this->readAttr( "arabic-form" ); + this->readAttr( "lang" ); + this->readAttr( "horiz-adv-x" ); + this->readAttr( "vert-origin-x" ); + this->readAttr( "vert-origin-y" ); + this->readAttr( "vert-adv-y" ); } SPObject::update(ctx, flags); @@ -250,42 +249,45 @@ void SPGlyph::update(SPCtx *ctx, guint flags) { #define COPY_ATTR(rd,rs,key) (rd)->setAttribute((key), rs->attribute(key)); -Inkscape::XML::Node* SPGlyph::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { - repr = xml_doc->createElement("svg:glyph"); - } +Inkscape::XML::Node* SPGlyph::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) +{ + if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { + repr = xml_doc->createElement("svg:glyph"); + } - /* I am commenting out this part because I am not certain how does it work. I will have to study it later. Juca - repr->setAttribute("unicode", glyph->unicode); - repr->setAttribute("glyph-name", glyph->glyph_name); - repr->setAttribute("d", glyph->d); - sp_repr_set_svg_double(repr, "orientation", (double) glyph->orientation); - sp_repr_set_svg_double(repr, "arabic-form", (double) glyph->arabic_form); - repr->setAttribute("lang", glyph->lang); - sp_repr_set_svg_double(repr, "horiz-adv-x", glyph->horiz_adv_x); - sp_repr_set_svg_double(repr, "vert-origin-x", glyph->vert_origin_x); - sp_repr_set_svg_double(repr, "vert-origin-y", glyph->vert_origin_y); - sp_repr_set_svg_double(repr, "vert-adv-y", glyph->vert_adv_y); - */ - if (repr != this->getRepr()) { - // All the COPY_ATTR functions below use - // XML Tree directly while they shouldn't. - COPY_ATTR(repr, this->getRepr(), "unicode"); - COPY_ATTR(repr, this->getRepr(), "glyph-name"); - COPY_ATTR(repr, this->getRepr(), "d"); - COPY_ATTR(repr, this->getRepr(), "orientation"); - COPY_ATTR(repr, this->getRepr(), "arabic-form"); - COPY_ATTR(repr, this->getRepr(), "lang"); - COPY_ATTR(repr, this->getRepr(), "horiz-adv-x"); - COPY_ATTR(repr, this->getRepr(), "vert-origin-x"); - COPY_ATTR(repr, this->getRepr(), "vert-origin-y"); - COPY_ATTR(repr, this->getRepr(), "vert-adv-y"); - } + /* I am commenting out this part because I am not certain how does it work. I will have to study it later. Juca + repr->setAttribute("unicode", glyph->unicode); + repr->setAttribute("glyph-name", glyph->glyph_name); + repr->setAttribute("d", glyph->d); + sp_repr_set_svg_double(repr, "orientation", (double) glyph->orientation); + sp_repr_set_svg_double(repr, "arabic-form", (double) glyph->arabic_form); + repr->setAttribute("lang", glyph->lang); + sp_repr_set_svg_double(repr, "horiz-adv-x", glyph->horiz_adv_x); + sp_repr_set_svg_double(repr, "vert-origin-x", glyph->vert_origin_x); + sp_repr_set_svg_double(repr, "vert-origin-y", glyph->vert_origin_y); + sp_repr_set_svg_double(repr, "vert-adv-y", glyph->vert_adv_y); + */ - SPObject::write(xml_doc, repr, flags); + if (repr != this->getRepr()) { + // All the COPY_ATTR functions below use + // XML Tree directly while they shouldn't. + COPY_ATTR(repr, this->getRepr(), "unicode"); + COPY_ATTR(repr, this->getRepr(), "glyph-name"); + COPY_ATTR(repr, this->getRepr(), "d"); + COPY_ATTR(repr, this->getRepr(), "orientation"); + COPY_ATTR(repr, this->getRepr(), "arabic-form"); + COPY_ATTR(repr, this->getRepr(), "lang"); + COPY_ATTR(repr, this->getRepr(), "horiz-adv-x"); + COPY_ATTR(repr, this->getRepr(), "vert-origin-x"); + COPY_ATTR(repr, this->getRepr(), "vert-origin-y"); + COPY_ATTR(repr, this->getRepr(), "vert-adv-y"); + } - return repr; + SPObject::write(xml_doc, repr, flags); + + return repr; } + /* Local Variables: mode:c++ diff --git a/src/sp-glyph.h b/src/sp-glyph.h index 798d9ff2f..e92357c94 100644 --- a/src/sp-glyph.h +++ b/src/sp-glyph.h @@ -1,13 +1,4 @@ -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - -#ifndef __SP_GLYPH_H__ -#define __SP_GLYPH_H__ - -/* - * SVG <glyph> element implementation - * +/** * Authors: * Felipe C. da S. Sanches <juca@members.fsf.org> * @@ -16,6 +7,9 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#ifndef SEEN_SP_GLYPH_H +#define SEEN_SP_GLYPH_H + #include "sp-object.h" #define SP_GLYPH(obj) (dynamic_cast<SPGlyph*>((SPObject*)obj)) @@ -34,11 +28,16 @@ enum glyphOrientation { GLYPH_ORIENTATION_BOTH }; +/* + * SVG <glyph> element + */ + class SPGlyph : public SPObject { public: - SPGlyph(); - virtual ~SPGlyph(); + SPGlyph(); + virtual ~SPGlyph() {} + // FIXME encapsulation Glib::ustring unicode; Glib::ustring glyph_name; char* d; @@ -51,14 +50,23 @@ public: double vert_adv_y; protected: - virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); - virtual void release(); - - virtual void set(unsigned int key, const gchar* value); + virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); + virtual void release(); + virtual void set(unsigned int key, const gchar* value); + virtual void update(SPCtx* ctx, unsigned int flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); - virtual void update(SPCtx* ctx, unsigned int flags); - - virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); }; -#endif //#ifndef __SP_GLYPH_H__ +#endif // !SEEN_SP_GLYPH_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:fileencoding=utf-8 : diff --git a/src/svg/svg-length.cpp b/src/svg/svg-length.cpp index b9e8e6340..b9b475f4b 100644 --- a/src/svg/svg-length.cpp +++ b/src/svg/svg-length.cpp @@ -1,6 +1,4 @@ -#define __SP_SVG_LENGTH_C__ - -/* +/** * SVG data parser * * Authors: @@ -12,20 +10,15 @@ * This code is in public domain */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - +#include <cmath> #include <cstring> #include <string> -#include <math.h> #include <glib.h> #include "svg.h" #include "stringstream.h" #include "util/units.h" - static unsigned sp_svg_length_read_lff(gchar const *str, SVGLength::Unit *unit, float *val, float *computed, char **next); #ifndef MAX @@ -570,4 +563,4 @@ void SVGLength::readOrUnset(gchar const *str, Unit u, float v, float c) fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/svg/svg-length.h b/src/svg/svg-length.h index 477b3ef81..c34905d07 100644 --- a/src/svg/svg-length.h +++ b/src/svg/svg-length.h @@ -1,11 +1,4 @@ -#ifndef SEEN_SP_SVG_LENGTH_H -#define SEEN_SP_SVG_LENGTH_H - /** - * \file src/svg/svg-length.h - * \brief SVG length type - */ -/* * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * Carl Hetherington <inkscape@carlh.net> @@ -16,10 +9,13 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <glib.h> +#ifndef SEEN_SP_SVG_LENGTH_H +#define SEEN_SP_SVG_LENGTH_H -class SVGLength -{ +/** + * SVG length type + */ +class SVGLength { public: SVGLength(); @@ -57,9 +53,9 @@ public: return v; } - bool read(gchar const *str); - void readOrUnset(gchar const *str, Unit u = NONE, float v = 0, float c = 0); - bool readAbsolute(gchar const *str); + bool read(char const *str); + void readOrUnset(char const *str, Unit u = NONE, float v = 0, float c = 0); + bool readAbsolute(char const *str); void set(Unit u, float v, float c); void unset(Unit u = NONE, float v = 0, float c = 0); void update(double em, double ex, double scale); @@ -76,4 +72,4 @@ public: fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/svg/svg-path.cpp b/src/svg/svg-path.cpp index 59dad9ead..9ba3c0ebd 100644 --- a/src/svg/svg-path.cpp +++ b/src/svg/svg-path.cpp @@ -1,41 +1,25 @@ -#define __SP_SVG_PARSE_C__ /* - svg-path.c: Parse SVG path element data into bezier path. - - Copyright (C) 2000 Eazel, Inc. - Copyright (C) 2000 Lauris Kaplinski - Copyright (C) 2001 Ximian, Inc. - Copyright (C) 2008 Johan Engelen - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program; if not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Authors: - Johan Engelen - (old nartbpath code that has been deleted: Raph Levien <raph@artofcode.com>) - (old nartbpath code that has been deleted: Lauris Kaplinski <lauris@ximian.com>) -*/ + * svg-path.cpp: Parse SVG path element data into bezier path. + * Authors: + * Johan Engelen + * (old nartbpath code that has been deleted: Raph Levien <raph@artofcode.com>) + * (old nartbpath code that has been deleted: Lauris Kaplinski <lauris@ximian.com>) + * + * Copyright (C) 2000 Eazel, Inc. + * Copyright (C) 2000 Lauris Kaplinski + * Copyright (C) 2001 Ximian, Inc. + * Copyright (C) 2008 Johan Engelen + * + * Copyright (C) 2000-2008 authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ #include <cstring> #include <string> #include <cassert> #include <glib.h> // g_assert() -#include "svg/svg.h" -#include "svg/path-string.h" - #include <2geom/pathvector.h> #include <2geom/path.h> #include <2geom/curves.h> @@ -45,6 +29,9 @@ #include <2geom/exception.h> #include <2geom/angle.h> +#include "svg/svg.h" +#include "svg/path-string.h" + /* * Parses the path in str. When an error is found in the pathstring, this method * returns a truncated path up to where the error was found in the pathstring. @@ -150,4 +137,4 @@ gchar * sp_svg_write_path(Geom::Path const &p) { fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/uri-references.cpp b/src/uri-references.cpp index 6db2ed21f..b23bed74a 100644 --- a/src/uri-references.cpp +++ b/src/uri-references.cpp @@ -1,6 +1,4 @@ -#define __SP_URI_REFERENCES_C__ - -/* +/** * Helper methods for resolving URI References * * Authors: @@ -206,4 +204,4 @@ sp_uri_reference_resolve (SPDocument *document, const gchar *uri) fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/uri-references.h b/src/uri-references.h index 631d440da..f68fe70c4 100644 --- a/src/uri-references.h +++ b/src/uri-references.h @@ -62,7 +62,7 @@ public: * @param rel_document document for relative URIs * @param uri the URI to watch */ - void attach(const URI &uri) throw(BadURIException); + void attach(URI const& uri) throw(BadURIException); /** * Detaches from the currently attached URI target, if any; @@ -105,7 +105,7 @@ public: * * @returns the currently attached URI, or NULL */ - const URI *getURI() const { + URI const* getURI() const { return _uri; } @@ -140,7 +140,7 @@ private: void _setObject(SPObject *object); void _release(SPObject *object); - void operator=(const URIReference &ref); + void operator=(URIReference const& ref); /* Private and definition-less to prevent accidental use. */ }; @@ -164,4 +164,4 @@ SPObject *sp_uri_reference_resolve (SPDocument *document, const gchar *uri); fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp index a1bd9b792..04426e734 100644 --- a/src/widgets/button.cpp +++ b/src/widgets/button.cpp @@ -1,6 +1,4 @@ -#define __SP_BUTTON_C__ - -/* +/** * Generic button widget * * Authors: @@ -13,282 +11,255 @@ * This code is in public domain */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif +#include "button.h" +#include "helper/action-context.h" #include "icon.h" -#include "shortcuts.h" #include "interface.h" -#include "helper/action-context.h" +#include "shortcuts.h" #include <gdk/gdkkeysyms.h> -#include "button.h" - static void sp_button_dispose(GObject *object); -#if GTK_CHECK_VERSION(3,0,0) -static void sp_button_get_preferred_width(GtkWidget *widget, - gint *minimal_width, - gint *natural_width); +#if GTK_CHECK_VERSION(3, 0, 0) +static void sp_button_get_preferred_width(GtkWidget *widget, gint *minimal_width, gint *natural_width); -static void sp_button_get_preferred_height(GtkWidget *widget, - gint *minimal_height, - gint *natural_height); +static void sp_button_get_preferred_height(GtkWidget *widget, gint *minimal_height, gint *natural_height); #else -static void sp_button_size_request (GtkWidget *widget, GtkRequisition *requisition); +static void sp_button_size_request(GtkWidget *widget, GtkRequisition *requisition); #endif -static void sp_button_clicked (GtkButton *button); -static void sp_button_perform_action (SPButton *button, gpointer data); -static gint sp_button_process_event (SPButton *button, GdkEvent *event); +static void sp_button_clicked(GtkButton *button); +static void sp_button_perform_action(SPButton *button, gpointer data); +static gint sp_button_process_event(SPButton *button, GdkEvent *event); -static void sp_button_set_action (SPButton *button, SPAction *action); -static void sp_button_set_doubleclick_action (SPButton *button, SPAction *action); -static void sp_button_action_set_active (SPButton *button, bool active); -static void sp_button_set_composed_tooltip (GtkWidget *widget, SPAction *action); +static void sp_button_set_action(SPButton *button, SPAction *action); +static void sp_button_set_doubleclick_action(SPButton *button, SPAction *action); +static void sp_button_action_set_active(SPButton *button, bool active); +static void sp_button_set_composed_tooltip(GtkWidget *widget, SPAction *action); G_DEFINE_TYPE(SPButton, sp_button, GTK_TYPE_TOGGLE_BUTTON); -static void -sp_button_class_init (SPButtonClass *klass) +static void sp_button_class_init(SPButtonClass *klass) { - GObjectClass *object_class=G_OBJECT_CLASS(klass); - GtkWidgetClass *widget_class=GTK_WIDGET_CLASS(klass); - GtkButtonClass *button_class=GTK_BUTTON_CLASS(klass); - - object_class->dispose = sp_button_dispose; -#if GTK_CHECK_VERSION(3,0,0) - widget_class->get_preferred_width = sp_button_get_preferred_width; - widget_class->get_preferred_height = sp_button_get_preferred_height; + GObjectClass *object_class = G_OBJECT_CLASS(klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); + GtkButtonClass *button_class = GTK_BUTTON_CLASS(klass); + + object_class->dispose = sp_button_dispose; +#if GTK_CHECK_VERSION(3, 0, 0) + widget_class->get_preferred_width = sp_button_get_preferred_width; + widget_class->get_preferred_height = sp_button_get_preferred_height; #else - widget_class->size_request = sp_button_size_request; + widget_class->size_request = sp_button_size_request; #endif - button_class->clicked = sp_button_clicked; + button_class->clicked = sp_button_clicked; } -static void -sp_button_init (SPButton *button) +static void sp_button_init(SPButton *button) { - button->action = NULL; - button->doubleclick_action = NULL; - new (&button->c_set_active) sigc::connection(); - new (&button->c_set_sensitive) sigc::connection(); + button->action = NULL; + button->doubleclick_action = NULL; + new (&button->c_set_active) sigc::connection(); + new (&button->c_set_sensitive) sigc::connection(); - gtk_container_set_border_width (GTK_CONTAINER (button), 0); + gtk_container_set_border_width(GTK_CONTAINER(button), 0); - gtk_widget_set_can_focus (GTK_WIDGET (button), FALSE); - gtk_widget_set_can_default (GTK_WIDGET (button), FALSE); + gtk_widget_set_can_focus(GTK_WIDGET(button), FALSE); + gtk_widget_set_can_default(GTK_WIDGET(button), FALSE); - g_signal_connect_after (G_OBJECT (button), "clicked", G_CALLBACK (sp_button_perform_action), NULL); - g_signal_connect_after (G_OBJECT (button), "event", G_CALLBACK (sp_button_process_event), NULL); + g_signal_connect_after(G_OBJECT(button), "clicked", G_CALLBACK(sp_button_perform_action), NULL); + g_signal_connect_after(G_OBJECT(button), "event", G_CALLBACK(sp_button_process_event), NULL); } static void sp_button_dispose(GObject *object) { - SPButton *button = SP_BUTTON (object); + SPButton *button = SP_BUTTON(object); - if (button->action) { - sp_button_set_action (button, NULL); - } - if (button->doubleclick_action) { - sp_button_set_doubleclick_action (button, NULL); - } + if (button->action) { + sp_button_set_action(button, NULL); + } + if (button->doubleclick_action) { + sp_button_set_doubleclick_action(button, NULL); + } - button->c_set_active.~connection(); - button->c_set_sensitive.~connection(); + button->c_set_active.~connection(); + button->c_set_sensitive.~connection(); - (G_OBJECT_CLASS(sp_button_parent_class))->dispose(object); + (G_OBJECT_CLASS(sp_button_parent_class))->dispose(object); } - - -#if GTK_CHECK_VERSION(3,0,0) +#if GTK_CHECK_VERSION(3, 0, 0) static void sp_button_get_preferred_width(GtkWidget *widget, gint *minimal_width, gint *natural_width) { - GtkWidget *child = gtk_bin_get_child(GTK_BIN (widget)); - GtkStyle *style = gtk_widget_get_style(widget); - - if (child) { - gtk_widget_get_preferred_width(GTK_WIDGET(child), minimal_width, natural_width); - } else { - *minimal_width = 0; - *natural_width = 0; - } - - *minimal_width += 2 + 2 * MAX(2, style->xthickness); - *natural_width += 2 + 2 * MAX(2, style->xthickness); + GtkWidget *child = gtk_bin_get_child(GTK_BIN(widget)); + GtkStyle *style = gtk_widget_get_style(widget); + + if (child) { + gtk_widget_get_preferred_width(GTK_WIDGET(child), minimal_width, natural_width); + } else { + *minimal_width = 0; + *natural_width = 0; + } + + *minimal_width += 2 + 2 * MAX(2, style->xthickness); + *natural_width += 2 + 2 * MAX(2, style->xthickness); } static void sp_button_get_preferred_height(GtkWidget *widget, gint *minimal_height, gint *natural_height) { - GtkWidget *child = gtk_bin_get_child(GTK_BIN (widget)); - GtkStyle *style = gtk_widget_get_style(widget); - - if (child) { - gtk_widget_get_preferred_height(GTK_WIDGET(child), minimal_height, natural_height); - } else { - *minimal_height = 0; - *natural_height = 0; - } + GtkWidget *child = gtk_bin_get_child(GTK_BIN(widget)); + GtkStyle *style = gtk_widget_get_style(widget); - *minimal_height += 2 + 2 * MAX(2, style->ythickness); - *natural_height += 2 + 2 * MAX(2, style->ythickness); + if (child) { + gtk_widget_get_preferred_height(GTK_WIDGET(child), minimal_height, natural_height); + } else { + *minimal_height = 0; + *natural_height = 0; + } + *minimal_height += 2 + 2 * MAX(2, style->ythickness); + *natural_height += 2 + 2 * MAX(2, style->ythickness); } #else static void sp_button_size_request(GtkWidget *widget, GtkRequisition *requisition) { - GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget)); - GtkStyle *style = gtk_widget_get_style (widget); - - if (child) { - gtk_widget_size_request (GTK_WIDGET (child), requisition); - } else { - requisition->width = 0; - requisition->height = 0; - } - - requisition->width += 2 + 2 * MAX (2, style->xthickness); - requisition->height += 2 + 2 * MAX (2, style->ythickness); + GtkWidget *child = gtk_bin_get_child(GTK_BIN(widget)); + GtkStyle *style = gtk_widget_get_style(widget); + + if (child) { + gtk_widget_size_request(GTK_WIDGET(child), requisition); + } else { + requisition->width = 0; + requisition->height = 0; + } + + requisition->width += 2 + 2 * MAX(2, style->xthickness); + requisition->height += 2 + 2 * MAX(2, style->ythickness); } #endif -static void -sp_button_clicked (GtkButton *button) +static void sp_button_clicked(GtkButton *button) { - SPButton *sp_button=SP_BUTTON (button); + SPButton *sp_button = SP_BUTTON(button); - if (sp_button->type == SP_BUTTON_TYPE_TOGGLE) { - (GTK_BUTTON_CLASS(sp_button_parent_class))->clicked (button); - } + if (sp_button->type == SP_BUTTON_TYPE_TOGGLE) { + (GTK_BUTTON_CLASS(sp_button_parent_class))->clicked(button); + } } -static gint -sp_button_process_event (SPButton *button, GdkEvent *event) +static gint sp_button_process_event(SPButton *button, GdkEvent *event) { - switch (event->type) { - case GDK_2BUTTON_PRESS: - if (button->doubleclick_action) { - sp_action_perform (button->doubleclick_action, NULL); - } - return TRUE; - break; - default: - break; - } - - return FALSE; + switch (event->type) { + case GDK_2BUTTON_PRESS: + if (button->doubleclick_action) { + sp_action_perform(button->doubleclick_action, NULL); + } + return TRUE; + break; + default: + break; + } + + return FALSE; } -static void -sp_button_perform_action (SPButton *button, gpointer /*data*/) +static void sp_button_perform_action(SPButton *button, gpointer /*data*/) { - if (button->action) { - sp_action_perform (button->action, NULL); - } + if (button->action) { + sp_action_perform(button->action, NULL); + } } - -GtkWidget * -sp_button_new( Inkscape::IconSize size, SPButtonType type, SPAction *action, SPAction *doubleclick_action ) +GtkWidget *sp_button_new(Inkscape::IconSize size, SPButtonType type, SPAction *action, SPAction *doubleclick_action) { - SPButton *button = SP_BUTTON(g_object_new(SP_TYPE_BUTTON, NULL)); + SPButton *button = SP_BUTTON(g_object_new(SP_TYPE_BUTTON, NULL)); - button->type = type; - button->lsize = CLAMP( size, Inkscape::ICON_SIZE_MENU, Inkscape::ICON_SIZE_DECORATION ); + button->type = type; + button->lsize = CLAMP(size, Inkscape::ICON_SIZE_MENU, Inkscape::ICON_SIZE_DECORATION); - sp_button_set_action (button, action); - if (doubleclick_action) - sp_button_set_doubleclick_action (button, doubleclick_action); + sp_button_set_action(button, action); + if (doubleclick_action) + sp_button_set_doubleclick_action(button, doubleclick_action); - // The Inkscape style is no-relief buttons - gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE); + // The Inkscape style is no-relief buttons + gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); - return GTK_WIDGET(button); + return GTK_WIDGET(button); } -void -sp_button_toggle_set_down (SPButton *button, gboolean down) +void sp_button_toggle_set_down(SPButton *button, gboolean down) { - g_return_if_fail (button->type == SP_BUTTON_TYPE_TOGGLE); - g_signal_handlers_block_by_func (G_OBJECT (button), (gpointer)G_CALLBACK (sp_button_perform_action), NULL); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), (unsigned int)down); - g_signal_handlers_unblock_by_func (G_OBJECT (button), (gpointer)G_CALLBACK (sp_button_perform_action), NULL); + g_return_if_fail(button->type == SP_BUTTON_TYPE_TOGGLE); + g_signal_handlers_block_by_func(G_OBJECT(button), (gpointer)G_CALLBACK(sp_button_perform_action), NULL); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), (unsigned int)down); + g_signal_handlers_unblock_by_func(G_OBJECT(button), (gpointer)G_CALLBACK(sp_button_perform_action), NULL); } -static void -sp_button_set_doubleclick_action (SPButton *button, SPAction *action) +static void sp_button_set_doubleclick_action(SPButton *button, SPAction *action) { - if (button->doubleclick_action) { - g_object_unref (button->doubleclick_action); - } - button->doubleclick_action = action; - if (action) { - g_object_ref(action); - } - + if (button->doubleclick_action) { + g_object_unref(button->doubleclick_action); + } + button->doubleclick_action = action; + if (action) { + g_object_ref(action); + } } -static void -sp_button_set_action (SPButton *button, SPAction *action) +static void sp_button_set_action(SPButton *button, SPAction *action) { - GtkWidget *child; - - if (button->action) { - button->c_set_active.disconnect(); - button->c_set_sensitive.disconnect(); - child = gtk_bin_get_child (GTK_BIN (button)); - if (child) { - gtk_container_remove (GTK_CONTAINER (button), child); - } - g_object_unref(button->action); - } - button->action = action; - if (action) { - g_object_ref(action); - button->c_set_active = action->signal_set_active.connect( - sigc::bind<0>( - sigc::ptr_fun(&sp_button_action_set_active), - SP_BUTTON(button))); - button->c_set_sensitive = action->signal_set_sensitive.connect( - sigc::bind<0>( - sigc::ptr_fun(>k_widget_set_sensitive), - GTK_WIDGET(button))); - if (action->image) { - child = sp_icon_new (button->lsize, action->image); - gtk_widget_show (child); - gtk_container_add (GTK_CONTAINER (button), child); - } - } - - sp_button_set_composed_tooltip(GTK_WIDGET(button), action); + GtkWidget *child; + + if (button->action) { + button->c_set_active.disconnect(); + button->c_set_sensitive.disconnect(); + child = gtk_bin_get_child(GTK_BIN(button)); + if (child) { + gtk_container_remove(GTK_CONTAINER(button), child); + } + g_object_unref(button->action); + } + button->action = action; + if (action) { + g_object_ref(action); + button->c_set_active = action->signal_set_active.connect( + sigc::bind<0>(sigc::ptr_fun(&sp_button_action_set_active), SP_BUTTON(button))); + button->c_set_sensitive = action->signal_set_sensitive.connect( + sigc::bind<0>(sigc::ptr_fun(>k_widget_set_sensitive), GTK_WIDGET(button))); + if (action->image) { + child = sp_icon_new(button->lsize, action->image); + gtk_widget_show(child); + gtk_container_add(GTK_CONTAINER(button), child); + } + } + + sp_button_set_composed_tooltip(GTK_WIDGET(button), action); } -static void -sp_button_action_set_active (SPButton *button, bool active) +static void sp_button_action_set_active(SPButton *button, bool active) { - if (button->type != SP_BUTTON_TYPE_TOGGLE) { - return; - } - - /* temporarily lobotomized until SPActions are per-view */ - if (0 && !active != !SP_BUTTON_IS_DOWN (button)) { - sp_button_toggle_set_down (button, active); - } + if (button->type != SP_BUTTON_TYPE_TOGGLE) { + return; + } + + /* temporarily lobotomized until SPActions are per-view */ + if (0 && !active != !SP_BUTTON_IS_DOWN(button)) { + sp_button_toggle_set_down(button, active); + } } static void sp_button_set_composed_tooltip(GtkWidget *widget, SPAction *action) { if (action) { - unsigned int shortcut = sp_shortcut_get_primary (action->verb); + unsigned int shortcut = sp_shortcut_get_primary(action->verb); if (shortcut != GDK_KEY_VoidSymbol) { // there's both action and shortcut gchar *key = sp_shortcut_get_label(shortcut); - gchar *tip = g_strdup_printf ("%s (%s)", action->tip, key); + gchar *tip = g_strdup_printf("%s (%s)", action->tip, key); gtk_widget_set_tooltip_text(widget, tip); g_free(tip); g_free(key); @@ -302,18 +273,14 @@ static void sp_button_set_composed_tooltip(GtkWidget *widget, SPAction *action) } } -GtkWidget * -sp_button_new_from_data( Inkscape::IconSize size, - SPButtonType type, - Inkscape::UI::View::View *view, - const gchar *name, - const gchar *tip ) +GtkWidget *sp_button_new_from_data(Inkscape::IconSize size, SPButtonType type, Inkscape::UI::View::View *view, + const gchar *name, const gchar *tip) { - GtkWidget *button; - SPAction *action=sp_action_new(Inkscape::ActionContext(view), name, name, tip, name, 0); - button = sp_button_new (size, type, action, NULL); - g_object_unref(action); - return button; + GtkWidget *button; + SPAction *action = sp_action_new(Inkscape::ActionContext(view), name, name, tip, name, 0); + button = sp_button_new(size, type, action, NULL); + g_object_unref(action); + return button; } /* @@ -325,4 +292,4 @@ sp_button_new_from_data( Inkscape::IconSize size, fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/widgets/button.h b/src/widgets/button.h index 41863357d..d5e29da1a 100644 --- a/src/widgets/button.h +++ b/src/widgets/button.h @@ -1,7 +1,7 @@ -#ifndef __SP_BUTTON_H__ -#define __SP_BUTTON_H__ +#ifndef SEEN_SP_BUTTON_H +#define SEEN_SP_BUTTON_H -/* +/** * Generic button widget * * Author: @@ -61,6 +61,15 @@ GtkWidget *sp_button_new_from_data (Inkscape::IconSize size, const gchar *name, const gchar *tip); +#endif // !SEEN_SP_BUTTON_H - -#endif +/* + 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:fileencoding=utf-8 : diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp index 327349844..d4a174a0d 100644 --- a/src/widgets/font-selector.cpp +++ b/src/widgets/font-selector.cpp @@ -1,6 +1,4 @@ -#define __SP_FONT_SELECTOR_C__ - -/* +/** * Font selection widgets * * Authors: @@ -554,4 +552,4 @@ double sp_font_selector_get_size(SPFontSelector *fsel) fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/widgets/font-selector.h b/src/widgets/font-selector.h index 66715f048..ff5472d2d 100644 --- a/src/widgets/font-selector.h +++ b/src/widgets/font-selector.h @@ -54,7 +54,7 @@ Glib::ustring sp_font_selector_get_fontspec (SPFontSelector *fsel); double sp_font_selector_get_size (SPFontSelector *fsel); -#endif // SP_FONT_SELECTOR_H +#endif // !SP_FONT_SELECTOR_H /* Local Variables: @@ -65,4 +65,4 @@ double sp_font_selector_get_size (SPFontSelector *fsel); fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/widgets/gradient-image.cpp b/src/widgets/gradient-image.cpp index 64b058f62..2e2c5423b 100644 --- a/src/widgets/gradient-image.cpp +++ b/src/widgets/gradient-image.cpp @@ -1,6 +1,4 @@ -#define __SP_GRADIENT_IMAGE_C__ - -/* +/** * A simple gradient preview * * Author: @@ -12,14 +10,13 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "macros.h" +#include <sigc++/signal.h> + #include "display/cairo-utils.h" #include "gradient-image.h" +#include "macros.h" #include "sp-gradient.h" -#include <sigc++/functors/ptr_fun.h> -#include <sigc++/adaptors/bind.h> - #define VBLOCK 16 static void sp_gradient_image_class_init (SPGradientImageClass *klass); @@ -269,3 +266,14 @@ sp_gradient_image_update (SPGradientImage *image) gtk_widget_queue_draw (GTK_WIDGET (image)); } } + +/* + 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:fileencoding=utf-8 : diff --git a/src/widgets/gradient-image.h b/src/widgets/gradient-image.h index 904ce4cac..cd7e0ed70 100644 --- a/src/widgets/gradient-image.h +++ b/src/widgets/gradient-image.h @@ -1,7 +1,7 @@ -#ifndef __SP_GRADIENT_IMAGE_H__ -#define __SP_GRADIENT_IMAGE_H__ +#ifndef SEEN_SP_GRADIENT_IMAGE_H +#define SEEN_SP_GRADIENT_IMAGE_H -/* +/** * A simple gradient preview * * Author: @@ -29,15 +29,15 @@ class SPGradient; #define SP_IS_GRADIENT_IMAGE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SP_TYPE_GRADIENT_IMAGE)) struct SPGradientImage { - GtkWidget widget; - SPGradient *gradient; + GtkWidget widget; + SPGradient *gradient; - sigc::connection release_connection; - sigc::connection modified_connection; + sigc::connection release_connection; + sigc::connection modified_connection; }; struct SPGradientImageClass { - GtkWidgetClass parent_class; + GtkWidgetClass parent_class; }; GType sp_gradient_image_get_type (void); @@ -47,3 +47,14 @@ GdkPixbuf *sp_gradient_to_pixbuf (SPGradient *gr, int width, int height); void sp_gradient_image_set_gradient (SPGradientImage *gi, SPGradient *gr); #endif + +/* + 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:fileencoding=utf-8 : diff --git a/src/widgets/sp-xmlview-tree.cpp b/src/widgets/sp-xmlview-tree.cpp index 43b7dc289..9b3775a34 100644 --- a/src/widgets/sp-xmlview-tree.cpp +++ b/src/widgets/sp-xmlview-tree.cpp @@ -1,6 +1,4 @@ -#define __SP_XMLVIEW_TREE_C__ - -/* +/** * Specialization of GtkTreeView for the XML tree view * * Authors: @@ -14,7 +12,7 @@ #include <cstring> #include <string> -#include "../xml/node-event-vector.h" +#include "xml/node-event-vector.h" #include "sp-xmlview-tree.h" struct NodeData { @@ -734,4 +732,4 @@ gboolean search_equal_func(GtkTreeModel *model, gint /*column*/, const gchar *ke fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/widgets/sp-xmlview-tree.h b/src/widgets/sp-xmlview-tree.h index 69228fa88..7ecbcb471 100644 --- a/src/widgets/sp-xmlview-tree.h +++ b/src/widgets/sp-xmlview-tree.h @@ -1,9 +1,4 @@ -#ifndef __SP_XMLVIEW_TREE_H__ -#define __SP_XMLVIEW_TREE_H__ - -/* - * Specialization of GtkTreeView for the XML editor - * +/** * Authors: * MenTaLguY <mental@rydia.net> * @@ -12,9 +7,15 @@ * Released under the GNU GPL; see COPYING for details */ +#ifndef SEEN_SP_XMLVIEW_TREE_H +#define SEEN_SP_XMLVIEW_TREE_H + #include <gtk/gtk.h> #include <glib.h> +/** + * Specialization of GtkTreeView for the XML editor + */ #define SP_TYPE_XMLVIEW_TREE (sp_xmlview_tree_get_type ()) #define SP_XMLVIEW_TREE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_XMLVIEW_TREE, SPXMLViewTree)) @@ -49,7 +50,7 @@ Inkscape::XML::Node * sp_xmlview_tree_node_get_repr (GtkTreeModel *model, GtkTre gboolean sp_xmlview_tree_get_repr_node (SPXMLViewTree * tree, Inkscape::XML::Node * repr, GtkTreeIter *node); -#endif +#endif // !SEEN_SP_XMLVIEW_TREE_H /* Local Variables: @@ -60,4 +61,4 @@ gboolean sp_xmlview_tree_get_repr_node (SPXMLViewTree * tree, Inkscape::XML::Nod fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : |
