[clutter] Long-running clutter process with multiple consecutive stages

2010-06-07 Thread Rupert Swarbrick

Hi,

I'm trying to set up some lisp bindings to clutter at the moment and
there's one thing that doesn't really work yet. In lisp, the model is
that you have one long-running process and (especially when developing)
you run the 'app' several times.

Problem is that I can't get the window to be correctly destroyed. I
realised that I didn't want to use clutter_stage_get_default since when
that's destroyed clutter dies. So I tried to use clutter_stage_new,
which works (yay!).

Unfortunately, the _second_ time this is run, I can't destroy the X11
window when I'm done with it. Since I presume you guys don't want to
faff around with lisp, I think I've managed to make a testcase in C,
which I'm attaching.

Am I doing something wrong? Or have I found a bug? I realise that this
isn't a standard use-case for C clutter applications, but hopefully the
first paragraph has convinced you it's not a waste of time for lispy
things...

Thanks for what looks like a fun library!

Rupert


#include clutter/clutter.h
#include stdlib.h
#include unistd.h

static gboolean
on_delete (ClutterStage *stage, ClutterEvent *event, gpointer data)
{
  clutter_actor_destroy (CLUTTER_ACTOR (stage));
  clutter_main_quit();
  return FALSE;
}

static void
run_stage ()
{
  ClutterColor stage_color = { 0x00, 0x00, 0x00, 0xff }; /* Black */
  ClutterActor *stage = clutter_stage_new ();
  clutter_actor_set_size (stage, 200, 200);
  clutter_stage_set_color (CLUTTER_STAGE (stage), stage_color);

  g_signal_connect (stage, delete-event, G_CALLBACK (on_delete), NULL);

  clutter_actor_show (stage);

  clutter_main ();
}

int main (int argc, char *argv[])
{
  int i;

  clutter_init (argc, argv);

  for (i=0; i5; i++) {
run_stage ();
sleep (2);
  }
  
  return EXIT_SUCCESS;
}


pgpdA88v4QaFM.pgp
Description: PGP signature


Re: [clutter] Long-running clutter process with multiple consecutive stages

2010-06-07 Thread Emmanuele Bassi
On Mon, 2010-06-07 at 22:38 +0100, Rupert Swarbrick wrote:

 static gboolean
 on_delete (ClutterStage *stage, ClutterEvent *event, gpointer data)
 {
   clutter_actor_destroy (CLUTTER_ACTOR (stage));
   clutter_main_quit();
   return FALSE;
 }

try not destroying the stage and returning TRUE. right now, you're
saying I did not handle the event and yet you just destroyed the stage
and quit the main loop.

you should actually use the ::destroy signal instead.

ciao,
 Emmanuele.

-- 
Emmanuele Bassi, Open Source Software Engineer
Intel Open Source Technology Center

-- 
To unsubscribe send a mail to clutter+unsubscr...@o-hand.com