comparison inkscape/firefox/content/inkscape.js @ 364:a373b4743e63

Add file dialog to add a new scene file into the project.
author wycc
date Sat, 14 Mar 2009 15:35:51 +0800
parents 83cae12cf428
children 6adb28388132
comparison
equal deleted inserted replaced
363:04609111485d 364:a373b4743e63
542 context : [ 542 context : [
543 { 543 {
544 id: "Open", 544 id: "Open",
545 label: "Open", 545 label: "Open",
546 icon: "open.png", 546 icon: "open.png",
547 visible: function(NODE,TREE_OBJ) { if(NODE.length != 1) return false; return NODE[0].id == "prj";}, 547 visible: function(NODE,TREE_OBJ) { if(NODE.length != 1) return false; return true;},
548 action: function(NODE,TREE_OBJ) { openFile(TREE_OBJ);} 548 action: function(NODE,TREE_OBJ) { onTree_openFile(NODE,TREE_OBJ);}
549 }, 549 },
550 { 550 {
551 id: "New", 551 id: "New",
552 label: "New", 552 label: "New",
553 icon: "create.png", 553 icon: "create.png",
565 } 565 }
566 566
567 }); 567 });
568 } 568 }
569 569
570 function fileDialog_cb()
571 {
572 var file = $('#filedialogsrc').attr('value');
573 filedialog.dialog('close');
574 filedialog_cb(file,filedialog_arg);
575 }
576
577 function openFileDialog(callback,arg)
578 {
579 filedialog_cb = callback;
580 filedialog_arg = arg;
581 filedialog.html('Please select the scene file<br>');
582 filedialog.append('<input type=file value="Select the scene file" id="filedialogsrc">');
583 filedialog.append('<input type=button value="Load" onclick="fileDialog_cb()">');
584 filedialog.show();
585 filedialog.dialog('open');
586 }
587
588
589 function project_addScene(file,treeobj)
590 {
591 if (file == '') {
592 return;
593 }
594 treeobj.create(false,treeobj.selected,file);
595 }
596
597 function onTree_addSceneFile(node,treeobj)
598 {
599 //treeobj.create(false,treeobj.selected,"xxx",null,"newscene");
600 openFileDialog(project_addScene,treeobj);
601 }
602
603
604 function onTree_openFile(node,treeobj)
605 {
606 if (node[0].id == "scenes") {
607 onTree_addSceneFile(node,treeobj);
608 } else if (node[0].id == "sources") {
609 onTree_addSourceFile(node,treeobj);
610 }
611 }
612
613
570 function system_read(fname) { 614 function system_read(fname) {
571 try { 615 try {
572 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 616 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
573 } catch (e) { 617 } catch (e) {
574 alert("Permission to read file was denied."); 618 alert("Permission to read file was denied.");
597 function project_loadFile() 641 function project_loadFile()
598 { 642 {
599 prjname = $('#mbsvg').attr('value'); 643 prjname = $('#mbsvg').attr('value');
600 var prj = system_read(prjname); 644 var prj = system_read(prjname);
601 project_parse(prj); 645 project_parse(prj);
646 filedialog.dialog('close');
602 } 647 }
603 648
604 var last_select = null; 649 var last_select = null;
605 650
606 $('#inkscape').html('Please select the project file<br>'); 651 $('#filedialog').dialog({ width:500});
607 $('#inkscape').append('<input type=file value="Select the project file" id="mbsvg" accept="image/png">'); 652 jQuery(document).ready(function() {
608 $('#inkscape').append('<input type=button value="Load" onclick="project_loadFile()">'); 653 filedialog = jQuery('#filedialog');
654 filedialog.dialog({width:500,
655 modal: true,
656 autopen:false,
657 title:'Please select a file'});
658 filedialog.show();
659 filedialog.html('Please select the project file<br>');
660 filedialog.append('<input type=file value="Select the project file" id="mbsvg" accept="image/png">');
661 filedialog.append('<input type=button value="Load" onclick="project_loadFile()">');
662 filedialog.dialog("open");
663 });
664
665