Maximum height of line of text in Pango
Hi, how can I efficiently obtain the minimum height in pixels which is guaranteed to cover a text line in a given font? Basically, I need something like (metrics.get_ascent() + metrics.get_descent()) / pango.SCALE where metrics is a pango.FontMetrics. Unfotunately, the operation given above takes ages to compute and is thus not feasible in the context of drawing a widget to the screen. Any ideas? Thank you in advance Dominique ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: scrolledview
Selon James Scott Jr [EMAIL PROTECTED]: An idle handler would be a good fit here. I assumed that you are creating and filling textviews during the startup of your program and possibly before you enter the main_loop or gtk_main. Or possibly in a routine that does everything at once. Here is the potential problem: your create and populate actions require some additional gtk messages to be processed, which are waiting to get serviced by the gtk_main() loop. So thing s will not appear to settle down until after the gtk_main has been allowed to run. Using an idle handler puts your call to a Position/Size routine at the back of the waiting queue of needed messages, so by the time it's processed the other messages have done their job and all the textviews/scrollbars/gtkvboxes, and scrolled windows have settled down. -- wait, this assumes you issued a gtk_widget_show{_all} on the main window containing all this stuff! Its the gtk_widget_show that starts the cascade of messages which includes the size and realize messages. g_idle_add() or g_timeout_add(250,...) show do the trick. Thank you... you seem to be right. Due to the nature of Gtk I should wait all events/messages to be consumed before trying to do anything with widgets. Mehmet ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GObject docs improvements
On Fri, Feb 09, 2007 at 01:42:19PM +0100, Stefan Kost wrote: Deriving from classes that implement interfaces and changing the implementation would worth an explanation and example. Huh, sounds scary. ... Do you have pointers to an example? I must admit while I do this in some real world code and it works, I have never verified I do it right by analysing the gtype.c code (too scary). That's one of the reasons why I suggested it... A testing (non-real world) example is attached, of which only MyPrintable, MyParent and MyChild2 are interesting (MyChild does not change the implementation). If I attempt to summarize it: 1. Implement the interface *again* in the subclass (this is the controversial point): G_DEFINE_TYPE_EXTENDED (MyChild2, my_child2, MY_TYPE_PARENT, 0, G_IMPLEMENT_INTERFACE(MY_TYPE_PRINTABLE, my_child2_printable_init)) 2. Get the parent interface in the interface init function with g_type_interface_peek_parent() and override methods: static void my_child2_printable_init(MyPrintableIface *iface) { my_child2_parent_printable = g_type_interface_peek_parent(iface); iface-print = my_child2_print; } 3. Use thus obtained parent implementation to call it in the overriden method (if suitable): my_child2_parent_printable-print(printable); While checking for an example, just noticed that the Implemented Interfaces stuff in Gtkdoc seems quite borked. Need to fix that. In what sense? It seems to work for me -- though I should note I use svn trunk gtk-doc. Yeti -- Whatever. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GObject docs improvements
On Sat, Feb 10, 2007 at 10:38:11PM +0100, David Nečas (Yeti) wrote: A testing (non-real world) example is attached Maybe this time I won't forget? Yeti -- Whatever. === #include glib-object.h // /* */ /* Interface*/ /* */ /* Consists of one virtual method: print(). */ /* */ // #define MY_TYPE_PRINTABLE (my_printable_get_type()) #define MY_PRINTABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), MY_TYPE_PRINTABLE, MyPrintable)) #define MY_PRINTABLE_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST((obj), MY_TYPE_PRINTABLE, MyPrintableIface)) #define MY_IS_PRINTABLE(obj)(G_TYPE_CHECK_INSTANCE_TYPE((obj), MY_TYPE_PRINTABLE)) #define MY_PRINTABLE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE((obj), MY_TYPE_PRINTABLE, MyPrintableIface)) typedef struct _MyPrintable MyPrintable; /* Dummy typedef */ typedef struct _MyPrintableIface MyPrintableIface; struct _MyPrintableIface { GTypeInterface g_iface; void (*print)(MyPrintable *printable); }; GType my_printable_get_type (void) G_GNUC_CONST; void my_printable_print(MyPrintable *printable); // GType my_printable_get_type(void) { static GType printable_type = 0; if (!printable_type) { static const GTypeInfo printable_info = { sizeof(MyPrintableIface), NULL, NULL, NULL, NULL, NULL, 0, 0, NULL }; printable_type = g_type_register_static(G_TYPE_INTERFACE, MyPrintable, printable_info, 0); g_type_interface_add_prerequisite(printable_type, G_TYPE_OBJECT); } return printable_type; } void my_printable_print(MyPrintable *printable) { g_return_if_fail(MY_IS_PRINTABLE(printable)); g_return_if_fail(MY_PRINTABLE_GET_IFACE(printable)-print != NULL); MY_PRINTABLE_GET_IFACE(printable)-print(printable); } // /* */ /* Parent class */ /* */ /* Implements MyPrintable. */ /* */ // #define MY_TYPE_PARENT(my_parent_get_type()) #define MY_PARENT(obj)(G_TYPE_CHECK_INSTANCE_CAST((obj), MY_TYPE_PARENT, MyParent)) #define MY_PARENT_CLASS(klass)(G_TYPE_CHECK_CLASS_CAST((klass), MY_TYPE_PARENT, MyParentClass)) #define MY_IS_PARENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), MY_TYPE_PARENT)) #define MY_IS_PARENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), MY_TYPE_PARENT)) #define MY_PARENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), MY_TYPE_PARENT, MyParentClass)) typedef struct _MyParent MyParent; typedef struct _MyParentClass MyParentClass; struct _MyParent { GObject object; gint data; }; struct _MyParentClass { GObjectClass object_class; }; GType my_parent_get_type (void) G_GNUC_CONST; MyParent* my_parent_new (gint i); void my_parent_set_data (MyParent *parent, gint i); // static void my_parent_printable_init(MyPrintableIface *iface); static void my_parent_print (MyPrintable *printable); G_DEFINE_TYPE_EXTENDED (MyParent, my_parent, G_TYPE_OBJECT, 0, G_IMPLEMENT_INTERFACE(MY_TYPE_PRINTABLE, my_parent_printable_init)) static void my_parent_printable_init(MyPrintableIface *iface) { iface-print = my_parent_print; } static void my_parent_class_init(MyParentClass *klass) { } static void my_parent_init(MyParent *parent) { } static void my_parent_print(MyPrintable *printable) { MyParent *parent = MY_PARENT(printable); g_print(%p: data=%d\n, parent, parent-data); } MyParent* my_parent_new(gint i) { MyParent *instance; instance = g_object_new(MY_TYPE_PARENT, NULL); instance-data = i; return instance; } void my_parent_set_data(MyParent *parent, gint i) { parent-data = i; } // /*
Re: how to make an animation ;)
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Fri, Feb 09, 2007 at 01:39:17PM +0100, Enrico Sardi wrote: [EMAIL PROTECTED] pronuncio' le seguenti parole il 09/02/2007 10:19: Hi Tomas! [...] Even better: pixbufs know about animations and do it for you! [...] I saw gdk_pixbuf_animation_new_from_file but it only works with an animated file as input while I need to build the animation from a series of indipendent files...thanks for the help! Yes. Well, either you go Olivier's path (concoct an animated GIF with all your images -- you can even embed timing info in that), or you start with gdk_pixbuf_simple_anim_new() -- Creates a new, empty animation. and add frame by frame with: gdk_pixbuf_simple_anim_add_frame() -- Adds a new frame to animation. In a timeout function (or possibly in an idle handler) you might have to call gdk_pixbuf_animation_iter_advance() (I don't know if that's done for you). The whole page http://developer.gnome.org/doc/API/2.0/gdk-pixbuf/gdk-pixbuf-animation.html is worth a read. Regards - -- tomás -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFFzq6hBcgs9XrR2kYRAmE1AJ97E0EFY5IhTWerRPFCiCjJm/GmgQCfSDY6 fYb3nfhBh0DKznBgv2lazu0= =FGBc -END PGP SIGNATURE- ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list