eric6/WebBrowser/WebBrowserSingleApplication.py

Sat, 27 Feb 2021 12:08:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Feb 2021 12:08:23 +0100
changeset 8138
169e65a6787c
parent 7923
91e843545d9a
child 8235
78e6d29eb773
permissions
-rw-r--r--

Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).

6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
3 # Copyright (c) 2018 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 """
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 Module implementing the single application server and client for the web
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9 browser.
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 """
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 from PyQt5.QtCore import pyqtSignal
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
7271
2cac5b7abcce Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
14 from Toolbox.SingleApplication import (
2cac5b7abcce Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
15 SingleApplicationClient, SingleApplicationServer
2cac5b7abcce Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
16 )
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 import Globals
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 ###########################################################################
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 ## define some module global stuff
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 ###########################################################################
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 SAFile = "eric6_browser"
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 # define the protocol tokens
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 SALoadUrl = 'LoadUrl'
6625
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
28 SANewTab = 'NewTab'
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 SASearch = 'Search'
6625
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
30 SAShutdown = 'Shutdown'
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 class WebBrowserSingleApplicationServer(SingleApplicationServer):
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 """
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 Class implementing the single application server embedded within the
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 Web Browser.
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37
6625
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
38 @signal loadUrl(str) emitted to load an URL
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
39 @signal newTab(str) emitted to load an URL in a new tab
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 @signal search(str) emitted to search for a given word
6625
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
41 @signal shutdown() emitted to shut down the browser
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 """
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 loadUrl = pyqtSignal(str)
6625
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
44 newTab = pyqtSignal(str)
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 search = pyqtSignal(str)
6625
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
46 shutdown = pyqtSignal()
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47
6625
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
48 def __init__(self, name=""):
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 """
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 Constructor
6625
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
51
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
52 @param name name to be used by the single application server
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
53 @type str
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 """
6625
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
55 if not name:
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
56 name = SAFile
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
57
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
58 SingleApplicationServer.__init__(self, name)
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 def handleCommand(self, command, arguments):
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 """
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 Public slot to handle the command sent by the client.
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 @param command command sent by the client
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 @type str
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 @param arguments list of command arguments
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 @type list of str
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 """
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 if command == SALoadUrl:
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 self.__saLoadUrl(arguments[0])
6625
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
71
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
72 elif command == SANewTab:
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
73 self.__saNewTab(arguments[0])
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
74
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 elif command == SASearch:
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 self.__saSearch(arguments[0])
6625
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
77
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
78 elif command == SAShutdown:
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
79 self.__saShutdown()
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 def __saLoadUrl(self, url):
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 """
6625
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
83 Private method to load an URL in a new tab.
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 @param url URL to be loaded
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 @type str
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 """
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 self.loadUrl.emit(url)
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89
6625
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
90 def __saNewTab(self, url):
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
91 """
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
92 Private method to load an URL .
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
93
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
94 @param url URL to be loaded
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
95 @type str
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
96 """
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
97 self.newTab.emit(url)
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
98
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 def __saSearch(self, word):
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 """
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 Private method to search for a given word.
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 @param word word to be searched for
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 @type str
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 """
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 self.search.emit(word)
6625
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
107
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
108 def __saShutdown(self):
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
109 """
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
110 Private method to shut down the web browser.
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
111 """
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
112 self.shutdown.emit()
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 class WebBrowserSingleApplicationClient(SingleApplicationClient):
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 """
6630
bddd12f27a4c Web Browser (QtWebKit): applied the changes of the new Web Brwoser to the QtWebKit based variant.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6625
diff changeset
117 Class implementing the single application client of the web browser.
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 """
6625
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
119 def __init__(self, name=""):
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 """
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 Constructor
6625
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
122
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
123 @param name name to be used by the single application server
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
124 @type str
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 """
6625
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
126 if not name:
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
127 name = SAFile
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128
6625
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
129 SingleApplicationClient.__init__(self, name)
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
130
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
131 def processArgs(self, args, disconnect=True):
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 """
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 Public method to process the command line args passed to the UI.
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134
6625
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
135 @param args list of command line arguments
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
136 @type list of str
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
137 @param disconnect flag indicating to disconnect when done
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
138 @type bool
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 """
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 # no args, return
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 if args is None:
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 return
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 if Globals.isWindowsPlatform():
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 argChars = ('-', '/')
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 else:
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 argChars = ('-', )
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 for arg in args:
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 if arg.startswith("--search="):
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 self.__search(arg.replace("--search=", ""))
6625
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
152 elif arg.startswith("--newtab="):
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
153 self.__newTab(arg.replace("--newtab=", ""))
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
154 elif arg == "--shutdown":
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
155 self.__shutdown()
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 elif not arg.startswith(argChars):
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 # it is an URL
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 self.__loadUrl(arg)
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159
6625
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
160 if disconnect:
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
161 self.disconnect()
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 def __loadUrl(self, url):
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 """
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 Private method to send an URL to be loaded.
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 @param url URL to be loaded
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 @type str
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 """
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 self.sendCommand(SALoadUrl, [url])
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171
6625
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
172 def __newTab(self, url):
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
173 """
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
174 Private method to send an URL to be loaded in a new tab.
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
175
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
176 @param url URL to be loaded
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
177 @type str
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
178 """
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
179 self.sendCommand(SANewTab, [url])
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
180
6623
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 def __search(self, word):
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 """
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 Private method to send a word to search for.
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 @param word to to be searched for
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 @type str
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 """
c0882a599e18 WebBrowser: added single application mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 self.sendCommand(SASearch, [word])
6625
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
189
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
190 def __shutdown(self):
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
191 """
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
192 Private method to signal a shutdown request to the browser.
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
193 """
a67fee7bc09c Web Browser: changed the web browser logic inside eric to use a remote controlled web browser process.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6623
diff changeset
194 self.sendCommand(SAShutdown, [])

eric ide

mercurial