15
15
#include <gtkmm/liststore.h>
17
17
#include "font-lister.h"
18
#include "FontFactory.h"
21
FontLister::FontLister ()
23
font_list_store = Gtk::ListStore::create (FontList);
25
if (font_factory::Default()->Families(&families))
27
for (unsigned int i = 0; i < families.length; ++i)
29
Gtk::TreeModel::iterator iter = font_list_store->append();
30
(*iter)[FontList.font] = reinterpret_cast<const char*>(families.names[i]);
33
if (font_factory::Default()->Styles (reinterpret_cast<const char*>(families.names[i]), &styles));
36
for (unsigned int n = 0; n < styles.length; ++n)
38
NRStyleRecord style_record = styles.records[n];
39
Styles = g_list_append (Styles, strdup(style_record.name));
42
(*iter)[FontList.styles] = Styles;
44
font_list_store_iter_map.insert (std::make_pair (reinterpret_cast<const char*>(families.names[i]), Gtk::TreePath (iter)));
50
FontLister::~FontLister ()
54
const Glib::RefPtr<Gtk::ListStore>
55
FontLister::get_font_list () const
57
return font_list_store;
22
FontLister::FontLister ()
24
font_list_store = Gtk::ListStore::create (FontList);
26
FamilyToStylesMap familyStyleMap;
27
font_factory::Default()->GetUIFamiliesAndStyles(&familyStyleMap);
29
// Grab the family names into a list and then sort them
30
std::list<Glib::ustring> familyList;
31
for (FamilyToStylesMap::iterator iter = familyStyleMap.begin();
32
iter != familyStyleMap.end();
34
familyList.push_back((*iter).first);
38
// Traverse through the family names and set up the list store (note that
39
// the styles list that are the map's values are already sorted)
40
while (!familyList.empty()) {
41
Glib::ustring familyName = familyList.front();
42
familyList.pop_front();
44
if (!familyName.empty()) {
45
Gtk::TreeModel::iterator treeModelIter = font_list_store->append();
46
(*treeModelIter)[FontList.font] = reinterpret_cast<const char*>(g_strdup(familyName.c_str()));
48
// Now go through the styles
50
std::list<Glib::ustring> &styleStrings = familyStyleMap[familyName];
51
for (std::list<Glib::ustring>::iterator it=styleStrings.begin();
52
it != styleStrings.end();
54
styles = g_list_append(styles, g_strdup((*it).c_str()));
57
(*treeModelIter)[FontList.styles] = styles;
59
font_list_store_iter_map.insert(std::make_pair(familyName, Gtk::TreePath(treeModelIter)));
64
FontLister::~FontLister ()
68
const Glib::RefPtr<Gtk::ListStore>
69
FontLister::get_font_list () const
71
return font_list_store;