1-- -*-haskell-*-
2--  GIMP Toolkit (GTK) Miscellaneous utilities
3--
4--  Author : John Millikin
5--
6--  Created: 15 November 2009
7--
8--  Copyright (C) 2009 John Millikin
9--
10--  This library is free software; you can redistribute it and/or
11--  modify it under the terms of the GNU Lesser General Public
12--  License as published by the Free Software Foundation; either
13--  version 2.1 of the License, or (at your option) any later version.
14--
15--  This library is distributed in the hope that it will be useful,
16--  but WITHOUT ANY WARRANTY; without even the implied warranty of
17--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18--  Lesser General Public License for more details.
19--
20-- |
21-- Maintainer  : gtk2hs-users@lists.sourceforge.net
22-- Stability   : provisional
23-- Portability : portable (depends on GHC)
24--
25-- This module binds GLib-specific utility procedures.
26--
27module System.Glib.Utils
28  ( getApplicationName
29  , setApplicationName
30  , getProgramName
31  , setProgramName
32  ) where
33
34import System.Glib.FFI
35import System.Glib.UTFString
36
37{# context lib="glib" prefix="g" #}
38
39-- |
40-- Gets a human-readable name for the application, as set by
41-- 'setApplicationName'. This name should be localized if possible, and is
42-- intended for display to the user. Contrast with 'getProgramName', which
43-- gets a non-localized name. If 'setApplicationName' has not been performed,
44-- returns the result of 'getProgramName' (which may be 'Nothing' if
45-- 'setProgramName' has also not been performed).
46--
47getApplicationName :: GlibString string => IO (Maybe string)
48getApplicationName = {#call unsafe get_application_name #} >>= maybePeek peekUTFString
49
50-- |
51-- Sets a human-readable name for the application. This name should be
52-- localized if possible, and is intended for display to the user. Contrast
53-- with 'setProgramName', which sets a non-localized name. 'setProgramName'
54-- will be performed automatically by 'initGUI', but 'setApplicationName'
55-- will not.
56--
57-- Note that for thread safety reasons, this computation can only be performed
58-- once.
59--
60-- The application name will be used in contexts such as error messages, or
61-- when displaying an application's name in the task list.
62--
63setApplicationName :: GlibString string => string -> IO ()
64setApplicationName = flip withUTFString {#call unsafe set_application_name #}
65
66-- |
67-- Gets the name of the program. This name should /not/ be localized, contrast
68-- with 'getApplicationName'. If you are using GDK or GTK+, the program name
69-- is set in 'initGUI' to the last component of argv[0].
70--
71getProgramName :: GlibString string => IO (Maybe string)
72getProgramName = {#call unsafe get_prgname #} >>= maybePeek peekUTFString
73
74-- |
75-- Sets the name of the program. This name should /not/ be localized, contrast
76-- with 'setApplicationName'. Note that for thread-safety reasons this
77-- computation can only be performed once.
78--
79setProgramName :: GlibString string => string -> IO ()
80setProgramName = flip withUTFString {#call unsafe set_prgname #}
81