diff --git a/rtgui/toollocationpref.cc b/rtgui/toollocationpref.cc index c0bb6bea3..3e874627c 100644 --- a/rtgui/toollocationpref.cc +++ b/rtgui/toollocationpref.cc @@ -26,6 +26,9 @@ using Tool = ToolPanelCoordinator::Tool; using Favorites = std::unordered_set; +namespace +{ + std::string getToolName(Tool tool) { switch (tool) { @@ -145,75 +148,6 @@ std::string getToolName(Tool tool) return ""; }; -class FavoritesColumns : public Gtk::TreeModelColumnRecord -{ -public: - Gtk::TreeModelColumn toolName; - Gtk::TreeModelColumn tool; - - FavoritesColumns() - { - add(toolName); - add(tool); - } -}; - -class ToolListColumns : public Gtk::TreeModelColumnRecord -{ -public: - Gtk::TreeModelColumn toolName; - Gtk::TreeModelColumn tool; - Gtk::TreeModelColumn isFavorite; - Gtk::TreeModelColumn isEditable; - - ToolListColumns() - { - add(toolName); - add(tool); - add(isFavorite); - add(isEditable); - } -}; - -struct ToolLocationPreference::Impl { - static std::unordered_map toolNamesReverseMap; - - Options &options; - - // Tool list. - ToolListColumns toolListColumns; - Glib::RefPtr toolListModelPtr; - Gtk::CellRendererToggle toolListCellRendererFavorite; - Gtk::CellRendererText toolListCellRendererToolName; - Gtk::TreeViewColumn toolListViewColumnFavorite; - Gtk::TreeViewColumn toolListViewColumnToolName; - Gtk::TreeView *toolListViewPtr; - - // Favorites list. - FavoritesColumns favoritesColumns; - Glib::RefPtr favoritesModelPtr; - Gtk::CellRendererText favoritesCellRendererToolName; - Gtk::TreeViewColumn favoritesViewColumnToolName; - Gtk::TreeView *favoritesViewPtr; - - explicit Impl(Options &options); - - void addToolListRowGroup( - const std::vector &tools, - const Gtk::TreeIter &parentRowIter, - const Favorites &favorites); - void favoriteToggled(const Glib::ustring &row_path); - Tool getToolFromName(const std::string &name) const; - void initFavoritesRows(const std::vector &favorites); - void initToolListRows(const std::vector &favorites); - std::vector toolNamesToTools( - const std::vector &tool_names) const; - void updateOptions(); -}; - -std::unordered_map - ToolLocationPreference::Impl::toolNamesReverseMap; - Glib::ustring getToolPanelTitleKey(ToolPanelCoordinator::Panel panel) { switch (panel) { @@ -357,6 +291,77 @@ Glib::ustring getToolTitleKey(Tool tool) return ""; } +} + +class FavoritesColumns : public Gtk::TreeModelColumnRecord +{ +public: + Gtk::TreeModelColumn toolName; + Gtk::TreeModelColumn tool; + + FavoritesColumns() + { + add(toolName); + add(tool); + } +}; + +class ToolListColumns : public Gtk::TreeModelColumnRecord +{ +public: + Gtk::TreeModelColumn toolName; + Gtk::TreeModelColumn tool; + Gtk::TreeModelColumn isFavorite; + Gtk::TreeModelColumn isEditable; + + ToolListColumns() + { + add(toolName); + add(tool); + add(isFavorite); + add(isEditable); + } +}; + +struct ToolLocationPreference::Impl { + static std::unordered_map toolNamesReverseMap; + + Options &options; + + // Tool list. + ToolListColumns toolListColumns; + Glib::RefPtr toolListModelPtr; + Gtk::CellRendererToggle toolListCellRendererFavorite; + Gtk::CellRendererText toolListCellRendererToolName; + Gtk::TreeViewColumn toolListViewColumnFavorite; + Gtk::TreeViewColumn toolListViewColumnToolName; + Gtk::TreeView *toolListViewPtr; + + // Favorites list. + FavoritesColumns favoritesColumns; + Glib::RefPtr favoritesModelPtr; + Gtk::CellRendererText favoritesCellRendererToolName; + Gtk::TreeViewColumn favoritesViewColumnToolName; + Gtk::TreeView *favoritesViewPtr; + + explicit Impl(Options &options); + + void addToolListRowGroup( + const std::vector &tools, + const Gtk::TreeIter &parentRowIter, + const Favorites &favorites); + void favoriteToggled(const Glib::ustring &row_path); + Tool getToolFromName(const std::string &name) const; + void initFavoritesRows(const std::vector &favorites); + void initToolListRows(const std::vector &favorites); + std::vector toolNamesToTools( + const std::vector &tool_names) const; + void updateOptions(); +}; + +std::unordered_map + ToolLocationPreference::Impl::toolNamesReverseMap; + ToolLocationPreference::Impl::Impl(Options &options) : options(options),