~ubuntu-branches/ubuntu/saucy/darktable/saucy

« back to all changes in this revision

Viewing changes to src/common/styles.c

  • Committer: Bazaar Package Importer
  • Author(s): David Bremner
  • Date: 2011-07-12 09:36:46 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20110712093646-yp9dbxan44dmw15h
Tags: 0.9-1
* New upstream release.
* Remove all patches now upstream; only patch for
  -Wno-error=unused-but-set-variable remains.
* Bump Standards-Version to 3.9.2 (no changes)

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
  int   module;
46
46
  GString   *operation;
47
47
  GString   *op_params;
 
48
  GString   *blendop_params;
48
49
  int   enabled;
49
50
} StylePluginData;
50
51
 
98
99
      GList *list=filter;
99
100
      char tmp[64];
100
101
      char include[2048]= {0};
101
 
      strcat(include,"num in (");
 
102
      g_strlcat(include,"num in (", 2048);
102
103
      do
103
104
      {
104
105
        if(list!=g_list_first(list))
105
 
          strcat(include,",");
 
106
          g_strlcat(include,",", 2048);
106
107
        sprintf(tmp,"%ld",(long int)list->data);
107
 
        strcat(include,tmp);
 
108
        g_strlcat(include,tmp, 2048);
108
109
      }
109
110
      while ((list=g_list_next(list)));
110
 
      strcat(include,")");
 
111
      g_strlcat(include,")", 2048);
111
112
      char query[4096]= {0};
112
 
      sprintf(query,"insert into style_items (styleid,num,module,operation,op_params,enabled) select ?1, num,module,operation,op_params,enabled from history where imgid=?2 and %s",include);
 
113
      sprintf(query,"insert into style_items (styleid,num,module,operation,op_params,enabled,blendop_params) select ?1, num,module,operation,op_params,enabled,blendop_params from history where imgid=?2 and %s",include);
113
114
      DT_DEBUG_SQLITE3_PREPARE_V2(darktable.db, query, -1, &stmt, NULL);
114
115
    }
115
116
    else
116
 
      DT_DEBUG_SQLITE3_PREPARE_V2(darktable.db, "insert into style_items (styleid,num,module,operation,op_params,enabled) select ?1, num,module,operation,op_params,enabled from history where imgid=?2", -1, &stmt, NULL);
 
117
      DT_DEBUG_SQLITE3_PREPARE_V2(darktable.db, "insert into style_items (styleid,num,module,operation,op_params,enabled,blendop_params) select ?1, num,module,operation,op_params,enabled,blendop_params from history where imgid=?2", -1, &stmt, NULL);
117
118
    DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, id);
118
119
    DT_DEBUG_SQLITE3_BIND_INT(stmt, 2, imgid);
119
120
    sqlite3_step (stmt);
169
170
    sqlite3_finalize (stmt);
170
171
 
171
172
    /* copy history items from styles onto image */
172
 
    DT_DEBUG_SQLITE3_PREPARE_V2(darktable.db, "insert into history (imgid,num,module,operation,op_params,enabled) select ?1, num+?2,module,operation,op_params,enabled from style_items where styleid=?3", -1, &stmt, NULL);
 
173
    DT_DEBUG_SQLITE3_PREPARE_V2(darktable.db, "insert into history (imgid,num,module,operation,op_params,enabled,blendop_params) select ?1, num+?2,module,operation,op_params,enabled,blendop_params from style_items where styleid=?3", -1, &stmt, NULL);
173
174
    DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, imgid);
174
175
    DT_DEBUG_SQLITE3_BIND_INT(stmt, 2, offs);
175
176
    DT_DEBUG_SQLITE3_BIND_INT(stmt, 3, id);
178
179
 
179
180
    /* add tag */
180
181
    guint tagid=0;
181
 
    if (dt_tag_new(name,&tagid))
 
182
    gchar ntag[512]={0};
 
183
    g_snprintf(ntag,512,"darktable|style|%s",name);
 
184
    if (dt_tag_new(ntag,&tagid))
182
185
      dt_tag_attach(tagid,imgid);
183
186
 
184
187
    /* if current image in develop reload history */
311
314
  xmlTextWriterEndElement(writer);
312
315
 
313
316
  xmlTextWriterStartElement(writer, BAD_CAST "style");
314
 
  DT_DEBUG_SQLITE3_PREPARE_V2(darktable.db, "select num,module,operation,op_params,enabled from style_items where styleid =?1",-1, &stmt,NULL);
 
317
  DT_DEBUG_SQLITE3_PREPARE_V2(darktable.db, "select num,module,operation,op_params,enabled,blendop_params from style_items where styleid =?1",-1, &stmt,NULL);
315
318
  DT_DEBUG_SQLITE3_BIND_INT(stmt,1,dt_styles_get_id_by_name(style_name));
316
319
  while (sqlite3_step (stmt) == SQLITE_ROW)
317
320
  {
321
324
    xmlTextWriterWriteFormatElement(writer, BAD_CAST "operation", "%s", sqlite3_column_text(stmt,2));
322
325
    xmlTextWriterWriteFormatElement(writer, BAD_CAST "op_params", "%s", dt_style_encode(stmt,3));
323
326
    xmlTextWriterWriteFormatElement(writer, BAD_CAST "enabled", "%d", sqlite3_column_int(stmt,4));
 
327
    xmlTextWriterWriteFormatElement(writer, BAD_CAST "blendop_params", "%s", dt_style_encode(stmt,5));
324
328
    xmlTextWriterEndElement(writer);
325
329
  }
326
330
  sqlite3_finalize(stmt);
429
433
    {
430
434
      g_string_append_len (plug->op_params, text, text_len);
431
435
    }
 
436
    else if (g_ascii_strcasecmp (elt, "blendop_params") == 0 )
 
437
    {
 
438
      g_string_append_len (plug->blendop_params, text, text_len);
 
439
    }
432
440
    else if (g_ascii_strcasecmp (elt, "num") == 0 )
433
441
    {
434
442
      plug->num = atoi(text);
459
467
{
460
468
  int id = GPOINTER_TO_INT(styleId);
461
469
  sqlite3_stmt *stmt;
462
 
  DT_DEBUG_SQLITE3_PREPARE_V2(darktable.db, "insert into style_items (styleid,num,module,operation,op_params,enabled) values(?1,?2,?3,?4,?5,?6)", -1, &stmt, NULL);
 
470
  DT_DEBUG_SQLITE3_PREPARE_V2(darktable.db, "insert into style_items (styleid,num,module,operation,op_params,enabled,blendop_params) values(?1,?2,?3,?4,?5,?6,?7)", -1, &stmt, NULL);
463
471
  DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, id);
464
472
  DT_DEBUG_SQLITE3_BIND_INT(stmt, 2, plugin->num);
465
473
  DT_DEBUG_SQLITE3_BIND_INT(stmt, 3, plugin->module);
473
481
  DT_DEBUG_SQLITE3_BIND_BLOB(stmt, 5, params, params_len, SQLITE_TRANSIENT);
474
482
  //
475
483
  DT_DEBUG_SQLITE3_BIND_INT(stmt, 6, plugin->enabled);
 
484
  
 
485
  /* decode and store blendop params */
 
486
  unsigned char *blendop_params = (unsigned char *)g_malloc(strlen(plugin->blendop_params->str));
 
487
  dt_exif_xmp_decode(plugin->blendop_params->str, blendop_params, strlen(plugin->blendop_params->str));
 
488
  DT_DEBUG_SQLITE3_BIND_BLOB(stmt, 7, blendop_params, strlen(plugin->blendop_params->str)/2, SQLITE_TRANSIENT);
 
489
 
476
490
  sqlite3_step(stmt);
477
491
  sqlite3_finalize(stmt);
478
492
  g_free(params);
590
604
  return id;
591
605
}
592
606
 
 
607
// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-space on;