Re: [gedit-list] How determine file path of currently open document




On Tue, Jan 20, 2015 at 5:18 PM, Peter Bittner <peter bittner gmx net
<mailto:peter bittner gmx net>> wrote:

    I'm working on a Gedit plugin that needs to determine the file path of
    the currently open document (if the content of the document is already
    saved as a file). In addition (for unsaved documents) I need to figure
    out Gedit's "working directory" (the one displayed with the `Save
    As...` dialog).

    Is there any API documentation that helps me with that? It seems
    surprisingly hard to find anything about this using a Web search. --
    Alternatively, where can I find Gedit's source code?

The following 4 lines are a gedit tool that might be helpful.

#!/bin/bash
echo "# asking for GEDIT environment variables"
env | grep GEDIT
echo "# end of environment list"

On my machine it puts the following into "untitled document" when I call it.

# asking for GEDIT environment variables
GEDIT_CURRENT_DOCUMENT_TYPE=text/plain
GEDIT_DOCUMENTS_PATH=/home/doug/ScratchPad /home/doug/Finance/Finance.txt /home/doug/Finance/FromJupiter /home/doug/.^/chats
GEDIT_CURRENT_LINE=
GEDIT_CURRENT_DOCUMENT_SCHEME=file
GEDIT_CURRENT_DOCUMENT_NAME=FromJupiter
GEDIT_CURRENT_WORD=
GEDIT_CURRENT_DOCUMENT_DIR=/home/doug/Finance
GEDIT_CURRENT_LINE_NUMBER=29
GEDIT_FILE_BROWSER_ROOT=/home/doug
GEDIT_CURRENT_DOCUMENT_PATH=/home/doug/Finance/FromJupiter
GEDIT_CWD=/home/doug
GEDIT_CURRENT_DOCUMENT_URI=file:///home/doug/Finance/FromJupiter
GEDIT_DOCUMENTS_URI=file:///home/doug/ScratchPad file:///home/doug/Finance/Finance.txt file:///home/doug/Finance/FromJupiter file:///home/doug/.%5E/chats
# end of environment list


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]