[rkward-cvs] SF.net SVN: rkward:[2491] trunk/rkward

tfry at users.sourceforge.net tfry at users.sourceforge.net
Tue May 19 15:23:12 UTC 2009


Revision: 2491
          http://rkward.svn.sourceforge.net/rkward/?rev=2491&view=rev
Author:   tfry
Date:     2009-05-19 15:23:12 +0000 (Tue, 19 May 2009)

Log Message:
-----------
Add action to cd to current script

Modified Paths:
--------------
    trunk/rkward/ChangeLog
    trunk/rkward/rkward/misc/rkstandardicons.cpp
    trunk/rkward/rkward/misc/rkstandardicons.h
    trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R
    trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp
    trunk/rkward/rkward/windows/rkcommandeditorwindow.h
    trunk/rkward/rkward/windows/rkcommandeditorwindowpart.rc

Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog	2009-05-19 14:24:21 UTC (rev 2490)
+++ trunk/rkward/ChangeLog	2009-05-19 15:23:12 UTC (rev 2491)
@@ -1,3 +1,4 @@
+- Add action to change working directory to that of the current script file
 - Fixed: No warning was shown, when an open script file was changed on disk, externally
 - Fixed: Opening most file types (e.g. PDF) from the help browser was broken		TODO: output refresh is somewhat broken, now
 - Fixed: Make built-in editor work again for file.edit ()

Modified: trunk/rkward/rkward/misc/rkstandardicons.cpp
===================================================================
--- trunk/rkward/rkward/misc/rkstandardicons.cpp	2009-05-19 14:24:21 UTC (rev 2490)
+++ trunk/rkward/rkward/misc/rkstandardicons.cpp	2009-05-19 15:23:12 UTC (rev 2491)
@@ -41,6 +41,7 @@
 	icons[ActionRunAll] = QIcon (rkward_icon_base + "run_all.png");
 	icons[ActionRunLine] = QIcon (rkward_icon_base + "run_line.png");
 	icons[ActionRunSelection] = QIcon (rkward_icon_base + "run_selection.png");
+	icons[ActionCDToScript] = KIcon ("folder-txt");
 
 	icons[ActionDeleteRow] = KIcon ("no");
 	icons[ActionInsertRow] = KIcon ("edit-add");

Modified: trunk/rkward/rkward/misc/rkstandardicons.h
===================================================================
--- trunk/rkward/rkward/misc/rkstandardicons.h	2009-05-19 14:24:21 UTC (rev 2490)
+++ trunk/rkward/rkward/misc/rkstandardicons.h	2009-05-19 15:23:12 UTC (rev 2491)
@@ -41,6 +41,7 @@
 		ActionRunAll=0,
 		ActionRunLine,
 		ActionRunSelection,
+		ActionCDToScript,
 
 		ActionDeleteRow,
 		ActionInsertRow,

Modified: trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R	2009-05-19 14:24:21 UTC (rev 2490)
+++ trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R	2009-05-19 15:23:12 UTC (rev 2491)
@@ -476,7 +476,7 @@
 
 "setwd" <- function () {
 	eval (body (base::setwd))
-	.rk.do.call ("wdChange", NULL);
+	invisible (.rk.do.call ("wdChange", NULL));
 }
 formals (setwd) <- formals (base::setwd)
 

Modified: trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp	2009-05-19 14:24:21 UTC (rev 2490)
+++ trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp	2009-05-19 15:23:12 UTC (rev 2491)
@@ -168,7 +168,14 @@
 	ac->addAction ("unmark_block", actionmenu_unmark_block);
 	connect (actionmenu_unmark_block->menu(), SIGNAL (aboutToShow()), this, SLOT (clearUnusedBlocks()));
 
-	QAction* action_configure = ac->addAction ("configure_commandeditor", this, SLOT (configure()));
+	action_setwd_to_script = ac->addAction ("setwd_to_script", this, SLOT (setWDToScript ()));
+	action_setwd_to_script->setText (i18n ("CD to this script"));
+#if KDE_IS_VERSION(4,3,0)
+	action_setwd_to_script->setHelpText (i18n ("Change the working directory to the directory of this script"));
+#endif
+	action_setwd_to_script->setIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionCDToScript));
+
+	KAction* action_configure = ac->addAction ("configure_commandeditor", this, SLOT (configure()));
 	action_configure->setText (i18n ("Configure Script Editor"));
 }
 
@@ -311,8 +318,7 @@
 }
 
 KUrl RKCommandEditorWindow::url () {
-	RK_TRACE (COMMANDEDITOR);
-
+//	RK_TRACE (COMMANDEDITOR);
 	return (m_doc->url ());
 }
 
@@ -335,12 +341,15 @@
 
 void RKCommandEditorWindow::updateCaption (KTextEditor::Document*) {
 	RK_TRACE (COMMANDEDITOR);
-	QString name = m_doc->url ().fileName ();
-	if (name.isEmpty ()) name = m_doc->url ().prettyUrl ();
+	QString name = url ().fileName ();
+	if (name.isEmpty ()) name = url ().prettyUrl ();
 	if (name.isEmpty ()) name = i18n ("Unnamed");
 	if (isModified ()) name.append (i18n (" [modified]"));
 
 	setCaption (name);
+
+	// Well, this does not really belong, here, but needs to happen on pretty much the same occastions:
+	action_setwd_to_script->setEnabled (!url ().isEmpty ());
 }
 
 void RKCommandEditorWindow::showHelp () {
@@ -426,6 +435,13 @@
 	return true;
 }
 
+void RKCommandEditorWindow::setWDToScript () {
+	RK_TRACE (COMMANDEDITOR);
+
+	RK_ASSERT (!url ().isEmpty ());
+	RKConsole::pipeUserCommand (new RCommand ("setwd (\"" + url ().directory () + "\")", RCommand::User, i18n ("cd to current script directory")));
+}
+
 void RKCommandEditorWindow::runSelection() {
 	RK_TRACE (COMMANDEDITOR);
 

Modified: trunk/rkward/rkward/windows/rkcommandeditorwindow.h
===================================================================
--- trunk/rkward/rkward/windows/rkcommandeditorwindow.h	2009-05-19 14:24:21 UTC (rev 2490)
+++ trunk/rkward/rkward/windows/rkcommandeditorwindow.h	2009-05-19 15:23:12 UTC (rev 2491)
@@ -180,6 +180,8 @@
 
 /** selection has changed. Enable / disable actions accordingly */
 	void selectionChanged (KTextEditor::View* view);
+/** change to the directory of the current script */
+	void setWDToScript ();
 protected:
 /** reimplemented from RKMDIWindow: give the editor window a chance to object to being closed (if unsaved) */
 	void closeEvent (QCloseEvent *e);
@@ -226,6 +228,8 @@
 	KAction* action_run_selection;
 	KAction* action_run_line;
 
+	KAction* action_setwd_to_script;
+
 	KAction* action_help_function;
 };
 

Modified: trunk/rkward/rkward/windows/rkcommandeditorwindowpart.rc
===================================================================
--- trunk/rkward/rkward/windows/rkcommandeditorwindowpart.rc	2009-05-19 14:24:21 UTC (rev 2490)
+++ trunk/rkward/rkward/windows/rkcommandeditorwindowpart.rc	2009-05-19 15:23:12 UTC (rev 2491)
@@ -1,5 +1,5 @@
 <!DOCTYPE kpartgui>
-<kpartgui name="rkward" version="0.5.0">
+<kpartgui name="rkward" version="0.5.1">
 	<MenuBar>
 		<Menu name="edit" noMerge="1"><text>&Edit</text>
 			<Menu name="tools"><text>&Tools Move</text>
@@ -17,6 +17,7 @@
 			<Separator/>
 			<Action name="run_block"/>
 			<Separator/>
+			<Action name="setwd_to_script"/>
 		</Menu>
 		<Menu name="settings"><text>&Settings</text>
 			<Action name="configure_commandeditor"></Action>
@@ -31,6 +32,8 @@
 		<Action name="run_all"/>
 		<Separator/>
 		<Action name="run_block"/>
+		<Separator/>
+		<Action name="setwd_to_script"/>
 	</ToolBar>
 	<Menu name="ktexteditor_popup">
 		<Merge/>
@@ -43,6 +46,8 @@
 			<Action name="run_all"/>
 			<Separator/>
 			<Action name="run_block"/>
+			<Separator/>
+			<Action name="setwd_to_script"/>
 		</Menu>
 		<Action name="function_reference"/>
 		<Separator/>


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the rkward-tracker mailing list