示例#1
0
void
on_update_clock(ClutterTimeline *timeline,
                      gint frame_num,
                      gpointer data)
{
  HandCar *all = (HandCar *)data;

  gchar *txt;
  gint64 time = -1;
  gint hours, minutes, seconds;
  

  if(!gst_element_query_position (all->player, &all->format, &time))
      clutter_label_set_text (CLUTTER_LABEL(all->label_time), "<span size='6000'>UNKNOWN</span>");
  else if (time != -1)
    {
      time /= GST_SECOND;
      hours = time / (60 * 60);
      minutes = (time - (hours *60 * 60)) / 60;
      seconds = time % 60;

      txt = g_strdup_printf ("%02d:%02d:%02d", 
                             hours, 
                             minutes,
                             seconds);

      clutter_label_set_text(CLUTTER_LABEL(all->label_time), txt);
      g_free (txt);
    }

}
gboolean
on_event (ClutterStage *stage,
	  ClutterEvent *event,
	  gpointer      user_data)
{
  switch (event->type)
    {
    case CLUTTER_BUTTON_PRESS:
      {
	gint x, y;
	ClutterActor * actor;
	ClutterUnit xu2, yu2;

        clutter_event_get_coords (event, &x, &y);

	actor = clutter_stage_get_actor_at_pos (stage, x, y);


	if (clutter_actor_transform_stage_point (actor,
						CLUTTER_UNITS_FROM_DEVICE (x),
						CLUTTER_UNITS_FROM_DEVICE (y),
						&xu2, &yu2))
	  {
	    gchar *txt;

	    if (actor != CLUTTER_ACTOR (stage))
	      txt = g_strdup_printf ("Click on rectangle\n"
				     "Screen coords: [%d, %d]\n"
				     "Local coords : [%d, %d]",
				     x, y,
				     CLUTTER_UNITS_TO_DEVICE (xu2),
				     CLUTTER_UNITS_TO_DEVICE (yu2));
	    else
	      txt = g_strdup_printf ("Click on stage\n"
				     "Screen coords: [%d, %d]\n"
				     "Local coords : [%d, %d]",
				     x, y,
				     CLUTTER_UNITS_TO_DEVICE (xu2),
				     CLUTTER_UNITS_TO_DEVICE (yu2));

	    clutter_label_set_text (CLUTTER_LABEL (label), txt);
	    g_free (txt);
	  }
	else
	  clutter_label_set_text (CLUTTER_LABEL (label),
				  "Unprojection failed.");
      }
      break;

    default:
      break;
    }

  return FALSE;
}
static gboolean
update_label_idle (gpointer data)
{
  TestUpdate *update = data;
  guint width;
  gchar *text;

  text = g_strdup_printf ("Count to %d", update->count);

  clutter_label_set_text (CLUTTER_LABEL (update->thread_data->label), text);
  clutter_actor_set_width (update->thread_data->label, -1);

  if (update->count == 0)
    width = 0;
  else if (update->count == 100)
    width = 350;
  else
    width = (guint) (update->count / 100.0 * 350.0);

  clutter_actor_set_width (update->thread_data->progress, width);

  g_free (text);
  g_free (update);

  return FALSE;
}
static void
on_key_press_event (ClutterStage    *stage,
                    ClutterKeyEvent *event,
                    gpointer         user_data)
{
  TestThreadData *data;

  switch (clutter_key_event_symbol (event))
    {
    case CLUTTER_s:
      clutter_label_set_text (CLUTTER_LABEL (help_label), "Press 'q' to quit");

      clutter_timeline_start (timeline);
      
      data = test_thread_data_new ();
      data->stage = g_object_ref (stage);
      data->label = g_object_ref (count_label);
      data->progress = g_object_ref (progress_rect);
      data->timeline = g_object_ref (timeline);
      g_thread_create (test_thread_func, data, FALSE, NULL);
      break;
    case CLUTTER_q:
      clutter_main_quit ();
      break;
    }
}
static gboolean
test_thread_done_idle (gpointer user_data)
{
  TestThreadData *data = user_data;

  g_print ("Thread completed\n");

  clutter_label_set_text (CLUTTER_LABEL (data->label), "Completed");
  clutter_timeline_stop (data->timeline);

  test_thread_data_free (data);

  return FALSE;
}
示例#6
0
/* Private functions */
static void
astro_contact_row_set_name (AstroContactRow *row, const gchar *name)
{
  AstroContactRowPrivate *priv;

  g_return_if_fail (ASTRO_IS_CONTACT_ROW (row));
  g_return_if_fail (name);
  priv = row->priv;

  if (priv->name)
    g_free (priv->name);
  priv->name = g_strdup (name);

  clutter_label_set_text (CLUTTER_LABEL (priv->label), name);

  clutter_actor_set_position (priv->label, (PADDING*2)+ICON_SIZE, 
                    (ROW_HEIGHT /2)-(clutter_actor_get_height (priv->label)/2));
}
示例#7
0
/* Public Functions */
void
astro_texture_group_set_text (AstroTextureGroup *group, const gchar *text)
{
  AstroTextureGroupPrivate *priv;

  g_return_if_fail (ASTRO_IS_TEXTURE_GROUP (group));
  g_return_if_fail (text);
  priv = group->priv;

  clutter_label_set_text (CLUTTER_LABEL (priv->label), text);

  clutter_actor_set_position (priv->label, PADDING, PADDING);
  
  clutter_actor_set_size (priv->bg, 
                          GROUP_WIDTH,
                          clutter_actor_get_height (priv->label) + (2*PADDING));
  clutter_actor_set_position (priv->bg, 0, 0);
}
示例#8
0
static gboolean 
set_time (AstroSystray *systray)
{
  AstroSystrayPrivate *priv;
  time_t rawtime;
  struct tm *timeinfo;
  char buffer [100];

  g_return_val_if_fail (ASTRO_IS_SYSTRAY (systray), FALSE);
  priv = systray->priv;

  time (&rawtime);
  timeinfo = localtime (&rawtime);

  strftime (buffer, 100, "%a %d %b,%H:%M   ", timeinfo);
  
  clutter_label_set_text (CLUTTER_LABEL (priv->time), buffer);
  
  return TRUE;
}