summaryrefslogtreecommitdiffstats
path: root/src/ui/dialog/livepatheffect-add.cpp
diff options
context:
space:
mode:
authorJabier Arraiza <jabier.arraiza@marker.es>2019-01-26 17:18:58 +0000
committerJabier Arraiza <jabier.arraiza@marker.es>2019-02-18 21:18:27 +0000
commit106cd424af0fec559422a6443944ed09e537d930 (patch)
tree182275be6ce6f9860aa4fb4c341574311796cc0a /src/ui/dialog/livepatheffect-add.cpp
parentAdding styling refactoring, moving after to other branch the CSS part (diff)
downloadinkscape-106cd424af0fec559422a6443944ed09e537d930.tar.gz
inkscape-106cd424af0fec559422a6443944ed09e537d930.zip
fixing coding style and translation and merge from master
Diffstat (limited to 'src/ui/dialog/livepatheffect-add.cpp')
-rw-r--r--src/ui/dialog/livepatheffect-add.cpp99
1 files changed, 62 insertions, 37 deletions
diff --git a/src/ui/dialog/livepatheffect-add.cpp b/src/ui/dialog/livepatheffect-add.cpp
index 630008606..b11ee66b7 100644
--- a/src/ui/dialog/livepatheffect-add.cpp
+++ b/src/ui/dialog/livepatheffect-add.cpp
@@ -13,31 +13,32 @@
# include "config.h" // only include where actually required!
#endif
+#include "desktop.h"
+#include "io/resource.h"
+#include "live_effects/effect.h"
#include "livepatheffect-add.h"
#include <glibmm/i18n.h>
-#include "desktop.h"
-
namespace Inkscape {
namespace UI {
namespace Dialog {
-LivePathEffectAdd::LivePathEffectAdd() :
- converter(Inkscape::LivePathEffect::LPETypeConverter)
+LivePathEffectAdd::LivePathEffectAdd()
+ : converter(Inkscape::LivePathEffect::LPETypeConverter)
{
- const std::string req_widgets[] = {"LPEDialogSelector", "LPESelector", "LPESelectorFlowBox"};
+ const std::string req_widgets[] = { "LPEDialogSelector", "LPESelector", "LPESelectorFlowBox" };
Glib::ustring gladefile = get_filename(Inkscape::IO::Resource::UIS, "dialog-livepatheffect-add.ui");
try {
_builder = Gtk::Builder::create_from_file(gladefile);
- } catch(const Glib::Error& ex) {
+ } catch (const Glib::Error &ex) {
g_warning("Glade file loading failed for filter effect dialog");
return;
}
- Gtk::Object* test;
- for(std::string w:req_widgets) {
- _builder->get_widget(w,test);
- if(!test){
+ Gtk::Object *test;
+ for (std::string w : req_widgets) {
+ _builder->get_widget(w, test);
+ if (!test) {
g_warning("Required widget %s does not exist", w.c_str());
return;
}
@@ -50,43 +51,42 @@ LivePathEffectAdd::LivePathEffectAdd() :
_builder->get_widget("LPEFilter", _LPEFilter);
_builder->get_widget("LPEInfo", _LPEInfo);
_LPEFilter->signal_search_changed().connect(sigc::mem_fun(*this, &LivePathEffectAdd::on_search));
- const std::string le_widgets[] = {"LPESelectorEffect", "LPEName","LPEDescription"};
+ const std::string le_widgets[] = { "LPESelectorEffect", "LPEName", "LPEDescription" };
Glib::ustring le_gladefile = get_filename(Inkscape::IO::Resource::UIS, "dialog-livepatheffect-add-effect.ui");
- for(int i = 0; i < static_cast<int>(converter._length); ++i) {
-
+ for (int i = 0; i < static_cast<int>(converter._length); ++i) {
+
try {
_builder = Gtk::Builder::create_from_file(le_gladefile);
- } catch(const Glib::Error& ex) {
+ } catch (const Glib::Error &ex) {
g_warning("Glade file loading failed for filter effect dialog");
return;
}
- for(int i = 0; i < static_cast<int>(converter._length); ++i) {
- Gtk::TreeModel::Row row = *(effectlist_store->append());
- const Util::EnumData<LivePathEffect::EffectType>* data = &converter.data(i);
- row[_columns.name] = _( converter.get_label(data->id).c_str() );
- row[_columns.data] = data;
- if (i == show) {
- Glib::RefPtr<Gtk::TreeSelection> select = effectlist_treeview.get_selection();
- select->select(row);
+ Gtk::Object *test;
+ for (std::string w : le_widgets) {
+ _builder->get_widget(w, test);
+ if (!test) {
+ g_warning("Required widget %s does not exist", w.c_str());
+ return;
+ }
}
- const LivePathEffect::EnumEffectData<LivePathEffect::EffectType>* data = &converter.data(i);
- Gtk::Label * LPEName;
+ const LivePathEffect::EnumEffectData<LivePathEffect::EffectType> *data = &converter.data(i);
+ Gtk::Label *LPEName;
_builder->get_widget("LPEName", LPEName);
Glib::ustring newid = "LPEName_" + Glib::ustring::format(i);
(*LPEName).set_name(newid);
(*LPEName).set_text(converter.get_label(data->id).c_str());
- Gtk::Label * LPEDescription;
+ Gtk::Label *LPEDescription;
_builder->get_widget("LPEDescription", LPEDescription);
newid = "LPEDescription_" + Glib::ustring::format(i);
(*LPEDescription).set_name(newid);
(*LPEDescription).set_text(converter.get_description(data->id));
- Gtk::Image * LPEIcon;
+ Gtk::Image *LPEIcon;
_builder->get_widget("LPEIcon", LPEIcon);
newid = "LPEIcon_" + Glib::ustring::format(i);
(*LPEIcon).set_name(newid);
- (*LPEIcon).set_from_icon_name(converter.get_icon(data->id),Gtk::BuiltinIconSize(Gtk::ICON_SIZE_DIALOG));
- Gtk::Box * LPESelectorEffect;
+ (*LPEIcon).set_from_icon_name(converter.get_icon(data->id), Gtk::BuiltinIconSize(Gtk::ICON_SIZE_DIALOG));
+ Gtk::Box *LPESelectorEffect;
_builder->get_widget("LPESelectorEffect", LPESelectorEffect);
newid = "LPESelectorEffect" + Glib::ustring::format(i);
(*LPESelectorEffect).set_name(newid);
@@ -99,15 +99,16 @@ LivePathEffectAdd::LivePathEffectAdd() :
_LPEInfo->set_visible(false);
}
-void LivePathEffectAdd::on_activate(Gtk::FlowBoxChild *child){
- for (auto i:_LPESelectorFlowBox->get_children()) {
- Gtk::FlowBoxChild * leitem = dynamic_cast<Gtk::FlowBoxChild *>(i);
+void LivePathEffectAdd::on_activate(Gtk::FlowBoxChild *child)
+{
+ for (auto i : _LPESelectorFlowBox->get_children()) {
+ Gtk::FlowBoxChild *leitem = dynamic_cast<Gtk::FlowBoxChild *>(i);
leitem->get_style_context()->remove_class("lpeactive");
leitem->get_style_context()->remove_class("colorinverse");
leitem->get_style_context()->remove_class("backgroundinverse");
Gtk::Box *box = dynamic_cast<Gtk::Box *>(leitem->get_child());
if (box) {
- std::vector<Gtk::Widget*> contents = box->get_children();
+ std::vector<Gtk::Widget *> contents = box->get_children();
Gtk::Box *actions = dynamic_cast<Gtk::Box *>(contents[3]);
if (actions) {
actions->set_visible(false);
@@ -120,7 +121,34 @@ void LivePathEffectAdd::on_activate(Gtk::FlowBoxChild *child){
child->show_all_children();
}
- auto mainVBox = get_content_area();
+bool LivePathEffectAdd::on_filter(Gtk::FlowBoxChild *child)
+{
+ if (_LPEFilter->get_text().length() < 4) {
+ _visiblelpe = _LPESelectorFlowBox->get_children().size();
+ return true;
+ }
+ Gtk::Box *box = dynamic_cast<Gtk::Box *>(child->get_child());
+ if (box) {
+ std::vector<Gtk::Widget *> contents = box->get_children();
+ Gtk::Label *lpename = dynamic_cast<Gtk::Label *>(contents[1]);
+ if (lpename) {
+ size_t s = lpename->get_text().uppercase().find(_LPEFilter->get_text().uppercase(), 0);
+ if (s != -1) {
+ _visiblelpe++;
+ return true;
+ }
+ }
+ Gtk::Label *lpedesc = dynamic_cast<Gtk::Label *>(contents[2]);
+ if (lpedesc) {
+ size_t s = lpedesc->get_text().uppercase().find(_LPEFilter->get_text().uppercase(), 0);
+ if (s != -1) {
+ _visiblelpe++;
+ return true;
+ }
+ }
+ }
+ return false;
+}
mainVBox->pack_start(scrolled_window, true, true);
add_action_widget(close_button, Gtk::RESPONSE_CLOSE);
@@ -147,10 +175,7 @@ void LivePathEffectAdd::onAdd()
onClose();
}
-void LivePathEffectAdd::onClose()
-{
- _LPEDialogSelector->hide();
-}
+void LivePathEffectAdd::onClose() { _LPEDialogSelector->hide(); }
void LivePathEffectAdd::onKeyEvent(GdkEventKey* evt)
{