1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
// SPDX-License-Identifier: GPL-2.0-or-later
/**
* @file
* Dialog for adding a live path effect.
*
* Author:
*
* Copyright (C) 2012 Authors
* Released under GNU GPL v2+, read the file 'COPYING' for more information.
*/
#ifdef HAVE_CONFIG_H
# include "config.h" // only include where actually required!
#endif
#include "livepatheffect-add.h"
#include <glibmm/i18n.h>
#include "desktop.h"
namespace Inkscape {
namespace UI {
namespace Dialog {
LivePathEffectAdd::LivePathEffectAdd() :
add_button(_("_Add"), true),
close_button(_("_Cancel"), true),
converter(Inkscape::LivePathEffect::LPETypeConverter),
applied(false)
{
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);
/**
* 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
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);
}
}
/**
* Buttons
*/
//close_button.set_can_default();
add_button.set_use_underline(true);
add_button.set_can_default();
auto mainVBox = get_content_area();
mainVBox->pack_start(scrolled_window, true, true);
add_action_widget(close_button, Gtk::RESPONSE_CLOSE);
add_action_widget(add_button, Gtk::RESPONSE_APPLY);
/**
* Signal handlers
*/
effectlist_treeview.signal_button_press_event().connect_notify( sigc::mem_fun(*this, &LivePathEffectAdd::onButtonEvent) );
effectlist_treeview.signal_key_press_event().connect_notify(sigc::mem_fun(*this, &LivePathEffectAdd::onKeyEvent));
close_button.signal_clicked().connect(sigc::mem_fun(*this, &LivePathEffectAdd::onClose));
add_button.signal_clicked().connect(sigc::mem_fun(*this, &LivePathEffectAdd::onAdd));
signal_delete_event().connect( sigc::bind_return(sigc::hide(sigc::mem_fun(*this, &LivePathEffectAdd::onClose)), true ) );
add_button.grab_default();
show_all_children();
}
void LivePathEffectAdd::onAdd()
{
applied = true;
onClose();
}
void LivePathEffectAdd::onClose()
{
hide();
}
void LivePathEffectAdd::onKeyEvent(GdkEventKey* evt)
{
if (evt->keyval == GDK_KEY_Return) {
onAdd();
}
if (evt->keyval == GDK_KEY_Escape) {
onClose();
}
}
void LivePathEffectAdd::onButtonEvent(GdkEventButton* evt)
{
// Double click on tree is same as clicking the add button
if (evt->type == GDK_2BUTTON_PRESS) {
onAdd();
}
}
const Util::EnumData<LivePathEffect::EffectType>*
LivePathEffectAdd::getActiveData()
{
Gtk::TreeModel::iterator iter = instance().effectlist_treeview.get_selection()->get_selected();
if ( iter ) {
Gtk::TreeModel::Row row = *iter;
return row[instance()._columns.data];
}
return nullptr;
}
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();
}
} // namespace Dialog
} // namespace UI
} // namespace Inkscape
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
|