本文整理汇总了C++中dt_loc_get_user_config_dir函数的典型用法代码示例。如果您正苦于以下问题:C++ dt_loc_get_user_config_dir函数的具体用法?C++ dt_loc_get_user_config_dir怎么用?C++ dt_loc_get_user_config_dir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dt_loc_get_user_config_dir函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dt_lua_init
void dt_lua_init(lua_State*L,const int init_gui)
{
char tmp_path[PATH_MAX];
// init the lua environment
lua_CFunction* cur_type = init_funcs;
while(*cur_type)
{
(*cur_type)(L);
cur_type++;
}
dt_lua_push_darktable_lib(L);
// build the table containing the configuration info
lua_getglobal(L,"package");
dt_lua_goto_subtable(L,"loaded");
lua_pushstring(L,"darktable");
dt_lua_push_darktable_lib(L);
lua_settable(L,-3);
lua_pop(L,1);
lua_getglobal(L,"package");
lua_getfield(L,-1,"path");
lua_pushstring(L,";");
dt_loc_get_datadir(tmp_path, PATH_MAX);
lua_pushstring(L,tmp_path);
lua_pushstring(L,"/lua/?.lua");
lua_pushstring(L,";");
dt_loc_get_user_config_dir(tmp_path, PATH_MAX);
lua_pushstring(L,tmp_path);
lua_pushstring(L,"/lua/?.lua");
lua_concat(L,7);
lua_setfield(L,-2,"path");
lua_pop(L,1);
if(init_gui)
{
// run global init script
dt_loc_get_datadir(tmp_path, PATH_MAX);
g_strlcat(tmp_path,"/rc.lua",PATH_MAX);
dt_lua_dofile(darktable.lua_state,tmp_path);
// run user init script
dt_loc_get_user_config_dir(tmp_path, PATH_MAX);
g_strlcat(tmp_path,"/rc.lua",PATH_MAX);
dt_lua_dofile(darktable.lua_state,tmp_path);
}
}
示例2: _handle_get_property
static GVariant *
_handle_get_property(GDBusConnection *connection,
const gchar *sender,
const gchar *object_path,
const gchar *interface_name,
const gchar *property_name,
GError **error,
gpointer user_data)
{
GVariant *ret;
ret = NULL;
if(!g_strcmp0(property_name, "DataDir"))
{
gchar datadir[PATH_MAX];
dt_loc_get_datadir(datadir, sizeof(datadir));
ret = g_variant_new_string(datadir);
}
else if(!g_strcmp0(property_name, "ConfigDir"))
{
gchar configdir[PATH_MAX];
dt_loc_get_user_config_dir(configdir, sizeof(configdir));
ret = g_variant_new_string(configdir);
}
return ret;
}
示例3: dt_styles_create_from_image
void
dt_styles_create_from_image (const char *name,const char *description,int32_t imgid,GList *filter)
{
int id=0;
sqlite3_stmt *stmt;
/* first create the style header */
if (!dt_styles_create_style_header(name,description) ) return;
if ((id=dt_styles_get_id_by_name(name)) != 0)
{
/* create the style_items from source image history stack */
if (filter)
{
GList *list=filter;
char tmp[64];
char include[2048]= {0};
g_strlcat(include,"num in (", 2048);
do
{
if(list!=g_list_first(list))
g_strlcat(include,",", 2048);
sprintf(tmp,"%ld",(long int)list->data);
g_strlcat(include,tmp, 2048);
}
while ((list=g_list_next(list)));
g_strlcat(include,")", 2048);
char query[4096]= {0};
sprintf(query,"insert into style_items (styleid,num,module,operation,op_params,enabled,blendop_params,blendop_version,multi_priority,multi_name) select ?1, num,module,operation,op_params,enabled,blendop_params,blendop_version,multi_priority,multi_name from history where imgid=?2 and %s",include);
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db), query, -1, &stmt, NULL);
}
else
DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db), "insert into style_items (styleid,num,module,operation,op_params,enabled,blendop_params,blendop_version,multi_priority,multi_name) select ?1, num,module,operation,op_params,enabled,blendop_params,blendop_version,multi_priority,multi_name from history where imgid=?2", -1, &stmt, NULL);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 1, id);
DT_DEBUG_SQLITE3_BIND_INT(stmt, 2, imgid);
sqlite3_step (stmt);
sqlite3_finalize (stmt);
/* backup style to disk */
char stylesdir[1024];
dt_loc_get_user_config_dir(stylesdir, 1024);
g_strlcat(stylesdir,"/styles",1024);
g_mkdir_with_parents(stylesdir,00755);
dt_styles_save_to_file(name,stylesdir,FALSE);
char tmp_accel[1024];
gchar* tmp_name = g_strdup(name); // freed by _destro_style_shortcut_callback
snprintf(tmp_accel,1024,"styles/Apply %s",name);
dt_accel_register_global( tmp_accel, 0, 0);
GClosure *closure;
closure = g_cclosure_new(
G_CALLBACK(_apply_style_shortcut_callback),
tmp_name, _destroy_style_shortcut_callback);
dt_accel_connect_global(tmp_accel, closure);
dt_control_log(_("style named '%s' successfully created"),name);
}
}
示例4: dt_lua_init
void dt_lua_init(lua_State*L,const char *lua_command)
{
/*
Note to reviewers
this is the only place where lua code is run without the lua lock.
At this point, no user script has been called,
so we are completely thread-safe. no need to lock
This is also the only place where lua code is run with the gdk lock
held, but this is not a problem because it is very brief, user calls
are delegated to a secondary job
*/
char tmp_path[PATH_MAX];
// init the lua environment
lua_CFunction* cur_type = init_funcs;
while(*cur_type)
{
(*cur_type)(L);
cur_type++;
}
// build the table containing the configuration info
lua_getglobal(L,"package");
dt_lua_goto_subtable(L,"loaded");
lua_pushstring(L,"darktable");
dt_lua_push_darktable_lib(L);
lua_settable(L,-3);
lua_pop(L,1);
lua_getglobal(L,"package");
lua_getfield(L,-1,"path");
lua_pushstring(L,";");
dt_loc_get_datadir(tmp_path, sizeof(tmp_path));
lua_pushstring(L,tmp_path);
lua_pushstring(L,"/lua/?.lua");
lua_pushstring(L,";");
dt_loc_get_user_config_dir(tmp_path, sizeof(tmp_path));
lua_pushstring(L,tmp_path);
lua_pushstring(L,"/lua/?.lua");
lua_concat(L,7);
lua_setfield(L,-2,"path");
lua_pop(L,1);
dt_job_t *job = dt_control_job_create(&run_early_script, "lua: run initial script");
dt_control_job_set_params(job, g_strdup(lua_command));
if(darktable.gui)
{
dt_control_add_job(darktable.control, DT_JOB_QUEUE_USER_BG, job);
}
else
{
run_early_script(job);
dt_control_job_dispose(job);
}
}
示例5: refresh_watermarks
static void refresh_watermarks( dt_iop_module_t *self )
{
dt_iop_watermark_gui_data_t *g = (dt_iop_watermark_gui_data_t *)self->gui_data;
dt_iop_watermark_params_t *p = (dt_iop_watermark_params_t *)self->params;
g_signal_handlers_block_by_func (g->combobox1,watermark_callback,self);
// Clear combobox...
GtkTreeModel *model=gtk_combo_box_get_model(g->combobox1);
gtk_list_store_clear (GTK_LIST_STORE(model));
// check watermarkdir and update combo with entries...
int count=0;
const gchar *d_name = NULL;
gchar configdir[DT_MAX_PATH_LEN];
gchar datadir[DT_MAX_PATH_LEN];
gchar filename[DT_MAX_PATH_LEN];
dt_loc_get_datadir(datadir, DT_MAX_PATH_LEN);
dt_loc_get_user_config_dir(configdir, DT_MAX_PATH_LEN);
g_strlcat(datadir,"/watermarks", DT_MAX_PATH_LEN);
g_strlcat(configdir,"/watermarks", DT_MAX_PATH_LEN);
/* read watermarks from datadir */
GDir *dir = g_dir_open(datadir, 0, NULL);
if(dir)
{
while((d_name = g_dir_read_name(dir)))
{
snprintf(filename, DT_MAX_PATH_LEN, "%s/%s", datadir, d_name);
gtk_combo_box_append_text( g->combobox1, d_name );
count++;
}
g_dir_close(dir) ;
}
/* read watermarks from user config dir*/
dir = g_dir_open(configdir, 0, NULL);
if(dir)
{
while((d_name = g_dir_read_name(dir)))
{
snprintf(filename, DT_MAX_PATH_LEN, "%s/%s", configdir, d_name);
gtk_combo_box_append_text( g->combobox1, d_name );
count++;
}
g_dir_close(dir) ;
}
_combo_box_set_active_text( g->combobox1, p->filename );
g_signal_handlers_unblock_by_func (g->combobox1,watermark_callback,self);
}
示例6: gui_init
void gui_init(struct dt_iop_module_t *self)
{
const int force_lcms2 = dt_conf_get_bool("plugins/lighttable/export/force_lcms2");
self->gui_data = calloc(1, sizeof(dt_iop_colorout_gui_data_t));
dt_iop_colorout_gui_data_t *g = (dt_iop_colorout_gui_data_t *)self->gui_data;
char datadir[PATH_MAX] = { 0 };
char confdir[PATH_MAX] = { 0 };
dt_loc_get_datadir(datadir, sizeof(datadir));
dt_loc_get_user_config_dir(confdir, sizeof(confdir));
self->widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, DT_BAUHAUS_SPACE);
// TODO:
g->output_intent = dt_bauhaus_combobox_new(self);
gtk_box_pack_start(GTK_BOX(self->widget), g->output_intent, TRUE, TRUE, 0);
dt_bauhaus_widget_set_label(g->output_intent, NULL, _("output intent"));
dt_bauhaus_combobox_add(g->output_intent, _("perceptual"));
dt_bauhaus_combobox_add(g->output_intent, _("relative colorimetric"));
dt_bauhaus_combobox_add(g->output_intent, C_("rendering intent", "saturation"));
dt_bauhaus_combobox_add(g->output_intent, _("absolute colorimetric"));
if(!force_lcms2)
{
gtk_widget_set_no_show_all(g->output_intent, TRUE);
gtk_widget_set_visible(g->output_intent, FALSE);
}
g->output_profile = dt_bauhaus_combobox_new(self);
dt_bauhaus_widget_set_label(g->output_profile, NULL, _("output profile"));
gtk_box_pack_start(GTK_BOX(self->widget), g->output_profile, TRUE, TRUE, 0);
for(GList *l = darktable.color_profiles->profiles; l; l = g_list_next(l))
{
dt_colorspaces_color_profile_t *prof = (dt_colorspaces_color_profile_t *)l->data;
if(prof->out_pos > -1) dt_bauhaus_combobox_add(g->output_profile, prof->name);
}
char tooltip[1024];
g_object_set(G_OBJECT(g->output_intent), "tooltip-text", _("rendering intent"), (char *)NULL);
snprintf(tooltip, sizeof(tooltip), _("ICC profiles in %s/color/out or %s/color/out"), confdir, datadir);
g_object_set(G_OBJECT(g->output_profile), "tooltip-text", tooltip, (char *)NULL);
g_signal_connect(G_OBJECT(g->output_intent), "value-changed", G_CALLBACK(intent_changed), (gpointer)self);
g_signal_connect(G_OBJECT(g->output_profile), "value-changed", G_CALLBACK(output_profile_changed), (gpointer)self);
// reload the profiles when the display or softproof profile changed!
dt_control_signal_connect(darktable.signals, DT_SIGNAL_CONTROL_PROFILE_CHANGED,
G_CALLBACK(_signal_profile_changed), self->dev);
// update the gui when the preferences changed (i.e. show intent when using lcms2)
dt_control_signal_connect(darktable.signals, DT_SIGNAL_PREFERENCES_CHANGE,
G_CALLBACK(_preference_changed), (gpointer)self);
}
示例7: dt_lua_init
void dt_lua_init(lua_State *L, const char *lua_command)
{
char tmp_path[PATH_MAX] = { 0 };
// init the lua environment
lua_CFunction *cur_type = init_funcs;
while(*cur_type)
{
(*cur_type)(L);
cur_type++;
}
assert(lua_gettop(L)
== 0); // if you are here, you have probably added an initialisation function that is not stack clean
// build the table containing the configuration info
lua_getglobal(L, "package");
dt_lua_goto_subtable(L, "loaded");
lua_pushstring(L, "darktable");
dt_lua_push_darktable_lib(L);
lua_settable(L, -3);
lua_pop(L, 1);
lua_getglobal(L, "package");
lua_getfield(L, -1, "path");
lua_pushstring(L, ";");
dt_loc_get_datadir(tmp_path, sizeof(tmp_path));
lua_pushstring(L, tmp_path);
lua_pushstring(L, "/lua/?.lua");
lua_pushstring(L, ";");
dt_loc_get_user_config_dir(tmp_path, sizeof(tmp_path));
lua_pushstring(L, tmp_path);
lua_pushstring(L, "/lua/?.lua");
lua_concat(L, 7);
lua_setfield(L, -2, "path");
lua_pop(L, 1);
lua_pushcfunction(L,run_early_script);
lua_pushstring(L,lua_command);
if(darktable.gui)
{
dt_lua_do_chunk_later(L,1);
}
else
{
dt_lua_do_chunk_silent(L,1,0);
}
// allow other threads to wake up and do their job
dt_lua_unlock();
}
示例8: refresh_watermarks
static void refresh_watermarks(dt_iop_module_t *self)
{
dt_iop_watermark_gui_data_t *g = (dt_iop_watermark_gui_data_t *)self->gui_data;
dt_iop_watermark_params_t *p = (dt_iop_watermark_params_t *)self->params;
g_signal_handlers_block_by_func(g->watermarks, watermark_callback, self);
// Clear combobox...
dt_bauhaus_combobox_clear(g->watermarks);
// check watermarkdir and update combo with entries...
int count = 0;
const gchar *d_name = NULL;
gchar configdir[PATH_MAX] = { 0 };
gchar datadir[PATH_MAX] = { 0 };
gchar filename[PATH_MAX] = { 0 };
dt_loc_get_datadir(datadir, sizeof(datadir));
dt_loc_get_user_config_dir(configdir, sizeof(configdir));
g_strlcat(datadir, "/watermarks", sizeof(datadir));
g_strlcat(configdir, "/watermarks", sizeof(configdir));
/* read watermarks from datadir */
GDir *dir = g_dir_open(datadir, 0, NULL);
if(dir)
{
while((d_name = g_dir_read_name(dir)))
{
snprintf(filename, sizeof(filename), "%s/%s", datadir, d_name);
dt_bauhaus_combobox_add(g->watermarks, d_name);
count++;
}
g_dir_close(dir);
}
/* read watermarks from user config dir*/
dir = g_dir_open(configdir, 0, NULL);
if(dir)
{
while((d_name = g_dir_read_name(dir)))
{
snprintf(filename, sizeof(filename), "%s/%s", configdir, d_name);
dt_bauhaus_combobox_add(g->watermarks, d_name);
count++;
}
g_dir_close(dir);
}
_combo_box_set_active_text(g->watermarks, p->filename);
g_signal_handlers_unblock_by_func(g->watermarks, watermark_callback, self);
}
示例9: dt_colorspaces_find_profile
int
dt_colorspaces_find_profile(char *filename, const int filename_len, const char *profile, const char *inout)
{
char datadir[DT_MAX_PATH_LEN];
dt_loc_get_user_config_dir(datadir, DT_MAX_PATH_LEN);
snprintf(filename, filename_len, "%s/color/%s/%s", datadir, inout, profile);
if(!g_file_test(filename, G_FILE_TEST_IS_REGULAR))
{
dt_loc_get_datadir(datadir, DT_MAX_PATH_LEN);
snprintf(filename, filename_len, "%s/color/%s/%s", datadir, inout, profile);
if(!g_file_test(filename, G_FILE_TEST_IS_REGULAR)) return 1;
}
return 0;
}
示例10: run_early_script
static int run_early_script(lua_State* L)
{
char tmp_path[PATH_MAX] = { 0 };
// run global init script
dt_loc_get_datadir(tmp_path, sizeof(tmp_path));
g_strlcat(tmp_path, "/luarc", sizeof(tmp_path));
dt_lua_dofile_silent(L, tmp_path, 0, 0);
if(darktable.gui != NULL)
{
// run user init script
dt_loc_get_user_config_dir(tmp_path, sizeof(tmp_path));
g_strlcat(tmp_path, "/luarc", sizeof(tmp_path));
dt_lua_dofile_silent(L, tmp_path, 0, 0);
}
if(!lua_isnil(L,1)){
const char *lua_command = lua_tostring(L, 1);
dt_lua_dostring_silent(L, lua_command, 0, 0);
}
dt_lua_redraw_screen();
return 0;
}
示例11: dt_lua_init_configuration
int dt_lua_init_configuration(lua_State*L){
char tmp_path[PATH_MAX];
dt_lua_push_darktable_lib(L);
dt_lua_goto_subtable(L,"configuration");
// build the table containing the configuration info
lua_pushstring(L,"tmp_dir");
dt_loc_get_tmp_dir(tmp_path, PATH_MAX);
lua_pushstring(L,tmp_path);
lua_settable(L,-3);
lua_pushstring(L,"config_dir");
dt_loc_get_user_config_dir(tmp_path, PATH_MAX);
lua_pushstring(L,tmp_path);
lua_settable(L,-3);
lua_pushstring(L,"cache_dir");
dt_loc_get_user_cache_dir(tmp_path, PATH_MAX);
lua_pushstring(L,tmp_path);
lua_settable(L,-3);
lua_pushstring(L,"version");
lua_pushstring(darktable.lua_state,PACKAGE_VERSION);
lua_settable(L,-3);
lua_pushstring(L,"verbose");
lua_pushboolean(L,darktable.unmuted & DT_DEBUG_LUA);
lua_settable(L,-3);
lua_pushstring(L,"has_gui");
lua_pushboolean(L,darktable.gui != NULL);
lua_settable(L,-3);
lua_pop(L,-1); //remove the configuration table from the stack
return 0;
}
示例12: run_early_script
static int run_early_script(lua_State* L)
{
char basedir[PATH_MAX] = { 0 };
// run global init script
dt_loc_get_datadir(basedir, sizeof(basedir));
char *luarc = g_build_filename(basedir, "luarc", NULL);
dt_lua_check_print_error(L, luaL_dofile(L, luarc));
g_free(luarc);
if(darktable.gui != NULL)
{
// run user init script
dt_loc_get_user_config_dir(basedir, sizeof(basedir));
luarc = g_build_filename(basedir, "luarc", NULL);
dt_lua_check_print_error(L, luaL_dofile(L, luarc));
g_free(luarc);
}
if(!lua_isnil(L,1)){
const char *lua_command = lua_tostring(L, 1);
dt_lua_check_print_error(L,luaL_dostring(L,lua_command));
}
dt_lua_redraw_screen();
return 0;
}
示例13: run_early_script
static int32_t run_early_script(dt_job_t *job)
{
char tmp_path[PATH_MAX];
lua_State *L = darktable.lua_state.state;
gboolean has_lock = dt_lua_lock();
// run global init script
dt_loc_get_datadir(tmp_path, sizeof(tmp_path));
g_strlcat(tmp_path, "/luarc", sizeof(tmp_path));
dt_lua_dofile_silent(L,tmp_path,0,0);
if(darktable.gui != NULL)
{
// run user init script
dt_loc_get_user_config_dir(tmp_path, sizeof(tmp_path));
g_strlcat(tmp_path, "/luarc", sizeof(tmp_path));
dt_lua_dofile_silent(L,tmp_path,0,0);
}
char *lua_command = dt_control_job_get_params(job);
if(lua_command)
dt_lua_dostring_silent(L, lua_command, 0, 0);
free(lua_command);
dt_lua_redraw_screen();
dt_lua_unlock(has_lock);
return 0;
}
示例14: dt_gui_gtk_init
int
dt_gui_gtk_init(dt_gui_gtk_t *gui, int argc, char *argv[])
{
// unset gtk rc from kde:
char gtkrc[PATH_MAX], path[PATH_MAX], datadir[PATH_MAX], configdir[PATH_MAX];
dt_loc_get_datadir(datadir, PATH_MAX);
dt_loc_get_user_config_dir(configdir, PATH_MAX);
g_snprintf(gtkrc, PATH_MAX, "%s/darktable.gtkrc", configdir);
if (!g_file_test(gtkrc, G_FILE_TEST_EXISTS))
g_snprintf(gtkrc, PATH_MAX, "%s/darktable.gtkrc", datadir);
if (g_file_test(gtkrc, G_FILE_TEST_EXISTS))
(void)setenv("GTK2_RC_FILES", gtkrc, 1);
else
fprintf(stderr, "[gtk_init] could not found darktable.gtkrc");
/* lets zero mem */
memset(gui,0,sizeof(dt_gui_gtk_t));
#if GLIB_MAJOR_VERSION <= 2
#if GLIB_MINOR_VERSION < 31
if (!g_thread_supported ()) g_thread_init(NULL);
#endif
#endif
gdk_threads_init();
gdk_threads_enter();
gtk_init (&argc, &argv);
GtkWidget *widget;
gui->ui = dt_ui_initialize(argc,argv);
gui->pixmap = NULL;
gui->center_tooltip = 0;
gui->presets_popup_menu = NULL;
if(g_file_test(gtkrc, G_FILE_TEST_EXISTS))
gtk_rc_parse (gtkrc);
// Initializing the shortcut groups
darktable.control->accelerators = gtk_accel_group_new();
darktable.control->accelerator_list = NULL;
// Connecting the callback to update keyboard accels for key_pressed
g_signal_connect(G_OBJECT(gtk_accel_map_get()),
"changed",
G_CALLBACK(key_accel_changed),
NULL);
// Initializing widgets
init_widgets();
// Adding the global shortcut group to the main window
gtk_window_add_accel_group(GTK_WINDOW(dt_ui_main_window(darktable.gui->ui)),
darktable.control->accelerators);
// get the screen resolution
gui->dpi = gdk_screen_get_resolution(gtk_widget_get_screen(GTK_WIDGET(dt_ui_main_window(darktable.gui->ui))));
// set constant width from conf key
int panel_width = dt_conf_get_int("panel_width");
if(panel_width < 20 || panel_width > 500)
{
// fix for unset/insane values.
panel_width = 300;
dt_conf_set_int("panel_width", panel_width);
}
// dt_gui_background_jobs_init();
/* Have the delete event (window close) end the program */
dt_loc_get_datadir(datadir, PATH_MAX);
snprintf(path, PATH_MAX, "%s/icons", datadir);
gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (), path);
widget = dt_ui_center(darktable.gui->ui);
g_signal_connect (G_OBJECT (widget), "key-press-event",
G_CALLBACK (key_pressed), NULL);
g_signal_connect (G_OBJECT (widget), "configure-event",
G_CALLBACK (configure), NULL);
g_signal_connect (G_OBJECT (widget), "expose-event",
G_CALLBACK (expose), NULL);
g_signal_connect (G_OBJECT (widget), "motion-notify-event",
G_CALLBACK (mouse_moved), NULL);
g_signal_connect (G_OBJECT (widget), "leave-notify-event",
G_CALLBACK (center_leave), NULL);
g_signal_connect (G_OBJECT (widget), "enter-notify-event",
G_CALLBACK (center_enter), NULL);
g_signal_connect (G_OBJECT (widget), "button-press-event",
G_CALLBACK (button_pressed), NULL);
g_signal_connect (G_OBJECT (widget), "button-release-event",
G_CALLBACK (button_released), NULL);
g_signal_connect (G_OBJECT (widget), "scroll-event",
G_CALLBACK (scrolled), NULL);
// TODO: left, right, top, bottom:
//leave-notify-event
//.........这里部分代码省略.........
示例15: dt_loc_get_datadir
static gchar *_watermark_get_svgdoc(dt_iop_module_t *self, dt_iop_watermark_data_t *data,
const dt_image_t *image)
{
gsize length;
gchar *svgdoc = NULL;
gchar configdir[PATH_MAX] = { 0 };
gchar datadir[PATH_MAX] = { 0 };
gchar *filename;
dt_loc_get_datadir(datadir, sizeof(datadir));
dt_loc_get_user_config_dir(configdir, sizeof(configdir));
g_strlcat(datadir, "/watermarks/", sizeof(datadir));
g_strlcat(configdir, "/watermarks/", sizeof(configdir));
g_strlcat(datadir, data->filename, sizeof(datadir));
g_strlcat(configdir, data->filename, sizeof(configdir));
if(g_file_test(configdir, G_FILE_TEST_EXISTS))
filename = configdir;
else if(g_file_test(datadir, G_FILE_TEST_EXISTS))
filename = datadir;
else
return NULL;
gchar *svgdata = NULL;
char datetime[200];
// EXIF datetime
struct tm tt_exif = { 0 };
if(sscanf(image->exif_datetime_taken, "%d:%d:%d %d:%d:%d", &tt_exif.tm_year, &tt_exif.tm_mon,
&tt_exif.tm_mday, &tt_exif.tm_hour, &tt_exif.tm_min, &tt_exif.tm_sec) == 6)
{
tt_exif.tm_year -= 1900;
tt_exif.tm_mon--;
}
// Current datetime
struct tm tt_cur = { 0 };
time_t t = time(NULL);
(void)localtime_r(&t, &tt_cur);
if(g_file_get_contents(filename, &svgdata, &length, NULL))
{
// File is loaded lets substitute strings if found...
// Darktable internal
svgdoc = _string_substitute(svgdata, "$(DARKTABLE.NAME)", PACKAGE_NAME);
if(svgdoc != svgdata)
{
g_free(svgdata);
svgdata = svgdoc;
}
svgdoc = _string_substitute(svgdata, "$(DARKTABLE.VERSION)", PACKAGE_VERSION);
if(svgdoc != svgdata)
{
g_free(svgdata);
svgdata = svgdoc;
}
// Simple text from watermark module
gchar buffer[1024];
if (data->font[0] && data->text[0])
{
g_snprintf(buffer, sizeof(buffer), "%s", data->text);
svgdoc = _string_substitute(svgdata, "$(WATERMARK_TEXT)", buffer);
if(svgdoc != svgdata)
{
g_free(svgdata);
svgdata = svgdoc;
}
PangoFontDescription *font = pango_font_description_from_string(data->font);
const PangoStyle font_style = pango_font_description_get_style(font);
const int font_weight = (int)pango_font_description_get_weight(font);
g_snprintf(buffer, sizeof(buffer), "%s", pango_font_description_get_family(font));
svgdoc = _string_substitute(svgdata, "$(WATERMARK_FONT_FAMILY)", buffer);
if(svgdoc != svgdata)
{
g_free(svgdata);
svgdata = svgdoc;
}
switch (font_style)
{
case PANGO_STYLE_OBLIQUE:
g_strlcpy(buffer, "oblique", sizeof(buffer));
break;
case PANGO_STYLE_ITALIC:
g_strlcpy(buffer, "italic", sizeof(buffer));
break;
default:
g_strlcpy(buffer, "normal", sizeof(buffer));
break;
}
svgdoc = _string_substitute(svgdata, "$(WATERMARK_FONT_STYLE)", buffer);
if(svgdoc != svgdata)
{
g_free(svgdata);
svgdata = svgdoc;
//.........这里部分代码省略.........