Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
recently-used-fonts.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Recently used fonts are stored in a separate file in the fontcollections directory under the SYSTEM
4 * path. Recently used fonts are managed as a list with the help of a list.
5 *
6 * Authors:
7 * Vaibhav Malik <vaibhavmalik2018@gmail.com>
8 *
9 * The contents of this file may be used under the GNU General Public License Version 2 or later.
10 *
11 */
12
13#ifndef INK_RECENTLY_USED_FONTS_H
14#define INK_RECENTLY_USED_FONTS_H
15
16#include <list>
17#include <set>
18#include <glibmm/ustring.h>
19#include <sigc++/connection.h>
20#include <sigc++/signal.h>
21
22#include "io/dir-util.h"
23#include "io/resource.h"
24
25namespace Inkscape {
26
27inline const char *RECENTFONTS_FILENAME = "recently_used_fonts.log";
28
30public:
31 enum What {
34 User
35 };
36
37 static RecentlyUsedFonts* get();
38 ~RecentlyUsedFonts() = default;
39
40 // To load the last saved recent font list.
41 void init();
42 void clear();
43
44 // void print_recently_used_fonts();
45
46 // Read recently used fonts from file.
47 void read(const Glib::ustring& file_name);
49
50 void change_max_list_size(const int& max_size);
51 void prepend_to_list(const Glib::ustring& font_name);
52 void pop_front();
53 bool get_continuous_streak() const;
54 void set_continuous_streak(bool streak);
55
56 std::list<Glib::ustring> const &get_fonts() const;
57 int get_count() const;
58
59 sigc::connection connectUpdate(sigc::slot <void ()> slot) {
60 return update_signal.connect(slot);
61 }
62
63private:
65 void _read(const Glib::ustring& file_name);
67
68 // This list will contain the recently used fonts queue.
69 std::list <Glib::ustring> _recent_list;
70
71 // Defines the maximum size the recently_used_font_list can have.
72 // TODO: Add an option in the preferences to change the maximum size of
73 // the recently used font list.
74 int _max_size{};
75 bool continuous_streak = false;
76
77 sigc::signal <void ()> update_signal;
78};
79
80} // Namespace Inkscape
81
82#endif // INK_RECENTLY_USED_FONTS_H
83
84/*
85 Local Variables:
86 mode:c++
87 c-file-style:"stroustrup"
88 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
89 indent-tabs-mode:nil
90 fill-column:99
91 End:
92*/
93// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
void prepend_to_list(const Glib::ustring &font_name)
static RecentlyUsedFonts * get()
void change_max_list_size(const int &max_size)
void _read(const Glib::ustring &file_name)
sigc::connection connectUpdate(sigc::slot< void()> slot)
std::list< Glib::ustring > const & get_fonts() const
void read(const Glib::ustring &file_name)
std::list< Glib::ustring > _recent_list
sigc::signal< void()> update_signal
std::string file_name
TODO: insert short description here.
Helper class to stream background task notifications as a series of messages.
const char * RECENTFONTS_FILENAME
Inkscape::IO::Resource - simple resource API.