~pyneighborhood/pyneighborhood/0.5

« back to all changes in this revision

Viewing changes to dialog.py

  • Committer: definer
  • Date: 2006-09-16 18:34:46 UTC
  • Revision ID: svn-v3-trunk0:918a6f1d-dd1c-0410-8c33-97c2c1a26c01:trunk:6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
 
 
3
# Dialog windows
 
4
 
 
5
import pygtk
 
6
pygtk.require('2.0')
 
7
import gtk
 
8
 
 
9
import pyNeighborhood
 
10
 
 
11
def dialog(text, parent):
 
12
    msg = gtk.MessageDialog(parent, gtk.DIALOG_MODAL, 
 
13
                            gtk.MESSAGE_WARNING, gtk.BUTTONS_CLOSE, text)
 
14
    msg.connect("response", lambda d, r: d.destroy())
 
15
    msg.show()
 
16
    return
 
17
                
 
18
def about(parent):
 
19
    text= """pyNeighborhood 0.3\nCopyright \302\251 2005 Mykola Lynnyk Home:pyneighborhood.sourceforge.net\n\n 
 
20
Distributed under the terms of the GNU General Public License"""
 
21
    msg = gtk.MessageDialog(parent, gtk.DIALOG_MODAL |gtk.DIALOG_DESTROY_WITH_PARENT, 
 
22
                                                                gtk.MESSAGE_INFO, gtk.BUTTONS_CLOSE, text)
 
23
    msg.connect ("response", lambda d, r: d.destroy())
 
24
    msg.show()
 
25
    return
 
26
 
 
27
def addmachine(parent):
 
28
    msg = gtk.Dialog("Add Machine",
 
29
                     parent,
 
30
                     gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
 
31
                     (gtk.STOCK_OK, gtk.RESPONSE_OK,
 
32
                     gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
 
33
        
 
34
    vbox = gtk.VBox(True, 20)
 
35
    msg.set_resizable(False)
 
36
 
 
37
    entry = gtk.Entry()
 
38
    entry.set_max_length(50)
 
39
    entry.select_region(0, len(entry.get_text()))
 
40
    msg.vbox.pack_start(entry, True, True, 0)
 
41
    entry.show()
 
42
 
 
43
    msg.show_all()
 
44
    response = msg.run()
 
45
    if response == gtk.RESPONSE_OK: 
 
46
        text = entry.get_text()
 
47
        msg.destroy()
 
48
        return text
 
49
    if response == gtk.RESPONSE_CANCEL: 
 
50
        msg.destroy()
 
51
        return None
 
52
    msg.destroy()
 
53
                        
 
54
def options(parent):
 
55
    msg = gtk.Dialog("Preferences",
 
56
                     parent,
 
57
                     gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
 
58
                     (gtk.STOCK_OK, gtk.RESPONSE_OK,
 
59
                     gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
 
60
      
 
61
    vbox = gtk.VBox(True, 20)
 
62
    msg.set_resizable(False)
 
63
        
 
64
    #Mount folder
 
65
    lbl1 = gtk.Label("Mount folder (you are to have write permissions)")
 
66
    lbl1.show()
 
67
    msg.vbox.pack_start(lbl1, False, False, 4)
 
68
  
 
69
    entry1 = gtk.Entry()
 
70
    entry1.set_max_length(50)
 
71
    entry1.select_region(0, len(entry1.get_text()))
 
72
#    entry1.set_text(optlist[0])
 
73
    entry1.set_text(pyNeighborhood.parser.optdict["mount_directory"])
 
74
    msg.vbox.pack_start(entry1, True, True, 0)
 
75
    hsep1 = gtk.HSeparator()
 
76
    msg.vbox.pack_start(hsep1, True, True, 0)
 
77
    hsep1.show()
 
78
    entry1.show()
 
79
 
 
80
    #Mount command
 
81
    lbl2 = gtk.Label("Mount command")
 
82
    lbl2.show()
 
83
    msg.vbox.pack_start(lbl2, False, False, 4)
 
84
        
 
85
    entry2 = gtk.Entry()
 
86
    entry2.set_max_length(50)
 
87
    entry2.select_region(0, len(entry2.get_text()))
 
88
    #entry2.set_text(optlist[1])
 
89
    entry2.set_text(pyNeighborhood.parser.optdict["smb_mount"])
 
90
    msg.vbox.pack_start(entry2, True, True, 0)
 
91
    hsep2 = gtk.HSeparator()
 
92
    msg.vbox.pack_start(hsep2, True, True, 0)
 
93
    hsep2.show()
 
94
    entry2.show()
 
95
 
 
96
    #Mount command-line options
 
97
    lbl3 = gtk.Label("Mount command-line options")
 
98
    lbl3.show()
 
99
    msg.vbox.pack_start(lbl3, False, False, 4)
 
100
        
 
101
    entry3 = gtk.Entry()
 
102
    entry3.set_max_length(50)
 
103
    entry3.select_region(0, len(entry3.get_text()))
 
104
    entry3.set_text(pyNeighborhood.parser.optdict["smb_options"])
 
105
    #entry3.set_text(optlist[2])
 
106
    msg.vbox.pack_start(entry3, True, True, 0)
 
107
    hsep3 = gtk.HSeparator()
 
108
    msg.vbox.pack_start(hsep3, True, True, 0)
 
109
    hsep3.show()
 
110
    entry3.show()
 
111
 
 
112
    #File manager to launch
 
113
    lbl4 = gtk.Label("Your file manager")
 
114
    lbl4.show()
 
115
    msg.vbox.pack_start(lbl4, False, False, 4)
 
116
 
 
117
    entry4 = gtk.Entry()
 
118
    entry4.set_max_length(50)
 
119
    entry4.select_region(0, len(entry4.get_text()))
 
120
    #entry4.set_text(optlist[3])
 
121
    entry4.set_text(pyNeighborhood.parser.file_managers[0])
 
122
    msg.vbox.pack_start(entry4, True, True, 0)
 
123
    hsep4 = gtk.HSeparator()
 
124
    msg.vbox.pack_start(hsep4, True, True, 0)
 
125
    hsep4.show()
 
126
    entry4.show()
 
127
 
 
128
    #Unmount command
 
129
    lbl5 = gtk.Label("Unmount command")
 
130
    lbl5.show()
 
131
    msg.vbox.pack_start(lbl5, False, False, 4)
 
132
 
 
133
    entry5 = gtk.Entry()
 
134
    entry5.set_max_length(50)
 
135
    entry5.select_region(0, len(entry5.get_text()))
 
136
    #entry5.set_text(optlist[4])
 
137
    entry5.set_text(pyNeighborhood.parser.optdict["smb_umount"])
 
138
    msg.vbox.pack_start(entry5, True, True, 0)
 
139
    hsep5 = gtk.HSeparator()
 
140
    msg.vbox.pack_start(hsep5, True, True, 0)
 
141
    hsep5.show()
 
142
    entry5.show()
 
143
 
 
144
    #Mtab location
 
145
#    lbl6 = gtk.Label("Mtab location")
 
146
 #   lbl6.show()
 
147
#    msg.vbox.pack_start(lbl6, False, False, 4)
 
148
#
 
149
#    entry6 = gtk.Entry()
 
150
#    entry6.set_max_length(50)
 
151
#    entry6.select_region(0, len(entry6.get_text()))
 
152
#    entry6.set_text(optlist[5])
 
153
#    msg.vbox.pack_start(entry6, True, True, 0)
 
154
#    hsep6 = gtk.HSeparator()
 
155
#    msg.vbox.pack_start(hsep6, True, True, 0)
 
156
#    hsep6.show()
 
157
#    entry6.show()
 
158
 
 
159
    msg.show_all()
 
160
    response = msg.run()
 
161
    newoptdict = {}
 
162
    if response == gtk.RESPONSE_OK: 
 
163
        newoptdict["mount_directory"] = entry1.get_text()
 
164
        newoptdict["smb_mount"] = entry2.get_text()
 
165
        newoptdict["smb_options"] = entry3.get_text()
 
166
        newoptdict["file_managers"] = entry4.get_text()
 
167
        newoptdict["smb_umount"] = entry5.get_text()
 
168
#        newoptlist.append(entry6.get_text())
 
169
        msg.destroy()
 
170
        return newoptdict
 
171
    if response == gtk.RESPONSE_CANCEL: 
 
172
        msg.destroy()
 
173
        return None
 
174
    msg.destroy()
 
175
                        
 
176
def main():     
 
177
    gtk.main()
 
178