Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

Editor's right-click menu can open file's containing folder.

<< < (2/5) > >>

codeman:

--- Quote from: ollydbg on July 25, 2010, 05:16:15 am ---Nice work.
But I can't apply your patch. (I just copy the patch, and create a a.patch file, then apply the patch by tortoiseSVN, then failed)
but it seems your patch was generated from "msys git" ? Can git used to access cb repo?

--- End quote ---

I stored the 10.05 source into a local git repo, and used git to create patches. After some reading, you can apply them to your files using git-apply (you dont need a git repository). I should probably get SVN so that I can work with the latest tree and create compatible patches  :P


--- Quote from: MortenMacFly on July 25, 2010, 09:49:14 am ---That is a very nice idea, however, I wonder whether wxWidgets can do that, too (in a cross platform way). Implementing such functionality OS natively should be our last option usually. Did you have a look at wxWidgets API first / ask in a wx forum?

--- End quote ---

I did a lot of searching to see if wx has builtin support for it, and I dont think it does. Well just have to do this for Windows, Mac and Linux seperately.

oBFusCATed:
Probably this could help: http://wiki.wxwidgets.org/Launching_The_Default_Browser

But I wasn't able to make it open the directory:

--- Code: ---    wxMimeTypesManager manager;
    wxFileType * filetype = manager.GetFileTypeFromMimeType(wxT("application/x-directory"));
    if (filetype)
    {
        wxString command = filetype->GetOpenCommand(wxT("/home/obfuscated"));
        wxExecute(command);
    }

--- End code ---


codeman: you could use git svn, but the generated patches couldn't be applied in a normal tree, last time I've tried. The git svn was not recognizing the "$Revision:" and similar tags.

codeman:
Ok I just replaced the patch with one coming from tortoiseSVN from the latest tree (revision 6416). Hopefully that will work for everyone.

MortenMacFly:

--- Quote from: oBFusCATed on July 25, 2010, 11:34:01 am ---
--- Code: ---    wxMimeTypesManager manager;
    wxFileType * filetype = manager.GetFileTypeFromMimeType(wxT("application/x-directory"));
    if (filetype)
    {
        wxString command = filetype->GetOpenCommand(wxT("/home/obfuscated"));
        wxExecute(command);
    }

--- End code ---

--- End quote ---
I think this only applies to a web browser. What I meant was really the platform's file explorer.

In this thread:
http://forums.wxwidgets.org/viewtopic.php?p=9441
...I found this:
http://forums.wxwidgets.org/viewtopic.php?p=9624#9624

This looks like cross-platform and in addition you can open up in a folder you like.

Strange that there is really no wx core function available. I wonder how it's done in Qt, maybe it can be done similar in wx, too.

codeman:
Ok here is my latest version that I have tested on Ubuntu - it works very well, except that it wont leave the file selected.

MortenMacFly: were you referring to the wxExecute() command when you said it was cross-platform? We still need to use different commands for the different platforms, like I have, correct?


--- Code: ---bool EditorManager::OpenContainingFolder()
{
cbEditor* ed = GetBuiltinEditor(GetActiveEditor());
if (!ed)
return false;

const wxString& fullpath = ed->GetFilename();

#ifdef __WXMSW__

WCHAR cmd[1024]; //CreateProcessW is allowed to modify this for internal processing.
wsprintf(cmd, _("explorer /select,%s"), fullpath.c_str()); //Build the command string to open an explorer window on the folder with the file selected

STARTUPINFOW si;
memset(&si, 0, sizeof(si));
si.cb = sizeof(si);
PROCESS_INFORMATION po;
memset(&po, 0, sizeof(po));
CreateProcessW(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &po); //Launch explorer
#else
//Extract the folder name from the file
wxString cmd;
wxFileName::SplitPath(fullpath, &cmd, NULL, NULL);

//Use the xdg-open command, and get the char* string
cmd.Prepend(_("xdg-open "));
wxCharBuffer mbcmd = cmd.mb_str();
system(mbcmd);
#endif

return true;
}

--- End code ---

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version