Re: Bring a widget to the foreground
Don't do that. Fixed size buffers are evil for string formatting. You better use g_strdup_printf even though this would lead to reallocations. But much better then end up with cropped text. On 01/02/2011 10:00 PM, jcup...@gmail.com wrote: On 2 January 2011 15:39, John Emmasjohn...@tiscali.co.uk wrote: To be honest, all I'm trying to do is create a button whose label font can be changed on demand. I've managed to achieve it by using an empty button with a label on top, except that the label doesn't always stay on top! Ah, OK, yes, there's a much simpler technique. Try something like this: txt = some text to display; font = sans 12; snprintf (button_text, 256, span font_desc=\%s\ size=\medium\%s/span, font, txt); gtk_label_set_markup ( GTK_LABEL (gtk_bin_get_child (GTK_BIN (button))), button_text); Assuming 'button' is a regular gtk button containing a label. John ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Bring a widget to the foreground
I agree, I was just trying to keep it simple. On Tuesday, 4 January 2011, Jaroslav Šmíd jardas...@gmail.com wrote: Don't do that. Fixed size buffers are evil for string formatting. You better use g_strdup_printf even though this would lead to reallocations. But much better then end up with cropped text. On 01/02/2011 10:00 PM, jcup...@gmail.com wrote: On 2 January 2011 15:39, John Emmasjohn...@tiscali.co.uk wrote: To be honest, all I'm trying to do is create a button whose label font can be changed on demand. I've managed to achieve it by using an empty button with a label on top, except that the label doesn't always stay on top! Ah, OK, yes, there's a much simpler technique. Try something like this: txt = some text to display; font = sans 12; snprintf (button_text, 256, span font_desc=\%s\ size=\medium\%s/span, font, txt); gtk_label_set_markup ( GTK_LABEL (gtk_bin_get_child (GTK_BIN (button))), button_text); Assuming 'button' is a regular gtk button containing a label. John ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: resetting timeout source
On Wed, Jan 5, 2011 at 5:48 AM, Jaroslav Šmíd jardas...@gmail.com wrote: Well, I cannot find anything in glib. If you use linux, you can use timerfd_create() to create pollable timer, create new GSource, attach the descriptor and you got your timer. Set intervals to zero to stop it, descriptor will get no more read events, and you don't even need to detach the source from event loop. You can 'reset' the timer without stopping it first. In fact, I just had to write something similar the other day - have a look at http://git.compiz.org/~dbo/compiz-with-glib-mainloop/tree/src/timer.cpp?h=glibmm-experimental#n30 (albeit it is glibmm, but you should be able to get the idea and translate it to regular glib, this is essentially what I did in reverse) On 12/25/2010 12:48 AM, Juan Pablo L. wrote: Hi, i m making an application which needs to perform a small task evey X secs, it will disconnect from a server if X seconds have passed without the aplication sending anything to the server, but if before completing the X secs i send something to the server i have to reset the timer for another X secs and so on like that all the time but my problem is that i can not find a way of resetting the timer without destroying and recreating the time again and again and again . which i find it too much for just the small task of resetting the timer, in other words i do not want to be freeing and getting new memory all the time i find that to be very inefficient and there should not be any need for it, so is there anyway to reset the timer without releasing its memory and getting memory all the time ? i know that if the callback function returns FALSE the source will not be added in the loop again so i guess i can just attach it again but that will only work when the timer ex pires so that will not help when the timer has not yet expired and i need to reset it for another X secs. So should know that i m attaching the timer to a non default main loop (it is a main loop inside a thread). any ideas will be very helpful. thanks!!! ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list -- Sam Spilsbury ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list