Commit Graph

73 Commits

Author SHA1 Message Date
Christophe Fergeau
506d59f526 Return correct font from gtk_font_chooser_widget_find_font
Commit 30a1c4ab fixed several memleaks including one in
gtk_font_chooser_widget_find_font.

However, the fix causes one extra call to gtk_tree_model_iter_next()
after finding the font we look for (ie pango_font_description_equal
returns TRUE): the 'increment' part of the for loop
(gtk_tree_model_iter_next) is run before the 'exit condition' of the for
loop is evaluated.

This commit reverts this part of commit 30a1c4ab and adds an extra
call to pango_font_description_free in order to fix the leak.

https://bugzilla.gnome.org/show_bug.cgi?id=739111
2014-10-26 21:53:33 -04:00
Christophe Fergeau
77487fef2f fontchooserwidget: Don't invalidate priv->font_iter in load_fonts
When using GtkFontChooserButton, the same GtkFontChooserWidget can be
hidden and shown multiple times. When doing that, the font that was
chosen the previous time should be the selected one in the
GtkFontChooserWidget, however this does not work as expected and a
somehow 'random' font gets selected (or none) instead.

Every time the font chooser widget is shown, its style will be updated,
causing gtk_font_chooser_widget_style_updated and then
gtk_font_chooser_widget_load_fonts to be called.

gtk_font_chooser_widget_load_fonts starts by clearing the GtkListStore
listing the available fonts, repopulates it, and then makes sure the
current font is selected.

However, this does not work as expected, as during the call to
gtk_list_store_clear, the cursor_changed_cb will be invoked multiple
times when the GtkTreeView cursor gets moved when the line where the
cursor currently is gets removed. This will cause the 'current font'
state (priv->font_desc) to be unexpectedly modified, and when
gtk_font_chooser_widget_load_fonts tries to reposition the cursor to the
'current font', we won't get the expect result.

This commit avoids that by making sure cursor_changed_cb does not get
called when we call gtk_list_store_clear in
gtk_font_chooser_widget_load_fonts.

https://bugzilla.gnome.org/show_bug.cgi?id=739111
2014-10-26 21:53:33 -04:00
Matthias Clasen
2eacaf2dd2 GtkFontChooserWidget: Plug several memleaks
These were showing up in valgrind.
2014-10-14 23:59:25 -04:00
Benjamin Otte
0e34c87211 fontchooserwidget: Use text attributes for the preview
... instead of adding a custom CSS provider.
2014-10-03 06:18:07 +02:00
Matthias Clasen
af4031d9fe GtkFontChooserWidget: Stop using deprecated API 2014-10-02 00:30:52 -04:00
Matthias Clasen
0f9fc277c2 GtkFontChooser: Prevent font fallback in the preview
We don't want to preview the fallback fonts, after all.
https://bugzilla.gnome.org/show_bug.cgi?id=570414
2014-08-15 17:29:34 -04:00
Matthias Clasen
a8ed0dd4ee GtkFontChooserWidget: Allow fractional font sizes
With this change, we let users enter up to 2 decimals in the entry,
to specify font sizes exactly. The slider still rounds to whole
numbers.

https://bugzilla.gnome.org/show_bug.cgi?id=665711
2014-08-15 14:57:31 -04:00
Behdad Esfahbod
dd6c2391d2 GtkFontChooserWidget: Use a better display name for the font
Instead of reconstructing a display name from the
PangoFontDescription, use the font family and face
objects, which have the original font. This lets us
get the names of fonts like Noto Sans CJK DemiLight
right, which would be shown as Noto Sans CJK SemiLight
when mangled via PangoFontDescription, since Pango
treats 'DemiLight' as an alias for the SemiLight weight.

https://bugzilla.gnome.org/show_bug.cgi?id=733832
2014-08-15 14:12:10 -04:00
Matthias Clasen
d669926130 font chooser: Update font list on font changes
We do get a style-updated emission when new fonts are installed.
Update the font list in this case.

https://bugzilla.gnome.org/show_bug.cgi?id=726476
2014-03-21 22:37:36 -04:00
William Jon McCann
469d333aa2 docs: use Returns: consistently
Instead of Return value:
2014-02-19 18:56:05 -05:00
William Jon McCann
4a11acdc8c resources: move resources into a subdirectory 2014-01-23 21:04:59 -05:00
Alberto Ruiz
ef77e4727c fontchooser: set the minimum size of the spinner to 1 2013-08-02 15:56:54 +02:00
Alberto Ruiz
20adc37a01 fontchoser: Fix slider position update when switching from fonts with different recommended sizes 2013-08-02 15:51:33 +02:00
Matthias Clasen
cda60c3c40 Another round of template binding api changes
We rename the gtk_widget_class_bind_template_child{_internal}
macros by appending a _private to their name. Otherwise, it
would be too magic to pass the 'public' names as arguments,
but affect a member of the Private struct. At the same time,

Add two new macros with the old names,
gtk_widget_class_bind_template_child{_internal} that operate
on members of the instance struct.
2013-07-26 16:29:12 -04:00
Emmanuele Bassi
89ae3524a3 Rename the widget template API
The macros and functions are inconsistently named, and are not tied to
the "template" concept - to the point that it seems plausible to use
them without setting the template.

The new naming scheme is as follows:

  gtk_widget_class_bind_template_child_full
  gtk_widget_class_bind_template_callback_full

With the convenience macros:

  gtk_widget_class_bind_template_child
  gtk_widget_class_bind_template_child_internal
  gtk_widget_class_bind_template_callback

https://bugzilla.gnome.org/show_bug.cgi?id=700898
https://bugzilla.gnome.org/show_bug.cgi?id=700896
2013-07-26 13:52:15 -04:00
Alexander Larsson
a8e84545d1 widget: Use a real offset in gtk_widget_class_automate_child
Using an offset from the struct means you can have children in
both the public and private (via G_PRIVATE_OFFSET) parts of the
instance. It also matches the new private macros nicer.

https://bugzilla.gnome.org/show_bug.cgi?id=702563

Signed-off-by: Emmanuele Bassi <ebassi@gnome.org>
2013-07-26 08:41:09 -04:00
Alberto Ruiz
1859fe8dcf fontchooser: Fix smooth scrolling in the scale and the preview entry 2013-07-21 20:46:30 +02:00
Emmanuele Bassi
0899ef7cc9 gtk: Use new macros for defining private data
https://bugzilla.gnome.org/show_bug.cgi?id=702996
2013-07-09 09:30:02 +01:00
Tristan Van Berkom
21391027c4 GtkFontChooserWidget: Define children with a GtkBuilder template 2013-04-08 21:19:28 +09:00
Colomban Wendling
5b8d67a0aa fontchooserwidget: scroll to the currently selected row
Scroll to the selection when setting it so the selected font is
visible on screen.  This is especially useful if an initial font is
set for the user to see it.

https://bugzilla.gnome.org/show_bug.cgi?id=684156
2012-09-16 19:09:45 -04:00
Matthias Clasen
89b4c15e59 Use GtkSearchEntry 2012-06-11 22:45:31 -04:00
Benjamin Otte
2353d60b8a types: Move GtkAdustment declaration to gtktypes.h
... and make all the headers to not include gtkadjustment.h anymore. Of
course, also include it in the source files instead.
2012-03-03 19:45:03 +01:00
Javier Jardón
9d0febc9a6 Change FSF Address 2012-02-27 17:06:11 +00:00
Matthias Clasen
03a2b338ee Small documentation tweaks in font choosers 2012-02-14 16:36:55 -05:00
Benjamin Otte
1377ff08c0 fontchooserwidget: Handle dpi < 0
Just use 96.0
2011-12-16 04:50:11 +01:00
Matthias Clasen
5ff8fe6971 Documentation fixes
Mostly making sure that return values and varargs don't loose
their docs.
2011-09-25 21:04:49 -04:00
Christian Persch
370f0d1d86 Disable font fallback in the fontchooser preview
The preview is should show the selected font, not whatever
font contains glyphs for the preview text.
2011-09-23 00:32:44 +02:00
Benjamin Otte
18a6d9803e fontchooser: Use fixed height mode for the font face list
Now that we enforce same height anyway, this just further speeds things
up.
2011-09-22 21:44:05 +02:00
Benjamin Otte
1892c64acc fontchooser: Set a fixed size on the preview cell
This way, all rows have the same height. It has 3 advantages:
1) No actual computation is necessary to compute the size of the cell.
   This speeds up the list tremendously (filling out the list goes from
   25s to 3s).
2) Buggy fonts don't mess up the list anymore with their weird sizes.
   Instead, they are clipped / empty space is added.
3) Buggy fonts look more buggy. So their use is hopefully discouraged.
2011-09-22 21:44:05 +02:00
Benjamin Otte
59fbfd6205 fontchooser: Split out computing of the preview text attributes 2011-09-22 21:44:05 +02:00
Benjamin Otte
c1958ae9f2 fontchooser: Use absolute size for the preview text in the list
With absolute sizes, Pango is way better at getting the actual sizes of
the fonts to match up. It's a bit harder to compute a proper value for
this, whcih makes the code ugly, but as long as it works better...
2011-09-22 21:44:05 +02:00
Benjamin Otte
14154dac31 fontchooser: Set cell data as text + attributes instead of markup
This is quite a bit uglier, but allows more freedom.
2011-09-22 21:44:05 +02:00
Benjamin Otte
38af387ee3 fontchooser: Reselect font when it's unfiltered 2011-09-22 21:44:05 +02:00
Benjamin Otte
c9ef2d019e fontchooser: Only compare font descriptions when families match
This way, we can find fonts way quicker as we only need to create font
descriptions for fonts with matching families. Most importantly, we're
rather quick in the "the font doesn't exist" case.
2011-09-22 21:44:05 +02:00
Benjamin Otte
7d5d0a19e7 fontchooser: Only create font descriptions on demand
pango_font_describe() is expensive, so try not to use it.
2011-09-22 21:44:05 +02:00
Benjamin Otte
a40d0b44e1 fontchooser: Make all setters go through merge_font_desc()
Don't special case cursor_changed anymore.
2011-09-22 21:44:05 +02:00
Benjamin Otte
af8c3fe98e fontchooser: Update range marks properly
Range marks weren't updated previously when the font was set
programmatically. Also, setting the range marks could cause the font
size to change.
2011-09-22 21:44:05 +02:00
Benjamin Otte
59298d9e82 fontchooser: Reorganize code a bit
The main reason is so that we have a new function that we can use from
the cursor_changed_cb.
2011-09-22 21:44:05 +02:00
Benjamin Otte
132ccf021f fontchooser: Don't store the current face and family anymore
They can be queried on-demand from the font list.
2011-09-22 21:44:05 +02:00
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