4
# creates a main window with basic view of a samba tree
13
from os import system, getenv
27
# close the window and quit
29
def delete_event(self):
31
conflocation = string.join([home, "/.pyNeighborhood"], '')
32
os.chdir(conflocation)
34
self.monitor_thr.quit = True
41
def get_main_menu(self, window):
42
actions = gtk.ActionGroup("Actions")
43
actions.add_actions(self.menu_entries)
46
ui.insert_action_group(actions, 0)
47
window.add_accel_group(ui.get_accel_group())
49
mergeid = ui.add_ui_from_string(self.ui_info)
50
except gobject.GError, msg:
51
print "building menus failed: %s" % msg
59
def delete_event_handler(self, widget, event, data=None):
64
# It is really necessary to move this handler here -
65
# because "monitor" and "bookmarks" objects are to be passed
67
treeselection = self.bookmarks.treeview.get_selection()
68
(model, iter) = treeselection.get_selected()
70
thr = threads.Umount_Thread(self.notebook,
78
# handlers for running menuitems
80
def scan_menu_handler(self, action):
81
handlers.scan(self, self)
83
def remove_menu_handler(self, action):
84
handlers.remove(self, self)
86
def filemanager_menu_handler(self, action):
87
handlers.filemanager(self, self)
89
def mount_menu_handler(self, action):
90
handlers.mount(self, self)
92
def umount_menu_handler(self, action):
95
def about_menu_handler(self, action):
96
dialog.about(self.window)
99
def addmach_menu_handler(self, action):
100
newhost = dialog.addmachine(self.window)
102
self.treestore.append(None, [newhost, "host", "", ""])
103
addconfig.addhost(newhost)
107
# After new interface implementing!!!!!!!!!!!!!!
109
def preferences_menu_handler(self, action):
110
newoptdict = dialog.options(self.window)
111
if newoptdict != None:
112
pyNeighborhood.parser.write(newoptdict["mount_directory"], newoptdict["file_managers"],
113
newoptdict["smb_mount"], newoptdict["smb_umount"], newoptdict["smb_options"],
117
def quit_menu_handler(self, action):
125
# create a new window
127
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
128
self.window.set_title("pyNeighborhood")
130
self.window.set_icon_from_file("icons/pyneighborhood.png")
132
self.window.set_icon_from_file(string.join([config.config(), '/', 'share', '/',
133
'pyNeighborhood', '/', 'icons', '/','pyneighborhood.png'], ''))
134
self.window.set_size_request(600, 400)
135
self.window.connect("delete_event", self.delete_event_handler, self.window)
136
self.window.connect("destroy", self.delete_event_handler, self.window)
141
self.menu_vbox = gtk.VBox(False, 1)
142
self.menu_vbox.set_border_width(1)
144
self.menu_entries = (
145
("FileMenu", None, "_File"),
146
("ActionMenu", None, "_Action"),
147
("EditMenu", None, "_Edit"),
148
("HelpMenu", None, "_Help"),
149
("Quit", gtk.STOCK_QUIT,
150
None, "<control>Q", None,
151
self.quit_menu_handler),
154
self.scan_menu_handler),
156
"_Mount", None, None,
157
self.mount_menu_handler),
158
("Unmount", "UNMOUNT",
159
"_Unmount", None, None,
160
self.umount_menu_handler),
161
("FileManager","FILEMANAGER",
162
"_File Manager", None, None,
163
self.filemanager_menu_handler),
164
("AddMachine", gtk.STOCK_ADD,
165
"_Add Machine...", "<control>A", None,
166
self.addmach_menu_handler),
167
("Remove", gtk.STOCK_REMOVE,
168
None, "<control>R", None,
169
self.remove_menu_handler),
170
("Preferences", gtk.STOCK_PREFERENCES,
172
self.preferences_menu_handler),
173
("Help", gtk.STOCK_ABOUT,
175
self.about_menu_handler)
181
<menubar name = "MenuBar">
182
<menu action = "FileMenu">
183
<menuitem action = "Quit"/>
185
<menu action = "ActionMenu">
186
<menuitem action = "Scan"/>
187
<menuitem action = "Mount"/>
188
<menuitem action = "Unmount"/>
189
<menuitem action = "FileManager"/>
191
<menu action = "EditMenu">
192
<menuitem action = "AddMachine"/>
193
<menuitem action = "Remove"/>
194
<menuitem action = "Preferences"/>
196
<menu action = "HelpMenu">
197
<menuitem action = "Help"/>
202
menubar = self.get_main_menu(self.window)
203
self.window.add(self.menu_vbox)
204
self.menu_vbox.show()
205
self.menu_vbox.pack_start(menubar.get_widget("/MenuBar"), False, False, 0)
208
# create a new notebook, place the position of the tabs
210
self.notebook = gtk.Notebook()
211
label_1 = gtk.Label()
212
label_1.set_text("Bookmarks")
213
label_2 = gtk.Label()
214
label_2.set_text("Mounts")
220
self.note_vbox = gtk.VBox(False, 1)
221
self.note_vbox.set_border_width(1)
222
self.note_vbox.show()
225
self.note_vbox_mou = gtk.VBox(False, 1)
226
self.note_vbox_mou.set_border_width(1)
227
self.note_vbox_mou.show()
230
# create "Bookmarks" and "Mounts" widgets
232
# create bookmarks treeview
233
self.bookmarks = bookmarks.Bookmarks_Widget(self)
234
self.scrolledwindow, self.treestore, self.treeview = self.bookmarks.Bookmarks()
235
# create monitor treeview
236
self.pyn_monitor = monitor.Monitor_Widget(self)
237
self.scrolledwindow_mon, self.treestore_mon, self.treeview_mon = self.pyn_monitor.Monitor()
240
# add widgets to notebook
243
self.note_vbox.pack_start(self.scrolledwindow, True, True, 0)
244
self.notebook.append_page(self.note_vbox, label_1)
247
self.note_vbox_mou.pack_start(self.scrolledwindow_mon, True, True, 0)
248
self.notebook.append_page(self.note_vbox_mou, label_2)
253
self.notebook.set_show_tabs(True)
257
# start a thread with the mounts monitor
259
self.monitor_thr = threads.Monitor_Thread(self.treestore_mon)
260
self.monitor_thr.start()
263
# pack everything into vbox and show all
266
print pyNeighborhood.parser.optdict
267
self.menu_vbox.pack_start(self.notebook, True, True, 0)
268
self.window.show_all()
271
gobject.threads_init()