1 |
schoenebeck |
3157 |
/* |
2 |
|
|
Copyright (c) MMXVII Christian Schoenebeck |
3 |
|
|
|
4 |
|
|
This file is part of "gigedit" and released under the terms of the |
5 |
|
|
GNU General Public License version 2. |
6 |
|
|
*/ |
7 |
|
|
|
8 |
|
|
#ifndef GIGEDIT_MACROSSETUP_H |
9 |
|
|
#define GIGEDIT_MACROSSETUP_H |
10 |
|
|
|
11 |
|
|
#ifdef LIBGIG_HEADER_FILE |
12 |
|
|
# include LIBGIG_HEADER_FILE(gig.h) |
13 |
|
|
# include LIBGIG_HEADER_FILE(Serialization.h) |
14 |
|
|
#else |
15 |
|
|
# include <gig.h> |
16 |
|
|
# include <Serialization.h> |
17 |
|
|
#endif |
18 |
|
|
|
19 |
|
|
#include <gtkmm.h> |
20 |
|
|
#if HAVE_CONFIG_H |
21 |
|
|
# include <config.h> |
22 |
|
|
#endif |
23 |
|
|
#include "compat.h" |
24 |
|
|
#include <gtkmm/uimanager.h> |
25 |
|
|
#include <gtkmm/actiongroup.h> |
26 |
|
|
#include "ManagedWindow.h" |
27 |
|
|
|
28 |
|
|
/** @brief Setup all gigedit macros. |
29 |
|
|
* |
30 |
|
|
* Shows a list with all gigedit macros configured by the user. It allows to |
31 |
|
|
* add and remove macros, and to reorder the list of macros for altering the |
32 |
|
|
* keyboard accelerators (F1 - F12) associated with the individual macros. |
33 |
|
|
*/ |
34 |
|
|
class MacrosSetup : public ManagedWindow { |
35 |
|
|
public: |
36 |
|
|
MacrosSetup(); |
37 |
|
|
~MacrosSetup(); |
38 |
|
|
void setMacros(const std::vector<Serialization::Archive>& macros); |
39 |
|
|
|
40 |
|
|
sigc::signal<void, const std::vector<Serialization::Archive>& >& signal_macros_changed(); |
41 |
|
|
|
42 |
|
|
// implementation for abstract methods of interface class "ManagedWindow" |
43 |
|
|
virtual Settings::Property<int>* windowSettingX() { return &Settings::singleton()->macrosSetupWindowX; } |
44 |
|
|
virtual Settings::Property<int>* windowSettingY() { return &Settings::singleton()->macrosSetupWindowY; } |
45 |
|
|
virtual Settings::Property<int>* windowSettingWidth() { return &Settings::singleton()->macrosSetupWindowW; } |
46 |
|
|
virtual Settings::Property<int>* windowSettingHeight() { return &Settings::singleton()->macrosSetupWindowH; } |
47 |
|
|
|
48 |
|
|
protected: |
49 |
|
|
std::vector<Serialization::Archive> m_macros; |
50 |
|
|
|
51 |
|
|
sigc::signal<void, const std::vector<Serialization::Archive>& > m_macros_changed; |
52 |
|
|
|
53 |
|
|
Gtk::VBox m_vbox; |
54 |
|
|
Gtk::HBox m_footerHBox; |
55 |
|
|
Gtk::HBox m_statusHBox; |
56 |
|
|
Gtk::HButtonBox m_buttonBoxL; |
57 |
|
|
Gtk::HButtonBox m_buttonBox; |
58 |
|
|
Gtk::ScrolledWindow m_scrolledWindow; |
59 |
|
|
|
60 |
|
|
class MacroListModel : public Gtk::TreeModel::ColumnRecord { |
61 |
|
|
public: |
62 |
|
|
MacroListModel() { |
63 |
|
|
add(m_col_key); |
64 |
|
|
add(m_col_name); |
65 |
|
|
add(m_col_comment); |
66 |
|
|
add(m_col_created); |
67 |
|
|
add(m_col_modified); |
68 |
|
|
add(m_col_index); |
69 |
|
|
} |
70 |
|
|
|
71 |
|
|
Gtk::TreeModelColumn<Glib::ustring> m_col_key; |
72 |
|
|
Gtk::TreeModelColumn<Glib::ustring> m_col_name; |
73 |
|
|
Gtk::TreeModelColumn<Glib::ustring> m_col_comment; |
74 |
|
|
Gtk::TreeModelColumn<Glib::ustring> m_col_created; |
75 |
|
|
Gtk::TreeModelColumn<Glib::ustring> m_col_modified; |
76 |
|
|
Gtk::TreeModelColumn<int> m_col_index; |
77 |
|
|
} m_treeModelMacros; |
78 |
|
|
|
79 |
|
|
class MacroListTreeStore : public Gtk::TreeStore { |
80 |
|
|
public: |
81 |
|
|
static Glib::RefPtr<MacroListTreeStore> create(const MacroListModel& columns) { |
82 |
|
|
return Glib::RefPtr<MacroListTreeStore>( new MacroListTreeStore(columns) ); |
83 |
|
|
} |
84 |
|
|
protected: |
85 |
|
|
MacroListTreeStore(const MacroListModel& columns) : Gtk::TreeStore(columns) {} |
86 |
|
|
}; |
87 |
|
|
|
88 |
|
|
Gtk::TreeView m_treeViewMacros; |
89 |
|
|
Glib::RefPtr<MacroListTreeStore> m_treeStoreMacros; |
90 |
|
|
bool m_ignoreTreeViewValueChange; |
91 |
|
|
|
92 |
|
|
Gtk::Label m_statusLabel; |
93 |
|
|
Gtk::Button m_deleteButton; |
94 |
|
|
Gtk::Button m_inverseDeleteButton; |
95 |
|
|
Gtk::Button m_applyButton; |
96 |
|
|
Gtk::Button m_cancelButton; |
97 |
|
|
|
98 |
|
|
bool m_altKeyDown; |
99 |
|
|
|
100 |
|
|
bool isModified() const; |
101 |
|
|
void onButtonCancel(); |
102 |
|
|
void onButtonApply(); |
103 |
|
|
void onWindowHide(); |
104 |
|
|
bool onWindowDelete(GdkEventAny* e); |
105 |
|
|
void updateStatus(); |
106 |
|
|
void updateStatusBar(); |
107 |
|
|
void reloadTreeView(); |
108 |
|
|
void onTreeViewSelectionChanged(); |
109 |
|
|
void onMacroTreeViewKeyRelease(GdkEventKey* button); |
110 |
|
|
void onMacroTreeViewRowValueChanged(const Gtk::TreeModel::Path& path, |
111 |
|
|
const Gtk::TreeModel::iterator& iter); |
112 |
|
|
void deleteSelectedRows(); |
113 |
|
|
void inverseDeleteSelectedRows(); |
114 |
|
|
void deleteRows(const std::vector<Gtk::TreeModel::Path>& rows); |
115 |
|
|
bool onKeyPressed(GdkEventKey* key); |
116 |
|
|
bool onKeyReleased(GdkEventKey* key); |
117 |
|
|
}; |
118 |
|
|
|
119 |
|
|
#endif // GIGEDIT_MACROSSETUP_H |