Commit f7a258c0 authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

port GUI code for pddplink

parent aa00d258
......@@ -99,19 +99,19 @@ static void pddplink_select(t_gobj *z, t_glist *glist, int state)
if (glist_isvisible(glist) && glist->gl_havewindow)
{
if (state) {
sys_vgui(".x%lx.c itemconfigure %s -fill $::pd_colors(selection)\n",
glist, rtext_gettag(y));
sys_vgui(".x%lx.c addtag selected withtag %s\n",
glist, rtext_gettag(y));
//sys_vgui(".x%lx.c itemconfigure %s -fill $::pd_colors(selection)\n",
// glist, rtext_gettag(y));
//sys_vgui(".x%lx.c addtag selected withtag %s\n",
// glist, rtext_gettag(y));
gui_vmess("gui_gobj_select", "xs",
glist, rtext_gettag(y));
}
else
{
sys_vgui(".x%lx.c itemconfigure %s -text {%s} -fill #0000dd -activefill #e70000\n",
glist, rtext_gettag(y), x->x_vistext);
sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", (t_int)glist_getcanvas(glist));
sys_vgui(".x%lx.c dtag %s selected\n", glist, rtext_gettag(y));
//sys_vgui(".x%lx.c itemconfigure %s -text {%s} -fill #0000dd -activefill #e70000\n",
// glist, rtext_gettag(y), x->x_vistext);
//sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", (t_int)glist_getcanvas(glist));
//sys_vgui(".x%lx.c dtag %s selected\n", glist, rtext_gettag(y));
gui_vmess("gui_gobj_deselect", "xs",
glist, rtext_gettag(y));
}
......@@ -160,7 +160,7 @@ static void pddplink_vis(t_gobj *z, t_glist *glist, int vis)
if ((glist->gl_havewindow || x->x_isgopvisible)
&& (y = glist_findrtext(glist, (t_text *)x)))
{
sys_vgui(".x%lx.c itemconfigure %s -text {%s} -fill #0000dd -activefill #e70000\n", glist_getcanvas(glist), rtext_gettag(y), x->x_vistext);
//sys_vgui(".x%lx.c itemconfigure %s -text {%s} -fill #0000dd -activefill #e70000\n", glist_getcanvas(glist), rtext_gettag(y), x->x_vistext);
gui_vmess("gui_text_create_gobj", "xssiii",
glist_getcanvas(glist),
rtext_gettag(y),
......@@ -231,8 +231,11 @@ static void pddplink_click(t_pddplink *x, t_floatarg xpos, t_floatarg ypos,
x->x_ishit = 1;
char final_name[FILENAME_MAX];
sys_expandpathelems(x->x_ulink->s_name, final_name);
sys_vgui("pddplink_open {%s} {%s}\n", \
final_name, x->x_dirsym->s_name);
//sys_vgui("pddplink_open {%s} {%s}\n", \
// final_name, x->x_dirsym->s_name);
gui_vmess("gui_pddplink_open", "ss",
final_name,
x->x_dirsym->s_name);
x->x_ishit = 0;
}
......
......@@ -216,7 +216,7 @@ function enquote (x) {
}
// from stackoverflow.com/questions/21698906/how-to-check-if-a-path-is-absolute-or-relative
// this doesn't seem to be needed atm
// only seems to be used by pddplink_open
function path_is_absolute(myPath) {
var ret = (path.resolve(myPath) ===
path.normalize(myPath).replace(/(.+)([\/]\\])$/, "$1"));
......@@ -3745,3 +3745,22 @@ exports.resize_window = function(did) {
dialogwin[did].width = w;
dialogwin[did].height = h;
}
// External GUI classes
function gui_pddplink_open(filename, dir) {
var full_path, revised_dir, revised_filename;
if (filename.indexOf("://") > -1) {
external_doc_open(filename);
} else if (path_is_absolute(filename)) {
doc_open(path.dirname(filename), path.basename(filename));
} else if (fs.existsSync(path.join(dir, filename))) {
full_path = path.normalize(path.join(dir, filename));
revised_dir = path.dirname(full_path);
revised_filename = path.basename(full_path);
doc_open(revised_dir, revised_filename);
} else {
// Give feedback to let user know the link didn't work...
post("pddplink: error: file not found: " + filename);
}
}
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