From d8d953490f50942012c33dee60401e0629a4ca13 Mon Sep 17 00:00:00 2001 From: rwst Date: Tue, 17 Jan 2006 09:51:29 +0000 Subject: [PATCH] applying patch #1407697 by Marco Scholten --- AUTHORS | 1 + ChangeLog | 9 +++ src/ui/dialog/inkscape-preferences.cpp | 82 ++++++++++++++++++-------- src/ui/dialog/inkscape-preferences.h | 1 - src/ui/widget/preferences-widget.cpp | 5 ++ src/ui/widget/preferences-widget.h | 1 + 6 files changed, 73 insertions(+), 26 deletions(-) diff --git a/AUTHORS b/AUTHORS index 832676b60..952c2b502 100644 --- a/AUTHORS +++ b/AUTHORS @@ -60,6 +60,7 @@ Frederic Rodrigo Juarez Rudsatz Xavier Conde Rueda Christian Schaller +Marco Scholten Tom von Schwerdtner Shivaken Boštjan Špetič diff --git a/ChangeLog b/ChangeLog index 57233d473..bc0b8a9ee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2006-01-15 Marco Scholten + + * /src/ui/dialog/inkscape-preferences.cpp + Added style swatches, + Changed Gtk::Requisition Gtk::Widget::size_request() to + void Gtk::Widget::size_request(const Requisition& requisition) + * /src/ui/dialog/preferences-widget.cpp & .h + Added DialogPage::set_tip() + 2006-01-17 Michael Wybrow * packaging/osx-app.sh, packaging/macosx/Resources/etc/fonts/fonts.conf: diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index addbcf39f..c22e1a4b6 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -16,6 +16,7 @@ #include #include +#include #include "prefs-utils.h" #include "inkscape-preferences.h" @@ -30,6 +31,7 @@ #include "selection.h" #include "selection-chemistry.h" #include "xml/repr.h" +#include "ui/widget/style-swatch.h" namespace Inkscape { namespace UI { @@ -46,7 +48,9 @@ InkscapePreferences::InkscapePreferences() sb->set_width_chars(6); this->get_vbox()->add(*sb); this->show_all_children(); - _sb_width = sb->size_request().width; + Gtk:: Requisition sreq; + sb->size_request(sreq); + _sb_width = sreq.width; this->get_vbox()->remove(*sb); delete sb; @@ -203,28 +207,7 @@ void InkscapePreferences::AddGradientCheckbox(DialogPage& p, const std::string& p.add_line( false, "", *cb, "", _("Whether selected objects display gradient editing controls")); } -void InkscapePreferences::AddNewObjectsStyle(DialogPage& p, const std::string& prefs_path) -{ - PrefRadioButton* current = Gtk::manage( new PrefRadioButton); - PrefRadioButton* own = Gtk::manage( new PrefRadioButton); - Gtk::Button* button = Gtk::manage( new Gtk::Button(_("Take from selection"),true)); - - own->changed_signal.connect( sigc::mem_fun(*button, &Gtk::Button::set_sensitive) ); - button->signal_clicked().connect(sigc::bind( sigc::ptr_fun(InkscapePreferences::StyleFromSelectionToTool), prefs_path.c_str() ) ); - - current->init ( _("Last used style"), prefs_path, "usecurrent", 1, true, 0); - own->init ( _("This tool's own style:"), prefs_path, "usecurrent", 0, false, current); - - p.add_group_header( _("Create new objects with:")); - p.add_line( true, "", *current, "", - _("Apply the style you last set on an object")); - p.add_line( true, "", *own, "", - _("Each tool may store its own style to apply to the newly created objects. Use the button below to set it.")); - p.add_line( true, "", *button, "", - _("Remember the style of the (first) selected object as this tool's style")); -} - -void InkscapePreferences::StyleFromSelectionToTool(gchar const *prefs_path) +void StyleFromSelectionToTool(gchar const *prefs_path, StyleSwatch *swatch) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; if (desktop == NULL) @@ -261,6 +244,53 @@ void InkscapePreferences::StyleFromSelectionToTool(gchar const *prefs_path) sp_repr_css_change (inkscape_get_repr (INKSCAPE, prefs_path), css, "style"); sp_repr_css_attr_unref (css); + + // update the swatch + if (swatch) { + Inkscape::XML::Node *tool_repr = inkscape_get_repr(INKSCAPE, prefs_path); + if (tool_repr) { + SPCSSAttr *css = sp_repr_css_attr_inherited(tool_repr, "style"); + swatch->setStyle (css); + sp_repr_css_attr_unref(css); + } + } +} + +void InkscapePreferences::AddNewObjectsStyle(DialogPage& p, const std::string& prefs_path) +{ + + + p.add_group_header( _("Create new objects with:")); + PrefRadioButton* current = Gtk::manage( new PrefRadioButton); + current->init ( _("Last used style"), prefs_path, "usecurrent", 1, true, 0); + p.add_line( true, "", *current, "", + _("Apply the style you last set on an object")); + + PrefRadioButton* own = Gtk::manage( new PrefRadioButton); + Gtk::HBox* hb = Gtk::manage( new Gtk::HBox); + Gtk::Alignment* align = Gtk::manage( new Gtk::Alignment); + own->init ( _("This tool's own style:"), prefs_path, "usecurrent", 0, false, current); + align->set(0,0,0,0); + align->add(*own); + hb->add(*align); + p.set_tip( *own, _("Each tool may store its own style to apply to the newly created objects. Use the button below to set it.")); + p.add_line( true, "", *hb, "", ""); + + // style swatch + Inkscape::XML::Node *tool_repr = inkscape_get_repr(INKSCAPE, prefs_path.c_str()); + Gtk::Button* button = Gtk::manage( new Gtk::Button(_("Take from selection"),true)); + StyleSwatch *swatch = 0; + if (tool_repr) { + SPCSSAttr *css = sp_repr_css_attr_inherited(tool_repr, "style"); + swatch = new StyleSwatch(css); + hb->add(*swatch); + sp_repr_css_attr_unref(css); + } + + button->signal_clicked().connect( sigc::bind( sigc::ptr_fun(StyleFromSelectionToTool), prefs_path.c_str(), swatch) ); + own->changed_signal.connect( sigc::mem_fun(*button, &Gtk::Button::set_sensitive) ); + p.add_line( true, "", *button, "", + _("Remember the style of the (first) selected object as this tool's style")); } void InkscapePreferences::initPageTools() @@ -486,8 +516,10 @@ bool InkscapePreferences::SetMaxDialogSize(const Gtk::TreeModel::iterator& iter) DialogPage* page = row[_page_list_columns._col_page]; _page_frame.add(*page); this->show_all_children(); - _max_dialog_width=std::max(_max_dialog_width, this->size_request().width); - _max_dialog_height=std::max(_max_dialog_height, this->size_request().height); + Gtk:: Requisition sreq; + this->size_request(sreq); + _max_dialog_width=std::max(_max_dialog_width, sreq.width); + _max_dialog_height=std::max(_max_dialog_height, sreq.height); _page_frame.remove(); return false; } diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index 269bce7f0..fe87583ba 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -103,7 +103,6 @@ protected: static void AddSelcueCheckbox(DialogPage& p, const std::string& prefs_path, bool def_value); static void AddGradientCheckbox(DialogPage& p, const std::string& prefs_path, bool def_value); static void AddNewObjectsStyle(DialogPage& p, const std::string& prefs_path); - static void StyleFromSelectionToTool(gchar const *prefs_path); void on_pagelist_selection_changed(); void initPageMouse(); diff --git a/src/ui/widget/preferences-widget.cpp b/src/ui/widget/preferences-widget.cpp index b53db0512..c45952c83 100644 --- a/src/ui/widget/preferences-widget.cpp +++ b/src/ui/widget/preferences-widget.cpp @@ -121,6 +121,11 @@ void DialogPage::add_group_header(Glib::ustring name) } } +void DialogPage::set_tip(Gtk::Widget& widget, const Glib::ustring& tip) +{ + _tooltips.set_tip (widget, tip); +} + void PrefCheckButton::init(const Glib::ustring& label, const std::string& prefs_path, const std::string& attr, bool default_value) { diff --git a/src/ui/widget/preferences-widget.h b/src/ui/widget/preferences-widget.h index a5a594114..361d737a8 100644 --- a/src/ui/widget/preferences-widget.h +++ b/src/ui/widget/preferences-widget.h @@ -94,6 +94,7 @@ public: DialogPage(); void add_line(bool indent, const Glib::ustring label, Gtk::Widget& widget, const Glib::ustring suffix, const Glib::ustring& tip, bool expand = true); void add_group_header(Glib::ustring name); + void set_tip(Gtk::Widget& widget, const Glib::ustring& tip); protected: Gtk::Tooltips _tooltips; }; -- 2.30.2