Re: Best way to busy-wait in Python 3 / Gtk+ 3?

2012-10-07 Thread Michael Torrie
On 10/07/2012 08:41 PM, Simon Feltman wrote:
> On Sun, Oct 7, 2012 at 12:29 PM, Filip Lamparski
>  wrote:
>> On 7 October 2012 12:58,  wrote:
>>
>>> To have the load in another process, use a pipe to send worker results
>>> back to the main process, and add the pipe to your gtk main loop as an
>>> event source.
>>>
>>
>> Is there any way I could do that? I looked at GLib's main loop and Gtk's
>> main loop, but can't seem to find it.
> 
> Is the idea to have a first pass downloading image files in a separate
> process and then use a thread to load them into memory? I don't know
> much about GStreamer but it seems like it might be helpful technology
> in this realm.
> 
> For completeness, you can use pythons multiprocessing module along
> with GLib's io watch:
> 
> parent, child = multiprocessing.Pipe()
> GLib.io_add_watch(parent, GLib.IOCondition.IN, event_callback)
> process = multiprocessing.Process(target=worker_func, args=(child,))
> process.start()

Maybe the best way is to avoid processes or threads altogether.  Since
downloading this thumbnail is io-bound, not cpu-bound, once you send off
your request, just use io watches to trigger the main loop when
something has come in.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Best way to busy-wait in Python 3 / Gtk+ 3?

2012-10-07 Thread Simon Feltman
On Sun, Oct 7, 2012 at 12:29 PM, Filip Lamparski
 wrote:
> On 7 October 2012 12:58,  wrote:
>
>> To have the load in another process, use a pipe to send worker results
>> back to the main process, and add the pipe to your gtk main loop as an
>> event source.
>>
>
> Is there any way I could do that? I looked at GLib's main loop and Gtk's
> main loop, but can't seem to find it.

Is the idea to have a first pass downloading image files in a separate
process and then use a thread to load them into memory? I don't know
much about GStreamer but it seems like it might be helpful technology
in this realm.

For completeness, you can use pythons multiprocessing module along
with GLib's io watch:

parent, child = multiprocessing.Pipe()
GLib.io_add_watch(parent, GLib.IOCondition.IN, event_callback)
process = multiprocessing.Process(target=worker_func, args=(child,))
process.start()

-Simon
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: [Pixman] debuging wxruby

2012-10-07 Thread Søren Sandmann
Svend Haugaard Sørensen  writes:

>> Most likely the issue is the same as in this bug:
>> 
>>https://bugs.freedesktop.org/show_bug.cgi?id4335
>> 
>> where some other library is using the TLS model "initial-exec", which
>> then conflicts with pixman using the "dynamic" model.
>
> And how do we find, test and fix that??
>
> Is the TLS supported by a certain dynamic library? Because the I
> can search for it.
>  
> PS. I don't use mesa, but the nvidia driver. 

It's possible that the root cause is this bug in glibc:

http://sourceware.org/bugzilla/show_bug.cgi?id=12453

If your C library is older than that, I'd try updating it first.


Søren
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Best way to busy-wait in Python 3 / Gtk+ 3?

2012-10-07 Thread Filip Lamparski
On 7 October 2012 12:58,  wrote:

> To have the load in another process, use a pipe to send worker results
> back to the main process, and add the pipe to your gtk main loop as an
> event source.
>

Is there any way I could do that? I looked at GLib's main loop and Gtk's
main loop, but can't seem to find it.


> You obviously can't use any gtk/glib stuff in your worker, you'd need
> to just make a .jpg, then do all the widget stuff in the main process,
>

Figured as much.

-- 
_
Filip Lamparski - FB  -
G+
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: [Pixman] debuging wxruby

2012-10-07 Thread Søren Sandmann
Svend Haugaard Sørensen  writes:

> On Sun, 07 Oct 2012 05:10:18 +0200
> sandm...@cs.au.dk (Søren Sandmann) wrote:
>
>> Svend Haugaard Sørensen  writes:
>> 
>> > The top of the stack dump look like this.
>> >
>> > #0  0xb47a6d9d in _pixman_lookup_composite_function
>> > (toplevel=0x80be750, op=PIXMAN_OP_SRC, src_format&2144,
>> > src_flags43063, mask_format=0, mask_flags92,
>> > dest_format=PIXMAN_a8r8g8b8, dest_flags4032255,
>> > out_imp=0xbfffb82c, out_func=0xbfffb828)
>> > at 
>> > /var/tmp/portage/x11-libs/pixman-0.26.0/work/pixman-0.26.0/pixman/pixman-utils.c:74
>> 
>> A crash at this point suggests that something is broken with thread
>> local storage on your setup. When you compiled pixman, which type of
>> thread local storage was detected by the configure script?
>> 
>> 
>> Søren
>
> The configure script write this to the output.
> checking for thread local storage (TLS) support... __thread
>
> I have posted the complete output on the gentoo forum.
> http://forums.gentoo.org/viewtopic-p-7157526.html#7157526
>  

Most likely the issue is the same as in this bug:

   https://bugs.freedesktop.org/show_bug.cgi?id=34335

where some other library is using the TLS model "initial-exec", which
then conflicts with pixman using the "dynamic" model.


Søren
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: gtk_tree_model_get end of Line marker

2012-10-07 Thread David Nečas
On Sun, Oct 07, 2012 at 05:43:52PM +0200, Arne Pagel wrote:
> because of my lazy programming style I sometimes forget or overwirte
> the comma before the -1  end of line marker for the gtk_tree_model_get
> or gtk_tree_store_set function.  This error can usually not be
> detected by the c-compilers, so that I had to spend some really
> unnecessary time to fix this typo.
> 
> Now I defined a makro for this, and in the case I forget the comma
> again at least I get a compiler error:
> 
> #define TREE_MODEL_EOL (int)-1
> 
> gtk_tree_model_get(model,iter,STUFF,&stuff,TREE_MODEL_EOL);
> 
> I think something like this would be integrated officially and also
> the all the examples would be updated, at lot of headache of many
> people could be avoided.

Errors related to the -1 sentinel could be avoided by much more
straightforward means: defining gtk_tree_model_get() with column id and
value pointer reversed, i.e. first comes the value pointer (presumably
non-NULL), then comes the column id.  Then gtk_tree_model_get() could
just carry __attribute__((sentinel)) a.k.a. G_GNUC_NULL_TERMINATED.  But
the Gtk+ devs decided otherwise.

It would be nice (also in other cases) if gcc had an attribute for
arbitrary constant-value sentinels.  Unfortunately, it has not.  The
corresponding bug

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28319

seems to be stale.  I'm not sure about LLVM but it does not seem to
support this either.

While I've never forget the comma before -1 I have forgetten the -1
entirely a few times so something that prevents all sentinels errors
would be quite useful.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: destroy a widget while keeping the window with Glade

2012-10-07 Thread Frank Cox
On Sun, 7 Oct 2012 16:59:48 +0900
Tristan Van Berkom wrote:

> Just right click on any widget in Glade's palette and chose "Add as toplevel"
> 
> Glade/GtkBuilder do not restrict you to using toplevel GtkWindows in your xml.

Well, whaddayaknow bout 'dat!

Thanks loads!

-- 
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


gtk_tree_model_get end of Line marker

2012-10-07 Thread Arne Pagel

Dear all,

because of my lazy programming style I sometimes forget or overwirte the comma 
before the -1  end of line marker for the
gtk_tree_model_get or gtk_tree_store_set function.
This error can usually not be detected by the c-compilers, so that I had to 
spend some really unnecessary time to
fix this typo.

Now I defined a makro for this, and in the case I forget the comma again at 
least I get a compiler error:

#define TREE_MODEL_EOL (int)-1

gtk_tree_model_get(model,iter,STUFF,&stuff,TREE_MODEL_EOL);

I think something like this would be integrated officially and also the all the 
examples would be updated,
at lot of headache of many people could be avoided.

--
 Arne

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Best way to busy-wait in Python 3 / Gtk+ 3?

2012-10-07 Thread Arne Pagel

Just notice the GTK is not thread Safe,
you might get in trouble if you make unsynchronized gtk_... calls from 
different processes.

I just found one Page with some hints at this:
http://blogs.operationaldynamics.com/andrew/software/gnome-desktop/gtk-thread-awareness

In my case I followed the rule “you must only make GTK library calls from the 
main thread”
and separated GUI and I/O stuff.
What also often helps instead heving a separate processes are functions called 
from gtk_idle_add or gtk_timeout_add,
but this would require that you can design your former process stuff 
nonblocking.

--
 Arne


Am 07.10.2012 11:23, schrieb jcup...@gmail.com:

On 6 October 2012 15:48, Filip Lamparski  wrote:

However, the thumbnail loading process takes a long time, so I want to put
it into another process, with the GUI displaying a spinner or a progress
bar until the loading finishes.


Sorry, I don't use Python much, but in C you'd start a thread to do
the load and then have that call g_idle_add() when it finished.
Meanwhile the main thread stays just handling inputs and repaints, but
you display some sort of busy indicator until the idle callback fires.
Something like:

on_load_button_click:
   busy = True
   update_view
   start worker thread

worker thread:
   load thumbnail
   g_idle_add (thumbnail_done, thumbnail)

thumbnail_done (thumbnail)
   busy = False
   set thumbnail
   update_view

John
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list



___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Best way to busy-wait in Python 3 / Gtk+ 3?

2012-10-07 Thread jcupitt
Sorry I missed the process bit.

To have the load in another process, use a pipe to send worker results
back to the main process, and add the pipe to your gtk main loop as an
event source.

You obviously can't use any gtk/glib stuff in your worker, you'd need
to just make a .jpg, then do all the widget stuff in the main process,

On 7 October 2012 12:34, Filip Lamparski  wrote:
> I specifically want to avoid using GLib's threading machinery in order to
> use multiprocessing, since later I want to add multithreading to the
> thumbnail loading process itself in order to utilise multiple cores more
> efficiently. That is because at first run, I have to download 128 images,
> and the server tends to take its sweet time.
>
> On 7 October 2012 10:23,  wrote:
>>
>> Sorry, I don't use Python much, but in C you'd start a thread to do
>> the load and then have that call g_idle_add() when it finished.
>> Meanwhile the main thread stays just handling inputs and repaints, but
>> you display some sort of busy indicator until the idle callback fires.
>>
>> John
>
>
>
>
> --
> _
> Filip Lamparski - FB - G+
>
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Best way to busy-wait in Python 3 / Gtk+ 3?

2012-10-07 Thread Filip Lamparski
I specifically want to avoid using GLib's threading machinery in order to
use multiprocessing, since later I want to add multithreading to the
thumbnail loading process itself in order to utilise multiple cores more
efficiently. That is because at first run, I have to download 128 images,
and the server tends to take its sweet time.

On 7 October 2012 10:23,  wrote:

> Sorry, I don't use Python much, but in C you'd start a thread to do
> the load and then have that call g_idle_add() when it finished.
> Meanwhile the main thread stays just handling inputs and repaints, but
> you display some sort of busy indicator until the idle callback fires.
>
> John
>



-- 
_
Filip Lamparski - FB  -
G+
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Best way to busy-wait in Python 3 / Gtk+ 3?

2012-10-07 Thread jcupitt
On 6 October 2012 15:48, Filip Lamparski  wrote:
> However, the thumbnail loading process takes a long time, so I want to put
> it into another process, with the GUI displaying a spinner or a progress
> bar until the loading finishes.

Sorry, I don't use Python much, but in C you'd start a thread to do
the load and then have that call g_idle_add() when it finished.
Meanwhile the main thread stays just handling inputs and repaints, but
you display some sort of busy indicator until the idle callback fires.
Something like:

on_load_button_click:
  busy = True
  update_view
  start worker thread

worker thread:
  load thumbnail
  g_idle_add (thumbnail_done, thumbnail)

thumbnail_done (thumbnail)
  busy = False
  set thumbnail
  update_view

John
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: destroy a widget while keeping the window with Glade

2012-10-07 Thread Tristan Van Berkom
On Sun, Oct 7, 2012 at 2:57 PM, Frank Cox  wrote:
> I've just started playing with Glade and once again I'm wondering if I'm using
> the wrong approach to get stuff done, since I can't find anything that tells 
> me
> how to do this.
>
> So far, I've been creating a main window for the program and simply creating 
> and
> destroying boxes and widgets within that window as different menu options are
> selected.
>
> Here is a simple example.
>
> I have a window with a box in it, which in turn contains a button.
>
> Now I want to be able to click on that button and destroy the box without
> destroying the window, then create a new box and a new button within the
> existing window.
>
> I can do this easily enough by writing the code to do the layout myself, but I
> don't see a way to do a Glade layout that can accomplish this.

Just right click on any widget in Glade's palette and chose "Add as toplevel"

Glade/GtkBuilder do not restrict you to using toplevel GtkWindows in your xml.

Cheers,
 -Tristan
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list