~ubuntu-branches/ubuntu/vivid/openipmi/vivid

« back to all changes in this revision

Viewing changes to swig/python/openipmigui/gui_popup.py

  • Committer: Bazaar Package Importer
  • Author(s): Noèl Köthe
  • Date: 2006-09-15 17:56:24 UTC
  • mfrom: (1.1.2 upstream) (2.1.1 etch)
  • Revision ID: james.westby@ubuntu.com-20060915175624-ljk0mg3xtcm65tvm
Tags: 2.0.7-1
* new upstream release from 2006-06-08
  Thanks to John Wright <john.wright hp.com> for initial work
  (closes: Bug#380149)
* updated Standards Version
* new binaries openipmicmd, openipmish, rmcp_ping

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# _domain.py
 
2
#
 
3
# openipmi GUI handling for domains
 
4
#
 
5
# Author: MontaVista Software, Inc.
 
6
#         Corey Minyard <minyard@mvista.com>
 
7
#         source@mvista.com
 
8
#
 
9
# Copyright 2006 MontaVista Software Inc.
 
10
#
 
11
#  This program is free software; you can redistribute it and/or
 
12
#  modify it under the terms of the GNU Lesser General Public License
 
13
#  as published by the Free Software Foundation; either version 2 of
 
14
#  the License, or (at your option) any later version.
 
15
#
 
16
#
 
17
#  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
 
18
#  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 
19
#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 
20
#  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 
21
#  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 
22
#  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 
23
#  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 
24
#  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
 
25
#  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
 
26
#  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
27
#
 
28
#  You should have received a copy of the GNU Lesser General Public
 
29
#  License along with this program; if not, write to the Free
 
30
#  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
31
#
 
32
 
 
33
import Tix
 
34
 
 
35
class PopupSelector:
 
36
    def __init__(self, handler, val, pd):
 
37
        self.handler = handler
 
38
        self.val = val;
 
39
        self.pd = pd
 
40
        return
 
41
 
 
42
    def handle(self):
 
43
        self.pd.done = True
 
44
        self.handler(self.val)
 
45
        return
 
46
 
 
47
    pass
 
48
 
 
49
class PopupDone:
 
50
    def __init__(self):
 
51
        self.done = False;
 
52
        pass
 
53
 
 
54
    def setdone(self, event):
 
55
        self.done = True
 
56
        return
 
57
    
 
58
    pass
 
59
 
 
60
def popup(ui, event, handlers, point=None):
 
61
    menu = Tix.Menu(ui, tearoff=0);
 
62
    pd = PopupDone()
 
63
    for h in handlers:
 
64
        if (len(h) >= 3):
 
65
            p = PopupSelector(h[1], h[2], pd)
 
66
            pass
 
67
        else:
 
68
            p = PopupSelector(h[1], None, pd)
 
69
            pass
 
70
        menu.add("command", command=p.handle, label=h[0])
 
71
        pass
 
72
    if (point == None):
 
73
        point = event
 
74
        pass
 
75
    menu.post(point.x_root, point.y_root)
 
76
    menu.grab_set_global()
 
77
    menu.bind("<FocusOut>", pd.setdone)
 
78
    menu.bind("<ButtonRelease-3>", pd.setdone)
 
79
    while (not pd.done):
 
80
        event.widget.tk.dooneevent()
 
81
        pass
 
82
    menu.grab_release()
 
83
    menu.destroy()
 
84
    return