示例#1
0
文件: bmeditor.c 项目: Sohil876/gftp2
static void
selection_changed_cb (GtkTreeSelection *selection, BookmarkEditor *editor)
{
    GtkTreeModel *model;
    GtkTreeIter iter;
    GNode *node;
    gftp2_bookmark *bm;

    model = GTK_TREE_MODEL (editor->store);

    /* save possible change */
    if (editor->selected_node != NULL && editor->selected_node_content_changed) {
        save_node_change ();
        editor->selected_node_content_changed = 0;
    }

    block_entry_change_signal ();

    if (gtk_tree_selection_get_selected (selection, NULL, &iter) == FALSE)
    { 
        editor->selected_node = NULL;
        set_blank ();
        set_sensitivity ();
        unblock_entry_change_signal ();
        return;
    } else {
        char buf[10];

        gtk_tree_model_get (model, &iter, COLUMN_ENTRY, &node, -1);
        bm = (gftp2_bookmark *)node->data;
        editor->selected_node = node;

        if (bm->is_folder) {
            set_blank ();
            gtk_entry_set_text (editor->name_entry, bm->name);
            set_sensitivity ();
            unblock_entry_change_signal ();
            return;
        }

        set_sensitivity ();
        gtk_entry_set_text (editor->name_entry, bm->name);
        gtk_entry_set_text (GTK_ENTRY (editor->host_entry), 
                            bm->hostname == NULL ? "": bm->hostname);
        gtk_entry_set_text (GTK_ENTRY (editor->user_entry), 
                            (bm->user == NULL) ? "": bm->user);
        gtk_entry_set_text (GTK_ENTRY (editor->passwd_entry), 
                            (bm->passwd == NULL) ? "": bm->passwd);
        snprintf (buf, 10, "%d", bm->port);
        gtk_entry_set_text (GTK_ENTRY (editor->port_entry), buf);

        if (bm->protocol != NULL)
            gtk_combo_box_set_active (GTK_COMBO_BOX (editor->protocol_combo),
                               gftp2_protocol_text_to_index (bm->protocol));
    }
    unblock_entry_change_signal ();
}
static GeglTile *
get_tile (GeglTileSource *gegl_tile_source,
          gint            x,
          gint            y,
          gint            z)
{
  GeglTileSource      *source = ((GeglTileHandler *) gegl_tile_source)->source;
  GeglTileHandlerZoom *zoom   = (GeglTileHandlerZoom *) gegl_tile_source;
  GeglTile            *tile   = NULL;
  const Babl          *format = gegl_tile_backend_get_format (zoom->backend);
  GeglTileStorage     *tile_storage;
  gint                 tile_width;
  gint                 tile_height;
  gint                 tile_size;

  if (source)
    tile = gegl_tile_source_get_tile (source, x, y, z);

  if (tile)
    return tile;

  if (z == 0)/* at base level with no tile found->send null, and shared empty
               tile will be used instead */
    {
      return NULL;
    }

  tile_storage = _gegl_tile_handler_get_tile_storage ((GeglTileHandler *) zoom);

  if (z > tile_storage->seen_zoom)
    tile_storage->seen_zoom = z;

  g_object_get (zoom->backend,
                "tile-width", &tile_width,
                "tile-height", &tile_height,
                "tile-size", &tile_size,
                NULL);

  {
    gint      i, j;
    GeglTile *source_tile[2][2] = { { NULL, NULL }, { NULL, NULL } };

    for (i = 0; i < 2; i++)
      for (j = 0; j < 2; j++)
        {
          /* we get the tile from ourselves, to make successive rescales work
           * correctly */
            source_tile[i][j] = gegl_tile_source_get_tile (gegl_tile_source,
                                                          x * 2 + i, y * 2 + j, z - 1);
        }

    if (source_tile[0][0] == NULL &&
        source_tile[0][1] == NULL &&
        source_tile[1][0] == NULL &&
        source_tile[1][1] == NULL)
      {
        return NULL;   /* no data from level below, return NULL and let GeglTileHandlerEmpty
                          fill in the shared empty tile */
      }

    g_assert (tile == NULL);

    tile = gegl_tile_handler_create_tile (GEGL_TILE_HANDLER (zoom), x, y, z);

    gegl_tile_lock (tile);

    for (i = 0; i < 2; i++)
      for (j = 0; j < 2; j++)
        {
          if (source_tile[i][j])
            {
              set_half (tile, source_tile[i][j], tile_width, tile_height, format, i, j);
              gegl_tile_unref (source_tile[i][j]);
            }
          else
            {
              set_blank (tile, tile_width, tile_height, format, i, j);
            }
        }
    gegl_tile_unlock (tile);
  }

  return tile;
}
示例#3
0
/** @brief Function for main application entry.
 */
int main(void)
{
		spi_buffer_t spi_buffer[NUM_SPI_BUS];
	
		rgb_led_t led_array[NUM_LEDS];
	
		uint32_t current_limit;
		float dim;
	
		// Configure on-board LED-pins as outputs.
		LEDS_CONFIGURE(LEDS_MASK);

		// Initialize spi I/F
		for(uint8_t i=0;i<NUM_SPI_BUS;i++) {
			ws2812b_driver_spi_init(i, &spi[i]);
		}

		for(uint8_t i=0;i<NUM_SPI_BUS;i++) {
				alloc_spi_buffer(&spi_buffer[i], NUM_LEDS);
		}

		LEDS_ON(1 << leds_list[0]);
		LEDS_ON(1 << leds_list[1]);
		LEDS_ON(1 << leds_list[2]);
		LEDS_ON(1 << leds_list[3]);
	
		for(;;)
		{
			LEDS_INVERT(1 << leds_list[2]);

			for(int8_t idemo=0;idemo<size_of_list;idemo++)
			{
				LEDS_INVERT(1 << leds_list[1]);
				
				demo_list[idemo].function_init();
				
				int32_t rest = demo_list[idemo].demo_period;
				int32_t rap  = 0;
				int32_t step = demo_list[idemo].wait_ms + demo_list[idemo].process_time;
				
				while( rest > 0 )
				{
					LEDS_INVERT(1 << leds_list[0]);


					// animate and set up led_array_work 
					demo_list[idemo].function_update(led_array,rap);
					
					// dim LEDs until current limit 
					current_limit = CURRENT_LIMIT;
					ws2812b_driver_current_cap(led_array, NUM_LEDS, current_limit);

					// fade in/out effect
					if ( (demo_list[idemo].demo_period - rest) < FADE_IN_MS )
					{
						dim = (float)0.01+((float)0.99 * ((demo_list[idemo].demo_period - rest)/(float)FADE_IN_MS));
					}
					else if ( rest < FADE_IN_MS) 
					{
						dim = (float)0.01+((float)0.99 * (rest/(float)FADE_IN_MS));
					}
					if ( dim > (float)1.0 ) {
						dim = 1.0;
					}
					
					ws2812b_driver_dim(led_array, NUM_LEDS, dim);
					
					// LED update
					ws2812b_driver_xfer(led_array, spi_buffer[0], spi[0]);
					
					// delay (LED will be updated this period)
					nrf_delay_ms(demo_list[idemo].wait_ms);

					//
					rest -= step;
					rap += step;
				}

				// blank 3sec. between demos
				set_blank(led_array,NUM_LEDS);
				ws2812b_driver_xfer(led_array, spi_buffer[0], spi[0]);

				// delay (LED will be updated this period)
				nrf_delay_ms(3000);
			} // idemo
		} // end-less loop
}