font-selector.cpp revision 783e7b605d323d06d42bb3cb155b6f1b3eece8b6
#define __SP_FONT_SELECTOR_C__
/*
* Font selection widgets
*
* Authors:
* Chris Lahey <clahey@ximian.com>
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
* Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
*
* Copyright (C) 1999-2001 Ximian, Inc.
* Copyright (C) 2002 Lauris Kaplinski
* Copyright (C) -2007 Authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <libnrtype/font-lister.h>
#include <libnrtype/font-instance.h>
#include "desktop.h"
#include "widgets/font-selector.h"
#include "preferences.h"
#include "unit-constants.h"
/* SPFontSelector */
struct SPFontSelector
{
unsigned int block_emit : 1;
int familyidx;
int styleidx;
bool fontsize_dirty;
};
struct SPFontSelectorClass
{
};
enum {
};
static void sp_font_selector_class_init (SPFontSelectorClass *c);
{
if (!type) {
sizeof(SPFontSelectorClass),
0, // base_init
0, // base_finalize
0, // class_finalize
0, // class_data
sizeof(SPFontSelector),
0, // n_preallocs
0 // value_table
};
}
return type;
}
static void sp_font_selector_class_init(SPFontSelectorClass *c)
{
1, G_TYPE_POINTER);
}
{
Glib::ustring tooltip = Glib::ustring::format(_("Font size"), " (", sp_style_get_css_unit_string(unit), ")");
}
{
/* Family frame */
gtk_widget_show (f);
gtk_tree_view_set_model (GTK_TREE_VIEW(fsel->family_treeview), GTK_TREE_MODEL (Glib::unwrap (store)));
g_signal_connect (G_OBJECT(selection), "changed", G_CALLBACK (sp_font_selector_family_select_row), fsel);
/* Style frame */
gtk_widget_show(f);
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
g_signal_connect (G_OBJECT(selection), "changed", G_CALLBACK (sp_font_selector_style_select_row), fsel);
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
g_signal_connect (G_OBJECT(fsel->size), "changed", G_CALLBACK (sp_font_selector_size_changed), fsel);
gtk_widget_show_all (l);
fsel->fontsize_dirty = false;
}
{
}
}
}
}
}
{
{
}
path = gtk_tree_path_new ();
gtk_tree_selection_select_path (gtk_tree_view_get_selection (GTK_TREE_VIEW (fsel->style_treeview)), path);
}
{
if (!fsel->block_emit)
{
}
}
/*
* Set the default list of font sizes, scaled to the users preferred unit
*/
{
int sizes[] = {
4, 6, 8, 9, 10, 11, 12, 13, 14, 16, 18, 20, 22, 24, 28,
32, 36, 40, 48, 56, 64, 72, 144
};
// Array must be same length as SPCSSUnit in style.h
for (unsigned int n = 0; n < G_N_ELEMENTS(sizes); ++n)
{
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(fsel->size), Glib::ustring::format(size).c_str());
}
}
{
if (text) {
value = -1;
}
int max_size = prefs->getInt("/dialogs/textandfont/maxFontSize", 10000); // somewhat arbitrary, but text&font preview freezes with too huge fontsizes
if (value <= 0) {
return; // could not parse value
}
{
fsel->fontsize_dirty = true;
}
}
{
//We need to check this here since most GtkTreeModel operations are not atomic
//See GtkListStore documenation, Chapter "Atomic Operations" --mderezynski
if (!model_family) return;
if (!model_style) return;
// FIXME: when a text object uses non-available font, font==NULL and we can't set size
// (and the size shown in the widget is invalid). To fix, here we must always get some
// default font, exactly the same as sptext uses for on-canvas display, so that
// font!=NULL ever.
if ( font ) {
}
}
}
fsel->fontsize_dirty = false;
if (font) {
}
}
{
return GTK_WIDGET(fsel);
}
/*
* Returns the index of the fonts closest style match from the provided list of styles
* Used in both the Text dialog and the Text toolbar to set the style combo on selection change
*/
{
return 0;
}
unsigned int currentStyleNumber = 0;
unsigned int bestStyleNumber = 0;
tempFont = (font_factory::Default())->FaceFromUIStrings(family.c_str(), static_cast<char*>(list->data));
if (tempFont) {
}
if( bestMatchForFont != NULL ) {
}
while (list) {
tempFont = font_factory::Default()->FaceFromUIStrings(family.c_str(), static_cast<char*>(list->data));
if (tempFont) {
}
if (currentMatchForFont) {
// Found a better match for the font we are looking for
}
}
}
if (bestMatchForFont)
if (incomingFont)
return bestStyleNumber;
}
{
if (font)
{
try {
} catch (...) {
return;
}
gtk_tree_selection_select_path (gtk_tree_view_get_selection (GTK_TREE_VIEW (fsel->family_treeview)), path.gobj());
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (fsel->family_treeview), path.gobj(), NULL, TRUE, 0.5, 0.5);
gtk_tree_selection_select_path (gtk_tree_view_get_selection (GTK_TREE_VIEW (fsel->style_treeview)), path_c);
{
gchar s[8];
}
}
}
{
}
}
/*
* Return the font size in pixels
*/
{
}
/*
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 :