diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ui/dialog/filter-editor.cpp | 2 | ||||
| -rw-r--r-- | src/ui/dialog/inkscape-preferences.cpp | 41 | ||||
| -rw-r--r-- | src/ui/dialog/livepatheffect-add.cpp | 127 | ||||
| -rw-r--r-- | src/ui/dialog/livepatheffect-add.h | 42 | ||||
| -rw-r--r-- | src/widgets/toolbox.cpp | 10 |
5 files changed, 119 insertions, 103 deletions
diff --git a/src/ui/dialog/filter-editor.cpp b/src/ui/dialog/filter-editor.cpp index 6ad9dca61..ba2c7357a 100644 --- a/src/ui/dialog/filter-editor.cpp +++ b/src/ui/dialog/filter-editor.cpp @@ -69,7 +69,7 @@ FilterEditorDialog::FilterEditorDialog() : UI::Widget::Panel("/dialogs/filtereff { const std::string req_widgets[] = {"FilterEditor", "FilterList", "FilterFERX", "FilterFERY", "FilterFERH", "FilterFERW", "FilterPreview", "FilterPrimitiveDescImage", "FilterPrimitiveList", "FilterPrimitiveDescText", "FilterPrimitiveAdd"}; - Glib::ustring gladefile = get_filename(UIS, "filter-editor.glade"); + Glib::ustring gladefile = get_filename(UIS, "dialog-filter-editor.ui"); try { builder = Gtk::Builder::create_from_file(gladefile); } catch(const Glib::Error& ex) { diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 9248b5944..86529fbbb 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -44,6 +44,7 @@ #include "selection.h" #include "shortcuts.h" #include "verbs.h" +#include "inkscape-window.h" #include "display/canvas-grid.h" #include "display/nr-filter-gaussian.h" @@ -687,7 +688,6 @@ void InkscapePreferences::symbolicAddClass() auto const screen = Gdk::Screen::get_default(); auto provider = Gtk::CssProvider::create(); Glib::ustring css_str = ""; - gchar colornamed[64]; gchar colornamed_inverse[64]; int colorset = prefs->getInt("/theme/symbolicColor", 0x000000ff); @@ -728,23 +728,24 @@ void InkscapePreferences::symbolicAddClass() // is more understandable than record previously applied Glib::ustring style = get_filename(UIS, "style.css"); if (!style.empty()) { - auto provider = Gtk::CssProvider::create(); - - // From 3.16, throws an error which we must catch. - try { - provider->load_from_path(style); - } -#if GTK_CHECK_VERSION(3, 16, 0) - // Gtk::CssProviderError not defined until 3.16. - catch (const Gtk::CssProviderError &ex) { - g_critical("CSSProviderError::load_from_path(): failed to load '%s'\n(%s)", style.c_str(), - ex.what().c_str()); - } + auto provider = Gtk::CssProvider::create(); + + // From 3.16, throws an error which we must catch. + try { + provider->load_from_path (style); + } +#if GTK_CHECK_VERSION(3,16,0) + // Gtk::CssProviderError not defined until 3.16. + catch (const Gtk::CssProviderError& ex) + { + g_critical("CSSProviderError::load_from_path(): failed to load '%s'\n(%s)", + style.c_str(), ex.what().c_str()); + } #else - catch (...) { - } + catch (...) + {} #endif - Gtk::StyleContext::add_provider_for_screen(screen, provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + Gtk::StyleContext::add_provider_for_screen (screen, provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); } } void InkscapePreferences::themeChange() @@ -756,15 +757,15 @@ void InkscapePreferences::themeChange() gchar *gtkThemeName; gboolean gtkApplicationPreferDarkTheme; Gtk::Window *window = SP_ACTIVE_DESKTOP->getToplevel(); - GtkSettings *settings = gtk_settings_get_default(); + GtkSettings *settings = gtk_settings_get_default(); if (window && settings) { g_object_get(settings, "gtk-theme-name", >kThemeName, NULL); g_object_get(settings, "gtk-application-prefer-dark-theme", >kApplicationPreferDarkTheme, NULL); bool dark = gtkApplicationPreferDarkTheme || Glib::ustring(gtkThemeName).find(":dark") != -1; if (!dark) { - Glib::RefPtr<Gtk::StyleContext> stylecontext = window->get_style_context(); - Gdk::RGBA rgba; - bool background_set = stylecontext->lookup_color("theme_bg_color", rgba); + Glib::RefPtr<Gtk::StyleContext> stylecontext = window->get_style_context(); + Gdk::RGBA rgba; + bool background_set = stylecontext->lookup_color("theme_bg_color", rgba); if (background_set && rgba.get_red() + rgba.get_green() + rgba.get_blue() < 1.0) { dark = true; } diff --git a/src/ui/dialog/livepatheffect-add.cpp b/src/ui/dialog/livepatheffect-add.cpp index 1fae9a513..630008606 100644 --- a/src/ui/dialog/livepatheffect-add.cpp +++ b/src/ui/dialog/livepatheffect-add.cpp @@ -23,44 +23,43 @@ namespace UI { namespace Dialog { LivePathEffectAdd::LivePathEffectAdd() : - add_button(_("_Add"), true), - close_button(_("_Cancel"), true), - converter(Inkscape::LivePathEffect::LPETypeConverter), - applied(false) + converter(Inkscape::LivePathEffect::LPETypeConverter) { - set_title(_("Add Path Effect")); - - /** - * Scrolled Window - */ - scrolled_window.add(effectlist_treeview); - scrolled_window.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); - scrolled_window.set_shadow_type(Gtk::SHADOW_IN); - scrolled_window.set_size_request(250, 200); - scrolled_window.set_can_focus(); - - /** - * Effect Store and Tree - */ - effectlist_store = Gtk::ListStore::create(_columns); - effectlist_store->set_sort_column (_columns.name, Gtk::SORT_ASCENDING ); - - effectlist_treeview.set_model(effectlist_store); - effectlist_treeview.set_headers_visible(false); - effectlist_treeview.append_column("Name", _columns.name); - //effectlist_treeview.set_activates_default(true); + 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) { + 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){ + g_warning("Required widget %s does not exist", w.c_str()); + return; + } + } + _builder->get_widget("LPEDialogSelector", _LPEDialogSelector); /** * Initialize Effect list */ - int show = LivePathEffect::ATTACH_PATH; -#ifdef LPE_ENABLE_TEST_EFFECTS - //TODO: Handle when showing the experimental effects without setting flag - show = LivePathEffect::ANGLE_BISECTOR; -#elif WITH_LPETOOL - //TODO: Handle when showing the experimental effects without setting flag - show = LivePathEffect::ANGLE_BISECTOR; -#endif + _builder->get_widget("LPESelectorFlowBox", _LPESelectorFlowBox); + _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"}; + 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) { + + try { + _builder = Gtk::Builder::create_from_file(le_gladefile); + } 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()); @@ -71,14 +70,55 @@ LivePathEffectAdd::LivePathEffectAdd() : Glib::RefPtr<Gtk::TreeSelection> select = effectlist_treeview.get_selection(); select->select(row); } + 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; + _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; + _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; + _builder->get_widget("LPESelectorEffect", LPESelectorEffect); + newid = "LPESelectorEffect" + Glib::ustring::format(i); + (*LPESelectorEffect).set_name(newid); + _LPESelectorFlowBox->insert(*LPESelectorEffect, i); } + _visiblelpe = _LPESelectorFlowBox->get_children().size(); + _LPESelectorFlowBox->signal_child_activated().connect(sigc::mem_fun(*this, &LivePathEffectAdd::on_activate)); + _LPEDialogSelector->set_title(_("Live Efects Selector")); + _LPEDialogSelector->show_all_children(); + _LPEInfo->set_visible(false); +} - /** - * Buttons - */ - //close_button.set_can_default(); - add_button.set_use_underline(true); - add_button.set_can_default(); +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(); + Gtk::Box *actions = dynamic_cast<Gtk::Box *>(contents[3]); + if (actions) { + actions->set_visible(false); + } + } + } + child->get_style_context()->add_class("lpeactive"); + child->get_style_context()->add_class("colorinverse"); + child->get_style_context()->add_class("backgroundinverse"); + child->show_all_children(); +} auto mainVBox = get_content_area(); @@ -109,7 +149,7 @@ void LivePathEffectAdd::onAdd() void LivePathEffectAdd::onClose() { - hide(); + _LPEDialogSelector->hide(); } void LivePathEffectAdd::onKeyEvent(GdkEventKey* evt) @@ -146,12 +186,7 @@ LivePathEffectAdd::getActiveData() void LivePathEffectAdd::show(SPDesktop *desktop) { LivePathEffectAdd &dial = instance(); - dial.applied=false; - dial.set_modal(true); - desktop->setWindowTransient (dial.gobj()); - dial.property_destroy_with_parent() = true; - dial.effectlist_treeview.grab_focus(); - dial.run(); + dial._LPEDialogSelector->run(); } } // namespace Dialog diff --git a/src/ui/dialog/livepatheffect-add.h b/src/ui/dialog/livepatheffect-add.h index 84901385c..671751ed2 100644 --- a/src/ui/dialog/livepatheffect-add.h +++ b/src/ui/dialog/livepatheffect-add.h @@ -72,37 +72,17 @@ protected: */ void onKeyEvent(GdkEventKey* evt); private: - - Gtk::TreeView effectlist_treeview; - Gtk::ScrolledWindow scrolled_window; - Gtk::Button add_button; - Gtk::Button close_button; - - class ModelColumns : public Gtk::TreeModel::ColumnRecord - { - public: - ModelColumns() - { - add(name); - //add(desc); - add(data); - } - ~ModelColumns() override = default; - - Gtk::TreeModelColumn<Glib::ustring> name; - /** - * TODO - Get detailed descriptions of each Effect to show in the dialog - */ - //Gtk::TreeModelColumn<Glib::ustring> desc; - Gtk::TreeModelColumn<const Util::EnumData<LivePathEffect::EffectType>*> data; - }; - - ModelColumns _columns; - Glib::RefPtr<Gtk::ListStore> effectlist_store; - const Util::EnumDataConverter<LivePathEffect::EffectType>& converter; - - bool applied; - + Gtk::Button _add_button; + Gtk::Button _close_button; + Gtk::Dialog *_LPEDialogSelector; + Glib::RefPtr<Gtk::Builder> _builder; + Gtk::FlowBox *_LPESelectorFlowBox; + Gtk::SearchEntry *_LPEFilter; + Gtk::Label *_LPEInfo; + Gtk::Box *_LPESelector; + guint _visiblelpe; + class Effect; + const LivePathEffect::EnumEffectDataConverter<LivePathEffect::EffectType>& converter; static LivePathEffectAdd &instance() { static LivePathEffectAdd instance_; return instance_; diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 140f87dc7..12b5c58d3 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -695,7 +695,7 @@ void ToolboxFactory::setOrientation(GtkWidget* toolbox, GtkOrientation orientati void setup_tool_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { setupToolboxCommon( toolbox, desktop, - "tool-toolbar.ui", + "toolbar-tool.ui", "/ui/ToolToolbar", "/toolbox/tools/small"); } @@ -743,12 +743,12 @@ void setup_aux_toolbox(GtkWidget *toolbox, SPDesktop *desktop) Glib::RefPtr<Gtk::ActionGroup> mainActions = create_or_fetch_actions( desktop ); // The UI Manager creates widgets based on the definitions in the - // "select-toolbar.ui" file. This is only used with the "prep" + // "toolbar-select.ui" file. This is only used with the "prep" // method of toolbar-creation GtkUIManager* mgr = gtk_ui_manager_new(); GError *err = nullptr; gtk_ui_manager_insert_action_group( mgr, mainActions->gobj(), 0 ); - Glib::ustring filename = get_filename(UIS, "select-toolbar.ui"); + Glib::ustring filename = get_filename(UIS, "toolbar-select.ui"); guint ret = gtk_ui_manager_add_ui_from_file(mgr, filename.c_str(), &err); if(err) { g_warning("Failed to load aux toolbar %s: %s", filename.c_str(), err->message); @@ -932,7 +932,7 @@ void update_aux_toolbox(SPDesktop * /*desktop*/, ToolBase *eventcontext, GtkWidg void setup_commands_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { setupToolboxCommon( toolbox, desktop, - "commands-toolbar.ui", + "toolbar-commands.ui", "/ui/CommandsToolbar", "/toolbox/small" ); } @@ -1246,7 +1246,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) } setupToolboxCommon( toolbox, desktop, - "snap-toolbar.ui", + "toolbar-snap.ui", "/ui/SnapToolbar", "/toolbox/secondary" ); } |
