KiCad PCB EDA Suite
KIPLATFORM::ENV Namespace Reference

Classes

struct  PROXY_CONFIG
 

Functions

void Init ()
 Perform environment initialization tasks. More...
 
bool MoveToTrash (const wxString &aPath, wxString &aError)
 Move the specified file/directory to the trash bin/recycle bin. More...
 
bool IsNetworkPath (const wxString &aPath)
 Determines if a given path is a network shared file apth On Windows for example, any form of path is accepted drive map or UNC. More...
 
wxString GetDocumentsPath ()
 Retrieves the operating system specific path for a user's documents. More...
 
wxString GetUserConfigPath ()
 Retrieves the operating system specific path for a user's configuration store. More...
 
wxString GetUserCachePath ()
 Retrieves the operating system specific path for user's application cache. More...
 
bool GetSystemProxyConfig (const wxString &aURL, PROXY_CONFIG &aCfg)
 Retrieves platform level proxying requirements to reach the given url. More...
 
bool VerifyFileSignature (const wxString &aPath)
 Validates the code signing signature of a given file This is most likely only ever going to be applicable to Windows. More...
 

Function Documentation

◆ GetDocumentsPath()

wxString KIPLATFORM::ENV::GetDocumentsPath ( )

Retrieves the operating system specific path for a user's documents.

Returns
User documents path

Definition at line 74 of file gtk/environment.cpp.

75 {
76  wxString docsPath = g_get_user_data_dir();
77 
78  if( docsPath.IsEmpty() )
79  {
80  wxFileName fallback;
81 
82  fallback.AssignDir( g_get_home_dir() );
83  fallback.AppendDir( wxT( ".local" ) );
84  fallback.AppendDir( wxT( "share" ) );
85  fallback.MakeAbsolute();
86 
87  docsPath = fallback.GetFullPath();
88  }
89 
90  return docsPath;
91 }

Referenced by PATHS::getUserDocumentPath(), and SystemDirsAppend().

◆ GetSystemProxyConfig()

bool KIPLATFORM::ENV::GetSystemProxyConfig ( const wxString &  aURL,
PROXY_CONFIG aCfg 
)

Retrieves platform level proxying requirements to reach the given url.

Parameters
aURLThe target url we will be requesting over http
aCfgThe proxy config struct that will be populated
Returns
True if successful fetched proxy info

Definition at line 106 of file gtk/environment.cpp.

107 {
108  return false;
109 }

Referenced by KICAD_CURL_EASY::SetURL().

◆ GetUserCachePath()

wxString KIPLATFORM::ENV::GetUserCachePath ( )

Retrieves the operating system specific path for user's application cache.

Returns
User cache path

Definition at line 100 of file gtk/environment.cpp.

101 {
102  return g_get_user_cache_dir();
103 }

Referenced by PATHS::GetUserCachePath().

◆ GetUserConfigPath()

wxString KIPLATFORM::ENV::GetUserConfigPath ( )

Retrieves the operating system specific path for a user's configuration store.

Returns
User config path

Definition at line 94 of file gtk/environment.cpp.

95 {
96  return g_get_user_config_dir();
97 }

Referenced by SETTINGS_MANAGER::calculateUserSettingsPath().

◆ Init()

void KIPLATFORM::ENV::Init ( )

Perform environment initialization tasks.

These tasks are called during the wxApp constructor and therefore won't have access to the underlying OS application.

Definition at line 28 of file gtk/environment.cpp.

29 {
30  // Disable proxy menu in Unity window manager. Only usual menubar works with
31  // wxWidgets (at least <= 3.1). When the proxy menu menubar is enable, some
32  // important things for us do not work: menuitems UI events and shortcuts.
33  wxString wm;
34 
35  if( wxGetEnv( wxT( "XDG_CURRENT_DESKTOP" ), &wm ) && wm.CmpNoCase( wxT( "Unity" ) ) == 0 )
36  wxSetEnv ( wxT("UBUNTU_MENUPROXY" ), wxT( "0" ) );
37 
38  // Force the use of X11 backend (or wayland-x11 compatibility layer). This is
39  // required until wxWidgets supports the Wayland compositors
40  wxSetEnv( wxT( "GDK_BACKEND" ), wxT( "x11" ) );
41 
42  // Set GTK2-style input instead of xinput2. This disables touchscreen and smooth
43  // scrolling. It's needed to ensure that we are not getting multiple mouse scroll
44  // events.
45  wxSetEnv( wxT( "GDK_CORE_DEVICE_EVENTS" ), wxT( "1" ) );
46 }

Referenced by APP_KICAD::APP_KICAD(), and APP_SINGLE_TOP::APP_SINGLE_TOP().

◆ IsNetworkPath()

bool KIPLATFORM::ENV::IsNetworkPath ( const wxString &  aPath)

Determines if a given path is a network shared file apth On Windows for example, any form of path is accepted drive map or UNC.

Parameters
aPathis any kind of file path to be tested
Returns
true if given path is on a network location

Definition at line 67 of file gtk/environment.cpp.

68 {
69  // placeholder, we "nerf" behavior if its a network path so return false by default
70  return false;
71 }

Referenced by PROJECT_TREE_PANE::FileWatcherReset().

◆ MoveToTrash()

bool KIPLATFORM::ENV::MoveToTrash ( const wxString &  aPath,
wxString &  aError 
)

Move the specified file/directory to the trash bin/recycle bin.

Parameters
aPathis the absolute path of the file/directory to move to the trash
aErroris the error message saying why the operation failed
Returns
true if the operation succeeds, false if it fails (see the contents of aError)

Definition at line 49 of file gtk/environment.cpp.

50 {
51  GError* err = nullptr;
52  GFile* file = g_file_new_for_path( aPath.fn_str() );
53 
54  bool retVal = g_file_trash( file, nullptr, &err );
55 
56  // Extract the error string if the operation failed
57  if( !retVal && err )
58  aError = err->message;
59 
60  g_clear_error( &err );
61  g_object_unref( file );
62 
63  return retVal;
64 }

Referenced by PROJECT_TREE_ITEM::Delete().

◆ VerifyFileSignature()

bool KIPLATFORM::ENV::VerifyFileSignature ( const wxString &  aPath)

Validates the code signing signature of a given file This is most likely only ever going to be applicable to Windows.

Returns
True if file signature passes

Definition at line 112 of file gtk/environment.cpp.

113 {
114  return true;
115 }

Referenced by KIWAY::KiFACE().