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
|
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* This file contains the definition of the FontCollectionSelector class. This widget
* defines a treeview to provide the interface to create, read, update and delete font
* collections and their respective fonts. This class contains all the code related to
* population of collections and their fonts in the TreeStore.
*
* Author:
* Vaibhav Malik <vaibhavmalik2018@gmail.com>
*
* Released under GNU GPL v2+, read the file 'COPYING' for more information.
*
*/
#ifndef INKSCAPE_UI_WIDGET_FONT_COLLECTION_SELECTOR_H
#define INKSCAPE_UI_WIDGET_FONT_COLLECTION_SELECTOR_H
#include <gtkmm/grid.h>
#include <gtkmm/frame.h>
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/treeview.h>
#include <gtkmm/label.h>
#include <gtkmm/comboboxtext.h>
#include "ui/tools/tool-base.h"
#include "ui/widget/iconrenderer.h"
#include "ui/widget/scrollprotected.h"
#include "util/font-collections.h"
#include "util/document-fonts.h"
#include "util/recently-used-fonts.h"
namespace Inkscape {
namespace UI {
namespace Widget {
/**
* A container of widgets for selecting font faces.
*/
class FontCollectionSelector : public Gtk::Grid
{
public:
enum {TEXT_COLUMN, ICON_COLUMN, N_COLUMNS};
enum SelectionStates {SYSTEM_COLLECTION = -1, USER_COLLECTION, USER_COLLECTION_FONT};
FontCollectionSelector();
// Basic setup.
void setup_tree_view(Gtk::TreeView*);
void change_frame_name(const Glib::ustring&);
void setup_signals();
Glib::ustring get_text_cell_markup(Gtk::TreeIter const &iter);
// Custom renderers.
void text_cell_data_func(Gtk::CellRenderer*, Gtk::TreeIter const&);
void icon_cell_data_func(Gtk::CellRenderer*, Gtk::TreeIter const&);
void check_button_cell_data_func(Gtk::CellRenderer*, Gtk::TreeIter const&);
bool row_separator_func(const Glib::RefPtr<Gtk::TreeModel>&, const Gtk::TreeModel::iterator&);
void populate_collections();
void populate_system_collections();
void populate_document_fonts();
void populate_recently_used_fonts();
void populate_user_collections();
void populate_fonts(const Glib::ustring&);
// Signal handlers
void on_delete_icon_clicked(Glib::ustring const&);
void on_create_collection();
void on_rename_collection(const Glib::ustring&, const Glib::ustring&);
void on_delete_button_pressed();
void on_edit_button_pressed();
int deleltion_warning_message_dialog(const Glib::ustring&);
bool on_key_pressed(GdkEventKey*);
bool on_drag_motion(const Glib::RefPtr<Gdk::DragContext> &, int, int, guint) override;
void on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>, int, int, const Gtk::SelectionData&, guint, guint);
bool on_drag_drop(const Glib::RefPtr<Gdk::DragContext> &, int, int, guint) override;
// bool on_drag_failed(const Glib::RefPtr<Gdk::DragContext> &, const Gtk::DragResult);
void on_drag_leave(const Glib::RefPtr<Gdk::DragContext> &, guint) override;
// void on_drag_start(const Glib::RefPtr<Gdk::DragContext> &);
void on_drag_end(const Glib::RefPtr<Gdk::DragContext> &) override;
void on_selection_changed();
sigc::connection connect_signal_changed(sigc::slot <void (int)> slot) {
return signal_changed.connect(slot);
}
protected:
class FontCollectionClass : public Gtk::TreeModelColumnRecord
{
public:
Gtk::TreeModelColumn<Glib::ustring> name;
Gtk::TreeModelColumn<bool> is_editable;
FontCollectionClass()
{
add(name);
add(is_editable);
}
};
FontCollectionClass FontCollection;
Gtk::TreeView *treeview;
Gtk::Frame frame;
Gtk::ScrolledWindow scroll;
Gtk::TreeViewColumn text_column;
Gtk::TreeViewColumn del_icon_column;
Gtk::CellRendererText *cell_text;
Inkscape::UI::Widget::IconRenderer *del_icon_renderer;
Glib::RefPtr<Gtk::TreeStore> store;
// What type of object can be dropped.
std::vector<Gtk::TargetEntry> target_entries;
sigc::signal <void (int)> signal_changed;
};
} // namespace Widget
} // namespace UI
} // namespace Inkscape
#endif // INKSCAPE_UI_WIDGET_FONT_COLLECTION_SELECTOR_H
/*
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 :
|