Esempio n. 1
0
static void bar_pane_gps_update(PaneGPSData *pgd)
{
	GList *list;
	GList *work;

	/* The widget does not have a parent during bar_pane_gps_new, so calling gtk_widget_show_all there gives a
	 * "Gtk-CRITICAL **: gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed"
	 * error. gtk_widget_show_all can be given after it has been added to the bar.
	 */
	if (gtk_widget_get_parent(pgd->widget) != NULL)
		gtk_widget_show_all(pgd->widget);

	/* If a create-marker background process is running, kill it
	 * and start again
	 */
	if (pgd->create_markers_id != 0)
		{
		if (g_idle_remove_by_data(pgd))
			{
			pgd->create_markers_id = 0;
			}
		else
			{
			return;
			}		
		}

	/* Delete any markers currently displayed
	 */
	work = clutter_container_get_children(CLUTTER_CONTAINER(pgd->icon_layer));
	while (work)
		{
		clutter_container_remove(CLUTTER_CONTAINER(pgd->icon_layer), work->data, NULL);
		work = work->next;
		}
	g_list_free(work);

	if (!pgd->enable_markers_checked)
		{
		return;
		}

	/* For each selected photo that has GPS data, create a marker containing
	 * a single, small text character the same colour as the marker background.
	 * Use a background process in case the user selects a large number of files.
	 */
	list = layout_selection_list(pgd->pane.lw);
	list = file_data_process_groups_in_selection(list, FALSE, NULL);

	if (list != NULL)
		{
		pgd->selection_list = g_list_copy(list);
		pgd->marker_list = g_ptr_array_new();
		pgd->selection_count = g_list_length(pgd->selection_list);
		pgd->create_markers_id = g_idle_add(bar_pane_gps_create_markers_cb, pgd);
		}

	g_list_free(list);
	g_list_free(work);
}
G_MODULE_EXPORT int
test_textures_main (int argc, char *argv[])
{
  ClutterActor    *texture;
  ClutterActor    *stage;
  gint             i, j;

  if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
    return 1;

  stage = clutter_stage_new ();
  clutter_actor_show_all (CLUTTER_ACTOR (stage));
  g_signal_connect (stage, "destroy", G_CALLBACK (exit_on_destroy), NULL);

  SPIN();

  for (i=100; i<=5000; i += 100)
    for (j=0; j<4; j++)
      {
        const int width = i+j;
        const int height = i+j;
        const gboolean has_alpha = TRUE;
        const int bpp = has_alpha ? 4 : 3;
        int rowstride;
        guchar *pixels;

        pixels = make_rgba_data (width, height, bpp, has_alpha, &rowstride);
        if (!pixels)
          g_error("No memory for %ix%i RGBA data failed", width, height);

        printf("o %ix%i texture... ", width, height);

        texture = clutter_texture_new ();
        if (!clutter_texture_set_from_rgb_data (CLUTTER_TEXTURE (texture),
                                                pixels,
                                                has_alpha,
                                                width,
                                                height,
                                                rowstride,
                                                bpp,
                                                0, NULL))
          g_error("texture creation failed");
        g_free(pixels);
	
	printf("uploaded to texture...\n");
	
	clutter_container_add (CLUTTER_CONTAINER (stage), texture, NULL);
	clutter_actor_set_size (texture, 400, 400);
	clutter_actor_show (texture);

	/* Hide & show to unreaise then realise the texture */
	clutter_actor_hide (texture);
	clutter_actor_show (texture);	

	SPIN();

        clutter_container_remove (CLUTTER_CONTAINER (stage), texture, NULL);
    }

  return EXIT_SUCCESS;
}