stype_info_dict = {'typestring':stype_typestring,
'desc':stype_desc,
'base_type':stype_base,
- 'flags':(flag_temp,flag_hidden)
+ 'flags':[flag_temp,flag_hidden]
}
return stype_info_dict.get(field)
def run_share_add_edit_dialog(self, share= None, apply_callback= None,wizard_mode=False):
-
+
if wizard_mode:
dialog = ShareWizardDialog(self.pipe_manager, None) # wizard only for a new share
else:
response_id = dialog.run()
if response_id in [gtk.RESPONSE_OK, gtk.RESPONSE_APPLY]:
- problem_msg = None # TODO temporary need to fix
- #problem_msg = dialog.check_for_problems()
+ problem_msg = dialog.validate_fields()
if problem_msg is not None:
self.run_message_dialog(gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, problem_msg, dialog)
self.connect_item.set_sensitive(not connected)
self.disconnect_item.set_sensitive(connected)
self.refresh_item.set_sensitive(connected)
-
+
self.new_item.set_sensitive(connected and share_page_active)
self.delete_item.set_sensitive(connected and selected)
self.edit_item.set_sensitive(connected and selected)
def on_new_item_activate(self, widget,wizard_mode=False):
share = self.run_share_add_edit_dialog(wizard_mode=wizard_mode)
+ print share.type
if share is None:
self.set_status("Share creation canceled.")
return
self.edit_item = gtk.ImageMenuItem(gtk.STOCK_EDIT, accel_group)
self.edit_item.set_sensitive(False)
share_menu.add(self.edit_item)
-
+
self.wizard_item = gtk.MenuItem("_Wizard")
self.menubar.add(self.wizard_item)
wizard_menu = gtk.Menu()
self.wizard_item.set_submenu(wizard_menu)
-
+
self.new_share_wizard_item = gtk.MenuItem(label="New Share Wizard")
wizard_menu.add(self.new_share_wizard_item)
self.delete_button = gtk.ToolButton(gtk.STOCK_DELETE)
self.delete_button.set_is_important(True)
self.toolbar.insert(self.delete_button, 5)
-
+
sep = gtk.SeparatorToolItem()
self.toolbar.insert(sep, 6)
-
+
image = gtk.Image()
image.set_from_stock(gtk.STOCK_EXECUTE, 48)
self.new_share_wizard_button = gtk.ToolButton(image,"New Share Wizard")
self.new_button.set_tooltip_text("Add a new Share")
self.edit_button.set_tooltip_text("Edit a Share")
self.delete_button.set_tooltip_text("Delete a Share")
-
+
#share-page
self.share_notebook = gtk.Notebook()
self.vbox.pack_start(self.share_notebook, True, True, 0)
main_window.show_all()
gtk.main()
-
+test = srvsvcPipeManager('127.0.0.1',0,'Administrator','Pass#2011')
else:
self.stype = srvsvc.STYPE_IPC
# check flags
- self.flags = (False,False)
+ self.flags = [False,False]
if self.sflag_temp_check_button.get_active():
self.flags[0] = True
if self.sflag_hidden_check_button.get_active():
self.flags[1] = True
if self.islocal :
self.path = self.file_button.get_filename()
- self.path = self.pipe.fix_path_format(self.path)
else:
self.path = self.path_entry.get_text()
- self.path = self.pipe.fix_path_format(self.path)
self.max_users = self.max_users_spinbox.get_value_as_int()
self.share.comment= self.comment
self.share.max_users= self.max_users
self.share.password= self.password
- self.share.path = self.path
+ self.share.path = self.pipe.fix_path_format(self.path)
+
self.share_password_entry.set_text(self.password)
self.share_password_entry.set_visibility(False)
self.share_password_entry.set_tooltip_text('Set a Share Password')
- #pwd toggle button
- self.set_pw_visiblity = gtk.CheckButton("Visible")
- self.set_pw_visiblity.set_tooltip_text('Enable or disable the password visiblity')
- self.set_pw_visiblity.set_active(False)
- self.set_pw_visiblity.connect("toggled",self.toggle_pwd_visiblity,None)
+ # For radio buttons we define other fields on the fly as these
+ # are lost on parent removal , and cause errors on draw .
# Radio buttons
self.stype_disktree_radio_button = gtk.RadioButton(None,'Disktree')
- self.stype_disktree_radio_button.set_tooltip_text('Disktree (folder) type Share. Default')
- self.stype_disktree_radio_button.set_active(self.stype == srvsvc.STYPE_DISKTREE)
-
self.stype_printq_radio_button = gtk.RadioButton(self.stype_disktree_radio_button,'Print Queue')
- self.stype_printq_radio_button.set_tooltip_text('Shared Print Queue')
- self.stype_printq_radio_button.set_active(self.stype == srvsvc.STYPE_PRINTQ)
-
self.stype_ipc_radio_button = gtk.RadioButton(self.stype_printq_radio_button,'IPC ')
- self.stype_ipc_radio_button.set_tooltip_text('Shared Interprocess Communication Pipe (IPC).')
- self.stype_ipc_radio_button.set_active(self.stype == srvsvc.STYPE_IPC)
- # Check buttons
self.sflag_temp_check_button = gtk.CheckButton('Temporary')
- self.sflag_temp_check_button.set_tooltip_text('Make share Temporary')
- self.sflag_temp_check_button.set_active(self.flags[0])
-
self.sflag_hidden_check_button = gtk.CheckButton('Hidden ')
- self.sflag_hidden_check_button.set_tooltip_text('Make share hidden.')
- self.sflag_hidden_check_button.set_active(self.flags[1])
#path
if self.islocal:
self.file_button = gtk.FileChooserButton('Browse')
- self.file_button.set_current_folder(self.path)
- self.file_button.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
- self.file_button.set_tooltip_text('Select the folder to share')
else:
self.file_entry = gtk.Entry()
- self.file_entry.set_text(self.path)
- self.file_entry.set_tooltip_text('Path to the folder to share')
#max_users
self.max_users_adjustment = gtk.Adjustment(self.max_users,1,0xFFFFFFFF,1,5)
self.action_area.set_layout(gtk.BUTTONBOX_CENTER)
-
+
self.cancel_button = gtk.Button("Cancel", gtk.STOCK_CANCEL)
self.cancel_button.set_flags(gtk.CAN_DEFAULT)
self.add_action_widget(self.cancel_button, gtk.RESPONSE_CANCEL)
-
+
self.prev_button = gtk.Button(stock=gtk.STOCK_GO_BACK)
self.prev_button.connect("clicked",self.update_fields,-1)
self.action_area.pack_start(self.prev_button, False, False, 10)
-
+
self.next_button = gtk.Button(stock=gtk.STOCK_GO_FORWARD)
self.next_button.connect("clicked", self.update_fields,+1)
self.action_area.pack_start(self.next_button, False, False, 0)
def update_fields(self,widget,change):
+ self.collect_fields()
self.page+=change
+ for widget in self.fields_box.get_children():
+ self.fields_box.remove(widget)
+
if self.page == 0 :
self.title_label.set_markup('<b>Welcome to the New Share Wizard</b>')
self.info_label.set_text(' ')
- for widget in self.fields_box.get_children():
- self.fields_box.remove(widget)
-
+
label =gtk.Label('Please press next to continue.')
label.set_alignment(0,0.5)
self.fields_box.pack_start(label,False,True,0)
self.prev_button.set_sensitive(False)
self.next_button.set_sensitive(True)
self.ok_button.set_sensitive(False)
-
-
-
+
+
+
self.fields_box.show_all()
self.prev_button.set_sensitive(True)
self.next_button.set_sensitive(True)
self.ok_button.set_sensitive(False)
-
- for widget in self.fields_box.get_children():
- self.fields_box.remove(widget)
+ if self.name is not None:
+ self.share_name_entry.set_text(self.name)
+ if self.password is not None:
+ self.share_comment_entry.set_text(self.password)
table = gtk.Table(2,2,True)
table.set_border_width(5)
label.set_alignment(1,0.5)
table.attach(label, 0, 1, 1, 2, gtk.FILL,gtk.FILL | gtk.EXPAND, 0, 0)
table.attach(self.share_password_entry, 1, 2, 1, 2, gtk.FILL,gtk.FILL | gtk.EXPAND, 0, 0)
-
-
+
+
self.fields_box.pack_start(table,False,True,0)
self.fields_box.show_all()
self.prev_button.set_sensitive(True)
self.next_button.set_sensitive(True)
self.ok_button.set_sensitive(False)
+ if self.comment is not None:
+ self.share_comment_entry.set_text(self.comment)
+ self.max_users_spinbox.set_value(self.max_users)
- for widget in self.fields_box.get_children():
- self.fields_box.remove(widget)
table = gtk.Table(2,2,True)
table.set_border_width(5)
self.next_button.set_sensitive(True)
self.ok_button.set_sensitive(False)
- for widget in self.fields_box.get_children():
- self.fields_box.remove(widget)
+ # Radio buttons
+ self.stype_disktree_radio_button = gtk.RadioButton(None,'Disktree')
+ self.stype_disktree_radio_button.set_tooltip_text('Disktree (folder) type Share. Default')
+ self.stype_disktree_radio_button.set_active(self.stype == srvsvc.STYPE_DISKTREE)
+
+ self.stype_printq_radio_button = gtk.RadioButton(self.stype_disktree_radio_button,'Print Queue')
+ self.stype_printq_radio_button.set_tooltip_text('Shared Print Queue')
+ self.stype_printq_radio_button.set_active(self.stype == srvsvc.STYPE_PRINTQ)
+
+ self.stype_ipc_radio_button = gtk.RadioButton(self.stype_printq_radio_button,'IPC ')
+ self.stype_ipc_radio_button.set_tooltip_text('Shared Interprocess Communication Pipe (IPC).')
+ self.stype_ipc_radio_button.set_active(self.stype == srvsvc.STYPE_IPC)
+
+ # Check buttons
+ self.sflag_temp_check_button = gtk.CheckButton('Temporary')
+ self.sflag_temp_check_button.set_tooltip_text('Make share Temporary')
+ self.sflag_temp_check_button.set_active(self.flags[0])
+
+ self.sflag_hidden_check_button = gtk.CheckButton('Hidden ')
+ self.sflag_hidden_check_button.set_tooltip_text('Make share hidden.')
+ self.sflag_hidden_check_button.set_active(self.flags[1])
+
+ hbox = gtk.HBox(True,10)
- hbox = gtk.HBox(True,10)
-
vbox = gtk.VBox()
vbox.set_border_width(5)
-
+
vbox.pack_start(self.stype_disktree_radio_button,True,True,3)
vbox.pack_start(self.stype_printq_radio_button,True,True,3)
vbox.pack_start(self.stype_ipc_radio_button,True,True,3)
hbox.pack_start(vbox,True,True,0)
-
+
vbox = gtk.VBox()
vbox.set_border_width(5)
-
+
vbox.pack_start(self.sflag_temp_check_button,True,True,3)
vbox.pack_start(self.sflag_hidden_check_button,True,True,3)
-
+
hbox.pack_start(vbox,True,True,0)
-
-
-
+
+
+
self.fields_box.pack_start(hbox,True,True,0)
self.fields_box.show_all()
self.next_button.set_sensitive(False)
self.ok_button.set_sensitive(True)
- for widget in self.fields_box.get_children():
- self.fields_box.remove(widget)
+ #path
+ if self.islocal:
+ self.file_button = gtk.FileChooserButton('Browse')
+ if self.path is not None:
+ self.file_button.set_current_folder(self.path)
+ else:
+ self.file_button.set_current_folder(".")
+ self.file_button.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
+ self.file_button.set_tooltip_text('Select the folder to share')
+ else:
+ self.file_entry = gtk.Entry()
+ if self.path is not None:
+ self.file_entry.set_text(self.path)
+ else:
+ self.file_entry.set_text("")
+ self.file_entry.set_tooltip_text('Path to the folder to share')
table = gtk.Table(1,2,True)
table.set_border_width(5)
table.attach(self.file_button, 1, 2, 0, 1, gtk.FILL,gtk.FILL | gtk.EXPAND, 0, 0)
else:
table.attach(self.file_entry, 1, 2, 0, 1, gtk.FILL,gtk.FILL | gtk.EXPAND, 0, 0)
-
+
self.fields_box.pack_start(table,False,True,0)
self.fields_box.show_all()