Ejemplo n.º 1
0
static int selection_cb(lua_State *L)
{
    GList *image = dt_collection_get_selected(darktable.collection, -1);
    if(lua_gettop(L) > 0)
    {
        GList * new_selection = NULL;
        luaL_checktype(L,-1,LUA_TTABLE);
        lua_pushnil(L);
        while (lua_next(L, -2) != 0)
        {
            /* uses 'key' (at index -2) and 'value' (at index -1) */
            int imgid;
            luaA_to(L,dt_lua_image_t,&imgid,-1);
            new_selection = g_list_prepend(new_selection,GINT_TO_POINTER(imgid));
            lua_pop(L,1);
        }
        new_selection = g_list_reverse(new_selection);
        dt_lua_unlock(true);// we need the gdk lock to update ui information
        dt_selection_clear(darktable.selection);
        dt_selection_select_list(darktable.selection,new_selection);
        dt_lua_lock();
        g_list_free(new_selection);
    }
    lua_newtable(L);
    while(image)
    {
        luaA_push(L,dt_lua_image_t,&image->data);
        luaL_ref(L,-2);
        image = g_list_delete_link(image, image);
    }
    return 1;
}
Ejemplo n.º 2
0
static gboolean _lib_filmstrip_select_key_accel_callback(GtkAccelGroup *accel_group, GObject *acceleratable,
    guint keyval, GdkModifierType modifier, gpointer data)
{
  switch(GPOINTER_TO_INT(data))
  {
    case 0:  // all
      dt_selection_select_all(darktable.selection);
      break;
    case 1: // none
      dt_selection_clear(darktable.selection);
      break;
    case 2: // invert
      dt_selection_invert(darktable.selection);
      break;
    case 4: // untouched
      dt_selection_select_unaltered(darktable.selection);
      break;
    default: // case 3: same film roll
      dt_selection_select_filmroll(darktable.selection);
  }

  if(darktable.view_manager->proxy.filmstrip.module)
    gtk_widget_queue_draw(darktable.view_manager->proxy.filmstrip.module->widget);

  return TRUE;
}
Ejemplo n.º 3
0
static gboolean _lib_lighttable_key_accel_select_callback(GtkAccelGroup *accel_group, GObject *acceleratable,
                                                          guint keyval, GdkModifierType modifier,
                                                          gpointer data)
{
  switch(GPOINTER_TO_INT(data))
  {
    case 0: // all
      dt_selection_select_all(darktable.selection);
      break;
    case 1: // none
      dt_selection_clear(darktable.selection);
      break;
    case 2: // invert
      dt_selection_invert(darktable.selection);
      break;
    case 4: // untouched
      dt_selection_select_unaltered(darktable.selection);
      break;
    default: // case 3: same film roll
      dt_selection_select_filmroll(darktable.selection);
  }

  dt_control_queue_redraw_center();
  return TRUE;
}
Ejemplo n.º 4
0
static void button_clicked(GtkWidget *widget, gpointer user_data)
{
  switch(GPOINTER_TO_INT(user_data))
  {
    case 0: // all
      dt_selection_select_all(darktable.selection);
      break;
    case 1: // none
      dt_selection_clear(darktable.selection);
      break;
    case 2: // invert
      dt_selection_invert(darktable.selection);
      break;
    case 4: // untouched
      dt_selection_select_unaltered(darktable.selection);
      break;
    default: // case 3: same film roll
      dt_selection_select_filmroll(darktable.selection);
  }

  dt_control_queue_redraw_center();
}
Ejemplo n.º 5
0
static int lua_button_clicked_cb(lua_State* L)
{
  lua_callback_data * data = lua_touserdata(L,1);
  dt_lua_module_entry_push(L,"lib",data->self->plugin_name);
  lua_getuservalue(L,-1);
  lua_getfield(L,-1,"callbacks");
  lua_getfield(L,-1,data->key);
  lua_pushstring(L,data->key);

  GList *image = dt_collection_get_all(darktable.collection, -1);
  lua_newtable(L);
  while(image)
  {
    luaA_push(L, dt_lua_image_t, &image->data);
    luaL_ref(L, -2);
    image = g_list_delete_link(image, image);
  }

  lua_call(L,2,1);

  GList *new_selection = NULL;
  luaL_checktype(L, -1, LUA_TTABLE);
  lua_pushnil(L);
  while(lua_next(L, -2) != 0)
  {
    /* uses 'key' (at index -2) and 'value' (at index -1) */
    int imgid;
    luaA_to(L, dt_lua_image_t, &imgid, -1);
    new_selection = g_list_prepend(new_selection, GINT_TO_POINTER(imgid));
    lua_pop(L, 1);
  }
  new_selection = g_list_reverse(new_selection);
  dt_selection_clear(darktable.selection);
  dt_selection_select_list(darktable.selection, new_selection);
  g_list_free(new_selection);
  return 0;

}