Sorry, for being a bit stupid and persistent
I appreciate your help, but I've also faced with structures:

When I changed a bit your example (I used 1 instead of 0)
    ClutterColor clutter_background_color = { 1, };

    g_debug("Colors: %x %x %x %x", clutter_background_color.red,
            clutter_background_color.blue,
            clutter_background_color.green,
            clutter_background_color.alpha);

I didn't get an expected result {1, 1, 1, 1}, I got {1, 0, 0, 0}:
DEBUG: Colors: 1 0 0 0

Is the example { num, } suitable only for {0,}? Or it makes the first
field equal to num.
The others attempts such as {1, 2,}; make the first and the second
field equal to 1 and 2, the third and so on are zero.

Thank you
Vlad Volodin


2009/3/17 Emmanuele Bassi <eba...@gmail.com>:
> On Tue, 2009-03-17 at 07:41 +0300, Vlad Volodin wrote:
>
>> Sorry, I've asked this question, but I can't find any explanation:
>>  GdkColor gdk_color = { 0, };
>>  ClutterColor clutter_color = { 0, };
>> They are structures, why do you use commas before the last brackets?
>
> because it will initialize all the members of a struct to 0. it's
> equivalent to:
>
>  GdkColor gdk_color = { 0, 0, 0, 0 };
>  ClutterColor clutter_color = { 0, 0, 0, 0 };
>
> or to:
>
>  GdkColor gdk_color;
>  ClutterColor clutter_color;
>
>  memset (&gdk_color, 0, sizeof (GdkColor));
>  memset (&clutter_color, 0, sizeof (ClutterColor));
>
> or, in C99:
>
>  GdkColor gdk_color = {
>    .pixel = 0,
>    .red = 0,
>    .green = 0,
>    .blue = 0
>  };
>  ClutterColor clutter_color = {
>    .red = 0,
>    .green = 0,
>    .blue = 0,
>    .alpha = 0
>  };
>
>> I've found C99 standard, where the same rule is applied to enum type
>> too.
>
> it doesn't have anything to do with enumerations -- enumerations will
> use the number to set their value explicitly, and it's something coming
> from ANSI C, way before C99.
>
> ciao,
>  Emmanuele.
>
>> Best wishes,
>> Vlad Volodin
>>
>> 2009/3/17 Emmanuele Bassi <eba...@gmail.com>:
>> > On Mon, 2009-03-16 at 23:28 +0300, Vlad Volodin wrote:
>> >
>> > first of all, you really want to use the clutter list.
>> >
>> >> I'm using libclutter-gtk (with GtkClutterEmbed widget), where I want
>> >> to display some graphics. If somebody doesn't know it, I'll describe
>> >> it a bit. It is derived from GtkWidget. Then it uses it's own canvas.
>> >> The canvas is white, and it doesn't have some kind of transparency.
>> >
>> >> So, as I thought, I decided to fill it's background with color, got
>> >> from it's GtkStyle. After some experiments I realized, that widgets
>> >> (main window, container and GtkClutterEmbed) don't have needed color:
>> >
>> > Containers in GTK+ do not usually have a background: they are assumed to
>> > be transparent transparent. GtkWindow does have a background color,
>> > though, since it'll have to provide the background for most widgets.
>> >
>> > to set the color of the Stage embedded inside GtkClutterEmbed you can
>> > get a specific color out of the GtkWindow style; you cannot do this at
>> > any time you like: you'll have to connect to the style-set signal of the
>> > GtkWindow that contains the GtkClutterEmbed-- at which point you have a
>> > guarantee that a GtkStyle has been applied to the widget.
>> >
>> > also, you have to remember that GdkColor and ClutterColor are not
>> > compatible structures: you have to convert between the two.
>> >
>> >  GdkColor gdk_color = { 0, };
>> >  ClutterColor clutter_color = { 0, };
>> >
>> >  gdk_color = widget->style->bg[GTK_STATE_NORMAL];
>> >
>> >  clutter_color.red   = CLAMP (((gdk_color.red   / 65535.0) * 255), 0, 255);
>> >  clutter_color.green = CLAMP (((gdk_color.green / 65535.0) * 255), 0, 255);
>> >  clutter_color.blue  = CLAMP (((gdk_color.blue  / 65535.0) * 255), 0, 255);
>> >  clutter_color.alpha = 255;
>> >
>> > ciao,
>> >  Emmanuele.
>> >
>> > --
>> > Emmanuele Bassi,
>> > W: http://www.emmanuelebassi.net
>> > B: http://log.emmanuelebassi.net
>> >
>> > _______________________________________________
>> > gtk-app-devel-list mailing list
>> > gtk-app-devel-list@gnome.org
>> > http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
>> >
> --
> Emmanuele Bassi,
> W: http://www.emmanuelebassi.net
> B: http://log.emmanuelebassi.net
>
>
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to