Re: looking for critic/advice

Jonas Kulla <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <CAK0i_71T9N4kEMjCoC3bM1CNHGEz=fMOwJUjddm2Gm_7qcJaXg@mail.gmail.com>
2013/5/23 First Last <[email protected]>

> Hi guys,
>

Hi,


> I try to writte a small clock application in C. I have 3 files yet,
> functions.h, functions.c, main.c. I'm using a structure wich contains a
> cairo_t and a cairo_surface_t that I need to update during the running of
> the application. For having this I'm using a structure defined in
> function.h, I'm a little suspicious about how I use this structure, I do
> some cast ( (*_mc) ) but I'm not sure that's well written, (I never
> written something so funky...), could you just take a look and told me if
> it's correct. gcc doesn't complains, and I don't get any runtime error, so
> I'm just looking for a critic or an advice.
>

Um... gcc doesn't complain, but I assume your program is not doing what you
want it to do?
Did you very recently start learning C? If so, maybe you should start by
writing something
simpler as an exercise (that doesn't require an event loop).

Judging from the little code you provided, it seems as if you create a
surface + context and
do one paint operation all in one function, which is most likely not what
you want to do.
Why aren't you using something more high level like GTK in the first place?
Going with raw Xlib for a simple clock seems a bit overkill to me.


> functions.h has :
>
> <...>
> typedef struct clockStruc{
>         cairo_t                 *c;
>         cairo_surface_t         *s;
>
> }CLOCKSTRUC;
> <...>
>
> functions.c has :
>
> <...>
> #include<cairo.h>
> #include<cairo-xlib.h>
> #include<time.h>
> #include"functions.h"
> <...>
>
> void cairoClock(CLOCKSTRUC *_mc, <...> , int _x, int _y, int _sizex, int
> _sizey){
>         <...>
>         (* _mc).s=cairo_xlib_surface_create(_dpy, wpnl,
> DefaultVisual(_dpy, 0), _sizex, _sizey);
>         (* _mc).c=cairo_create((*_mc).s);
>
>         cairo_rectangle((*_mc).c,0,0,_sizex,_sizey);
>         cairo_set_source_rgba((*_mc).c, 0.5, 0., 0., 1.); // nicoo :
> rouge, temporaire....
>         cairo_fill((*_mc).c);
> }
>
> <...>
>
> main.c has :
>
> <...>
> #include"functions.h"
> <...>
>
> int main(int argc, char *argv[]){
>         <...>
>         CLOCKSTRUC myClock;
>         <...>
>         cairoClock(&myClock, dpy,scr,panelv,5,5,BAR2X-10,34);
>         <...>
> }
>

Jonas

-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.