Esempio n. 1
0
/* =====================================================================
 *
 * =====================================================================*/
static void update_clock()
{
  GdkPixbuf *pixmap;
  char *str = g_strdup_printf("%s%d.png", "timers/clock", errors);

  pixmap = gc_skin_pixmap_load(str);

  g_object_set(clock_image_item,
	       "pixbuf", pixmap,
	       NULL);

  gdk_pixbuf_unref(pixmap);
  g_free(str);
}
Esempio n. 2
0
/* =====================================================================
 *
 * =====================================================================*/
static GooCanvasItem *colors_create_item(GooCanvasItem *parent)
{
  GdkPixbuf *pixmap;
  char *str = NULL;

  boardRootItem = goo_canvas_group_new (goo_canvas_get_root_item(gcomprisBoard->canvas),
					NULL);


  str = g_strdup_printf("%s/%s", gcomprisBoard->boarddir,
			"highlight.png");
  pixmap = gc_pixmap_load(str);

  highlight_image_item = goo_canvas_image_new (boardRootItem,
					       pixmap,
					       0,
					       0,
					       NULL);

  highlight_width = gdk_pixbuf_get_width(pixmap);
  highlight_height = gdk_pixbuf_get_height(pixmap);

  g_free(str);
  g_object_set (highlight_image_item,
		"visibility", GOO_CANVAS_ITEM_INVISIBLE,
		NULL);

  gdk_pixbuf_unref(pixmap);

  /* setup the clock */
  str = g_strdup_printf("%s%d.png", "timers/clock",errors);
  pixmap = gc_skin_pixmap_load(str);

  clock_image_item = goo_canvas_image_new (boardRootItem,
					   pixmap,
					   CLOCK_X,
					   CLOCK_Y,
					   NULL);

  gdk_pixbuf_unref(pixmap);
  g_free(str);

  return NULL;
}
Esempio n. 3
0
/* GdkPixbuf *gc_skin_pixmap_load(char *pixmapfile); */
static PyObject*
py_gc_skin_pixmap_load(PyObject* self, PyObject* args)
{
  char* pixmapfile;
  GdkPixbuf* result;
  PyObject* pyresult;

  /* Parse arguments */
  if(!PyArg_ParseTuple(args, "s:gc_skin_pixmap_load", &pixmapfile))
    return NULL;

  /* Call the corresponding C function */
  result = gc_skin_pixmap_load(pixmapfile);

  /* Create and return the result */
  pyresult = (PyObject*) pygobject_new((GObject*) result);

  gdk_pixbuf_unref(result);

  return(pyresult);
}
Esempio n. 4
0
void
gc_timer_display(int ax, int ay,
		 TimerList atype, int second,
		 GcomprisTimerEnd agcomprisTimerEnd)
{
  GdkFont *gdk_font;
  GdkPixbuf *pixmap = NULL;
  GcomprisProperties *properties = gc_prop_get();

  /* Timer is user disabled */
  if(properties->timer==0)
    return;

  gdk_font = gdk_font_load (FONT_BOARD_MEDIUM);

  gc_timer_end();

  paused = FALSE;

  boardRootItem = goo_canvas_group_new (goo_canvas_get_root_item(gc_get_canvas()),
					NULL);

  x = ax;
  y = ay;
  second = second / properties->timer;
  timer = second;

  type = atype;
  gcomprisTimerEnd = agcomprisTimerEnd;

  switch(type)
    {
    case GCOMPRIS_TIMER_SAND:
    case GCOMPRIS_TIMER_CLOCK:
      {
	gchar		*filename = NULL;
	gint		fileid;

	fileid = (gint)timer;
	if(type==GCOMPRIS_TIMER_SAND)
	  filename = g_strdup_printf("timers/sablier%d.png", fileid);
	else
	  filename = g_strdup_printf("timers/clock%d.png", fileid);

	pixmap = gc_skin_pixmap_load(filename);

	gc_timer_item = goo_canvas_image_new (boardRootItem,
					      pixmap,
					      x,
					      y,
                          NULL);

#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
	gdk_pixbuf_unref(pixmap);
#else
	g_object_unref(pixmap);
#endif
	g_free(filename);
      }
      break;
    case GCOMPRIS_TIMER_TEXT:
      {
	gchar *tmpstr = g_strdup_printf("Remaining Time = %d", timer);
	/* Display the value for this timer */
	gc_timer_item = goo_canvas_text_new (boardRootItem,
					     tmpstr,
					     x,
					     y,
					     -1,
					     GTK_ANCHOR_CENTER,
					     "font_gdk", gdk_font,
					     "fill_color", "white",
					     NULL);
	g_free(tmpstr);
      }
      break;
    case GCOMPRIS_TIMER_BALLOON:
      pixmap = gc_skin_pixmap_load("timers/tuxballoon.png");
      gc_timer_item = goo_canvas_image_new (boardRootItem,
					    pixmap,
					    x,
					    y,
					    NULL);

      /* Calc the number of step needed to reach
       * the sea based on user y and second
       */
      ystep = (BOARDHEIGHT-y-gdk_pixbuf_get_height(pixmap))/second;

#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
      gdk_pixbuf_unref(pixmap);
#else
      g_object_unref(pixmap);
#endif

      pixmap = gc_skin_pixmap_load("timers/sea.png");
      goo_canvas_image_new (boardRootItem,
			    pixmap,
			    0,
			    BOARDHEIGHT - gdk_pixbuf_get_height(pixmap),
			    "width", (double) gdk_pixbuf_get_width(pixmap),
			    "height", (double) gdk_pixbuf_get_height(pixmap),
			    NULL);
#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
      gdk_pixbuf_unref(pixmap);
#else
      g_object_unref(pixmap);
#endif

      break;
    default:
      break;
    }

  start_animation();
}
Esempio n. 5
0
static gint
timer_increment(GooCanvasItem *item)
{
  if(paused || !boardRootItem)
    return(FALSE);

  timer--;

  if(timer==-1)
    {
      display_time_ellapsed();
      if(gcomprisTimerEnd!=NULL)
	{
	  /* Call the callback */
	  gcomprisTimerEnd();

	}
      return (FALSE);
    }

  switch(type)
    {
    case GCOMPRIS_TIMER_SAND:
    case GCOMPRIS_TIMER_CLOCK:
      if(item)
	{
	  GdkPixbuf	*pixmap = NULL;
	  gchar		*filename = NULL;
	  gint		 fileid;

	  fileid = (gint)timer;
	  if(type == GCOMPRIS_TIMER_SAND)
	    filename = g_strdup_printf("timers/sablier%d.png", fileid);
	  else
	    filename = g_strdup_printf("timers/clock%d.png", fileid);

	  pixmap = gc_skin_pixmap_load(filename);
	  g_object_set(item,
		       "pixbuf", pixmap,
		       NULL);
#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
	  gdk_pixbuf_unref(pixmap);
#else
	  g_object_unref(pixmap);
#endif
	  g_free(filename);
	}
      break;
    case GCOMPRIS_TIMER_TEXT:
      /* Display the value for this timer */
      if(item)
	{
	  char *tmpstr = g_strdup_printf(_("Remaining Time = %d"), timer);
	  g_object_set (item,
			"text", tmpstr,
			NULL);
	  g_free(tmpstr);
	}
      break;
    case GCOMPRIS_TIMER_BALLOON:
      break;
    default:
      break;
    }

  return (TRUE);
}