~ubuntu-branches/debian/sid/filezilla/sid

« back to all changes in this revision

Viewing changes to src/interface/edithandler.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Adrien Cunin
  • Date: 2009-11-15 17:15:41 UTC
  • mfrom: (1.3.5 upstream) (4.1.6 sid)
  • Revision ID: james.westby@ubuntu.com-20091115171541-nvo6m3hl3iof0lnc
* New upstream release
* Updated previous changelog entry to mention desktop notifications as a new
  feature

Show diffs side-by-side

added added

removed removed

Lines of Context:
651
651
 
652
652
                // File has changed, ask user what to do
653
653
 
654
 
        wxTopLevelWindow* pTopWindow = (wxTopLevelWindow*)wxTheApp->GetTopWindow();
 
654
                wxTopLevelWindow* pTopWindow = (wxTopLevelWindow*)wxTheApp->GetTopWindow();
655
655
                if (pTopWindow && pTopWindow->IsIconized())
656
656
                {
657
657
                        pTopWindow->RequestUserAttention(wxUSER_ATTENTION_INFO);
912
912
        else if (command[0] == '1')
913
913
        {
914
914
                // Text editor
915
 
                const wxString random = _T("5AC2EE515D18406aB77C2C60F1F88952.txt"); // Chosen by fair dice roll. Guaranteed to be random.
 
915
                const wxString random = _T("5AC2EE515D18406 space aB77C2C60F1F88952.txt"); // Chosen by fair dice roll. Guaranteed to be random.
916
916
                wxString command = GetSystemOpenCommand(random, program_exists);
917
917
                if (command.empty() || !program_exists)
918
918
                        return command;
978
978
        return true;
979
979
}
980
980
 
981
 
wxString CEditHandler::GetSystemOpenCommand(const wxString& file, bool &program_exists)
 
981
wxString CEditHandler::GetSystemOpenCommand(wxString file, bool &program_exists)
982
982
{
983
983
        wxFileName fn(file);
984
984
 
986
986
        if (ext == _T(""))
987
987
                return _T("");
988
988
 
989
 
        wxFileType* pType = wxTheMimeTypesManager->GetFileTypeFromExtension(ext);
990
 
        if (!pType)
991
 
                return _T("");
992
 
 
993
 
        wxString cmd;
994
 
        if (!pType->GetOpenCommand(&cmd, wxFileType::MessageParameters(file)))
 
989
        while (true)
995
990
        {
 
991
                wxFileType* pType = wxTheMimeTypesManager->GetFileTypeFromExtension(ext);
 
992
                if (!pType)
 
993
                        return _T("");
 
994
 
 
995
                wxString cmd;
 
996
                if (!pType->GetOpenCommand(&cmd, wxFileType::MessageParameters(file)))
 
997
                {
 
998
                        delete pType;
 
999
                        return _T("");
 
1000
                }
996
1001
                delete pType;
997
 
                return _T("");
998
 
        }
999
 
        delete pType;
1000
 
 
1001
 
        if (cmd.empty())
1002
 
                return wxEmptyString;
1003
 
 
1004
 
        program_exists = false;
1005
 
 
1006
 
        wxString editor;
1007
 
        if (cmd.Left(7) == _T("WX_DDE#"))
1008
 
        {
1009
 
                // See wxWidget's wxExecute in src/msw/utilsexc.cpp
1010
 
                // WX_DDE#<command>#DDE_SERVER#DDE_TOPIC#DDE_COMMAND
1011
 
                editor = cmd.Mid(7);
1012
 
                int pos = editor.Find('#');
1013
 
                if (pos < 1)
1014
 
                        return cmd;
1015
 
                editor = editor.Left(pos);
1016
 
        }
1017
 
        else
1018
 
                editor = cmd;
1019
 
 
1020
 
        wxString args;
1021
 
        if (!UnquoteCommand(editor, args) || editor.empty())
1022
 
                return cmd;
1023
 
 
1024
 
        if (!PathExpand(editor))
1025
 
                return cmd;
1026
 
 
1027
 
        if (ProgramExists(editor))
1028
 
                program_exists = true;
1029
 
        return cmd;
 
1002
 
 
1003
                if (cmd.empty())
 
1004
                        return wxEmptyString;
 
1005
 
 
1006
                program_exists = false;
 
1007
 
 
1008
                wxString editor;
 
1009
                if (cmd.Left(7) == _T("WX_DDE#"))
 
1010
                {
 
1011
                        // See wxWidget's wxExecute in src/msw/utilsexc.cpp
 
1012
                        // WX_DDE#<command>#DDE_SERVER#DDE_TOPIC#DDE_COMMAND
 
1013
                        editor = cmd.Mid(7);
 
1014
                        int pos = editor.Find('#');
 
1015
                        if (pos < 1)
 
1016
                                return cmd;
 
1017
                        editor = editor.Left(pos);
 
1018
                }
 
1019
                else
 
1020
                        editor = cmd;
 
1021
 
 
1022
                wxString args;
 
1023
                if (!UnquoteCommand(editor, args) || editor.empty())
 
1024
                        return cmd;
 
1025
 
 
1026
                if (!PathExpand(editor))
 
1027
                        return cmd;
 
1028
 
 
1029
                if (ProgramExists(editor))
 
1030
                        program_exists = true;
 
1031
 
 
1032
#ifdef __WXGTK__
 
1033
                int pos = args.Find(file);
 
1034
                if (pos != -1 && file.Find(' ') != -1 && file[0] != '\'' && file[0] != '"')
 
1035
                {
 
1036
                        // Might need to quote filename, wxWidgets doesn't do it
 
1037
                        if ((!pos || (args[pos - 1] != '\'' && args[pos - 1] != '"')) &&
 
1038
                                args[pos + file.Length()] != '\'' && args[pos + file.Length()] != '"')
 
1039
                        {
 
1040
                                // Filename in command arguments isn't quoted. Repeat with quoted filename
 
1041
                                file = _T("\"") + file + _T("\"");
 
1042
                                continue;
 
1043
                        }
 
1044
                }
 
1045
#endif
 
1046
                return cmd;
 
1047
        }
 
1048
 
 
1049
        return wxEmptyString;
1030
1050
}
1031
1051
 
1032
1052
wxString CEditHandler::GetCustomOpenCommand(const wxString& file, bool& program_exists)
1163
1183
{
1164
1184
        for (std::list<t_fileData>::const_iterator iter = m_fileDataList[remote].begin(); iter != m_fileDataList[remote].end(); iter++)
1165
1185
        {
 
1186
#ifdef __WXMSW__
 
1187
                if (!iter->file.CmpNoCase(file))
 
1188
#else
1166
1189
                if (iter->file == file)
 
1190
#endif
1167
1191
                        return true;
1168
1192
        }
1169
1193
 
1591
1615
 
1592
1616
void CNewAssociationDialog::SetCtrlState()
1593
1617
{
1594
 
        const bool custom = XRCCTRL(*this, "ID_USE_CUSTOM", wxRadioButton)->GetValue();
 
1618
        wxRadioButton* pCustom = wxDynamicCast(FindWindow(XRCID("ID_USE_CUSTOM")), wxRadioButton);
 
1619
        if (!pCustom)
 
1620
        {
 
1621
                // Return since it can get called before dialog got fully loaded
 
1622
                return;
 
1623
        }
 
1624
 
 
1625
        const bool custom = pCustom->GetValue();
1595
1626
 
1596
1627
        XRCCTRL(*this, "ID_CUSTOM", wxTextCtrl)->Enable(custom);
1597
1628
        XRCCTRL(*this, "ID_BROWSE", wxButton)->Enable(custom);