Re: gtk2 multithreaded programming win32 issue

2008-08-28 Thread Kuang-Chun Cheng
On Thu, Aug 28, 2008 at 3:42 AM, Tor Lillqvist <[EMAIL PROTECTED]> wrote:
>> Are these correct ?
>
> Yes,

OK, thanks.

Here is my another question.
My GUI require update after some non-gui thread finish it's task.

So I create an idle callback + GAsyncQueue in main thread.
When non-gui thread push message to GAsyncQueue, my idle callback will
be wakeup and do the GUI update.

And I found when idle callback block on GAsyncQueue, the GUI is locked !!
or the main event loop is blocked.

I then replace the g_async_queue_pop() by g_asysc_queue_try_pop(), it works but
take 100%CPU load.

Use g_async_queue_timed_pop() help ... but the GUI become polling driven instead
of event driven ... which I don't like.

Also replace idle callback by timeout callback works fine too, but again, it's
not event driven.

I also look into GObject system, impl. an object signal which will do
the GUI call.
Emit the signal from non-gui thread ... but this doesn't work.  The callback
function connect to the object will be run in non-gui thread instead
of main thread.
Is it possible for a GObject to connect to a callback which will be
invoke by thread A
when receive signal from thread B ?

Well, so far, I tried couple methods ... and only polling driven approach work.
Is this the only way to use Gtk2 under Win32.   Any better approach
(event driven)
which allow to update GUI by receiving trigger/signal from non-gui thread ?

Thanks a lot

Regards
KC



>
> --tml
>
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: gtk2 multithreaded programming win32 issue

2008-08-28 Thread jcupitt
Hi,

2008/8/28 Kuang-Chun Cheng <[EMAIL PROTECTED]>:
> My GUI require update after some non-gui thread finish it's task.
>
> So I create an idle callback + GAsyncQueue in main thread.
> When non-gui thread push message to GAsyncQueue, my idle callback will
> be wakeup and do the GUI update.

You don't need the GAsyncQueue. Just call g_idle_add() from the
non-gui thread and the idle callback will run in the gui thread next
time the main loop is idle. I do this in my app and it works well on
linux and windows.

John
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


How to set the font's size of the GtkLabel?

2008-08-28 Thread Lazy Fox
I wrote the following statememts to set a GtkLabel's font size.
But it seems don't work?
I'm not good at Pango, can anybody help me?
+---
| PangoAttrList *pg_attr_list = pango_attr_list_new();
| PangoAttribute *pg_attr = pango_attr_size_new(10);
|
| label = gtk_label_new("This is a label");
| pango_attr_list_change(pg_attr_list, pg_attr);
| gtk_label_set_attributes(GTK_LABEL(label), pg_attr_list);
+--
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: gtk_print

2008-08-28 Thread Richard Boaz
On Sat, Aug 23, 2008 at 2:32 AM, Paul Davis <[EMAIL PROTECTED]>
wrote:

 On Sat, 2008-08-23 at 00:28 +0100, Chris Vine wrote:
 > On Fri, 22 Aug 2008 19:04:19 -0400
 > Paul Davis <[EMAIL PROTECTED]> wrote:
 > > On Fri, 2008-08-22 at 14:12 +0100, Chris Vine wrote:
 > > > On Fri, 22 Aug 2008 13:40:20 +0200 (CEST)
 > > > "Richard Boaz" <[EMAIL PROTECTED]> wrote:
 > > > [snip]
 > >
 > >  [ ... snip snip snip ... ]
 > >
 > > this sounds like a disaster of an API.
 > >
 > > most other GTK/GDK APIs that involve things that ultimately come down
 > > to pixels seem to have variants that allow you to provide
 > > unstructured data and structured data, sometimes in multiple formats.
 > > there is often a way to get data directly from a file too.
 > >
 > > a print API that hides all the hard work of printer discovery and
 > > configuration but then prevents you from pointing it at a file to get
 > > the data to be printed seems fundamentally broken.
 >
 > On the issue of printing a postscript file under windows, I don't think
 > GTK+ should be expected to provide its own postscript interpreter, just
 > because windows does not natively support printing postscript in the
 > way that unix-like OSes do.

 aha. a very fair point, and one that is highly relevant to the OP's
 question. Richard, i think you need to think carefully about how you
 would print this file *outside* of GTK. if selecting a printer and
 identifying the file to be sent there is not enough to get the job done,
 its a bit hard to expect GTK to go the extra mile and work this way.

=

Hi again (sorry to be coming back to this so much later, was away...),

I guess what I'm really looking for is a separation between the two
distinct functionalities currently provided by GtkPrint.  As it is, it
provides two distinct features:

1) identification (and selection) of known/found printers, and
2) issuing commands for selected printer, commands being currently limited
to the Cairo family.

In my case, I have a *file* that I want to send to the printer.  If the
printer is PS-aware, then sending the file is enough, interpretation
happens at the printer (no?).  So, I need the functionality described by
1), but not the functionality described by 2).  Except that on windows
they are, seemingly, inseparable.

As stated, this is only a problem in the windows platform since
GtkPrintUnixDialog in conjunction with GtkPrintJob will send a manually
generated PS-file to the selected printer.

I guess I don't understand why this is available only on Unix?

For my 2-step solution, I have found a program (PrintFile) that will send
a PS file to a printer on Windows.  What exactly prevents the
functionality provided by this program from being imported into Gtk for
windows?; effectively providing the non-portable Unix print functionality.
 The only thing it does is send a PS file to the printer disabling the
windows driver from interpreting it as text, much like GtkPrintUnixDialog
and friends.

I realize that GtkPrint is a recent addition to the library and that first
editions do not necessarily provide all possible desired functionality; I
don't have a problem with this, evolution is what it is.  But I do wonder
if this gap (as perceived by me) will be addressed in some future release.

Or is windows so special that this isn't really possible?  ;)

cheers,

richard

___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: How to set the font's size of the GtkLabel?

2008-08-28 Thread Dov Grobgeld
Hi Lazy (great name),

The way to do it is to set the name of the label through:

gtk_widget_set_name(label, "foo");

and then define a style for the name "foo", that includes a font
specification:

gtk_rc_parse_string("style \"foo\" {\n"
  "font = \"Serif 32\"\n"
  "}\n"
  );

Hope this helps,
Dov

2008/8/28 Lazy Fox <[EMAIL PROTECTED]>

> I wrote the following statememts to set a GtkLabel's font size.
> But it seems don't work?
> I'm not good at Pango, can anybody help me?
>
> +---
> | PangoAttrList *pg_attr_list = pango_attr_list_new();
> | PangoAttribute *pg_attr = pango_attr_size_new(10);
> |
> | label = gtk_label_new("This is a label");
> | pango_attr_list_change(pg_attr_list, pg_attr);
> | gtk_label_set_attributes(GTK_LABEL(label), pg_attr_list);
>
> +--
>
> ___
> gtk-list mailing list
> gtk-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/gtk-list
>
>
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: How to set the font's size of the GtkLabel?

2008-08-28 Thread Tomas Carnecky
Dov Grobgeld wrote:
> Hi Lazy (great name),
> 
> The way to do it is to set the name of the label through:
> 
> gtk_widget_set_name(label, "foo");
> 
> and then define a style for the name "foo", that includes a font
> specification:
> 
> gtk_rc_parse_string("style \"foo\" {\n"
>   "font = \"Serif 32\"\n"
>   "}\n"
>   );
> 

Ugh, that's complicated. An easier way is:

GtkLabel *label = gtk_label_new("");
gtk_label_set_markup(label, "This is a
label");

See http://library.gnome.org/devel/pango/stable/PangoMarkupFormat.html
how to use the pango markup language.

> 
> 2008/8/28 Lazy Fox <[EMAIL PROTECTED]>
> 
>> I wrote the following statememts to set a GtkLabel's font size.
>> But it seems don't work?
>> I'm not good at Pango, can anybody help me?
>>
>> +---
>> | PangoAttrList *pg_attr_list = pango_attr_list_new();
>> | PangoAttribute *pg_attr = pango_attr_size_new(10);
>> |
>> | label = gtk_label_new("This is a label");
>> | pango_attr_list_change(pg_attr_list, pg_attr);
>> | gtk_label_set_attributes(GTK_LABEL(label), pg_attr_list);
>>
>> +--
>>
>> ___
>> gtk-list mailing list
>> gtk-list@gnome.org
>> http://mail.gnome.org/mailman/listinfo/gtk-list
>>
>>
> ___
> gtk-app-devel-list mailing list
> [EMAIL PROTECTED]
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
> 

___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: How to set the font's size of the GtkLabel?

2008-08-28 Thread Dov Grobgeld
Hi Tomas,

You are certainly right The style method is more suited when you want to
change additional properties like background color, etc. I stand corrected.

Regards,
Dov

2008/8/28 Tomas Carnecky <[EMAIL PROTECTED]>

> Dov Grobgeld wrote:
> > Hi Lazy (great name),
> >
> > The way to do it is to set the name of the label through:
> >
> > gtk_widget_set_name(label, "foo");
> >
> > and then define a style for the name "foo", that includes a font
> > specification:
> >
> > gtk_rc_parse_string("style \"foo\" {\n"
> >   "font = \"Serif 32\"\n"
> >   "}\n"
> >   );
> >
>
> Ugh, that's complicated. An easier way is:
>
> GtkLabel *label = gtk_label_new("");
> gtk_label_set_markup(label, "This is a
> label");
>
> See http://library.gnome.org/devel/pango/stable/PangoMarkupFormat.html
> how to use the pango markup language.
>
> >
> > 2008/8/28 Lazy Fox <[EMAIL PROTECTED]>
> >
> >> I wrote the following statememts to set a GtkLabel's font size.
> >> But it seems don't work?
> >> I'm not good at Pango, can anybody help me?
> >>
> >>
> +---
> >> | PangoAttrList *pg_attr_list = pango_attr_list_new();
> >> | PangoAttribute *pg_attr = pango_attr_size_new(10);
> >> |
> >> | label = gtk_label_new("This is a label");
> >> | pango_attr_list_change(pg_attr_list, pg_attr);
> >> | gtk_label_set_attributes(GTK_LABEL(label), pg_attr_list);
> >>
> >>
> +--
> >>
> >> ___
> >> gtk-list mailing list
> >> gtk-list@gnome.org
> >> http://mail.gnome.org/mailman/listinfo/gtk-list
> >>
> >>
> > ___
> > gtk-app-devel-list mailing list
> > [EMAIL PROTECTED]
> > http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
> >
>
>
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: gtk2 multithreaded programming win32 issue

2008-08-28 Thread Kuang-Chun Cheng
On Thu, Aug 28, 2008 at 5:23 PM,  <[EMAIL PROTECTED]> wrote:
> Hi,
>
> 2008/8/28 Kuang-Chun Cheng <[EMAIL PROTECTED]>:
>> My GUI require update after some non-gui thread finish it's task.
>>
>> So I create an idle callback + GAsyncQueue in main thread.
>> When non-gui thread push message to GAsyncQueue, my idle callback will
>> be wakeup and do the GUI update.
>
> You don't need the GAsyncQueue. Just call g_idle_add() from the
> non-gui thread and the idle callback will run in the gui thread next
> time the main loop is idle. I do this in my app and it works well on
> linux and windows.
Hi John,

Could you explain more on this ?  Is calling g_idle_add() from
"NON-GUI" thread important ?   I think no matter which thread invoke
g_idle_add(),
the idle callback will be associated with default main loop, am I correct ?

Did you put a g_usleep() in your idle callback ?  If not, how did you avoid
the idle callback to take all of the CPU loading ?

Thanks
KC



>
> John
>
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: gtk2 multithreaded programming win32 issue

2008-08-28 Thread Tor Lillqvist
> Could you explain more on this ?  Is calling g_idle_add() from
> "NON-GUI" thread important ?

No, you can call it from any thread.

> I think no matter which thread invoke g_idle_add(),
> the idle callback will be associated with default main loop, am I correct ?

Yes.

> Did you put a g_usleep() in your idle callback ?  If not, how did you avoid
> the idle callback to take all of the CPU loading ?

Have the idle callback function return FALSE... Schedule it again with
g_idle_add() whenever you have something new that needs to be done in
the GUI thread.

--tml
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: gtk2 multithreaded programming win32 issue

2008-08-28 Thread jcupitt
2008/8/28 Tor Lillqvist <[EMAIL PROTECTED]>:
> Have the idle callback function return FALSE... Schedule it again with
> g_idle_add() whenever you have something new that needs to be done in
> the GUI thread.

I wrote a tiny bit of sample code in an old mail:

  http://lists-archives.org/gtk/08308-gtk-and-threads.html

maybe that helps a bit.

John
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: gtk2 multithreaded programming win32 issue

2008-08-28 Thread Kuang-Chun Cheng
On Thu, Aug 28, 2008 at 9:23 PM,  <[EMAIL PROTECTED]> wrote:
> 2008/8/28 Tor Lillqvist <[EMAIL PROTECTED]>:
>> Have the idle callback function return FALSE... Schedule it again with
>> g_idle_add() whenever you have something new that needs to be done in
>> the GUI thread.

I were stuck in forever loop concept ...
"Have the idle callback function return FALSE" ... why
I did not think about this !!!  That's a great point !!  Thanks


>
> I wrote a tiny bit of sample code in an old mail:
>
>  http://lists-archives.org/gtk/08308-gtk-and-threads.html

It's very helpful.  Thanks again.

KC
>
> maybe that helps a bit.
>
> John
>
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Images in GTK over DirectFB - delay in image transitions

2008-08-28 Thread Harinandan S
Hi All,

I made the transition smooth by destroying only the image and recreating a
new one. I now have another problem - memory leak. I first create a pixbuf,
scale it and then create an image widget from the scaled pixbuf. I see a
memory leak here. I feel that its because i am not freeing pixbuf at all. My
code is like this

pixbuf = gdk_pixbuf_new_from_file(filename,NULL );
pixbuf_scaled = gdk_pixbuf_scale_simple(pixbuf,640,480,GDK_INTERP_BILINEAR);
image = gtk_image_new_from_pixbuf(pixbuf_scaled);

I destroy image whenever i need a new image later. How can i free pixbuf and
pixbuf_scaled after image widget is created?


On Wed, Aug 27, 2008 at 8:28 PM, richard boaz <[EMAIL PROTECTED]> wrote:

> I guess I don't understand why you have to create new windows.  Why can you
> not use the same window and GtkImage widget to display all images?  thus
> avoiding having to create them every time?
>
>
> On Wed, Aug 27, 2008 at 4:50 PM, Harinandan S <[EMAIL PROTECTED]>wrote:
>
>>  Hi,
>>
>> I also tried a sequence in which i create next frame before hand. ie
>>
>> on startup:
>> create window1
>> show window 1
>> create window2
>>
>> on next
>> show window2
>> create window3
>>
>> Similarly on subsequent next clicks. I see no improvement. In the above
>> sequence only show window was the work, which made me think that show may be
>> taking most of the time in transition.
>> I am not able to use the sequence you mentioned since I use GtkImage and
>> not GtkDrawingArea.
>> On Wed, Aug 27, 2008 at 7:53 PM, richard boaz <[EMAIL PROTECTED]>wrote:
>>
>>> Hi,
>>>
>>> Try a different sequence, if possible:
>>>
>>>1. at startup, create window and drawing area to display image
>>>2. never destroy window and drawing area, except on application exit
>>>3. on next:
>>>3.1  destroy previous image
>>>3.2 create next image for display
>>>4. invoke the expose callback on the drawing area to display image
>>>from 3.2
>>>
>>> With this sequence, you are guaranteed that the only work required is to
>>> create the next image and display it, i.e., the absolute minimum of work
>>> required.
>>>
>>> richard
>>>
>>> 2008/8/27 Harinandan S <[EMAIL PROTECTED]>
>>>
   Hi All,

 I am implementing a image viewer using GTK on DirectFB on an embedded
 ARM. When i press next i should get a new image. At present i am putting an
 image(VGA size) in a window and destroying the window and creating a new
 window with next image. I see that its taking a lot of time in transition.

 At present my sequence is :

  when next button is pressed -
   1. Create new window with new image.
   2. Show new window
   3. Destroy old window

 I thought old window will still be shown until new window is created so
 transition will be smooth. But still transition is taking time.

 Is there any better way to do this so that the transition is smooth?

 --
 Regards,
 Harinandan S

 ___
 gtk-list mailing list
 gtk-list@gnome.org
 http://mail.gnome.org/mailman/listinfo/gtk-list


>>>
>>
>>
>> --
>> Regards,
>> Harinandan S
>>
>
>


-- 
Regards,
Harinandan S
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: How to set the font's size of the GtkLabel?

2008-08-28 Thread Lazy Fox
Is the pango markup language most popular way to set font's style?

On Thu, Aug 28, 2008 at 8:16 PM, Tomas Carnecky <[EMAIL PROTECTED]> wrote:

> Dov Grobgeld wrote:
> > Hi Lazy (great name),
> >
> > The way to do it is to set the name of the label through:
> >
> > gtk_widget_set_name(label, "foo");
> >
> > and then define a style for the name "foo", that includes a font
> > specification:
> >
> > gtk_rc_parse_string("style \"foo\" {\n"
> >   "font = \"Serif 32\"\n"
> >   "}\n"
> >   );
> >
>
> Ugh, that's complicated. An easier way is:
>
> GtkLabel *label = gtk_label_new("");
> gtk_label_set_markup(label, "This is a
> label");
>
> See http://library.gnome.org/devel/pango/stable/PangoMarkupFormat.html
> how to use the pango markup language.
>
> >
> > 2008/8/28 Lazy Fox <[EMAIL PROTECTED]>
> >
> >> I wrote the following statememts to set a GtkLabel's font size.
> >> But it seems don't work?
> >> I'm not good at Pango, can anybody help me?
> >>
> >>
> +---
> >> | PangoAttrList *pg_attr_list = pango_attr_list_new();
> >> | PangoAttribute *pg_attr = pango_attr_size_new(10);
> >> |
> >> | label = gtk_label_new("This is a label");
> >> | pango_attr_list_change(pg_attr_list, pg_attr);
> >> | gtk_label_set_attributes(GTK_LABEL(label), pg_attr_list);
> >>
> >>
> +--
> >>
> >> ___
> >> gtk-list mailing list
> >> gtk-list@gnome.org
> >> http://mail.gnome.org/mailman/listinfo/gtk-list
> >>
> >>
> > ___
> > gtk-app-devel-list mailing list
> > [EMAIL PROTECTED]
> > http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
> >
>
>


-- 
--
┏┓
┃菩提本无树,明镜亦非台。本来无一物,何处惹尘埃。┃
┗┛
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: How to set the font's size of the GtkLabel?

2008-08-28 Thread Lazy Fox
I find another way:
+-
| PangoFontDescription * desc = pango_font_description_new();
| pango_font_description_set_size(desc, 50*PANGO_SCALE);
| .
| .
| gtk_widget_modify_font(label, desc);
+-

Is this a better choice, or the pango markup language?


On 8/28/08, Dov Grobgeld <[EMAIL PROTECTED]> wrote:
>
> Hi Lazy (great name),
>
> The way to do it is to set the name of the label through:
>
> gtk_widget_set_name(label, "foo");
>
> and then define a style for the name "foo", that includes a font
> specification:
>
> gtk_rc_parse_string("style \"foo\" {\n"
>   "font = \"Serif 32\"\n"
>   "}\n"
>   );
>
> Hope this helps,
> Dov
>
> 2008/8/28 Lazy Fox <[EMAIL PROTECTED]>
>
>> I wrote the following statememts to set a GtkLabel's font size.
>> But it seems don't work?
>> I'm not good at Pango, can anybody help me?
>>
>> +---
>> | PangoAttrList *pg_attr_list = pango_attr_list_new();
>> | PangoAttribute *pg_attr = pango_attr_size_new(10);
>> |
>> | label = gtk_label_new("This is a label");
>> | pango_attr_list_change(pg_attr_list, pg_attr);
>> | gtk_label_set_attributes(GTK_LABEL(label), pg_attr_list);
>>
>> +--
>>
>> ___
>> gtk-list mailing list
>> gtk-list@gnome.org
>> http://mail.gnome.org/mailman/listinfo/gtk-list
>>
>>
>
>



-- 
--
┏┓
┃菩提本无树,明镜亦非台。本来无一物,何处惹尘埃。┃
┗┛
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


GTK over DirectFB in 4 colour mode

2008-08-28 Thread Harinandan S
Hi All,

I've an embedded sytem having only 2 bits per pixel thus four colours. Is it
possible to run GTK over DirectFB on this platform?
-- 
Regards,
Harinandan S
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list