The Battle for Wesnoth  1.13.10+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Namespaces | Classes | Enumerations | Functions
desktop Namespace Reference

Namespaces

 clipboard
 
 notifications
 

Classes

struct  bookmark_info
 
struct  path_info
 

Enumerations

enum  GAME_PATH_TYPES { GAME_BIN_DIR = 0x1, GAME_CORE_DATA_DIR = 0x2, GAME_USER_PREFS_DIR = 0x4, GAME_USER_DATA_DIR = 0x8 }
 
enum  SYSTEM_PATH_TYPES { SYSTEM_ALL_DRIVES = 0x1, SYSTEM_USER_PROFILE = 0x2, SYSTEM_ROOTFS = 0x4 }
 

Functions

bool open_object_is_supported ()
 Returns whether open_object() is supported/implemented for the current platform. More...
 
bool open_object (const std::string &path_or_url)
 Opens the specified object with the default application configured for its type. More...
 
std::string user_profile_dir ()
 Returns the path to the user profile dir (e.g. More...
 
std::ostream & operator<< (std::ostream &os, const path_info &pinf)
 
std::vector< path_infogame_paths (unsigned path_types=GAME_CORE_DATA_DIR|GAME_USER_DATA_DIR)
 Returns a list of game-related paths. More...
 
std::vector< path_infosystem_paths (unsigned path_types=SYSTEM_ALL_DRIVES|SYSTEM_USER_PROFILE|SYSTEM_ROOTFS)
 Returns a list of system-defined paths. More...
 
unsigned add_user_bookmark (const std::string &label, const std::string &path)
 
void remove_user_bookmark (unsigned index)
 
std::vector< bookmark_infouser_bookmarks ()
 
std::string os_version ()
 Returns a string with the running OS name and version information. More...
 

Enumeration Type Documentation

Enumerator
GAME_BIN_DIR 

Game executable dir.

GAME_CORE_DATA_DIR 

Game data dir.

GAME_USER_PREFS_DIR 

User preferences dir.

GAME_USER_DATA_DIR 

User data dir.

Definition at line 54 of file paths.hpp.

Enumerator
SYSTEM_ALL_DRIVES 

Paths for each storage media found (Windows), /media and/or /mnt (X11, if non-empty).

SYSTEM_USER_PROFILE 

Path to the user's profile dir (e.g.

/home/username or X:\Users\Username).

SYSTEM_ROOTFS 

Path to the root of the filesystem hierarchy (ignored on Windows).

Definition at line 62 of file paths.hpp.

Function Documentation

unsigned desktop::add_user_bookmark ( const std::string &  label,
const std::string &  path 
)
std::vector< path_info > desktop::game_paths ( unsigned  path_types = GAME_CORE_DATA_DIR|GAME_USER_DATA_DIR)

Returns a list of game-related paths.

These paths are guaranteed to be their canonical forms (with links and dot entries resolved) and using the platform's preferred path delimiter.

Definition at line 191 of file paths.cpp.

References GAME_BIN_DIR, GAME_CORE_DATA_DIR, GAME_USER_DATA_DIR, GAME_USER_PREFS_DIR, filesystem::get_exe_dir(), filesystem::get_user_config_dir(), filesystem::get_user_data_dir(), GETTEXT_DOMAIN, N_, and game_config::path.

Referenced by gui2::dialogs::file_dialog::pre_show().

bool desktop::open_object ( const std::string &  path_or_url)

Opens the specified object with the default application configured for its type.

The default application for handling the object represented by path_or_url is defined by the operating system and desktop environment under which Wesnoth is running, and it is not under our control. Therefore, EXTREME CAUTION is advised when using this function with URLs or paths that are entirely or partially constructed from user-provided input (e.g., WML from user-made add-ons, chat log messages).

If the content pointed to by path_or_url cannot be trusted, you should either refrain from using this function, or warn the user before calling this function.

Note
Currently, only X11, Apple OS X, and Microsoft Windows are supported. Using this function on unsupported platforms will result in an error message logged in stderr.
Returns
true on success, false otherwise. Failure to perform the platform call means either that we do not currently support the running platform, the child process exited with a non-zero status, or something else went wrong. Thus, a value of true does not truly guarantee success – take it with a grain of salt.

Definition at line 53 of file open.cpp.

References ERR_DU, LOG_DU, unicode_cast(), and UNUSED.

Referenced by gui2::dialogs::game_cache_options::browse_cache_callback(), gui2::dialogs::game_version::browse_directory_callback(), gui2::dialogs::addon_manager::browse_url_callback(), gui2::dialogs::screenshot_notification::pre_show(), and gui2::label::signal_handler_left_button_click().

bool desktop::open_object_is_supported ( )

Returns whether open_object() is supported/implemented for the current platform.

Definition at line 44 of file open.cpp.

Referenced by gui2::dialogs::addon_manager::pre_show(), gui2::dialogs::game_version::pre_show(), and gui2::label::signal_handler_left_button_click().

std::ostream & desktop::operator<< ( std::ostream &  os,
const path_info &  pinf 
)
std::string desktop::os_version ( )

Returns a string with the running OS name and version information.

On Windows, this is a string we generate ourselves by processing GetVersionEx's output. On OS X and Linux, this is the output of a command provided by the OS if available; failing that (and on other Unixes as well), we use the uname system call, which is hardly ever useful.

Definition at line 118 of file version.cpp.

References _(), ERR_DU, filesystem::file_exists(), version_info::major_version(), version_info::minor_version(), p, unicode_cast(), and game_config::version.

Referenced by game_config::full_build_report(), and gui2::dialogs::game_version::pre_show().

void desktop::remove_user_bookmark ( unsigned  index)
std::vector< path_info > desktop::system_paths ( unsigned  path_types = SYSTEM_ALL_DRIVES|SYSTEM_USER_PROFILE|SYSTEM_ROOTFS)

Returns a list of system-defined paths.

This includes removable media on platforms where we can reasonably accurately enumerate those (FIXME: only Windows right now), the path to the user's profile directory (/home/username, X:\Users\Username, etc.), and the system drive root.

These paths are guaranteed to be their canonical forms (with links and dot entries resolved) and using the platform's preferred path delimiter.

Definition at line 219 of file paths.cpp.

References GETTEXT_DOMAIN, N_, SYSTEM_ALL_DRIVES, SYSTEM_ROOTFS, SYSTEM_USER_PROFILE, and user_profile_dir().

Referenced by gui2::dialogs::file_dialog::pre_show().

std::vector< bookmark_info > desktop::user_bookmarks ( )

Definition at line 267 of file paths.cpp.

References config::child_range(), and config::has_child().

Referenced by gui2::dialogs::file_dialog::pre_show().

std::string desktop::user_profile_dir ( )

Returns the path to the user profile dir (e.g.

/home/username).

An empty string is returned if the path cannot be determined somehow.

Definition at line 157 of file paths.cpp.

References unicode_cast().

Referenced by system_paths().