1 // 2 // Copyright (C) 2001-2013 Graeme Walker <graeme_walker@users.sourceforge.net> 3 // 4 // This program is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // This program is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with this program. If not, see <http://www.gnu.org/licenses/>. 16 // === 17 /// 18 /// \file glink.h 19 /// 20 21 #ifndef G_LINK_H__ 22 #define G_LINK_H__ 23 24 #include "gdef.h" 25 #include "gpath.h" 26 #include "gexception.h" 27 #include "gstrings.h" 28 #include <string> 29 30 class GLinkImp ; 31 32 /// \class GLink 33 /// A class for creating desktop links (aka "shortcuts") and 34 /// application menu items. 35 /// 36 class GLink 37 { 38 public: 39 G_EXCEPTION( SaveError , "error saving desktop or menu link" ) ; 40 41 enum Show { Show_Default , Show_Hide } ; 42 43 GLink( const G::Path & target_path , const std::string & name , const std::string & description , 44 const G::Path & working_dir , const G::Strings & args = G::Strings() , 45 const G::Path & icon_source = G::Path() , Show show = Show_Default , 46 const std::string & internal_comment_1 = std::string() , 47 const std::string & internal_comment_2 = std::string() , 48 const std::string & internal_comment_3 = std::string() ) ; 49 ///< Constructor. Note that the path of the link itself 50 ///< is specified in saveAs(), not the constructor. 51 ///< The "working_dir" is the current-working-directory 52 ///< when the link is used. 53 54 static std::string filename( const std::string & name ) ; 55 ///< Returns a normalised filename including an extension like ".lnk" or ".desktop". 56 57 void saveAs( const G::Path & link_path ) ; 58 ///< Saves the link. 59 60 ~GLink() ; 61 ///< Destructor. 62 63 static bool remove( const G::Path & ) ; 64 ///< Removes a link. 65 66 private: 67 GLink( const GLink & ) ; 68 void operator=( const GLink & ) ; 69 70 private: 71 GLinkImp * m_imp ; 72 } ; 73 74 #endif 75