Re: drawing on X11, above all applications, emulating an alpha channel

2007-08-21 Thread Ana
On Tue, Aug 21, 2007 at 10:21:52AM +0200, David Ne?as (Yeti) wrote:
> On Tue, Aug 21, 2007 at 12:28:30AM -0700, Ana wrote:
> > 
> > and...  if possible, update the image, from time to time, with whatever
> > X11 would be displaying if my application weren't there, in order to
> > emulate numbers/graphics painted over an X-level-alpha-channel.
> 
> Ah, I missed you want alpha channel.  IMO emulating it now
> when people are starting to use compositing managers and
> RGBA visuals would be a waste of time.  Look at
> http://macslow.thepimp.net/?page_id=23

That looks promising.  Thank you very much for the tip.

- Ana

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


drawing on X11, above all applications, emulating an alpha channel

2007-08-21 Thread Ana
Hi.

I've been messing around with my little ir remote control recently,
having fun...   and I've been, sort of, longing for some way to make the
current "tv-channel" show up on my screen in the upper right hand corner
of my monitor.  You know?  Like my TV displays the new channel number
for 1 or 2 seconds after I press, for example, the channel-up button.  I
want to see the numbers up on the screen above any and all other
applications.  I don't want to have to rely on an application (like
mplayer) running in full-screen mode in order to do this.

So, I've been wondering how to look for an application that already does
this.  And, I wonder how to make something like this happen, (which is
much more fun of course).

How to do it?...  I will have to experiment because I'm not sure what
problems I will run into.  So far, my basic idea is this:

- grab a screen shot section at the location where I want to draw my
  numbers/graphics.
- paint the numbers/graphics into the screen-shot image
- create a gtk-window without window manager decorations.  (no wire
  frame, no title bar)
- fill the window with one widget, which simply displays the altered
  screen-shot image.
- show() the window at the exact location where I had taken the
  screen-shot
- close window after some timeout.


and...  if possible, update the image, from time to time, with whatever
X11 would be displaying if my application weren't there, in order to
emulate numbers/graphics painted over an X-level-alpha-channel.

the basic idea should be very simple, I think.

I would like to hear others' thoughts about this.  Especially, I want to
hear about similar projects that I might pull from, or use un-altered.

Thanks,

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


Re: Installing gtk+2.10.12 issues.

2007-05-31 Thread Ana
On Fri, Jun 01, 2007 at 12:52:02AM +0200, David Ne?as (Yeti) wrote:
> On Thu, May 31, 2007 at 03:22:08PM -0700, Sergei Steshenko wrote:
> > 
> > FOSS is also about freedom of speech.
> > 
> > So, you and others are entitled to have your opinion about what I'm saying, 
> > but
> > I will be posting what _I_ think is relevant and necessary.
> 
> As you might or might not notice, no one tried to deprive
> you of the freedom of speech.  The problem is in the form.
> Do not be surprised if you end up not being listened to, even
> with all your freedom of speech.
> 
> (Hm, this would probably weigh more if someone else said it.)

Forgive me Sergei, but I started deleting your email, on site, quite a
while ago.

You may wish to Google: shameless self-promotion netiquette

Here's an example of what's returned:
http://www.passionatepen.com/netiquettearticle.htm

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


Re: Data available for reading in a GIOChannel

2007-05-29 Thread Ana
Looking at the glib source here:

glib/giochannel.c
glib/giochannel.h
glib/giounix.c

You can see that, at least on a *nix machine, g_io_channel_read_chars()
calls the c library read() on a file descriptor in the GIOChannel
struct.  The segment:


  result = read (unix_channel->fd, buf, count);

  if (result < 0)
{
  *bytes_read = 0;

  switch (errno)
{
#ifdef EINTR
  case EINTR:
goto retry;
#endif
#ifdef EAGAIN
  case EAGAIN:
return G_IO_STATUS_AGAIN;
#endif


So, basically, on a Linux (or presumably any *nix like OS) the semantics
of g_io_channel_read_chars() will be roughly the same as POSIX read()*.
You can see that when read() returns -1 (< 0), and the global errno is
set to EAGAIN then G_IO_STATUS_AGAIN is returned.

read() is a system call.  Last I checked (a long, long time ago) EAGAIN
is set in the kernel side of the read() call when there is no data in
the buffer to read.  Unless I'm mistaken, the only way, in *nix land, to
hear from the kernel again about there being more data, is to call
select(), poll(), or read() again...  or to handle SIGIO while using
signal-driven IO (see O_ASYNC in the open(2) man page and*).

The g_io_channels appear to use poll() if a built-in system version is
available, and to emulate poll(), if it's not.  So, I believe the
semantics, on *nix at least, more or less amount to:

while( poll() )  /* glib main loop does this */
{
read();  /* your callback does this */
}


I don't see any magic happening that might make it more complicated.  If
you're using threads then it does get more complicated, but not in any
way that can't be managed by typical thread management.  Also, the
functions that are actually used to do the reading are set as callbacks
in the GIOChannel struct.  Default calls the standard unix read(), but
if you're working on someone else's code...  you may want to double
check that.

I have never done IO on a win32 or...  really on any non-*nix machine,
so my experience is a bit limited.  As I understand it though, glib/gtk+
work at making the differences as small as possible.  I would not expect
a significant difference in how the g_io_channel interface behaves.

- Ana



* if you haven't already read it: "Advanced Programming in the UNIX
Environment", by W. Richard Stevens is a good book to keep around.

On Tue, May 29, 2007 at 10:20:20PM +0200, Jonathan Winterflood wrote:
>Thanks for your precisions on where this difference comes from :)
> 
>I guess   g_io_channel_set_flags(_channel, G_IO_FLAG_NONBLOCK, NULL);  is
>good for switching to non-blocking mode.
> 
>A question arises, though: is it possible that the channel will recieve
>the last of the data between the
>time  g_io_channel_read_chars  returns G_IO_STATUS_AGAIN and the callback 
> exits, and that the callback will not be called again?
> 
>This would be a really easy way to get stuck waiting for data which is
>already there, so I'm thinking no, can you confirm this?
> 
>Thanks a lot,
>Jonathan
> 
>On 5/29/07, Paul Davis <[EMAIL PROTECTED]> wrote:
> 
>  On Mon, 2007-05-28 at 17:26 +0200, Jonathan Winterflood wrote:
>  > Hi,
>  >
>  > > you never know how much readable data is available until you read
>  > it, you are only ever guaranteed to have one byte of data available
>  > for reading anyway.
>  >
>  > In my opinion, the channel should _always_ know how much data is
>  > available, how can it tell that there is nothing there?... Plus, it
>  > can't not know the amount of data it _has_ actually recieved and is
>  > buffered ready for me...
> 
>  there is a very big difference between knowing the distinctions between:
> 
> * something and nothing
> * specifically how much and nothing at all
> 
>  the process that leads to the callback is called as soon as a single
>  byte of data arrives. there might be more data by the time it actually
>  executes. nothing else in the system (except perhaps a device driver) is
>  buffering data for you and then saying (post-facto) "we have some
>  stuff". your callback can do that if it wants to offer that kind of
>  service to high level layers of your application/code.
> 
>  > Java InputStreams for example have the available() method:
>  >
>  
> [2]http://java.sun.com/javase/6/docs/api/java/io/InputStream.html#available()
> 
>  thats because Java InputStreams are heavily buffered. glib/gtk
>  IOChannels are not, by default. in particular, when you 

Re: Data available for reading in a GIOChannel

2007-05-28 Thread Ana
On Mon, May 28, 2007 at 04:42:11PM -0300, Alexandre Moreira wrote:
> On 5/28/07, Robert Pearce <[EMAIL PROTECTED]> wrote:
> > On Sun, 27 May 2007 16:57:03 +0200 Jonathan wrote:
> > > Hi,
> > >
> > > I need to read a large amount of data from a GIOChannel (200K, over
> > > the internet).
> > >
> > > So far, I use the gnet library to create the
> > > socket, and then I use the GIOChannel to integrate the read/writing
> > > into the program's loop (a
> > > GTK application)
> > >
> > > I use g_io_add_watch(_channel, G_IO_IN, &(_imageDataReadyForReading), 
> > > this);
> > > to register the callback for data reading.
> > >
> > > How can I determine the number of bytes available for reading, so as not 
> > > to
> > > block on reading the data?
> > >
> >
> > On the applications where I've used g_io_add_watch it's on a serial port 
> > that I've opened non-blocking. Then my callback I just does:
> > stat = g_io_channel_read_chars ( source,
> >  tmpbuf, sizeof(tmpbuf), &len, &err );
> >
> > If there are less than tmpbuf characters waiting, it fills what it can and 
> > sets len to the actual number. Then I process len bytes. Normally my tmpbuf 
> > is bigger than the longest message I expect, but it seems to work even if 
> > it isn't.
> 
> Please anyone correct me if I'm wrong, but...
> 
> I guess you should loop until EAGAIN,  because you can get some nasty
> things if your program is being run on a system where the select (or
> poll, or whatever it uses to watch the channels) call returns when the
> file descriptor CHANGES its state (ready to read // not ready to
> read).

That's what I typically do.  something like this:

/* make sure 'source' is non-blocking before entering loop
 * below is simplified */
do {
  len = 0;
  stat = g_io_channel_read_chars ( source,
   tmpbuf, sizeof(tmpbuf), &len, &err );
  if( len > 0 )
process_data(tmpbuf, len);
 } while(stat == G_IO_STATUS_NORMAL && len == sizeof(tmpbuf));


Whether it's necessary or advisable to read in a loop like that, I'm not
sure.  Depending on certain things, such how long the process_data()
function takes, you may wish to let the main loop run after every time
process_data() is called...  in which case you wouldn't use a loop like
the above.


> In that case you could create a situation where a client is expecting
> for some response from you, but you didn't actually read the request
> (because it is lost in the buffer) and therefore each process is
> waiting for the other to act.

I think the question here is: if we don't read all available data before
returning to poll/select, will our callback be triggered again so that
we can process the remaining data?  Without doing any research, I
believe the answer would have to be 'yes'.  To make sure, look at some
source or create a test.

- Ana

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


Re: Re: Editable Label Widget

2007-05-17 Thread Ana
On Wed, May 16, 2007 at 06:19:30PM -0400, ANDREW JAMES KRAUSE wrote:
>My problem with using a GtkEntry is that I need the label to be
>multi-lined. I don't want to use GtkCellView because, when I edit
>the text, it will resize the widget. It is possible to have hundreds
>of these widgets in a column, so that would be a rendering mess.
> 
>I had originally used the idea of switching between a GtkLabel and
>GtkEntry. There are a few problems with this. First, you still have
>the resizing issues. The user can't see the whole text when it is
>in a GtkEntry, so it will be difficult to edit longer texts.  Also,
>you have to keep two widgets around, which takes more memory.

Are you going for a WYSIWYG thing?  I'm sure I can't help you much
there.

Another idea that occurs to me is creating a tiny, borderless pop-up
window over the label that contains a single editable widget.  The
window and editable could be created afresh every time the user wants to
edit a label (and destroyed after) so it wouldn't take additional memory
per widget.  Having it pop-up z-order-above the label/main-window would
avoid the resizing issue.  You could have this little window return any
kind of text, perhaps pango markup (generated from parsed WYSIWYG
text?).  Or, when the window is instantiated, hand it a reference to the
label being edited and have the update occur when the window closes or
in real-time.  You might even attach a little formatting tool-bar to one
edge of this tiny window so people could easily mark portions of text
bold, italic, etc..  One of the nicest bits of this is that you wouldn't
have to create a new "label" widget at all and instead rely on the
GtkLabel's existing strengths.  You'd just connect whatever signals of
the GtkLabel you need to begin the pop-up/editing.

One of the major challenges, I think, would be getting the user to
notice the tiny window and avoid confusion about what is going on; with
this tiny modal "dialog."  The tab, enter and/or escape keys would need
to close the window.  And, how would the user signal signal that s/he
wants to edit the label?  Perhaps editing could begin when the user
gives an "editable label" the focus and presses Enter.

...just thinking "out loud"

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


Re: Editable Label Widget

2007-05-16 Thread Ana
Hi Andrew.  :)

I think making the GtkEntry look like a label is a good idea, but might
be more work than you'd expect.  It seems that whenever you mess with a
widget's appearance you have to worry about interfering with themes.
Who knows what other issues there might be.

Another idea might be to make a composite object, which subclasses from
a container (GtkBox), and works sort of like a modal editor.  (hehe.
I'm a vi user.)  You display either a GtkLabel or a GtkEntry depending
on the "mode."

- Ana


On Wed, May 16, 2007 at 07:00:10PM +0200, Hans Oesterholt-Dijkema wrote:
> Why not use a GtkEntry and make it look like a GtkLabel?
> You could also have a look at GtkCellView.
> 
> --Hans
> 
> 
> ANDREW JAMES KRAUSE schreef:
> > Hello All,
> >
> > I have an interest invested in an editable label 
> > widget because of an application I am working on. 
> > Because of this, I decided to work on the widget 
> > myself since the project seems to have been dropped 
> > from the list of priorities.
> >
> > On Bugzilla, there is an implementation that was
> > written in 2005, but it is not acceptable because it
> > uses more than the available signal padding slots
> > from GtkLabel.
> >
> > It is quite obvious that the way to go is to use the
> > GtkEditable interface in a new widget called something
> > like GtkEditableLabel. However, there are two different
> > approaches that I've come up with.
> >
> > One way to implement this widget would be to derive it
> > from GtkLabel. This would allow the widget to inherit
> > all of the code from GtkLabel, but may cause problems
> > because of hidden data and the fact that GtkLabel
> > already handles selections in a different way.
> >
> > The other option is to do what EelEditableLabel did 
> > and just derive from GtkMisc. This would add a little
> > extra baggage because of reimplementing a few of the
> > same features. However, I think this may be the better
> > way to go in terms of API and speed of the widget.
> >
> > Does anyone have any thoughts on this issue, in one
> > direction or the other?
> >
> > ---
> > Andrew Krause
> >
> > ___
> > 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-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: GObject Interface vs Pure Virtual Class

2007-05-14 Thread Ana
On Sat, May 12, 2007 at 02:42:50PM +0800, Kuang-Chun Cheng wrote:
>On 5/12/07, Jean Br*fort <[EMAIL PROTECTED]> wrote:

> 
>  A GObject class can inherit from only one parent (which might be
>  virtual), but you can add as many Interfaces as you like. It is somewhat
>  similar to multiple inheritance in C++ (more like the D language
>  actually).
> 
>Hi Jean,
> 
>That's new to me ... I did not catch up this from GObject Ref. Manual ...
>Thanks.
> 
>KC

It's also important to note that GTK+ Interfaces cannot directly
implement any functionality, unlike C++ classes.  They only specify the
set of (rigid) "prototypes" that *must* be fully implemented by the
implementing class.  Interfaces also define a "type" which the
implementing class must be cast-to in order to call the interface
methods.  In C++, an analogous situation would be implementing a pure
virtual class (containing *only* pure virtual methods), which can be
used in single or multiple inheritance.  The GTK+ inheritance model is
much more like Java than C++; with only single inheritance allowed, but
no limit on the number of Interfaces which may be implemented.  (much
better than C++ imho.)  I recommend you read about Java interfaces.

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


Re: How to get pixel values along a line?

2007-04-13 Thread Ana
On Thu, Apr 12, 2007 at 08:37:12AM +0200, Fredrik Persson wrote:
> Somehow this thread slipped off the list...

Hello Fredrik.

If you don't mind, I would very much like to read a summary of the
thread, including what's been said off-list.  Please, if it's not too
much trouble, will you post some key points of what you found out and
maybe a simple code example?

Thanks very much.

- Ana

___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


colors change.

2003-04-06 Thread Ana GP
Hello,
I'm using gtk to make a design of lines, rectangles and other polygons.
My question is why when I draw the objects, for example, lines and after
that
I draw the rectangles, the first line I was drawed changes its color to
the
rectangle's color? And so on with the other objects.

See here  some code to how I draw any, for example the rectangle:

...
gdk_colormap_alloc_color(a->gdkcolormap, &vr[i].rcolor, TRUE, TRUE);
gdk_gc_set_foreground(a->gdkgc, &vr[i].rcolor);
gdk_gc_set_line_attributes(a->gdkgc,
vr[i].rgrosor,
GDK_LINE_SOLID,
GDK_CAP_BUTT,
GDK_JOIN_MITER);
gdk_draw_rectangle(a->drawingarea->window, a->gdkgc, TRUE,
vr[i].rx,
vr[i].ry,
vr[i].ranchura,
vr[i].raltura);
...

thanks in advance,

ana.

___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Question of GtkMenuFactory

2003-03-07 Thread Ana Gutierrez Pascual
Hi,
I've compiled the example GtkMenuFactory of the tutorial GTK 1.2, and
I've obtain two errors, I want to know if anybody can help me.


menufactory.c: In function `get_main_menu':
menufactory.c:49: warning: implicit declaration of function
`gtk_window_add_accelerator_table'
/tmp/cc9OOlUT.o: In function `get_main_menu':
/home/ana/menus/menufactory.c:49: undefined reference to
`gtk_window_add_accelerator_table'
collect2: ld returned 1 exit status
make: *** [menufactory] Error 1


and if I erase the instruction of the line 49

//gtk_window_add_accelerator_table(GTK_WINDOW(window),
subfactory->table); //subfactory->table

I can execute the program but the first message I've obtain is:

Gtk-WARNING **: gtk_menu_factory_new(): GtkMenuFactory is deprecated and
will shortly vanish

Gtk-WARNING **: gtk_menu_factory_new(): GtkMenuFactory is deprecated and
will shortly vanish

And after that, the program goes well.
Any suggestions?

thanks in advance,


ana.

___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Problem with colors

2003-03-05 Thread Ana Gutierrez Pascual
Hi,
I've got a problem with the colors. When I draw objects in a window,
like lines, circles rectangles, text, I use for each object, a different
color, but after that, when any event is in the window, the color
changes. any suggestions?

here is the code to put the color,

(...)
  r->rcolor.red= 0x;
  r->rcolor.green= 0;
  r->rcolor.blue= 0x;
(...)
  gtk_widget_realize(app.window);
  app.gdkgc= gdk_gc_new(app.window->window);
  app.gdkcolormap= gdk_colormap_get_system();
(...)
void DibujarRectangulo(aplicacion_t *a, rectangulo_t *r)
{
  gdk_colormap_alloc_color(a->gdkcolormap, &r->rcolor, TRUE, TRUE);
  gdk_gc_set_foreground(a->gdkgc, &r->rcolor);
  gdk_gc_set_line_attributes(a->gdkgc,
r->rgrosor,
GDK_LINE_SOLID,
GDK_CAP_BUTT,
GDK_JOIN_MITER);
  gdk_draw_rectangle(a->drawingarea->window, a->gdkgc, FALSE, r->rx,
r->ry, r->ranchura, r->raltura);
  if (r->rfont == NULL)
g_print("rfont is NULL\n");
  else
gdk_draw_string (a->drawingarea->window, r->rfont, a->gdkgc, r->rx,
r->ry-5, r->rnombre);
}
(...)

thanks in advance,



ana.

___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Draw a line & erase it

2003-03-05 Thread Ana Gutierrez Pascual
hi,
I want to know how can I do if after I draw a line, and an event
ocurres, the line will be erase.
there's my code to draw a line.

void DibujarLinea(aplicacion_t *a, linea_t *l)
{
  //reserva un espacio en color map para el color
  gdk_colormap_alloc_color(a->gdkcolormap, &l->lcolor, TRUE, TRUE);
  //esta función pone el color al gdkgc q se va a dibujar
  gdk_gc_set_foreground(a->gdkgc, &l->lcolor);

  gdk_gc_set_line_attributes(a->gdkgc,
l->lgrosor,
GDK_LINE_SOLID,
GDK_CAP_BUTT,
GDK_JOIN_MITER);

  gdk_draw_line(a->drawingarea->window, a->gdkgc, l->lx1, l->ly1,
l->lx2, l->ly2);
}

thanks in advance,

ana.

___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Maintain pressed button and lossen it

2003-02-28 Thread Ana Gutierrez Pascual
Hi,
I want to know how can I do:
If I'm a drawing area, with some different objects, lines, rectangles,
points, circles, ... So, I want that when I click inside any object,
create an event that shows the value of the object during I maintain
pressed button, and when I loosen the button the value disappears.
Any idea,
My problem is when if I use a variable GdkFont, it appears when I
clicked in the object, but I can't delete it after it's drawed.
thanks in advance.

ana.


___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Meaning of gtk_container_border_width

2003-02-25 Thread Ana Gutiérrez Pascual
hi,
In my program I use these two functions

1) gtk_container_border_widht(GTK_CONTAINER(app.window), 300);
2) gtk_drawing_area_size(GTK_DRAWING_AREA(app.drawingarea), 300, 300);

and I've some conflicts 'cause I want the objects of the window and the
drawing area in the same space, to click or do events at both of them at
the same time.
thanks en advance,

ana.

___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


A problem when I insert a structure.

2003-02-25 Thread Ana Gutiérrez Pascual
Hi,
I've got an error: Segmentation Fault when I run my code.
It goes well with structures linea and rectangulo, but when I want to
insert another, in this case called circulo, the error appears.
See in my code fuction EventoExponer the last instruction called
DibujarCirculo.
I haven't any idea to solve it, could anybody tell me something?
thanks in advance.

ana.

//code program.h

#include 

typedef struct {
  gdouble lx1;
  gdouble lx2;
  gdouble ly1;
  gdouble ly2;
  double lgrosor;
  GdkColor lcolor;
  GdkFont *lfont;
  gchar *lnombre;
} linea_t;

typedef struct {
  gdouble rx, ry, ranchura, raltura;
  double rgrosor;
  GdkColor rcolor;
  GdkFont *rfont;
  gchar *rnombre;
} rectangulo_t;

typedef struct {
  gdouble cx, cy, canchura, caltura, cangulo1, cangulo2;
  gdouble cradio;
  gdouble ccentrox, ccentroy;
  double cgrosor;
  GdkColor ccolor;
  GdkFont *cfont;
  gchar *cnombre;
} circulo_t;

typedef struct
{
  GtkWidget *window;
  gchar *nom;
  GtkWidget *drawingarea;
  GdkColormap *gdkcolormap;
  GdkGC *gdkgc;
} aplicacion_t;

typedef  struct
{
  aplicacion_t *aplicacion;
  linea_t *linea;
  rectangulo_t *rectangulo;
  circulo_t *circulo;
} datos_t;

void InicializarLinea(linea_t *l);
void InicializarRectangulo(rectangulo_t *r);
void InicializarCirculo(circulo_t *c);

void DibujarLinea(aplicacion_t *a, linea_t *l);
void DibujarRectangulo(aplicacion_t *a, rectangulo_t *r);
void DibujarCirculo(aplicacion_t *a, circulo_t *c);

gboolean EventoExponer(GtkWidget *widget,
GdkEventButton *event,
datos_t * datos);

// code program.c

#include "program.h"
#include 

gint main (gint argc,gchar *argv[])
{
  linea_t lin;
  rectangulo_t rec;
  aplicacion_t app;
  datos_t datos;
  GtkWidget *vbox;

  datos.aplicacion= &app;
  datos.linea= &lin;
  datos.rectangulo= &rec;

  gtk_init (&argc, &argv);
  InicializarLinea(&lin);
  InicializarRectangulo(&rec);

  app.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (app.window), "Hola Hello Salut!");

  gtk_signal_connect(GTK_OBJECT (app.window), "destroy",
GTK_SIGNAL_FUNC (gtk_main_quit), NULL);

  gtk_container_border_width (GTK_CONTAINER (app.window), 150);

  vbox = gtk_vbox_new(FALSE, 0);
  gtk_container_add(GTK_CONTAINER (app.window), vbox);
  gtk_widget_show(vbox);

  app.drawingarea = gtk_drawing_area_new();
  //gtk_drawing_area_size(GTK_DRAWING_AREA(app.drawingarea), 10, 10);
  gtk_box_pack_start(GTK_BOX(vbox), app.drawingarea, TRUE, TRUE, 0);
  gtk_widget_show(app.drawingarea);

  gtk_widget_realize(app.window);
  app.gdkgc= gdk_gc_new(app.window->window);
  app.gdkcolormap= gdk_colormap_get_system();

  gtk_widget_set_events(app.drawingarea, GDK_EXPOSURE_MASK);

  gtk_signal_connect(GTK_OBJECT(app.drawingarea),
"expose_event",
GTK_SIGNAL_FUNC(EventoExponer),
&datos);

  gtk_widget_show(app.window);

  gtk_main();

  exit(0);
}

void InicializarLinea(linea_t *l)
{
  l->lx1= 50;
  l->lx1= 50;
  l->lx2= 100;
  l->ly1= 80;
  l->ly2= 80;

  l->lgrosor= 5;

  l->lcolor.red= 0x;
  l->lcolor.green= 0;
  l->lcolor.blue= 0;

  l->lfont=
gdk_font_load("-Adobe-Helvetica-Bold-R-Normal--*-140-*-*-*-*-*-*");
  l->lnombre= "l- 0 0";
}

void InicializarRectangulo(rectangulo_t *r)
{
  r->rx= 100;
  r->ry= 100;
  r->ranchura= 150;
  r->raltura= 100;

  r->rgrosor= 5;

  r->rcolor.red= 0x;
  r->rcolor.green= 0;
  r->rcolor.blue= 0x;

  r->rfont= gdk_font_load
("-Adobe-Helvetica-Bold-R-Normal--*-140-*-*-*-*-*-*");
  r->rnombre= "r- 0 1";
}

void InicializarCirculo(circulo_t *c)
{
  c->cx= 20;
  c->cy= 150;
  c->canchura= 60;
  c->caltura= 60;
  c->cangulo1= 0;
  c->cangulo2= 64*360;
  c->cradio= c->canchura/2;
  //será el radio correcto siempre q altura y anchura sean la misma,
sino se dibujaría un óvalo
  c->ccentrox= c->cx+c->cradio;
  c->ccentroy= c->cy+c->cradio;

  c->cgrosor= 4;

  c->ccolor.red= 0;
  c->ccolor.green= 0;
  c->ccolor.blue= 0;

  c->cfont= gdk_font_load
("-Adobe-Helvetica-Bold-R-Normal--*-140-*-*-*-*-*-*");
  c->cnombre= "c- 0 2";
}

void DibujarLinea(aplicacion_t *a, linea_t *l)
{
  //reserva un espacio en color map para el color
  gdk_colormap_alloc_color(a->gdkcolormap, &l->lcolor, TRUE, TRUE);
  //esta función pone el color al gdkgc q se va a dibujar
  gdk_gc_set_foreground(a->gdkgc, &l->lcolor);

  gdk_gc_set_line_attributes(a->gdkgc,
l->lgrosor,
GDK_LINE_SOLID,
GDK_CAP_BUTT,
GDK_JOIN_MITER);

  gdk_draw_line(a->window->window, a->gdkgc, l->lx1, l->ly1, l->lx2,
l->ly2);


a question of gtk/gdk structures

2003-02-18 Thread Ana Gutiérrez Pascual
hi,
I'm new in gtk programming and I've got an error when I compile
the easy program, any expert could tell me a solution?
thanks in advance,
Ana.

the code is:

//--

#include 

typedef struct {
  gdouble lx1;
  gdouble lx2;
  gdouble ly1;
  gdouble ly2;
  double lgrosor;
  GdkColor lcolor;
  GdkFont *lfont;
  gchar *lnombre;
} e_linea;

typedef struct
{
  GtkWidget *window;
  gchar *nom;
  GtkWidget *drawingarea;
  GdkDrawable *drawable;
  GdkColormap *gdkcolormap;
  GdkGC *gdkgc;
} e_app;

typedef struct {
  e_linea *linea;
  e_app *app;
} e_objeto;

void InicializarLinea(e_objeto *o);
void DibujarLinea(e_objeto *o);

gboolean EventoExponer(GtkWidget *widget,
GdkEventButton *event,
gpointer client_data);
gint main (gint argc,gchar *argv[])
{

  e_objeto obj;
  GtkWidget *vbox;

  gtk_init (&argc, &argv);
  InicializarLinea(&obj);

  obj.app->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_widget_set_name(obj.app->window, "Ventanita");

  vbox = gtk_vbox_new(FALSE, 0);
  gtk_container_add(GTK_CONTAINER (obj.app->window), vbox);

  gtk_widget_realize(obj.app->window);
  gtk_widget_show(vbox);

  obj.app->drawingarea = gtk_drawing_area_new();
  gtk_drawing_area_size(GTK_DRAWING_AREA(obj.app->drawingarea), 300,
300);

  gtk_box_pack_start(GTK_BOX(vbox), obj.app->drawingarea, TRUE, TRUE,
0);
  gtk_widget_show(obj.app->drawingarea);

  obj.app->drawable = obj.app->drawingarea -> window;
  obj.app->gdkgc= gdk_gc_new(obj.app->drawable);
  obj.app->gdkcolormap= gdk_colormap_get_system();

  gtk_widget_set_events(obj.app->drawingarea, GDK_EXPOSURE_MASK);

  gtk_signal_connect(GTK_OBJECT (obj.app->window), "destroy",
GTK_SIGNAL_FUNC (gtk_main_quit), NULL);

  gtk_signal_connect(GTK_OBJECT(obj.app->drawingarea),
"event",
GTK_SIGNAL_FUNC(EventoExponer),
&obj);

  gtk_widget_show(obj.app->window);
  gtk_main();
  return 0;
}

void InicializarLinea(e_objeto *o)
{
  o->linea->lx1= 50;
  o->linea->lx2= 100;
  o->linea->ly1= 80;
  o->linea->ly2= 80;

  o->linea->lgrosor= 1;

  o->linea->lcolor.red= 0x;
  o->linea->lcolor.green= 0;
  o->linea->lcolor.blue= 0;

  o->linea->lfont=
gdk_font_load("-Adobe-Helvetica-Bold-R-Normal--*-140-*-*-*-*-*-*");
  o->linea->lnombre= "l- 0 0";
}

void DibujarLinea(e_objeto *o)
{
  gdk_colormap_alloc_color(o->app->gdkcolormap, &o->linea->lcolor, TRUE,
TRUE);
  gdk_gc_set_foreground(o->app->gdkgc, &o->linea->lcolor);
  gdk_gc_set_line_attributes(o->app->gdkgc,
o->linea->lgrosor,
GDK_LINE_SOLID,
GDK_CAP_BUTT,
GDK_JOIN_MITER);
  gdk_draw_line(o->app->drawable, o->app->gdkgc, o->linea->lx1,
o->linea->ly1, o->linea->lx2, o->linea->ly2);
  if (o->linea->lfont == NULL)
g_print("font is NULL\n");
  else
gdk_draw_string(o->app->drawable, o->linea->lfont, o->app->gdkgc,
o->linea->lx1, o->linea->ly1-10, o->linea->lnombre);
}

gboolean EventoExponer(GtkWidget *widget,
GdkEventButton *event,
gpointer client_data)
{
  if (event->type == GDK_EXPOSE)
DibujarLinea((e_objeto *)client_data);
  return FALSE;
}
//

___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list



Re: How can I solve this problem of Gdk

2003-02-16 Thread Ana Gutiérrez Pascual
hi,
i do the changes you tell me but the errors continue :(
could you help me?

Ana.

On 14 Feb 2003, Sven Neumann wrote:

> Hi,
>
> =?ISO-8859-15?B?QW5hIEd1dGnpcnJl?=z Pascual <[EMAIL PROTECTED]> writes:
>
> > i'm new with gtk/gdk. i create a program to design some differents objects, in
> > this case a simple line. but i supose i don't use correctly the pointers
> > 'cause i obtain these errors.
> >
> > Gdk-CRITICAL **: file gdkgc.c: line 51 (gdk_gc_new_with_values): assertion
> > `window != NULL' failed.
>
> you can not access a widget's window before it is realized (because
> there is none). You should either connect_after realize and create
> your GC there or simply do it in the expose_event handler where you
> do your drawing.
>
>
> Salut, Sven
>

___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list



How can I solve this problem of Gdk

2003-02-14 Thread Ana Gutiérrez Pascual
hi, 
i'm new with gtk/gdk. i create a program to design some differents objects, in 
this case a simple line. but i supose i don't use correctly the pointers 
'cause i obtain these errors. 
  
Gdk-CRITICAL **: file gdkgc.c: line 51 (gdk_gc_new_with_values): assertion 
`window != NULL' failed. 
 
Gdk-CRITICAL **: file gdkgc.c: line 456 (gdk_gc_set_foreground): assertion `gc 
!= NULL' failed. 
 
Gdk-CRITICAL **: file gdkgc.c: line 766 (gdk_gc_set_line_attributes): 
assertion `gc != NULL' failed. 
 
Gdk-CRITICAL **: file gdkdraw.c: line 65 (gdk_draw_line): assertion `drawable 
!= NULL' failed. 
 
Gdk-CRITICAL **: file gdkdraw.c: line 212 (gdk_draw_string): assertion 
`drawable != NULL' failed. 
 
my code see above. 
 
// -- 
 
#include  
 
typedef struct 
{ 
  GtkWidget *window; 
  gchar *nom; 
  GtkWidget *drawingarea; 
  GdkDrawable *drawable; 
  GdkColormap *gdkcolormap; 
  GdkGC *gdkgc; 
} e_app; 
 
typedef struct { 
  gdouble lx1, lx2, ly1, ly2; 
  double lgrosor; 
  GdkColor lcolor; 
  GdkFont *lfont; 
  gchar *lnombre; 
} e_linea; 
 
void InicializarLinea(e_linea *l); 
void DibujarLinea(e_linea *l, e_app *a); 
 
gboolean EventoExponer(GtkWidget *widget, 
GdkEventButton *event, 
gpointer client_data); 
gint main (gint argc,gchar *argv[]) 
{ 
  e_app app; 
  e_linea lin; 
  GtkWidget *vbox; 
 
  gtk_init (&argc, &argv); 
  InicializarLinea(&lin); 
  app.window = gtk_window_new(GTK_WINDOW_TOPLEVEL); 
  gtk_widget_set_name(app.window, "Ventanita"); 
  vbox = gtk_vbox_new(FALSE, 0); 
  gtk_container_add(GTK_CONTAINER (app.window), vbox); 
  gtk_widget_show(vbox); 
 
  gtk_signal_connect(GTK_OBJECT (app.window), "destroy", 
GTK_SIGNAL_FUNC (gtk_main_quit), NULL); 
  app.drawingarea = gtk_drawing_area_new(); 
 
  gtk_drawing_area_size(GTK_DRAWING_AREA(app.drawingarea), 300, 300); 
  gtk_box_pack_start(GTK_BOX(vbox), app.drawingarea, TRUE, TRUE, 0); 
  gtk_widget_show(app.drawingarea); 
  gtk_widget_set_events(app.drawingarea, GDK_EXPOSURE_MASK); 
 
  gtk_signal_connect(GTK_OBJECT(app.drawingarea), 
"event", 
GTK_SIGNAL_FUNC(EventoExponer), 
&app); 
 
  gtk_widget_realize(app.window); 
 
  app.drawable = app.drawingarea -> window; 
  app.gdkgc= gdk_gc_new(app.drawable); 
  app.gdkcolormap= gdk_colormap_get_system(); 
 
  gtk_widget_show(app.window); 
  gtk_main(); 
  return 0; 
} 
 
void InicializarLinea(e_linea *l) 
{ 
  l->lx1= 50; 
  l->lx2= 100; 
  l->ly1= 80; 
  l->ly2= 80; 
 
  l->lgrosor= 1; 
 
  l->lcolor.red= 0x; 
  l->lcolor.green= 0; 
  l->lcolor.blue= 0; 
 
  l->lfont= gdk_font_load 
("-Adobe-Helvetica-Bold-R-Normal--*-140-*-*-*-*-*-*"); 
  l->lnombre= "l- 0 0"; 
} 
 
void DibujarLinea(e_linea *l, e_app *a) 
{ 
  gdk_colormap_alloc_color(a->gdkcolormap, &l->lcolor, TRUE, TRUE); 
  gdk_gc_set_foreground(a->gdkgc, &l->lcolor); 
  gdk_gc_set_line_attributes(a->gdkgc, 
l->lgrosor, 
GDK_LINE_SOLID, 
GDK_CAP_BUTT, 
GDK_JOIN_MITER); 
  gdk_draw_line(a->drawable, a->gdkgc, l->lx1, l->ly1, l->lx2, l->ly2); 
  if (l->lfont == NULL) 
g_print("font is NULL\n"); 
  else 
gdk_draw_string (a->drawable, l->lfont, a->gdkgc, l->lx1, l->ly1-10, 
l->lnombre); 
} 
 
gboolean EventoExponer(GtkWidget *widget, 
GdkEventButton *event, 
gpointer client_data) 
{ 
  if (event->type == GDK_EXPOSE) 
DibujarLinea((e_linea *)client_data, (e_app *)client_data); 
  return FALSE; 
} 
 
// -- 

___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list



How to trap right mouse button?

2003-01-17 Thread Ana Gutierrez Pascual
Hi list,
My question is how can I trap the right or middle mouse button click?
I know how trap the left mouse click, but I don't know with the others.
thanks.



___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list



Re: A problem with the button_press.

2003-01-09 Thread Ana Gutierrez Pascual
Hello,

Thanks for the answer.

I do the changes you tell me, and it runs well, but my question is: if I
want to know when I'm clicking just in the draw, in this case the
rectangle, which functions I must to use?
My idea is make a design, and know I click on it.
So when I click in the rectangle in my case.

ana regards,

ana.

___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list



A problem with the button_press.

2003-01-09 Thread Ana Gutiérrez Pascual
/* 
  Hi everybody, I'm new in GTK. 
 
  My problem is how can I know I'm clicking in any line of my rectangle 
  'cause when I used the function button_press_event there's nothing 
  new, and I want to know when I'm clicking in the rectangle, any idea? 
  See the code bellow. 
 
  thnanks in advance, 
 
  ana*/ 
 
#include  
 
typedef struct { 
GtkWidget *window; 
GtkWidget *drawing_area; 
GdkGC *drawing_area_gc; 
} MyApp; 
 
void pinta_rectangle(GdkWindow *window, 
   GdkGC *gc, 
   double line_width, 
   gint x, 
   gint y, 
   gint width, 
   gint height) 
{ 
gdk_gc_set_line_attributes(gc, 
   line_width, 
   GDK_LINE_SOLID, 
   GDK_CAP_ROUND, 
   GDK_JOIN_ROUND); 
 
gdk_draw_rectangle(window, gc, FALSE, x, y, width, height); 
} 
 
void rectangle1(MyApp *app) 
{ 
pinta_rectangle(app->drawing_area->window, 
app->drawing_area_gc, 
5,/*grosor linea*/ 
20, 20, 
50, 50); 
} 
 
 
gboolean event_handler (GtkWidget *drawing_area, 
GdkEvent *event, 
gpointer client_data) 
{ 
 if (event->type == GDK_EXPOSE) 
 rectangle1((MyApp*)client_data); 
 
  return 1; 
} 
 
gboolean button_press_event (GtkWidget *drawing_area, 
GdkEvent *event, 
gpointer client_data) 
{ 
 g_print("hi\n"); 
 return 1; 
} 
 
 
gint main (gint argc,gchar *argv[]) 
{ 
MyApp app; 
 
GtkWidget *vbox; 
GtkWidget *button; 
 
gtk_init (&argc, &argv); 
 
app.window = gtk_window_new (GTK_WINDOW_TOPLEVEL); 
gtk_widget_set_name (app.window, "Disseny"); 
 
vbox = gtk_vbox_new (FALSE, 0); 
gtk_container_add (GTK_CONTAINER (app.window), vbox); 
gtk_widget_show (vbox); 
 
gtk_signal_connect (GTK_OBJECT (app.window), "destroy", 
GTK_SIGNAL_FUNC (gtk_main_quit), NULL); 
 
app.drawing_area = gtk_drawing_area_new (); 
gtk_drawing_area_size (GTK_DRAWING_AREA(app.drawing_area), 
   300, 200); 
 
gtk_box_pack_start (GTK_BOX (vbox), app.drawing_area, TRUE, TRUE, 0); 
 
gtk_widget_show (app.drawing_area); 
 
 
gtk_signal_connect (GTK_OBJECT(app.drawing_area), 
"event", 
GTK_SIGNAL_FUNC(event_handler), 
&app); 
 
gtk_signal_connect (GTK_OBJECT (app.drawing_area), "button_press_event", 
   GTK_SIGNAL_FUNC(button_press_event), NULL); 
 
gtk_widget_set_events (app.drawing_area, GDK_EXPOSURE_MASK 
 | GDK_LEAVE_NOTIFY_MASK 
 | GDK_BUTTON_PRESS_MASK); 
 
gtk_widget_realize (app.window); 
app.drawing_area_gc = gdk_gc_new (app.window->window); 
 
/*botón Salir*/ 
button = gtk_button_new_with_label ("Salir"); 
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); 
gtk_signal_connect_object (GTK_OBJECT (button), "clicked", 
 GTK_SIGNAL_FUNC (gtk_widget_destroy), 
 GTK_OBJECT (app.window)); 
gtk_widget_show (button); 
 
gtk_widget_show (app.window); 
 
gtk_main (); 
 
return 0; 
} 

___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list



how to control drawing area?

2003-01-08 Thread Ana GUTIERREZ PASCUAL
Hi,
I'm new in gtk. And after I make the differents drawing area, now how
can I control them, with the mouse.

thanks in advance.

ana.

___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list



how create a design and control it???

2002-12-19 Thread Ana GUTIERREZ PASCUAL
Hi,

I'm new in gtk. I want to know how to create a
simple rectangle and a line in a window and
can con control them.

If I can do than I can continue working.

thanks,

ana.



___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list