gio-0.13.1.0/0000755000000000000000000000000012507510337010701 5ustar0000000000000000gio-0.13.1.0/COPYING0000644000000000000000000006351012507510337011741 0ustar0000000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! gio-0.13.1.0/gio.cabal0000644000000000000000000000577512507510337012461 0ustar0000000000000000Name: gio Version: 0.13.1.0 License: LGPL-2.1 License-file: COPYING Copyright: (c) 2001-2010 The Gtk2Hs Team Author: Peter Gavin, Andy Stewart Maintainer: gtk2hs-users@lists.sourceforge.net Build-Type: Custom Cabal-Version: >= 1.18 Stability: stable homepage: http://projects.haskell.org/gtk2hs/ bug-reports: https://github.com/gtk2hs/gtk2hs/issues Synopsis: Binding to the GIO. Description: GIO is striving to provide a modern, easy-to-use VFS API that sits at the right level in the library stack. The goal is to overcome the shortcomings of GnomeVFS and provide an API that is so good that developers prefer it over raw POSIX calls. Among other things that means using GObject. It also means not cloning the POSIX API, but providing higher-level, document-centric interfaces. Category: System Tested-With: GHC == 7.0.4, GHC == 7.2.2, GHC == 7.4.1 Extra-Source-Files: SetupWrapper.hs SetupMain.hs Gtk2HsSetup.hs marshal.list hierarchy.list x-Types-File: System/GIO/Types.chs x-Types-ModName: System.GIO.Types x-Types-Import: System.Glib.GObject x-Types-Lib: gio x-Types-Prefix: g x-Types-Tag: gio x-Types-Hierarchy: hierarchy.list Data-Dir: demo Data-Files: Makefile FileManager.hs Source-Repository head type: git location: https://github.com/gtk2hs/gtk2hs subdir: gio Library build-depends: base >= 4 && < 5, array, containers, mtl, bytestring, glib >= 0.13.0.0 && < 0.14 build-tools: gtk2hsC2hs >= 0.13.12, gtk2hsHookGenerator, gtk2hsTypeGen exposed-modules: System.GIO System.GIO.Enums System.GIO.Types System.GIO.Async.AsyncResult System.GIO.Async.Cancellable System.GIO.File.AppInfo System.GIO.File.ContentType System.GIO.File.FileAttribute System.GIO.File.File System.GIO.File.FileEnumerator System.GIO.File.FileInfo System.GIO.File.FileMonitor System.GIO.File.IOError System.GIO.File.MountOperation System.GIO.Icons.Emblem System.GIO.Icons.EmblemedIcon System.GIO.Icons.FileIcon System.GIO.Icons.Icon System.GIO.Icons.ThemedIcon System.GIO.Volumes.Drive System.GIO.Volumes.Mount System.GIO.Volumes.Volume System.GIO.Volumes.VolumeMonitor other-modules: System.GIO.Signals default-language: Haskell98 default-extensions: ForeignFunctionInterface cpp-options: -U__BLOCKS__ -Ubool -D__attribute__(A)= x-Signals-File: System/GIO/Signals.chs x-Signals-Modname: System.GIO.Signals x-Signals-Types: marshal.list x-c2hs-Header: gio/gio.h pkgconfig-depends: gio-2.0 >= 2.16.4 gio-0.13.1.0/Gtk2HsSetup.hs0000644000000000000000000005421612507510337013370 0ustar0000000000000000{-# LANGUAGE CPP, ViewPatterns #-} #ifndef CABAL_VERSION_CHECK #error This module has to be compiled via the Setup.hs program which generates the gtk2hs-macros.h file #endif -- | Build a Gtk2hs package. -- module Gtk2HsSetup ( gtk2hsUserHooks, getPkgConfigPackages, checkGtk2hsBuildtools, typeGenProgram, signalGenProgram, c2hsLocal ) where import Distribution.Simple import Distribution.Simple.PreProcess import Distribution.InstalledPackageInfo ( importDirs, showInstalledPackageInfo, libraryDirs, extraLibraries, extraGHCiLibraries ) import Distribution.Simple.PackageIndex ( lookupInstalledPackageId ) import Distribution.PackageDescription as PD ( PackageDescription(..), updatePackageDescription, BuildInfo(..), emptyBuildInfo, allBuildInfo, Library(..), libModules, hasLibs) import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(withPackageDB, buildDir, localPkgDescr, installedPkgs, withPrograms), InstallDirs(..), componentPackageDeps, absoluteInstallDirs) import Distribution.Simple.Compiler ( Compiler(..) ) import Distribution.Simple.Program ( Program(..), ConfiguredProgram(..), rawSystemProgramConf, rawSystemProgramStdoutConf, programName, programPath, c2hsProgram, pkgConfigProgram, gccProgram, requireProgram, ghcPkgProgram, simpleProgram, lookupProgram, rawSystemProgramStdout, ProgArg) import Distribution.ModuleName ( ModuleName, components, toFilePath ) import Distribution.Simple.Utils import Distribution.Simple.Setup (CopyFlags(..), InstallFlags(..), CopyDest(..), defaultCopyFlags, ConfigFlags(configVerbosity), fromFlag, toFlag, RegisterFlags(..), flagToMaybe, fromFlagOrDefault, defaultRegisterFlags) import Distribution.Simple.BuildPaths ( autogenModulesDir ) import Distribution.Simple.Install ( install ) import Distribution.Simple.Register ( generateRegistrationInfo, registerPackage ) import Distribution.Text ( simpleParse, display ) import System.FilePath import System.Exit (exitFailure) import System.Directory ( doesFileExist, getDirectoryContents, doesDirectoryExist ) import Distribution.Version (Version(..)) import Distribution.Verbosity import Control.Monad (when, unless, filterM, liftM, forM, forM_) import Data.Maybe ( isJust, isNothing, fromMaybe, maybeToList, catMaybes ) import Data.List (isPrefixOf, isSuffixOf, nub, minimumBy, stripPrefix, tails ) import Data.Ord as Ord (comparing) import Data.Char (isAlpha, isNumber) import qualified Data.Map as M import qualified Data.Set as S import qualified Distribution.Simple.LocalBuildInfo as LBI import Distribution.Simple.Compiler (compilerVersion) import Control.Applicative ((<$>)) #if CABAL_VERSION_CHECK(1,17,0) import Distribution.Simple.Program.Find ( defaultProgramSearchPath ) onDefaultSearchPath f a b = f a b defaultProgramSearchPath libraryConfig lbi = case [clbi | (LBI.CLibName, clbi, _) <- LBI.componentsConfigs lbi] of [clbi] -> Just clbi _ -> Nothing #else onDefaultSearchPath = id libraryConfig = LBI.libraryConfig #endif -- the name of the c2hs pre-compiled header file precompFile = "precompchs.bin" gtk2hsUserHooks = simpleUserHooks { hookedPrograms = [typeGenProgram, signalGenProgram, c2hsLocal], hookedPreProcessors = [("chs", ourC2hs)], confHook = \pd cf -> (fmap adjustLocalBuildInfo (confHook simpleUserHooks pd cf)), postConf = \args cf pd lbi -> do genSynthezisedFiles (fromFlag (configVerbosity cf)) pd lbi postConf simpleUserHooks args cf pd lbi, buildHook = \pd lbi uh bf -> fixDeps pd >>= \pd -> buildHook simpleUserHooks pd lbi uh bf, copyHook = \pd lbi uh flags -> copyHook simpleUserHooks pd lbi uh flags >> installCHI pd lbi (fromFlag (copyVerbosity flags)) (fromFlag (copyDest flags)), instHook = \pd lbi uh flags -> #if defined(mingw32_HOST_OS) || defined(__MINGW32__) installHook pd lbi uh flags >> installCHI pd lbi (fromFlag (installVerbosity flags)) NoCopyDest, regHook = registerHook #else instHook simpleUserHooks pd lbi uh flags >> installCHI pd lbi (fromFlag (installVerbosity flags)) NoCopyDest #endif } ------------------------------------------------------------------------------ -- Lots of stuff for windows ghci support ------------------------------------------------------------------------------ getDlls :: [FilePath] -> IO [FilePath] getDlls dirs = filter ((== ".dll") . takeExtension) . concat <$> mapM getDirectoryContents dirs fixLibs :: [FilePath] -> [String] -> [String] fixLibs dlls = concatMap $ \ lib -> case filter (isLib lib) dlls of dlls@(_:_) -> [dropExtension (pickDll dlls)] _ -> if lib == "z" then [] else [lib] where -- If there are several .dll files matching the one we're after then we -- just have to guess. For example for recent Windows cairo builds we get -- libcairo-2.dll libcairo-gobject-2.dll libcairo-script-interpreter-2.dll -- Our heuristic is to pick the one with the shortest name. -- Yes this is a hack but the proper solution is hard: we would need to -- parse the .a file and see which .dll file(s) it needed to link to. pickDll = minimumBy (Ord.comparing length) isLib lib dll = case stripPrefix ("lib"++lib) dll of Just ('.':_) -> True Just ('-':n:_) | isNumber n -> True _ -> False -- The following code is a big copy-and-paste job from the sources of -- Cabal 1.8 just to be able to fix a field in the package file. Yuck. installHook :: PackageDescription -> LocalBuildInfo -> UserHooks -> InstallFlags -> IO () installHook pkg_descr localbuildinfo _ flags = do let copyFlags = defaultCopyFlags { copyDistPref = installDistPref flags, copyDest = toFlag NoCopyDest, copyVerbosity = installVerbosity flags } install pkg_descr localbuildinfo copyFlags let registerFlags = defaultRegisterFlags { regDistPref = installDistPref flags, regInPlace = installInPlace flags, regPackageDB = installPackageDB flags, regVerbosity = installVerbosity flags } when (hasLibs pkg_descr) $ register pkg_descr localbuildinfo registerFlags registerHook :: PackageDescription -> LocalBuildInfo -> UserHooks -> RegisterFlags -> IO () registerHook pkg_descr localbuildinfo _ flags = if hasLibs pkg_descr then register pkg_descr localbuildinfo flags else setupMessage verbosity "Package contains no library to register:" (packageId pkg_descr) where verbosity = fromFlag (regVerbosity flags) register :: PackageDescription -> LocalBuildInfo -> RegisterFlags -- ^Install in the user's database?; verbose -> IO () register pkg@PackageDescription { library = Just lib } lbi regFlags = do let clbi = LBI.getComponentLocalBuildInfo lbi LBI.CLibName installedPkgInfoRaw <- generateRegistrationInfo #if CABAL_VERSION_CHECK(1,22,0) verbosity pkg lib lbi clbi inplace False distPref packageDb #else verbosity pkg lib lbi clbi inplace distPref #endif dllsInScope <- getSearchPath >>= (filterM doesDirectoryExist) >>= getDlls let libs = fixLibs dllsInScope (extraLibraries installedPkgInfoRaw) installedPkgInfo = installedPkgInfoRaw { extraGHCiLibraries = libs } -- Three different modes: case () of _ | modeGenerateRegFile -> writeRegistrationFile installedPkgInfo | modeGenerateRegScript -> die "Generate Reg Script not supported" | otherwise -> registerPackage verbosity installedPkgInfo pkg lbi inplace #if CABAL_VERSION_CHECK(1,10,0) packageDbs #else packageDb #endif where modeGenerateRegFile = isJust (flagToMaybe (regGenPkgConf regFlags)) regFile = fromMaybe (display (packageId pkg) <.> "conf") (fromFlag (regGenPkgConf regFlags)) modeGenerateRegScript = fromFlag (regGenScript regFlags) inplace = fromFlag (regInPlace regFlags) packageDbs = nub $ withPackageDB lbi ++ maybeToList (flagToMaybe (regPackageDB regFlags)) packageDb = registrationPackageDB packageDbs distPref = fromFlag (regDistPref regFlags) verbosity = fromFlag (regVerbosity regFlags) writeRegistrationFile installedPkgInfo = do notice verbosity ("Creating package registration file: " ++ regFile) writeUTF8File regFile (showInstalledPackageInfo installedPkgInfo) register _ _ regFlags = notice verbosity "No package to register" where verbosity = fromFlag (regVerbosity regFlags) ------------------------------------------------------------------------------ -- This is a hack for Cabal-1.8, It is not needed in Cabal-1.9.1 or later ------------------------------------------------------------------------------ adjustLocalBuildInfo :: LocalBuildInfo -> LocalBuildInfo adjustLocalBuildInfo lbi = let extra = (Just libBi, []) libBi = emptyBuildInfo { includeDirs = [ autogenModulesDir lbi , buildDir lbi ] } in lbi { localPkgDescr = updatePackageDescription extra (localPkgDescr lbi) } ------------------------------------------------------------------------------ -- Processing .chs files with our local c2hs. ------------------------------------------------------------------------------ ourC2hs :: BuildInfo -> LocalBuildInfo -> PreProcessor ourC2hs bi lbi = PreProcessor { platformIndependent = False, runPreProcessor = runC2HS bi lbi } runC2HS :: BuildInfo -> LocalBuildInfo -> (FilePath, FilePath) -> (FilePath, FilePath) -> Verbosity -> IO () runC2HS bi lbi (inDir, inFile) (outDir, outFile) verbosity = do -- have the header file name if we don't have the precompiled header yet header <- case lookup "x-c2hs-header" (customFieldsBI bi) of Just h -> return h Nothing -> die ("Need x-c2hs-Header definition in the .cabal Library section "++ "that sets the C header file to process .chs.pp files.") -- c2hs will output files in out dir, removing any leading path of the input file. -- Thus, append the dir of the input file to the output dir. let (outFileDir, newOutFile) = splitFileName outFile let newOutDir = outDir outFileDir -- additional .chi files might be needed that other packages have installed; -- we assume that these are installed in the same place as .hi files let chiDirs = [ dir | ipi <- maybe [] (map fst . componentPackageDeps) (libraryConfig lbi), dir <- maybe [] importDirs (lookupInstalledPackageId (installedPkgs lbi) ipi) ] (gccProg, _) <- requireProgram verbosity gccProgram (withPrograms lbi) rawSystemProgramConf verbosity c2hsLocal (withPrograms lbi) $ map ("--include=" ++) (outDir:chiDirs) ++ [ "--cpp=" ++ programPath gccProg, "--cppopts=-E" ] ++ ["--cppopts=" ++ opt | opt <- getCppOptions bi lbi] ++ ["--output-dir=" ++ newOutDir, "--output=" ++ newOutFile, "--precomp=" ++ buildDir lbi precompFile, header, inDir inFile] getCppOptions :: BuildInfo -> LocalBuildInfo -> [String] getCppOptions bi lbi = nub $ ["-I" ++ dir | dir <- PD.includeDirs bi] ++ [opt | opt@('-':c:_) <- PD.cppOptions bi ++ PD.ccOptions bi, c `elem` "DIU"] ++ ["-D__GLASGOW_HASKELL__="++show (ghcDefine . ghcVersion . compilerId $ LBI.compiler lbi)] where ghcDefine (v1:v2:_) = v1 * 100 + v2 ghcDefine _ = __GLASGOW_HASKELL__ ghcVersion :: CompilerId -> [Int] -- This version is nicer, but we need to know the Cabal version that includes the new CompilerId -- #if CABAL_VERSION_CHECK(1,19,2) -- ghcVersion (CompilerId GHC v _) = versionBranch v -- ghcVersion (CompilerId _ _ (Just c)) = ghcVersion c -- #else -- ghcVersion (CompilerId GHC v) = versionBranch v -- #endif -- ghcVersion _ = [] -- This version should work fine for now ghcVersion = concat . take 1 . map (read . (++"]") . takeWhile (/=']')) . catMaybes . map (stripPrefix "CompilerId GHC (Version {versionBranch = ") . tails . show installCHI :: PackageDescription -- ^information from the .cabal file -> LocalBuildInfo -- ^information from the configure step -> Verbosity -> CopyDest -- ^flags sent to copy or install -> IO () installCHI pkg@PD.PackageDescription { library = Just lib } lbi verbosity copydest = do let InstallDirs { libdir = libPref } = absoluteInstallDirs pkg lbi copydest -- cannot use the recommended 'findModuleFiles' since it fails if there exists -- a modules that does not have a .chi file mFiles <- mapM (findFileWithExtension' ["chi"] [buildDir lbi] . toFilePath) (PD.libModules lib) let files = [ f | Just f <- mFiles ] installOrdinaryFiles verbosity libPref files installCHI _ _ _ _ = return () ------------------------------------------------------------------------------ -- Generating the type hierarchy and signal callback .hs files. ------------------------------------------------------------------------------ typeGenProgram :: Program typeGenProgram = simpleProgram "gtk2hsTypeGen" signalGenProgram :: Program signalGenProgram = simpleProgram "gtk2hsHookGenerator" c2hsLocal :: Program c2hsLocal = (simpleProgram "gtk2hsC2hs") { programFindVersion = findProgramVersion "--version" $ \str -> -- Invoking "gtk2hsC2hs --version" gives a string like: -- C->Haskell Compiler, version 0.13.4 (gtk2hs branch) "Bin IO", 13 Nov 2004 case words str of (_:_:_:ver:_) -> ver _ -> "" } genSynthezisedFiles :: Verbosity -> PackageDescription -> LocalBuildInfo -> IO () genSynthezisedFiles verb pd lbi = do cPkgs <- getPkgConfigPackages verb lbi pd let xList = maybe [] (customFieldsBI . libBuildInfo) (library pd) ++customFieldsPD pd typeOpts :: String -> [ProgArg] typeOpts tag = concat [ map (\val -> '-':'-':drop (length tag) field ++ '=':val) (words content) | (field,content) <- xList, tag `isPrefixOf` field, field /= (tag++"file")] ++ [ "--tag=" ++ tag | PackageIdentifier name (Version (major:minor:_) _) <- cPkgs , let name' = filter isAlpha (display name) , tag <- name' :[ name' ++ "-" ++ show maj ++ "." ++ show d2 | (maj, d2) <- [(maj, d2) | maj <- [0..(major-1)], d2 <- [0,2..20]] ++ [(major, d2) | d2 <- [0,2..minor]] ] ] signalsOpts :: [ProgArg] signalsOpts = concat [ map (\val -> '-':'-':drop 10 field++'=':val) (words content) | (field,content) <- xList, "x-signals-" `isPrefixOf` field, field /= "x-signals-file"] genFile :: Program -> [ProgArg] -> FilePath -> IO () genFile prog args outFile = do res <- rawSystemProgramStdoutConf verb prog (withPrograms lbi) args rewriteFile outFile res forM_ (filter (\(tag,_) -> "x-types-" `isPrefixOf` tag && "file" `isSuffixOf` tag) xList) $ \(fileTag, f) -> do let tag = reverse (drop 4 (reverse fileTag)) info verb ("Ensuring that class hierarchy in "++f++" is up-to-date.") genFile typeGenProgram (typeOpts tag) f case lookup "x-signals-file" xList of Nothing -> return () Just f -> do info verb ("Ensuring that callback hooks in "++f++" are up-to-date.") genFile signalGenProgram signalsOpts f writeFile "gtk2hs_macros.h" $ generateMacros cPkgs -- Based on Cabal/Distribution/Simple/Build/Macros.hs generateMacros :: [PackageId] -> String generateMacros cPkgs = concat $ "/* DO NOT EDIT: This file is automatically generated by Gtk2HsSetup.hs */\n\n" : [ concat ["/* package ",display pkgid," */\n" ,"#define VERSION_",pkgname," ",show (display version),"\n" ,"#define MIN_VERSION_",pkgname,"(major1,major2,minor) (\\\n" ," (major1) < ",major1," || \\\n" ," (major1) == ",major1," && (major2) < ",major2," || \\\n" ," (major1) == ",major1," && (major2) == ",major2," && (minor) <= ",minor,")" ,"\n\n" ] | pkgid@(PackageIdentifier name version) <- cPkgs , let (major1:major2:minor:_) = map show (versionBranch version ++ repeat 0) pkgname = map fixchar (display name) ] where fixchar '-' = '_' fixchar '.' = '_' fixchar c = c --FIXME: Cabal should tell us the selected pkg-config package versions in the -- LocalBuildInfo or equivalent. -- In the mean time, ask pkg-config again. getPkgConfigPackages :: Verbosity -> LocalBuildInfo -> PackageDescription -> IO [PackageId] getPkgConfigPackages verbosity lbi pkg = sequence [ do version <- pkgconfig ["--modversion", display pkgname] case simpleParse version of Nothing -> die "parsing output of pkg-config --modversion failed" Just v -> return (PackageIdentifier pkgname v) | Dependency pkgname _ <- concatMap pkgconfigDepends (allBuildInfo pkg) ] where pkgconfig = rawSystemProgramStdoutConf verbosity pkgConfigProgram (withPrograms lbi) ------------------------------------------------------------------------------ -- Dependency calculation amongst .chs files. ------------------------------------------------------------------------------ -- Given all files of the package, find those that end in .chs and extract the -- .chs files they depend upon. Then return the PackageDescription with these -- files rearranged so that they are built in a sequence that files that are -- needed by other files are built first. fixDeps :: PackageDescription -> IO PackageDescription fixDeps pd@PD.PackageDescription { PD.library = Just lib@PD.Library { PD.exposedModules = expMods, PD.libBuildInfo = bi@PD.BuildInfo { PD.hsSourceDirs = srcDirs, PD.otherModules = othMods }}} = do let findModule m = findFileWithExtension [".chs.pp",".chs"] srcDirs (joinPath (components m)) mExpFiles <- mapM findModule expMods mOthFiles <- mapM findModule othMods -- tag all exposed files with True so we throw an error if we need to build -- an exposed module before an internal modules (we cannot express this) let modDeps = zipWith (ModDep True []) expMods mExpFiles++ zipWith (ModDep False []) othMods mOthFiles modDeps <- mapM extractDeps modDeps let (othMods, expMods) = span (not . mdExposed) $ reverse $ sortTopological modDeps return pd { PD.library = Just lib { PD.exposedModules = map mdOriginal (reverse expMods), PD.libBuildInfo = bi { PD.otherModules = map mdOriginal (reverse othMods) } }} data ModDep = ModDep { mdExposed :: Bool, mdRequires :: [ModuleName], mdOriginal :: ModuleName, mdLocation :: Maybe FilePath } instance Show ModDep where show x = show (mdLocation x) instance Eq ModDep where ModDep { mdOriginal = m1 } == ModDep { mdOriginal = m2 } = m1==m2 instance Ord ModDep where compare ModDep { mdOriginal = m1 } ModDep { mdOriginal = m2 } = compare m1 m2 -- Extract the dependencies of this file. This is intentionally rather naive as it -- ignores CPP conditionals. We just require everything which means that the -- existance of a .chs module may not depend on some CPP condition. extractDeps :: ModDep -> IO ModDep extractDeps md@ModDep { mdLocation = Nothing } = return md extractDeps md@ModDep { mdLocation = Just f } = withUTF8FileContents f $ \con -> do let findImports acc (('{':'#':xs):xxs) = case (dropWhile (' ' ==) xs) of ('i':'m':'p':'o':'r':'t':' ':ys) -> case simpleParse (takeWhile ('#' /=) ys) of Just m -> findImports (m:acc) xxs Nothing -> die ("cannot parse chs import in "++f++":\n"++ "offending line is {#"++xs) -- no more imports after the first non-import hook _ -> return acc findImports acc (_:xxs) = findImports acc xxs findImports acc [] = return acc mods <- findImports [] (lines con) return md { mdRequires = mods } -- Find a total order of the set of modules that are partially sorted by their -- dependencies on each other. The function returns the sorted list of modules -- together with a list of modules that are required but not supplied by this -- in the input set of modules. sortTopological :: [ModDep] -> [ModDep] sortTopological ms = reverse $ fst $ foldl visit ([], S.empty) (map mdOriginal ms) where set = M.fromList (map (\m -> (mdOriginal m, m)) ms) visit (out,visited) m | m `S.member` visited = (out,visited) | otherwise = case m `M.lookup` set of Nothing -> (out, m `S.insert` visited) Just md -> (md:out', visited') where (out',visited') = foldl visit (out, m `S.insert` visited) (mdRequires md) -- Check user whether install gtk2hs-buildtools correctly. checkGtk2hsBuildtools :: [Program] -> IO () checkGtk2hsBuildtools programs = do programInfos <- mapM (\ prog -> do location <- onDefaultSearchPath programFindLocation prog normal return (programName prog, location) ) programs let printError name = do putStrLn $ "Cannot find " ++ name ++ "\n" ++ "Please install `gtk2hs-buildtools` first and check that the install directory is in your PATH (e.g. HOME/.cabal/bin)." exitFailure forM_ programInfos $ \ (name, location) -> when (isNothing location) (printError name) gio-0.13.1.0/hierarchy.list0000644000000000000000000004024312507510337013557 0ustar0000000000000000# This list is the result of a copy-and-paste from the GtkObject hierarchy # html documentation. Deprecated widgets are uncommented. Some additional # object have been defined at the end of the copied list. # The Gtk prefix of every object is removed, the other prefixes are # kept. The indentation implies the object hierarchy. In case the # type query function cannot be derived from the name or the type name # is different, an alternative name and type query function can be # specified by appending 'as typename, '. In case this # function is not specified, the is converted to # gtk__get_type where is where each upperscore # letter is converted to an underscore and lowerletter. The underscore # is omitted if an upperscore letter preceeded: GtkHButtonBox -> # gtk_hbutton_box_get_type. The generation of a type can be # conditional by appending 'if '. Such types are only produces if # --tag= is given on the command line of TypeGenerator. GObject GdkDrawable GdkWindow as DrawWindow, gdk_window_object_get_type # GdkDrawableImplX11 # GdkWindowImplX11 GdkPixmap GdkGLPixmap if gtkglext GdkGLWindow if gtkglext GdkColormap GdkScreen if gtk-2.2 GdkDisplay if gtk-2.2 GdkVisual GdkDevice GtkSettings GtkTextBuffer GtkSourceBuffer if sourceview GtkSourceBuffer if gtksourceview2 GtkTextTag GtkSourceTag if sourceview GtkTextTagTable GtkSourceTagTable if sourceview GtkStyle GtkRcStyle GdkDragContext GdkPixbuf GdkPixbufAnimation GdkPixbufSimpleAnim GdkPixbufAnimationIter GtkTextChildAnchor GtkTextMark GtkSourceMarker if sourceview GtkSourceMark if gtksourceview2 GtkObject GtkWidget GtkMisc GtkLabel GtkAccelLabel GtkTipsQuery if deprecated GtkArrow GtkImage GtkContainer WebKitWebView as WebView, webkit_web_view_get_type if webkit GtkBin GtkAlignment GtkFrame GtkAspectFrame GtkButton GtkToggleButton GtkCheckButton GtkRadioButton GtkColorButton if gtk-2.4 GtkFontButton if gtk-2.4 GtkOptionMenu if deprecated GtkItem GtkMenuItem GtkCheckMenuItem GtkRadioMenuItem GtkTearoffMenuItem GtkImageMenuItem GtkSeparatorMenuItem GtkListItem if deprecated # GtkTreeItem GtkWindow GtkDialog GtkAboutDialog if gtk-2.6 GtkColorSelectionDialog GtkFileSelection GtkFileChooserDialog if gtk-2.4 GtkFontSelectionDialog GtkInputDialog GtkMessageDialog GtkPlug if plugNsocket GtkEventBox GtkHandleBox GtkScrolledWindow GtkViewport GtkExpander if gtk-2.4 GtkComboBox if gtk-2.4 GtkComboBoxEntry if gtk-2.4 GtkToolItem if gtk-2.4 GtkToolButton if gtk-2.4 GtkMenuToolButton if gtk-2.6 GtkToggleToolButton if gtk-2.4 GtkRadioToolButton if gtk-2.4 GtkSeparatorToolItem if gtk-2.4 GtkMozEmbed if mozembed VteTerminal as Terminal if vte GtkBox GtkButtonBox GtkHButtonBox GtkVButtonBox GtkVBox GtkColorSelection GtkFontSelection GtkFileChooserWidget if gtk-2.4 GtkHBox GtkCombo if deprecated GtkFileChooserButton if gtk-2.6 GtkStatusbar GtkCList if deprecated GtkCTree if deprecated GtkFixed GtkPaned GtkHPaned GtkVPaned GtkIconView if gtk-2.6 GtkLayout GtkList if deprecated GtkMenuShell GtkMenu GtkMenuBar GtkNotebook # GtkPacker GtkSocket if plugNsocket GtkTable GtkTextView GtkSourceView if sourceview GtkSourceView if gtksourceview2 GtkToolbar GtkTreeView GtkCalendar GtkCellView if gtk-2.6 GtkDrawingArea GtkEntry GtkSpinButton GtkRuler GtkHRuler GtkVRuler GtkRange GtkScale GtkHScale GtkVScale GtkScrollbar GtkHScrollbar GtkVScrollbar GtkSeparator GtkHSeparator GtkVSeparator GtkInvisible # GtkOldEditable # GtkText GtkPreview if deprecated # Progress is deprecated, ProgressBar contains everything necessary # GtkProgress GtkProgressBar GtkAdjustment GtkIMContext GtkIMMulticontext GtkItemFactory if deprecated GtkTooltips # These object were added by hand because they do not show up in the hierarchy # chart. # These are derived from GtkObject: GtkTreeViewColumn GtkCellRenderer GtkCellRendererPixbuf GtkCellRendererText GtkCellRendererCombo if gtk-2.6 GtkCellRendererToggle GtkCellRendererProgress if gtk-2.6 GtkFileFilter if gtk-2.4 GtkBuilder if gtk-2.12 # These are actually interfaces, but all objects that implement it are at # least GObjects. GtkCellLayout if gtk-2.4 GtkTreeSortable if gtk-2.4 GtkTooltip if gtk-2.12 # These are derived from GObject: GtkStatusIcon if gtk-2.10 GtkTreeSelection GtkTreeModel GtkTreeStore GtkListStore GtkTreeModelSort GtkTreeModelFilter if gtk-2.4 GtkIconFactory GtkIconTheme GtkSizeGroup GtkClipboard if gtk-2.2 GtkAccelGroup GtkAccelMap if gtk-2.4 GtkEntryCompletion if gtk-2.4 GtkAction if gtk-2.4 GtkToggleAction if gtk-2.4 GtkRadioAction if gtk-2.4 GtkActionGroup if gtk-2.4 GtkUIManager if gtk-2.4 GtkWindowGroup GtkSourceLanguage if sourceview GtkSourceLanguage if gtksourceview2 GtkSourceLanguagesManager if sourceview GtkSourceLanguageManager if gtksourceview2 GladeXML as GladeXML, glade_xml_get_type if libglade GConfClient as GConf if gconf # These ones are actualy interfaces, but interface implementations are GObjects GtkEditable GtkSourceStyle as SourceStyleObject if gtksourceview2 GtkSourceStyleScheme if sourceview GtkSourceStyleScheme if gtksourceview2 GtkSourceStyleSchemeManager if gtksourceview2 GtkFileChooser if gtk-2.4 ## This now became a GObject in version 2: GdkGC as GC, gdk_gc_get_type ## These are Pango structures PangoContext as PangoContext, pango_context_get_type if pango PangoLayout as PangoLayoutRaw, pango_layout_get_type if pango PangoFont as Font, pango_font_get_type if pango PangoFontFamily as FontFamily, pango_font_family_get_type if pango PangoFontFace as FontFace, pango_font_face_get_type if pango PangoFontMap as FontMap, pango_font_face_get_type if pango PangoFontset as FontSet, pango_fontset_get_type if pango ## This type is only available for PANGO_ENABLE_BACKEND compiled source ## PangoFontsetSimple as FontSetSimple, pango_fontset_simple_get_type ## GtkGlExt classes GdkGLContext if gtkglext GdkGLConfig if gtkglext GdkGLDrawable if gtkglext ## GnomeVFS classes GnomeVFSVolume as Volume, gnome_vfs_volume_get_type if gnomevfs GnomeVFSDrive as Drive, gnome_vfs_drive_get_type if gnomevfs GnomeVFSVolumeMonitor as VolumeMonitor, gnome_vfs_volume_monitor_get_type if gnomevfs ## GIO classes # Note on all the "as" clauses: the prefix G is unfortunate since it leads # to two consecutive upper case letters which are not translated with an # underscore each (e.g. GConf -> gconf, GtkHButtonBox -> gtk_hbutton_box). # GUnixMountMonitor as UnixMountMonitor, g_unix_mount_monitor_get_type if gio GOutputStream as OutputStream, g_output_stream_get_type if gio GFilterOutputStream as FilterOutputStream, g_filter_output_stream_get_type if gio GDataOutputStream as DataOutputStream, g_data_output_stream_get_type if gio GBufferedOutputStream as BufferedOutputStream, g_buffered_output_stream_get_type if gio # GUnixOutputStream as UnixOutputStream, g_unix_output_stream_get_type if gio GFileOutputStream as FileOutputStream, g_file_output_stream_get_type if gio GMemoryOutputStream as MemoryOutputStream, g_memory_output_stream_get_type if gio GInputStream as InputStream, g_input_stream_get_type if gio # GUnixInputStream as UnixInputStream, g_unix_input_stream_get_type if gio GMemoryInputStream as MemoryInputStream, g_memory_input_stream_get_type if gio GFilterInputStream as FilterInputStream, g_filter_input_stream_get_type if gio GBufferedInputStream as BufferedInputStream, g_buffered_input_stream_get_type if gio GDataInputStream as DataInputStream, g_data_input_stream_get_type if gio GFileInputStream as FileInputStream, g_file_input_stream_get_type if gio # GDesktopAppInfo as DesktopAppInfo, g_desktop_app_info_get_type if gio GFileMonitor as FileMonitor, g_file_monitor_get_type if gio GVfs as Vfs, g_vfs_get_type if gio GMountOperation as MountOperation, g_mount_operation_get_type if gio GThemedIcon as ThemedIcon, g_themed_icon_get_type if gio GEmblem as Emblem, g_emblem_get_type if gio-2.18 GEmblemedIcon as EmblemedIcon, g_emblemed_icon_get_type if gio-2.18 GFileEnumerator as FileEnumerator, g_file_enumerator_get_type if gio GFilenameCompleter as FilenameCompleter, g_filename_completer_get_type if gio GFileIcon as FileIcon, g_file_icon_get_type if gio GVolumeMonitor as VolumeMonitor, g_volume_monitor_get_type if gio GCancellable as Cancellable, g_cancellable_get_type if gio GSimpleAsyncResult as SimpleAsyncResult, g_async_result_get_type if gio GFileInfo as FileInfo, g_file_info_get_type if gio GAppLaunchContext as AppLaunchContext, g_app_launch_context_get_type if gio ## these are actually GInterfaces GIcon as Icon, g_icon_get_type if gio GSeekable as Seekable, g_seekable_get_type if gio GAppInfo as AppInfo, g_app_info_get_type if gio GVolume as Volume, g_volume_get_type if gio GAsyncResult as AsyncResult, g_async_result_get_type if gio GLoadableIcon as LoadableIcon, g_loadable_icon_get_type if gio GDrive as Drive, g_drive_get_type if gio GFile noEq as File, g_file_get_type if gio GMount as Mount, g_mount_get_type if gio ## GStreamer classes GstObject as Object, gst_object_get_type if gstreamer GstPad as Pad, gst_pad_get_type if gstreamer GstGhostPad as GhostPad, gst_ghost_pad_get_type if gstreamer GstPluginFeature as PluginFeature, gst_plugin_feature_get_type if gstreamer GstElementFactory as ElementFactory, gst_element_factory_get_type if gstreamer GstTypeFindFactory as TypeFindFactory, gst_type_find_factory_get_type if gstreamer GstIndexFactory as IndexFactory, gst_index_factory_get_type if gstreamer GstElement as Element, gst_element_get_type if gstreamer GstBin as Bin, gst_bin_get_type if gstreamer GstPipeline as Pipeline, gst_pipeline_get_type if gstreamer GstImplementsInterface as ImplementsInterface, gst_implements_interface_get_type if gstreamer GstTagSetter as TagSetter, gst_tag_setter_get_type if gstreamer GstBaseSrc as BaseSrc, gst_base_src_get_type if gstreamer GstPushSrc as PushSrc, gst_push_src_get_type if gstreamer GstBaseSink as BaseSink, gst_base_sink_get_type if gstreamer GstBaseTransform as BaseTransform, gst_base_transform_get_type if gstreamer GstPlugin as Plugin, gst_plugin_get_type if gstreamer GstRegistry as Registry, gst_registry_get_type if gstreamer GstBus as Bus, gst_bus_get_type if gstreamer GstClock as Clock, gst_clock_get_type if gstreamer GstAudioClock as AudioClock, gst_audio_clock_get_type if gstreamer GstSystemClock as SystemClock, gst_system_clock_get_type if gstreamer GstNetClientClock as NetClientClock, gst_net_client_clock_get_type if gstreamer GstIndex as Index, gst_index_get_type if gstreamer GstPadTemplate as PadTemplate, gst_pad_template_get_type if gstreamer GstTask as Task, gst_task_get_type if gstreamer GstXML as XML, gst_xml_get_type if gstreamer GstChildProxy as ChildProxy, gst_child_proxy_get_type if gstreamer GstCollectPads as CollectPads, gst_collect_pads_get_type if gstreamer ## these are actually GInterfaces GstURIHandler as URIHandler, gst_uri_handler_get_type if gstreamer GstAdapter as Adapter, gst_adapter_get_type if gstreamer GstController as Controller, gst_controller_get_type if gstreamer WebKitWebFrame as WebFrame, webkit_web_frame_get_type if webkit WebKitWebSettings as WebSettings, webkit_web_settings_get_type if webkit WebKitNetworkRequest as NetworkRequest, webkit_network_request_get_type if webkit WebKitNetworkResponse as NetworkResponse, webkit_network_response_get_type if webkit WebKitDownload as Download, webkit_download_get_type if webkit WebKitWebBackForwardList as WebBackForwardList, webkit_web_back_forward_list_get_type if webkit WebKitWebHistoryItem as WebHistoryItem, webkit_web_history_item_get_type if webkit WebKitWebInspector as WebInspector, webkit_web_inspector_get_type if webkit WebKitHitTestResult as HitTestResult, webkit_hit_test_result_get_type if webkit WebKitSecurityOrigin as SecurityOrigin, webkit_security_origin_get_type if webkit WebKitSoupAuthDialog as SoupAuthDialog, webkit_soup_auth_dialog_get_type if webkit WebKitWebDatabase as WebDatabase, webkit_web_database_get_type if webkit WebKitWebDataSource as WebDataSource, webkit_web_data_source_get_type if webkit WebKitWebNavigationAction as WebNavigationAction, webkit_web_navigation_action_get_type if webkit WebKitWebPolicyDecision as WebPolicyDecision, webkit_web_policy_decision_get_type if webkit WebKitWebResource as WebResource, webkit_web_resource_get_type if webkit WebKitWebWindowFeatures as WebWindowFeatures, webkit_web_window_features_get_type if webkit gio-0.13.1.0/marshal.list0000644000000000000000000000467612507510337013242 0ustar0000000000000000# see glib-genmarshal(1) for a detailed description of the file format, # possible parameter types are: # VOID indicates no return type, or no extra # parameters. if VOID is used as the parameter # list, no additional parameters may be present. # BOOLEAN for boolean types (gboolean) # CHAR for signed char types (gchar) # UCHAR for unsigned char types (guchar) # INT for signed integer types (gint) # UINT for unsigned integer types (guint) # LONG for signed long integer types (glong) # ULONG for unsigned long integer types (gulong) # ENUM for enumeration types (gint) # FLAGS for flag enumeration types (guint) # FLOAT for single-precision float types (gfloat) # DOUBLE for double-precision float types (gdouble) # GLIBSTRING for string types (gchar*) # BOXED for boxed (anonymous but reference counted) types (GBoxed*) # POINTER for anonymous pointer types (gpointer) # NONE deprecated alias for VOID # BOOL deprecated alias for BOOLEAN # # One discrepancy from Gtk+ is that for signals that may pass NULL for an object # reference, the Haskell signal should be passed a 'Maybe GObject'. # We therefore have two variants that are marshalled as a maybe type: # # OBJECT for GObject or derived types (GObject*) # MOBJECT for GObject or derived types (GObject*) that may be NULL # Furthermore, some objects needs to be destroyed synchronously from the main loop of # Gtk rather than during GC. These objects need to be marshalled using TOBJECT (for thread-safe # object). It doesn't hurt to use TOBJECT for an object that doesn't need it, except for the # some performance. As a rule of thumb, use TOBJECT for all libraries that build on package # 'gtk' and use OBJECT for all packages that only need packages 'glib', 'pango', 'cairo', # 'gio'. Again both variants exist. Note that the same names will be generated for OBJECT and # TOBJECT, so you have to remove the OBJECT handler if you need both. # # TOBJECT for GObject or derived types (GObject*) # MTOBJECT for GObject or derived types (GObject*) that may be NULL # If you add a new signal type, please check that it actually works! # If it is a Boxed type check that the reference counting is right. NONE:NONE NONE:GLIBSTRING,GLIBSTRING,GLIBSTRING,ENUM NONE:OBJECT,OBJECT,ENUM NONE:ENUM NONE:OBJECT NONE:MOBJECT,MOBJECT,ENUM gio-0.13.1.0/Setup.hs0000644000000000000000000000050412507510337012334 0ustar0000000000000000-- Standard setup file for a Gtk2Hs module. -- -- See also: -- * SetupMain.hs : the real Setup script for this package -- * Gtk2HsSetup.hs : Gtk2Hs-specific boilerplate -- * SetupWrapper.hs : wrapper for compat with various ghc/cabal versions import SetupWrapper ( setupWrapper ) main = setupWrapper "SetupMain.hs" gio-0.13.1.0/SetupMain.hs0000644000000000000000000000105112507510337013137 0ustar0000000000000000-- The real Setup file for a Gtk2Hs package (invoked via the SetupWrapper). -- It contains only adjustments specific to this package, -- all Gtk2Hs-specific boilerplate is kept in Gtk2HsSetup.hs -- which should be kept identical across all packages. -- import Gtk2HsSetup ( gtk2hsUserHooks, checkGtk2hsBuildtools, typeGenProgram, signalGenProgram, c2hsLocal) import Distribution.Simple ( defaultMainWithHooks ) main = do checkGtk2hsBuildtools [typeGenProgram, signalGenProgram, c2hsLocal] defaultMainWithHooks gtk2hsUserHooks gio-0.13.1.0/SetupWrapper.hs0000644000000000000000000001542212507510337013702 0ustar0000000000000000-- A wrapper script for Cabal Setup.hs scripts. Allows compiling the real Setup -- conditionally depending on the Cabal version. module SetupWrapper (setupWrapper) where import Distribution.Package import Distribution.Compiler import Distribution.Simple.Utils import Distribution.Simple.Program import Distribution.Simple.Compiler import Distribution.Simple.BuildPaths (exeExtension) import Distribution.Simple.Configure (configCompilerEx) import Distribution.Simple.GHC (getInstalledPackages) import qualified Distribution.Simple.PackageIndex as PackageIndex import Distribution.Version import Distribution.Verbosity import Distribution.Text import System.Environment import System.Process import System.Exit (ExitCode(..), exitWith) import System.FilePath import System.Directory import qualified Control.Exception as Exception import System.IO.Error (isDoesNotExistError) import Data.List import Data.Char import Control.Monad -- moreRecentFile is implemented in Distribution.Simple.Utils, but only in -- Cabal >= 1.18. For backwards-compatibility, we implement a copy with a new -- name here. Some desirable alternate strategies don't work: -- * We can't use CPP to check which version of Cabal we're up against because -- this is the file that's generating the macros for doing that. -- * We can't use the name moreRecentFiles and use -- import D.S.U hiding (moreRecentFiles) -- because on old GHC's (and according to the Report) hiding a name that -- doesn't exist is an error. moreRecentFile' :: FilePath -> FilePath -> IO Bool moreRecentFile' a b = do exists <- doesFileExist b if not exists then return True else do tb <- getModificationTime b ta <- getModificationTime a return (ta > tb) setupWrapper :: FilePath -> IO () setupWrapper setupHsFile = do args <- getArgs createDirectoryIfMissingVerbose verbosity True setupDir compileSetupExecutable invokeSetupScript args where setupDir = "dist/setup-wrapper" setupVersionFile = setupDir "setup" <.> "version" setupProgFile = setupDir "setup" <.> exeExtension setupMacroFile = setupDir "wrapper-macros.h" useCabalVersion = Version [1,8] [] usePackageDB = [GlobalPackageDB, UserPackageDB] verbosity = normal cabalLibVersionToUse comp conf = do savedVersion <- savedCabalVersion case savedVersion of Just version -> return version _ -> do version <- installedCabalVersion comp conf writeFile setupVersionFile (show version ++ "\n") return version savedCabalVersion = do versionString <- readFile setupVersionFile `Exception.catch` \e -> if isDoesNotExistError e then return "" else Exception.throwIO e case reads versionString of [(version,s)] | all isSpace s -> return (Just version) _ -> return Nothing installedCabalVersion comp conf = do index <- getInstalledPackages verbosity usePackageDB conf let cabalDep = Dependency (PackageName "Cabal") (orLaterVersion useCabalVersion) case PackageIndex.lookupDependency index cabalDep of [] -> die $ "The package requires Cabal library version " ++ display useCabalVersion ++ " but no suitable version is installed." pkgs -> return $ bestVersion (map fst pkgs) where bestVersion = maximumBy (comparing preference) preference version = (sameVersion, sameMajorVersion ,stableVersion, latestVersion) where sameVersion = version == cabalVersion sameMajorVersion = majorVersion version == majorVersion cabalVersion majorVersion = take 2 . versionBranch stableVersion = case versionBranch version of (_:x:_) -> even x _ -> False latestVersion = version -- | If the Setup.hs is out of date wrt the executable then recompile it. -- Currently this is GHC only. It should really be generalised. -- compileSetupExecutable = do setupHsNewer <- setupHsFile `moreRecentFile'` setupProgFile cabalVersionNewer <- setupVersionFile `moreRecentFile'` setupProgFile let outOfDate = setupHsNewer || cabalVersionNewer when outOfDate $ do debug verbosity "Setup script is out of date, compiling..." (comp, _, conf) <- configCompilerEx (Just GHC) Nothing Nothing defaultProgramConfiguration verbosity cabalLibVersion <- cabalLibVersionToUse comp conf let cabalPkgid = PackageIdentifier (PackageName "Cabal") cabalLibVersion debug verbosity $ "Using Cabal library version " ++ display cabalLibVersion writeFile setupMacroFile (generateVersionMacro cabalLibVersion) rawSystemProgramConf verbosity ghcProgram conf $ ["--make", setupHsFile, "-o", setupProgFile] ++ ghcPackageDbOptions usePackageDB ++ ["-package", display cabalPkgid ,"-cpp", "-optP-include", "-optP" ++ setupMacroFile ,"-odir", setupDir, "-hidir", setupDir] where ghcPackageDbOptions dbstack = case dbstack of (GlobalPackageDB:UserPackageDB:dbs) -> concatMap specific dbs (GlobalPackageDB:dbs) -> "-no-user-package-conf" : concatMap specific dbs _ -> ierror where specific (SpecificPackageDB db) = [ "-package-conf", db ] specific _ = ierror ierror = error "internal error: unexpected package db stack" generateVersionMacro :: Version -> String generateVersionMacro version = concat ["/* DO NOT EDIT: This file is automatically generated by Cabal */\n\n" ,"#define CABAL_VERSION_CHECK(major1,major2,minor) (\\\n" ," (major1) < ",major1," || \\\n" ," (major1) == ",major1," && (major2) < ",major2," || \\\n" ," (major1) == ",major1," && (major2) == ",major2," && (minor) <= ",minor,")" ,"\n\n" ] where (major1:major2:minor:_) = map show (versionBranch version ++ repeat 0) invokeSetupScript :: [String] -> IO () invokeSetupScript args = do info verbosity $ unwords (setupProgFile : args) process <- runProcess (currentDir setupProgFile) args Nothing Nothing Nothing Nothing Nothing exitCode <- waitForProcess process unless (exitCode == ExitSuccess) $ exitWith exitCode gio-0.13.1.0/demo/0000755000000000000000000000000012507510337011625 5ustar0000000000000000gio-0.13.1.0/demo/FileManager.hs0000644000000000000000000001345712507510337014345 0ustar0000000000000000-- | File Manager demo. -- Author : Andy Stewart -- Copyright : (c) 2010 Andy Stewart -- | This simple file-manager base on gio. -- module Main where import Control.Monad import Data.Maybe import Graphics.UI.Gtk import Graphics.UI.Gtk.General.IconTheme import Graphics.UI.Gtk.ModelView import System.GIO import System.Glib.GDateTime import System.Glib.GError import System.Locale import System.Time import Text.Printf import qualified Data.ByteString.UTF8 as UTF8 data FMInfo = FMInfo { fIcon :: Pixbuf, -- icon fName :: String, -- file name fDesc :: String, -- mime type description fSize :: Integer, -- file size fTime :: ClockTime -- modified time } -- | Main. main :: IO () main = do -- Init. initGUI -- Create window. window <- windowNew windowSetDefaultSize window 900 600 windowSetPosition window WinPosCenter scrolledWindow <- scrolledWindowNew Nothing Nothing window `containerAdd` scrolledWindow -- Get file infos under specify directory. infos <- directoryGetFileInfos "/" -- Get FMInfo. fInfos <- mapM (\info -> do -- Get Icon. icon <- fileInfoGetIcon info iconTheme <- iconThemeGetDefault iconInfo <- iconThemeLookupByGIcon iconTheme icon 24 IconLookupUseBuiltin pixbuf <- case iconInfo of Just ii -> iconInfoLoadIcon ii Nothing -> liftM fromJust $ iconThemeLoadIcon iconTheme "unknown" 24 IconLookupUseBuiltin let -- Get file name. name = fromJust $ fileInfoGetName info -- File size. size = toInteger $ fileInfoGetSize info -- File modified time. time = gTimeValToClockTime $ fileInfoGetModificationTime info -- File mime description. Just contentType = fileInfoGetContentType info desc = contentTypeGetDescription contentType return $ FMInfo pixbuf (UTF8.toString name) desc size time ) infos -- Initialize tree view. store <- listStoreNew fInfos tv <- treeViewNewWithModel store scrolledWindow `containerAdd` tv -- List Icons. tvc <- treeViewColumnNew set tvc [ treeViewColumnTitle := "Icon" , treeViewColumnResizable := True ] treeViewAppendColumn tv tvc icon <- cellRendererPixbufNew treeViewColumnPackStart tvc icon True cellLayoutSetAttributes tvc icon store $ \FMInfo { fIcon = icon } -> [ cellPixbuf := icon ] -- List Name. tvc <- treeViewColumnNew set tvc [ treeViewColumnTitle := "Name" , treeViewColumnResizable := True ] treeViewAppendColumn tv tvc name <- cellRendererTextNew treeViewColumnPackStart tvc name True cellLayoutSetAttributes tvc name store $ \FMInfo { fName = name } -> [ cellText := name ] -- List file mime description. tvc <- treeViewColumnNew set tvc [ treeViewColumnTitle := "Description" , treeViewColumnResizable := True ] treeViewAppendColumn tv tvc desc <- cellRendererTextNew treeViewColumnPackStart tvc desc True cellLayoutSetAttributes tvc desc store $ \FMInfo { fDesc = desc } -> [ cellText := desc ] -- List file size. tvc <- treeViewColumnNew set tvc [ treeViewColumnTitle := "Size" , treeViewColumnResizable := True ] treeViewAppendColumn tv tvc size <- cellRendererTextNew treeViewColumnPackStart tvc size True cellLayoutSetAttributes tvc size store $ \FMInfo { fSize = size } -> [ cellText := formatFileSizeForDisplay size , cellXAlign := 1.0] -- List modified time. tvc <- treeViewColumnNew set tvc [ treeViewColumnTitle := "Modified" , treeViewColumnResizable := True ] treeViewAppendColumn tv tvc time <- cellRendererTextNew treeViewColumnPackStart tvc time True cellLayoutSetAttributes tvc time store $ \FMInfo { fTime = time } -> [ cellText :=> do calTime <- toCalendarTime time return (formatCalendarTime defaultTimeLocale "%Y/%m/%d %T" calTime)] -- Show window. window `onDestroy` mainQuit widgetShowAll window mainGUI directoryGetFileInfos :: FilePath -> IO [FileInfo] directoryGetFileInfos directory = do let dir = fileFromPath (UTF8.fromString directory) enumerator <- fileEnumerateChildren dir "*" [] Nothing fileEnumeratorGetFileInfos enumerator fileEnumeratorGetFileInfos :: FileEnumeratorClass enumerator => enumerator -> IO [FileInfo] fileEnumeratorGetFileInfos enum = do fileInfo <- fileEnumeratorNextFile enum Nothing case fileInfo of Just info -> do infos <- fileEnumeratorGetFileInfos enum return $ info : infos Nothing -> return [] formatFileSizeForDisplay :: Integer -> String formatFileSizeForDisplay size | size < 2 ^ 10 = humanSize 1 ++ " bytes" | size < 2 ^ 20 = humanSize (2 ^ 10) ++ " KB" | size < 2 ^ 30 = humanSize (2 ^ 20) ++ " MB" | size < 2 ^ 40 = humanSize (2 ^ 30) ++ " GB" | size < 2 ^ 50 = humanSize (2 ^ 40) ++ " TB" | size < 2 ^ 60 = humanSize (2 ^ 50) ++ " PB" | size < 2 ^ 70 = humanSize (2 ^ 60) ++ " EB" | size < 2 ^ 80 = humanSize (2 ^ 70) ++ " ZB" | size < 2 ^ 90 = humanSize (2 ^ 80) ++ " YB" | size < 2 ^ 100 = humanSize (2 ^ 90) ++ " NB" | size < 2 ^ 110 = humanSize (2 ^ 100) ++ " DB" where humanSize base = printf "%.1f" (integralToDouble size / base) :: String integralToDouble :: Integral a => a -> Double integralToDouble v = fromIntegral v :: Double gTimeValToClockTime :: GTimeVal -> ClockTime gTimeValToClockTime GTimeVal {gTimeValSec = seconds ,gTimeValUSec = microseconds} = TOD (toInteger seconds) (toInteger microseconds * 1000) gio-0.13.1.0/demo/Makefile0000644000000000000000000000025212507510337013264 0ustar0000000000000000 PROG = filemanager SOURCES = FileManager.hs $(PROG) : $(SOURCES) $(HC) --make $< -o $@ $(HCFLAGS) clean: rm -f $(SOURCES:.hs=.hi) $(SOURCES:.hs=.o) $(PROG) HC=ghc gio-0.13.1.0/System/0000755000000000000000000000000012507510337012165 5ustar0000000000000000gio-0.13.1.0/System/GIO.hs0000644000000000000000000000503612507510337013143 0ustar0000000000000000-- GIMP Toolkit (GTK) Binding for Haskell: binding to gio -*-haskell-*- -- -- Author : Peter Gavin -- Created: 13-Oct-2008 -- -- Copyright (c) 2008 Peter Gavin -- -- This library is free software: you can redistribute it and/or -- modify it under the terms of the GNU Lesser General Public License -- as published by the Free Software Foundation, either version 3 of -- the License, or (at your option) any later version. -- -- This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public -- License along with this program. If not, see -- . -- -- GIO, the C library which this Haskell library depends on, is -- available under LGPL Version 2. The documentation included with -- this library is based on the original GIO documentation. -- -- | Maintainer : gtk2hs-devel@lists.sourceforge.net -- Stability : alpha -- Portability : portable (depends on GHC) module System.GIO ( module System.GIO.Async.AsyncResult, module System.GIO.Async.Cancellable, module System.GIO.File.AppInfo, module System.GIO.File.ContentType, module System.GIO.File.File, module System.GIO.File.FileEnumerator, module System.GIO.File.FileInfo, module System.GIO.File.FileMonitor, module System.GIO.File.IOError, module System.GIO.File.MountOperation, module System.GIO.Icons.Emblem, module System.GIO.Icons.EmblemedIcon, module System.GIO.Icons.FileIcon, module System.GIO.Icons.Icon, module System.GIO.Icons.ThemedIcon, module System.GIO.Volumes.Drive, module System.GIO.Volumes.Mount, module System.GIO.Volumes.Volume, module System.GIO.Volumes.VolumeMonitor, ) where import System.GIO.Async.AsyncResult import System.GIO.Async.Cancellable import System.GIO.File.AppInfo import System.GIO.File.ContentType import System.GIO.File.File import System.GIO.File.FileEnumerator import System.GIO.File.FileInfo import System.GIO.File.FileMonitor import System.GIO.File.IOError import System.GIO.File.MountOperation import System.GIO.Icons.Emblem import System.GIO.Icons.EmblemedIcon import System.GIO.Icons.FileIcon import System.GIO.Icons.Icon import System.GIO.Icons.ThemedIcon import System.GIO.Volumes.Drive import System.GIO.Volumes.Mount import System.GIO.Volumes.Volume import System.GIO.Volumes.VolumeMonitor gio-0.13.1.0/System/GIO/0000755000000000000000000000000012507510337012603 5ustar0000000000000000gio-0.13.1.0/System/GIO/Enums.chs0000644000000000000000000001413612507510337014376 0ustar0000000000000000{-# LANGUAGE CPP, DeriveDataTypeable #-} -- GIMP Toolkit (GTK) Binding for Haskell: binding to gio -*-haskell-*- -- -- Author : Andy Stewart -- Created: 30-April-2010 -- -- Copyright (c) 2010 Andy Stewart -- -- This library is free software: you can redistribute it and/or -- modify it under the terms of the GNU Lesser General Public License -- as published by the Free Software Foundation, either version 3 of -- the License, or (at your option) any later version. -- -- This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public -- License along with this program. If not, see -- . -- -- GIO, the C library which this Haskell library depends on, is -- available under LGPL Version 2. The documentation included with -- this library is based on the original GIO documentation. -- -- | Maintainer : gtk2hs-devel@lists.sourceforge.net -- Stability : alpha -- Portability : portable (depends on GHC) module System.GIO.Enums ( -- * Enums FileQueryInfoFlags(..), FileCreateFlags(..), FileCopyFlags(..), FileMonitorFlags(..), FilesystemPreviewType(..), FileType(..), FileAttributeStatus(..), FileAttributeInfoFlags(..), AskPasswordFlags(..), PasswordSave(..), MountOperationResult(..), IOErrorEnum(..), FileMonitorEvent(..), MountMountFlags(..), MountUnmountFlags(..), #if GLIB_CHECK_VERSION(2,22,0) DriveStartFlags(..), DriveStartStopType(..), #endif #if GLIB_CHECK_VERSION(2,18,0) EmblemOrigin(..), #endif AppInfoCreateFlags(..), ) where import Control.Monad import Data.Typeable import System.Glib.FFI import System.Glib.Flags import System.Glib.GError import System.Glib.GObject import System.Glib.UTFString {# context lib = "gio" prefix = "g" #} -- | Flags used when querying a 'FileInfo'. {# enum GFileQueryInfoFlags as FileQueryInfoFlags {underscoreToCase} with prefix = "G" deriving (Eq, Ord, Bounded, Show, Typeable) #} instance Flags FileQueryInfoFlags -- | Flags used when an operation may create a file. {# enum GFileCreateFlags as FileCreateFlags {underscoreToCase} with prefix = "G" deriving (Eq, Ord, Bounded, Show, Typeable) #} instance Flags FileCreateFlags -- | Flags used when copying or moving files. {# enum GFileCopyFlags as FileCopyFlags {underscoreToCase} with prefix = "G" deriving (Eq, Ord, Bounded, Show, Typeable) #} instance Flags FileCopyFlags -- | Flags used to set what a 'FileMonitor' will watch for. {# enum GFileMonitorFlags as FileMonitorFlags {underscoreToCase} with prefix = "G" deriving (Eq, Ord, Bounded, Show, Typeable) #} instance Flags FileMonitorFlags -- | Indicates a hint from the file system whether files should be previewed in a file manager. Returned -- as the value of the key 'FileAttributeFilesystemUsePreview'. {# enum GFilesystemPreviewType as FilesystemPreviewType {underscoreToCase} with prefix = "G" deriving (Eq, Ord, Bounded, Show, Typeable) #} -- | Indicates the file's on-disk type. {# enum GFileType as FileType {underscoreToCase} with prefix = "G" deriving (Eq, Ord, Bounded, Show, Typeable) #} -- | Used by 'fileSetAttributesFromInfo' when setting file attributes. {# enum GFileAttributeStatus as FileAttributeStatus {underscoreToCase} with prefix = "G" deriving (Eq, Ord, Bounded, Show, Typeable) #} -- | Flags specifying the behaviour of an attribute. {# enum GFileAttributeInfoFlags as FileAttributeInfoFlags {underscoreToCase} with prefix = "G" deriving (Eq, Ord, Bounded, Read, Show) #} instance Flags FileAttributeInfoFlags -- | 'AskPasswordFlags' are used to request specific information from the user, or to notify the user of -- their choices in an authentication situation. {# enum GAskPasswordFlags as AskPasswordFlags {underscoreToCase} with prefix = "G" deriving (Eq, Ord, Bounded, Show, Typeable) #} instance Flags AskPasswordFlags -- | 'PasswordSave' is used to indicate the lifespan of a saved password. {# enum GPasswordSave as PasswordSave {underscoreToCase} with prefix = "G" deriving (Eq, Ord, Bounded, Show, Typeable) #} -- | 'MountOperationResult' is returned as a result when a request for information is send by the mounting -- operation. {# enum GMountOperationResult as MountOperationResult {underscoreToCase} with prefix = "G" deriving (Eq, Ord, Bounded, Show, Typeable) #} -- | Error codes returned by GIO functions. {# enum GIOErrorEnum as IOErrorEnum {underscoreToCase} with prefix = "G" deriving (Eq, Ord, Bounded, Show, Typeable) #} -- | Specifies what type of event a monitor event is. {# enum GFileMonitorEvent as FileMonitorEvent {underscoreToCase} with prefix = "G" deriving (Eq, Ord, Bounded, Show, Typeable) #} -- | Flags used when mounting a mount. {# enum GMountMountFlags as MountMountFlags {underscoreToCase} with prefix = "G" deriving (Eq, Ord, Bounded, Show, Typeable) #} instance Flags MountMountFlags -- | Flags used when an unmounting a mount. {# enum GMountUnmountFlags as MountUnmountFlags {underscoreToCase} with prefix = "G" deriving (Eq, Ord, Bounded, Show, Typeable) #} instance Flags MountUnmountFlags #if GLIB_CHECK_VERSION(2,22,0) -- | Flags used when starting a drive. {# enum GDriveStartFlags as DriveStartFlags {underscoreToCase} with prefix = "G" deriving (Eq, Ord, Bounded, Show, Typeable) #} instance Flags DriveStartFlags -- | Enumeration describing how a drive can be started/stopped. {# enum GDriveStartStopType as DriveStartStopType {underscoreToCase} with prefix = "G" deriving (Eq, Ord, Bounded, Show, Typeable) #} #endif #if GLIB_CHECK_VERSION(2,18,0) -- | 'EmblemOrigin' is used to add information about the origin of the emblem to 'Emblem'. {# enum GEmblemOrigin as EmblemOrigin {underscoreToCase} with prefix = "G" deriving (Eq, Ord, Bounded, Show, Typeable) #} #endif -- | Flags used when creating a 'AppInfo'. {# enum GAppInfoCreateFlags as AppInfoCreateFlags {underscoreToCase} with prefix = "G" deriving (Eq, Ord, Bounded, Show, Typeable) #} instance Flags AppInfoCreateFlags gio-0.13.1.0/System/GIO/Signals.chs0000644000000000000000000001327112507510337014706 0ustar0000000000000000{-# OPTIONS_HADDOCK hide #-} {-# OPTIONS_GHC -fno-warn-unused-imports #-} -- -*-haskell-*- -- -------------------- automatically generated file - do not edit ------------ -- Callback installers for the GIMP Toolkit (GTK) Binding for Haskell -- -- Author : Axel Simon -- -- Created: 1 July 2000 -- -- Copyright (C) 2000-2005 Axel Simon -- -- This library is free software; you can redistribute it and/or -- modify it under the terms of the GNU Lesser General Public -- License as published by the Free Software Foundation; either -- version 2.1 of the License, or (at your option) any later version. -- -- This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- Lesser General Public License for more details. -- -- #hide -- These functions are used to connect signals to widgets. They are auto- -- matically created through HookGenerator.hs which takes a list of possible -- function signatures that are included in the GTK sources (gtkmarshal.list). -- -- The object system in the second version of GTK is based on GObject from -- GLIB. This base class is rather primitive in that it only implements -- ref and unref methods (and others that are not interesting to us). If -- the marshall list mentions OBJECT it refers to an instance of this -- GObject which is automatically wrapped with a ref and unref call. -- Structures which are not derived from GObject have to be passed as -- BOXED which gives the signal connect function a possibility to do the -- conversion into a proper ForeignPtr type. In special cases the signal -- connect function use a PTR type which will then be mangled in the -- user function directly. The latter is needed if a signal delivers a -- pointer to a string and its length in a separate integer. -- module System.GIO.Signals ( module System.Glib.Signals, connect_NONE__NONE, connect_GLIBSTRING_GLIBSTRING_GLIBSTRING_ENUM__NONE, connect_OBJECT_OBJECT_ENUM__NONE, connect_ENUM__NONE, connect_OBJECT__NONE, connect_MOBJECT_MOBJECT_ENUM__NONE, ) where import Control.Monad (liftM) import System.Glib.FFI import System.Glib.UTFString (peekUTFString,maybePeekUTFString) import qualified System.Glib.UTFString as Glib import System.Glib.GError (failOnGError) {#import System.Glib.Signals#} {#import System.Glib.GObject#} {#context lib="gtk" prefix="gtk" #} -- Here are the generators that turn a Haskell function into -- a C function pointer. The fist Argument is always the widget, -- the last one is the user g_pointer. Both are ignored. connect_NONE__NONE :: GObjectClass obj => SignalName -> ConnectAfter -> obj -> (IO ()) -> IO (ConnectId obj) connect_NONE__NONE signal after obj user = connectGeneric signal after obj action where action :: Ptr GObject -> IO () action _ = failOnGError $ user connect_GLIBSTRING_GLIBSTRING_GLIBSTRING_ENUM__NONE :: (Glib.GlibString a', Glib.GlibString b', Glib.GlibString c', Enum d, GObjectClass obj) => SignalName -> ConnectAfter -> obj -> (a' -> b' -> c' -> d -> IO ()) -> IO (ConnectId obj) connect_GLIBSTRING_GLIBSTRING_GLIBSTRING_ENUM__NONE signal after obj user = connectGeneric signal after obj action where action :: Ptr GObject -> CString -> CString -> CString -> Int -> IO () action _ str1 str2 str3 enum4 = failOnGError $ peekUTFString str3 >>= \str3' -> peekUTFString str2 >>= \str2' -> peekUTFString str1 >>= \str1' -> user str1' str2' str3' (toEnum enum4) connect_OBJECT_OBJECT_ENUM__NONE :: (GObjectClass a', GObjectClass b', Enum c, GObjectClass obj) => SignalName -> ConnectAfter -> obj -> (a' -> b' -> c -> IO ()) -> IO (ConnectId obj) connect_OBJECT_OBJECT_ENUM__NONE signal after obj user = connectGeneric signal after obj action where action :: Ptr GObject -> Ptr GObject -> Ptr GObject -> Int -> IO () action _ obj1 obj2 enum3 = failOnGError $ makeNewGObject (GObject, objectUnref) (return obj2) >>= \obj2' -> makeNewGObject (GObject, objectUnref) (return obj1) >>= \obj1' -> user (unsafeCastGObject obj1') (unsafeCastGObject obj2') (toEnum enum3) connect_ENUM__NONE :: (Enum a, GObjectClass obj) => SignalName -> ConnectAfter -> obj -> (a -> IO ()) -> IO (ConnectId obj) connect_ENUM__NONE signal after obj user = connectGeneric signal after obj action where action :: Ptr GObject -> Int -> IO () action _ enum1 = failOnGError $ user (toEnum enum1) connect_OBJECT__NONE :: (GObjectClass a', GObjectClass obj) => SignalName -> ConnectAfter -> obj -> (a' -> IO ()) -> IO (ConnectId obj) connect_OBJECT__NONE signal after obj user = connectGeneric signal after obj action where action :: Ptr GObject -> Ptr GObject -> IO () action _ obj1 = failOnGError $ makeNewGObject (GObject, objectUnref) (return obj1) >>= \obj1' -> user (unsafeCastGObject obj1') connect_MOBJECT_MOBJECT_ENUM__NONE :: (GObjectClass a', GObjectClass b', Enum c, GObjectClass obj) => SignalName -> ConnectAfter -> obj -> (Maybe a' -> Maybe b' -> c -> IO ()) -> IO (ConnectId obj) connect_MOBJECT_MOBJECT_ENUM__NONE signal after obj user = connectGeneric signal after obj action where action :: Ptr GObject -> Ptr GObject -> Ptr GObject -> Int -> IO () action _ obj1 obj2 enum3 = failOnGError $ maybeNull (makeNewGObject (GObject, objectUnref)) (return obj2) >>= \obj2' -> maybeNull (makeNewGObject (GObject, objectUnref)) (return obj1) >>= \obj1' -> user (liftM unsafeCastGObject obj1') (liftM unsafeCastGObject obj2') (toEnum enum3) gio-0.13.1.0/System/GIO/Types.chs0000644000000000000000000010741712507510337014420 0ustar0000000000000000{-# LANGUAGE CPP #-} {-# OPTIONS_HADDOCK hide #-} {-# OPTIONS_GHC -fno-warn-unused-imports #-} -- -*-haskell-*- -- -------------------- automatically generated file - do not edit ---------- -- Object hierarchy for the GIMP Toolkit (GTK) Binding for Haskell -- -- Author : Axel Simon -- -- Copyright (C) 2001-2005 Axel Simon -- -- This library is free software; you can redistribute it and/or -- modify it under the terms of the GNU Lesser General Public -- License as published by the Free Software Foundation; either -- version 2.1 of the License, or (at your option) any later version. -- -- This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- Lesser General Public License for more details. -- -- #hide -- | -- Maintainer : gtk2hs-users@lists.sourceforge.net -- Stability : provisional -- Portability : portable (depends on GHC) -- -- This file reflects the Gtk+ object hierarchy in terms of Haskell classes. -- -- Note: the mk... functions were originally meant to simply be an alias -- for the constructor. However, in order to communicate the destructor -- of an object to objectNew, the mk... functions are now a tuple containing -- Haskell constructor and the destructor function pointer. This hack avoids -- changing all modules that simply pass mk... to objectNew. -- module System.GIO.Types ( OutputStream(OutputStream), OutputStreamClass, toOutputStream, mkOutputStream, unOutputStream, castToOutputStream, gTypeOutputStream, FilterOutputStream(FilterOutputStream), FilterOutputStreamClass, toFilterOutputStream, mkFilterOutputStream, unFilterOutputStream, castToFilterOutputStream, gTypeFilterOutputStream, DataOutputStream(DataOutputStream), DataOutputStreamClass, toDataOutputStream, mkDataOutputStream, unDataOutputStream, castToDataOutputStream, gTypeDataOutputStream, BufferedOutputStream(BufferedOutputStream), BufferedOutputStreamClass, toBufferedOutputStream, mkBufferedOutputStream, unBufferedOutputStream, castToBufferedOutputStream, gTypeBufferedOutputStream, FileOutputStream(FileOutputStream), FileOutputStreamClass, toFileOutputStream, mkFileOutputStream, unFileOutputStream, castToFileOutputStream, gTypeFileOutputStream, MemoryOutputStream(MemoryOutputStream), MemoryOutputStreamClass, toMemoryOutputStream, mkMemoryOutputStream, unMemoryOutputStream, castToMemoryOutputStream, gTypeMemoryOutputStream, InputStream(InputStream), InputStreamClass, toInputStream, mkInputStream, unInputStream, castToInputStream, gTypeInputStream, MemoryInputStream(MemoryInputStream), MemoryInputStreamClass, toMemoryInputStream, mkMemoryInputStream, unMemoryInputStream, castToMemoryInputStream, gTypeMemoryInputStream, FilterInputStream(FilterInputStream), FilterInputStreamClass, toFilterInputStream, mkFilterInputStream, unFilterInputStream, castToFilterInputStream, gTypeFilterInputStream, BufferedInputStream(BufferedInputStream), BufferedInputStreamClass, toBufferedInputStream, mkBufferedInputStream, unBufferedInputStream, castToBufferedInputStream, gTypeBufferedInputStream, DataInputStream(DataInputStream), DataInputStreamClass, toDataInputStream, mkDataInputStream, unDataInputStream, castToDataInputStream, gTypeDataInputStream, FileInputStream(FileInputStream), FileInputStreamClass, toFileInputStream, mkFileInputStream, unFileInputStream, castToFileInputStream, gTypeFileInputStream, FileMonitor(FileMonitor), FileMonitorClass, toFileMonitor, mkFileMonitor, unFileMonitor, castToFileMonitor, gTypeFileMonitor, Vfs(Vfs), VfsClass, toVfs, mkVfs, unVfs, castToVfs, gTypeVfs, MountOperation(MountOperation), MountOperationClass, toMountOperation, mkMountOperation, unMountOperation, castToMountOperation, gTypeMountOperation, ThemedIcon(ThemedIcon), ThemedIconClass, toThemedIcon, mkThemedIcon, unThemedIcon, castToThemedIcon, gTypeThemedIcon, Emblem(Emblem), EmblemClass, toEmblem, mkEmblem, unEmblem, castToEmblem, gTypeEmblem, EmblemedIcon(EmblemedIcon), EmblemedIconClass, toEmblemedIcon, mkEmblemedIcon, unEmblemedIcon, castToEmblemedIcon, gTypeEmblemedIcon, FileEnumerator(FileEnumerator), FileEnumeratorClass, toFileEnumerator, mkFileEnumerator, unFileEnumerator, castToFileEnumerator, gTypeFileEnumerator, FilenameCompleter(FilenameCompleter), FilenameCompleterClass, toFilenameCompleter, mkFilenameCompleter, unFilenameCompleter, castToFilenameCompleter, gTypeFilenameCompleter, FileIcon(FileIcon), FileIconClass, toFileIcon, mkFileIcon, unFileIcon, castToFileIcon, gTypeFileIcon, VolumeMonitor(VolumeMonitor), VolumeMonitorClass, toVolumeMonitor, mkVolumeMonitor, unVolumeMonitor, castToVolumeMonitor, gTypeVolumeMonitor, Cancellable(Cancellable), CancellableClass, toCancellable, mkCancellable, unCancellable, castToCancellable, gTypeCancellable, SimpleAsyncResult(SimpleAsyncResult), SimpleAsyncResultClass, toSimpleAsyncResult, mkSimpleAsyncResult, unSimpleAsyncResult, castToSimpleAsyncResult, gTypeSimpleAsyncResult, FileInfo(FileInfo), FileInfoClass, toFileInfo, mkFileInfo, unFileInfo, castToFileInfo, gTypeFileInfo, AppLaunchContext(AppLaunchContext), AppLaunchContextClass, toAppLaunchContext, mkAppLaunchContext, unAppLaunchContext, castToAppLaunchContext, gTypeAppLaunchContext, Icon(Icon), IconClass, toIcon, mkIcon, unIcon, castToIcon, gTypeIcon, Seekable(Seekable), SeekableClass, toSeekable, mkSeekable, unSeekable, castToSeekable, gTypeSeekable, AppInfo(AppInfo), AppInfoClass, toAppInfo, mkAppInfo, unAppInfo, castToAppInfo, gTypeAppInfo, Volume(Volume), VolumeClass, toVolume, mkVolume, unVolume, castToVolume, gTypeVolume, AsyncResult(AsyncResult), AsyncResultClass, toAsyncResult, mkAsyncResult, unAsyncResult, castToAsyncResult, gTypeAsyncResult, LoadableIcon(LoadableIcon), LoadableIconClass, toLoadableIcon, mkLoadableIcon, unLoadableIcon, castToLoadableIcon, gTypeLoadableIcon, Drive(Drive), DriveClass, toDrive, mkDrive, unDrive, castToDrive, gTypeDrive, File(File), FileClass, toFile, mkFile, unFile, castToFile, gTypeFile, Mount(Mount), MountClass, toMount, mkMount, unMount, castToMount, gTypeMount ) where import Foreign.ForeignPtr (ForeignPtr, castForeignPtr) #if __GLASGOW_HASKELL__ >= 707 import Foreign.ForeignPtr.Unsafe (unsafeForeignPtrToPtr) #else import Foreign.ForeignPtr (unsafeForeignPtrToPtr) #endif import Foreign.C.Types (CULong(..), CUInt(..), CULLong(..)) import System.Glib.GType (GType, typeInstanceIsA) import System.Glib.GObject {# context lib="gio" prefix="g" #} -- The usage of foreignPtrToPtr should be safe as the evaluation will only be -- forced if the object is used afterwards -- castTo :: (GObjectClass obj, GObjectClass obj') => GType -> String -> (obj -> obj') castTo gtype objTypeName obj = case toGObject obj of gobj@(GObject objFPtr) | typeInstanceIsA ((unsafeForeignPtrToPtr.castForeignPtr) objFPtr) gtype -> unsafeCastGObject gobj | otherwise -> error $ "Cannot cast object to " ++ objTypeName -- *************************************************************** OutputStream {#pointer *GOutputStream as OutputStream foreign newtype #} deriving (Eq,Ord) mkOutputStream = (OutputStream, objectUnref) unOutputStream (OutputStream o) = o class GObjectClass o => OutputStreamClass o toOutputStream :: OutputStreamClass o => o -> OutputStream toOutputStream = unsafeCastGObject . toGObject instance OutputStreamClass OutputStream instance GObjectClass OutputStream where toGObject = GObject . castForeignPtr . unOutputStream unsafeCastGObject = OutputStream . castForeignPtr . unGObject castToOutputStream :: GObjectClass obj => obj -> OutputStream castToOutputStream = castTo gTypeOutputStream "OutputStream" gTypeOutputStream :: GType gTypeOutputStream = {# call fun unsafe g_output_stream_get_type #} -- ********************************************************* FilterOutputStream {#pointer *GFilterOutputStream as FilterOutputStream foreign newtype #} deriving (Eq,Ord) mkFilterOutputStream = (FilterOutputStream, objectUnref) unFilterOutputStream (FilterOutputStream o) = o class OutputStreamClass o => FilterOutputStreamClass o toFilterOutputStream :: FilterOutputStreamClass o => o -> FilterOutputStream toFilterOutputStream = unsafeCastGObject . toGObject instance FilterOutputStreamClass FilterOutputStream instance OutputStreamClass FilterOutputStream instance GObjectClass FilterOutputStream where toGObject = GObject . castForeignPtr . unFilterOutputStream unsafeCastGObject = FilterOutputStream . castForeignPtr . unGObject castToFilterOutputStream :: GObjectClass obj => obj -> FilterOutputStream castToFilterOutputStream = castTo gTypeFilterOutputStream "FilterOutputStream" gTypeFilterOutputStream :: GType gTypeFilterOutputStream = {# call fun unsafe g_filter_output_stream_get_type #} -- *********************************************************** DataOutputStream {#pointer *GDataOutputStream as DataOutputStream foreign newtype #} deriving (Eq,Ord) mkDataOutputStream = (DataOutputStream, objectUnref) unDataOutputStream (DataOutputStream o) = o class FilterOutputStreamClass o => DataOutputStreamClass o toDataOutputStream :: DataOutputStreamClass o => o -> DataOutputStream toDataOutputStream = unsafeCastGObject . toGObject instance DataOutputStreamClass DataOutputStream instance FilterOutputStreamClass DataOutputStream instance OutputStreamClass DataOutputStream instance GObjectClass DataOutputStream where toGObject = GObject . castForeignPtr . unDataOutputStream unsafeCastGObject = DataOutputStream . castForeignPtr . unGObject castToDataOutputStream :: GObjectClass obj => obj -> DataOutputStream castToDataOutputStream = castTo gTypeDataOutputStream "DataOutputStream" gTypeDataOutputStream :: GType gTypeDataOutputStream = {# call fun unsafe g_data_output_stream_get_type #} -- ******************************************************* BufferedOutputStream {#pointer *GBufferedOutputStream as BufferedOutputStream foreign newtype #} deriving (Eq,Ord) mkBufferedOutputStream = (BufferedOutputStream, objectUnref) unBufferedOutputStream (BufferedOutputStream o) = o class FilterOutputStreamClass o => BufferedOutputStreamClass o toBufferedOutputStream :: BufferedOutputStreamClass o => o -> BufferedOutputStream toBufferedOutputStream = unsafeCastGObject . toGObject instance BufferedOutputStreamClass BufferedOutputStream instance FilterOutputStreamClass BufferedOutputStream instance OutputStreamClass BufferedOutputStream instance GObjectClass BufferedOutputStream where toGObject = GObject . castForeignPtr . unBufferedOutputStream unsafeCastGObject = BufferedOutputStream . castForeignPtr . unGObject castToBufferedOutputStream :: GObjectClass obj => obj -> BufferedOutputStream castToBufferedOutputStream = castTo gTypeBufferedOutputStream "BufferedOutputStream" gTypeBufferedOutputStream :: GType gTypeBufferedOutputStream = {# call fun unsafe g_buffered_output_stream_get_type #} -- *********************************************************** FileOutputStream {#pointer *GFileOutputStream as FileOutputStream foreign newtype #} deriving (Eq,Ord) mkFileOutputStream = (FileOutputStream, objectUnref) unFileOutputStream (FileOutputStream o) = o class OutputStreamClass o => FileOutputStreamClass o toFileOutputStream :: FileOutputStreamClass o => o -> FileOutputStream toFileOutputStream = unsafeCastGObject . toGObject instance FileOutputStreamClass FileOutputStream instance OutputStreamClass FileOutputStream instance GObjectClass FileOutputStream where toGObject = GObject . castForeignPtr . unFileOutputStream unsafeCastGObject = FileOutputStream . castForeignPtr . unGObject castToFileOutputStream :: GObjectClass obj => obj -> FileOutputStream castToFileOutputStream = castTo gTypeFileOutputStream "FileOutputStream" gTypeFileOutputStream :: GType gTypeFileOutputStream = {# call fun unsafe g_file_output_stream_get_type #} -- ********************************************************* MemoryOutputStream {#pointer *GMemoryOutputStream as MemoryOutputStream foreign newtype #} deriving (Eq,Ord) mkMemoryOutputStream = (MemoryOutputStream, objectUnref) unMemoryOutputStream (MemoryOutputStream o) = o class OutputStreamClass o => MemoryOutputStreamClass o toMemoryOutputStream :: MemoryOutputStreamClass o => o -> MemoryOutputStream toMemoryOutputStream = unsafeCastGObject . toGObject instance MemoryOutputStreamClass MemoryOutputStream instance OutputStreamClass MemoryOutputStream instance GObjectClass MemoryOutputStream where toGObject = GObject . castForeignPtr . unMemoryOutputStream unsafeCastGObject = MemoryOutputStream . castForeignPtr . unGObject castToMemoryOutputStream :: GObjectClass obj => obj -> MemoryOutputStream castToMemoryOutputStream = castTo gTypeMemoryOutputStream "MemoryOutputStream" gTypeMemoryOutputStream :: GType gTypeMemoryOutputStream = {# call fun unsafe g_memory_output_stream_get_type #} -- **************************************************************** InputStream {#pointer *GInputStream as InputStream foreign newtype #} deriving (Eq,Ord) mkInputStream = (InputStream, objectUnref) unInputStream (InputStream o) = o class GObjectClass o => InputStreamClass o toInputStream :: InputStreamClass o => o -> InputStream toInputStream = unsafeCastGObject . toGObject instance InputStreamClass InputStream instance GObjectClass InputStream where toGObject = GObject . castForeignPtr . unInputStream unsafeCastGObject = InputStream . castForeignPtr . unGObject castToInputStream :: GObjectClass obj => obj -> InputStream castToInputStream = castTo gTypeInputStream "InputStream" gTypeInputStream :: GType gTypeInputStream = {# call fun unsafe g_input_stream_get_type #} -- ********************************************************** MemoryInputStream {#pointer *GMemoryInputStream as MemoryInputStream foreign newtype #} deriving (Eq,Ord) mkMemoryInputStream = (MemoryInputStream, objectUnref) unMemoryInputStream (MemoryInputStream o) = o class InputStreamClass o => MemoryInputStreamClass o toMemoryInputStream :: MemoryInputStreamClass o => o -> MemoryInputStream toMemoryInputStream = unsafeCastGObject . toGObject instance MemoryInputStreamClass MemoryInputStream instance InputStreamClass MemoryInputStream instance GObjectClass MemoryInputStream where toGObject = GObject . castForeignPtr . unMemoryInputStream unsafeCastGObject = MemoryInputStream . castForeignPtr . unGObject castToMemoryInputStream :: GObjectClass obj => obj -> MemoryInputStream castToMemoryInputStream = castTo gTypeMemoryInputStream "MemoryInputStream" gTypeMemoryInputStream :: GType gTypeMemoryInputStream = {# call fun unsafe g_memory_input_stream_get_type #} -- ********************************************************** FilterInputStream {#pointer *GFilterInputStream as FilterInputStream foreign newtype #} deriving (Eq,Ord) mkFilterInputStream = (FilterInputStream, objectUnref) unFilterInputStream (FilterInputStream o) = o class InputStreamClass o => FilterInputStreamClass o toFilterInputStream :: FilterInputStreamClass o => o -> FilterInputStream toFilterInputStream = unsafeCastGObject . toGObject instance FilterInputStreamClass FilterInputStream instance InputStreamClass FilterInputStream instance GObjectClass FilterInputStream where toGObject = GObject . castForeignPtr . unFilterInputStream unsafeCastGObject = FilterInputStream . castForeignPtr . unGObject castToFilterInputStream :: GObjectClass obj => obj -> FilterInputStream castToFilterInputStream = castTo gTypeFilterInputStream "FilterInputStream" gTypeFilterInputStream :: GType gTypeFilterInputStream = {# call fun unsafe g_filter_input_stream_get_type #} -- ******************************************************** BufferedInputStream {#pointer *GBufferedInputStream as BufferedInputStream foreign newtype #} deriving (Eq,Ord) mkBufferedInputStream = (BufferedInputStream, objectUnref) unBufferedInputStream (BufferedInputStream o) = o class FilterInputStreamClass o => BufferedInputStreamClass o toBufferedInputStream :: BufferedInputStreamClass o => o -> BufferedInputStream toBufferedInputStream = unsafeCastGObject . toGObject instance BufferedInputStreamClass BufferedInputStream instance FilterInputStreamClass BufferedInputStream instance InputStreamClass BufferedInputStream instance GObjectClass BufferedInputStream where toGObject = GObject . castForeignPtr . unBufferedInputStream unsafeCastGObject = BufferedInputStream . castForeignPtr . unGObject castToBufferedInputStream :: GObjectClass obj => obj -> BufferedInputStream castToBufferedInputStream = castTo gTypeBufferedInputStream "BufferedInputStream" gTypeBufferedInputStream :: GType gTypeBufferedInputStream = {# call fun unsafe g_buffered_input_stream_get_type #} -- ************************************************************ DataInputStream {#pointer *GDataInputStream as DataInputStream foreign newtype #} deriving (Eq,Ord) mkDataInputStream = (DataInputStream, objectUnref) unDataInputStream (DataInputStream o) = o class BufferedInputStreamClass o => DataInputStreamClass o toDataInputStream :: DataInputStreamClass o => o -> DataInputStream toDataInputStream = unsafeCastGObject . toGObject instance DataInputStreamClass DataInputStream instance BufferedInputStreamClass DataInputStream instance FilterInputStreamClass DataInputStream instance InputStreamClass DataInputStream instance GObjectClass DataInputStream where toGObject = GObject . castForeignPtr . unDataInputStream unsafeCastGObject = DataInputStream . castForeignPtr . unGObject castToDataInputStream :: GObjectClass obj => obj -> DataInputStream castToDataInputStream = castTo gTypeDataInputStream "DataInputStream" gTypeDataInputStream :: GType gTypeDataInputStream = {# call fun unsafe g_data_input_stream_get_type #} -- ************************************************************ FileInputStream {#pointer *GFileInputStream as FileInputStream foreign newtype #} deriving (Eq,Ord) mkFileInputStream = (FileInputStream, objectUnref) unFileInputStream (FileInputStream o) = o class InputStreamClass o => FileInputStreamClass o toFileInputStream :: FileInputStreamClass o => o -> FileInputStream toFileInputStream = unsafeCastGObject . toGObject instance FileInputStreamClass FileInputStream instance InputStreamClass FileInputStream instance GObjectClass FileInputStream where toGObject = GObject . castForeignPtr . unFileInputStream unsafeCastGObject = FileInputStream . castForeignPtr . unGObject castToFileInputStream :: GObjectClass obj => obj -> FileInputStream castToFileInputStream = castTo gTypeFileInputStream "FileInputStream" gTypeFileInputStream :: GType gTypeFileInputStream = {# call fun unsafe g_file_input_stream_get_type #} -- **************************************************************** FileMonitor {#pointer *GFileMonitor as FileMonitor foreign newtype #} deriving (Eq,Ord) mkFileMonitor = (FileMonitor, objectUnref) unFileMonitor (FileMonitor o) = o class GObjectClass o => FileMonitorClass o toFileMonitor :: FileMonitorClass o => o -> FileMonitor toFileMonitor = unsafeCastGObject . toGObject instance FileMonitorClass FileMonitor instance GObjectClass FileMonitor where toGObject = GObject . castForeignPtr . unFileMonitor unsafeCastGObject = FileMonitor . castForeignPtr . unGObject castToFileMonitor :: GObjectClass obj => obj -> FileMonitor castToFileMonitor = castTo gTypeFileMonitor "FileMonitor" gTypeFileMonitor :: GType gTypeFileMonitor = {# call fun unsafe g_file_monitor_get_type #} -- ************************************************************************ Vfs {#pointer *GVfs as Vfs foreign newtype #} deriving (Eq,Ord) mkVfs = (Vfs, objectUnref) unVfs (Vfs o) = o class GObjectClass o => VfsClass o toVfs :: VfsClass o => o -> Vfs toVfs = unsafeCastGObject . toGObject instance VfsClass Vfs instance GObjectClass Vfs where toGObject = GObject . castForeignPtr . unVfs unsafeCastGObject = Vfs . castForeignPtr . unGObject castToVfs :: GObjectClass obj => obj -> Vfs castToVfs = castTo gTypeVfs "Vfs" gTypeVfs :: GType gTypeVfs = {# call fun unsafe g_vfs_get_type #} -- ************************************************************* MountOperation {#pointer *GMountOperation as MountOperation foreign newtype #} deriving (Eq,Ord) mkMountOperation = (MountOperation, objectUnref) unMountOperation (MountOperation o) = o class GObjectClass o => MountOperationClass o toMountOperation :: MountOperationClass o => o -> MountOperation toMountOperation = unsafeCastGObject . toGObject instance MountOperationClass MountOperation instance GObjectClass MountOperation where toGObject = GObject . castForeignPtr . unMountOperation unsafeCastGObject = MountOperation . castForeignPtr . unGObject castToMountOperation :: GObjectClass obj => obj -> MountOperation castToMountOperation = castTo gTypeMountOperation "MountOperation" gTypeMountOperation :: GType gTypeMountOperation = {# call fun unsafe g_mount_operation_get_type #} -- ***************************************************************** ThemedIcon {#pointer *GThemedIcon as ThemedIcon foreign newtype #} deriving (Eq,Ord) mkThemedIcon = (ThemedIcon, objectUnref) unThemedIcon (ThemedIcon o) = o class GObjectClass o => ThemedIconClass o toThemedIcon :: ThemedIconClass o => o -> ThemedIcon toThemedIcon = unsafeCastGObject . toGObject instance ThemedIconClass ThemedIcon instance GObjectClass ThemedIcon where toGObject = GObject . castForeignPtr . unThemedIcon unsafeCastGObject = ThemedIcon . castForeignPtr . unGObject castToThemedIcon :: GObjectClass obj => obj -> ThemedIcon castToThemedIcon = castTo gTypeThemedIcon "ThemedIcon" gTypeThemedIcon :: GType gTypeThemedIcon = {# call fun unsafe g_themed_icon_get_type #} -- ********************************************************************* Emblem {#pointer *GEmblem as Emblem foreign newtype #} deriving (Eq,Ord) mkEmblem = (Emblem, objectUnref) unEmblem (Emblem o) = o class GObjectClass o => EmblemClass o toEmblem :: EmblemClass o => o -> Emblem toEmblem = unsafeCastGObject . toGObject instance EmblemClass Emblem instance GObjectClass Emblem where toGObject = GObject . castForeignPtr . unEmblem unsafeCastGObject = Emblem . castForeignPtr . unGObject castToEmblem :: GObjectClass obj => obj -> Emblem castToEmblem = castTo gTypeEmblem "Emblem" gTypeEmblem :: GType gTypeEmblem = {# call fun unsafe g_emblem_get_type #} -- *************************************************************** EmblemedIcon {#pointer *GEmblemedIcon as EmblemedIcon foreign newtype #} deriving (Eq,Ord) mkEmblemedIcon = (EmblemedIcon, objectUnref) unEmblemedIcon (EmblemedIcon o) = o class GObjectClass o => EmblemedIconClass o toEmblemedIcon :: EmblemedIconClass o => o -> EmblemedIcon toEmblemedIcon = unsafeCastGObject . toGObject instance EmblemedIconClass EmblemedIcon instance GObjectClass EmblemedIcon where toGObject = GObject . castForeignPtr . unEmblemedIcon unsafeCastGObject = EmblemedIcon . castForeignPtr . unGObject castToEmblemedIcon :: GObjectClass obj => obj -> EmblemedIcon castToEmblemedIcon = castTo gTypeEmblemedIcon "EmblemedIcon" gTypeEmblemedIcon :: GType gTypeEmblemedIcon = {# call fun unsafe g_emblemed_icon_get_type #} -- ************************************************************* FileEnumerator {#pointer *GFileEnumerator as FileEnumerator foreign newtype #} deriving (Eq,Ord) mkFileEnumerator = (FileEnumerator, objectUnref) unFileEnumerator (FileEnumerator o) = o class GObjectClass o => FileEnumeratorClass o toFileEnumerator :: FileEnumeratorClass o => o -> FileEnumerator toFileEnumerator = unsafeCastGObject . toGObject instance FileEnumeratorClass FileEnumerator instance GObjectClass FileEnumerator where toGObject = GObject . castForeignPtr . unFileEnumerator unsafeCastGObject = FileEnumerator . castForeignPtr . unGObject castToFileEnumerator :: GObjectClass obj => obj -> FileEnumerator castToFileEnumerator = castTo gTypeFileEnumerator "FileEnumerator" gTypeFileEnumerator :: GType gTypeFileEnumerator = {# call fun unsafe g_file_enumerator_get_type #} -- ********************************************************** FilenameCompleter {#pointer *GFilenameCompleter as FilenameCompleter foreign newtype #} deriving (Eq,Ord) mkFilenameCompleter = (FilenameCompleter, objectUnref) unFilenameCompleter (FilenameCompleter o) = o class GObjectClass o => FilenameCompleterClass o toFilenameCompleter :: FilenameCompleterClass o => o -> FilenameCompleter toFilenameCompleter = unsafeCastGObject . toGObject instance FilenameCompleterClass FilenameCompleter instance GObjectClass FilenameCompleter where toGObject = GObject . castForeignPtr . unFilenameCompleter unsafeCastGObject = FilenameCompleter . castForeignPtr . unGObject castToFilenameCompleter :: GObjectClass obj => obj -> FilenameCompleter castToFilenameCompleter = castTo gTypeFilenameCompleter "FilenameCompleter" gTypeFilenameCompleter :: GType gTypeFilenameCompleter = {# call fun unsafe g_filename_completer_get_type #} -- ******************************************************************* FileIcon {#pointer *GFileIcon as FileIcon foreign newtype #} deriving (Eq,Ord) mkFileIcon = (FileIcon, objectUnref) unFileIcon (FileIcon o) = o class GObjectClass o => FileIconClass o toFileIcon :: FileIconClass o => o -> FileIcon toFileIcon = unsafeCastGObject . toGObject instance FileIconClass FileIcon instance GObjectClass FileIcon where toGObject = GObject . castForeignPtr . unFileIcon unsafeCastGObject = FileIcon . castForeignPtr . unGObject castToFileIcon :: GObjectClass obj => obj -> FileIcon castToFileIcon = castTo gTypeFileIcon "FileIcon" gTypeFileIcon :: GType gTypeFileIcon = {# call fun unsafe g_file_icon_get_type #} -- ************************************************************** VolumeMonitor {#pointer *GVolumeMonitor as VolumeMonitor foreign newtype #} deriving (Eq,Ord) mkVolumeMonitor = (VolumeMonitor, objectUnref) unVolumeMonitor (VolumeMonitor o) = o class GObjectClass o => VolumeMonitorClass o toVolumeMonitor :: VolumeMonitorClass o => o -> VolumeMonitor toVolumeMonitor = unsafeCastGObject . toGObject instance VolumeMonitorClass VolumeMonitor instance GObjectClass VolumeMonitor where toGObject = GObject . castForeignPtr . unVolumeMonitor unsafeCastGObject = VolumeMonitor . castForeignPtr . unGObject castToVolumeMonitor :: GObjectClass obj => obj -> VolumeMonitor castToVolumeMonitor = castTo gTypeVolumeMonitor "VolumeMonitor" gTypeVolumeMonitor :: GType gTypeVolumeMonitor = {# call fun unsafe g_volume_monitor_get_type #} -- **************************************************************** Cancellable {#pointer *GCancellable as Cancellable foreign newtype #} deriving (Eq,Ord) mkCancellable = (Cancellable, objectUnref) unCancellable (Cancellable o) = o class GObjectClass o => CancellableClass o toCancellable :: CancellableClass o => o -> Cancellable toCancellable = unsafeCastGObject . toGObject instance CancellableClass Cancellable instance GObjectClass Cancellable where toGObject = GObject . castForeignPtr . unCancellable unsafeCastGObject = Cancellable . castForeignPtr . unGObject castToCancellable :: GObjectClass obj => obj -> Cancellable castToCancellable = castTo gTypeCancellable "Cancellable" gTypeCancellable :: GType gTypeCancellable = {# call fun unsafe g_cancellable_get_type #} -- ********************************************************** SimpleAsyncResult {#pointer *GSimpleAsyncResult as SimpleAsyncResult foreign newtype #} deriving (Eq,Ord) mkSimpleAsyncResult = (SimpleAsyncResult, objectUnref) unSimpleAsyncResult (SimpleAsyncResult o) = o class GObjectClass o => SimpleAsyncResultClass o toSimpleAsyncResult :: SimpleAsyncResultClass o => o -> SimpleAsyncResult toSimpleAsyncResult = unsafeCastGObject . toGObject instance SimpleAsyncResultClass SimpleAsyncResult instance GObjectClass SimpleAsyncResult where toGObject = GObject . castForeignPtr . unSimpleAsyncResult unsafeCastGObject = SimpleAsyncResult . castForeignPtr . unGObject castToSimpleAsyncResult :: GObjectClass obj => obj -> SimpleAsyncResult castToSimpleAsyncResult = castTo gTypeSimpleAsyncResult "SimpleAsyncResult" gTypeSimpleAsyncResult :: GType gTypeSimpleAsyncResult = {# call fun unsafe g_async_result_get_type #} -- ******************************************************************* FileInfo {#pointer *GFileInfo as FileInfo foreign newtype #} deriving (Eq,Ord) mkFileInfo = (FileInfo, objectUnref) unFileInfo (FileInfo o) = o class GObjectClass o => FileInfoClass o toFileInfo :: FileInfoClass o => o -> FileInfo toFileInfo = unsafeCastGObject . toGObject instance FileInfoClass FileInfo instance GObjectClass FileInfo where toGObject = GObject . castForeignPtr . unFileInfo unsafeCastGObject = FileInfo . castForeignPtr . unGObject castToFileInfo :: GObjectClass obj => obj -> FileInfo castToFileInfo = castTo gTypeFileInfo "FileInfo" gTypeFileInfo :: GType gTypeFileInfo = {# call fun unsafe g_file_info_get_type #} -- *********************************************************** AppLaunchContext {#pointer *GAppLaunchContext as AppLaunchContext foreign newtype #} deriving (Eq,Ord) mkAppLaunchContext = (AppLaunchContext, objectUnref) unAppLaunchContext (AppLaunchContext o) = o class FileInfoClass o => AppLaunchContextClass o toAppLaunchContext :: AppLaunchContextClass o => o -> AppLaunchContext toAppLaunchContext = unsafeCastGObject . toGObject instance AppLaunchContextClass AppLaunchContext instance FileInfoClass AppLaunchContext instance GObjectClass AppLaunchContext where toGObject = GObject . castForeignPtr . unAppLaunchContext unsafeCastGObject = AppLaunchContext . castForeignPtr . unGObject castToAppLaunchContext :: GObjectClass obj => obj -> AppLaunchContext castToAppLaunchContext = castTo gTypeAppLaunchContext "AppLaunchContext" gTypeAppLaunchContext :: GType gTypeAppLaunchContext = {# call fun unsafe g_app_launch_context_get_type #} -- *********************************************************************** Icon {#pointer *GIcon as Icon foreign newtype #} deriving (Eq,Ord) mkIcon = (Icon, objectUnref) unIcon (Icon o) = o class GObjectClass o => IconClass o toIcon :: IconClass o => o -> Icon toIcon = unsafeCastGObject . toGObject instance IconClass Icon instance GObjectClass Icon where toGObject = GObject . castForeignPtr . unIcon unsafeCastGObject = Icon . castForeignPtr . unGObject castToIcon :: GObjectClass obj => obj -> Icon castToIcon = castTo gTypeIcon "Icon" gTypeIcon :: GType gTypeIcon = {# call fun unsafe g_icon_get_type #} -- ******************************************************************* Seekable {#pointer *GSeekable as Seekable foreign newtype #} deriving (Eq,Ord) mkSeekable = (Seekable, objectUnref) unSeekable (Seekable o) = o class GObjectClass o => SeekableClass o toSeekable :: SeekableClass o => o -> Seekable toSeekable = unsafeCastGObject . toGObject instance SeekableClass Seekable instance GObjectClass Seekable where toGObject = GObject . castForeignPtr . unSeekable unsafeCastGObject = Seekable . castForeignPtr . unGObject castToSeekable :: GObjectClass obj => obj -> Seekable castToSeekable = castTo gTypeSeekable "Seekable" gTypeSeekable :: GType gTypeSeekable = {# call fun unsafe g_seekable_get_type #} -- ******************************************************************** AppInfo {#pointer *GAppInfo as AppInfo foreign newtype #} deriving (Eq,Ord) mkAppInfo = (AppInfo, objectUnref) unAppInfo (AppInfo o) = o class GObjectClass o => AppInfoClass o toAppInfo :: AppInfoClass o => o -> AppInfo toAppInfo = unsafeCastGObject . toGObject instance AppInfoClass AppInfo instance GObjectClass AppInfo where toGObject = GObject . castForeignPtr . unAppInfo unsafeCastGObject = AppInfo . castForeignPtr . unGObject castToAppInfo :: GObjectClass obj => obj -> AppInfo castToAppInfo = castTo gTypeAppInfo "AppInfo" gTypeAppInfo :: GType gTypeAppInfo = {# call fun unsafe g_app_info_get_type #} -- ********************************************************************* Volume {#pointer *GVolume as Volume foreign newtype #} deriving (Eq,Ord) mkVolume = (Volume, objectUnref) unVolume (Volume o) = o class GObjectClass o => VolumeClass o toVolume :: VolumeClass o => o -> Volume toVolume = unsafeCastGObject . toGObject instance VolumeClass Volume instance GObjectClass Volume where toGObject = GObject . castForeignPtr . unVolume unsafeCastGObject = Volume . castForeignPtr . unGObject castToVolume :: GObjectClass obj => obj -> Volume castToVolume = castTo gTypeVolume "Volume" gTypeVolume :: GType gTypeVolume = {# call fun unsafe g_volume_get_type #} -- **************************************************************** AsyncResult {#pointer *GAsyncResult as AsyncResult foreign newtype #} deriving (Eq,Ord) mkAsyncResult = (AsyncResult, objectUnref) unAsyncResult (AsyncResult o) = o class GObjectClass o => AsyncResultClass o toAsyncResult :: AsyncResultClass o => o -> AsyncResult toAsyncResult = unsafeCastGObject . toGObject instance AsyncResultClass AsyncResult instance GObjectClass AsyncResult where toGObject = GObject . castForeignPtr . unAsyncResult unsafeCastGObject = AsyncResult . castForeignPtr . unGObject castToAsyncResult :: GObjectClass obj => obj -> AsyncResult castToAsyncResult = castTo gTypeAsyncResult "AsyncResult" gTypeAsyncResult :: GType gTypeAsyncResult = {# call fun unsafe g_async_result_get_type #} -- *************************************************************** LoadableIcon {#pointer *GLoadableIcon as LoadableIcon foreign newtype #} deriving (Eq,Ord) mkLoadableIcon = (LoadableIcon, objectUnref) unLoadableIcon (LoadableIcon o) = o class GObjectClass o => LoadableIconClass o toLoadableIcon :: LoadableIconClass o => o -> LoadableIcon toLoadableIcon = unsafeCastGObject . toGObject instance LoadableIconClass LoadableIcon instance GObjectClass LoadableIcon where toGObject = GObject . castForeignPtr . unLoadableIcon unsafeCastGObject = LoadableIcon . castForeignPtr . unGObject castToLoadableIcon :: GObjectClass obj => obj -> LoadableIcon castToLoadableIcon = castTo gTypeLoadableIcon "LoadableIcon" gTypeLoadableIcon :: GType gTypeLoadableIcon = {# call fun unsafe g_loadable_icon_get_type #} -- ********************************************************************** Drive {#pointer *GDrive as Drive foreign newtype #} deriving (Eq,Ord) mkDrive = (Drive, objectUnref) unDrive (Drive o) = o class GObjectClass o => DriveClass o toDrive :: DriveClass o => o -> Drive toDrive = unsafeCastGObject . toGObject instance DriveClass Drive instance GObjectClass Drive where toGObject = GObject . castForeignPtr . unDrive unsafeCastGObject = Drive . castForeignPtr . unGObject castToDrive :: GObjectClass obj => obj -> Drive castToDrive = castTo gTypeDrive "Drive" gTypeDrive :: GType gTypeDrive = {# call fun unsafe g_drive_get_type #} -- *********************************************************************** File {#pointer *GFile as File foreign newtype #} mkFile = (File, objectUnref) unFile (File o) = o class GObjectClass o => FileClass o toFile :: FileClass o => o -> File toFile = unsafeCastGObject . toGObject instance FileClass File instance GObjectClass File where toGObject = GObject . castForeignPtr . unFile unsafeCastGObject = File . castForeignPtr . unGObject castToFile :: GObjectClass obj => obj -> File castToFile = castTo gTypeFile "File" gTypeFile :: GType gTypeFile = {# call fun unsafe g_file_get_type #} -- ********************************************************************** Mount {#pointer *GMount as Mount foreign newtype #} deriving (Eq,Ord) mkMount = (Mount, objectUnref) unMount (Mount o) = o class GObjectClass o => MountClass o toMount :: MountClass o => o -> Mount toMount = unsafeCastGObject . toGObject instance MountClass Mount instance GObjectClass Mount where toGObject = GObject . castForeignPtr . unMount unsafeCastGObject = Mount . castForeignPtr . unGObject castToMount :: GObjectClass obj => obj -> Mount castToMount = castTo gTypeMount "Mount" gTypeMount :: GType gTypeMount = {# call fun unsafe g_mount_get_type #} gio-0.13.1.0/System/GIO/Async/0000755000000000000000000000000012507510337013660 5ustar0000000000000000gio-0.13.1.0/System/GIO/Async/AsyncResult.chs0000644000000000000000000000410312507510337016631 0ustar0000000000000000{-# LANGUAGE CPP #-} -- GIMP Toolkit (GTK) Binding for Haskell: binding to gio -*-haskell-*- -- -- Author : Peter Gavin -- Created: 13-Oct-2008 -- -- Copyright (c) 2008 Peter Gavin -- -- This library is free software: you can redistribute it and/or -- modify it under the terms of the GNU Lesser General Public License -- as published by the Free Software Foundation, either version 3 of -- the License, or (at your option) any later version. -- -- This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public -- License along with this program. If not, see -- . -- -- GIO, the C library which this Haskell library depends on, is -- available under LGPL Version 2. The documentation included with -- this library is based on the original GIO documentation. -- -- | Maintainer : gtk2hs-devel@lists.sourceforge.net -- Stability : alpha -- Portability : portable (depends on GHC) module System.GIO.Async.AsyncResult ( -- * Types AsyncResult, AsyncResultClass, AsyncReadyCallback, -- * Methods marshalAsyncReadyCallback, ) where import Control.Monad import System.Glib.FFI import System.Glib.GObject {#import System.GIO.Types#} type AsyncReadyCallback = GObject -> AsyncResult -> IO () {#pointer GAsyncReadyCallback#} foreign import ccall "wrapper" mkAsyncReadyCallback :: (Ptr () -> Ptr AsyncResult -> Ptr () -> IO ()) -> IO GAsyncReadyCallback marshalAsyncReadyCallback :: AsyncReadyCallback -> IO GAsyncReadyCallback marshalAsyncReadyCallback asyncReadyCallback = mkAsyncReadyCallback $ \ cObject cAsyncResult cCallback -> do object <- (makeNewGObject mkGObject . return) (castPtr cObject) asyncResult <- (makeNewGObject mkAsyncResult . return) cAsyncResult asyncReadyCallback object asyncResult freeHaskellFunPtr (castPtrToFunPtr cCallback) gio-0.13.1.0/System/GIO/Async/Cancellable.chs0000644000000000000000000001370712507510337016554 0ustar0000000000000000{-# LANGUAGE CPP #-} -- GIMP Toolkit (GTK) Binding for Haskell: binding to gio -*-haskell-*- -- -- Author : Peter Gavin -- Created: 13-Oct-2008 -- -- Copyright (c) 2008 Peter Gavin -- -- This library is free software: you can redistribute it and/or -- modify it under the terms of the GNU Lesser General Public License -- as published by the Free Software Foundation, either version 3 of -- the License, or (at your option) any later version. -- -- This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public -- License along with this program. If not, see -- . -- -- GIO, the C library which this Haskell library depends on, is -- available under LGPL Version 2. The documentation included with -- this library is based on the original GIO documentation. -- -- | Maintainer : gtk2hs-devel@lists.sourceforge.net -- Stability : alpha -- Portability : portable (depends on GHC) module System.GIO.Async.Cancellable ( -- * Details -- | 'Cancellable' is a thread-safe operation cancellation stack used throughout GIO to allow for -- cancellation of synchronous and asynchronous operations. -- * Types Cancellable (..), CancellableClass, -- * Methods cancellableNew, cancellableIsCancelled, cancellableThrowErrorIfCancelled, cancellableGetCurrent, cancellablePopCurrent, cancellablePushCurrent, cancellableReset, cancellableCancel, -- * Signals cancellableCancelled ) where import Control.Monad import Data.Maybe (fromMaybe) import System.Glib.FFI import System.Glib.GError import System.Glib.GObject import System.Glib.Signals {#import System.GIO.Signals#} {#import System.GIO.Types#} {# context lib = "gio" prefix = "g" #} -- | Creates a new 'Cancellable' object. -- -- Applications that want to start one or more operations that should be cancellable should create a -- 'Cancellable' and pass it to the operations. -- -- One 'Cancellable' can be used in multiple consecutive operations, but not in multiple concurrent -- operations. cancellableNew :: IO Cancellable cancellableNew = wrapNewGObject mkCancellable $ {# call cancellable_new #} -- | Checks if a cancellable job has been cancelled. cancellableIsCancelled :: Cancellable -> IO Bool -- ^ returns 'True' if cancellable is cancelled, 'False' if called with 'Nothing' or if item is not cancelled. cancellableIsCancelled = liftM toBool . {# call cancellable_is_cancelled #} -- | If the cancellable is cancelled, throws a 'GError' to notify that the operation was cancelled. cancellableThrowErrorIfCancelled :: Cancellable -> IO () cancellableThrowErrorIfCancelled cancellable = propagateGError $ \gErrorPtr -> do {# call cancellable_set_error_if_cancelled #} cancellable gErrorPtr return () -- | Gets the top cancellable from the stack. cancellableGetCurrent :: IO (Maybe Cancellable) -- ^ returns a 'Cancellable' from the top of the stack, or 'Nothing' if the stack is empty. cancellableGetCurrent = maybeNull (makeNewGObject mkCancellable) $ {# call cancellable_get_current #} -- | Pops cancellable off the cancellable stack (verifying that cancellable is on the top of the stack). cancellablePopCurrent :: Maybe Cancellable -> IO () cancellablePopCurrent cancellable = {# call cancellable_pop_current #} (fromMaybe (Cancellable nullForeignPtr) cancellable) -- | Pushes cancellable onto the cancellable stack. The current cancllable can then be recieved using -- 'cancellableGetCurrent' . -- -- This is useful when implementing cancellable operations in code that does not allow you to pass down -- the cancellable object. -- -- This is typically called automatically by e.g. 'File' operations, so you rarely have to call this -- yourself. cancellablePushCurrent :: Maybe Cancellable -> IO () cancellablePushCurrent cancellable = {# call cancellable_push_current #} (fromMaybe (Cancellable nullForeignPtr) cancellable) -- | Resets cancellable to its uncancelled state. cancellableReset :: Cancellable -> IO () cancellableReset = {# call cancellable_reset #} -- | Will set cancellable to cancelled, and will emit the "cancelled" signal. (However, see the warning -- about race conditions in the documentation for that signal if you are planning to connect to it.) -- -- This function is thread-safe. In other words, you can safely call it from a thread other than the -- one running the operation that was passed the cancellable. -- -- The convention within gio is that cancelling an asynchronous operation causes it to complete -- asynchronously. That is, if you cancel the operation from the same thread in which it is running, -- then the operation's 'AsyncReadyCallback' will not be invoked until the application returns to the -- main loop. cancellableCancel :: Cancellable -> IO () cancellableCancel = {# call cancellable_cancel #} -- | Emitted when the operation has been cancelled. -- -- Can be used by implementations of cancellable operations. If the operation is cancelled from another -- thread, the signal will be emitted in the thread that cancelled the operation, not the thread that -- is running the operation. -- -- Note that disconnecting from this signal (or any signal) in a multi-threaded program is prone to -- race conditions. For instance it is possible that a signal handler may be invoked even after a call -- to 'signalHandlerDisconnect' for that handler has already returned. -- -- There is also a problem when cancellation happen right before connecting to the signal. If this -- happens the signal will unexpectedly not be emitted, and checking before connecting to the signal -- leaves a race condition where this is still happening. cancellableCancelled :: Signal Cancellable (IO ()) cancellableCancelled = Signal $ connect_NONE__NONE "cancelled" gio-0.13.1.0/System/GIO/File/0000755000000000000000000000000012507510337013462 5ustar0000000000000000gio-0.13.1.0/System/GIO/File/AppInfo.chs0000644000000000000000000005215712507510337015527 0ustar0000000000000000{-# LANGUAGE CPP #-} -- GIMP Toolkit (GTK) Binding for Haskell: binding to gio -*-haskell-*- -- -- Author : Andy Stewart -- Created: 30-Apirl-2010 -- -- Copyright (c) 2010 Andy Stewart -- -- This library is free software: you can redistribute it and/or -- modify it under the terms of the GNU Lesser General Public License -- as published by the Free Software Foundation, either version 3 of -- the License, or (at your option) any later version. -- -- This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public -- License along with this program. If not, see -- . -- -- GIO, the C library which this Haskell library depends on, is -- available under LGPL Version 2. The documentation included with -- this library is based on the original GIO documentation. -- -- | Maintainer : gtk2hs-devel@lists.sourceforge.net -- Stability : alpha -- Portability : portable (depends on GHC) module System.GIO.File.AppInfo ( -- * Details -- | 'AppInfo' and 'AppLaunchContext' are used for describing and launching applications installed on the -- system. -- -- As of GLib 2.20, URIs will always be converted to POSIX paths (using 'fileGetPath' when using -- 'appInfoLaunch' even if the application requested an URI and not a POSIX path. For example for -- an desktop-file based application with Exec key totem %U and a single URI, sftp://foo/file.avi, then -- /home/user/.gvfs/sftp on foo/file.avi will be passed. This will only work if a set of suitable GIO -- extensions (such as gvfs 2.26 compiled with FUSE support), is available and operational; if this is -- not the case, the URI will be passed unmodified to the application. Some URIs, such as mailto:, of -- course cannot be mapped to a POSIX path (in gvfs there's no FUSE mount for it); such URIs will be -- passed unmodified to the application. -- -- Specifically for gvfs 2.26 and later, the POSIX URI will be mapped back to the GIO URI in the 'File' -- constructors (since gvfs implements the GVfs extension point). As such, if the application needs to -- examine the URI, it needs to use 'fileGetUri' or similar on 'File'. In other words, an -- application cannot assume that the URI passed to e.g. 'fileNewForCommandlineArg ' is equal to -- the result of 'fileGetUri'. -- * Types AppInfo, AppInfoClass, AppLaunchContext, AppLaunchContextClass, -- * Enums AppInfoCreateFlags (..), -- * Methods appInfoCreateFromCommandline, appInfoDup, appInfoEqual, appInfoGetId, appInfoGetName, #if GLIB_CHECK_VERSION(2,24,0) appInfoGetDisplayName, #endif appInfoGetDescription, appInfoGetExecutable, #if GLIB_CHECK_VERSION(2,20,0) appInfoGetCommandline, #endif appInfoGetIcon, appInfoLaunch, appInfoSupportsFiles, appInfoSupportsUris, appInfoLaunchUris, appInfoShouldShow, #if GLIB_CHECK_VERSION(2,20,0) appInfoCanDelete, appInfoDelete, appInfoResetTypeAssociations, #endif appInfoSetAsDefaultForType, appInfoSetAsDefaultForExtension, appInfoAddSupportsType, appInfoCanRemoveSupportsType, appInfoRemoveSupportsType, appInfoGetAll, appInfoGetAllForType, appInfoGetDefaultForType, appInfoGetDefaultForUriScheme, appInfoLaunchDefaultForUri, appLaunchContextGetDisplay, appLaunchContextGetStartupNotifyId, appLaunchContextLaunchFailed, appLaunchContextNew ) where import Control.Monad import Data.Maybe (fromMaybe) import Data.ByteString (ByteString) import Data.ByteString.Unsafe (unsafePackCStringFinalizer) import System.GIO.Enums import System.Glib.FFI import System.Glib.Flags import System.Glib.GError import System.Glib.GList import System.Glib.GObject import System.Glib.UTFString {#import System.GIO.Types#} {# context lib = "gio" prefix = "g" #} -- | Creates a new 'AppInfo' from the given information. appInfoCreateFromCommandline :: GlibString string => string -- ^ @commandline@ the commandline to use -> Maybe string -- ^ @applicationName@ the application name, or 'Nothing' to use commandline -> [AppInfoCreateFlags] -- ^ @flags@ flags that can specify details of the created 'AppInfo' -> IO AppInfo -- ^ returns new 'AppInfo' for given command. appInfoCreateFromCommandline commandline applicationName flags = wrapNewGObject mkAppInfo $ withUTFString commandline $ \ commandlinePtr -> maybeWith withUTFString applicationName $ \ applicationNamePtr -> propagateGError ({#call g_app_info_create_from_commandline #} commandlinePtr applicationNamePtr ((fromIntegral . fromFlags) flags)) -- | Creates a duplicate of a 'AppInfo'. appInfoDup :: AppInfoClass appinfo => appinfo -> IO AppInfo appInfoDup appinfo = wrapNewGObject mkAppInfo $ {#call g_app_info_dup #} (toAppInfo appinfo) -- | Checks if two 'AppInfo's are equal. appInfoEqual :: (AppInfoClass info1, AppInfoClass info2) => info1 -> info2 -> Bool -- ^ returns 'True' if appinfo1 is equal to appinfo2. 'False' otherwise. appInfoEqual info1 info2 = unsafePerformIO $ liftM toBool $ {#call g_app_info_equal #} (toAppInfo info1) (toAppInfo info2) -- | Gets the ID of an application. An id is a string that identifies the application. The exact format -- of the id is platform dependent. For instance, on Unix this is the desktop file id from the xdg menu -- specification. -- -- Note that the returned ID may be 'Nothing', depending on how the appinfo has been constructed. appInfoGetId :: (AppInfoClass appinfo, GlibString string) => appinfo -> IO (Maybe string) appInfoGetId appinfo = {#call g_app_info_get_id#} (toAppInfo appinfo) >>= maybePeek readUTFString -- | Gets the installed name of the application. appInfoGetName :: AppInfoClass appinfo => appinfo -> String -- ^ returns the name of the application for appinfo. appInfoGetName appinfo = unsafePerformIO $ {#call g_app_info_get_name#} (toAppInfo appinfo) >>= readCString #if GLIB_CHECK_VERSION(2,24,0) -- | Gets the installed name of the application. appInfoGetDisplayName :: (AppInfoClass appinfo, GlibString string) => appinfo -> string -- ^ returns the display name of the application for appinfo, or the name if no display name is available. appInfoGetDisplayName appinfo = unsafePerformIO $ {#call g_app_info_get_display_name#} (toAppInfo appinfo) >>= readUTFString #endif -- | Gets a human-readable description of an installed application. appInfoGetDescription :: (AppInfoClass appinfo, GlibString string) => appinfo -> Maybe string -- ^ returns a string containing a description of the application appinfo, or 'Nothing' if none. appInfoGetDescription appinfo = unsafePerformIO $ do {#call g_app_info_get_description#} (toAppInfo appinfo) >>= maybePeek peekUTFString -- | Gets the executable's name for the installed application. appInfoGetExecutable :: (AppInfoClass appinfo, GlibString string) => appinfo -> string -- ^ returns the executable of the application for appinfo. appInfoGetExecutable appinfo = unsafePerformIO $ {#call g_app_info_get_executable#} (toAppInfo appinfo) >>= peekUTFString #if GLIB_CHECK_VERSION(2,20,0) -- | Gets the commandline with which the application will be started. appInfoGetCommandline :: AppInfoClass appinfo => appinfo -> Maybe ByteString -- ^ returns a string containing the appinfo's commandline, or 'Nothing' if this information is not available appInfoGetCommandline appinfo = unsafePerformIO $ do sPtr <- {#call g_app_info_get_commandline#} (toAppInfo appinfo) if sPtr == nullPtr then return Nothing else do sLen <- lengthArray0 0 sPtr liftM Just $ unsafePackCStringFinalizer (castPtr sPtr) (fromIntegral sLen) ({#call unsafe g_free#} (castPtr sPtr)) #endif -- | Gets the icon for the application. appInfoGetIcon :: AppInfoClass appinfo => appinfo -> IO (Maybe Icon) -- ^ returns the default 'Icon' for appinfo or 'Nothing' appInfoGetIcon appinfo = maybeNull (makeNewGObject mkIcon) $ {#call g_app_info_get_icon#} (toAppInfo appinfo) -- | Launches the application. Passes files to the launched application as arguments, using the optional -- @launchContext@ to get information about the details of the launcher (like what screen it is on). -- Throws a 'GError' if an error occurs -- -- To lauch the application without arguments pass a emtpy files list. -- -- Note that even if the launch is successful the application launched can fail to start if it runs -- into problems during startup. There is no way to detect this. -- -- Some URIs can be changed when passed through a 'File' (for instance unsupported uris with strange -- formats like mailto:), so if you have a textual uri you want to pass in as argument, consider using -- 'appInfoLaunchUris' instead. appInfoLaunch :: AppInfoClass appinfo => appinfo -> [File] -- ^ @files@ a list of 'File' objects -> Maybe AppLaunchContext -- ^ @launchContext@ a 'AppLaunchContext' or 'Nothing' -> IO () appInfoLaunch appinfo files launchContext = withForeignPtrs (map unFile files) $ \wFilePtr -> withGList wFilePtr $ \filesPtr -> propagateGError (\gErrorPtr -> do {#call g_app_info_launch#} (toAppInfo appinfo) filesPtr (fromMaybe (AppLaunchContext nullForeignPtr) launchContext) gErrorPtr return ()) -- | Checks if the application accepts files as arguments. appInfoSupportsFiles :: AppInfoClass appinfo => appinfo -> IO Bool -- ^ returns 'True' if the appinfo supports files. appInfoSupportsFiles appinfo = liftM toBool $ {#call g_app_info_supports_files #} (toAppInfo appinfo) -- | Checks if the application accepts uris as arguments. appInfoSupportsUris :: AppInfoClass appinfo => appinfo -> IO Bool -- ^ returns 'True' if the appinfo supports uris. appInfoSupportsUris appinfo = liftM toBool $ {#call g_app_info_supports_uris #} (toAppInfo appinfo) -- | Launches the application. Passes uris to the launched application as arguments, using the optional -- @launchContext@ to get information about the details of the launcher (like what screen it is on). -- Throws a 'GError' if an error occurs. -- -- To lauch the application without arguments pass a empty uris list. -- -- Note that even if the launch is successful the application launched can fail to start if it runs -- into problems during startup. There is no way to detect this. appInfoLaunchUris :: (AppInfoClass appinfo, GlibString string) => appinfo -> [string] -- ^ @uris@ a list containing URIs to launch. -> Maybe AppLaunchContext -- ^ @launchContext@ a 'AppLaunchContext' or 'Nothing' -> IO () appInfoLaunchUris appinfo uris launchContext = withUTFStringArray uris $ \urisPtr -> propagateGError (\gErrorPtr -> do {#call g_app_info_launch_uris#} (toAppInfo appinfo) (castPtr urisPtr) (fromMaybe (AppLaunchContext nullForeignPtr) launchContext) gErrorPtr return ()) -- | Checks if the application info should be shown in menus that list available applications. appInfoShouldShow :: AppInfoClass appinfo => appinfo -> IO Bool -- ^ returns 'True' if the appinfo should be shown, 'False' otherwise. appInfoShouldShow appinfo = liftM toBool $ {#call g_app_info_should_show#} (toAppInfo appinfo) #if GLIB_CHECK_VERSION(2,20,0) -- | Obtains the information whether the 'AppInfo' can be deleted. See 'appInfoDelete'. appInfoCanDelete :: AppInfoClass appinfo => appinfo -> IO Bool -- ^ returns 'True' if appinfo can be deleted appInfoCanDelete appinfo = liftM toBool $ {#call g_app_info_can_delete#} (toAppInfo appinfo) -- | Tries to delete a 'AppInfo'. -- -- On some platforms, there may be a difference between user-defined 'AppInfo's which can be deleted, -- and system-wide ones which cannot. See 'appInfoCanDelete'. appInfoDelete :: AppInfoClass appinfo => appinfo -> IO Bool -- ^ returns 'True' if appinfo has been deleted appInfoDelete appinfo = liftM toBool $ {#call g_app_info_delete#} (toAppInfo appinfo) -- | Removes all changes to the type associations done by 'appInfoSetAsDefaultForType', -- 'appInfoSetAsDefaultForExtension' or -- 'appInfoRemoveSupportsType'. appInfoResetTypeAssociations :: GlibString string => string -- ^ @contentType@ a content type -> IO () appInfoResetTypeAssociations contentType = withUTFString contentType $ \ contentTypePtr -> {#call g_app_info_reset_type_associations#} (castPtr contentTypePtr) #endif -- | Sets the application as the default handler for a given type. -- Throws a 'GError' if an error occurs. appInfoSetAsDefaultForType :: (AppInfoClass appinfo, GlibString string) => appinfo -> string -- ^ @contentType@ the content type. -> IO () appInfoSetAsDefaultForType appinfo contentType = withUTFString contentType $ \ contentTypePtr -> propagateGError (\gErrorPtr -> do {#call g_app_info_set_as_default_for_type#} (toAppInfo appinfo) (castPtr contentTypePtr) gErrorPtr return ()) -- | Sets the application as the default handler for a given extension. -- Throws a 'GError' if an error occurs. appInfoSetAsDefaultForExtension :: (AppInfoClass appinfo, GlibString string) => appinfo -> string -- ^ @extension@ a string containing the file extension (without the dot). -> IO () appInfoSetAsDefaultForExtension appinfo extension = withUTFString extension $ \ extensionPtr -> propagateGError (\gErrorPtr -> do {#call g_app_info_set_as_default_for_extension #} (toAppInfo appinfo) (castPtr extensionPtr) gErrorPtr return ()) -- | Adds a content type to the application information to indicate the application is capable of opening -- files with the given content type. -- Throws a 'GError' if an error occurs. appInfoAddSupportsType :: (AppInfoClass appinfo, GlibString string) => appinfo -> string -- ^ @contentType@ a string. -> IO () appInfoAddSupportsType appinfo extension = withUTFString extension $ \ extensionPtr -> propagateGError (\gErrorPtr -> do {#call g_app_info_add_supports_type#} (toAppInfo appinfo) (castPtr extensionPtr) gErrorPtr return ()) -- | Checks if a supported content type can be removed from an application. appInfoCanRemoveSupportsType :: AppInfoClass appinfo => appinfo -> IO Bool -- ^ returns 'True' if it is possible to remove supported content types from a given appinfo, 'False' if not. appInfoCanRemoveSupportsType appinfo = liftM toBool $ {#call g_app_info_can_remove_supports_type#} (toAppInfo appinfo) -- | Removes a supported type from an application, if possible. -- Throws a 'GError' if an error occurs. appInfoRemoveSupportsType :: (AppInfoClass appinfo, GlibString string) => appinfo -> string -- ^ @contentType@ a string. -> IO () appInfoRemoveSupportsType appinfo extension = withUTFString extension $ \ extensionPtr -> propagateGError (\gErrorPtr -> do {#call g_app_info_remove_supports_type#} (toAppInfo appinfo) (castPtr extensionPtr) gErrorPtr return ()) -- | Gets a list of all of the applications currently registered on this system. -- -- For desktop files, this includes applications that have NoDisplay=true set or are excluded from -- display by means of OnlyShowIn or NotShowIn. See 'appInfoShouldShow'. The returned list does -- not include applications which have the Hidden key set. appInfoGetAll :: IO [AppInfo] appInfoGetAll = do glistPtr <- {# call g_app_info_get_all #} list <- fromGList glistPtr mapM (wrapNewGObject mkAppInfo . return) list -- | Gets a list of all 'AppInfo's for a given content type. appInfoGetAllForType :: GlibString string => string -- ^ @contentType@ the content type to find a 'AppInfo' for -> IO [AppInfo] -- ^ returns list of 'AppInfo's for given @contentType@ or 'empty' on error. appInfoGetAllForType contentType = withUTFString contentType $ \ contentTypePtr -> do glistPtr <- {# call g_app_info_get_all_for_type #} (castPtr contentTypePtr) if glistPtr == nullPtr then return [] else do list <- fromGList glistPtr mapM (wrapNewGObject mkAppInfo . return) list -- | Gets the 'AppInfo' that corresponds to a given content type. appInfoGetDefaultForType :: GlibString string => string -- ^ @contentType@ the content type to find a 'AppInfo' for -> Bool -- ^ @mustSupportUris@ if 'True', the 'AppInfo' is expected to support URIs -> IO (Maybe AppInfo) -- ^ returns list of 'AppInfo's for given @contentType@ or 'Nothing' on error. appInfoGetDefaultForType contentType mustSupportUris = maybeNull (wrapNewGObject mkAppInfo) $ withUTFString contentType $ \ contentTypePtr -> do {# call g_app_info_get_default_for_type #} (castPtr contentTypePtr) (fromBool mustSupportUris) -- | Gets the default application for launching applications using this URI scheme. A URI scheme is the -- initial part of the URI, up to but not including the ':', e.g. "http", "ftp" or "sip". appInfoGetDefaultForUriScheme :: GlibString string => string -- ^ @uriScheme@ a string containing a URI scheme. -> IO (Maybe AppInfo) -- ^ returns list of 'AppInfo's for given @contentType@ or 'Nothing' on error. appInfoGetDefaultForUriScheme uriScheme = maybeNull (wrapNewGObject mkAppInfo) $ withUTFString uriScheme $ \ uriSchemePtr -> {# call g_app_info_get_default_for_uri_scheme #} (castPtr uriSchemePtr) -- | Utility function that launches the default application registered to handle the specified -- uri. Synchronous I/O is done on the uri to detect the type of the file if required. -- Throws a 'GError' if an error occurs. appInfoLaunchDefaultForUri :: GlibString string => string -- ^ @uri@ the uri to show -> AppLaunchContext -- ^ @launchContext@ an optional 'AppLaunchContext'. -> IO () appInfoLaunchDefaultForUri uri launchContext = withUTFString uri $ \ uriPtr -> propagateGError (\gErrorPtr -> do {#call g_app_info_launch_default_for_uri#} (castPtr uriPtr) launchContext gErrorPtr return ()) -- | Gets the display string for the display. This is used to ensure new applications are started on the -- same display as the launching application. appLaunchContextGetDisplay :: (AppInfoClass appinfo, GlibString string) => AppLaunchContext -> appinfo -> [File] -- ^ @files@ a list of 'File' objects -> IO string -- ^ returns a display string for the display. appLaunchContextGetDisplay launchContext appinfo files = withForeignPtrs (map unFile files) $ \wFilePtr -> withGList wFilePtr $ \filesPtr -> {#call g_app_launch_context_get_display#} (toAppLaunchContext launchContext) (toAppInfo appinfo) filesPtr >>= readUTFString -- | Initiates startup notification for the application and returns the DesktopStartupId for the -- launched operation, if supported. -- -- Startup notification IDs are defined in the FreeDesktop.Org Startup Notifications standard. appLaunchContextGetStartupNotifyId :: (AppInfoClass appinfo, GlibString string) => AppLaunchContext -> appinfo -> [File] -- ^ @files@ a list of 'File' objects -> IO (Maybe string) -- ^ returns a startup notification ID for the application, or 'Nothing' if not supported. appLaunchContextGetStartupNotifyId launchContext appinfo files = withForeignPtrs (map unFile files) $ \wFilePtr -> withGList wFilePtr $ \filesPtr -> {#call g_app_launch_context_get_startup_notify_id #} (toAppLaunchContext launchContext) (toAppInfo appinfo) filesPtr >>= maybePeek readUTFString -- | Called when an application has failed to launch, so that it can cancel the application startup -- notification started in 'appLaunchContextGetStartupNotifyId'. appLaunchContextLaunchFailed :: GlibString string => AppLaunchContext -> string -- ^ @startupNotifyId@ the startup notification id that was returned by 'appLaunchContextGetStartupNotifyId'. -> IO () appLaunchContextLaunchFailed launchContext startupNotifyId = withUTFString startupNotifyId $ \ startupNotifyIdPtr -> {#call g_app_launch_context_launch_failed#} (toAppLaunchContext launchContext) (castPtr startupNotifyIdPtr) -- | Creates a new application launch context. This is not normally used, instead you instantiate a -- subclass of this, such as 'AppLaunchContext'. appLaunchContextNew :: IO AppLaunchContext appLaunchContextNew = wrapNewGObject mkAppLaunchContext $ {#call g_app_launch_context_new#} gio-0.13.1.0/System/GIO/File/ContentType.chs0000644000000000000000000001635712507510337016451 0ustar0000000000000000{-# LANGUAGE CPP #-} -- GIMP Toolkit (GTK) Binding for Haskell: binding to gio -*-haskell-*- -- -- Author : Andy Stewart -- Created: 30-Apirl-2010 -- -- Copyright (c) 2010 Andy Stewart -- -- This library is free software: you can redistribute it and/or -- modify it under the terms of the GNU Lesser General Public License -- as published by the Free Software Foundation, either version 3 of -- the License, or (at your option) any later version. -- -- This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public -- License along with this program. If not, see -- . -- -- GIO, the C library which this Haskell library depends on, is -- available under LGPL Version 2. The documentation included with -- this library is based on the original GIO documentation. -- -- | Maintainer : gtk2hs-devel@lists.sourceforge.net -- Stability : alpha -- Portability : portable (depends on GHC) module System.GIO.File.ContentType ( -- * Details -- -- | A content type is a platform specific string that defines the type of a file. On unix it is a mime -- type, on win32 it is an extension string like ".doc", ".txt" or a percieved string like -- "audio". Such strings can be looked up in the registry at HkeyClassesRoot. -- * Methods contentTypeEquals, contentTypeIsA, contentTypeIsUnknown, contentTypeGetDescription, contentTypeGetMimeType, contentTypeGetIcon, contentTypeCanBeExecutable, #if GLIB_CHECK_VERSION(2,18,0) contentTypeFromMimeType, #endif contentTypeGuess, #if GLIB_CHECK_VERSION(2,18,0) contentTypeGuessForTree, #endif contentTypesGetRegistered, ) where import Control.Monad import System.GIO.Enums import System.Glib.FFI import System.Glib.Flags import System.Glib.GError import System.Glib.GList import System.Glib.GObject import System.Glib.UTFString {#import System.GIO.Types#} {# context lib = "gio" prefix = "g" #} -- | Compares two content types for equality. contentTypeEquals :: GlibString string => string -> string -> Bool -- ^ returns 'True' if the two strings are identical or equivalent, 'False' otherwise. contentTypeEquals type1 type2 = toBool $ unsafePerformIO $ withUTFString type1 $ \ type1Ptr -> withUTFString type2 $ \ type2Ptr -> {#call g_content_type_equals#} type1Ptr type2Ptr -- | Determines if type is a subset of supertype. contentTypeIsA :: GlibString string => string -> string -> Bool -- ^ returns 'True' if type is a kind of supertype, 'False' otherwise. contentTypeIsA type1 supertype = toBool $ unsafePerformIO $ withUTFString type1 $ \ type1Ptr -> withUTFString supertype $ \ supertypePtr -> {#call g_content_type_equals#} type1Ptr supertypePtr -- | Checks if the content type is the generic "unknown" type. On unix this is the -- "application/octet-stream" mimetype, while on win32 it is \"*\". contentTypeIsUnknown :: GlibString string => string -> Bool -- ^ returns 'True' if the type is the unknown type. contentTypeIsUnknown typ = toBool $ unsafePerformIO $ withUTFString typ $ \ typPtr -> {#call g_content_type_is_unknown#} typPtr -- | Gets the human readable description of the content type. contentTypeGetDescription :: GlibString string => string -> string -- ^ returns a short description of the content type type. contentTypeGetDescription typ = unsafePerformIO $ withUTFString typ $ \ typPtr -> {#call g_content_type_get_description#} typPtr >>= readUTFString -- | Gets the mime-type for the content type. If one is registered contentTypeGetMimeType :: GlibString string => string -> string -- ^ returns the registered mime-type for the given type, or 'Nothing' if unknown. contentTypeGetMimeType typ = unsafePerformIO $ withUTFString typ $ \ typPtr -> {#call g_content_type_get_mime_type#} typPtr >>= readUTFString -- | Gets the icon for a content type. contentTypeGetIcon :: GlibString string => string -> Icon -- ^ returns 'Icon' corresponding to the content type. contentTypeGetIcon typ = unsafePerformIO $ wrapNewGObject mkIcon $ withUTFString typ $ \ typPtr -> {#call g_content_type_get_icon#} typPtr -- | Checks if a content type can be executable. Note that for instance things like text files can be -- executables (i.e. scripts and batch files). contentTypeCanBeExecutable :: GlibString string => string -> Bool -- ^ returns 'True' if the file type corresponds to a type that can be executable, 'False' otherwise. contentTypeCanBeExecutable typ = toBool $ unsafePerformIO $ withUTFString typ $ \ typPtr -> {#call g_content_type_can_be_executable#} typPtr #if GLIB_CHECK_VERSION(2,18,0) -- | Tries to find a content type based on the mime type name. contentTypeFromMimeType :: GlibString string => string -- ^ @mimeType@ a mime type string. -> string contentTypeFromMimeType mimeType = unsafePerformIO $ withUTFString mimeType $ \ mimeTypePtr -> {#call g_content_type_from_mime_type#} mimeTypePtr >>= readUTFString #endif -- | Guesses the content type based on example data. If the function is uncertain, @resultUncertain@ will -- be set to 'True'. Either filename or data may be 'Nothing', in which case the guess will be based solely on -- the other argument. contentTypeGuess :: (GlibFilePath fp, GlibString string) => fp -> string -- ^ @data@ a stream of data, -> Int -- ^ @dataSize@ the size of data -> IO (Bool, string) -- ^ returns a string indicating a guessed content type for the given data. contentTypeGuess filename dat dataSize = withUTFFilePath filename $ \ filenamePtr -> withUTFString dat $ \ datPtr -> alloca $ \ resultUncertainPtr -> do strPtr <- {#call g_content_type_guess#} filenamePtr (castPtr datPtr) (fromIntegral dataSize) (castPtr resultUncertainPtr) resultUncertain <- peek resultUncertainPtr str <- readUTFString strPtr return (resultUncertain, str) #if GLIB_CHECK_VERSION(2,18,0) -- | Tries to guess the type of the tree with root root, by looking at the files it contains. The result -- is an array of content types, with the best guess coming first. -- -- The types returned all have the form x-content/foo, e.g. x-content/audio-cdda (for audio CDs) or -- x-content/image-dcf (for a camera memory card). See the shared-mime-info specification for more on -- x-content types. -- -- This function is useful in the implementation of 'mountGuessContentType'. contentTypeGuessForTree :: (FileClass file, GlibString string) => file -- ^ @root@ the root of the tree to guess a type for -> IO [string] -- ^ returns a list of possible content types contentTypeGuessForTree root = {#call g_content_type_guess_for_tree#} (toFile root) >>= readUTFStringArray0 #endif -- | Gets a list of strings containing all the registered content types known to the system. contentTypesGetRegistered :: GlibString string => IO [string] -- ^ returns GList of the registered content types. contentTypesGetRegistered = do glistPtr <- {#call g_content_types_get_registered#} strPtrs <- fromGList glistPtr mapM readUTFString strPtrs gio-0.13.1.0/System/GIO/File/File.chs0000644000000000000000000026366512507510337015062 0ustar0000000000000000{-# LANGUAGE CPP, DeriveDataTypeable #-} -- GIMP Toolkit (GTK) Binding for Haskell: binding to gio -*-haskell-*- -- -- Author : Peter Gavin, Andy Stewart -- Created: 13-Oct-2008 -- -- Copyright (c) 2008 Peter Gavin -- Copyright (c) 2010 Andy Stewart -- -- This library is free software: you can redistribute it and/or -- modify it under the terms of the GNU Lesser General Public License -- as published by the Free Software Foundation, either version 3 of -- the License, or (at your option) any later version. -- -- This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public -- License along with this program. If not, see -- . -- -- GIO, the C library which this Haskell library depends on, is -- available under LGPL Version 2. The documentation included with -- this library is based on the original GIO documentation. -- -- | Maintainer : gtk2hs-devel@lists.sourceforge.net -- Stability : alpha -- Portability : portable (depends on GHC) module System.GIO.File.File ( -- * Details -- -- | 'File' is a high level abstraction for manipulating files on a virtual file system. 'File's are -- lightweight, immutable objects that do no I/O upon creation. It is necessary to understand that -- 'File' objects do not represent files, merely an identifier for a file. All file content I/O is -- implemented as streaming operations (see GInputStream and GOutputStream). -- -- To construct a 'File', you can use: 'fileFromPath' if -- you have a URI. 'fileNewForCommandlineArg' -- from a utf8 string gotten from 'fileGetParseName'. -- -- One way to think of a 'File' is as an abstraction of a pathname. For normal files the system pathname -- is what is stored internally, but as 'File's are extensible it could also be something else that -- corresponds to a pathname in a userspace implementation of a filesystem. -- -- 'File's make up hierarchies of directories and files that correspond to the files on a -- filesystem. You can move through the file system with 'File' using 'fileGetParent' to get an -- identifier for the parent directory, 'fileGetChild' to get a child within a directory, -- 'fileResolveRelativePath' to resolve a relative path between two 'File's. There can be multiple -- hierarchies, so you may not end up at the same root if you repeatedly call 'fileGetParent' on -- two different files. -- -- All 'File's have a basename (get with 'fileGetBasename'. These names are byte strings that are -- used to identify the file on the filesystem (relative to its parent directory) and there is no -- guarantees that they have any particular charset encoding or even make any sense at all. If you want -- to use filenames in a user interface you should use the display name that you can get by requesting -- the 'FileAttributeStandardDisplayName' attribute with 'fileQueryInfo'. This is guaranteed to -- be in utf8 and can be used in a user interface. But always store the real basename or the 'File' to -- use to actually access the file, because there is no way to go from a display name to the actual -- name. -- -- Using 'File' as an identifier has the same weaknesses as using a path in that there may be multiple -- aliases for the same file. For instance, hard or soft links may cause two different 'File's to refer -- to the same file. Other possible causes for aliases are: case insensitive filesystems, short and -- long names on Fat/NTFS, or bind mounts in Linux. If you want to check if two 'File's point to the -- same file you can query for the 'FileAttributeIdFile' attribute. Note that 'File' does some -- trivial canonicalization of pathnames passed in, so that trivial differences in the path string used -- at creation (duplicated slashes, slash at end of path, "." or ".." path segments, etc) does not -- create different 'File's. -- -- Many 'File' operations have both synchronous and asynchronous versions to suit your -- application. Asynchronous versions of synchronous functions simply have _async() appended to their -- function names. The asynchronous I/O functions call a 'AsyncReadyCallback' which is then used to -- finalize the operation, producing a 'AsyncResult' which is then passed to the function's matching -- _finish() operation. -- -- Some 'File' operations do not have synchronous analogs, as they may take a very long time to finish, -- and blocking may leave an application unusable. Notable cases include: 'fileMountMountable' to -- mount a mountable file. 'fileUnmountMountableWithOperation' to unmount a mountable -- file. 'fileEjectMountableWithOperation' to eject a mountable file. -- -- One notable feature of 'File's are entity tags, or "etags" for short. Entity tags are somewhat like a -- more abstract version of the traditional mtime, and can be used to quickly determine if the file has -- been modified from the version on the file system. See the HTTP 1.1 specification for HTTP Etag -- headers, which are a very similar concept. -- * Types. File(..), FileClass, FileProgressCallback, FileReadMoreCallback, Offset, FileInputStream, FileInputStreamClass, FileOutputStream, FileOutputStreamClass, InputStream, InputStreamClass, OutputStream, OutputStreamClass, BufferedInputStream, BufferedInputStreamClass, BufferedOutputStream, BufferedOutputStreamClass, MemoryInputStream, MemoryInputStreamClass, MemoryOutputStream, MemoryOutputStreamClass, FilterInputStream, FilterInputStreamClass, FilterOutputStream, FilterOutputStreamClass, DataInputStream, DataInputStreamClass, DataOutputStream, DataOutputStreamClass, -- * Enums FileType (..), FileCopyFlags (..), FileQueryInfoFlags (..), FileCreateFlags (..), FileMonitorFlags (..), MountMountFlags (..), MountUnmountFlags (..), -- * Methods fileFromPath, fileFromURI, fileFromCommandlineArg, fileFromParseName, fileEqual, fileBasename, filePath, #if GLIB_CHECK_VERSION(2,24,0) fileHasParent, #endif fileURI, fileParseName, fileGetChild, fileGetChildForDisplayName, fileHasPrefix, fileGetRelativePath, fileResolveRelativePath, fileIsNative, fileHasURIScheme, fileURIScheme, fileRead, fileReadAsync, fileReadFinish, fileAppendTo, fileCreate, fileReplace, fileAppendToAsync, fileAppendToFinish, fileCreateAsync, fileCreateFinish, fileReplaceAsync, fileReplaceFinish, fileQueryInfo, fileQueryInfoAsync, fileQueryInfoFinish, fileQueryExists, #if GLIB_CHECK_VERSION(2,18,0) fileQueryFileType, #endif fileQueryFilesystemInfo, fileQueryFilesystemInfoAsync, fileQueryFilesystemInfoFinish, fileQueryDefaultHandler, fileFindEnclosingMount, fileFindEnclosingMountAsync, fileFindEnclosingMountFinish, fileEnumerateChildren, fileEnumerateChildrenAsync, fileEnumerateChildrenFinish, fileSetDisplayName, fileSetDisplayNameAsync, fileSetDisplayNameFinish, fileDelete, fileTrash, fileCopy, fileCopyAsync, fileCopyFinish, fileMove, fileMakeDirectory, #if GLIB_CHECK_VERSION(2,18,0) fileMakeDirectoryWithParents, #endif fileMakeSymbolicLink, fileQuerySettableAttributes, fileQueryWritableNamespaces, fileSetAttributesFromInfo, fileSetAttributesFromInfoAsync, fileSetAttributesFinish, fileSetAttributeString, fileSetAttributeByteString, fileSetAttributeWord32, fileSetAttributeInt32, fileSetAttributeWord64, fileSetAttributeInt64, fileCopyAttributes, fileMonitorDirectory, fileMonitorFile, #if GLIB_CHECK_VERSION(2,18,0) fileMonitor, #endif fileMountMountable, fileMountMountableFinish, #if GLIB_CHECK_VERSION(2,22,0) fileUnmountMountableWithOperation, fileUnmountMountableWithOperationFinish, fileEjectMountableWithOperation, fileEjectMountableWithOperationFinish, fileStartMountable, fileStartMountableFinish, fileStopMountable, fileStopMountableFinish, filePollMountable, filePollMountableFinish, fileMountEnclosingVolume, fileMountEnclosingVolumeFinish, fileSupportsThreadContexts, #endif ) where import Control.Monad import Data.Typeable import Data.Maybe (fromMaybe) import Data.ByteString (ByteString) import Data.ByteString (useAsCString) import Data.ByteString.Unsafe (unsafePackCStringFinalizer) import System.GIO.Enums import System.GIO.File.FileAttribute import System.Glib.FFI import System.Glib.Flags import System.Glib.GError import System.Glib.GObject import System.Glib.UTFString {#import System.GIO.Async.AsyncResult#} {#import System.GIO.Types#} import qualified Data.ByteString as BS {# context lib = "gio" prefix = "g" #} type Offset = {# type goffset #} {#pointer GFileProgressCallback #} type FileProgressCallback = Offset -> Offset -> IO () foreign import ccall "wrapper" mkFileProgressCallback :: ({#type goffset #} -> {#type goffset #} -> Ptr () -> IO ()) -> IO GFileProgressCallback marshalFileProgressCallback :: FileProgressCallback -> IO GFileProgressCallback marshalFileProgressCallback fileProgressCallback = mkFileProgressCallback $ \ cCurrentNumBytes cTotalNumBytes _ -> do fileProgressCallback (fromIntegral cCurrentNumBytes) (fromIntegral cTotalNumBytes) type FileReadMoreCallback = BS.ByteString -> IO Bool -- | Constructs a 'File' for a given path. This operation never fails, but the returned object might not -- support any I/O operation if path is malformed. fileFromPath :: ByteString -> File fileFromPath path = unsafePerformIO $ wrapNewGObject mkFile $ useAsCString path $ \cPath -> {# call file_new_for_path #} cPath -- | Constructs a 'File' for a given URI. This operation never fails, but the returned object might not -- support any I/O operation if uri is malformed or if the uri type is not supported. fileFromURI :: GlibString string => string -> File fileFromURI uri = unsafePerformIO $ wrapNewGObject mkFile $ withUTFString uri $ \cURI -> {# call file_new_for_uri #} cURI -- | Creates a 'File' with the given argument from the command line. The value of arg can be either a URI, -- an absolute path or a relative path resolved relative to the current working directory. This -- operation never fails, but the returned object might not support any I/O operation if arg points to -- a malformed path. fileFromCommandlineArg :: ByteString -> File fileFromCommandlineArg arg = unsafePerformIO $ wrapNewGObject mkFile $ useAsCString arg $ \cArg -> {# call file_new_for_commandline_arg #} cArg -- | Constructs a 'File' with the given name (i.e. something given by 'fileParseName'. This -- operation never fails, but the returned object might not support any I/O operation if the @parseName@ -- cannot be parsed. fileFromParseName :: GlibString string => string -> File fileFromParseName parseName = unsafePerformIO $ wrapNewGObject mkFile $ withUTFString parseName $ \cParseName -> {# call file_parse_name #} cParseName -- | Compare two file descriptors for equality. This test is also used to -- implement the '(==)' function, that is, comparing two descriptions -- will compare their content, not the pointers to the two structures. -- fileEqual :: (FileClass file1, FileClass file2) => file1 -> file2 -> Bool fileEqual file1 file2 = unsafePerformIO $ liftM toBool $ {# call file_equal #} (toFile file1) (toFile file2) instance Eq File where (==) = fileEqual -- | Gets the base name (the last component of the path) for a given 'File'. -- -- If called for the top level of a system (such as the filesystem root or a uri like sftp://host/) it -- will return a single directory separator (and on Windows, possibly a drive letter). -- -- The base name is a byte string (*not* UTF-8). It has no defined encoding or rules other than it may -- not contain zero bytes. If you want to use filenames in a user interface you should use the display -- name that you can get by requesting the 'FileAttributeStandardDisplayName' attribute with -- 'fileQueryInfo'. -- -- This call does no blocking i/o. fileBasename :: FileClass file => file -> ByteString fileBasename file = unsafePerformIO $ do sPtr <- {# call file_get_basename #} (toFile file) sLen <- lengthArray0 0 sPtr unsafePackCStringFinalizer (castPtr sPtr) (fromIntegral sLen) ({#call unsafe g_free#} (castPtr sPtr)) -- | Gets the local pathname for 'File', if one exists. -- -- This call does no blocking i/o. filePath :: FileClass file => file -> ByteString filePath file = unsafePerformIO $ do sPtr <- {# call file_get_path #} (toFile file) sLen <- lengthArray0 0 sPtr unsafePackCStringFinalizer (castPtr sPtr) (fromIntegral sLen) ({#call unsafe g_free#} (castPtr sPtr)) -- | Gets the URI for the file. -- -- This call does no blocking i/o. fileURI :: (FileClass file, GlibString string) => file -> string fileURI file = unsafePerformIO $ {# call file_get_uri #} (toFile file) >>= readUTFString -- | Gets the parse name of the file. A parse name is a UTF-8 string that describes the file such that -- one can get the 'File' back using 'fileParseName'. -- -- This is generally used to show the 'File' as a nice full-pathname kind of string in a user interface, -- like in a location entry. -- -- For local files with names that can safely be converted to UTF8 the pathname is used, otherwise the -- IRI is used (a form of URI that allows UTF8 characters unescaped). -- -- This call does no blocking i/o. fileParseName :: (FileClass file, GlibString string) => file -> string fileParseName file = unsafePerformIO $ {# call file_get_parse_name #} (toFile file) >>= readUTFString -- | Gets the parent directory for the file. If the file represents the root directory of the file -- system, then 'Nothing' will be returned. -- -- This call does no blocking i/o. fileParent :: FileClass file => file -> Maybe File fileParent file = unsafePerformIO $ maybeNull (wrapNewGObject mkFile) $ {# call file_get_parent #} (toFile file) #if GLIB_CHECK_VERSION(2,24,0) -- | Checks if file has a parent, and optionally, if it is parent. -- -- If parent is 'Nothing' then this function returns 'True' if file has any parent at all. If parent is -- non-'Nothing' then 'True' is only returned if file is a child of parent. fileHasParent :: FileClass file => file -> Maybe File -> Bool fileHasParent file parent = unsafePerformIO $ liftM toBool $ {#call g_file_has_parent#} (toFile file) (fromMaybe (File nullForeignPtr) parent) #endif -- | Gets a child of file with basename equal to name. -- -- Note that the file with that specific name might not exist, but you can still have a 'File' that -- points to it. You can use this for instance to create that file. -- -- This call does no blocking i/o. fileGetChild :: FileClass file => file -> ByteString -> File fileGetChild file name = unsafePerformIO $ wrapNewGObject mkFile $ useAsCString name $ \cName -> {# call file_get_child #} (toFile file) cName -- | Gets the child of file for a given 'name (i.e. a UTF8 version of the name)'. If this function -- fails, it throws a GError. This is very useful when constructing a 'File' for a -- new file and the user entered the filename in the user interface, for instance when you select a -- directory and type a filename in the file selector. -- -- This call does no blocking i/o. fileGetChildForDisplayName :: (FileClass file, GlibString string) => file -> string -> File fileGetChildForDisplayName file displayName = unsafePerformIO $ (wrapNewGObject mkFile) $ withUTFString displayName $ \cDisplayName -> propagateGError ({# call file_get_child_for_display_name #} (toFile file) cDisplayName) -- | Checks whether file has the prefix specified by prefix. In other word, if the names of inital -- elements of files pathname match prefix. Only full pathname elements are matched, so a path like -- /foo is not considered a prefix of /foobar, only of / foo/bar. -- -- This call does no i/o, as it works purely on names. As such it can sometimes return 'False' even if -- file is inside a prefix (from a filesystem point of view), because the prefix of file is an alias of -- prefix. fileHasPrefix :: (FileClass file1, FileClass file2) => file1 -> file2 -> Bool fileHasPrefix file1 file2 = unsafePerformIO $ liftM toBool $ {# call file_has_prefix #} (toFile file1) (toFile file2) -- | Gets the path for descendant relative to parent. -- -- This call does no blocking i/o. fileGetRelativePath :: (FileClass file1, FileClass file2) => file1 -> file2 -> Maybe ByteString fileGetRelativePath file1 file2 = unsafePerformIO $ do sPtr <- {# call file_get_relative_path #} (toFile file1) (toFile file2) if sPtr == nullPtr then return Nothing else do sLen <- lengthArray0 0 sPtr liftM Just $ unsafePackCStringFinalizer (castPtr sPtr) (fromIntegral sLen) ({#call unsafe g_free#} (castPtr sPtr)) -- | Resolves a relative path for file to an absolute path. -- -- This call does no blocking i/o. fileResolveRelativePath :: FileClass file => file -> ByteString -> Maybe File fileResolveRelativePath file relativePath = unsafePerformIO $ maybeNull (wrapNewGObject mkFile) $ useAsCString relativePath $ \cRelativePath -> {# call file_resolve_relative_path #} (toFile file) cRelativePath -- | Checks to see if a file is native to the platform. -- -- A native file s one expressed in the platform-native filename format, e.g. \"C:\Windows\" or -- \"/usr/bin/\". This does not mean the file is local, as it might be on a locally mounted remote -- filesystem. -- -- On some systems non-native files may be available using the native filesystem via a userspace -- filesystem (FUSE), in these cases this call will return 'False', but 'fileGetPath' will still -- return a native path. -- -- This call does no blocking i/o. fileIsNative :: FileClass file => file -> Bool fileIsNative = unsafePerformIO . liftM toBool . {# call file_is_native #} . toFile -- | Checks to see if a 'File' has a given URI scheme. -- -- This call does no blocking i/o. fileHasURIScheme :: (FileClass file, GlibString string) => file -> string -> Bool fileHasURIScheme file uriScheme = unsafePerformIO $ withUTFString uriScheme $ \cURIScheme -> liftM toBool $ {# call file_has_uri_scheme #} (toFile file) cURIScheme -- | Gets the URI scheme for a 'File'. RFC 3986 decodes the scheme as: -- -- URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ] -- -- Common schemes include "file", "http", "ftp", etc. -- -- This call does no blocking i/o. fileURIScheme :: (FileClass file, GlibString string) => file -> string fileURIScheme file = unsafePerformIO $ {# call file_get_uri_scheme #} (toFile file) >>= readUTFString -- | Opens a file for reading. The result is a 'FileInputStream' that can be used to read the contents of -- the file. -- -- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object -- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be -- returned. -- -- If the file does not exist, the 'IoErrorNotFound' error will be returned. If the file is a -- directory, the 'IoErrorIsDirectory' error will be returned. Other errors are possible too, and -- depend on what kind of filesystem the file is on. fileRead :: FileClass file => file -> Maybe Cancellable -> IO FileInputStream fileRead file cancellable = wrapNewGObject mkFileInputStream $ propagateGError ({#call g_file_read#} (toFile file) (fromMaybe (Cancellable nullForeignPtr) cancellable)) -- | Asynchronously opens file for reading. -- -- For more details, see 'fileRead' which is the synchronous version of this call. -- -- When the operation is finished, callback will be called. You can then call 'fileReadFinish' to -- get the result of the operation. fileReadAsync :: FileClass file => file -> Int -> Maybe Cancellable -> AsyncReadyCallback -> IO () fileReadAsync file ioPriority mbCancellable callback = do cCallback <- marshalAsyncReadyCallback callback {#call g_file_read_async#} (toFile file) (fromIntegral ioPriority) (fromMaybe (Cancellable nullForeignPtr) mbCancellable) cCallback (castFunPtrToPtr cCallback) -- | Finishes an asynchronous file read operation started with 'fileReadAsync'. fileReadFinish :: FileClass file => file -> AsyncResult -> IO FileInputStream fileReadFinish file asyncResult = wrapNewGObject mkFileInputStream $ propagateGError ({# call file_read_finish #} (toFile file) asyncResult) -- | Gets an output stream for appending data to the file. If the file doesn't already exist it is -- created. -- -- By default files created are generally readable by everyone, but if you pass 'FileCreatePrivate' -- in flags the file will be made readable only to the current user, to the level that is supported on -- the target filesystem. -- -- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object -- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be -- returned. -- -- Some file systems don't allow all file names, and may return an 'IoErrorInvalidFilename' -- error. If the file is a directory the 'IoErrorIsDirectory' error will be returned. Other errors -- are possible too, and depend on what kind of filesystem the file is on. fileAppendTo :: FileClass file => file -> [FileCreateFlags] -> Maybe Cancellable -> IO FileOutputStream fileAppendTo file flags cancellable = wrapNewGObject mkFileOutputStream $ propagateGError ({#call g_file_append_to #} (toFile file) ((fromIntegral . fromFlags) flags) (fromMaybe (Cancellable nullForeignPtr) cancellable) ) -- | Creates a new file and returns an output stream for writing to it. The file must not already exist. -- -- By default files created are generally readable by everyone, but if you pass 'FileCreatePrivate' -- in flags the file will be made readable only to the current user, to the level that is supported on -- the target filesystem. -- -- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object -- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be -- returned. -- -- If a file or directory with this name already exists the 'IoErrorExists' error will be -- returned. Some file systems don't allow all file names, and may return an -- 'IoErrorInvalidFilename' error, and if the name is to long 'IoErrorFilenameTooLong' will be -- returned. Other errors are possible too, and depend on what kind of filesystem the file is on. fileCreate :: FileClass file => file -> [FileCreateFlags] -> Maybe Cancellable -> IO FileOutputStream fileCreate file flags cancellable = wrapNewGObject mkFileOutputStream $ propagateGError ({#call g_file_create #} (toFile file) ((fromIntegral . fromFlags) flags) (fromMaybe (Cancellable nullForeignPtr) cancellable) ) -- | Returns an output stream for overwriting the file, possibly creating a backup copy of the file -- first. If the file doesn't exist, it will be created. -- -- This will try to replace the file in the safest way possible so that any errors during the writing -- will not affect an already existing copy of the file. For instance, for local files it may write to -- a temporary file and then atomically rename over the destination when the stream is closed. -- -- By default files created are generally readable by everyone, but if you pass 'FileCreatePrivate' -- in flags the file will be made readable only to the current user, to the level that is supported on -- the target filesystem. -- -- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object -- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be -- returned. -- -- If you pass in a non-'Nothing' etag value, then this value is compared to the current entity tag of the -- file, and if they differ an 'IoErrorWrongEtag' error is returned. This generally means that the -- file has been changed since you last read it. You can get the new etag from -- 'fileOutputStreamGetEtag' after you've finished writing and closed the 'FileOutputStream'. -- When you load a new file you can use 'fileInputStreamQueryInfo' to get the etag of the file. -- -- If @makeBackup@ is 'True', this function will attempt to make a backup of the current file before -- overwriting it. If this fails a 'IoErrorCantCreateBackup' error will be returned. If you want to -- replace anyway, try again with @makeBackup@ set to 'False'. -- -- If the file is a directory the 'IoErrorIsDirectory' error will be returned, and if the file is -- some other form of non-regular file then a 'IoErrorNotRegularFile' error will be returned. Some -- file systems don't allow all file names, and may return an 'IoErrorInvalidFilename' error, and if -- the name is to long 'IoErrorFilenameTooLong' will be returned. Other errors are possible too, -- and depend on what kind of filesystem the file is on. fileReplace :: (FileClass file, GlibString string) => file -> Maybe string -> Bool -> [FileCreateFlags] -> Maybe Cancellable -> IO FileOutputStream fileReplace file etag makeBackup flags cancellable = wrapNewGObject mkFileOutputStream $ maybeWith withUTFString etag $ \cEtag -> propagateGError ({#call g_file_replace#} (toFile file) cEtag (fromBool makeBackup) ((fromIntegral . fromFlags) flags) (fromMaybe (Cancellable nullForeignPtr) cancellable)) -- | Asynchronously opens file for appending. -- -- For more details, see 'fileAppendTo' which is the synchronous version of this call. -- -- When the operation is finished, callback will be called. You can then call 'fileAppendToFinish' -- to get the result of the operation. fileAppendToAsync :: FileClass file => file -> [FileCreateFlags] -> Int -> Maybe Cancellable -> AsyncReadyCallback -> IO () fileAppendToAsync file flags ioPriority cancellable callback = do cCallback <- marshalAsyncReadyCallback callback {#call g_file_append_to_async#} (toFile file) ((fromIntegral . fromFlags) flags) (fromIntegral ioPriority) (fromMaybe (Cancellable nullForeignPtr) cancellable) cCallback (castFunPtrToPtr cCallback) -- | Finishes an asynchronous file append operation started with 'fileAppendToAsync'. fileAppendToFinish :: FileClass file => file -> AsyncResult -> IO FileOutputStream fileAppendToFinish file asyncResult = wrapNewGObject mkFileOutputStream $ propagateGError ({# call file_append_to_finish #} (toFile file) asyncResult) -- | Asynchronously creates a new file and returns an output stream for writing to it. The file must not -- already exist. -- -- For more details, see 'fileCreate' which is the synchronous version of this call. -- -- When the operation is finished, callback will be called. You can then call 'fileCreateFinish' to -- get the result of the operation. fileCreateAsync :: FileClass file => file -> [FileCreateFlags] -> Int -> Maybe Cancellable -> AsyncReadyCallback -> IO () fileCreateAsync file flags ioPriority cancellable callback = do cCallback <- marshalAsyncReadyCallback callback {#call g_file_create_async #} (toFile file) ((fromIntegral . fromFlags) flags) (fromIntegral ioPriority) (fromMaybe (Cancellable nullForeignPtr) cancellable) cCallback (castFunPtrToPtr cCallback) -- | Finishes an asynchronous file create operation started with 'fileCreateAsync'. fileCreateFinish :: FileClass file => file -> AsyncResult -> IO FileOutputStream fileCreateFinish file asyncResult = wrapNewGObject mkFileOutputStream $ propagateGError ({# call file_create_finish #} (toFile file) asyncResult) -- | Asynchronously overwrites the file, replacing the contents, possibly creating a backup copy of the -- file first. -- -- For more details, see 'fileReplace' which is the synchronous version of this call. -- -- When the operation is finished, callback will be called. You can then call 'fileReplaceFinish' -- to get the result of the operation. fileReplaceAsync :: (FileClass file, GlibString string) => file -> string -> Bool -> [FileCreateFlags] -> Int -> Maybe Cancellable -> AsyncReadyCallback -> IO () fileReplaceAsync file etag makeBackup flags ioPriority cancellable callback = withUTFString etag $ \cEtag -> do cCallback <- marshalAsyncReadyCallback callback {#call g_file_replace_async #} (toFile file) cEtag (fromBool makeBackup) ((fromIntegral . fromFlags) flags) (fromIntegral ioPriority) (fromMaybe (Cancellable nullForeignPtr) cancellable) cCallback (castFunPtrToPtr cCallback) -- | Finishes an asynchronous file replace operation started with 'fileReplaceAsync'. fileReplaceFinish :: FileClass file => file -> AsyncResult -> IO FileOutputStream fileReplaceFinish file asyncResult = wrapNewGObject mkFileOutputStream $ propagateGError ({# call file_replace_finish #} (toFile file) asyncResult) -- | Gets the requested information about specified file. The result is a 'FileInfo' object that contains -- key-value attributes (such as the type or size of the file). -- -- The attribute value is a string that specifies the file attributes that should be gathered. It is -- not an error if it's not possible to read a particular requested attribute from a file - it just -- won't be set. attribute should be a comma-separated list of attribute or attribute wildcards. The -- wildcard \"*\" means all attributes, and a wildcard like \"standard::*\" means all attributes in the -- standard namespace. An example attribute query be \"standard::*,'user'\". The standard attributes -- are available as defines, like 'FileAttributeStandardName'. -- -- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object -- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be -- returned. -- -- For symlinks, normally the information about the target of the symlink is returned, rather than -- information about the symlink itself. However if you pass 'FileQueryInfoNofollowSymlinks' in -- flags the information about the symlink itself will be returned. Also, for symlinks that point to -- non-existing files the information about the symlink itself will be returned. -- -- If the file does not exist, the 'IoErrorNotFound' error will be returned. Other errors are -- possible too, and depend on what kind of filesystem the file is on. fileQueryInfo :: (FileClass file, GlibString string) => file -> string -> [FileQueryInfoFlags] -> Maybe Cancellable -> IO FileInfo fileQueryInfo file attributes flags cancellable = makeNewGObject mkFileInfo $ withUTFString attributes $ \cAttributes -> propagateGError ({#call g_file_query_info #} (toFile file) cAttributes ((fromIntegral . fromFlags) flags) (fromMaybe (Cancellable nullForeignPtr) cancellable) ) -- | Asynchronously gets the requested information about specified file. The result is a 'FileInfo' object -- that contains key-value attributes (such as type or size for the file). -- -- For more details, see 'fileQueryInfo' which is the synchronous version of this call. -- -- When the operation is finished, callback will be called. You can then call -- 'fileQueryInfoFinish' to get the result of the operation. fileQueryInfoAsync :: (FileClass file, GlibString string) => file -> string -> [FileQueryInfoFlags] -> Int -> Maybe Cancellable -> AsyncReadyCallback -> IO () fileQueryInfoAsync file attributes flags ioPriority cancellable callback = withUTFString attributes $ \cAttributes -> do cCallback <- marshalAsyncReadyCallback callback {#call g_file_query_info_async #} (toFile file) cAttributes ((fromIntegral . fromFlags) flags) (fromIntegral ioPriority) (fromMaybe (Cancellable nullForeignPtr) cancellable) cCallback (castFunPtrToPtr cCallback) -- | Finishes an asynchronous file info query. See 'fileQueryInfoAsync'. fileQueryInfoFinish :: FileClass file => file -> AsyncResult -> IO FileInfo fileQueryInfoFinish file asyncResult = makeNewGObject mkFileInfo $ propagateGError ({#call file_query_info_finish #} (toFile file) asyncResult) -- | Utility function to check if a particular file exists. This is implemented using 'fileQueryInfo' -- and as such does blocking I/O. -- -- Note that in many cases it is racy to first check for file existence and then execute something -- based on the outcome of that, because the file might have been created or removed in between the -- operations. The general approach to handling that is to not check, but just do the operation and -- handle the errors as they come. -- -- As an example of race-free checking, take the case of reading a file, and if it doesn't exist, -- creating it. There are two racy versions: read it, and on error create it; and: check if it exists, -- if not create it. These can both result in two processes creating the file (with perhaps a partially -- written file as the result). The correct approach is to always try to create the file with -- 'fileCreate' which will either atomically create the file or fail with a 'IoErrorExists' error. -- -- However, in many cases an existence check is useful in a user interface, for instance to make a menu -- item sensitive/ insensitive, so that you don't have to fool users that something is possible and -- then just show and error dialog. If you do this, you should make sure to also handle the errors that -- can happen due to races when you execute the operation. fileQueryExists :: FileClass file => file -> Maybe Cancellable -> Bool fileQueryExists file cancellable = unsafePerformIO $ liftM toBool $ {#call g_file_query_exists #} (toFile file) (fromMaybe (Cancellable nullForeignPtr) cancellable) #if GLIB_CHECK_VERSION(2,18,0) -- | Utility function to inspect the 'FileType' of a file. This is implemented using 'fileQueryInfo' -- and as such does blocking I/O. -- -- The primary use case of this method is to check if a file is a regular file, directory, or symlink. fileQueryFileType :: FileClass file => file -> [FileQueryInfoFlags] -> Maybe Cancellable -> FileType fileQueryFileType file flags cancellable = (toEnum . fromIntegral) $ unsafePerformIO $ ({#call g_file_query_file_type #} (toFile file) ((fromIntegral . fromFlags) flags) (fromMaybe (Cancellable nullForeignPtr) cancellable) ) #endif -- | Similar to 'fileQueryInfo', but obtains information about the filesystem the file is on, rather -- than the file itself. For instance the amount of space available and the type of the filesystem. -- -- The attribute value is a string that specifies the file attributes that should be gathered. It is -- not an error if it's not possible to read a particular requested attribute from a file - it just -- won't be set. attribute should be a comma-separated list of attribute or attribute wildcards. The -- wildcard \"*\" means all attributes, and a wildcard like "fs:*" means all attributes in the fs -- namespace. The standard namespace for filesystem attributes is "fs". Common attributes of interest -- are 'FILEAttributeFilesystemSize (The Total Size Of The Filesystem In Bytes)', -- 'FILEAttributeFilesystemFree (Number Of Bytes Available)', and 'FileAttributeFilesystemType' -- (type of the filesystem). -- -- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object -- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be -- returned. -- -- If the file does not exist, the 'IoErrorNotFound' error will be returned. Other errors are -- possible too, and depend on what kind of filesystem the file is on. fileQueryFilesystemInfo :: (FileClass file, GlibString string) => file -> string -> Maybe Cancellable -> IO FileInfo fileQueryFilesystemInfo file attributes cancellable = makeNewGObject mkFileInfo $ withUTFString attributes $ \cAttributes -> propagateGError ({#call g_file_query_filesystem_info #} (toFile file) cAttributes (fromMaybe (Cancellable nullForeignPtr) cancellable) ) -- | Asynchronously gets the requested information about the filesystem that the specified file is -- on. The result is a 'FileInfo' object that contains key-value attributes (such as type or size for -- the file). -- -- For more details, see 'fileQueryFilesystemInfo' which is the synchronous version of this call. -- -- When the operation is finished, callback will be called. You can then call -- 'fileQueryInfoFinish' to get the result of the operation. fileQueryFilesystemInfoAsync :: (FileClass file, GlibString string) => file -> string -> Int -> Maybe Cancellable -> AsyncReadyCallback -> IO () fileQueryFilesystemInfoAsync file attributes ioPriority cancellable callback = withUTFString attributes $ \cAttributes -> do cCallback <- marshalAsyncReadyCallback callback {#call g_file_query_filesystem_info_async #} (toFile file) cAttributes (fromIntegral ioPriority) (fromMaybe (Cancellable nullForeignPtr) cancellable) cCallback (castFunPtrToPtr cCallback) -- | Finishes an asynchronous filesystem info query. See 'fileQueryFilesystemInfoAsync'. fileQueryFilesystemInfoFinish :: FileClass file => file -> AsyncResult -> IO FileInfo fileQueryFilesystemInfoFinish file asyncResult = makeNewGObject mkFileInfo $ propagateGError ({# call file_query_filesystem_info_finish #} (toFile file) asyncResult) -- | Returns the 'AppInfo' that is registered as the default application to handle the file specified by -- file. -- -- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object -- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be -- returned. fileQueryDefaultHandler :: FileClass file => file -> Maybe Cancellable -> IO AppInfo fileQueryDefaultHandler file cancellable = wrapNewGObject mkAppInfo $ propagateGError ({#call g_file_query_default_handler #} (toFile file) (fromMaybe (Cancellable nullForeignPtr) cancellable) ) -- | Gets a 'Mount' for the 'File'. -- -- If the 'FileIface' for file does not have a mount (e.g. possibly a remote share), error will be set -- to 'IoErrorNotFound' and 'Nothing' will be returned. -- -- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object -- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be -- returned. fileFindEnclosingMount :: FileClass file => file -> Maybe Cancellable -> IO Mount fileFindEnclosingMount file cancellable = wrapNewGObject mkMount $ propagateGError ({#call g_file_find_enclosing_mount #} (toFile file) (fromMaybe (Cancellable nullForeignPtr) cancellable) ) -- | Asynchronously gets the mount for the file. -- -- For more details, see 'fileFindEnclosingMount' which is the synchronous version of this call. -- -- When the operation is finished, callback will be called. You can then call -- 'fileFindEnclosingMountFinish' to get the result of the operation. fileFindEnclosingMountAsync :: FileClass file => file -> Int -> Maybe Cancellable -> AsyncReadyCallback -> IO () fileFindEnclosingMountAsync file ioPriority cancellable callback = do cCallback <- marshalAsyncReadyCallback callback {#call g_file_find_enclosing_mount_async #} (toFile file) (fromIntegral ioPriority) (fromMaybe (Cancellable nullForeignPtr) cancellable) cCallback (castFunPtrToPtr cCallback) -- | Finishes an asynchronous find mount request. See 'fileFindEnclosingMountAsync'. fileFindEnclosingMountFinish :: FileClass file => file -> AsyncResult -> IO Mount fileFindEnclosingMountFinish file asyncResult = wrapNewGObject mkMount $ propagateGError ({# call file_find_enclosing_mount_finish #} (toFile file) asyncResult) -- | Gets the requested information about the files in a directory. The result is a 'FileEnumerator' -- object that will give out 'FileInfo' objects for all the files in the directory. -- -- The attribute value is a string that specifies the file attributes that should be gathered. It is -- not an error if it's not possible to read a particular requested attribute from a file - it just -- won't be set. attribute should be a comma-separated list of attribute or attribute wildcards. The -- wildcard \"*\" means all attributes, and a wildcard like \"standard::*\" means all attributes in the -- standard namespace. An example attribute query be \"standard::*,'user'\". The standard attributes -- are available as defines, like 'FileAttributeStandardName'. -- -- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object -- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be -- returned. -- -- If the file does not exist, the 'IoErrorNotFound' error will be returned. If the file is not a -- directory, the 'FileErrorNotdir' error will be returned. Other errors are possible too. fileEnumerateChildren :: FileClass file => file -> String -> [FileQueryInfoFlags] -> Maybe Cancellable -> IO FileEnumerator fileEnumerateChildren file attributes flags cancellable = wrapNewGObject mkFileEnumerator $ withCString attributes $ \cAttributes -> propagateGError ({#call g_file_enumerate_children #} (toFile file) cAttributes ((fromIntegral . fromFlags) flags) (fromMaybe (Cancellable nullForeignPtr) cancellable) ) -- | Asynchronously gets the requested information about the files in a directory. The result is a -- 'FileEnumerator' object that will give out 'FileInfo' objects for all the files in the directory. -- -- For more details, see 'fileEnumerateChildren' which is the synchronous version of this call. -- -- When the operation is finished, callback will be called. You can then call -- 'fileEnumerateChildrenFinish' to get the result of the operation. fileEnumerateChildrenAsync :: (FileClass file, GlibString string) => file -> string -> [FileQueryInfoFlags] -> Int -> Maybe Cancellable -> AsyncReadyCallback -> IO () fileEnumerateChildrenAsync file attributes flags ioPriority cancellable callback = withUTFString attributes $ \cAttributes -> do cCallback <- marshalAsyncReadyCallback callback {#call g_file_enumerate_children_async #} (toFile file) cAttributes ((fromIntegral . fromFlags) flags) (fromIntegral ioPriority) (fromMaybe (Cancellable nullForeignPtr) cancellable) cCallback (castFunPtrToPtr cCallback) -- | Finishes an async enumerate children operation. See 'fileEnumerateChildrenAsync'. fileEnumerateChildrenFinish :: FileClass file => file -> AsyncResult -> IO FileEnumerator fileEnumerateChildrenFinish file asyncResult = wrapNewGObject mkFileEnumerator $ propagateGError ({# call file_enumerate_children_finish #} (toFile file) asyncResult) -- | Renames file to the specified display name. -- -- The display name is converted from UTF8 to the correct encoding for the target filesystem if -- possible and the file is renamed to this. -- -- If you want to implement a rename operation in the user interface the edit name -- ('FileAttributeStandardEditName') should be used as the initial value in the rename widget, and -- then the result after editing should be passed to 'fileSetDisplayName'. -- -- On success the resulting converted filename is returned. -- -- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object -- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be -- returned. fileSetDisplayName :: (FileClass file, GlibString string) => file -> string -> Maybe Cancellable -> IO File fileSetDisplayName file displayName cancellable = wrapNewGObject mkFile $ withUTFString displayName $ \cDisplayName -> propagateGError ({#call g_file_set_display_name #} (toFile file) cDisplayName (fromMaybe (Cancellable nullForeignPtr) cancellable) ) -- | Asynchronously sets the display name for a given 'File'. -- -- For more details, see 'fileSetDisplayName' which is the synchronous version of this call. -- -- When the operation is finished, callback will be called. You can then call -- 'fileSetDisplayNameFinish' to get the result of the operation. fileSetDisplayNameAsync :: (FileClass file, GlibString string) => file -> string -> Int -> Maybe Cancellable -> AsyncReadyCallback -> IO () fileSetDisplayNameAsync file displayName ioPriority cancellable callback = withUTFString displayName $ \cDisplayName -> do cCallback <- marshalAsyncReadyCallback callback {#call g_file_set_display_name_async #} (toFile file) cDisplayName (fromIntegral ioPriority) (fromMaybe (Cancellable nullForeignPtr) cancellable) cCallback (castFunPtrToPtr cCallback) -- | Finishes setting a display name started with 'fileSetDisplayNameAsync'. fileSetDisplayNameFinish :: FileClass file => file -> AsyncResult -> IO File fileSetDisplayNameFinish file asyncResult = wrapNewGObject mkFile $ propagateGError ({# call file_set_display_name_finish #} (toFile file) asyncResult) -- | Deletes a file. If the file is a directory, it will only be deleted if it is empty. -- -- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object -- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be -- returned. fileDelete :: FileClass file => file -> Maybe Cancellable -> IO () fileDelete file cancellable = propagateGError ({#call g_file_delete #} (toFile file) (fromMaybe (Cancellable nullForeignPtr) cancellable) ) >> return () -- | Sends file to the "Trashcan", if possible. This is similar to deleting it, but the user can recover -- it before emptying the trashcan. Not all file systems support trashing, so this call can return the -- 'IoErrorNotSupported' error. -- -- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object -- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be -- returned. fileTrash :: FileClass file => file -> Maybe Cancellable -> IO () fileTrash file cancellable = propagateGError ({#call g_file_trash #} (toFile file) (fromMaybe (Cancellable nullForeignPtr) cancellable) ) >> return () -- | Copies the file source to the location specified by destination. Can not handle recursive copies of -- directories. -- -- If the flag 'FileCopyOverwrite' is specified an already existing destination file is overwritten. -- -- If the flag 'FileCopyNofollowSymlinks' is specified then symlinks will be copied as symlinks, -- otherwise the target of the source symlink will be copied. -- -- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object -- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be -- returned. -- -- If @progressCallback@ is not 'Nothing', then the operation can be monitored by setting this to a -- 'FileProgressCallback' function. @progressCallbackData@ will be passed to this function. It is -- guaranteed that this callback will be called after all data has been transferred with the total -- number of bytes copied during the operation. -- -- If the source file does not exist then the 'IoErrorNotFound' error is returned, independent on -- the status of the destination. -- -- If 'FileCopyOverwrite' is not specified and the target exists, then the error 'IoErrorExists' is -- returned. -- -- If trying to overwrite a file over a directory the 'IoErrorIsDirectory' error is returned. If -- trying to overwrite a directory with a directory the 'IoErrorWouldMerge' error is returned. -- -- If the source is a directory and the target does not exist, or 'FileCopyOverwrite' is specified -- and the target is a file, then the 'IoErrorWouldRecurse' error is returned. -- -- If you are interested in copying the 'File' object itself (not the on-disk file), see 'fileDup'. fileCopy :: (FileClass source, FileClass destination) => source -> destination -> [FileCopyFlags] -> Maybe Cancellable -> Maybe FileProgressCallback -> IO () fileCopy source destination flags cancellable progressCallback = do cProgressCallback <- maybe (return nullFunPtr) marshalFileProgressCallback progressCallback propagateGError $ \cError -> do {#call g_file_copy #} (toFile source) (toFile destination) ((fromIntegral . fromFlags) flags) (fromMaybe (Cancellable nullForeignPtr) cancellable) cProgressCallback nullPtr cError when (cProgressCallback /= nullFunPtr) $ freeHaskellFunPtr cProgressCallback -- | Copies the file source to the location specified by destination asynchronously. For details of the -- behaviour, see 'fileCopy'. -- -- If @progressCallback@ is not 'Nothing', then that function that will be called just like in 'fileCopy', -- however the callback will run in the main loop, not in the thread that is doing the I/O operation. -- -- When the operation is finished, callback will be called. You can then call 'fileCopyFinish' to -- get the result of the operation. fileCopyAsync :: (FileClass source, FileClass destination) => source -> destination -> [FileCopyFlags] -> Int -> Maybe Cancellable -> Maybe FileProgressCallback -> AsyncReadyCallback -> IO () fileCopyAsync source destination flags ioPriority cancellable progressCallback callback = do cProgressCallback <- maybe (return nullFunPtr) marshalFileProgressCallback progressCallback cCallback <- marshalAsyncReadyCallback $ \sourceObject res -> do when (cProgressCallback /= nullFunPtr) $ freeHaskellFunPtr cProgressCallback callback sourceObject res {#call g_file_copy_async #} (toFile source) (toFile destination) ((fromIntegral . fromFlags) flags) (fromIntegral ioPriority) (fromMaybe (Cancellable nullForeignPtr) cancellable) cProgressCallback nullPtr cCallback (castFunPtrToPtr cCallback) -- | Finishes copying the file started with 'fileCopyAsync'. -- -- Throws a 'GError' if an error occurs. fileCopyFinish :: FileClass file => file -> AsyncResult -> IO () fileCopyFinish file asyncResult = propagateGError (\gErrorPtr -> do {# call file_copy_finish #} (toFile file) asyncResult gErrorPtr return ()) -- | Tries to move the file or directory source to the location specified by destination. If native move -- operations are supported then this is used, otherwise a copy + delete fallback is used. The native -- implementation may support moving directories (for instance on moves inside the same filesystem), -- but the fallback code does not. -- -- If the flag 'FileCopyOverwrite' is specified an already existing destination file is overwritten. -- -- If the flag 'FileCopyNofollowSymlinks' is specified then symlinks will be copied as symlinks, -- otherwise the target of the source symlink will be copied. -- -- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object -- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be -- returned. -- -- If @progressCallback@ is not 'Nothing', then the operation can be monitored by setting this to a -- 'FileProgressCallback' function. @progressCallbackData@ will be passed to this function. It is -- guaranteed that this callback will be called after all data has been transferred with the total -- number of bytes copied during the operation. -- -- If the source file does not exist then the 'IoErrorNotFound' error is returned, independent on -- the status of the destination. -- -- If 'FileCopyOverwrite' is not specified and the target exists, then the error 'IoErrorExists' is -- returned. -- -- If trying to overwrite a file over a directory the 'IoErrorIsDirectory' error is returned. If -- trying to overwrite a directory with a directory the 'IoErrorWouldMerge' error is returned. -- -- If the source is a directory and the target does not exist, or 'FileCopyOverwrite' is specified -- and the target is a file, then the 'IoErrorWouldRecurse' error may be returned (if the native -- move operation isn't available). fileMove :: (FileClass source, FileClass destination) => source -> destination -> [FileCopyFlags] -> Maybe Cancellable -> Maybe FileProgressCallback -> IO () fileMove source destination flags cancellable progressCallback = do cProgressCallback <- maybe (return nullFunPtr) marshalFileProgressCallback progressCallback propagateGError $ \cError -> do {#call g_file_move #} (toFile source) (toFile destination) ((fromIntegral . fromFlags) flags) (fromMaybe (Cancellable nullForeignPtr) cancellable) cProgressCallback nullPtr cError when (cProgressCallback /= nullFunPtr) $ freeHaskellFunPtr cProgressCallback -- | Creates a directory. Note that this will only create a child directory of the immediate parent -- directory of the path or URI given by the 'File'. To recursively create directories, see -- 'fileMakeDirectoryWithParents'. This function will fail if the parent directory does not -- exist, setting error to 'IoErrorNotFound'. If the file system doesn't support creating -- directories, this function will fail, setting error to 'IoErrorNotSupported'. -- -- For a local 'File' the newly created directory will have the default (current) ownership and -- permissions of the current process. -- -- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object -- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be -- returned. fileMakeDirectory :: FileClass file => file -> Maybe Cancellable -> IO () fileMakeDirectory file cancellable = do propagateGError $ {#call g_file_make_directory #} (toFile file) (fromMaybe (Cancellable nullForeignPtr) cancellable) return () #if GLIB_CHECK_VERSION(2,18,0) -- | Creates a directory and any parent directories that may not exist similar to 'mkdir -p'. If the file -- system does not support creating directories, this function will fail, setting error to -- 'IoErrorNotSupported'. -- -- For a local 'File' the newly created directories will have the default (current) ownership and -- permissions of the current process. -- -- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object -- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be -- returned. fileMakeDirectoryWithParents :: FileClass file => file -> Maybe Cancellable -> IO () fileMakeDirectoryWithParents file cancellable = do propagateGError $ {#call g_file_make_directory_with_parents #} (toFile file) (fromMaybe (Cancellable nullForeignPtr) cancellable) return () #endif -- | Creates a symbolic link. -- -- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object -- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be -- returned. fileMakeSymbolicLink :: FileClass file => file -> ByteString -> Maybe Cancellable -> IO () fileMakeSymbolicLink file symlinkValue cancellable = useAsCString symlinkValue $ \cSymlinkValue -> do propagateGError $ {#call g_file_make_symbolic_link #} (toFile file) cSymlinkValue (fromMaybe (Cancellable nullForeignPtr) cancellable) return () {# pointer *FileAttributeInfoList newtype #} takeFileAttributeInfoList :: Ptr FileAttributeInfoList -> IO [FileAttributeInfo] takeFileAttributeInfoList ptr = do cInfos <- liftM castPtr $ {# get FileAttributeInfoList->infos #} ptr cNInfos <- {# get FileAttributeInfoList->n_infos #} ptr infos <- peekArray (fromIntegral cNInfos) cInfos return infos -- | Obtain the list of settable attributes for the file. -- -- Returns the type and full attribute name of all the attributes that can be set on this file. This -- doesn't mean setting it will always succeed though, you might get an access failure, or some -- specific file may not support a specific attribute. -- -- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object -- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be -- returned. fileQuerySettableAttributes :: FileClass file => file -> Maybe Cancellable -> IO [FileAttributeInfo] fileQuerySettableAttributes file cancellable = do ptr <- propagateGError $ {#call g_file_query_settable_attributes #} (toFile file) (fromMaybe (Cancellable nullForeignPtr) cancellable) infos <- takeFileAttributeInfoList ptr return infos -- | Obtain the list of attribute namespaces where new attributes can be created by a user. An example of -- this is extended attributes (in the "xattr" namespace). -- -- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object -- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be -- returned. fileQueryWritableNamespaces :: FileClass file => file -> Maybe Cancellable -> IO [FileAttributeInfo] fileQueryWritableNamespaces file cancellable = do ptr <- propagateGError $ {#call g_file_query_writable_namespaces #} (toFile file) (fromMaybe (Cancellable nullForeignPtr) cancellable) infos <- takeFileAttributeInfoList ptr return infos -- | Tries to set all attributes in the 'FileInfo' on the target values, not stopping on the first error. -- -- If there is any error during this operation then error will be set to the first error. Error on -- particular fields are flagged by setting the "status" field in the attribute value to -- 'FileAttributeStatusErrorSetting', which means you can also detect further errors. -- -- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object -- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be -- returned. fileSetAttributesFromInfo :: FileClass file => file -> FileInfo -> [FileQueryInfoFlags] -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore. -> IO () fileSetAttributesFromInfo file fileInfo flags cancellable = propagateGError (\gErrorPtr -> do {#call g_file_set_attributes_from_info #} (toFile file) (toFileInfo fileInfo) ((fromIntegral . fromFlags) flags) (fromMaybe (Cancellable nullForeignPtr) cancellable) gErrorPtr return ()) -- | Asynchronously sets the attributes of file with info. -- -- For more details, see 'fileSetAttributesFromInfo' which is the synchronous version of this -- call. -- -- When the operation is finished, callback will be called. You can then call -- 'fileSetAttributesFinish' to get the result of the operation. fileSetAttributesFromInfoAsync :: FileClass file => file -> FileInfo -> [FileQueryInfoFlags] -> Int -- ^ @ioPriority@ the I/O priority of the request. -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore. -> AsyncReadyCallback -> IO () -- ^ returns 'True' if there was any error, 'False' otherwise. fileSetAttributesFromInfoAsync file fileInfo flags ioPriority cancellable callback = do cCallback <- marshalAsyncReadyCallback callback {#call g_file_set_attributes_async #} (toFile file) (toFileInfo fileInfo) ((fromIntegral . fromFlags) flags) (fromIntegral ioPriority) (fromMaybe (Cancellable nullForeignPtr) cancellable) cCallback (castFunPtrToPtr cCallback) -- | Finishes setting an attribute started in 'fileSetAttributesAsync'. -- -- Throws a 'GError' if an error occurs. fileSetAttributesFinish :: FileClass file => file -> AsyncResult -> FileInfo -> IO () fileSetAttributesFinish file asyncResult fileInfo = withForeignPtr (unFileInfo fileInfo) $ \cFileInfo -> propagateGError (\gErrorPtr -> do {# call g_file_set_attributes_finish #} (toFile file) asyncResult cFileInfo gErrorPtr return ()) -- | Sets attribute of type 'FileAttributeTypeString' to value. If attribute is of a different type, -- this operation will fail. -- -- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object -- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be -- returned. fileSetAttributeString :: (FileClass file, GlibString string) => file -> string -- ^ @attribute@ a string containing the attribute's name. -> string -- ^ @value@ a string containing the attribute's value. -> [FileQueryInfoFlags] -- ^ @flags@ 'FileQueryInfoFlags'. -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore. -> IO () fileSetAttributeString file attribute value flags cancellable = withUTFString attribute $ \ attributePtr -> withUTFString value $ \ valuePtr -> do propagateGError (\gErrorPtr -> do {#call g_file_set_attribute_string #} (toFile file) attributePtr valuePtr ((fromIntegral . fromFlags) flags) (fromMaybe (Cancellable nullForeignPtr) cancellable) gErrorPtr return ()) -- | Sets attribute of type 'FileAttributeTypeByteString' to value. If attribute is of a different -- type, this operation will fail, returning 'False'. -- -- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object -- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be -- returned. fileSetAttributeByteString :: (FileClass file, GlibString string) => file -> string -- ^ @attribute@ a string containing the attribute's name. -> string -- ^ @value@ a string containing the attribute's value. -> [FileQueryInfoFlags] -- ^ @flags@ 'FileQueryInfoFlags'. -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore. -> IO () fileSetAttributeByteString file attribute value flags cancellable = withUTFString attribute $ \ attributePtr -> withUTFString value $ \ valuePtr -> do propagateGError (\gErrorPtr -> do {#call g_file_set_attribute_byte_string #} (toFile file) attributePtr valuePtr ((fromIntegral . fromFlags) flags) (fromMaybe (Cancellable nullForeignPtr) cancellable) gErrorPtr return ()) -- | Sets attribute of type 'FileAttributeTypeUint32' to value. If attribute is of a different type, -- this operation will fail. -- -- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object -- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be -- returned. fileSetAttributeWord32 :: (FileClass file, GlibString string) => file -> string -- ^ @attribute@ a string containing the attribute's name. -> Word32 -- ^ @value@ a Word32 containing the attribute's new value. -> [FileQueryInfoFlags] -- ^ @flags@ 'FileQueryInfoFlags'. -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore. -> IO () fileSetAttributeWord32 file attribute value flags cancellable = withUTFString attribute $ \ attributePtr -> propagateGError (\gErrorPtr -> do {#call g_file_set_attribute_uint32 #} (toFile file) attributePtr (fromIntegral value) ((fromIntegral . fromFlags) flags) (fromMaybe (Cancellable nullForeignPtr) cancellable) gErrorPtr return ()) -- | Sets attribute of type 'FileAttributeTypeInt32' to value. If attribute is of a different type, -- this operation will fail. -- -- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object -- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be -- returned. fileSetAttributeInt32 :: (FileClass file, GlibString string) => file -> string -- ^ @attribute@ a string containing the attribute's name. -> Int32 -- ^ @value@ a Int32 containing the attribute's new value. -> [FileQueryInfoFlags] -- ^ @flags@ 'FileQueryInfoFlags'. -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore. -> IO () fileSetAttributeInt32 file attribute value flags cancellable = withUTFString attribute $ \ attributePtr -> propagateGError (\gErrorPtr -> do {#call g_file_set_attribute_int32 #} (toFile file) attributePtr (fromIntegral value) ((fromIntegral . fromFlags) flags) (fromMaybe (Cancellable nullForeignPtr) cancellable) gErrorPtr return ()) -- | Sets attribute of type 'FileAttributeTypeUint64' to value. If attribute is of a different type, -- this operation will fail. -- -- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object -- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be -- returned. fileSetAttributeWord64 :: (FileClass file, GlibString string) => file -> string -- ^ @attribute@ a string containing the attribute's name. -> Word64 -- ^ @value@ a Word64 containing the attribute's new value. -> [FileQueryInfoFlags] -- ^ @flags@ 'FileQueryInfoFlags'. -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore. -> IO () fileSetAttributeWord64 file attribute value flags cancellable = withUTFString attribute $ \ attributePtr -> propagateGError (\gErrorPtr -> do {#call g_file_set_attribute_uint64 #} (toFile file) attributePtr (fromIntegral value) ((fromIntegral . fromFlags) flags) (fromMaybe (Cancellable nullForeignPtr) cancellable) gErrorPtr return ()) -- | Sets attribute of type 'FileAttributeTypeInt64' to value. If attribute is of a different type, -- this operation will fail. -- -- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object -- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be -- returned. fileSetAttributeInt64 :: (FileClass file, GlibString string) => file -> string -- ^ @attribute@ a string containing the attribute's name. -> Int64 -- ^ @value@ a Int64 containing the attribute's new value. -> [FileQueryInfoFlags] -- ^ @flags@ 'FileQueryInfoFlags'. -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore. -> IO () fileSetAttributeInt64 file attribute value flags cancellable = withUTFString attribute $ \ attributePtr -> propagateGError (\gErrorPtr -> do {#call g_file_set_attribute_int64 #} (toFile file) attributePtr (fromIntegral value) ((fromIntegral . fromFlags) flags) (fromMaybe (Cancellable nullForeignPtr) cancellable) gErrorPtr return ()) -- | Copies the file attributes from source to destination. -- -- Normally only a subset of the file attributes are copied, those that are copies in a normal file -- copy operation (which for instance does not include e.g. owner). However if 'FileCopyAllMetadata' -- is specified in flags, then all the metadata that is possible to copy is copied. This is useful when -- implementing move by copy + delete source. fileCopyAttributes :: (FileClass source, FileClass destination) => source -- ^ @source@ a 'File' with attributes. -> destination -- ^ @destination@ a 'File' to copy attributes to. -> [FileCopyFlags] -- ^ @flags@ a set of 'FileCopyFlags'. -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore. -> IO () fileCopyAttributes source destination flags cancellable = propagateGError (\gErrorPtr -> do {#call g_file_copy_attributes #} (toFile source) (toFile destination) ((fromIntegral . fromFlags) flags) (fromMaybe (Cancellable nullForeignPtr) cancellable) gErrorPtr return ()) -- | Obtains a directory monitor for the given file. This may fail if directory monitoring is not -- supported. -- -- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object -- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be -- returned. fileMonitorDirectory :: FileClass file => file -> [FileMonitorFlags] -> Maybe Cancellable -> IO FileMonitor fileMonitorDirectory file flags cancellable = wrapNewGObject mkFileMonitor $ propagateGError ({#call g_file_monitor_directory #} (toFile file) ((fromIntegral . fromFlags) flags) (fromMaybe (Cancellable nullForeignPtr) cancellable) ) -- | Obtains a file monitor for the given file. If no file notification mechanism exists, then regular -- polling of the file is used. -- -- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object -- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be -- returned. fileMonitorFile :: FileClass file => file -> [FileMonitorFlags] -> Maybe Cancellable -> IO FileMonitor fileMonitorFile file flags cancellable = wrapNewGObject mkFileMonitor $ propagateGError ({#call g_file_monitor_file #} (toFile file) ((fromIntegral . fromFlags) flags) (fromMaybe (Cancellable nullForeignPtr) cancellable) ) #if GLIB_CHECK_VERSION(2,18,0) -- | Obtains a file or directory monitor for the given file, depending on the type of the file. -- -- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object -- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be -- returned. fileMonitor :: FileClass file => file -> [FileMonitorFlags] -> Maybe Cancellable -> IO FileMonitor fileMonitor file flags cancellable = wrapNewGObject mkFileMonitor $ propagateGError ({#call g_file_monitor #} (toFile file) ((fromIntegral . fromFlags) flags) (fromMaybe (Cancellable nullForeignPtr) cancellable) ) #endif -- | Mounts a file of type 'FileTypeMountable'. Using @mountOperation@, you can request callbacks when, -- for instance, passwords are needed during authentication. -- -- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object -- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be -- returned. -- -- When the operation is finished, callback will be called. You can then call -- 'fileMountMountableFinish' to get the result of the operation. fileMountMountable :: FileClass file => file -> [MountMountFlags] -- ^ @flags@ flags affecting the operation -> Maybe MountOperation -- ^ @mountOperation@ a 'MountOperation' or 'Nothing' to avoid user interaction. -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore. -> AsyncReadyCallback -- ^ @callback@ a 'AsyncReadyCallback' -> IO () fileMountMountable file flags mountOperation cancellable callback = do cCallback <- marshalAsyncReadyCallback callback {#call g_file_mount_mountable #} (toFile file) ((fromIntegral . fromFlags) flags) (fromMaybe (MountOperation nullForeignPtr) mountOperation) (fromMaybe (Cancellable nullForeignPtr) cancellable) cCallback (castFunPtrToPtr cCallback) -- | Finishes a mount operation. See 'fileMountMountable' for details. -- -- Finish an asynchronous mount operation that was started with 'fileMountMountable'. fileMountMountableFinish :: FileClass file => file -> AsyncResult -- ^ @result@ a 'AsyncResult' -> IO File fileMountMountableFinish file result = wrapNewGObject mkFile $ propagateGError ({#call g_file_mount_mountable_finish#} (toFile file) result) #if GLIB_CHECK_VERSION(2,22,0) -- | Unmounts a file of type 'FileTypeMountable'. -- -- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object -- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be -- returned. -- -- When the operation is finished, callback will be called. You can then call -- 'fileUnmountMountableFinish' to get the result of the operation. fileUnmountMountableWithOperation :: FileClass file => file -> [MountUnmountFlags] -- ^ @flags@ flags affecting the operation -> Maybe MountOperation -- ^ @mountOperation@ a 'MountOperation' or 'Nothing' to avoid user interaction. -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore. -> AsyncReadyCallback -- ^ @callback@ a 'AsyncReadyCallback' -> IO () fileUnmountMountableWithOperation file flags mountOperation cancellable callback = do cCallback <- marshalAsyncReadyCallback callback {#call g_file_unmount_mountable_with_operation #} (toFile file) ((fromIntegral . fromFlags) flags) (fromMaybe (MountOperation nullForeignPtr) mountOperation) (fromMaybe (Cancellable nullForeignPtr) cancellable) cCallback (castFunPtrToPtr cCallback) -- | Finishes an unmount operation, see 'fileUnmountMountableWithOperation' for details. -- -- Finish an asynchronous unmount operation that was started with -- 'fileUnmountMountableWithOperation'. -- -- Throws a 'GError' if an error occurs. fileUnmountMountableWithOperationFinish :: FileClass file => file -> AsyncResult -- ^ @result@ a 'AsyncResult' -> IO () fileUnmountMountableWithOperationFinish file result = propagateGError (\gErrorPtr -> do {#call g_file_unmount_mountable_with_operation_finish#} (toFile file) result gErrorPtr return ()) -- | Starts an asynchronous eject on a mountable. When this operation has completed, callback will be -- called with @userUser@ data, and the operation can be finalized with -- 'fileEjectMountableWithOperationFinish'. -- -- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object -- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be -- returned. fileEjectMountableWithOperation :: FileClass file => file -> [MountUnmountFlags] -- ^ @flags@ flags affecting the operation -> Maybe MountOperation -- ^ @mountOperation@ a 'MountOperation' or 'Nothing' to avoid user interaction. -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore. -> AsyncReadyCallback -- ^ @callback@ a 'AsyncReadyCallback' -> IO () fileEjectMountableWithOperation file flags mountOperation cancellable callback = do cCallback <- marshalAsyncReadyCallback callback {#call g_file_eject_mountable_with_operation #} (toFile file) ((fromIntegral . fromFlags) flags) (fromMaybe (MountOperation nullForeignPtr) mountOperation) (fromMaybe (Cancellable nullForeignPtr) cancellable) cCallback (castFunPtrToPtr cCallback) -- | Finishes an asynchronous eject operation started by 'fileEjectMountableWithOperation'. -- -- Throws a 'GError' if an error occurs. fileEjectMountableWithOperationFinish :: FileClass file => file -> AsyncResult -- ^ @result@ a 'AsyncResult' -> IO () fileEjectMountableWithOperationFinish file result = propagateGError (\gErrorPtr -> do {#call g_file_eject_mountable_with_operation_finish#} (toFile file) result gErrorPtr return ()) -- | Starts a file of type 'FileTypeMountable'. Using @startOperation@, you can request callbacks when, -- for instance, passwords are needed during authentication. -- -- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object -- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be -- returned. -- -- When the operation is finished, callback will be called. You can then call -- 'fileMountMountableFinish' to get the result of the operation. fileStartMountable :: FileClass file => file -> [DriveStartFlags] -- ^ @flags@ flags affecting the start operation. -> Maybe MountOperation -- ^ @mountOperation@ a 'MountOperation' or 'Nothing' to avoid user interaction. -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore. -> AsyncReadyCallback -- ^ @callback@ a 'AsyncReadyCallback' -> IO () fileStartMountable file flags mountOperation cancellable callback = do cCallback <- marshalAsyncReadyCallback callback {#call g_file_start_mountable #} (toFile file) ((fromIntegral . fromFlags) flags) (fromMaybe (MountOperation nullForeignPtr) mountOperation) (fromMaybe (Cancellable nullForeignPtr) cancellable) cCallback (castFunPtrToPtr cCallback) -- | Finishes a start operation. See 'fileStartMountable' for details. -- -- Finish an asynchronous start operation that was started with 'fileStartMountable'. -- -- Throws a 'GError' if an error occurs. fileStartMountableFinish :: FileClass file => file -> AsyncResult -- ^ @result@ a 'AsyncResult'. -> IO () fileStartMountableFinish file result = propagateGError (\gErrorPtr -> do {#call g_file_start_mountable_finish #} (toFile file) result gErrorPtr return ()) -- | Stops a file of type 'FileTypeMountable'. -- -- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object -- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be -- returned. -- -- When the operation is finished, callback will be called. You can then call -- 'fileStopMountableFinish' to get the result of the operation. fileStopMountable :: FileClass file => file -> [MountUnmountFlags] -- ^ @flags@ flags affecting the stop operation. -> Maybe MountOperation -- ^ @mountOperation@ a 'MountOperation' or 'Nothing' to avoid user interaction. -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore. -> AsyncReadyCallback -- ^ @callback@ a 'AsyncReadyCallback' -> IO () fileStopMountable file flags mountOperation cancellable callback = do cCallback <- marshalAsyncReadyCallback callback {#call g_file_stop_mountable #} (toFile file) ((fromIntegral . fromFlags) flags) (fromMaybe (MountOperation nullForeignPtr) mountOperation) (fromMaybe (Cancellable nullForeignPtr) cancellable) cCallback (castFunPtrToPtr cCallback) -- | Finishes a stop operation. See 'fileStopMountable' for details. -- -- Finish an asynchronous stop operation that was stoped with 'fileStopMountable'. -- -- Throws a 'GError' if an error occurs. fileStopMountableFinish :: FileClass file => file -> AsyncResult -- ^ @result@ a 'AsyncResult'. -> IO () fileStopMountableFinish file result = propagateGError (\gErrorPtr -> do {#call g_file_stop_mountable_finish #} (toFile file) result gErrorPtr return ()) -- | Polls a file of type 'FileTypeMountable'. -- -- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object -- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be -- returned. -- -- When the operation is finished, callback will be called. You can then call -- 'fileMountMountableFinish' to get the result of the operation. filePollMountable :: FileClass file => file -> Maybe Cancellable -> AsyncReadyCallback -> IO () filePollMountable file cancellable callback = do cCallback <- marshalAsyncReadyCallback callback {#call g_file_poll_mountable #} (toFile file) (fromMaybe (Cancellable nullForeignPtr) cancellable) cCallback (castFunPtrToPtr cCallback) -- | Finishes a poll operation. See 'filePollMountable' for details. -- -- Finish an asynchronous poll operation that was polled with 'filePollMountable'. filePollMountableFinish :: FileClass file => file -> AsyncResult -- ^ @result@ a 'AsyncResult'. -> IO Bool -- ^ returns 'True' if the file was successfully ejected. 'False' otherwise. filePollMountableFinish file result = liftM toBool $ propagateGError ({#call g_file_poll_mountable_finish #} (toFile file) result) #endif -- | Starts a @mountOperation@, mounting the volume that contains the file location. -- -- When this operation has completed, callback will be called with @userUser@ data, and the operation -- can be finalized with 'fileMountEnclosingVolumeFinish'. -- -- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object -- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be -- returned. fileMountEnclosingVolume :: FileClass file => file -> [MountMountFlags] -- ^ @flags@ flags affecting the operation -> Maybe MountOperation -- ^ @mountOperation@ a 'MountOperation' or 'Nothing' to avoid user interaction. -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore. -> AsyncReadyCallback -- ^ @callback@ a 'AsyncReadyCallback' -> IO () fileMountEnclosingVolume file flags mountOperation cancellable callback = do cCallback <- marshalAsyncReadyCallback callback {#call g_file_mount_enclosing_volume #} (toFile file) ((fromIntegral . fromFlags) flags) (fromMaybe (MountOperation nullForeignPtr) mountOperation) (fromMaybe (Cancellable nullForeignPtr) cancellable) cCallback (castFunPtrToPtr cCallback) -- | Finishes a mount operation started by 'fileMountEnclosingVolume'. fileMountEnclosingVolumeFinish :: FileClass file => file -> AsyncResult -- ^ @result@ a 'AsyncResult'. -> IO Bool -- ^ returns 'True' if the file was successfully ejected. 'False' otherwise. fileMountEnclosingVolumeFinish file result = liftM toBool $ propagateGError ({#call g_file_mount_enclosing_volume_finish #} (toFile file) result) #if GLIB_CHECK_VERSION(2,22,0) -- | Checks if file supports thread-default contexts. If this returns 'False', you cannot perform -- asynchronous operations on file in a thread that has a thread-default context. fileSupportsThreadContexts :: FileClass file => file -> IO Bool -- ^ returns Whether or not file supports thread-default contexts. fileSupportsThreadContexts file = liftM toBool $ {#call g_file_supports_thread_contexts#} (toFile file) #endif gio-0.13.1.0/System/GIO/File/FileAttribute.hsc0000644000000000000000000004267312507510337016740 0ustar0000000000000000{-# LANGUAGE CPP #-} {-# LANGUAGE ScopedTypeVariables #-} -- -*-haskell-*- #include -- GIMP Toolkit (GTK) Binding for Haskell: binding to gio -*-haskell-*- -- -- Author : Peter Gavin, Andy Stewart -- Created: 13-Oct-2008 -- -- Copyright (c) 2008 Peter Gavin -- Copyright (c) 2010 Andy Stewart -- -- This library is free software: you can redistribute it and/or -- modify it under the terms of the GNU Lesser General Public License -- as published by the Free Software Foundation, either version 3 of -- the License, or (at your option) any later version. -- -- This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public -- License along with this program. If not, see -- . -- -- GIO, the C library which this Haskell library depends on, is -- available under LGPL Version 2. The documentation included with -- this library is based on the original GIO documentation. -- -- | Maintainer : gtk2hs-devel@lists.sourceforge.net -- Stability : alpha -- Portability : portable (depends on GHC) module System.GIO.File.FileAttribute ( -- * Details -- | File attributes in GIO consist of a list of key-value pairs. -- -- Keys are strings that contain a key namespace and a key name, separated by a colon, -- e.g. "namespace:keyname". Namespaces are included to sort key-value pairs by namespaces for -- relevance. Keys can be retrived using wildcards, e.g. \"standard::*\" will return all of the keys in -- the "standard" namespace. -- -- Values are stored within the list in 'FileAttributeValue' structures. Values can store different -- types, listed in the enum 'FileAttributeType'. Upon creation of a 'FileAttributeValue', the type will -- be set to 'FileAttributeTypeInvalid'. -- -- The list of possible attributes for a filesystem (pointed to by a 'File') is availible as a -- 'FileAttributeInfoList'. This list is queryable by key names as indicated earlier. -- -- Classes that implement 'FileIface' will create a 'FileAttributeInfoList' and install default keys and -- values for their given file system, architecture, and other possible implementation details (e.g., -- on a UNIX system, a file attribute key will be registered for the user id for a given file). -- * Types FileAttributeType (..), FileAttributeInfo (..), -- * Enums FileAttributeInfoFlags (..), -- * Methods fileAttributeStandardType, fileAttributeStandardIsHidden, fileAttributeStandardIsBackup, fileAttributeStandardIsSymlink, fileAttributeStandardIsVirtual, fileAttributeStandardName, fileAttributeStandardDisplayName, fileAttributeStandardEditName, fileAttributeStandardCopyName, fileAttributeStandardIcon, fileAttributeStandardContentType, fileAttributeStandardFastContentType, fileAttributeStandardSize, #if GLIB_CHECK_VERSION(2,20,0) fileAttributeStandardAllocatedSize, #endif fileAttributeStandardSymlinkTarget, fileAttributeStandardTargetURI, fileAttributeStandardSortOrder, fileAttributeEtagValue, fileAttributeIDFile, fileAttributeIDFilesystem, fileAttributeAccessCanRead, fileAttributeAccessCanWrite, fileAttributeAccessCanExecute, fileAttributeAccessCanDelete, fileAttributeAccessCanTrash, fileAttributeAccessCanRename, fileAttributeMountableCanMount, fileAttributeMountableCanUnmount, fileAttributeMountableCanEject, fileAttributeMountableUnixDevice, #if GLIB_CHECK_VERSION(2,22,0) fileAttributeMountableUnixDeviceFile, fileAttributeMountableCanStart, fileAttributeMountableCanDegraded, fileAttributeMountableCanStop, fileAttributeMountableStartStopType, fileAttributeMountableCanPoll, #endif fileAttributeMountableHalUDI, fileAttributeTimeModified, fileAttributeTimeModifiedUSec, fileAttributeTimeAccess, fileAttributeTimeAccessUSec, fileAttributeTimeChanged, fileAttributeTimeChangedUSec, fileAttributeTimeCreated, fileAttributeTimeCreatedUSec, fileAttributeUnixDevice, fileAttributeUnixInode, fileAttributeUnixMode, fileAttributeUnixNLink, fileAttributeUnixUID, fileAttributeUnixGID, fileAttributeUnixRDev, fileAttributeUnixBlockSize, fileAttributeUnixBlocks, fileAttributeDosIsMountpoint, fileAttributeDosIsArchive, fileAttributeDosIsSystem, fileAttributeOwnerUser, fileAttributeOwnerUserReal, fileAttributeOwnerGroup, fileAttributeThumbnailPath, fileAttributeThumbnailingFailed, #if GLIB_CHECK_VERSION(2,20,0) fileAttributePreviewIcon, #endif fileAttributeFilesystemSize, fileAttributeFilesystemFree, fileAttributeFilesystemType, fileAttributeFilesystemReadonly, fileAttributeGVfsBackend, fileAttributeSELinuxContext, fileAttributeTrashItemCount, fileAttributeFilesystemUsePreview, fileAttributeStandardDescription, #if GLIB_CHECK_VERSION(2,24,0) fileAttributeTrashOrigPath, fileAttributeTrashDeletionDate, #endif ) where import System.Glib.FFI import System.Glib.UTFString import System.Glib.Flags import System.GIO.Enums data FileAttributeType = FileAttributeTypeInvalid | FileAttributeTypeString | FileAttributeTypeByteString | FileAttributeTypeBool | FileAttributeTypeWord32 | FileAttributeTypeInt32 | FileAttributeTypeWord64 | FileAttributeTypeInt64 | FileAttributeTypeObject #if GLIB_CHECK_VERSION(2,22,0) | FileAttributeTypeStringList #endif deriving (Eq, Ord, Bounded, Show, Read) instance Enum FileAttributeType where toEnum #{const G_FILE_ATTRIBUTE_TYPE_INVALID} = FileAttributeTypeInvalid toEnum #{const G_FILE_ATTRIBUTE_TYPE_STRING} = FileAttributeTypeString toEnum #{const G_FILE_ATTRIBUTE_TYPE_BYTE_STRING} = FileAttributeTypeByteString toEnum #{const G_FILE_ATTRIBUTE_TYPE_BOOLEAN} = FileAttributeTypeBool toEnum #{const G_FILE_ATTRIBUTE_TYPE_UINT32} = FileAttributeTypeWord32 toEnum #{const G_FILE_ATTRIBUTE_TYPE_INT32} = FileAttributeTypeInt32 toEnum #{const G_FILE_ATTRIBUTE_TYPE_UINT64} = FileAttributeTypeWord64 toEnum #{const G_FILE_ATTRIBUTE_TYPE_INT64} = FileAttributeTypeInt64 toEnum #{const G_FILE_ATTRIBUTE_TYPE_OBJECT} = FileAttributeTypeObject #if GLIB_CHECK_VERSION(2,22,0) toEnum #{const G_FILE_ATTRIBUTE_TYPE_STRINGV} = FileAttributeTypeStringList #endif fromEnum FileAttributeTypeInvalid = #{const G_FILE_ATTRIBUTE_TYPE_INVALID} fromEnum FileAttributeTypeString = #{const G_FILE_ATTRIBUTE_TYPE_STRING} fromEnum FileAttributeTypeByteString = #{const G_FILE_ATTRIBUTE_TYPE_BYTE_STRING} fromEnum FileAttributeTypeBool = #{const G_FILE_ATTRIBUTE_TYPE_BOOLEAN} fromEnum FileAttributeTypeWord32 = #{const G_FILE_ATTRIBUTE_TYPE_UINT32} fromEnum FileAttributeTypeInt32 = #{const G_FILE_ATTRIBUTE_TYPE_INT32} fromEnum FileAttributeTypeWord64 = #{const G_FILE_ATTRIBUTE_TYPE_UINT64} fromEnum FileAttributeTypeInt64 = #{const G_FILE_ATTRIBUTE_TYPE_INT64} fromEnum FileAttributeTypeObject = #{const G_FILE_ATTRIBUTE_TYPE_OBJECT} #if GLIB_CHECK_VERSION(2,22,0) fromEnum FileAttributeTypeStringList = #{const G_FILE_ATTRIBUTE_TYPE_STRINGV} #endif data FileAttributeInfo = FileAttributeInfo { fileAttributeInfoName :: DefaultGlibString , fileAttributeInfoType :: FileAttributeType , fileAttributeInfoFlags :: [FileAttributeInfoFlags] } deriving (Eq, Read, Show) instance Storable FileAttributeInfo where sizeOf _ = #{size GFileAttributeInfo} alignment _ = alignment (undefined :: Ptr ()) peek ptr = do retName <- #{peek GFileAttributeInfo, name} ptr >>= readUTFString retType <- (#{peek GFileAttributeInfo, type} ptr :: IO CInt) >>= return . (toEnum . fromIntegral) retFlags <- (#{peek GFileAttributeInfo, flags} ptr :: IO CInt) >>= return . (toFlags . fromIntegral) return $ FileAttributeInfo { fileAttributeInfoName = retName , fileAttributeInfoType = retType , fileAttributeInfoFlags = retFlags } poke _ = error "not implemented" fileAttributeStandardType, fileAttributeStandardIsHidden, fileAttributeStandardIsBackup, fileAttributeStandardIsSymlink, fileAttributeStandardIsVirtual, fileAttributeStandardName, fileAttributeStandardDisplayName, fileAttributeStandardEditName, fileAttributeStandardCopyName, fileAttributeStandardIcon, fileAttributeStandardContentType, fileAttributeStandardFastContentType, fileAttributeStandardSize, #if GLIB_CHECK_VERSION(2,20,0) fileAttributeStandardAllocatedSize, #endif fileAttributeStandardSymlinkTarget, fileAttributeStandardTargetURI, fileAttributeStandardSortOrder, fileAttributeEtagValue, fileAttributeIDFile, fileAttributeIDFilesystem, fileAttributeAccessCanRead, fileAttributeAccessCanWrite, fileAttributeAccessCanExecute, fileAttributeAccessCanDelete, fileAttributeAccessCanTrash, fileAttributeAccessCanRename, fileAttributeMountableCanMount, fileAttributeMountableCanUnmount, fileAttributeMountableCanEject, fileAttributeMountableUnixDevice, #if GLIB_CHECK_VERSION(2,22,0) fileAttributeMountableUnixDeviceFile, fileAttributeMountableCanStart, fileAttributeMountableCanDegraded, fileAttributeMountableCanStop, fileAttributeMountableStartStopType, fileAttributeMountableCanPoll, #endif fileAttributeMountableHalUDI, fileAttributeTimeModified, fileAttributeTimeModifiedUSec, fileAttributeTimeAccess, fileAttributeTimeAccessUSec, fileAttributeTimeChanged, fileAttributeTimeChangedUSec, fileAttributeTimeCreated, fileAttributeTimeCreatedUSec, fileAttributeUnixDevice, fileAttributeUnixInode, fileAttributeUnixMode, fileAttributeUnixNLink, fileAttributeUnixUID, fileAttributeUnixGID, fileAttributeUnixRDev, fileAttributeUnixBlockSize, fileAttributeUnixBlocks, fileAttributeDosIsMountpoint, fileAttributeDosIsArchive, fileAttributeDosIsSystem, fileAttributeOwnerUser, fileAttributeOwnerUserReal, fileAttributeOwnerGroup, fileAttributeThumbnailPath, fileAttributeThumbnailingFailed, #if GLIB_CHECK_VERSION(2,20,0) fileAttributePreviewIcon, #endif fileAttributeFilesystemSize, fileAttributeFilesystemFree, fileAttributeFilesystemType, fileAttributeFilesystemReadonly, fileAttributeGVfsBackend, fileAttributeSELinuxContext, fileAttributeTrashItemCount, fileAttributeFilesystemUsePreview, #if GLIB_CHECK_VERSION(2,24,0) fileAttributeTrashOrigPath, fileAttributeTrashDeletionDate, #endif fileAttributeStandardDescription :: String fileAttributeStandardType = #{const_str G_FILE_ATTRIBUTE_STANDARD_TYPE} fileAttributeStandardIsHidden = #{const_str G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN} fileAttributeStandardIsBackup = #{const_str G_FILE_ATTRIBUTE_STANDARD_IS_BACKUP} fileAttributeStandardIsSymlink = #{const_str G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK} fileAttributeStandardIsVirtual = #{const_str G_FILE_ATTRIBUTE_STANDARD_IS_VIRTUAL} fileAttributeStandardName = #{const_str G_FILE_ATTRIBUTE_STANDARD_NAME} fileAttributeStandardDisplayName = #{const_str G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME} fileAttributeStandardEditName = #{const_str G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME} fileAttributeStandardCopyName = #{const_str G_FILE_ATTRIBUTE_STANDARD_COPY_NAME} fileAttributeStandardIcon = #{const_str G_FILE_ATTRIBUTE_STANDARD_ICON} fileAttributeStandardContentType = #{const_str G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE} fileAttributeStandardFastContentType = #{const_str G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE} fileAttributeStandardSize = #{const_str G_FILE_ATTRIBUTE_STANDARD_SIZE} #if GLIB_CHECK_VERSION(2,20,0) fileAttributeStandardAllocatedSize = #{const_str G_FILE_ATTRIBUTE_STANDARD_ALLOCATED_SIZE} #endif fileAttributeStandardSymlinkTarget = #{const_str G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET} fileAttributeStandardTargetURI = #{const_str G_FILE_ATTRIBUTE_STANDARD_TARGET_URI} fileAttributeStandardSortOrder = #{const_str G_FILE_ATTRIBUTE_STANDARD_SORT_ORDER} fileAttributeEtagValue = #{const_str G_FILE_ATTRIBUTE_ETAG_VALUE} fileAttributeIDFile = #{const_str G_FILE_ATTRIBUTE_ID_FILE} fileAttributeIDFilesystem = #{const_str G_FILE_ATTRIBUTE_ID_FILESYSTEM} fileAttributeAccessCanRead = #{const_str G_FILE_ATTRIBUTE_ACCESS_CAN_READ} fileAttributeAccessCanWrite = #{const_str G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE} fileAttributeAccessCanExecute = #{const_str G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE} fileAttributeAccessCanDelete = #{const_str G_FILE_ATTRIBUTE_ACCESS_CAN_DELETE} fileAttributeAccessCanTrash = #{const_str G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH} fileAttributeAccessCanRename = #{const_str G_FILE_ATTRIBUTE_ACCESS_CAN_RENAME} fileAttributeMountableCanMount = #{const_str G_FILE_ATTRIBUTE_MOUNTABLE_CAN_MOUNT} fileAttributeMountableCanUnmount = #{const_str G_FILE_ATTRIBUTE_MOUNTABLE_CAN_UNMOUNT} fileAttributeMountableCanEject = #{const_str G_FILE_ATTRIBUTE_MOUNTABLE_CAN_EJECT} fileAttributeMountableUnixDevice = #{const_str G_FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE} #if GLIB_CHECK_VERSION(2,22,0) fileAttributeMountableUnixDeviceFile = #{const_str G_FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE_FILE} fileAttributeMountableCanStart = #{const_str G_FILE_ATTRIBUTE_MOUNTABLE_CAN_START} fileAttributeMountableCanDegraded = #{const_str G_FILE_ATTRIBUTE_MOUNTABLE_CAN_START_DEGRADED} fileAttributeMountableCanStop = #{const_str G_FILE_ATTRIBUTE_MOUNTABLE_CAN_STOP} fileAttributeMountableStartStopType = #{const_str G_FILE_ATTRIBUTE_MOUNTABLE_START_STOP_TYPE} fileAttributeMountableCanPoll = #{const_str G_FILE_ATTRIBUTE_MOUNTABLE_CAN_POLL} fileAttributeMountableIsMediaCheckAutomatic = #{const_str G_FILE_ATTRIBUTE_MOUNTABLE_IS_MEDIA_CHECK_AUTOMATIC} #endif fileAttributeMountableHalUDI = #{const_str G_FILE_ATTRIBUTE_MOUNTABLE_HAL_UDI} fileAttributeTimeModified = #{const_str G_FILE_ATTRIBUTE_TIME_MODIFIED} fileAttributeTimeModifiedUSec = #{const_str G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC} fileAttributeTimeAccess = #{const_str G_FILE_ATTRIBUTE_TIME_ACCESS} fileAttributeTimeAccessUSec = #{const_str G_FILE_ATTRIBUTE_TIME_ACCESS_USEC} fileAttributeTimeChanged = #{const_str G_FILE_ATTRIBUTE_TIME_CHANGED} fileAttributeTimeChangedUSec = #{const_str G_FILE_ATTRIBUTE_TIME_CHANGED_USEC} fileAttributeTimeCreated = #{const_str G_FILE_ATTRIBUTE_TIME_CREATED} fileAttributeTimeCreatedUSec = #{const_str G_FILE_ATTRIBUTE_TIME_CREATED_USEC} fileAttributeUnixDevice = #{const_str G_FILE_ATTRIBUTE_UNIX_DEVICE} fileAttributeUnixInode = #{const_str G_FILE_ATTRIBUTE_UNIX_INODE} fileAttributeUnixMode = #{const_str G_FILE_ATTRIBUTE_UNIX_MODE} fileAttributeUnixNLink = #{const_str G_FILE_ATTRIBUTE_UNIX_NLINK} fileAttributeUnixUID = #{const_str G_FILE_ATTRIBUTE_UNIX_UID} fileAttributeUnixGID = #{const_str G_FILE_ATTRIBUTE_UNIX_GID} fileAttributeUnixRDev = #{const_str G_FILE_ATTRIBUTE_UNIX_RDEV} fileAttributeUnixBlockSize = #{const_str G_FILE_ATTRIBUTE_UNIX_BLOCK_SIZE} fileAttributeUnixBlocks = #{const_str G_FILE_ATTRIBUTE_UNIX_BLOCKS} fileAttributeDosIsMountpoint = #{const_str G_FILE_ATTRIBUTE_UNIX_IS_MOUNTPOINT} fileAttributeDosIsArchive = #{const_str G_FILE_ATTRIBUTE_DOS_IS_ARCHIVE} fileAttributeDosIsSystem = #{const_str G_FILE_ATTRIBUTE_DOS_IS_SYSTEM} fileAttributeOwnerUser = #{const_str G_FILE_ATTRIBUTE_OWNER_USER} fileAttributeOwnerUserReal = #{const_str G_FILE_ATTRIBUTE_OWNER_USER_REAL} fileAttributeOwnerGroup = #{const_str G_FILE_ATTRIBUTE_OWNER_GROUP} fileAttributeThumbnailPath = #{const_str G_FILE_ATTRIBUTE_THUMBNAIL_PATH} fileAttributeThumbnailingFailed = #{const_str G_FILE_ATTRIBUTE_THUMBNAILING_FAILED} #if GLIB_CHECK_VERSION(2,20,0) fileAttributePreviewIcon = #{const_str G_FILE_ATTRIBUTE_PREVIEW_ICON} #endif fileAttributeFilesystemSize = #{const_str G_FILE_ATTRIBUTE_FILESYSTEM_SIZE} fileAttributeFilesystemFree = #{const_str G_FILE_ATTRIBUTE_FILESYSTEM_FREE} fileAttributeFilesystemType = #{const_str G_FILE_ATTRIBUTE_FILESYSTEM_TYPE} fileAttributeFilesystemReadonly = #{const_str G_FILE_ATTRIBUTE_FILESYSTEM_READONLY} fileAttributeGVfsBackend = #{const_str G_FILE_ATTRIBUTE_GVFS_BACKEND} fileAttributeSELinuxContext = #{const_str G_FILE_ATTRIBUTE_SELINUX_CONTEXT} fileAttributeTrashItemCount = #{const_str G_FILE_ATTRIBUTE_TRASH_ITEM_COUNT} fileAttributeFilesystemUsePreview = #{const_str G_FILE_ATTRIBUTE_FILESYSTEM_USE_PREVIEW} fileAttributeStandardDescription = #{const_str G_FILE_ATTRIBUTE_STANDARD_DESCRIPTION} #if GLIB_CHECK_VERSION(2,24,0) fileAttributeTrashOrigPath = #{const_str G_FILE_ATTRIBUTE_TRASH_ORIG_PATH} fileAttributeTrashDeletionDate = #{const_str G_FILE_ATTRIBUTE_TRASH_DELETION_DATE} #endif gio-0.13.1.0/System/GIO/File/FileEnumerator.chs0000644000000000000000000002337112507510337017110 0ustar0000000000000000{-# LANGUAGE CPP #-} -- GIMP Toolkit (GTK) Binding for Haskell: binding to gio -*-haskell-*- -- -- Author : Andy Stewart -- Created: 30-Apirl-2010 -- -- Copyright (c) 2010 Andy Stewart -- -- This library is free software: you can redistribute it and/or -- modify it under the terms of the GNU Lesser General Public License -- as published by the Free Software Foundation, either version 3 of -- the License, or (at your option) any later version. -- -- This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public -- License along with this program. If not, see -- . -- -- GIO, the C library which this Haskell library depends on, is -- available under LGPL Version 2. The documentation included with -- this library is based on the original GIO documentation. -- -- | Maintainer : gtk2hs-devel@lists.sourceforge.net -- Stability : alpha -- Portability : portable (depends on GHC) module System.GIO.File.FileEnumerator ( -- * Details -- -- | 'FileEnumerator' allows you to operate on a set of 'File's, returning a 'FileInfo' structure for each -- file enumerated (e.g. 'fileEnumerateChildren' will return a 'FileEnumerator' for each of the -- children within a directory). -- -- To get the next file's information from a 'FileEnumerator', use 'fileEnumeratorNextFile' or its -- asynchronous version, 'fileEnumeratorNextFilesAsync'. Note that the asynchronous version will -- return a list of 'FileInfo', whereas the synchronous will only return the next file in the -- enumerator. -- -- To close a 'FileEnumerator', use 'fileEnumeratorClose', or its asynchronous version, -- 'fileEnumeratorCloseAsync'. -- -- * Types FileEnumerator (..), FileEnumeratorClass, -- * Methods fileEnumeratorNextFile, fileEnumeratorClose, fileEnumeratorNextFilesAsync, fileEnumeratorNextFilesFinish, fileEnumeratorCloseAsync, fileEnumeratorCloseFinish, fileEnumeratorIsClosed, fileEnumeratorHasPending, fileEnumeratorSetPending, #if GLIB_CHECK_VERSION(2,18,0) fileEnumeratorGetContainer, #endif ) where import Control.Monad import Data.Maybe (fromMaybe) import System.GIO.Enums import System.Glib.FFI import System.Glib.Flags import System.Glib.GError import System.Glib.GList import System.Glib.GObject import System.Glib.UTFString {#import System.GIO.Async.AsyncResult#} {#import System.GIO.Types#} {# context lib = "gio" prefix = "g" #} -- | Returns information for the next file in the enumerated object. Will block until the information is -- available. The 'FileInfo' returned from this function will contain attributes that match the -- attribute string that was passed when the 'FileEnumerator' was created. -- -- On error, a 'GError' is thrown. If the enumerator is at the end, 'Nothing' will be -- returned. fileEnumeratorNextFile :: FileEnumeratorClass enumerator => enumerator -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore. -> IO (Maybe FileInfo) -- ^ returns A 'FileInfo' or 'Nothing' on error or end of enumerator. fileEnumeratorNextFile enumerator cancellable = checkGError ( \gErrorPtr -> maybeNull (makeNewGObject mkFileInfo) $ {#call g_file_enumerator_next_file #} (toFileEnumerator enumerator) (fromMaybe (Cancellable nullForeignPtr) cancellable) gErrorPtr) (\ _ -> return Nothing) -- | Releases all resources used by this enumerator, making the enumerator return GIoErrorClosed on -- all calls. -- -- This will be automatically called when the last reference is dropped, but you might want to call -- this function to make sure resources are released as early as possible. -- -- Throws a 'GError' if an error occurs. fileEnumeratorClose :: FileEnumeratorClass enumerator => enumerator -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore. -> IO () fileEnumeratorClose enumerator cancellable = propagateGError $ \gErrorPtr -> do {#call g_file_enumerator_close#} (toFileEnumerator enumerator) (fromMaybe (Cancellable nullForeignPtr) cancellable) gErrorPtr return () -- | Request information for a number of files from the enumerator asynchronously. When all i/o for the -- operation is finished the callback will be called with the requested information. -- -- The callback can be called with less than @numFiles@ files in case of error or at the end of the -- enumerator. In case of a partial error the callback will be called with any succeeding items and no -- error, and on the next request the error will be reported. If a request is cancelled the callback -- will be called with 'IoErrorCancelled'. -- -- During an async request no other sync and async calls are allowed, and will result in -- 'IoErrorPending' errors. -- -- Any outstanding i/o request with higher priority (lower numerical value) will be executed before an -- outstanding request with lower priority. Default priority is GPriorityDefault. fileEnumeratorNextFilesAsync :: FileEnumeratorClass enumerator => enumerator -> Int -- ^ @numFiles@ the number of file info objects to request -> Int -- ^ @ioPriority@ the io priority of the request. -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore. -> AsyncReadyCallback -- ^ @callback@ a 'AsyncReadyCallback' to call when the request is satisfied -> IO () fileEnumeratorNextFilesAsync enumerator numFiles ioPriority cancellable callback = do cCallback <- marshalAsyncReadyCallback callback {#call g_file_enumerator_next_files_async #} (toFileEnumerator enumerator) (fromIntegral numFiles) (fromIntegral ioPriority) (fromMaybe (Cancellable nullForeignPtr) cancellable) cCallback (castFunPtrToPtr cCallback) -- | Finishes the asynchronous operation started with 'fileEnumeratorNextFilesAsync'. fileEnumeratorNextFilesFinish :: FileEnumeratorClass enumerator => enumerator -> AsyncResult -> IO [FileInfo] fileEnumeratorNextFilesFinish enumerator asyncResult = propagateGError ({# call g_file_enumerator_next_files_finish #} (toFileEnumerator enumerator) asyncResult) >>= \glistPtr -> do infoPtrs <- fromGList glistPtr mapM (makeNewGObject mkFileInfo . return) infoPtrs -- | Asynchronously closes the file enumerator. -- -- If cancellable is not 'Nothing', then the operation can be cancelled by triggering the cancellable object -- from another thread. If the operation was cancelled, the error 'IoErrorCancelled' will be returned -- in 'fileEnumeratorCloseFinish'. fileEnumeratorCloseAsync :: FileEnumeratorClass enumerator => enumerator -> Int -- ^ @ioPriority@ the I/O priority of the request. -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore. -> AsyncReadyCallback -- ^ @callback@ a 'AsyncReadyCallback' to call when the request is satisfied -> IO () fileEnumeratorCloseAsync enumerator ioPriority mbCancellable callback = do cCallback <- marshalAsyncReadyCallback callback {#call g_file_enumerator_close_async #} (toFileEnumerator enumerator) (fromIntegral ioPriority) (fromMaybe (Cancellable nullForeignPtr) mbCancellable) cCallback (castFunPtrToPtr cCallback) -- | Finishes closing a file enumerator, started from 'fileEnumeratorCloseAsync'. -- -- If the file enumerator was already closed when 'fileEnumeratorCloseAsync' was called, then this -- function will report GIoErrorClosed in error, and return 'False'. If the file enumerator had -- pending operation when the close operation was started, then this function will report -- 'IoErrorPending', and return 'False'. If cancellable was not 'Nothing', then the operation may have been -- cancelled by triggering the cancellable object from another thread. If the operation was cancelled, -- the 'GError' 'IoErrorCancelled' will be thrown. fileEnumeratorCloseFinish :: FileEnumeratorClass enumerator => enumerator -> AsyncResult -> IO () fileEnumeratorCloseFinish enumerator asyncResult = propagateGError (\gErrorPtr -> do {# call g_file_enumerator_close_finish #} (toFileEnumerator enumerator) asyncResult gErrorPtr return ()) -- | Checks if the file enumerator has been closed. fileEnumeratorIsClosed :: FileEnumeratorClass enumerator => enumerator -> IO Bool -- ^ returns 'True' if the enumerator is closed. fileEnumeratorIsClosed enumerator = liftM toBool $ {#call g_file_enumerator_is_closed#} (toFileEnumerator enumerator) -- | Checks if the file enumerator has pending operations. fileEnumeratorHasPending :: FileEnumeratorClass enumerator => enumerator -> IO Bool -- ^ returns 'True' if the enumerator has pending operations. fileEnumeratorHasPending enumerator = liftM toBool $ {#call g_file_enumerator_has_pending#} (toFileEnumerator enumerator) -- | Sets the file enumerator as having pending operations. fileEnumeratorSetPending :: FileEnumeratorClass enumerator => enumerator -> Bool -> IO () fileEnumeratorSetPending enumerator pending = {#call g_file_enumerator_set_pending#} (toFileEnumerator enumerator) (fromBool pending) #if GLIB_CHECK_VERSION(2,18,0) -- | Get the 'File' container which is being enumerated. fileEnumeratorGetContainer :: FileEnumeratorClass enumerator => enumerator -> IO File fileEnumeratorGetContainer enumerator = makeNewGObject mkFile $ {#call g_file_enumerator_get_container#} (toFileEnumerator enumerator) #endif gio-0.13.1.0/System/GIO/File/FileInfo.chs0000644000000000000000000006554212507510337015670 0ustar0000000000000000{-# LANGUAGE CPP #-} -- GIMP Toolkit (GTK) Binding for Haskell: binding to gio -*-haskell-*- -- -- Author : Andy Stewart -- Created: 30-Apirl-2010 -- -- Copyright (c) 2010 Andy Stewart -- -- This library is free software: you can redistribute it and/or -- modify it under the terms of the GNU Lesser General Public License -- as published by the Free Software Foundation, either version 3 of -- the License, or (at your option) any later version. -- -- This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public -- License along with this program. If not, see -- . -- -- GIO, the C library which this Haskell library depends on, is -- available under LGPL Version 2. The documentation included with -- this library is based on the original GIO documentation. -- -- | Maintainer : gtk2hs-devel@lists.sourceforge.net -- Stability : alpha -- Portability : portable (depends on GHC) module System.GIO.File.FileInfo ( -- * Details -- -- | Functionality for manipulating basic metadata for files. 'FileInfo' implements methods for getting -- information that all files should contain, and allows for manipulation of extended attributes. -- -- See 'FileAttribute' for more information on how GIO handles file attributes. -- -- To obtain a 'FileInfo' for a 'File', use 'fileQueryInfo'. To obtain a -- 'FileInfo' for a file input or output stream, use 'fileInputStreamQueryInfo' or -- 'fileOutputStreamQueryInfo'. -- -- To change the actual attributes of a file, you should then set the attribute in the 'FileInfo' and -- call 'fileSetAttributesFromInfo' on a 'File'. -- -- However, not all attributes can be changed in the file. For instance, the actual size of a file -- cannot be changed via 'fileInfoSetSize' and -- 'fileQueryWritableNamespaces' to discover the settable attributes of a particular file at -- runtime. -- -- 'FileAttributeMatcher' allows for searching through a 'FileInfo' for attributes. -- * Types FileInfo(..), FileInfoClass, -- * Enums, FileAttributeStatus (..), -- * Methods fileInfoNew, fileInfoDup, fileInfoCopyInto, fileInfoHasAttribute, #if GLIB_CHECK_VERSION(2,22,0) fileInfoHasNamespace, #endif fileInfoListAttributes, fileInfoGetAttributeType, fileInfoRemoveAttribute, fileInfoGetAttributeAsString, fileInfoGetAttributeStatus, fileInfoGetAttributeString, #if GLIB_CHECK_VERSION(2,22,0) fileInfoGetAttributeStringList, #endif fileInfoGetAttributeByteString, fileInfoGetAttributeBool, fileInfoGetAttributeWord32, fileInfoGetAttributeInt32, fileInfoGetAttributeWord64, fileInfoGetAttributeInt64, fileInfoGetAttributeObject, #if GLIB_CHECK_VERSION(2,22,0) fileInfoSetAttributeStatus, #endif fileInfoSetAttributeString, #if GLIB_CHECK_VERSION(2,22,0) fileInfoSetAttributeStringList, #endif fileInfoSetAttributeByteString, fileInfoSetAttributeBool, fileInfoSetAttributeWord32, fileInfoSetAttributeInt32, fileInfoSetAttributeWord64, fileInfoSetAttributeInt64, fileInfoSetAttributeObject, fileInfoClearStatus, fileInfoGetFileType, fileInfoGetIsHidden, fileInfoGetIsBackup, fileInfoGetIsSymlink, fileInfoGetName, fileInfoGetDisplayName, fileInfoGetEditName, fileInfoGetIcon, fileInfoGetContentType, fileInfoGetModificationTime, fileInfoGetSize, fileInfoGetSymlinkTarget, fileInfoGetEtag, fileInfoGetSortOrder, fileInfoUnsetAttributeMask, fileInfoSetFileType, fileInfoSetIsHidden, fileInfoSetIsSymlink, fileInfoSetName, fileInfoSetDisplayName, fileInfoSetEditName, fileInfoSetIcon, fileInfoSetContentType, fileInfoSetModificationTime, fileInfoSetSize, -- 'fileInfoSetSymlinkTarget' use *static string* that we don't understand the purpose of this function. -- If someone know how to use it, uncomment it and fix documentation. -- fileInfoSetSymlinkTarget, fileInfoSetSortOrder, ) where import Control.Monad import Data.ByteString (ByteString) import Data.ByteString (useAsCString) import Data.ByteString.Unsafe (unsafePackCStringFinalizer) import System.Glib.FFI import System.Glib.Flags import System.Glib.GError import System.Glib.UTFString import System.Glib.GObject import System.Glib.GDateTime import System.GIO.Enums import System.GIO.File.FileAttribute {#import System.GIO.Types#} {# context lib = "gio" prefix = "g" #} -- | Creates a new file info structure. fileInfoNew :: IO FileInfo fileInfoNew = wrapNewGObject mkFileInfo $ {#call g_file_info_new#} -- | Duplicates a file info structure. fileInfoDup :: FileInfoClass info => info -> IO FileInfo fileInfoDup info = wrapNewGObject mkFileInfo $ {#call g_file_info_dup#} (toFileInfo info) -- | Copies all of the 'FileAttributes' from @srcInfo@ to @destInfo@. fileInfoCopyInto :: (FileInfoClass srcInfo, FileInfoClass destInfo) => srcInfo -- ^ @srcInfo@ source to copy attributes from. -> destInfo -- ^ @destInfo@ destination to copy attributes to. -> IO () fileInfoCopyInto srcInfo destInfo = {#call g_file_info_copy_into#} (toFileInfo srcInfo) (toFileInfo destInfo) -- | Checks if a file info structure has an attribute named attribute. fileInfoHasAttribute :: (FileInfoClass info, GlibString string) => info -> string -- ^ @attribute@ a file attribute key. -> Bool -- ^ returns 'True' if Ginfo has an attribute named attribute, 'False' otherwise. fileInfoHasAttribute info attribute = toBool $ unsafePerformIO $ withUTFString attribute $ \ attributePtr -> {#call g_file_info_has_attribute#} (toFileInfo info) attributePtr #if GLIB_CHECK_VERSION(2,22,0) -- | Checks if a file info structure has an attribute in the specified @nameSpace@. fileInfoHasNamespace :: (FileInfoClass info, GlibString string) => info -> string -- ^ @namespace@ a file namespace key. -> Bool -- ^ returns 'True' if Ginfo has an namespace named namespace, 'False' otherwise. fileInfoHasNamespace info namespace = toBool $ unsafePerformIO $ withUTFString namespace $ \ namespacePtr -> {#call g_file_info_has_namespace#} (toFileInfo info) namespacePtr #endif -- | Lists the file info structure's attributes. fileInfoListAttributes :: (FileInfoClass info, GlibString string) => info -> string -- ^ @nameSpace@ a file attribute key's namespace. -> IO [string]-- ^ returns a array of strings of all of the possible attribute types for the given @nameSpace@ fileInfoListAttributes info nameSpace = withUTFString nameSpace $ \ nameSpacePtr -> {#call g_file_info_list_attributes#} (toFileInfo info) nameSpacePtr >>= readUTFStringArray0 -- | Gets the attribute type for an attribute key. fileInfoGetAttributeType :: (FileInfoClass info, GlibString string) => info -> string -- ^ @attribute@ a file attribute key. -> IO FileAttributeType -- ^ returns a 'FileAttributeType' for the given attribute, or 'FileAttributeTypeInvalid' if the key is not set. fileInfoGetAttributeType info attribute = liftM (toEnum . fromIntegral) $ withUTFString attribute $ \ attributePtr -> {#call g_file_info_get_attribute_type#} (toFileInfo info) attributePtr -- | Removes all cases of attribute from info if it exists. fileInfoRemoveAttribute :: (FileInfoClass info, GlibString string) => info -> string -- ^ @attribute@ a file attribute key. -> IO () fileInfoRemoveAttribute info attribute = withUTFString attribute $ \ attributePtr -> {#call g_file_info_remove_attribute#} (toFileInfo info) attributePtr -- | Gets the value of a attribute, formated as a string. This escapes things as needed to make the -- string valid utf8. fileInfoGetAttributeAsString :: (FileInfoClass info, GlibString string) => info -> string -- ^ @attribute@ a file attribute key. -> IO string -- ^ returns a UTF-8 string associated with the given attribute. fileInfoGetAttributeAsString info attribute = withUTFString attribute $ \ attributePtr -> {#call g_file_info_get_attribute_as_string#} (toFileInfo info) attributePtr >>= readUTFString -- | Gets the attribute status for an attribute key. fileInfoGetAttributeStatus :: (FileInfoClass info, GlibString string) => info -> string -- ^ @attribute@ a file attribute key. -> IO FileAttributeStatus -- ^ returns a 'FileAttributeStatus' for the given attribute, or 'FileAttributeStatusUnset' if the key is invalid. fileInfoGetAttributeStatus info attribute = liftM (toEnum . fromIntegral) $ withUTFString attribute $ \ attributePtr -> {#call g_file_info_get_attribute_status#} (toFileInfo info) attributePtr -- | Gets the value of a string attribute. fileInfoGetAttributeString :: (FileInfoClass info, GlibString string) => info -> string -- ^ @attribute@ a file attribute key. -> IO string -- ^ returns the contents of the attribute value as a string fileInfoGetAttributeString info attribute = withUTFString attribute $ \ attributePtr -> {#call g_file_info_get_attribute_string#} (toFileInfo info) attributePtr >>= readUTFString #if GLIB_CHECK_VERSION(2,22,0) -- | Gets the value of a stringv attribute. If the attribute does not contain a stringv fileInfoGetAttributeStringList :: (FileInfoClass info, GlibString string) => info -> string -- ^ @attribute@ a file attribute key. -> IO [string] -- ^ returns the contents of the attribute value as a string list fileInfoGetAttributeStringList info attribute = withUTFString attribute $ \ attributePtr -> {#call g_file_info_get_attribute_stringv#} (toFileInfo info) attributePtr >>= readUTFStringArray0 #endif -- | Gets the value of a byte string attribute. fileInfoGetAttributeByteString :: (FileInfoClass info, GlibString string) => info -> string -- ^ @attribute@ a file attribute key. -> IO ByteString -- ^ returns the contents of the attribute value as a ByteString fileInfoGetAttributeByteString info attribute = withUTFString attribute $ \ attributePtr -> do sPtr <- {#call g_file_info_get_attribute_byte_string#} (toFileInfo info) attributePtr sLen <- lengthArray0 0 sPtr unsafePackCStringFinalizer (castPtr sPtr) (fromIntegral sLen) ({#call unsafe g_free#} (castPtr sPtr)) -- | Gets the value of a boolean attribute. fileInfoGetAttributeBool :: (FileInfoClass info, GlibString string) => info -> string -- ^ @attribute@ a file attribute key. -> IO Bool -- ^ returns the contents of the attribute value as a bool fileInfoGetAttributeBool info attribute = liftM toBool $ withUTFString attribute $ \ attributePtr -> {#call g_file_info_get_attribute_boolean#} (toFileInfo info) attributePtr -- | Gets an Word32 contained within the attribute. fileInfoGetAttributeWord32 :: (FileInfoClass info, GlibString string) => info -> string -- ^ @attribute@ a file attribute key. -> IO Word32 -- ^ returns the contents of the attribute value as a bool fileInfoGetAttributeWord32 info attribute = liftM fromIntegral $ withUTFString attribute $ \ attributePtr -> do {#call g_file_info_get_attribute_uint32#} (toFileInfo info) attributePtr -- | Gets an Int32 contained within the attribute. fileInfoGetAttributeInt32 :: (FileInfoClass info, GlibString string) => info -> string -- ^ @attribute@ a file attribute key. -> IO Int32 -- ^ returns the contents of the attribute value as a bool fileInfoGetAttributeInt32 info attribute = liftM fromIntegral $ withUTFString attribute $ \ attributePtr -> do {#call g_file_info_get_attribute_int32#} (toFileInfo info) attributePtr -- | Gets an Word64 contained within the attribute. fileInfoGetAttributeWord64 :: (FileInfoClass info, GlibString string) => info -> string -- ^ @attribute@ a file attribute key. -> IO Word64 -- ^ returns the contents of the attribute value as a bool fileInfoGetAttributeWord64 info attribute = liftM fromIntegral $ withUTFString attribute $ \ attributePtr -> do {#call g_file_info_get_attribute_uint64#} (toFileInfo info) attributePtr -- | Gets an Int64 contained within the attribute. fileInfoGetAttributeInt64 :: (FileInfoClass info, GlibString string) => info -> string -- ^ @attribute@ a file attribute key. -> IO Int64 -- ^ returns the contents of the attribute value as a bool fileInfoGetAttributeInt64 info attribute = liftM fromIntegral $ withUTFString attribute $ \ attributePtr -> do {#call g_file_info_get_attribute_int64#} (toFileInfo info) attributePtr -- | Gets the value of a GObject attribute. fileInfoGetAttributeObject :: (FileInfoClass info, GlibString string) => info -> string -- ^ @attribute@ a file attribute key. -> IO (Maybe GObject) -- ^ returns the contents of the attribute value as a object fileInfoGetAttributeObject info attribute = withUTFString attribute $ \ attributePtr -> {#call g_file_info_get_attribute_object#} (toFileInfo info) attributePtr >>= \x -> maybeNull (makeNewGObject mkGObject) (return $ castPtr x) #if GLIB_CHECK_VERSION(2,22,0) -- | Sets the attribute status for an attribute key. This is only needed by external code that implement -- 'fileSetAttributesFromInfo' or similar functions. -- -- The attribute must exist in info for this to work. Otherwise 'False' is returned and info is -- unchanged. fileInfoSetAttributeStatus :: (FileInfoClass info, GlibString string) => info -> string -- ^ @attribute@ a file attribute key -> FileAttributeStatus -- ^ @status@ a 'FileAttributeStatus' -> IO Bool -- ^ returns 'True' if the status was changed, 'False' if the key was not set. fileInfoSetAttributeStatus info attribute status = liftM toBool $ withUTFString attribute $ \ attributePtr -> {#call g_file_info_set_attribute_status#} (toFileInfo info) attributePtr ((fromIntegral . fromEnum) status) #endif -- | Sets the attribute to contain the given @attrValue@, if possible. fileInfoSetAttributeString :: (FileInfoClass info, GlibString string) => info -> string -- ^ @attribute@ a file attribute key. -> string -- ^ @attrValue@ a string. -> IO () fileInfoSetAttributeString info attribute attrValue = withUTFString attribute $ \ attributePtr -> withUTFString attrValue $ \ attrValuePtr -> {#call g_file_info_set_attribute_string#} (toFileInfo info) attributePtr attrValuePtr #if GLIB_CHECK_VERSION(2,22,0) -- | Sets the attribute to contain the given @attrValue@, if possible. fileInfoSetAttributeStringList :: (FileInfoClass info, GlibString string) => info -> string -- ^ @attribute@ a file attribute key. -> [string] -- ^ @attrValue@ a string. -> IO () fileInfoSetAttributeStringList info attribute attrValue = withUTFString attribute $ \ attributePtr -> withUTFStringArray0 attrValue $ \ attrValuePtr -> {#call g_file_info_set_attribute_stringv#} (toFileInfo info) attributePtr attrValuePtr #endif -- | Sets the attribute to contain the given @attrValue@, if possible. fileInfoSetAttributeByteString :: (FileInfoClass info, GlibString string) => info -> string -- ^ @attribute@ a file attribute key. -> ByteString -- ^ @attrValue@ a string. -> IO () fileInfoSetAttributeByteString info attribute attrValue = withUTFString attribute $ \ attributePtr -> useAsCString attrValue $ \ attrValuePtr -> {#call g_file_info_set_attribute_byte_string#} (toFileInfo info) attributePtr attrValuePtr -- | Sets the attribute to contain the given @attrValue@, if possible. fileInfoSetAttributeBool :: (FileInfoClass info, GlibString string) => info -> string -- ^ @attribute@ a file attribute key. -> Bool -- ^ @attrValue@ a string. -> IO () fileInfoSetAttributeBool info attribute attrValue = withUTFString attribute $ \ attributePtr -> {#call g_file_info_set_attribute_boolean#} (toFileInfo info) attributePtr (fromBool attrValue) -- | Sets the attribute to contain the given @attrValue@, if possible. fileInfoSetAttributeWord32 :: (FileInfoClass info, GlibString string) => info -> string -- ^ @attribute@ a file attribute key. -> Word32 -- ^ @attrValue@ an Word32 -> IO () fileInfoSetAttributeWord32 info attribute attrValue = withUTFString attribute $ \ attributePtr -> {#call g_file_info_set_attribute_uint32#} (toFileInfo info) attributePtr (fromIntegral attrValue) -- | Sets the attribute to contain the given @attrValue@, if possible. fileInfoSetAttributeInt32 :: (FileInfoClass info, GlibString string) => info -> string -- ^ @attribute@ a file attribute key. -> Int32 -- ^ @attrValue@ an Int32 -> IO () fileInfoSetAttributeInt32 info attribute attrValue = withUTFString attribute $ \ attributePtr -> {#call g_file_info_set_attribute_int32#} (toFileInfo info) attributePtr (fromIntegral attrValue) -- | Sets the attribute to contain the given @attrValue@, if possible. fileInfoSetAttributeWord64 :: (FileInfoClass info, GlibString string) => info -> string -- ^ @attribute@ a file attribute key. -> Word64 -- ^ @attrValue@ an Word64 -> IO () fileInfoSetAttributeWord64 info attribute attrValue = withUTFString attribute $ \ attributePtr -> {#call g_file_info_set_attribute_uint64#} (toFileInfo info) attributePtr (fromIntegral attrValue) -- | Sets the attribute to contain the given @attrValue@, if possible. fileInfoSetAttributeInt64 :: (FileInfoClass info, GlibString string) => info -> string -- ^ @attribute@ a file attribute key. -> Int64 -- ^ @attrValue@ an Int64 -> IO () fileInfoSetAttributeInt64 info attribute attrValue = withUTFString attribute $ \ attributePtr -> {#call g_file_info_set_attribute_int64#} (toFileInfo info) attributePtr (fromIntegral attrValue) -- | Sets the attribute to contain the given @attrValue@, if possible. fileInfoSetAttributeObject :: (FileInfoClass info, GlibString string) => info -> string -> GObject -> IO () fileInfoSetAttributeObject info attribute (GObject attrValue) = withUTFString attribute $ \ attributePtr -> withForeignPtr attrValue $ \attrValuePtr -> {#call g_file_info_set_attribute_object#} (toFileInfo info) attributePtr (castPtr attrValuePtr) -- | Clears the status information from info. -- fileInfoClearStatus :: FileInfoClass info => info -> IO () fileInfoClearStatus info = {#call g_file_info_clear_status #} (toFileInfo info) -- | Gets a file's type (whether it is a regular file, symlink, etc). This is different from the file's -- content type, see 'fileInfoGetContentType'. -- fileInfoGetFileType :: FileInfoClass info => info -> FileType -- ^ returns a 'FileType' for the given file. fileInfoGetFileType info = (toEnum . fromIntegral) $ unsafePerformIO $ {#call g_file_info_get_file_type#} (toFileInfo info) -- | Checks if a file is hidden. fileInfoGetIsHidden :: FileInfoClass info => info -> Bool -- ^ returns 'True' if the file is a hidden file, 'False' otherwise. fileInfoGetIsHidden info = toBool $ unsafePerformIO $ {#call g_file_info_get_is_hidden#} (toFileInfo info) -- | Checks if a file is a backup file. fileInfoGetIsBackup :: FileInfoClass info => info -> Bool -- ^ returns 'True' if the file is a backup file, 'False' otherwise. fileInfoGetIsBackup info = toBool $ unsafePerformIO $ {#call g_file_info_get_is_backup#} (toFileInfo info) -- | Checks if a file is a symlink file. fileInfoGetIsSymlink :: FileInfoClass info => info -> Bool -- ^ returns 'True' if the file is a symlink file, 'False' otherwise. fileInfoGetIsSymlink info = toBool $ unsafePerformIO $ {#call g_file_info_get_is_symlink#} (toFileInfo info) -- | Gets the name for a file. fileInfoGetName :: FileInfoClass info => info -> Maybe ByteString -- ^ returns a string containing the file name. fileInfoGetName info = unsafePerformIO $ do sPtr <- {#call g_file_info_get_name#} (toFileInfo info) if sPtr == nullPtr then return Nothing else do sLen <- lengthArray0 0 sPtr liftM Just $ unsafePackCStringFinalizer (castPtr sPtr) (fromIntegral sLen) ({#call unsafe g_free#} (castPtr sPtr)) -- | Gets the display name for a file. fileInfoGetDisplayName :: (FileInfoClass info, GlibString string) => info -> Maybe string -- ^ returns a string containing the display name. fileInfoGetDisplayName info = unsafePerformIO $ {#call g_file_info_get_display_name#} (toFileInfo info) >>= maybePeek readUTFString -- | Gets the edit name for a file. fileInfoGetEditName :: (FileInfoClass info, GlibString string) => info -> Maybe string -- ^ returns a string containing the edit name. fileInfoGetEditName info = unsafePerformIO $ {#call g_file_info_get_edit_name#} (toFileInfo info) >>= maybePeek readUTFString -- | Gets the icon for a file. fileInfoGetIcon :: FileInfoClass info => info -> IO Icon -- ^ returns 'Icon' for the given info. fileInfoGetIcon info = makeNewGObject mkIcon $ {#call g_file_info_get_icon#} (toFileInfo info) -- | Gets the file's content type. fileInfoGetContentType :: (FileInfoClass info, GlibString string) => info -> Maybe string -- ^ returns a string containing the file's content type. fileInfoGetContentType info = unsafePerformIO $ {#call g_file_info_get_content_type#} (toFileInfo info) >>= maybePeek peekUTFString -- | Gets the modification time of the current info and sets it in result. fileInfoGetModificationTime :: FileInfoClass info => info -> GTimeVal fileInfoGetModificationTime info = unsafePerformIO $ alloca $ \ timeValPtr -> do {#call g_file_info_get_modification_time#} (toFileInfo info) (castPtr timeValPtr) peek timeValPtr -- | Gets the file's size. fileInfoGetSize :: FileInfoClass info => info -> Int64 -- ^ returns a 'Offset' containing the file's size. fileInfoGetSize info = fromIntegral $ unsafePerformIO $ {#call g_file_info_get_size#} (toFileInfo info) -- | Gets the symlink target for a given 'FileInfo'. fileInfoGetSymlinkTarget :: (FileInfoClass info, GlibString string) => info -> Maybe string -- ^ returns a string containing the symlink target. fileInfoGetSymlinkTarget info = unsafePerformIO $ {#call g_file_info_get_symlink_target#} (toFileInfo info) >>= maybePeek readUTFString -- | Gets the entity tag for a given 'FileInfo'. See 'FileAttributeEtagValue'. fileInfoGetEtag :: (FileInfoClass info, GlibString string) => info -> Maybe string -- ^ returns a string containing the value of the "etag:value" attribute. fileInfoGetEtag info = unsafePerformIO $ {#call g_file_info_get_etag#} (toFileInfo info) >>= maybePeek readUTFString -- | Gets the value of the @sortOrder@ attribute from the 'FileInfo'. See -- 'FileAttributeStandardSortOrder'. fileInfoGetSortOrder :: FileInfoClass info => info -> Int -- ^ returns the value of the \"standard::sort_order\" attribute. fileInfoGetSortOrder info = fromIntegral $ unsafePerformIO $ {#call g_file_info_get_sort_order#} (toFileInfo info) -- | Unsets a mask set by 'fileInfoSetAttributeMask', if one is set. fileInfoUnsetAttributeMask :: FileInfoClass info => info -> IO () fileInfoUnsetAttributeMask info = {#call g_file_info_unset_attribute_mask#} (toFileInfo info) -- | Sets the file type in a 'FileInfo' to type. See 'FileAttributeStandardType'. fileInfoSetFileType :: FileInfoClass info => info -> FileType -> IO () fileInfoSetFileType info fType = {#call g_file_info_set_file_type#} (toFileInfo info) ((fromIntegral . fromEnum) fType) -- | Sets the @isHidden@ attribute in a 'FileInfo' according to @isSymlink@. See -- 'FileAttributeStandardIsHidden'. fileInfoSetIsHidden :: FileInfoClass info => info -> Bool -> IO () fileInfoSetIsHidden info isHidden = {#call g_file_info_set_is_hidden#} (toFileInfo info) (fromBool isHidden) -- | Sets the @isSymlink@ attribute in a 'FileInfo' according to @isSymlink@. See -- 'FileAttributeStandardIsSymlink'. fileInfoSetIsSymlink :: FileInfoClass info => info -> Bool -> IO () fileInfoSetIsSymlink info isSymlink = {#call g_file_info_set_is_symlink#} (toFileInfo info) (fromBool isSymlink) -- | Sets the name attribute for the current 'FileInfo'. See 'FileAttributeStandardName'. fileInfoSetName :: FileInfoClass info => info -> ByteString -> IO () fileInfoSetName info name = useAsCString name $ \ namePtr -> {#call g_file_info_set_name#} (toFileInfo info) namePtr -- | Sets the display name for the current 'FileInfo'. See 'FileAttributeStandardDisplayName'. fileInfoSetDisplayName :: (FileInfoClass info, GlibString string) => info -> string -> IO () fileInfoSetDisplayName info displayName = withUTFString displayName $ \ displayNamePtr -> {#call g_file_info_set_display_name#} (toFileInfo info) displayNamePtr -- | Sets the edit name for the current 'FileInfo'. See 'FileAttributeStandardEditName'. fileInfoSetEditName :: (FileInfoClass info, GlibString string) => info -> string -> IO () fileInfoSetEditName info editName = withUTFString editName $ \ editNamePtr -> {#call g_file_info_set_edit_name#} (toFileInfo info) editNamePtr -- | Sets the icon for a given 'FileInfo'. See 'FileAttributeStandardIcon'. fileInfoSetIcon :: FileInfoClass info => info -> Icon -> IO () fileInfoSetIcon info icon = {#call g_file_info_set_icon#} (toFileInfo info) (toIcon icon) -- | Sets the content type attribute for a given 'FileInfo'. See 'FileAttributeStandardContentType'. fileInfoSetContentType :: (FileInfoClass info, GlibString string) => info -> string -- ^ @contentType@ a content type. See GContentType. -> IO () fileInfoSetContentType info contentType = withUTFString contentType $ \ contentTypePtr -> {#call g_file_info_set_content_type#} (toFileInfo info) contentTypePtr -- | Sets the 'FileAttributeTimeModified' attribute in the file info to the given time value. fileInfoSetModificationTime :: FileInfoClass info => info -> GTimeVal -> IO () fileInfoSetModificationTime info mtime = with mtime $ \ mtimePtr -> {#call g_file_info_set_modification_time#} (toFileInfo info) (castPtr mtimePtr) -- | Sets the 'FileAttributeStandardSize' attribute in the file info to the given size. fileInfoSetSize :: FileInfoClass info => info -> Int64 -- ^ @size@ a goffset containing the file's size. -> IO () fileInfoSetSize info size = {#call g_file_info_set_size#} (toFileInfo info) (fromIntegral size) -- | Sets the 'FileAttributeStandardSymlinkTarget' attribute in the file info to the given symlink -- target. -- fileInfoSetSymlinkTarget :: FileInfoClass info => info -- -> String -- ^ @symlinkTarget@ a static string containing a path to a symlink target. -- -> IO () -- fileInfoSetSymlinkTarget info symlinkTarget = -- withUTFString symlinkTarget $ \ symlinkTargetPtr -> -- {#call g_file_info_set_symlink_target#} (toFileInfo info) symlinkTargetPtr -- | Sets the sort order attribute in the file info structure. See 'FileAttributeStandardSortOrder'. fileInfoSetSortOrder :: FileInfoClass info => info -> Int -- ^ @sortOrder@ a sort order integer. -> IO () fileInfoSetSortOrder info sortOrder = {#call g_file_info_set_sort_order#} (toFileInfo info) (fromIntegral sortOrder) gio-0.13.1.0/System/GIO/File/FileMonitor.chs0000644000000000000000000000720712507510337016416 0ustar0000000000000000{-# LANGUAGE CPP #-} -- GIMP Toolkit (GTK) Binding for Haskell: binding to gio -*-haskell-*- -- -- Author : Andy Stewart -- Created: 30-Apirl-2010 -- -- Copyright (c) 2010 Andy Stewart -- -- This library is free software: you can redistribute it and/or -- modify it under the terms of the GNU Lesser General Public License -- as published by the Free Software Foundation, either version 3 of -- the License, or (at your option) any later version. -- -- This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public -- License along with this program. If not, see -- . -- -- GIO, the C library which this Haskell library depends on, is -- available under LGPL Version 2. The documentation included with -- this library is based on the original GIO documentation. -- -- | Maintainer : gtk2hs-devel@lists.sourceforge.net -- Stability : alpha -- Portability : portable (depends on GHC) module System.GIO.File.FileMonitor ( -- * Details -- -- | Monitors a file or directory for changes. -- -- To obtain a 'FileMonitor' for a file or directory, use 'fileMonitor', or -- 'fileMonitorDirectory' . -- -- To get informed about changes to the file or directory you are monitoring, connect to the "changed" -- signal. The signal will be emitted in the thread-default main context of the thread that the monitor -- was created in (though if the global default main context is blocked, this may cause notifications -- to be blocked even if the thread-default context is still running). -- * Types FileMonitor(..), FileMonitorClass, -- * Enums FileMonitorEvent(..), -- * Methods fileMonitorCancel, fileMonitorIsCancelled, -- * Attributes fileMonitorCancelled, fileMonitorRateLimit, -- * Signals fileMonitorChanged, ) where import Control.Monad import System.GIO.Enums import System.Glib.Attributes import System.Glib.FFI import System.Glib.Flags import System.Glib.GError import System.Glib.GObject import System.Glib.Properties import System.Glib.Signals import System.Glib.UTFString {#import System.GIO.Signals#} {#import System.GIO.Types#} -------------------- -- Methods -- | Cancels a file monitor. fileMonitorCancel :: FileMonitorClass monitor => monitor -> IO Bool -- ^ returns 'True' if monitor was cancelled. fileMonitorCancel monitor = liftM toBool $ {#call g_file_monitor_cancel #} (toFileMonitor monitor) -- | Returns whether the monitor is canceled. fileMonitorIsCancelled :: FileMonitorClass monitor => monitor -> IO Bool -- ^ returns 'True' if monitor is canceled. 'False' otherwise. fileMonitorIsCancelled monitor = liftM toBool $ {#call g_file_monitor_is_cancelled#} (toFileMonitor monitor) -------------------- -- Attributes -- | Whether the monitor has been cancelled. -- -- Default value: 'False' fileMonitorCancelled :: FileMonitorClass monitor => ReadAttr monitor Bool fileMonitorCancelled = readAttrFromBoolProperty "cancelled" -- | The limit of the monitor to watch for changes, in milliseconds. -- -- Allowed values: >= 0 -- -- Default value: 800 fileMonitorRateLimit :: FileMonitorClass monitor => Attr monitor Int fileMonitorRateLimit = newAttrFromIntProperty "rate-limit" -------------------- -- Signals fileMonitorChanged :: FileMonitorClass monitor => Signal monitor (Maybe File -> Maybe File -> FileMonitorEvent -> IO ()) fileMonitorChanged = Signal (connect_MOBJECT_MOBJECT_ENUM__NONE "changed") gio-0.13.1.0/System/GIO/File/IOError.chs0000644000000000000000000000345012507510337015504 0ustar0000000000000000{-# LANGUAGE CPP #-} -- GIMP Toolkit (GTK) Binding for Haskell: binding to gio -*-haskell-*- -- -- Author : Andy Stewart -- Created: 30-Apirl-2010 -- -- Copyright (c) 2010 Andy Stewart -- -- This library is free software: you can redistribute it and/or -- modify it under the terms of the GNU Lesser General Public License -- as published by the Free Software Foundation, either version 3 of -- the License, or (at your option) any later version. -- -- This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public -- License along with this program. If not, see -- . -- -- GIO, the C library which this Haskell library depends on, is -- available under LGPL Version 2. The documentation included with -- this library is based on the original GIO documentation. -- -- | Maintainer : gtk2hs-devel@lists.sourceforge.net -- Stability : alpha -- Portability : portable (depends on GHC) module System.GIO.File.IOError ( -- * Details -- -- | Contains helper functions for reporting errors to the user. -- * Enums IOErrorEnum(..), -- * Methods ioErrorFromErrno, ) where import Control.Monad import System.GIO.Enums import System.Glib.FFI -------------------- -- Methods -- | Converts errno.h error codes into GIO error codes. ioErrorFromErrno :: Int -- ^ @err@ Error number as defined in errno.h. -> IO IOErrorEnum -- ^ returns 'IOErrorEnum' value for the given errno.h error number. ioErrorFromErrno err = liftM (toEnum . fromIntegral) $ {#call g_io_error_from_errno#} (fromIntegral err) gio-0.13.1.0/System/GIO/File/MountOperation.chs0000644000000000000000000001536012507510337017151 0ustar0000000000000000{-# LANGUAGE CPP #-} -- GIMP Toolkit (GTK) Binding for Haskell: binding to gio -*-haskell-*- -- -- Author : Andy Stewart -- Created: 30-Apirl-2010 -- -- Copyright (c) 2010 Andy Stewart -- -- This library is free software: you can redistribute it and/or -- modify it under the terms of the GNU Lesser General Public License -- as published by the Free Software Foundation, either version 3 of -- the License, or (at your option) any later version. -- -- This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public -- License along with this program. If not, see -- . -- -- GIO, the C library which this Haskell library depends on, is -- available under LGPL Version 2. The documentation included with -- this library is based on the original GIO documentation. -- -- | Maintainer : gtk2hs-devel@lists.sourceforge.net -- Stability : alpha -- Portability : portable (depends on GHC) module System.GIO.File.MountOperation ( -- * Details -- -- | 'MountOperation' provides a mechanism for interacting with the user. It can be used for -- authenticating mountable operations, such as loop mounting files, hard drive partitions or server -- locations. It can also be used to ask the user questions or show a list of applications preventing -- unmount or eject operations from completing. -- -- Note that 'Mount'Operation is used for more than just 'Mount' objects – for example it is also used in -- 'driveStart'. -- -- Users should instantiate a subclass of this that implements all the various callbacks to show the -- required dialogs, such as 'MountOperation'. If no user interaction is desired (for example when -- automounting filesystems at login time), usually 'Nothing' can be passed, see each method taking a -- 'MountOperation' for details. -- * Types MountOperation(..), MountOperationClass, -- * Enums MountOperationResult(..), AskPasswordFlags(..), PasswordSave(..), -- * Methods mountOperationNew, mountOperationReply, -- * Attributes mountOperationAnonymous, mountOperationChoice, mountOperationDomain, mountOperationPassword, mountOperationPasswordSave, mountOperationUsername, -- * Signals #if GLIB_CHECK_VERSION(2,20,0) mountOperationAborted, mountOperationAskPassword, -- askQuestion, mountOperationReplySignal, -- showProcesses, #endif ) where #include import Control.Monad import System.GIO.Enums import System.Glib.Attributes import System.Glib.FFI import System.Glib.Flags import System.Glib.GError import System.Glib.GObject import System.Glib.Properties import System.Glib.Signals import System.Glib.UTFString {#import System.GIO.Signals#} {#import System.GIO.Types#} {# context lib = "gio" prefix = "g" #} -------------------- -- Methods -- | Creates a new mount operation. mountOperationNew :: IO MountOperation mountOperationNew = wrapNewGObject mkMountOperation $ {# call g_mount_operation_new #} -- | Emits the "reply" signal. mountOperationReply :: MountOperationClass op => op -> MountOperationResult -> IO () mountOperationReply op result = {#call g_mount_operation_reply#} (toMountOperation op) ((fromIntegral . fromEnum) result) -------------------- -- Attributes -- | Whether to use an anonymous user when authenticating. -- -- Default value: 'False' mountOperationAnonymous :: MountOperationClass op => Attr op Bool mountOperationAnonymous = newAttrFromBoolProperty "anonymous" -- | The index of the user's choice when a question is asked during the mount operation. See the -- 'askQuestion' signal. -- -- Allowed values: >= 0 -- -- Default value: 0 mountOperationChoice :: MountOperationClass op => Attr op Int mountOperationChoice = newAttrFromIntProperty "choice" -- | The domain to use for the mount operation. -- -- Default value: \"\" mountOperationDomain :: (MountOperationClass op, GlibString string) => Attr op string mountOperationDomain = newAttrFromStringProperty "domain" -- | The password that is used for authentication when carrying out the mount operation. -- -- Default value: \"\" mountOperationPassword :: (MountOperationClass op, GlibString string) => Attr op string mountOperationPassword = newAttrFromStringProperty "password" -- | Determines if and how the password information should be saved. -- -- Default value: 'PasswordSaveNever' mountOperationPasswordSave :: MountOperationClass op => Attr op PasswordSave mountOperationPasswordSave = newAttrFromEnumProperty "password-save" {#call pure unsafe g_password_save_get_type #} -- | The user name that is used for authentication when carrying out the mount operation. -- -- Default value: \"\" mountOperationUsername :: (MountOperationClass op, GlibString string) => Attr op string mountOperationUsername = newAttrFromStringProperty "username" -------------------- -- Signals #if GLIB_CHECK_VERSION(2,20,0) -- | Emitted by the backend when e.g. a device becomes unavailable while a mount operation is in -- progress. -- -- Implementations of 'MountOperation' should handle this signal by dismissing open password dialogs. -- -- Since 2.20 mountOperationAborted :: MountOperationClass op => Signal op (IO ()) mountOperationAborted = Signal (connect_NONE__NONE "aborted") #endif -- | Emitted when a mount operation asks the user for a password. -- -- If the message contains a line break, the first line should be presented as a heading. For example, -- it may be used as the primary text in a 'MessageDialog'. mountOperationAskPassword :: (MountOperationClass op, GlibString string) => Signal op (string -> string -> string -> AskPasswordFlags -> IO ()) mountOperationAskPassword = Signal (connect_GLIBSTRING_GLIBSTRING_GLIBSTRING_ENUM__NONE "ask-password") -- | Emitted when asking the user a question and gives a list of choices for the user to choose from. -- -- If the message contains a line break, the first line should be presented as a heading. For example, -- it may be used as the primary text in a 'MessageDialog'. -- askQuestion :: MountOperationClass op => Signal op (String -> [String] -> IO ()) -- askQuestion Signal (\after obj user -> connect_GLIBSTRING_BOXED__NONE "ask-question" after obj -- (\message choicesPtr -> do -- choices <- peekUTFString choicesPtr -- user str choices)) -- | Emitted when the user has replied to the mount operation. mountOperationReplySignal :: MountOperationClass op => Signal op (MountOperationResult -> IO ()) mountOperationReplySignal = Signal (connect_ENUM__NONE "reply") gio-0.13.1.0/System/GIO/Icons/0000755000000000000000000000000012507510337013656 5ustar0000000000000000gio-0.13.1.0/System/GIO/Icons/Emblem.chs0000644000000000000000000000617512507510337015567 0ustar0000000000000000{-# LANGUAGE CPP #-} -- GIMP Toolkit (GTK) Binding for Haskell: binding to gio -*-haskell-*- -- -- Author : Andy Stewart -- Created: 30-Apirl-2010 -- -- Copyright (c) 2010 Andy Stewart -- -- This library is free software: you can redistribute it and/or -- modify it under the terms of the GNU Lesser General Public License -- as published by the Free Software Foundation, either version 3 of -- the License, or (at your option) any later version. -- -- This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public -- License along with this program. If not, see -- . -- -- GIO, the C library which this Haskell library depends on, is -- available under LGPL Version 2. The documentation included with -- this library is based on the original GIO documentation. -- -- | Maintainer : gtk2hs-devel@lists.sourceforge.net -- Stability : alpha -- Portability : portable (depends on GHC) module System.GIO.Icons.Emblem ( -- * Details -- -- | 'Emblem' is an implementation of 'Icon' that supports having an emblem, which is an icon with -- additional properties. It can than be added to a 'EmblemedIcon'. -- -- Currently, only metainformation about the emblem's origin is supported. More may be added in the -- future. #if GLIB_CHECK_VERSION(2,18,0) -- * Types Emblem(..), EmblemClass, -- * Enums EmblemOrigin (..), -- * Methods emblemNew, emblemNewWithOrigin, emblemGetIcon, emblemGetOrigin, #endif ) where import Control.Monad import System.GIO.Enums import System.Glib.FFI import System.Glib.Flags import System.Glib.GError import System.Glib.GObject import System.Glib.UTFString {#import System.GIO.Types#} {# context lib = "gio" prefix = "g" #} #if GLIB_CHECK_VERSION(2,18,0) ------------------- -- Methods -- | Creates a new emblem for icon. emblemNew :: IconClass icon => icon -> IO Emblem emblemNew icon = wrapNewGObject mkEmblem $ {#call g_emblem_new#} (toIcon icon) -- | Creates a new emblem for icon. emblemNewWithOrigin :: IconClass icon => icon -- ^ @icon@ a 'Icon' containing the icon. -> EmblemOrigin -- ^ @origin@ a 'EmblemOrigin' enum defining the emblem's origin -> IO Emblem emblemNewWithOrigin icon origin = wrapNewGObject mkEmblem $ {#call g_emblem_new_with_origin#} (toIcon icon) ((fromIntegral . fromEnum) origin) -- | Gives back the icon from emblem. emblemGetIcon :: EmblemClass emblem => emblem -- ^ @emblem@ a 'Emblem' from which the icon should be extracted. -> IO Icon -- ^ returns a 'Icon'. The returned object belongs to the emblem and should not be modified or freed. emblemGetIcon emblem = makeNewGObject mkIcon $ {#call g_emblem_get_icon#} (toEmblem emblem) -- | Gets the origin of the emblem. emblemGetOrigin :: EmblemClass emblem => emblem -> IO EmblemOrigin emblemGetOrigin emblem = liftM (toEnum . fromIntegral) $ {#call g_emblem_get_origin#} (toEmblem emblem) #endif gio-0.13.1.0/System/GIO/Icons/EmblemedIcon.chs0000644000000000000000000000641412507510337016705 0ustar0000000000000000{-# LANGUAGE CPP #-} -- GIMP Toolkit (GTK) Binding for Haskell: binding to gio -*-haskell-*- -- -- Author : Andy Stewart -- Created: 30-Apirl-2010 -- -- Copyright (c) 2010 Andy Stewart -- -- This library is free software: you can redistribute it and/or -- modify it under the terms of the GNU Lesser General Public License -- as published by the Free Software Foundation, either version 3 of -- the License, or (at your option) any later version. -- -- This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public -- License along with this program. If not, see -- . -- -- GIO, the C library which this Haskell library depends on, is -- available under LGPL Version 2. The documentation included with -- this library is based on the original GIO documentation. -- -- | Maintainer : gtk2hs-devel@lists.sourceforge.net -- Stability : alpha -- Portability : portable (depends on GHC) module System.GIO.Icons.EmblemedIcon ( -- * Details -- -- | 'EmblemedIcon' is an implementation of 'Icon' that supports adding an emblem to an icon. Adding -- multiple emblems to an icon is ensured via 'emblemedIconAddEmblem'. -- -- Note that 'Emblem'edIcon allows no control over the position of the emblems. See also 'Emblem' for -- more information. #if GLIB_CHECK_VERSION(2,18,0) -- * Types EmblemedIcon(..), EmblemedIconClass, -- * Methods emblemedIconNew, emblemedIconGetIcon, emblemedIconGetEmblems, emblemedIconAddEmblem, #endif ) where import Control.Monad import System.GIO.Enums import System.Glib.FFI import System.Glib.Flags import System.Glib.GError import System.Glib.GList import System.Glib.GObject import System.Glib.UTFString {#import System.GIO.Types#} {# context lib = "gio" prefix = "g" #} #if GLIB_CHECK_VERSION(2,18,0) ------------------- -- Methods -- | Creates a new emblemed icon for icon with the emblem emblem. emblemedIconNew :: (IconClass icon, EmblemClass emblem) => icon -> emblem -> IO EmblemedIcon emblemedIconNew icon emblem = {#call g_emblemed_icon_new#} (toIcon icon) (toEmblem emblem) >>= (constructNewGObject mkEmblemedIcon . return) . castPtr -- | Gets the main icon for emblemed. emblemedIconGetIcon :: EmblemedIconClass emblemed => emblemed -> IO Icon -- ^ returns a 'Icon' that is owned by emblemed emblemedIconGetIcon emblemed = makeNewGObject mkIcon $ {#call g_emblemed_icon_get_icon#} (toEmblemedIcon emblemed) -- | Gets the list of emblems for the icon. emblemedIconGetEmblems :: EmblemedIconClass emblemed => emblemed -> IO [Emblem] -- ^ returns a list of 'Emblem' s that is owned by emblemed emblemedIconGetEmblems emblemed = do glistPtr <- {#call g_emblemed_icon_get_emblems#} (toEmblemedIcon emblemed) emblemPtrs <- readGList glistPtr mapM (makeNewGObject mkEmblem . return) emblemPtrs -- | Adds emblem to the 'Emblem'. emblemedIconAddEmblem :: EmblemedIconClass emblemed => emblemed -> Emblem -> IO () emblemedIconAddEmblem emblemed emblem = {#call g_emblemed_icon_add_emblem#} (toEmblemedIcon emblemed) emblem #endif gio-0.13.1.0/System/GIO/Icons/FileIcon.chs0000644000000000000000000000412412507510337016046 0ustar0000000000000000{-# LANGUAGE CPP #-} -- GIMP Toolkit (GTK) Binding for Haskell: binding to gio -*-haskell-*- -- -- Author : Andy Stewart -- Created: 30-Apirl-2010 -- -- Copyright (c) 2010 Andy Stewart -- -- This library is free software: you can redistribute it and/or -- modify it under the terms of the GNU Lesser General Public License -- as published by the Free Software Foundation, either version 3 of -- the License, or (at your option) any later version. -- -- This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public -- License along with this program. If not, see -- . -- -- GIO, the C library which this Haskell library depends on, is -- available under LGPL Version 2. The documentation included with -- this library is based on the original GIO documentation. -- -- | Maintainer : gtk2hs-devel@lists.sourceforge.net -- Stability : alpha -- Portability : portable (depends on GHC) module System.GIO.Icons.FileIcon ( -- * Details -- -- | 'FileIcon' specifies an icon by pointing to an image file to be used as icon. -- * Types FileIcon(..), FileIconClass, -- * Methods fileIconNew, fileIconGetFile, ) where import Control.Monad import System.GIO.Enums import System.Glib.FFI import System.Glib.Flags import System.Glib.GError import System.Glib.GObject import System.Glib.UTFString {#import System.GIO.Types#} {# context lib = "gio" prefix = "g" #} ------------------- -- Methods -- | Creates a new icon for a file. fileIconNew :: FileClass file => file -> IO FileIcon fileIconNew file = {#call g_file_icon_new#} (toFile file) >>= (wrapNewGObject mkFileIcon . return) . castPtr -- | Gets the 'File' associated with the given icon. fileIconGetFile :: FileIconClass icon => icon -> IO File fileIconGetFile icon = makeNewGObject mkFile $ {#call g_file_icon_get_file#} (toFileIcon icon) gio-0.13.1.0/System/GIO/Icons/Icon.chs0000644000000000000000000001040412507510337015244 0ustar0000000000000000{-# LANGUAGE CPP #-} -- GIMP Toolkit (GTK) Binding for Haskell: binding to gio -*-haskell-*- -- -- Author : Andy Stewart -- Created: 30-Apirl-2010 -- -- Copyright (c) 2010 Andy Stewart -- -- This library is free software: you can redistribute it and/or -- modify it under the terms of the GNU Lesser General Public License -- as published by the Free Software Foundation, either version 3 of -- the License, or (at your option) any later version. -- -- This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public -- License along with this program. If not, see -- . -- -- GIO, the C library which this Haskell library depends on, is -- available under LGPL Version 2. The documentation included with -- this library is based on the original GIO documentation. -- -- | Maintainer : gtk2hs-devel@lists.sourceforge.net -- Stability : alpha -- Portability : portable (depends on GHC) module System.GIO.Icons.Icon ( -- * Details -- -- | 'Icon' is a very minimal interface for icons. It provides functions for checking the equality of two -- icons, hashing of icons and serializing an icon to and from strings. -- -- 'Icon' does not provide the actual pixmap for the icon as this is out of GIO's scope, however -- implementations of 'Icon' may contain the name of an icon (see 'ThemedIcon'), or the path to an icon -- (see GLoadableIcon). -- -- To obtain a hash of a 'Icon', see 'iconHash'. -- -- To check if two 'Icon's are equal, see 'iconEqual'. -- -- For serializing a 'Icon', use 'iconToString'. -- -- If your application or library provides one or more 'Icon' implementations you need to ensure that -- each GType is registered with the type system prior to calling 'iconNewForString'. -- * Types Icon(..), IconClass, -- * Methods iconEqual, #if GLIB_CHECK_VERSION(2,20,0) iconToString, iconNewForString, #endif ) where import Control.Monad import Data.ByteString (ByteString) import Data.ByteString (useAsCString) import Data.ByteString.Unsafe (unsafePackCStringFinalizer) import System.GIO.Enums import System.Glib.FFI import System.Glib.Flags import System.Glib.GError import System.Glib.GObject import System.Glib.UTFString {#import System.GIO.Types#} {# context lib = "gio" prefix = "g" #} -- | Checks if two icons are equal. iconEqual :: (IconClass icon1, IconClass icon2) => icon1 -> icon2 -> IO Bool -- ^ returns 'True' if icon1 is equal to icon2. 'False' otherwise. iconEqual icon1 icon2 = liftM toBool $ {#call g_icon_equal#} (toIcon icon1) (toIcon icon2) #if GLIB_CHECK_VERSION(2,20,0) -- | Generates a textual representation of icon that can be used for serialization such as when passing -- icon to a different process or saving it to persistent storage. Use 'iconNewForString' to get -- icon back from the returned string. -- -- The encoding of the returned string is proprietary to 'Icon' except in the following two cases -- -- * If icon is a 'FileIcon', the returned string is a native path (such as /path/to/my icon.png) -- without escaping if the 'File' for icon is a native file. If the file is not native, the returned -- string is the result of 'fileGetUri'. -- -- * If icon is a 'ThemedIcon' with exactly one name, the encoding is simply the name (such as -- network-server). iconToString :: IconClass icon => icon -> IO ByteString iconToString icon = do sPtr <- {#call g_icon_to_string#} (toIcon icon) sLen <- lengthArray0 0 sPtr unsafePackCStringFinalizer (castPtr sPtr) (fromIntegral sLen) ({#call unsafe g_free#} (castPtr sPtr)) -- | Generate a 'Icon' instance from str. This function can fail if str is not valid - see -- 'iconToString' for discussion. -- -- If your application or library provides one or more 'Icon' implementations you need to ensure that -- each GType is registered with the type system prior to calling 'iconNewForString'. iconNewForString :: ByteString -> IO Icon iconNewForString str = wrapNewGObject mkIcon $ useAsCString str $ \ strPtr -> propagateGError ({# call g_icon_new_for_string #} strPtr) #endif gio-0.13.1.0/System/GIO/Icons/ThemedIcon.chs0000644000000000000000000000736712507510337016411 0ustar0000000000000000{-# LANGUAGE CPP #-} -- GIMP Toolkit (GTK) Binding for Haskell: binding to gio -*-haskell-*- -- -- Author : Andy Stewart -- Created: 30-Apirl-2010 -- -- Copyright (c) 2010 Andy Stewart -- -- This library is free software: you can redistribute it and/or -- modify it under the terms of the GNU Lesser General Public License -- as published by the Free Software Foundation, either version 3 of -- the License, or (at your option) any later version. -- -- This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public -- License along with this program. If not, see -- . -- -- GIO, the C library which this Haskell library depends on, is -- available under LGPL Version 2. The documentation included with -- this library is based on the original GIO documentation. -- -- | Maintainer : gtk2hs-devel@lists.sourceforge.net -- Stability : alpha -- Portability : portable (depends on GHC) module System.GIO.Icons.ThemedIcon ( -- * Details -- -- | 'ThemeIcon' specifies an icon by pointing to an image file to be used as icon. -- * Types ThemedIcon(..), ThemedIconClass, -- * Methods themedIconNew, themedIconNewFromNames, #if GLIB_CHECK_VERSION(2,18,0) themedIconPrependName, #endif themedIconAppendName, themedIconGetNames, ) where import Control.Monad import Data.ByteString (ByteString) import Data.ByteString (useAsCString) import Data.ByteString.Unsafe (unsafePackCStringFinalizer) import System.GIO.Enums import System.Glib.FFI import System.Glib.Flags import System.Glib.GError import System.Glib.GObject import System.Glib.UTFString {#import System.GIO.Types#} {# context lib = "gio" prefix = "g" #} ------------------- -- Methods -- | Creates a new icon for a file. themedIconNew :: ByteString -- ^ @iconname@ a string containing an icon name. -> IO ThemedIcon themedIconNew iconName = useAsCString iconName $ \ iconNamePtr -> {#call g_themed_icon_new#} iconNamePtr >>= (wrapNewGObject mkThemedIcon . return) . castPtr -- | Creates a new themed icon for iconnames. themedIconNewFromNames :: GlibString string => [string] -- ^ @iconnames@ an array of strings containing icon names. -> IO ThemedIcon themedIconNewFromNames iconNames = do let len = if null iconNames then (-1) else length iconNames withUTFStringArray iconNames $ \ iconNamesPtr -> {#call g_themed_icon_new_from_names#} iconNamesPtr (fromIntegral len) >>= (wrapNewGObject mkThemedIcon . return) . castPtr #if GLIB_CHECK_VERSION(2,18,0) -- | Prepend a name to the list of icons from within icon. themedIconPrependName :: (ThemedIconClass icon, GlibString string) => icon -> string -- ^ @iconname@ name of icon to prepend to list of icons from within icon. -> IO () themedIconPrependName icon iconname = withUTFString iconname $ \ iconnamePtr -> {#call g_themed_icon_prepend_name#} (toThemedIcon icon) iconnamePtr #endif -- | Append a name to the list of icons from within icon. themedIconAppendName :: (ThemedIconClass icon, GlibString string) => icon -> string -- ^ @iconname@ name of icon to append to list of icons from within icon. -> IO () themedIconAppendName icon iconname = withUTFString iconname $ \ iconnamePtr -> {#call g_themed_icon_append_name#} (toThemedIcon icon) iconnamePtr -- | Gets the names of icons from within icon. themedIconGetNames :: (ThemedIconClass icon, GlibString string) => icon -> IO [string] -- ^ returns a list of icon names. themedIconGetNames icon = {#call g_themed_icon_get_names#} (toThemedIcon icon) >>= readUTFStringArray0 gio-0.13.1.0/System/GIO/Volumes/0000755000000000000000000000000012507510337014235 5ustar0000000000000000gio-0.13.1.0/System/GIO/Volumes/Drive.chs0000644000000000000000000003474512507510337016022 0ustar0000000000000000{-# LANGUAGE CPP #-} -- GIMP Toolkit (GTK) Binding for Haskell: binding to gio -*-haskell-*- -- -- Author : Andy Stewart -- Created: 30-Apirl-2010 -- -- Copyright (c) 2010 Andy Stewart -- -- This library is free software: you can redistribute it and/or -- modify it under the terms of the GNU Lesser General Public License -- as published by the Free Software Foundation, either version 3 of -- the License, or (at your option) any later version. -- -- This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public -- License along with this program. If not, see -- . -- -- GIO, the C library which this Haskell library depends on, is -- available under LGPL Version 2. The documentation included with -- this library is based on the original GIO documentation. -- -- | Maintainer : gtk2hs-devel@lists.sourceforge.net -- Stability : alpha -- Portability : portable (depends on GHC) module System.GIO.Volumes.Drive ( -- * Details -- -- | 'Drive' - this represent a piece of hardware connected to the machine. It's generally only created -- for removable hardware or hardware with removable media. -- -- 'Drive' is a container class for 'Volume' objects that stem from the same piece of media. As such, -- 'Drive' abstracts a drive with (or without) removable media and provides operations for querying -- whether media is available, determing whether media change is automatically detected and ejecting -- the media. -- -- If the 'Drive' reports that media isn't automatically detected, one can poll for media; typically one -- should not do this periodically as a poll for media operation is potententially expensive and may -- spin up the drive creating noise. -- -- 'Drive' supports starting and stopping drives with authentication support for the former. This can be -- used to support a diverse set of use cases including connecting/disconnecting iSCSI devices, -- powering down external disk enclosures and starting/stopping multi-disk devices such as RAID -- devices. Note that the actual semantics and side-effects of starting/ stopping a 'Drive' may vary -- according to implementation. To choose the correct verbs in e.g. a file manager, use -- 'driveGetStartStopType'. -- -- For porting from GnomeVFS note that there is no equivalent of 'Drive' in that API. -- * Types Drive(..), DriveClass, -- * Enums, #if GLIB_CHECK_VERSION(2,22,0) DriveStartStopType (..), DriveStartFlags (..), #endif -- * Methods driveGetName, driveGetIcon, driveHasVolumes, driveGetVolumes, driveCanEject, #if GLIB_CHECK_VERSION(2,22,0) driveGetStartStopType, driveCanStart, driveCanStartDegraded, driveCanStop, #endif driveCanPollForMedia, drivePollForMedia, driveHasMedia, driveIsMediaCheckAutomatic, driveIsMediaRemovable, #if GLIB_CHECK_VERSION(2,22,0) driveEjectWithOperation, driveEjectWithOperationFinish, driveStart, driveStartFinish, driveStopFinish, #endif driveEnumerateIdentifiers, driveGetIdentifier, -- * Signals driveChanged, driveDisconnected, driveEjectButton, #if GLIB_CHECK_VERSION(2,22,0) driveStopButton, #endif ) where import Control.Monad import Data.Maybe (fromMaybe) import System.GIO.Enums import System.Glib.Attributes import System.Glib.FFI import System.Glib.Flags import System.Glib.GError import System.Glib.GList import System.Glib.GObject import System.Glib.Properties import System.Glib.Signals import System.Glib.UTFString {#import System.GIO.Async.AsyncResult#} {#import System.GIO.Signals#} {#import System.GIO.Types#} {# context lib = "gio" prefix = "g" #} -------------------- -- Methods -- | Gets the name of drive. driveGetName :: (DriveClass drive, GlibString string) => drive -> IO string -- ^ returns the name for the given drive. driveGetName drive = {#call g_drive_get_name#} (toDrive drive) >>= readUTFString -- | Gets the icon for drive. driveGetIcon :: DriveClass drive => drive -> IO Icon -- ^ returns a 'Icon'. driveGetIcon drive = wrapNewGObject mkIcon $ {#call g_drive_get_icon#} (toDrive drive) -- | Check if drive has any mountable volumes. driveHasVolumes :: DriveClass drive => drive -> IO Bool -- ^ returns 'True' if the drive contains volumes, 'False' otherwise. driveHasVolumes drive = liftM toBool $ {#call g_drive_has_volumes#} (toDrive drive) -- | Get a list of mountable volumes for drive. driveGetVolumes :: DriveClass drive => drive -> IO [Volume] driveGetVolumes drive = do glistPtr <- {#call g_drive_get_volumes #} (toDrive drive) volumePtrs <- fromGList glistPtr mapM (wrapNewGObject mkVolume . return) volumePtrs -- | Checks if drive can be eject. driveCanEject :: DriveClass drive => drive -> IO Bool -- ^ returns 'True' if the drive can be ejected. driveCanEject drive = liftM toBool $ {#call g_drive_can_eject#} (toDrive drive) #if GLIB_CHECK_VERSION(2,22,0) -- | Gets a hint about how a drive can be started/stopped. driveGetStartStopType :: DriveClass drive => drive -> IO DriveStartStopType -- ^ returns A value from the 'DriveStartStopType' enumeration. driveGetStartStopType drive = liftM (toEnum . fromIntegral) $ {#call g_drive_get_start_stop_type#} (toDrive drive) -- | Checks if a drive can be started. driveCanStart :: DriveClass drive => drive -> IO Bool -- ^ returns 'True' if the drive can be started, 'False' otherwise. driveCanStart drive = liftM toBool $ {#call g_drive_can_start#} (toDrive drive) -- | Checks if a drive can be started degraded. driveCanStartDegraded :: DriveClass drive => drive -> IO Bool -- ^ returns 'True' if the drive can be started degraded, 'False' otherwise. driveCanStartDegraded drive = liftM toBool $ {#call g_drive_can_start_degraded#} (toDrive drive) -- | Checks if a drive can be stoped. driveCanStop :: DriveClass drive => drive -> IO Bool -- ^ returns 'True' if the drive can be stoped, 'False' otherwise. driveCanStop drive = liftM toBool $ {#call g_drive_can_stop#} (toDrive drive) #endif -- | Checks if a drive can be polled for media changes. driveCanPollForMedia :: DriveClass drive => drive -> IO Bool driveCanPollForMedia drive = liftM toBool $ {#call g_drive_can_poll_for_media#} (toDrive drive) -- | Asynchronously polls drive to see if media has been inserted or removed. -- -- When the operation is finished, callback will be called. You can then call -- 'drivePollForMediaFinish' to obtain the result of the operation. drivePollForMedia :: DriveClass drive => drive -> Maybe Cancellable -> AsyncReadyCallback -> IO () drivePollForMedia drive cancellable callback = do cCallback <- marshalAsyncReadyCallback callback {#call g_drive_poll_for_media #} (toDrive drive) (fromMaybe (Cancellable nullForeignPtr) cancellable) cCallback (castFunPtrToPtr cCallback) -- | Finishes an operation started with 'drivePollForMedia' on a drive. -- -- Throws a 'GError' if an error occurs. drivePollForMediaFinish :: DriveClass drive => drive -> AsyncResult -- ^ @result@ a 'AsyncResult'. -> IO () drivePollForMediaFinish drive result = propagateGError (\gErrorPtr -> do {#call g_drive_poll_for_media_finish #} (toDrive drive) result gErrorPtr return ()) -- | Checks if the drive has media. Note that the OS may not be polling the drive for media changes; see -- 'driveIsMediaCheckAutomatic' for more details. driveHasMedia :: DriveClass drive => drive -> IO Bool -- ^ returns 'True' if drive has media, 'False' otherwise. driveHasMedia drive = liftM toBool $ {#call g_drive_has_media#} (toDrive drive) -- | Checks if drive is capabable of automatically detecting media changes. driveIsMediaCheckAutomatic :: DriveClass drive => drive -> IO Bool -- ^ returns 'True' if the drive is capabable of automatically detecting media changes, 'False' otherwise. driveIsMediaCheckAutomatic drive = liftM toBool $ {#call g_drive_is_media_check_automatic#} (toDrive drive) -- | Checks if the drive supports removable media. driveIsMediaRemovable :: DriveClass drive => drive -> IO Bool -- ^ returns 'True' if drive supports removable media, 'False' otherwise. driveIsMediaRemovable drive = liftM toBool $ {#call g_drive_is_media_removable#} (toDrive drive) #if GLIB_CHECK_VERSION(2,22,0) -- | Ejects a drive. This is an asynchronous operation, and is finished by calling -- 'driveEjectWithOperationFinish' with the drive and 'AsyncResult' data returned in the callback. driveEjectWithOperation :: DriveClass drive => drive -> [MountUnmountFlags] -- ^ @flags@ flags affecting the unmount if required for eject -> Maybe MountOperation -- ^ @mountOperation@ a 'MountOperation' or 'Nothing' to avoid user interaction. -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore. -> AsyncReadyCallback -- ^ @callback@ a 'AsyncReadyCallback' -> IO () driveEjectWithOperation drive flags mountOperation cancellable callback = do cCallback <- marshalAsyncReadyCallback callback {#call g_drive_eject_with_operation #} (toDrive drive) ((fromIntegral . fromFlags) flags) (fromMaybe (MountOperation nullForeignPtr) mountOperation) (fromMaybe (Cancellable nullForeignPtr) cancellable) cCallback (castFunPtrToPtr cCallback) -- | Finishes ejecting a drive. If any errors occurred during the operation, error will be set to contain -- the errors and 'False' will be returned. -- -- Throws a 'GError' if an error occurs. driveEjectWithOperationFinish :: DriveClass drive => drive -> AsyncResult -- ^ @result@ a 'AsyncResult'. -> IO () driveEjectWithOperationFinish drive result = propagateGError (\gErrorPtr -> do {#call g_drive_eject_with_operation_finish #} (toDrive drive) result gErrorPtr return ()) -- | Asynchronously starts a drive. -- -- When the operation is finished, callback will be called. You can then call 'driveStartFinish' to -- obtain the result of the operation. driveStart :: DriveClass drive => drive -> [DriveStartFlags] -- ^ @flags@ flags affecting the start operation. -> Maybe MountOperation -- ^ @mountOperation@ a 'MountOperation' or 'Nothing' to avoid user interaction. -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore. -> AsyncReadyCallback -- ^ @callback@ a 'AsyncReadyCallback' -> IO () driveStart drive flags mountOperation cancellable callback = do cCallback <- marshalAsyncReadyCallback callback {#call g_drive_start #} (toDrive drive) ((fromIntegral . fromFlags) flags) (fromMaybe (MountOperation nullForeignPtr) mountOperation) (fromMaybe (Cancellable nullForeignPtr) cancellable) cCallback (castFunPtrToPtr cCallback) -- | Finishes starting a drive. -- -- Throws a 'GError' if an error occurs. driveStartFinish :: DriveClass drive => drive -> AsyncResult -- ^ @result@ a 'AsyncResult'. -> IO () driveStartFinish drive result = propagateGError (\gErrorPtr -> do {#call g_drive_start_finish #} (toDrive drive) result gErrorPtr return ()) -- | Asynchronously stops a drive. -- -- When the operation is finished, callback will be called. You can then call 'driveStopFinish' to -- obtain the result of the operation. driveStop :: DriveClass drive => drive -> [MountUnmountFlags] -- ^ @flags@ flags affecting the stop operation. -> Maybe MountOperation -- ^ @mountOperation@ a 'MountOperation' or 'Nothing' to avoid user interaction. -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore. -> AsyncReadyCallback -- ^ @callback@ a 'AsyncReadyCallback' -> IO () driveStop drive flags mountOperation cancellable callback = do cCallback <- marshalAsyncReadyCallback callback {#call g_drive_stop #} (toDrive drive) ((fromIntegral . fromFlags) flags) (fromMaybe (MountOperation nullForeignPtr) mountOperation) (fromMaybe (Cancellable nullForeignPtr) cancellable) cCallback (castFunPtrToPtr cCallback) -- | Finishes stoping a drive. -- -- Throws a 'GError' if an error occurs. driveStopFinish :: DriveClass drive => drive -> AsyncResult -- ^ @result@ a 'AsyncResult'. -> IO () driveStopFinish drive result = propagateGError (\gErrorPtr -> do {#call g_drive_stop_finish #} (toDrive drive) result gErrorPtr return ()) #endif -- | Gets the kinds of identifiers that drive has. Use 'driveGetIdentifer' to obtain the -- identifiers themselves. driveEnumerateIdentifiers :: (DriveClass drive, GlibString string) => drive -> IO [string] driveEnumerateIdentifiers drive = {#call g_drive_enumerate_identifiers#} (toDrive drive) >>= readUTFStringArray0 -- | Gets the identifier of the given kind for drive. See the introduction for more information about -- drive identifiers. driveGetIdentifier :: (DriveClass drive, GlibString string) => drive -> string -- ^ @kind@ the kind of identifier to return -> IO string driveGetIdentifier drive kind = withUTFString kind $ \ kindPtr -> {#call g_drive_get_identifier#} (toDrive drive) kindPtr >>= readUTFString -------------------- -- Signals -- | Emitted when a drive changes. driveChanged :: DriveClass drive => Signal drive (Drive -> IO ()) driveChanged = Signal (connect_OBJECT__NONE "drive-changed") -- | Emitted when a drive changes. driveDisconnected :: DriveClass drive => Signal drive (Drive -> IO ()) driveDisconnected = Signal (connect_OBJECT__NONE "drive-disconnected") -- | Emitted when the eject button is pressed on drive. driveEjectButton :: DriveClass drive => Signal drive (Drive -> IO ()) driveEjectButton = Signal (connect_OBJECT__NONE "drive-eject-button") #if GLIB_CHECK_VERSION(2,22,0) -- | Emitted when the stop button is pressed on drive. driveStopButton :: DriveClass drive => Signal drive (Drive -> IO ()) driveStopButton = Signal (connect_OBJECT__NONE "drive-stop-button") #endif gio-0.13.1.0/System/GIO/Volumes/Mount.chs0000644000000000000000000004205112507510337016040 0ustar0000000000000000{-# LANGUAGE CPP #-} -- GIMP Toolkit (GTK) Binding for Haskell: binding to gio -*-haskell-*- -- -- Author : Andy Stewart -- Created: 30-Apirl-2010 -- -- Copyright (c) 2010 Andy Stewart -- -- This library is free software: you can redistribute it and/or -- modify it under the terms of the GNU Lesser General Public License -- as published by the Free Software Foundation, either version 3 of -- the License, or (at your option) any later version. -- -- This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public -- License along with this program. If not, see -- . -- -- GIO, the C library which this Haskell library depends on, is -- available under LGPL Version 2. The documentation included with -- this library is based on the original GIO documentation. -- -- | Maintainer : gtk2hs-devel@lists.sourceforge.net -- Stability : alpha -- Portability : portable (depends on GHC) module System.GIO.Volumes.Mount ( -- * Details -- -- | The 'Mount' interface represents user-visible mounts. Note, when porting from GnomeVFS, 'Mount' is the -- moral equivalent of GnomeVFSVolume. -- -- 'Mount' is a "mounted" filesystem that you can access. Mounted is in quotes because it's not the same -- as a unix mount, it might be a gvfs mount, but you can still access the files on it if you use -- GIO. Might or might not be related to a volume object. -- -- Unmounting a 'Mount' instance is an asynchronous operation. For more information about asynchronous -- operations, see 'AsyncReady' and GSimpleAsyncReady. To unmount a 'Mount' instance, first call -- 'mountUnmountWithOperation' the 'Mount' instance and a 'AsyncReadyCallback'. The -- callback will be fired when the operation has resolved (either with success or failure), and a -- 'AsyncReady' structure will be passed to the callback. That callback should then call -- 'mountUnmountWithOperationFinish' with the 'Mount' and the 'AsyncReady' data to see if the -- operation was completed successfully. If an error is present when -- 'mountUnmountWithOperationFinish' is called, then it will be filled with any error -- information. -- * Types Mount(..), MountClass, -- * Methods mountGetName, mountGetUUID, mountGetIcon, mountGetDrive, mountGetRoot, mountGetVolume, #if GLIB_CHECK_VERSION(2,24,0) mountGetDefaultLocation, #endif mountCanUnmount, #if GLIB_CHECK_VERSION(2,22,0) mountUnmountWithOperation, mountUnmountWithOperationFinish, #endif mountRemount, mountRemountFinish, mountCanEject, #if GLIB_CHECK_VERSION(2,22,0) mountEjectWithOperation, mountEjectWithOperationFinish, #endif #if GLIB_CHECK_VERSION(2,18,0) mountGuessContentType, mountGuessContentTypeFinish, mountGuessContentTypeSync, #endif #if GLIB_CHECK_VERSION(2,20,0) mountIsShadowed, mountShadow, mountUnshadow, #endif -- * Signals mountChanged, #if GLIB_CHECK_VERSION(2,22,0) mountPreUnmount, #endif mountUnmounted, ) where import Control.Monad import Data.Maybe (fromMaybe) import System.GIO.Enums import System.Glib.Attributes import System.Glib.FFI import System.Glib.Flags import System.Glib.GError import System.Glib.GList import System.Glib.GObject import System.Glib.Properties import System.Glib.Signals import System.Glib.UTFString {#import System.GIO.Async.AsyncResult#} {#import System.GIO.Signals#} {#import System.GIO.Types#} {# context lib = "gio" prefix = "g" #} -------------------- -- Methods -- | Gets the name of mount. mountGetName :: (MountClass mount, GlibString string) => mount -> IO string -- ^ returns the name for the given mount. mountGetName mount = {#call g_mount_get_name#} (toMount mount) >>= readUTFString -- | Gets the UUID for the mount. The reference is typically based on the file system UUID for the mount -- in question and should be considered an opaque string. Returns 'Nothing' if there is no UUID available. mountGetUUID :: (MountClass mount, GlibString string) => mount -> IO (Maybe string) -- ^ returns the UUID for mount or 'Nothing' if no UUID can be computed. mountGetUUID mount = do {#call g_mount_get_uuid#} (toMount mount) >>= maybePeek readUTFString -- | Gets the icon for mount. mountGetIcon :: MountClass mount => mount -> IO Icon -- ^ returns a 'Icon'. mountGetIcon mount = wrapNewGObject mkIcon $ {#call g_mount_get_icon#} (toMount mount) -- | Gets the drive for the mount. -- -- This is a convenience method for getting the 'Volume' and then using that object to get the 'Drive'. mountGetDrive :: MountClass mount => mount -> IO (Maybe Drive) -- ^ returns the 'Drive' for mount or 'Nothing' if no 'Drive' can be computed. mountGetDrive mount = maybeNull (wrapNewGObject mkDrive) $ {#call g_mount_get_drive#} (toMount mount) -- | Gets the root directory on mount. mountGetRoot :: MountClass mount => mount -> IO File mountGetRoot mount = wrapNewGObject mkFile $ {#call g_mount_get_root#} (toMount mount) -- | Gets the volume directory on mount. mountGetVolume :: MountClass mount => mount -> IO (Maybe Volume) -- ^ returns a 'Volume' or 'Nothing' if mount is not associated with a volume. mountGetVolume mount = maybeNull (wrapNewGObject mkVolume) $ {#call g_mount_get_volume#} (toMount mount) #if GLIB_CHECK_VERSION(2,24,0) -- | Gets the default location of mount. The default location of the given mount is a path that reflects -- the main entry point for the user (e.g. the home directory, or the root of the volume). -- | Gets the root directory on mount. mountGetDefaultLocation :: MountClass mount => mount -> IO File mountGetDefaultLocation mount = wrapNewGObject mkFile $ {#call g_mount_get_default_location#} (toMount mount) #endif -- | Checks if mount can be mounted. mountCanUnmount :: MountClass mount => mount -> IO Bool -- ^ returns 'True' if the mount can be unmounted. mountCanUnmount mount = liftM toBool $ {#call g_mount_can_unmount#} (toMount mount) #if GLIB_CHECK_VERSION(2,22,0) -- | Unmounts a mount. This is an asynchronous operation, and is finished by calling -- 'mountUnmountWithOperationFinish' with the mount and 'AsyncResult' data returned in the -- callback. mountUnmountWithOperation :: MountClass mount => mount -> [MountUnmountFlags] -- ^ @flags@ flags affecting the unmount if required for eject -> Maybe MountOperation -- ^ @mountOperation@ a 'MountOperation' or 'Nothing' to avoid user interaction. -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore. -> AsyncReadyCallback -- ^ @callback@ a 'AsyncReadyCallback' -> IO () mountUnmountWithOperation mount flags mountOperation cancellable callback = do cCallback <- marshalAsyncReadyCallback callback {#call g_mount_unmount_with_operation #} (toMount mount) ((fromIntegral . fromFlags) flags) (fromMaybe (MountOperation nullForeignPtr) mountOperation) (fromMaybe (Cancellable nullForeignPtr) cancellable) cCallback (castFunPtrToPtr cCallback) -- | Finishes unmounting a mount. If any errors occurred during the operation, error will be set to -- contain the errors and 'False' will be returned. -- -- Throws a 'GError' if an error occurs. mountUnmountWithOperationFinish :: MountClass mount => mount -> AsyncResult -- ^ @result@ a 'AsyncResult'. -> IO () mountUnmountWithOperationFinish mount result = propagateGError (\gErrorPtr -> do {#call g_mount_unmount_with_operation_finish #} (toMount mount) result gErrorPtr return ()) #endif -- | Remounts a mount. This is an asynchronous operation, and is finished by calling -- 'mountRemountFinish' with the mount and 'AsyncResult's data returned in the callback. -- -- Remounting is useful when some setting affecting the operation of the volume has been changed, as -- these may need a remount to take affect. While this is semantically equivalent with unmounting and -- then remounting not all backends might need to actually be unmounted. mountRemount :: MountClass mount => mount -> [MountMountFlags] -- ^ @flags@ flags affecting the unmount if required for eject -> Maybe MountOperation -- ^ @mountOperation@ a 'MountOperation' or 'Nothing' to avoid user interaction. -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore. -> AsyncReadyCallback -- ^ @callback@ a 'AsyncReadyCallback' -> IO () mountRemount mount flags mountOperation cancellable callback = do cCallback <- marshalAsyncReadyCallback callback {#call g_mount_remount #} (toMount mount) ((fromIntegral . fromFlags) flags) (fromMaybe (MountOperation nullForeignPtr) mountOperation) (fromMaybe (Cancellable nullForeignPtr) cancellable) cCallback (castFunPtrToPtr cCallback) -- | Finishes remounting a mount. If any errors occurred during the operation, error will be set to -- contain the errors and 'False' will be returned. -- -- Throws a 'GError' if an error occurs. mountRemountFinish :: MountClass mount => mount -> AsyncResult -- ^ @result@ a 'AsyncResult'. -> IO () mountRemountFinish mount result = propagateGError (\gErrorPtr -> do {#call g_mount_remount_finish #} (toMount mount) result gErrorPtr return ()) -- | Checks if mount can be eject. mountCanEject :: MountClass mount => mount -> IO Bool -- ^ returns 'True' if the mount can be ejected. mountCanEject mount = liftM toBool $ {#call g_mount_can_eject#} (toMount mount) #if GLIB_CHECK_VERSION(2,22,0) -- | Ejects a mount. This is an asynchronous operation, and is finished by calling -- 'mountEjectWithOperationFinish' with the mount and 'AsyncResult' data returned in the callback. mountEjectWithOperation :: MountClass mount => mount -> [MountUnmountFlags] -- ^ @flags@ flags affecting the unmount if required for eject -> Maybe MountOperation -- ^ @mountOperation@ a 'MountOperation' or 'Nothing' to avoid user interaction. -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore. -> AsyncReadyCallback -- ^ @callback@ a 'AsyncReadyCallback' -> IO () mountEjectWithOperation mount flags mountOperation cancellable callback = do cCallback <- marshalAsyncReadyCallback callback {#call g_mount_eject_with_operation #} (toMount mount) ((fromIntegral . fromFlags) flags) (fromMaybe (MountOperation nullForeignPtr) mountOperation) (fromMaybe (Cancellable nullForeignPtr) cancellable) cCallback (castFunPtrToPtr cCallback) -- | Finishes ejecting a mount. If any errors occurred during the operation. -- -- Throws a 'GError' if an error occurs. mountEjectWithOperationFinish :: MountClass mount => mount -> AsyncResult -- ^ @result@ a 'AsyncResult'. -> IO () mountEjectWithOperationFinish mount result = propagateGError (\gErrorPtr -> do {#call g_mount_eject_with_operation_finish #} (toMount mount) result gErrorPtr return ()) #endif #if GLIB_CHECK_VERSION(2,18,0) -- | Tries to guess the type of content stored on mount. Returns one or more textual identifiers of -- well-known content types (typically prefixed with \"x-content/\"), e.g. x-content/image-dcf for camera -- memory cards. See the shared-mime-info specification for more on x-content types. -- -- This is an asynchronous operation (see 'mountGuessContentTypeSync' for the synchronous -- version), and is finished by calling 'mountGuessContentTypeFinish' with the mount and -- 'AsyncResult' data returned in the callback. mountGuessContentType :: MountClass mount => mount -> Bool -- ^ @forceRescan@ Whether to force a rescan of the content. Otherwise a cached result will be used if available -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore -> AsyncReadyCallback -- ^ @callback@ a 'AsyncReadyCallback' -> IO () mountGuessContentType mount forceRescan cancellable callback = do cCallback <- marshalAsyncReadyCallback callback {#call g_mount_guess_content_type #} (toMount mount) (fromBool forceRescan) (fromMaybe (Cancellable nullForeignPtr) cancellable) cCallback (castFunPtrToPtr cCallback) -- | Finishes guessing content types of mount. If any errors occured during the operation, error will be -- set to contain the errors and 'False' will be returned. In particular, you may get an -- 'IoErrorNotSupported' if the mount does not support content guessing. mountGuessContentTypeFinish :: (MountClass mount, GlibString string) => mount -> AsyncResult -- ^ @result@ a 'AsyncResult'. -> IO [string] -- ^ returns 'True' if the mount was successfully ejected. 'False' otherwise. mountGuessContentTypeFinish mount result = propagateGError ({#call g_mount_guess_content_type_finish #} (toMount mount) result) >>= readUTFStringArray0 -- | Tries to guess the type of content stored on mount. Returns one or more textual identifiers of -- well-known content types (typically prefixed with \"x-content/\"), e.g. x-content/image-dcf for camera -- memory cards. See the shared-mime-info specification for more on x-content types. -- -- This is an synchronous operation and as such may block doing IO; see 'mountGuessContentType' -- for the asynchronous version. mountGuessContentTypeSync :: (MountClass mount, GlibString string) => mount -> Bool -- ^ @forceRescan@ Whether to force a rescan of the content. Otherwise a cached result will be used if available -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore -> IO [string] mountGuessContentTypeSync mount forceRescan cancellable = propagateGError ({#call g_mount_guess_content_type_sync #} (toMount mount) (fromBool forceRescan) (fromMaybe (Cancellable nullForeignPtr) cancellable) ) >>= readUTFStringArray0 #endif #if GLIB_CHECK_VERSION(2,20,0) -- | Determines if mount is shadowed. Applications or libraries should avoid displaying mount in the user -- interface if it is shadowed. -- -- A mount is said to be shadowed if there exists one or more user visible objects (currently 'Mount' -- objects) with a root that is inside the root of mount. -- -- One application of shadow mounts is when exposing a single file system that is used to address -- several logical volumes. In this situation, a 'VolumeMonitor' implementation would create two 'Volume' -- objects (for example, one for the camera functionality of the device and one for a SD card reader on -- the device) with activation URIs gphoto2://[usb:001,002]/store1/ and -- gphoto2://[usb:001,002]/store2/. When the underlying mount (with root gphoto2://[usb:001,002]/) is -- mounted, said 'VolumeMonitor' implementation would create two 'Mount' objects (each with their root -- matching the corresponding volume activation root) that would shadow the original mount. -- -- The proxy monitor in GVfs 2.26 and later, automatically creates and manage shadow mounts (and -- shadows the underlying mount) if the activation root on a 'Volume' is set. mountIsShadowed :: MountClass mount => mount -> IO Bool -- ^ returns 'True' if mount is shadowed. mountIsShadowed mount = liftM toBool $ {#call g_mount_is_shadowed#} (toMount mount) -- | Increments the shadow count on mount. Usually used by 'VolumeMonitor' implementations when creating a -- shadow mount for mount, see 'mountIsShadowed' for more information. The caller will need to emit -- the "changed" signal on mount manually. mountShadow :: MountClass mount => mount -> IO () mountShadow mount = {#call g_mount_shadow#} (toMount mount) -- | Decrements the shadow count on mount. Usually used by 'VolumeMonitor' implementations when destroying -- a shadow mount for mount, see 'mountIsShadowed' for more information. The caller will need to -- emit the "changed" signal on mount manually. mountUnshadow :: MountClass mount => mount -> IO () mountUnshadow mount = {#call g_mount_unshadow#} (toMount mount) #endif -------------------- -- Signals -- | Emitted when the mount has been changed. mountChanged :: MountClass mount => Signal mount (IO ()) mountChanged = Signal (connect_NONE__NONE "changed") #if GLIB_CHECK_VERSION(2,22,0) -- | This signal is emitted when the 'Mount' is about to be unmounted. mountPreUnmount :: MountClass mount => Signal mount (IO ()) mountPreUnmount = Signal (connect_NONE__NONE "pre-unmount") #endif -- | This signal is emitted when the 'Mount' have been unmounted. If the recipient is holding references -- to the object they should release them so the object can be finalized. mountUnmounted :: MountClass mount => Signal mount (IO ()) mountUnmounted = Signal (connect_NONE__NONE "unmounted") gio-0.13.1.0/System/GIO/Volumes/Volume.chs0000644000000000000000000003006612507510337016210 0ustar0000000000000000{-# LANGUAGE CPP #-} -- GIMP Toolkit (GTK) Binding for Haskell: binding to gio -*-haskell-*- -- -- Author : Andy Stewart -- Created: 30-Apirl-2010 -- -- Copyright (c) 2010 Andy Stewart -- -- This library is free software: you can redistribute it and/or -- modify it under the terms of the GNU Lesser General Public License -- as published by the Free Software Foundation, either version 3 of -- the License, or (at your option) any later version. -- -- This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public -- License along with this program. If not, see -- . -- -- GIO, the C library which this Haskell library depends on, is -- available under LGPL Version 2. The documentation included with -- this library is based on the original GIO documentation. -- -- | Maintainer : gtk2hs-devel@lists.sourceforge.net -- Stability : alpha -- Portability : portable (depends on GHC) module System.GIO.Volumes.Volume ( -- * Details -- -- | The 'Volume' interface represents user-visible objects that can be mounted. Note, when porting from -- GnomeVFS, 'Volume' is the moral equivalent of GnomeVFSDrive. -- -- Mounting a 'Volume' instance is an asynchronous operation. For more information about asynchronous -- operations, see 'AsyncReady' and GSimpleAsyncReady. To mount a 'Volume', first call 'volumeMount' -- with (at least) the 'Volume' instance, optionally a 'MountOperation' object and a 'AsyncReadyCallback'. -- -- Typically, one will only want to pass 'Nothing' for the 'MountOperation' if automounting all volumes when -- a desktop session starts since it's not desirable to put up a lot of dialogs asking for credentials. -- -- The callback will be fired when the operation has resolved (either with success or failure), and a -- 'AsyncReady' structure will be passed to the callback. That callback should then call -- 'volumeMountFinish' with the 'Volume' instance and the 'AsyncReady' data to see if the operation -- was completed successfully. If an error is present when 'volumeMountFinish' is called, then it -- will be filled with any error information. -- -- It is sometimes necessary to directly access the underlying operating system object behind a volume -- (e.g. for passing a volume to an application via the commandline). For this purpose, GIO allows to -- obtain an 'identifier' for the volume. There can be different kinds of identifiers, such as Hal -- UDIs, filesystem labels, traditional Unix devices (e.g. /dev/sda2), uuids. GIO uses predefind -- strings as names for the different kinds of identifiers: 'VolumeIdentifierKindHalUdi', -- 'VolumeIdentifierKindLabel', etc. Use 'volumeGetIdentifier' to obtain an identifier for a -- volume. -- -- Note that 'VolumeIdentifierKindHalUdi' will only be available when the gvfs hal volume monitor -- is in use. Other volume monitors will generally be able to provide the -- 'VolumeIdentifierKindUnixDevice' identifier, which can be used to obtain a hal device by means -- of 'mangerFindDeviceStringMatch'. -- * Types Volume(..), VolumeClass, -- * Methods volumeGetName, volumeGetUUID, volumeGetIcon, volumeGetDrive, volumeGetMount, volumeCanMount, volumeShouldAutomount, #if GLIB_CHECK_VERSION(2,18,0) volumeGetActivationRoot, #endif volumeMount, volumeMountFinish, volumeCanEject, #if GLIB_CHECK_VERSION(2,22,0) volumeEjectWithOperation, volumeEjectWithOperationFinish, #endif volumeEnumerateIdentifiers, volumeGetIdentifier, -- * Signals volumeChanged, volumeRemoved, ) where import Control.Monad import Data.Maybe (fromMaybe) import System.GIO.Enums import System.Glib.Attributes import System.Glib.FFI import System.Glib.Flags import System.Glib.GError import System.Glib.GObject import System.Glib.Properties import System.Glib.Signals import System.Glib.UTFString {#import System.GIO.Async.AsyncResult#} {#import System.GIO.Signals#} {#import System.GIO.Types#} {# context lib = "gio" prefix = "g" #} -------------------- -- Methods -- | Gets the name of volume. volumeGetName :: (VolumeClass volume, GlibString string) => volume -> IO string -- ^ returns the name for the given volume. volumeGetName volume = {#call g_volume_get_name#} (toVolume volume) >>= readUTFString -- | Gets the UUID for the volume. The reference is typically based on the file system UUID for the -- volume in question and should be considered an opaque string. Returns 'Nothing' if there is no UUID -- available. volumeGetUUID :: (VolumeClass volume, GlibString string) => volume -> IO (Maybe string) -- ^ returns the UUID for volume or 'Nothing' if no UUID can be computed. volumeGetUUID volume = {#call g_volume_get_uuid#} (toVolume volume) >>= maybePeek readUTFString -- | Gets the icon for volume. volumeGetIcon :: VolumeClass volume => volume -> IO Icon volumeGetIcon volume = wrapNewGObject mkIcon $ {#call g_volume_get_icon#} (toVolume volume) -- | Gets the drive for the volume. volumeGetDrive :: VolumeClass volume => volume -> IO (Maybe Drive) -- ^ returns a 'Drive' or 'Nothing' if volume is not associated with a drive. volumeGetDrive volume = maybeNull (wrapNewGObject mkDrive) $ {#call g_volume_get_drive#} (toVolume volume) -- | Gets the mount for the volume. volumeGetMount :: VolumeClass volume => volume -> IO (Maybe Mount) -- ^ returns a 'Mount' or 'Nothing' if volume is not associated with a mount. volumeGetMount volume = maybeNull (wrapNewGObject mkMount) $ {#call g_volume_get_mount#} (toVolume volume) -- | Checks if a volume can be mounted. volumeCanMount :: VolumeClass volume => volume -> IO Bool -- ^ returns 'True' if the volume can be mounted. 'False' otherwise. volumeCanMount volume = liftM toBool $ {#call g_volume_can_mount#} (toVolume volume) -- | Returns whether the volume should be automatically mounted. volumeShouldAutomount :: VolumeClass volume => volume -> IO Bool -- ^ returns 'True' if the volume should be automatically mounted. volumeShouldAutomount volume = liftM toBool $ {#call g_volume_should_automount#} (toVolume volume) #if GLIB_CHECK_VERSION(2,18,0) -- | Gets the activation root for a 'Volume' if it is known ahead of mount time. Returns 'Nothing' -- otherwise. If not 'Nothing' and if volume is mounted, then the result of 'mountGetRoot' on the 'Mount' -- object obtained from 'volumeGetMount' will always either be equal or a prefix of what this -- function returns. volumeGetActivationRoot :: VolumeClass volume => volume -> IO (Maybe File) -- ^ returns the activation root of volume or 'Nothing'. volumeGetActivationRoot volume = maybeNull (wrapNewGObject mkFile) $ {#call g_volume_get_activation_root#} (toVolume volume) #endif -- | Mounts a volume. This is an asynchronous operation, and is finished by calling -- 'volumeMountFinish' with the volume and 'AsyncResult' returned in the callback. volumeMount :: VolumeClass volume => volume -> [MountMountFlags] -- ^ @flags@ flags affecting the operation -> Maybe MountOperation -- ^ @mountOperation@ a 'MountOperation' or 'Nothing' to avoid user interaction. -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore. -> AsyncReadyCallback -- ^ @callback@ a 'AsyncReadyCallback' -> IO () volumeMount volume flags mountOperation cancellable callback = do cCallback <- marshalAsyncReadyCallback callback {#call g_volume_mount #} (toVolume volume) ((fromIntegral . fromFlags) flags) (fromMaybe (MountOperation nullForeignPtr) mountOperation) (fromMaybe (Cancellable nullForeignPtr) cancellable) cCallback (castFunPtrToPtr cCallback) -- | Finishes mounting a volume. If any errors occured during the operation, error will be set to contain -- the errors and 'False' will be returned. -- -- If the mount operation succeeded, 'volumeGetMount' on volume is guaranteed to return the mount -- right after calling this function; there's no need to listen for the 'mount-added' signal on -- 'VolumeMonitor'. -- -- Throws a 'GError' if an error occurs. volumeMountFinish :: VolumeClass volume => volume -> AsyncResult -- ^ @result@ a 'AsyncResult' -> IO () volumeMountFinish volume result = propagateGError (\gErrorPtr -> do {#call g_volume_mount_finish#} (toVolume volume) result gErrorPtr return ()) -- | Checks if a volume can be ejected. volumeCanEject :: VolumeClass volume => volume -> IO Bool -- ^ returns 'True' if the volume can be ejected. 'False' otherwise. volumeCanEject volume = liftM toBool $ {#call g_volume_can_eject#} (toVolume volume) #if GLIB_CHECK_VERSION(2,22,0) -- | Ejects a volume. This is an asynchronous operation, and is finished by calling -- 'volumeEjectWithOperationFinish' with the volume and 'AsyncResult' data returned in the -- callback. volumeEjectWithOperation :: VolumeClass volume => volume -> [MountUnmountFlags] -- ^ @flags@ flags affecting the unmount if required for eject -> Maybe MountOperation -- ^ @mountOperation@ a 'MountOperation' or 'Nothing' to avoid user interaction. -> Maybe Cancellable -- ^ @cancellable@ optional 'Cancellable' object, 'Nothing' to ignore. -> AsyncReadyCallback -- ^ @callback@ a 'AsyncReadyCallback' -> IO () volumeEjectWithOperation volume flags mountOperation cancellable callback = do cCallback <- marshalAsyncReadyCallback callback {#call g_volume_eject_with_operation #} (toVolume volume) ((fromIntegral . fromFlags) flags) (fromMaybe (MountOperation nullForeignPtr) mountOperation) (fromMaybe (Cancellable nullForeignPtr) cancellable) cCallback (castFunPtrToPtr cCallback) -- | Finishes ejecting a volume. If any errors occurred during the operation, error will be set to -- contain the errors and 'False' will be returned. -- -- Throws a 'GError' if an error occurs. volumeEjectWithOperationFinish :: VolumeClass volume => volume -> AsyncResult -- ^ @result@ a 'AsyncResult'. -> IO () volumeEjectWithOperationFinish volume result = propagateGError (\gErrorPtr -> do {#call g_volume_eject_with_operation_finish #} (toVolume volume) result gErrorPtr return ()) #endif -- | Gets the kinds of identifiers that volume has. Use 'volumeGetIdentifer' to obtain the -- identifiers themselves. volumeEnumerateIdentifiers :: (VolumeClass volume, GlibString string) => volume -> IO [string] volumeEnumerateIdentifiers volume = {#call g_volume_enumerate_identifiers#} (toVolume volume) >>= readUTFStringArray0 -- | Gets the identifier of the given kind for volume. See the introduction for more information about -- volume identifiers. volumeGetIdentifier :: (VolumeClass volume, GlibString string) => volume -> string -- ^ @kind@ the kind of identifier to return -> IO string volumeGetIdentifier volume kind = withUTFString kind $ \ kindPtr -> {#call g_volume_get_identifier#} (toVolume volume) kindPtr >>= readUTFString -------------------- -- Signals -- | Emitted when the volume has been changed. volumeChanged :: VolumeClass volume => Signal volume (IO ()) volumeChanged = Signal (connect_NONE__NONE "changed") -- | This signal is emitted when the 'Volume' have been removed. If the recipient is holding references to -- the object they should release them so the object can be finalized. volumeRemoved :: VolumeClass volume => Signal volume (IO ()) volumeRemoved = Signal (connect_NONE__NONE "removed") gio-0.13.1.0/System/GIO/Volumes/VolumeMonitor.chs0000644000000000000000000001607612507510337017565 0ustar0000000000000000{-# LANGUAGE CPP #-} -- GIMP Toolkit (GTK) Binding for Haskell: binding to gio -*-haskell-*- -- -- Author : Andy Stewart -- Created: 30-Apirl-2010 -- -- Copyright (c) 2010 Andy Stewart -- -- This library is free software: you can redistribute it and/or -- modify it under the terms of the GNU Lesser General Public License -- as published by the Free Software Foundation, either version 3 of -- the License, or (at your option) any later version. -- -- This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public -- License along with this program. If not, see -- . -- -- GIO, the C library which this Haskell library depends on, is -- available under LGPL Version 2. The documentation included with -- this library is based on the original GIO documentation. -- -- | Maintainer : gtk2hs-devel@lists.sourceforge.net -- Stability : alpha -- Portability : portable (depends on GHC) module System.GIO.Volumes.VolumeMonitor ( -- * Details -- -- | 'VolumeMonitor' is for listing the user interesting devices and volumes on the computer. In other -- words, what a file selector or file manager would show in a sidebar. -- -- 'VolumeMonitor' is not thread-default-context aware, and so should not be used other than from the -- main thread, with no thread-default-context active. -- * Types VolumeMonitor(..), VolumeMonitorClass, -- * Methods volumeMonitorGet, volumeMonitorGetConnectedDrives, volumeMonitorGetVolumes, volumeMonitorGetMounts, volumeMonitorGetMountForUUID, volumeMonitorGetVolumeForUUID, -- * Signals vmDriveChanged, vmDriveConnected, vmDriveDisconnected, #if GLIB_CHECK_VERSION(2,18,0) vmDriveEjectButton, #endif #if GLIB_CHECK_VERSION(2,22,0) vmDriveStopButton, #endif vmMountAdded, vmMountChanged, vmMountPreUnmount, vmMountRemoved, vmVolumeAdded, vmVolumeChanged, vmVolumeRemoved, ) where import Control.Monad import System.GIO.Enums import System.Glib.Attributes import System.Glib.FFI import System.Glib.Flags import System.Glib.GError import System.Glib.GList import System.Glib.GObject import System.Glib.Properties import System.Glib.Signals import System.Glib.UTFString {#import System.GIO.Signals#} {#import System.GIO.Types#} {# context lib = "gio" prefix = "g" #} -------------------- -- Methods -- | Gets the volume monitor used by gio. volumeMonitorGet :: IO VolumeMonitor volumeMonitorGet = wrapNewGObject mkVolumeMonitor $ {#call g_volume_monitor_get #} -- | Gets a list of drives connected to the system. volumeMonitorGetConnectedDrives :: VolumeMonitorClass monitor => monitor -> IO [Drive] volumeMonitorGetConnectedDrives monitor = do glistPtr <- {#call g_volume_monitor_get_connected_drives #} (toVolumeMonitor monitor) drivePtrs <- fromGList glistPtr mapM (wrapNewGObject mkDrive . return) drivePtrs -- | Gets a list of the volumes on the system. volumeMonitorGetVolumes :: VolumeMonitorClass monitor => monitor -> IO [Drive] volumeMonitorGetVolumes monitor = do glistPtr <- {#call g_volume_monitor_get_volumes #} (toVolumeMonitor monitor) volumePtrs <- fromGList glistPtr mapM (wrapNewGObject mkDrive . return) volumePtrs -- | Gets a list of the mounts on the system. volumeMonitorGetMounts :: VolumeMonitorClass monitor => monitor -> IO [Drive] volumeMonitorGetMounts monitor = do glistPtr <- {#call g_volume_monitor_get_mounts #} (toVolumeMonitor monitor) mountPtrs <- fromGList glistPtr mapM (wrapNewGObject mkDrive . return) mountPtrs -- | Finds a 'Mount' object by its UUID (see 'mountGetUuid' volumeMonitorGetMountForUUID :: (VolumeMonitorClass monitor, GlibString string) => monitor -> string -- ^ @uuid@ the UUID to look for -> IO (Maybe Mount) -- ^ returns a 'Mount' or 'Nothing' if no such mount is available. volumeMonitorGetMountForUUID monitor uuid = maybeNull (wrapNewGObject mkMount) $ withUTFString uuid $ \ uuidPtr -> {#call g_volume_monitor_get_mount_for_uuid#} (toVolumeMonitor monitor) uuidPtr -- | Finds a 'Volume' object by its UUID (see 'volumeGetUuid') volumeMonitorGetVolumeForUUID :: (VolumeMonitorClass monitor, GlibString string) => monitor -> string -- ^ @uuid@ the UUID to look for -> IO (Maybe Volume) -- ^ returns a 'Volume' or 'Nothing' if no such volume is available. volumeMonitorGetVolumeForUUID monitor uuid = maybeNull (wrapNewGObject mkVolume) $ withUTFString uuid $ \ uuidPtr -> {#call g_volume_monitor_get_volume_for_uuid#} (toVolumeMonitor monitor) uuidPtr -------------------- -- Signals -- | Emitted when a drive changes. vmDriveChanged :: VolumeMonitorClass monitor => Signal monitor (Drive -> IO ()) vmDriveChanged = Signal (connect_OBJECT__NONE "drive-changed") -- | Emitted when a drive changes. vmDriveConnected :: VolumeMonitorClass monitor => Signal monitor (Drive -> IO ()) vmDriveConnected = Signal (connect_OBJECT__NONE "drive-connected") -- | Emitted when a drive changes. vmDriveDisconnected :: VolumeMonitorClass monitor => Signal monitor (Drive -> IO ()) vmDriveDisconnected = Signal (connect_OBJECT__NONE "drive-disconnected") #if GLIB_CHECK_VERSION(2,18,0) -- | Emitted when the eject button is pressed on drive. vmDriveEjectButton :: VolumeMonitorClass monitor => Signal monitor (Drive -> IO ()) vmDriveEjectButton = Signal (connect_OBJECT__NONE "drive-eject-button") #endif #if GLIB_CHECK_VERSION(2,22,0) -- | Emitted when the stop button is pressed on drive. vmDriveStopButton :: VolumeMonitorClass monitor => Signal monitor (Drive -> IO ()) vmDriveStopButton = Signal (connect_OBJECT__NONE "drive-stop-button") #endif -- | Emitted when a mount is added. vmMountAdded :: VolumeMonitorClass monitor => Signal monitor (Mount -> IO ()) vmMountAdded = Signal (connect_OBJECT__NONE "mount-added") -- | Emitted when a mount is changed. vmMountChanged :: VolumeMonitorClass monitor => Signal monitor (Mount -> IO ()) vmMountChanged = Signal (connect_OBJECT__NONE "mount-changed") -- | Emitted when a mount is about to be removed. vmMountPreUnmount :: VolumeMonitorClass monitor => Signal monitor (Mount -> IO ()) vmMountPreUnmount = Signal (connect_OBJECT__NONE "mount-pre-unmount") -- | Emitted when a mount is removed. vmMountRemoved :: VolumeMonitorClass monitor => Signal monitor (Mount -> IO ()) vmMountRemoved = Signal (connect_OBJECT__NONE "mount-removed") -- | Emitted when a volume is added. vmVolumeAdded :: VolumeMonitorClass monitor => Signal monitor (Volume -> IO ()) vmVolumeAdded = Signal (connect_OBJECT__NONE "volume-added") -- | Emitted when a volume is changed. vmVolumeChanged :: VolumeMonitorClass monitor => Signal monitor (Volume -> IO ()) vmVolumeChanged = Signal (connect_OBJECT__NONE "volume-changed") -- | Emitted when a volume is removed. vmVolumeRemoved :: VolumeMonitorClass monitor => Signal monitor (Volume -> IO ()) vmVolumeRemoved = Signal (connect_OBJECT__NONE "volume-removed")