Coverage for src/robotide/postinstall/desktopshortcut.py: 70%

31 statements  

« prev     ^ index     » next       coverage.py v7.8.0, created at 2025-05-06 10:40 +0100

1# Copyright 2008-2015 Nokia Networks 

2# Copyright 2016- Robot Framework Foundation 

3# 

4# Licensed under the Apache License, Version 2.0 (the "License"); 

5# you may not use this file except in compliance with the License. 

6# You may obtain a copy of the License at 

7# 

8# http://www.apache.org/licenses/LICENSE-2.0 

9# 

10# Unless required by applicable law or agreed to in writing, software 

11# distributed under the License is distributed on an "AS IS" BASIS, 

12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 

13# See the License for the specific language governing permissions and 

14# limitations under the License. 

15 

16import atexit 1ab

17import builtins 1ab

18import sys 1ab

19import wx 1ab

20 

21from ..pluginapi import Plugin 1ab

22from ..action import ActionInfo 1ab

23 

24_ = wx.GetTranslation # To keep linter/code analyser happy 1ab

25builtins.__dict__['_'] = wx.GetTranslation 1ab

26 

27 

28class ShortcutPlugin(Plugin): 1ab

29 """Creator of RIDE Desktop Shortcuts.""" 

30 

31 def __init__(self, app): 1ab

32 Plugin.__init__(self, app, default_settings={ 

33 'desktop_shortcut_exists': False, 

34 'initial_project': None 

35 }) 

36 self._window = None 

37 atexit.register(self._close) 

38 

39 def _close(self): 1ab

40 """ Just ignore it """ 

41 pass 

42 

43 def enable(self): 1ab

44 self._create_menu() 

45 

46 def disable(self): 1ab

47 self.unregister_actions() 

48 if self._window: 

49 self._window.close(self.notebook) 

50 

51 def _create_menu(self): 1ab

52 self.unregister_actions() 

53 self.register_action(ActionInfo(_('Tools'), 

54 _('Create RIDE Desktop Shortcut'), 

55 self.on_view_shortcut_create, 

56 position=85)) 

57 

58 def on_view_shortcut_create(self, event): 1ab

59 __ = event 

60 self.call_creator(self.notebook) 

61 # self.disable() 

62 

63 @staticmethod 1ab

64 def call_creator(notebook): 1ab

65 from . import caller 

66 return caller(notebook.GetParent(), sys.platform.lower())