From: gouldtj Date: Tue, 2 May 2006 05:26:00 +0000 (+0000) Subject: r11466@tres: ted | 2006-04-19 21:27:49 -0700 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=e0fce6fec3bdf991587ebb3a36c91f0c9ce76f2e;p=inkscape.git r11466@tres: ted | 2006-04-19 21:27:49 -0700 Moving the auto gui stuff into it's own class that subclasses from VBox. This should make adding tooltips easier... --- diff --git a/src/extension/extension.cpp b/src/extension/extension.cpp index e41990a1c..79f063591 100644 --- a/src/extension/extension.cpp +++ b/src/extension/extension.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include "inkscape.h" #include "extension/implementation/implementation.h" @@ -580,6 +581,31 @@ Extension::error_file_close (void) error_file.close(); }; +/** \brief A widget to represent the inside of an AutoGUI widget */ +class AutoGUI : public Gtk::VBox { + Gtk::Tooltips _tooltips; +public: + /** \brief Create an AutoGUI object */ + AutoGUI (void) : Gtk::VBox() {}; + /** \brief Adds a widget with a tool tip into the autogui + \param widg Widget to add + \param tooltip Tooltip for the widget + + If there is no widget, nothing happens. Otherwise it is just + added into the VBox. If there is a tooltip (non-NULL) then it + is placed on the widget. + */ + void addWidget (Gtk::Widget * widg, gchar const * tooltip) { + if (widg == NULL) return; + this->pack_start(*widg, true, true); + if (tooltip != NULL) { + _tooltips.set_tip(*widg, Glib::ustring(tooltip)); + // printf("Setting tooltip: %s\n", tooltip); + } + return; + }; +}; + /** \brief A function to automatically generate a GUI using the parameters \return Generated widget @@ -594,17 +620,17 @@ Extension::autogui (void) { if (g_slist_length(parameters) == 0) return NULL; - Gtk::VBox * vbox = Gtk::manage(new Gtk::VBox()); + AutoGUI * agui = Gtk::manage(new AutoGUI()); for (GSList * list = parameters; list != NULL; list = g_slist_next(list)) { Parameter * param = reinterpret_cast(list->data); Gtk::Widget * widg = param->get_widget(); - if (widg != NULL) - vbox->pack_start(*widg, true, true); + gchar const * tip = param->get_tooltip(); + agui->addWidget(widg, tip); } - vbox->show(); - return vbox; + agui->show(); + return agui; }; /**