/* Copyright (c) MMXVII Christian Schoenebeck This file is part of "gigedit" and released under the terms of the GNU General Public License version 2. */ #ifndef GIGEDIT_MACROSSETUP_H #define GIGEDIT_MACROSSETUP_H #ifdef LIBGIG_HEADER_FILE # include LIBGIG_HEADER_FILE(gig.h) # include LIBGIG_HEADER_FILE(Serialization.h) #else # include # include #endif #include #if HAVE_CONFIG_H # include #endif #include "compat.h" #include #include #include "ManagedWindow.h" /** @brief Setup all gigedit macros. * * Shows a list with all gigedit macros configured by the user. It allows to * add and remove macros, and to reorder the list of macros for altering the * keyboard accelerators (F1 - F12) associated with the individual macros. */ class MacrosSetup : public ManagedWindow { public: MacrosSetup(); ~MacrosSetup(); void setMacros(const std::vector& macros); sigc::signal& >& signal_macros_changed(); // implementation for abstract methods of interface class "ManagedWindow" virtual Settings::Property* windowSettingX() { return &Settings::singleton()->macrosSetupWindowX; } virtual Settings::Property* windowSettingY() { return &Settings::singleton()->macrosSetupWindowY; } virtual Settings::Property* windowSettingWidth() { return &Settings::singleton()->macrosSetupWindowW; } virtual Settings::Property* windowSettingHeight() { return &Settings::singleton()->macrosSetupWindowH; } protected: std::vector m_macros; sigc::signal& > m_macros_changed; Gtk::VBox m_vbox; Gtk::HBox m_footerHBox; Gtk::HBox m_statusHBox; Gtk::HButtonBox m_buttonBoxL; Gtk::HButtonBox m_buttonBox; Gtk::ScrolledWindow m_scrolledWindow; class MacroListModel : public Gtk::TreeModel::ColumnRecord { public: MacroListModel() { add(m_col_key); add(m_col_name); add(m_col_comment); add(m_col_created); add(m_col_modified); add(m_col_index); } Gtk::TreeModelColumn m_col_key; Gtk::TreeModelColumn m_col_name; Gtk::TreeModelColumn m_col_comment; Gtk::TreeModelColumn m_col_created; Gtk::TreeModelColumn m_col_modified; Gtk::TreeModelColumn m_col_index; } m_treeModelMacros; class MacroListTreeStore : public Gtk::TreeStore { public: static Glib::RefPtr create(const MacroListModel& columns) { return Glib::RefPtr( new MacroListTreeStore(columns) ); } protected: MacroListTreeStore(const MacroListModel& columns) : Gtk::TreeStore(columns) {} }; Gtk::TreeView m_treeViewMacros; Glib::RefPtr m_treeStoreMacros; bool m_ignoreTreeViewValueChange; Gtk::Label m_statusLabel; Gtk::Button m_deleteButton; Gtk::Button m_inverseDeleteButton; Gtk::Button m_applyButton; Gtk::Button m_cancelButton; bool m_altKeyDown; bool isModified() const; void onButtonCancel(); void onButtonApply(); void onWindowHide(); bool onWindowDelete(GdkEventAny* e); void updateStatus(); void updateStatusBar(); void reloadTreeView(); void onTreeViewSelectionChanged(); void onMacroTreeViewKeyRelease(GdkEventKey* button); void onMacroTreeViewRowValueChanged(const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator& iter); void deleteSelectedRows(); void inverseDeleteSelectedRows(); void deleteRows(const std::vector& rows); bool onKeyPressed(GdkEventKey* key); bool onKeyReleased(GdkEventKey* key); }; #endif // GIGEDIT_MACROSSETUP_H