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
« 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.
16import atexit 1ab
17import builtins 1ab
18import sys 1ab
19import wx 1ab
21from ..pluginapi import Plugin 1ab
22from ..action import ActionInfo 1ab
24_ = wx.GetTranslation # To keep linter/code analyser happy 1ab
25builtins.__dict__['_'] = wx.GetTranslation 1ab
28class ShortcutPlugin(Plugin): 1ab
29 """Creator of RIDE Desktop Shortcuts."""
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)
39 def _close(self): 1ab
40 """ Just ignore it """
41 pass
43 def enable(self): 1ab
44 self._create_menu()
46 def disable(self): 1ab
47 self.unregister_actions()
48 if self._window:
49 self._window.close(self.notebook)
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))
58 def on_view_shortcut_create(self, event): 1ab
59 __ = event
60 self.call_creator(self.notebook)
61 # self.disable()
63 @staticmethod 1ab
64 def call_creator(notebook): 1ab
65 from . import caller
66 return caller(notebook.GetParent(), sys.platform.lower())