~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to www/plugins/console/__init__.py

  • Committer: mattgiuca
  • Date: 2008-01-30 06:14:53 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:332
console plugin: Now presents minimize/maximize buttons, allowing itself to be
opened and closed.
The console python "present" function now also requires a windowpane=True if
in window pane mode (updated tutorial).
Implemented minimal/maximal classes in console.css (a lot of this feature is
CSS-based - min and max buttons just change the class and the CSS handles the
mode switch).

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
# onload events.
28
28
 
29
29
from common import util
 
30
import cgi
30
31
 
31
32
def insert_scripts_styles(scripts, styles):
32
33
    """Given 2 lists of strings: scripts and styles. These lists are lists of
43
44
    _append_if_absent(styles,
44
45
        "media/console/console.css")
45
46
 
46
 
def present(req):
 
47
def present(req, windowpane=False):
47
48
    """Writes the HTML for this plugin into a request stream.
48
49
    May utilise other properties of the Request object in generating the HTML.
 
50
    windowpane: If True, starts the console in "window pane" mode, where it
 
51
    will float over the page and have a "minimize" button.
49
52
    """
50
 
    req.write("""<div id="console_body"><div id="console_body2">
 
53
    req.write("""<div id="console_body">
 
54
  <div id="console_heading">Python Console
 
55
""")
 
56
    if windowpane:
 
57
        req.write("""<span class="console_button minimize">
 
58
      <a onclick="console_minimize()"
 
59
        title="Minimize the Python console">
 
60
        <img src="%s" /></a>
 
61
    </span>
 
62
""" % cgi.escape(util.make_path("media/images/interface/minimize.png")))
 
63
    req.write("""</div>
 
64
  <div id="console_body2">
51
65
  <div id="console_output">
52
66
  </div>
53
67
  <div id="console_input">
54
 
   <div id="console_inputArea">
55
 
   </div>
56
 
   <label id="console_prompt">&gt;&gt;&gt;&nbsp;</label>
57
 
   <input id="console_inputText"
58
 
     type="text" size="80" onkeypress="catch_input(event.keyCode)" />
59
 
  </div>
 
68
    <div id="console_inputArea">
 
69
    </div>
 
70
    <label id="console_prompt">&gt;&gt;&gt;&nbsp;</label>
 
71
    <input id="console_inputText"
 
72
      type="text" size="80" onkeypress="catch_input(event.keyCode)" />
 
73
""")
 
74
    if windowpane:
 
75
        req.write("""<span class="console_button maximize">
 
76
      <a onclick="console_maximize()"
 
77
        title="Open up the Python console">
 
78
        <img src="%s" /></a>
 
79
    </span>
 
80
""" % cgi.escape(util.make_path("media/images/interface/maximize.png")))
 
81
    req.write("""</div>
60
82
</div></div>
 
83
""")
 
84
    if windowpane:
 
85
        req.write("""
61
86
<!-- Console filler, provides extra vertical space to stop the console
62
87
     covering over the bottom content -->
63
88
<div id="console_filler"></div>