bin: add .lui extension

Files with a .lui extension get executed as lua code similar to the
on-canvas ui. For now, such files get only black thumbnails.
parent 22f07ad3
......@@ -423,6 +423,7 @@ int gegl_str_has_image_suffix (char *path)
g_str_has_suffix (path, ".JPEG") ||
g_str_has_suffix (path, ".CR2") ||
g_str_has_suffix (path, ".cr2") ||
g_str_has_suffix (path, ".lui") ||
g_str_has_suffix (path, ".exr");
}
......
......@@ -16,7 +16,7 @@ typedef void* GeglProcessor;
typedef void* GThread;
typedef void* GHashTable;
struct State {
struct _GeState {
int64_t pad_for_gobject[3];
void (*ui) (Mrg *mrg, void *state);
......@@ -111,14 +111,27 @@ struct State {
GHashTable *ui_consumer;
};
typedef struct _GeState GeState;
const char *ge_state_get_path (GeState *state, int no);
int ge_state_get_n_paths (GeState *state);
float hypotf (float a, float b);
struct State *app_state(void);
GeState *app_state(void);
int argvs_eval (const char *str);
]]
o = ffi.C.app_state()
mrg = o.mrg
ffi.metatype('GeState', {__index = {
get_path = function(...) local ret = ffi.C.ge_state_get_path(...)
if ret ~= nil then return ffi.string(ret) end
return nil
end;
get_n_paths = function(...) return ffi.C.get_state_get_n_paths(...) end;
}})
function touch_point(x, y)
cr:new_path()
......
......@@ -5327,33 +5327,6 @@ jump:
cairo_restore (cr);
}
static void vector_op_ui (GeState *o, GeglNode *node)
{
Mrg *mrg = o->mrg;
GeglPath *path;
cairo_t *cr = mrg_cr (mrg);
double linewidth = 2.0f;
double linewidth_shadow = 2.5f;
double foo ;
cairo_device_to_user_distance (cr, &linewidth, &foo);
cairo_device_to_user_distance (cr, &linewidth_shadow, &foo);
return;
gegl_node_get (node, "d", &path, NULL);
cairo_move_to (cr, 0, 0);
cairo_line_to (cr, 1100,1100);
cairo_set_source_rgba (cr, 0,0,0, .5);
cairo_set_line_width (cr, linewidth_shadow);
cairo_set_source_rgba (cr, 1,0,0, 1.0);
cairo_stroke (cr);
}
static cairo_matrix_t node_get_relative_transform (GeglNode *node_view,
GeglNode *source);
......@@ -5387,17 +5360,7 @@ static int per_op_canvas_ui (GeState *o)
luaname[i] = '_';
}
if (0)
{
if (!strcmp (opname, "gegl:vector-stroke"))
{
vector_op_ui (o, o->active);
}
}
{
run_lua_file (luaname);
}
run_lua_file (luaname);
cairo_restore (cr);
......@@ -5685,6 +5648,35 @@ static void gegl_ui (Mrg *mrg, void *data)
else
{
if (g_str_has_suffix (o->path, ".lui"))
{
int result;
int status = luaL_loadfile(L, o->path);
if (status)
{
fprintf(stderr, "Couldn't load file: %s\n", lua_tostring(L, -1));
}
else
{
result = lua_pcall(L, 0, LUA_MULTRET, 0);
if (result){
fprintf (stderr, "lua exec problem %s\n", lua_tostring(L, -1));
} else
{
}
}
}
#if HAVE_LUA
if (run_lua_file ("viewer.lua"))
{
......@@ -5999,6 +5991,15 @@ static void load_path_inner (GeState *o,
"operation", "gegl:pdf-load", "path", path, NULL);
gegl_node_link_many (o->source, o->sink, NULL);
}
else if (g_str_has_suffix (path, ".lui"))
{
o->gegl = gegl_node_new ();
o->sink = gegl_node_new_child (o->gegl,
"operation", "gegl:nop", NULL);
o->source = gegl_node_new_child (o->gegl,
"operation", "gegl:rectangle", "color", gegl_color_new ("black"), "width", 1024.0, "height", 768.0, NULL);
gegl_node_link_many (o->source, o->sink, NULL);
}
else if (g_str_has_suffix (path, ".gif"))
{
o->gegl = gegl_node_new ();
......@@ -8106,5 +8107,13 @@ cmd_todo (COMMAND_ARGS)
return 0;
}
const char *ge_state_get_path (GeState *state, int no)
{
return g_list_nth_data (state->paths, no);
}
int ge_state_get_n_paths (GeState *state)
{
return g_list_length (state->paths);
}
#endif
......@@ -29,6 +29,7 @@ typedef struct _GeStateClass GeStateClass;
*
*/
struct _GeState {
GObject parent;
void (*ui) (Mrg *mrg, void *state);
......@@ -128,7 +129,8 @@ struct _GeStateClass {
GType ge_state_get_type (void) G_GNUC_CONST;
GeState* ge_state_new (void);
void ge_state_greet (GeState *state);
const char *ge_state_get_path (GeState *state, int no);
int ge_state_get_n_paths (GeState *state);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment