Commit Graph

184 Commits

Author SHA1 Message Date
Benjamin Otte
7cf53a9f60 fontchooser: Take font description from model
... instead of taking face and constructing it from there.
2011-09-22 21:44:05 +02:00
Benjamin Otte
2b83d03604 fontchooser: Sanitize variable declarations
- no empty lines between variables
- no unnecessary casts
- use glib-style casts
- no spaces
2011-09-22 21:44:05 +02:00
Benjamin Otte
5a5737e3b6 fontchooser: Fix leak
the path variable is set, not filled in.
2011-09-22 21:44:05 +02:00
Benjamin Otte
a124d17825 fontchooser: Store an iter to the current font
Note that we cannot use GtkTreeSelection for this, because when the font
list is filtered the current font may not be visible.
2011-09-22 21:44:05 +02:00
Benjamin Otte
6499088f7f fontchooser: Store tree model member variables as GtkTreeModel
... and remove the now unnecessary treemodel casts everywhere.

Just code cleanup.
2011-09-22 21:44:05 +02:00
Benjamin Otte
3d87ee7716 fontchooser: Rename populate_list() function
Name it gtk_font_chooser_widget_load_fonts(). Also, don't take any
arguments, they were the same everywhere and they're member variables of
the font chooser anyway.
2011-09-22 21:44:04 +02:00
Benjamin Otte
6cbbc789d5 fontchooser: Make changing the preview text fast
Instead of reloading the font list, we now just queue a redraw. This
works, because the preview text is added using a cell data func instead
of a custom column.
2011-09-22 21:44:04 +02:00
Benjamin Otte
5834691e69 fontchooser: Use a cell_data_func for the font list
This way, we don't have to store the preview text in the list.
2011-09-22 21:44:04 +02:00
Benjamin Otte
3a77b7e005 fontchooser: Don't scroll in the populate_list() function 2011-09-22 21:44:04 +02:00
Benjamin Otte
ded10365a1 fontchooser: Remove needless scroll calls
Previous functions take care of scrolling already.
2011-09-22 21:44:04 +02:00
Benjamin Otte
3af04c1dce fontchooser: Introduce gtk_font_chooser_find_font()
... which looks up the font in the list of fonts. This then can be used
to select an actual font upon changes.

Also fixes cases where the get_family() and get_face() functions would
return outdated data when set_font() had been called.
2011-09-22 21:44:04 +02:00
Benjamin Otte
fe8ed0a3f6 fontchooser: Rewrite size changes
They now go through gtk_font_chooser_widget_take_font_desc(). The end
goal is to make all changes go through this function, so that all
updates that are happening are easy to track.

Another change is that the code now merges the font description instead
of just using the new one. This avoids weird situations when people set
the font "Bold" for example, which has neither a size nor a font family.
2011-09-22 21:44:04 +02:00
Benjamin Otte
af5f593b6d fontchooser: Fix size computation 2011-09-22 21:44:04 +02:00
Benjamin Otte
8f33324750 fontchooser: Fix gcc warnings 2011-09-22 21:44:04 +02:00
Benjamin Otte
34f9e6a0f3 fontchooser: Remove special case for a single signal handler 2011-09-19 22:11:06 +02:00
Benjamin Otte
a4c3271854 fontchooser: Remove useless code
gtk_adjustment_set_value() clamps itself, no need to do the clamping.

But I was impressed at the amount of comments.
2011-09-19 22:11:06 +02:00
Benjamin Otte
e465023051 fontchooser: Don't store the size separately
Instead, use the font description's size.
2011-09-19 22:11:06 +02:00
Benjamin Otte
6552a8245b fontchooser: Don't reload the fonts on style changes
It's not necessary, because nothing changes.
2011-09-19 22:11:06 +02:00
Benjamin Otte
64d3350264 fontchooser: Assume NULL screen means the default screen
... and update the font list only when the screen actually changes.
2011-09-19 22:11:06 +02:00
Benjamin Otte
ae5f82e455 fontchooser: Store the font description in the model
It's actually expensive to create (>5ms per font with >1000 fonts
installed), so better cache it.
2011-09-19 22:11:06 +02:00
Benjamin Otte
6d8010d3d4 fontchooser: Move the filter func to the visibility func
... instead of rereading all the fonts every time.

With this change, the liststore now contains every font face known to
GTK, so we can actually walk it for matching fonts.
2011-09-19 22:11:06 +02:00
Benjamin Otte
d88b7a6d6b fontchooser: Fix code to make it not look like GTK 0.9 2011-09-19 22:11:06 +02:00
Benjamin Otte
a5f516c818 fontchooser: Family or face can never be NULL
... so there's no need to special-case those situations.
2011-09-19 22:11:05 +02:00
Benjamin Otte
fb2bc139bb fontchooser: Use gtk_list_store_insert_with_values()
... instead of append() + set_values()
2011-09-19 22:11:05 +02:00
Benjamin Otte
824aeb77c6 fontchooserwidget: Simplify function
- Don't do unnecessary casts
- Fix weird variable declaration indenting
- Fix loop indentation
- Use a for loop for iterating over a list, instead of a while loop
- Casefold font name only once, instead of every iteration
- Remove needless true_var = true_var && TRUE assignment
2011-09-19 22:11:05 +02:00
Christian Persch
71c16bad33 Take font size also from the font description 2011-09-13 12:55:34 +02:00
Christian Persch
d82895127e Remove some unnecessary casts 2011-09-13 12:55:34 +02:00
Christian Persch
abd9242f33 Add GtkFontChooser:font-desc property
Add a way to set/get the font as a PangoFontDescription.
2011-09-13 12:55:33 +02:00
Christian Persch
1b818f2e46 Remove GtkFontChooser:[sg]et_font
Now that the setter doesn't return a value anymore, we can just use
g_object_[sg]et instead of having these vfuncs.
2011-09-13 12:55:22 +02:00
Christian Persch
0b7db6888a Setters should not return a boolean
The setter for the "font" property returned a boolean that indicated
whether the given font has been found. Instead, fall back to the default
font name when the given font doesn't exist.
2011-09-13 12:55:22 +02:00
Matthias Clasen
cf14868619 Cosmetic doc fixes 2011-09-13 12:55:22 +02:00
Christian Persch
85e95a765d Mark string for translation 2011-09-13 12:55:22 +02:00
Christian Persch
eb9efc9fd2 Rename GtkFontChooser:font-name to :font
GtkFontButton already has a property named "font-name" which may
conflict / be an ABI break when moving GtkFontButton to implement
GtkFontChooser. Also, this is more in line with how other parts in
gtk (e.g. GtkCellRendererText) call a font string property.
2011-09-13 12:55:21 +02:00
Christian Persch
5452525143 Make GtkFontChooser an interface
Make the GtkFontChooser API similar to the Gtk{File,Recent,App}Chooser
APIs by introducing GtkFontChooser as an interface, that has a default
implementation in GtkFontChooserWidget.

https://bugzilla.gnome.org/show_bug.cgi?id=657627
2011-09-13 12:55:21 +02:00