Re: Why doesn't my label show up in the window
On 08/27/2012 09:30 AM, Frank Cox wrote: > My mailserver is small and I need to pace the email that I send to it to avoid > DOS-ing it. Therefore, I inject a pause of a fixed number of seconds between > sending each outbound email. > > If I'm not allowed to pause the program, then how shall I create the delay > between sending each message? > > Perhaps if I can get past this issue then everything else will fall into > place. many function calls in an event driven programs don't do anything immediately. Which can be very confusing the first time you work with them. --> gtk_widget_show() will not show the widget <-- so what does it do? it registers work-to-be-done in the event loop, so once the event loop has finished working on higher priority things, it will show the widget. so that is the way you have to work with this: you register your email-to-be-sent in the main event loop, and the event loop will call the functions when it is time. Lucky for you the event loop has more options than just a priority, you can also register your function to be called after some time has passed. So create a list or queue in your program, and create a function that pops an item from the list and sends an email. register the function with a timeout with g_timeout_add_full() keep returning TRUE (= call me again) until there is no email to pop from the list. Olivier ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Trouble maximizing windows on MS Windows
On Mon, 27 Aug 2012 14:27:22 +1000 Jared Henley wrote: > Does anyone have a clue about how to solve this? I've trawled the 'net > and this list and come up with nothing. I'm probably the last person to try to provide a usable answer to anyone's question on this topic since I've just started learning GTK and haven't touched MS Windows since Win98. Having said that, it occurs to me that you might want to see what happens if you set gtk_window_default_size() to something equal to or larger than your screen. -- MELVILLE THEATRE ~ Real D 3D Digital Cinema ~ www.melvilletheatre.com www.creekfm.com - FIFTY THOUSAND WATTS of POW WOW POWER! ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Why doesn't my label show up in the window
Le 27/08/2012 11:05, Colomban Wendling a écrit : > Le 27/08/2012 00:20, Frank Cox a écrit : >> On Sun, 26 Aug 2012 22:49:26 +0200 >> Colomban Wendling wrote: >> >>> For example, I attached a dummy program that replicates yours but using >>> threading. >> >> Thanks loads for all of the information! Unfortunately, the dummy program >> that >> you attached wasn't actually attached. I'd love to see it, though, so I can >> get a direct look at what I've been doing wrong here. > > Woops, here it is. ...or not. Looks like I didn't forgot it even the first time but the ML is eating it. OK, here you go: https://gist.github.com/3486813 ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Why doesn't my label show up in the window
Le 27/08/2012 00:20, Frank Cox a écrit : > On Sun, 26 Aug 2012 22:49:26 +0200 > Colomban Wendling wrote: > >> For example, I attached a dummy program that replicates yours but using >> threading. > > Thanks loads for all of the information! Unfortunately, the dummy program > that > you attached wasn't actually attached. I'd love to see it, though, so I can > get a direct look at what I've been doing wrong here. Woops, here it is. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Why doesn't my label show up in the window
hi; On 27 August 2012 08:30, Frank Cox wrote: > On Mon, 27 Aug 2012 08:13:30 +0100 > Emmanuele Bassi wrote: > >> another thing is that if you feel you need to call sleep() anywhere in >> a GUI then you are doing it wrong on an epic scale. the first rule of >> mainloop-driven toolkits (such as GTK+) is: you do not block the main >> loop. the second rule of mainloop-driven toolkits is: you do *not* >> block the main loop. even if you're using sleep() to demonstrate the >> fact that your long running operation is blocking the GUI, you're >> doing it wrong. > > Okey dokey. I'll study your message in more detail tomorrow since it's > getting > pretty darn late here, but I do have one immediate question. > > My mailserver is small and I need to pace the email that I send to it to avoid > DOS-ing it. Therefore, I inject a pause of a fixed number of seconds between > sending each outbound email. > > If I'm not allowed to pause the program, then how shall I create the delay > between sending each message? create a queue with all the messages, then use g_timeout_add_seconds() to have a function called after a certain amount of seconds has elapsed — and send a single mail from the head of the queue, after which you update the queue. the timeout source function should return TRUE if there are elements in the queue, and FALSE otherwise. more information available here: http://developer.gnome.org/glib/stable/glib-The-Main-Event-Loop.html http://developer.gnome.org/glib/stable/glib-Double-ended-Queues.html ciao, Emmanuele. -- W: http://www.emmanuelebassi.name B: http://blogs.gnome.org/ebassi/ ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Why doesn't my label show up in the window
On Mon, 27 Aug 2012 08:13:30 +0100 Emmanuele Bassi wrote: > another thing is that if you feel you need to call sleep() anywhere in > a GUI then you are doing it wrong on an epic scale. the first rule of > mainloop-driven toolkits (such as GTK+) is: you do not block the main > loop. the second rule of mainloop-driven toolkits is: you do *not* > block the main loop. even if you're using sleep() to demonstrate the > fact that your long running operation is blocking the GUI, you're > doing it wrong. Okey dokey. I'll study your message in more detail tomorrow since it's getting pretty darn late here, but I do have one immediate question. My mailserver is small and I need to pace the email that I send to it to avoid DOS-ing it. Therefore, I inject a pause of a fixed number of seconds between sending each outbound email. If I'm not allowed to pause the program, then how shall I create the delay between sending each message? Perhaps if I can get past this issue then everything else will fall into place. -- MELVILLE THEATRE ~ Real D 3D Digital Cinema ~ www.melvilletheatre.com www.creekfm.com - FIFTY THOUSAND WATTS of POW WOW POWER! ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Why doesn't my label show up in the window
hi; On 27 August 2012 07:40, Frank Cox wrote: > Both of the attached modifications of the program appears to work properly > every > time. > > So is my problem that the label isn't actually ready to be drawn on the first > call to sleep() for some reason? you still fail at understanding the basic concept of event driven programming — i.e. you react to what the GUI tells you that happened, not the other way around — and, more importantly, at understanding the basic tenet of mainloop-driven toolkits, which is: Thou Shall Never Block Thy Main Loop. widgets are not "ready to be drawn" because you told them to: they have internal state that has to be updated, and given that the toolkit authors do not want to block the main loop, it will be mostly done lazily, and along with the full tree, instead of piecemeal. that's *the* main difference between event driven programming with graphical toolkits and programming done on the console: the widgets will tell *you* when they are being drawn, or when something happens. in other words, "in event driven programming, like in Soviet Russia, the toolkit updates you". another thing is that if you feel you need to call sleep() anywhere in a GUI then you are doing it wrong on an epic scale. the first rule of mainloop-driven toolkits (such as GTK+) is: you do not block the main loop. the second rule of mainloop-driven toolkits is: you do *not* block the main loop. even if you're using sleep() to demonstrate the fact that your long running operation is blocking the GUI, you're doing it wrong. let the main loop run; do not try and spin it yourself; do not try to block it; do not let long running operations in the same loop as your GUI loop, *ever*. everything I've seen from you code snippets contains at least one violation of these rules. stop trying to write code in GTK+ like you would do with ncurses. look at examples on the developer.gnome.org website; look at existing GTK+ applications; read books on event-driven programming. ciao, Emmanuele. -- W: http://www.emmanuelebassi.name B: http://blogs.gnome.org/ebassi/ ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list