1. === modified file 'src/ui/dialog/inkscape-preferences.cpp'
  2. --- src/ui/dialog/inkscape-preferences.cpp 2017-03-30 19:14:41 +0000
  3. +++ src/ui/dialog/inkscape-preferences.cpp 2017-04-28 19:33:28 +0000
  4. @@ -27,7 +27,10 @@
  5. #include "preferences.h"
  6. #include "verbs.h"
  7. #include "selcue.h"
  8. -
  9. +#include "live_effects/effect-enum.h"
  10. +#include "live_effects/effect.h"
  11. +#include "live_effects/lpeobject.h"
  12. +#include "sp-defs.h"
  13. #include "extension/internal/gdkpixbuf-input.h"
  14. #include "message-stack.h"
  15. #include "style.h"
  16. @@ -820,6 +823,93 @@
  17. this->AddPage(_page_grids, _("Grids"), iter_ui, PREFS_PAGE_UI_GRIDS);
  18. initKeyboardShortcuts(iter_ui);
  19. +
  20. + _page_lpe.add_group_header( _("Allow set default to this parameters:"));
  21. + SPDocument * doc = SP_ACTIVE_DOCUMENT;
  22. + Inkscape::XML::Document *xml_doc = doc->getReprDoc();
  23. + Inkscape::XML::Node *lpe_repr = xml_doc->createElement("inkscape:path-effect");
  24. + lpe_repr->setAttribute("id", "deleteme");
  25. + SPObject *lpeo = SP_OBJECT(doc->getDefs()->appendChildRepr(lpe_repr));
  26. + Inkscape::GC::release(lpe_repr);
  27. + Inkscape::UI::Widget::Registry * wr;
  28. + Inkscape::Preferences *prefs = Inkscape::Preferences::get();
  29. +
  30. + for ( int le = Inkscape::LivePathEffect::EffectType::BEND_PATH; le != Inkscape::LivePathEffect::EffectType::INVALID_LPE; ++le){
  31. + Inkscape::LivePathEffect::EffectType lpenr = static_cast<Inkscape::LivePathEffect::EffectType>(le);
  32. + Glib::ustring effectname = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_label(lpenr);
  33. + Glib::ustring effectkey = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_key(lpenr);
  34. + bool is_text_label_lpe = effectkey == (Glib::ustring)"text_label";
  35. + if (!effectname.empty() && !is_text_label_lpe){
  36. + lpeo->setAttribute("effect", effectkey.c_str());
  37. + LivePathEffectObject * lpeobj = dynamic_cast<LivePathEffectObject *>(lpeo);
  38. + Glib::ustring liveeffect = effectname +(Glib::ustring)_(":");
  39. + Inkscape::LivePathEffect::Effect* effect = Inkscape::LivePathEffect::Effect::New(lpenr, lpeobj);
  40. + std::vector<Inkscape::LivePathEffect::Parameter *> param_vector = effect->getParamVector();
  41. + if (param_vector.size() == 1) {
  42. + continue;
  43. + }
  44. + std::vector<Inkscape::LivePathEffect::Parameter *>::iterator it = param_vector.begin();
  45. + Gtk::VBox * vbox_expander = Gtk::manage( new Gtk::VBox() );
  46. + vbox_expander->set_border_width(10);
  47. + vbox_expander->set_spacing(2);
  48. + while (it != param_vector.end()) {
  49. + Inkscape::LivePathEffect::Parameter * param = *it;
  50. + const gchar * key = param->param_key.c_str();
  51. + if (strcmp(key,"is_visible") == 0 ){
  52. + ++it;
  53. + continue;
  54. + }
  55. + const gchar * value = param->param_label.c_str();
  56. + const gchar * tooltip_extra = _(". Toogling this check in preferences reset to default custom values for this parameter");
  57. + Glib::ustring tooltip = param->param_tooltip + (Glib::ustring)tooltip_extra;
  58. + Glib::ustring pref_path = (Glib::ustring)"/live_effects/" +
  59. + effectkey +
  60. + (Glib::ustring)"/" +
  61. + (Glib::ustring)key;
  62. + bool valid = prefs->getEntry(pref_path).isValid();
  63. + bool set = false;
  64. + if(valid){
  65. + set = true;
  66. + }
  67. + Inkscape::UI::Widget::RegisteredCheckButton * checkwdg = Gtk::manage(
  68. + new Inkscape::UI::Widget::RegisteredCheckButton( param->param_label,
  69. + tooltip,
  70. + param->param_key,
  71. + *wr,
  72. + false,
  73. + NULL,
  74. + NULL) );
  75. + checkwdg->setActive(set);
  76. + checkwdg->setProgrammatically = false;
  77. + checkwdg->signal_toggled().connect(sigc::bind<Glib::ustring, Inkscape::UI::Widget::RegisteredCheckButton *>(sigc::mem_fun(*this, &InkscapePreferences::defaultLpeUpdater), pref_path, checkwdg));
  78. + vbox_expander->pack_start(*dynamic_cast<Gtk::Widget *> (checkwdg), true, true, 2);
  79. + ++it;
  80. + }
  81. +
  82. + Gtk::Expander * expander = Gtk::manage(new Gtk::Expander(liveeffect));
  83. + expander->add(*vbox_expander);
  84. + expander->set_expanded(false);
  85. + Glib::ustring tip = (Glib::ustring)_("Set defaultables parameters for ") + liveeffect;
  86. + _page_lpe.add_line( true, "", *dynamic_cast<Gtk::Widget *>(expander), "", tip.c_str() );
  87. + }
  88. + }
  89. + lpeo->deleteObject();
  90. + this->AddPage(_page_lpe, _("Live Effects"), iter_ui, PREFS_PAGE_UI_LPE);
  91. +}
  92. +
  93. +void
  94. +InkscapePreferences::defaultLpeUpdater(Glib::ustring pref_path, Inkscape::UI::Widget::RegisteredCheckButton * checkwdg)
  95. +{
  96. + Inkscape::Preferences *prefs = Inkscape::Preferences::get();
  97. + if (checkwdg->get_active())
  98. + {
  99. + prefs->setString(pref_path, "--default");
  100. +
  101. + } else {
  102. + prefs->remove(pref_path);
  103. + prefs->remove((Glib::ustring)"/live_effects/gdsgddssdggdsgdsgdsgs");
  104. + prefs->remove((Glib::ustring)"/ddsdsdsgdsg");
  105. + }
  106. }
  107. #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
  108. @@ -2042,7 +2132,7 @@
  109. _page_list.expand_row(_path_tools, false);
  110. if (desired_page >= PREFS_PAGE_TOOLS_SHAPES && desired_page <= PREFS_PAGE_TOOLS_SHAPES_SPIRAL)
  111. _page_list.expand_row(_path_shapes, false);
  112. - if (desired_page >= PREFS_PAGE_UI && desired_page <= PREFS_PAGE_UI_KEYBOARD_SHORTCUTS)
  113. + if (desired_page >= PREFS_PAGE_UI && desired_page <= PREFS_PAGE_UI_LPE)
  114. _page_list.expand_row(_path_ui, false);
  115. if (desired_page >= PREFS_PAGE_BEHAVIOR && desired_page <= PREFS_PAGE_BEHAVIOR_MASKS)
  116. _page_list.expand_row(_path_behavior, false);
  117. === modified file 'src/ui/dialog/inkscape-preferences.h'
  118. --- src/ui/dialog/inkscape-preferences.h 2017-03-30 19:14:41 +0000
  119. +++ src/ui/dialog/inkscape-preferences.h 2017-04-26 22:18:01 +0000
  120. @@ -22,6 +22,7 @@
  121. #include <iostream>
  122. #include <vector>
  123. #include "ui/widget/preferences-widget.h"
  124. +#include "ui/widget/registered-widget.h"
  125. #include "ui/widget/button.h"
  126. #include <stddef.h>
  127. #include <gtkmm/colorbutton.h>
  128. @@ -30,6 +31,7 @@
  129. #include <gtkmm/treeview.h>
  130. #include <gtkmm/frame.h>
  131. #include <gtkmm/notebook.h>
  132. +#include <gtkmm/expander.h>
  133. #include <gtkmm/textview.h>
  134. #include <gtkmm/scrolledwindow.h>
  135. #include <gtkmm/liststore.h>
  136. @@ -73,6 +75,7 @@
  137. PREFS_PAGE_UI_WINDOWS,
  138. PREFS_PAGE_UI_GRIDS,
  139. PREFS_PAGE_UI_KEYBOARD_SHORTCUTS,
  140. + PREFS_PAGE_UI_LPE,
  141. PREFS_PAGE_BEHAVIOR,
  142. PREFS_PAGE_BEHAVIOR_SELECTING,
  143. PREFS_PAGE_BEHAVIOR_TRANSFORMS,
  144. @@ -187,6 +190,7 @@
  145. UI::Widget::DialogPage _page_spellcheck;
  146. UI::Widget::DialogPage _page_keyshortcuts;
  147. + UI::Widget::DialogPage _page_lpe;
  148. UI::Widget::PrefSpinButton _mouse_sens;
  149. UI::Widget::PrefSpinButton _mouse_thres;
  150. @@ -490,7 +494,7 @@
  151. Gtk::TreeModel::iterator AddPage(UI::Widget::DialogPage& p, Glib::ustring title, Gtk::TreeModel::iterator parent, int id);
  152. bool SetMaxDialogSize(const Gtk::TreeModel::iterator& iter);
  153. bool PresentPage(const Gtk::TreeModel::iterator& iter);
  154. -
  155. + void defaultLpeUpdater(Glib::ustring pref_path, Inkscape::UI::Widget::RegisteredCheckButton * checkwdg);
  156. static void AddSelcueCheckbox(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, bool def_value);
  157. static void AddGradientCheckbox(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, bool def_value);
  158. static void AddConvertGuidesCheckbox(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, bool def_value);
 
 

1282

Preferences with LPE list and Parameter

-Finaly not used but maybe can resque in the future if we want to add preferences to LPE

PasteBin

行數
164
字數
595
大小
8.2 KB
建立時間
類型
text/plain
Public Domain (PD)
登入以留下評註!