示例#1
0
static void
_gui_styles_new_style_response(GtkDialog *dialog, gint response_id, dt_gui_styles_dialog_t *g)
{
  if (response_id == GTK_RESPONSE_ACCEPT)
  {
    /* get the filtered list from dialog */
    GList *result = _gui_styles_get_active_items(g);

    /* create the style from imageid */
    if (gtk_entry_get_text ( GTK_ENTRY (g->name)) && strlen(gtk_entry_get_text ( GTK_ENTRY (g->name)))>0)
      dt_styles_create_from_image(
        gtk_entry_get_text ( GTK_ENTRY (g->name)),
        gtk_entry_get_text ( GTK_ENTRY (g->description)),
        g->imgid,result);
  }
  gtk_widget_destroy(GTK_WIDGET(dialog));
  g_free(g->nameorig);
  g_free(g);
}
示例#2
0
文件: styles.c 项目: AlicVB/darktable
int dt_lua_style_create_from_image(lua_State *L)
{
  dt_lua_image_t imgid;
  luaA_to(L, dt_lua_image_t, &imgid, -3);
  const char *newname = luaL_checkstring(L, -2);
  const char *description = lua_isnoneornil(L, -1) ? "" : luaL_checkstring(L, -1);
  dt_styles_create_from_image(newname, description, imgid, NULL);
  GList *style_list = dt_styles_get_list(newname);
  while(style_list)
  {
    dt_style_t *data = style_list->data;
    if(!strcmp(data->name, newname))
    {
      luaA_push(L, dt_style_t, data);
      g_free(data);
      style_list = g_list_delete_link(style_list, style_list);
    }
  }
  g_list_free_full(style_list, dt_style_free); // deal with what's left
  return 1;
}