Code

remove warnings
[inkscape.git] / src / extension / extension.cpp
index 4aac7780af88a955335a163c6a1e35d0dad6d921..bffdc2595a187ef1d54cf84262e11a4c83e4c2f3 100644 (file)
@@ -23,6 +23,9 @@
 
 #include <glibmm/i18n.h>
 #include <gtkmm/box.h>
+#include <gtkmm/label.h>
+#include <gtkmm/frame.h>
+#include <gtkmm/table.h>
 
 #include "inkscape.h"
 #include "extension/implementation/implementation.h"
@@ -53,7 +56,7 @@ Parameter * param_shared (const gchar * name, GSList * list);
     not related to the module directly.  If the Repr does not include
     a name and an ID the module will be left in an errored state.
 */
-Extension::Extension (Inkscape::XML::Node * in_repr, Implementation::Implementation * in_imp)
+Extension::Extension (Inkscape::XML::Node * in_repr, Implementation::Implementation * in_imp) : _help(NULL)
 {
     repr = in_repr;
     Inkscape::GC::anchor(in_repr);
@@ -84,6 +87,9 @@ Extension::Extension (Inkscape::XML::Node * in_repr, Implementation::Implementat
             if (!strcmp(chname, "name")) {
                 name = g_strdup (sp_repr_children(child_repr)->content());
             } /* name */
+            if (!strcmp(chname, "help")) {
+                _help = g_strdup (sp_repr_children(child_repr)->content());
+            } /* name */
             if (!strcmp(chname, "param")) {
                                Parameter * param;
                                param = Parameter::make(child_repr, this);
@@ -274,7 +280,7 @@ void
 Extension::printFailure (Glib::ustring reason)
 {
        error_file << _("Extension \"") << name << _("\" failed to load because ");
-       error_file << reason;
+       error_file << reason.raw();
        error_file << std::endl;
        return;
 }
@@ -313,7 +319,7 @@ Extension::get_name (void)
     \return  None
        \brief   This function diactivates the extension (which makes it
                 unusable, but not deleted)
-       
+
     This function is used to removed an extension from functioning, but
        not delete it completely.  It sets the state to \c STATE_DEACTIVATED to
        mark to the world that it has been deactivated.  It also removes
@@ -377,7 +383,7 @@ Parameter *
 param_shared (const gchar * name, GSList * list)
 {
     Parameter * output;
-    
+
     if (name == NULL) {
         throw Extension::param_not_exist();
     }
@@ -407,7 +413,7 @@ const gchar *
 Extension::get_param_string (const gchar * name, const Inkscape::XML::Document * doc)
 {
     Parameter * param;
-    
+
     param = param_shared(name, parameters);
        return param->get_string(doc);
 }
@@ -426,7 +432,7 @@ bool
 Extension::get_param_bool (const gchar * name, const Inkscape::XML::Document * doc)
 {
     Parameter * param;
-    
+
     param = param_shared(name, parameters);
     return param->get_bool(doc);
 }
@@ -445,7 +451,7 @@ int
 Extension::get_param_int (const gchar * name, const Inkscape::XML::Document * doc)
 {
     Parameter * param;
-    
+
     param = param_shared(name, parameters);
     return param->get_int(doc);
 }
@@ -553,7 +559,7 @@ Extension::error_file_open (void)
        error_file.open(filename);
        if (!error_file.is_open()) {
                g_warning(_("Could not create extension error log file '%s'"),
-                         filename);    
+                         filename);
        }
        g_free(filename);
        g_free(ext_error_file);
@@ -621,6 +627,78 @@ Extension::paramString (void)
        return param_string;
 }
 
+/* Extension editor dialog stuff */
+
+Gtk::VBox *
+Extension::get_info_widget(void)
+{
+    Gtk::VBox * retval = Gtk::manage(new Gtk::VBox());
+
+    Gtk::Frame * info = Gtk::manage(new Gtk::Frame("General Extension Information"));
+    retval->pack_start(*info, true, true, 5);
+
+    Gtk::Table * table = Gtk::manage(new Gtk::Table());
+    info->add(*table);
+
+    int row = 0;
+    add_val(_("Name:"), _(name), table, &row);
+    add_val(_("ID:"), id, table, &row);
+    add_val(_("State:"), _state == STATE_LOADED ? _("Loaded") : _state == STATE_UNLOADED ? _("Unloaded") : _("Deactivated"), table, &row);
+
+
+    retval->show_all();
+    return retval;
+}
+
+void
+Extension::add_val(Glib::ustring labelstr, Glib::ustring valuestr, Gtk::Table * table, int * row)
+{
+    Gtk::Label * label;
+    Gtk::Label * value;
+
+    (*row)++; 
+    label = Gtk::manage(new Gtk::Label(labelstr));
+    value = Gtk::manage(new Gtk::Label(valuestr));
+    table->attach(*label, 0, 1, (*row) - 1, *row);
+    table->attach(*value, 1, 2, (*row) - 1, *row);
+
+    label->show();
+    value->show();
+
+    return;
+}
+
+Gtk::VBox *
+Extension::get_help_widget(void)
+{
+    Gtk::VBox * retval = Gtk::manage(new Gtk::VBox());
+
+    if (_help == NULL) {
+        Gtk::Label * content = Gtk::manage(new Gtk::Label("Currently there is no help available for this Extension.  Please look on the Inkscape website or ask on the mailing lists if you have questions regarding this extension."));
+        retval->pack_start(*content, true, true, 5);
+        content->set_line_wrap(true);
+        content->show();
+    } else {
+
+
+
+    }
+
+    retval->show();
+    return retval;
+}
+
+Gtk::VBox *
+Extension::get_params_widget(void)
+{
+    Gtk::VBox * retval = Gtk::manage(new Gtk::VBox());
+    Gtk::Widget * content = Gtk::manage(new Gtk::Label("Params"));
+    retval->pack_start(*content, true, true, 5);
+    content->show();
+    retval->show();
+    return retval;
+}
+
 }  /* namespace Extension */
 }  /* namespace Inkscape */