Code

Extensions. General UI improvements (gnome HIG). New group header extension parameter.
authorJazzyNico <nicoduf@yahoo.fr>
Tue, 7 Sep 2010 21:11:53 +0000 (23:11 +0200)
committerJazzyNico <nicoduf@yahoo.fr>
Tue, 7 Sep 2010 21:11:53 +0000 (23:11 +0200)
src/extension/Makefile_insert
src/extension/extension.cpp
src/extension/param/CMakeLists.txt
src/extension/param/bool.cpp
src/extension/param/description.cpp
src/extension/param/groupheader.cpp [new file with mode: 0755]
src/extension/param/groupheader.h [new file with mode: 0755]
src/extension/param/notebook.cpp
src/extension/param/parameter.cpp

index 1965dfa9aa86aeedd21c698e5695ebe2de109891..b9ce224cacd267a42fd1cfc24e51aab3f309d205 100644 (file)
@@ -1,53 +1,55 @@
 ## Makefile.am fragment sourced by src/Makefile.am.
 
 ink_common_sources +=  \
-       extension/extension.cpp \
-       extension/extension.h   \
-       extension/extension-forward.h   \
-       extension/db.cpp        \
-       extension/db.h  \
-       extension/dependency.cpp \
-       extension/dependency.h \
-       extension/error-file.cpp \
-       extension/error-file.h \
-       extension/execution-env.cpp \
-       extension/execution-env.h \
-       extension/init.cpp      \
-       extension/init.h        \
-       extension/param/parameter.h \
-       extension/param/parameter.cpp \
-       extension/param/notebook.h \
-       extension/param/notebook.cpp \
-       extension/param/bool.h \
-       extension/param/bool.cpp \
-       extension/param/color.h \
-       extension/param/color.cpp \
-       extension/param/description.h \
-       extension/param/description.cpp \
-       extension/param/enum.h \
-       extension/param/enum.cpp \
-       extension/param/float.h \
-       extension/param/float.cpp \
-       extension/param/int.h \
-       extension/param/int.cpp \
-       extension/param/radiobutton.h \
-       extension/param/radiobutton.cpp \
-       extension/param/string.h \
-       extension/param/string.cpp \
-       extension/prefdialog.cpp \
-       extension/prefdialog.h \
-       extension/system.cpp    \
-       extension/system.h \
-       extension/timer.cpp \
-       extension/timer.h \
-       extension/input.h \
-       extension/input.cpp \
-       extension/output.h \
-       extension/output.cpp \
-       extension/effect.h \
-       extension/effect.cpp \
-       extension/patheffect.h \
-       extension/patheffect.cpp \
-       extension/print.h \
-       extension/print.cpp
+    extension/extension.cpp    \
+    extension/extension.h      \
+    extension/extension-forward.h      \
+    extension/db.cpp   \
+    extension/db.h     \
+    extension/dependency.cpp \
+    extension/dependency.h \
+    extension/error-file.cpp \
+    extension/error-file.h \
+    extension/execution-env.cpp \
+    extension/execution-env.h \
+    extension/init.cpp \
+    extension/init.h   \
+    extension/param/parameter.h \
+    extension/param/parameter.cpp \
+    extension/param/notebook.h \
+    extension/param/notebook.cpp \
+    extension/param/bool.h \
+    extension/param/bool.cpp \
+    extension/param/color.h \
+    extension/param/color.cpp \
+    extension/param/description.h \
+    extension/param/description.cpp \
+    extension/param/groupheader.h \
+    extension/param/groupheader.cpp \
+    extension/param/enum.h \
+    extension/param/enum.cpp \
+    extension/param/float.h \
+    extension/param/float.cpp \
+    extension/param/int.h \
+    extension/param/int.cpp \
+    extension/param/radiobutton.h \
+    extension/param/radiobutton.cpp \
+    extension/param/string.h \
+    extension/param/string.cpp \
+    extension/prefdialog.cpp \
+    extension/prefdialog.h \
+    extension/system.cpp       \
+    extension/system.h \
+    extension/timer.cpp \
+    extension/timer.h \
+    extension/input.h \
+    extension/input.cpp \
+    extension/output.h \
+    extension/output.cpp \
+    extension/effect.h \
+    extension/effect.cpp \
+    extension/patheffect.h \
+    extension/patheffect.cpp \
+    extension/print.h \
+    extension/print.cpp
 
index 3aed5a23385c96fd89a7c017c339d50983019966..caed62735d1da0a4797b4b05ce4467e194f6b691 100644 (file)
@@ -669,7 +669,7 @@ public:
     */
     void addWidget (Gtk::Widget * widg, gchar const * tooltip) {
         if (widg == NULL) return;
-        this->pack_start(*widg, true, true, 2);
+        this->pack_start(*widg, false, false, 2);
         if (tooltip != NULL) {
             _tooltips.set_tip(*widg, Glib::ustring(_(tooltip)));
         }
index 843de8b7a4512430952493dbf5f66dfe16dfaff9..2ef5d5005b7f6adf8d023c8d5851f265467db62f 100644 (file)
@@ -2,6 +2,7 @@ SET(extension_param_SRC
 bool.cpp
 color.cpp
 description.cpp
+groupheader.cpp
 enum.cpp
 parameter.cpp
 float.cpp
index 1dda3d73f82e4dea77009e5e1b839ac05b25056f..299d8ffd19b1b4e487101a03846600c2b8ee6b3e 100644 (file)
@@ -139,9 +139,9 @@ ParamBool::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signa
 
     Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_LEFT));
     label->show();
-    hbox->pack_start(*label, true, true);
+    hbox->pack_end(*label, true, true);
 
-    ParamBoolCheckButton * checkbox = new ParamBoolCheckButton(this, doc, node, changeSignal);
+    ParamBoolCheckButton * checkbox = Gtk::manage(new ParamBoolCheckButton(this, doc, node, changeSignal));
     checkbox->show();
     hbox->pack_start(*checkbox, false, false);
 
index 656e58c491cc53ea0fcd8fa7183cbbcb8adfc610..d73439414498ba341cdc10c6a6e38943a55c7cd6 100644 (file)
@@ -50,12 +50,12 @@ ParamDescription::get_widget (SPDocument * /*doc*/, Inkscape::XML::Node * /*node
 {
        if (_gui_hidden) return NULL;
 
-    Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_value)));
+    Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_value), Gtk::ALIGN_LEFT));
     label->set_line_wrap();
     label->show();
 
     Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4));
-    hbox->pack_start(*label, true, true, 5);
+    hbox->pack_start(*label, true, true, 12);
     hbox->show();
 
     return hbox;
diff --git a/src/extension/param/groupheader.cpp b/src/extension/param/groupheader.cpp
new file mode 100755 (executable)
index 0000000..8bdb7f3
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2005-2010 Authors:
+ *   Ted Gould <ted@gould.cx>
+ *   Johan Engelen <johan@shouraizou.nl> *
+ *   Nicolas Dufour <nicoduf@yahoo.fr>
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#ifdef linux  // does the dollar sign need escaping when passed as string parameter?
+# define ESCAPE_DOLLAR_COMMANDLINE
+#endif
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+
+#include "groupheader.h"
+
+#include <gtkmm/adjustment.h>
+#include <gtkmm/box.h>
+#include <gtkmm/spinbutton.h>
+#include <sstream>
+#include <glibmm/i18n.h>
+
+#include "xml/node.h"
+#include "extension/extension.h"
+
+namespace Inkscape {
+namespace Extension {
+
+
+/** \brief  Initialize the object, to do that, copy the data. */
+ParamGroupHeader::ParamGroupHeader (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) :
+    Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), _value(NULL)
+{
+    // printf("Building GroupHeader\n");
+    const char * defaultval = NULL;
+    if (sp_repr_children(xml) != NULL)
+        defaultval = sp_repr_children(xml)->content();
+
+    if (defaultval != NULL)
+        _value = g_strdup(defaultval);
+
+    return;
+}
+
+/** \brief  Create a label for the GroupHeader */
+Gtk::Widget *
+ParamGroupHeader::get_widget (SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/, sigc::signal<void> * /*changeSignal*/)
+{
+       if (_gui_hidden) return NULL;
+
+    Gtk::Label * label = Gtk::manage(new Gtk::Label(Glib::ustring("<b>") + _(_value) + Glib::ustring("</b>"), Gtk::ALIGN_LEFT));
+    label->set_line_wrap();
+    label->set_padding(0,5);
+    label->set_use_markup(true);
+    label->show();
+
+    Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4));
+    hbox->pack_start(*label, true, true);
+    hbox->show();
+
+    return hbox;
+}
+
+}  /* namespace Extension */
+}  /* namespace Inkscape */
diff --git a/src/extension/param/groupheader.h b/src/extension/param/groupheader.h
new file mode 100755 (executable)
index 0000000..92908ca
--- /dev/null
@@ -0,0 +1,44 @@
+#ifndef __INK_EXTENSION_PARAMGROUPHEADER_H__
+#define __INK_EXTENSION_PARAMGROUPHEADER_H__
+
+/*
+ * Copyright (C) 2005-2010 Authors:
+ *   Ted Gould <ted@gould.cx>
+ *   Johan Engelen <johan@shouraizou.nl> *
+ *   Nicolas Dufour <nicoduf@yahoo.fr>
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include <gtkmm/widget.h>
+#include <xml/node.h>
+#include <document.h>
+#include "parameter.h"
+
+namespace Inkscape {
+namespace Extension {
+
+/** \brief  A GroupLabel parameter */
+class ParamGroupHeader : public Parameter {
+private:
+    /** \brief  Internal value. */
+    gchar * _value;
+public:
+    ParamGroupHeader(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
+    Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
+};
+
+}  /* namespace Extension */
+}  /* namespace Inkscape */
+
+#endif /* __INK_EXTENSION_PARAMGROUPHEADER_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 :
index 1c30b7e0e82ac04acbd8b2e66dc4c8a70d418293..50cef0db7a2d167a9152afed896154bf8ba1365c 100644 (file)
@@ -210,8 +210,8 @@ ParamNotebookPage::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sig
         Parameter * param = reinterpret_cast<Parameter *>(list->data);
         Gtk::Widget * widg = param->get_widget(doc, node, changeSignal);
         gchar const * tip = param->get_tooltip();
-
-        vbox->pack_start(*widg, true, true, 2);
+//        printf("Tip: '%s'\n", tip);
+        vbox->pack_start(*widg, false, false, 2);
         if (tip != NULL) {
             _tooltips->set_tip(*widg, Glib::ustring(tip));
         }
index 3320cddcac2fd2ea8047d1563fa75b0bcf476ce1..91d614b93f4e3c9eaac85c01e59fc310119f4c0a 100644 (file)
@@ -35,6 +35,7 @@
 #include "bool.h"
 #include "color.h"
 #include "description.h"
+#include "groupheader.h"
 #include "enum.h"
 #include "float.h"
 #include "int.h"
@@ -134,6 +135,8 @@ Parameter::make (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension *
         }
     } else if (!strcmp(type, "description")) {
         param = new ParamDescription(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr);
+    } else if (!strcmp(type, "groupheader")) {
+        param = new ParamGroupHeader(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr);        
     } else if (!strcmp(type, "enum")) {
         param = new ParamComboBox(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr);
     } else if (!strcmp(type, "notebook")) {
@@ -294,7 +297,7 @@ Parameter::Parameter (const gchar * name, const gchar * guitext, const gchar * d
     }
     if (desc != NULL) {
         _desc = g_strdup(desc);
-        // printf("Adding description: '%s' on '%s'\n", _desc, _name);
+//        printf("Adding description: '%s' on '%s'\n", _desc, _name);
     }
     if (gui_tip != NULL) {
         _gui_tip = g_strdup(gui_tip);
@@ -315,6 +318,7 @@ Parameter::~Parameter (void)
     g_free(_name);
     g_free(_text);
        g_free(_gui_tip);
+    g_free(_desc);
 }
 
 /** \brief  Build the name to write the parameter from the extension's