Re: [Vala] Gtk.FontChooser problem



OK, I tracked the problem down to the mismatch between the .vapi and
the Gtk headers I have installed on my system (up-to-date Debian,
testing branch):

inequation spearhead:~/projects/PerceptVala/src$ grep gtk_font_chooser
`locate *gtk*.h`
/usr/include/gtk-3.0/gtk/gtkfontchooser.h: * @data: (closure): user
data passed to gtk_font_chooser_set_filter_func()
/usr/include/gtk-3.0/gtk/gtkfontchooser.h: * shown in a
#GtkFontChooser. See gtk_font_chooser_set_filter_func().
/usr/include/gtk-3.0/gtk/gtkfontchooser.h:#define
GTK_TYPE_FONT_CHOOSER                 (gtk_font_chooser_get_type ())
/usr/include/gtk-3.0/gtk/gtkfontchooser.h:GType
gtk_font_chooser_get_type                 (void) G_GNUC_CONST;
/usr/include/gtk-3.0/gtk/gtkfontchooser.h:PangoFontFamily
*gtk_font_chooser_get_font_family          (GtkFontChooser
*fontchooser);
/usr/include/gtk-3.0/gtk/gtkfontchooser.h:PangoFontFace
*gtk_font_chooser_get_font_face            (GtkFontChooser
*fontchooser);
/usr/include/gtk-3.0/gtk/gtkfontchooser.h:gint
gtk_font_chooser_get_font_size            (GtkFontChooser
*fontchooser);
/usr/include/gtk-3.0/gtk/gtkfontchooser.h:
gtk_font_chooser_get_font_desc            (GtkFontChooser
*fontchooser);
/usr/include/gtk-3.0/gtk/gtkfontchooser.h:void
gtk_font_chooser_set_font_desc            (GtkFontChooser
*fontchooser,
/usr/include/gtk-3.0/gtk/gtkfontchooser.h:gchar*
gtk_font_chooser_get_font                 (GtkFontChooser
*fontchooser);
/usr/include/gtk-3.0/gtk/gtkfontchooser.h:void
gtk_font_chooser_set_font                 (GtkFontChooser
*fontchooser,
/usr/include/gtk-3.0/gtk/gtkfontchooser.h:gchar*
gtk_font_chooser_get_preview_text         (GtkFontChooser
*fontchooser);
/usr/include/gtk-3.0/gtk/gtkfontchooser.h:void
gtk_font_chooser_set_preview_text         (GtkFontChooser
*fontchooser,
/usr/include/gtk-3.0/gtk/gtkfontchooser.h:gboolean
gtk_font_chooser_get_show_preview_entry   (GtkFontChooser
*fontchooser);
/usr/include/gtk-3.0/gtk/gtkfontchooser.h:void
gtk_font_chooser_set_show_preview_entry   (GtkFontChooser
*fontchooser,
/usr/include/gtk-3.0/gtk/gtkfontchooser.h:void
gtk_font_chooser_set_filter_func          (GtkFontChooser
*fontchooser,
/usr/include/gtk-3.0/gtk/gtkfontchooserdialog.h:#define
GTK_TYPE_FONT_CHOOSER_DIALOG
(gtk_font_chooser_dialog_get_type ())
/usr/include/gtk-3.0/gtk/gtkfontchooserdialog.h:GType
gtk_font_chooser_dialog_get_type         (void) G_GNUC_CONST;
/usr/include/gtk-3.0/gtk/gtkfontchooserdialog.h:GtkWidget*
gtk_font_chooser_dialog_new              (const gchar          *title,
/usr/include/gtk-3.0/gtk/gtkfontchooserwidget.h:#define
GTK_TYPE_FONT_CHOOSER_WIDGET
(gtk_font_chooser_widget_get_type ())
/usr/include/gtk-3.0/gtk/gtkfontchooserwidget.h:GType
gtk_font_chooser_widget_get_type                 (void) G_GNUC_CONST;
/usr/include/gtk-3.0/gtk/gtkfontchooserwidget.h:GtkWidget*
gtk_font_chooser_widget_new                      (void);
inequation spearhead:~/projects/PerceptVala/src$

Whereas the relevant part of the .vapi looks like this (I'm using Vala 0.14):

        public class FontChooser : Gtk.Box, Atk.Implementor,
Gtk.Buildable, Gtk.Orientable {
                [CCode (has_construct_function = false, type = "GtkWidget*")]
                public FontChooser ();
                public unowned Pango.FontFace get_face ();
                public unowned Pango.FontFamily get_family ();
                public unowned string get_font_name ();
                public unowned string get_preview_text ();
                public bool get_show_preview_entry ();
                public int get_size ();
                public void set_filter_func (owned Gtk.FontFilterFunc filter);
                public bool set_font_name (string fontname);
                public void set_preview_text (string text);
                public void set_show_preview_entry (bool show_preview_entry);
                public string font_name { get; set; }
                public string preview_text { get; set; }
                public bool show_preview_entry { get; set; }
                public virtual signal void font_activated (string fontname);
        }

So, we have a funny situation here - there are different declarations
in the Valadoc, different in the .vapi, and different ones in the Gtk
headers. Note, for instance, the differences between the get_size()
and get_font_size() methods.

The question remains - which one is wrong and/or not up-to-date?

W dniu 15 kwietnia 2012 19:55 użytkownik Leszek Godlewski
<lg inequation org> napisał:
I'm trying to adapt the second Pango/Cairo sample
(http://live.gnome.org/Vala/PangoCairoSample) to my needs. I'm stuck
at setting the font with a FontButton (i.e. getting the
FontDescription from the FontChooser interface), though:

CharacterRenderer.vala:20.32-20.59: error: The name `get_font_desc'
does not exist in the context of `Gtk.FontChooser'
               playout.set_font_description(m_font_chooser.get_font_desc());

I don't understand it. It's all according to what's in the Valadoc:

http://valadoc.org/#!api=gtk+-3.0/Gtk.FontChooser

What am I doing wrong? I'm compiling with --pkg gtk+-3.0 --pkg cairo
--pkg pango --pkg gee-1.0.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]