Proposal for bug/feature request 110804 (system-config-samba) The way this works is pretty simple or should be simple to understand. I had to change some minor things to the parser in order to add a parent to a section-header (it's adding itself as parent). This eases finding back the correct section-header which is what we want to change, of course. It adds a label and textbox in the glade UI On the add-button if decides to use or the sharename or if that one is empty it will use the old-style technique to choose a name. We might want to change that functionality to a on_text_changed callback for the path-entry and set the generated name in the new text on-path-text-changed or something like that. As I am not sure whether or not this is what you like or want I decide to not yet move this functionality (would make the patch larger and would radically modify stuff and the way things work now. As a small contributor I feel that this is not really my task nor decision to make). On the edit-button it will search for lines with parent 'oldsharename' and it will change the parent name. It will also change the section-header and it will set the treestore of the parentclass of course. -- Philip Van Hoof, Software Developer @ Cronos home: me at freax dot org work: Philip dot VanHoof at cronos dot be http://www.freax.be, http://www.freax.eu.org
Index: src/mainWindow.py =================================================================== RCS file: /usr/local/CVS/redhat-config-samba/src/mainWindow.py,v retrieving revision 1.63 diff -u -r1.63 mainWindow.py --- src/mainWindow.py 9 Feb 2004 20:18:18 -0000 1.63 +++ src/mainWindow.py 27 May 2004 20:34:10 -0000 @@ -209,6 +209,27 @@ pass + def changeSectionHeader(self, oldname, newname): + self.samba_file_list = self.samba_data.getList() + + found = gtk.FALSE + last_global_line = 0 + + for line in self.samba_file_list: + + if line.type == sambaToken.SambaToken.SAMBA_TOKEN_SECTION_HEADER: + sectionname = string.strip (line.getData(),"\n[]") + if sectionname == oldname: + line.value = "[" + newname + "]" + found = gtk.TRUE + break + last_global_line = self.samba_file_list.index(line) + + if found == gtk.FALSE: + line = "[" + newname + "]" + token = self.samba_data.createToken(line) + self.samba_file_list.insert(last_global_line, token) + def changeValue(self, keyname, value, parent): self.samba_file_list = self.samba_data.getList() @@ -336,8 +357,23 @@ advanced_preferences_win = self.xml.get_widget("advanced_preferences_win") advanced_preferences_win.show_all() - def onRefreshButtonClicked(self, *args): + def refreshData (self): + # help me! this aint working correctly :-( + # self.share_view.set_model (None) + # self.share_store.clear() + + # self.samba_data = sambaParser.SambaParser(self) + + # self.share_store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, + # gobject.TYPE_STRING) + + # self.processSambaData(self.samba_data) + # self.share_view.set_model (self.share_store) pass + + + def onRefreshButtonClicked(self, *args): + refreshData() def onModifyUsersClicked(self, *args): self.samba_user_win.showWindow() Index: src/sambaParser.py =================================================================== RCS file: /usr/local/CVS/redhat-config-samba/src/sambaParser.py,v retrieving revision 1.29 diff -u -r1.29 sambaParser.py --- src/sambaParser.py 20 Feb 2004 02:49:04 -0000 1.29 +++ src/sambaParser.py 27 May 2004 20:34:10 -0000 @@ -100,7 +100,7 @@ elif tmp[0] == "[" and tmp[-1] == "]": #The line contains a section header - token = sambaToken.SambaToken(sambaToken.SambaToken.SAMBA_TOKEN_SECTION_HEADER, (stripped_line)) + token = sambaToken.SambaToken(sambaToken.SambaToken.SAMBA_TOKEN_SECTION_HEADER, (stripped_line), self.parent, None) # self.samba_file_list.append(token) self.parent = stripped_line return token Index: src/shareWindow.py =================================================================== RCS file: /usr/local/CVS/redhat-config-samba/src/shareWindow.py,v retrieving revision 1.45 diff -u -r1.45 shareWindow.py --- src/shareWindow.py 9 Mar 2004 15:42:19 -0000 1.45 +++ src/shareWindow.py 27 May 2004 20:34:12 -0000 @@ -21,6 +21,7 @@ import mainWindow import sambaToken import sambaUserData +import sambaParser import os import gobject @@ -50,6 +51,7 @@ self.share_notebook = xml.get_widget("share_notebook") self.dir_entry = xml.get_widget("share_dir_entry") self.description_entry = xml.get_widget("description_entry") + self.sharename_entry = xml.get_widget("sharename_entry") self.read_radio = xml.get_widget("share_read_radio") self.write_radio = xml.get_widget("share_write_radio") @@ -153,6 +155,9 @@ invalidUsers = None for line in self.samba_file_list: + if line.type == sambaToken.SambaToken.SAMBA_TOKEN_SECTION_HEADER and string.strip(line.getData()) == parent: + sharename = string.strip (line.getData(),"\n[]") + self.sharename_entry.set_text(sharename) if line.type == sambaToken.SambaToken.SAMBA_TOKEN_KEYVAL and line.parent == parent: if line.keyname == "path": self.dir_entry.set_text(line.keyval) @@ -231,6 +236,13 @@ # Strip off any whitespace path = string.strip(path) + # Get the sharename and strip off any whitespace + sharename = string.strip(self.sharename_entry.get_text()) + + # Question: Are there other characters that are invalid for the sharename? + sharename = string.replace (sharename, "[", "") + sharename = string.replace (sharename, "]", "") + #Check to see if directory exists if not self.checkDirectoryValidity(path): return @@ -260,35 +272,38 @@ self.share_notebook.set_current_page(1) return - if path == "/": - #Sharing the root is a special case - dir = "/" - dir_header = "[root directory]" + if sharename == "": + if path == "/": + #Sharing the root is a special case + dir = "/" + dir_header = "[root directory]" - else: - #Check to see if the path ends in a "/" If it does, strip it off - if path[-1:] == "/": - path = path[:-1] - - #If there are any /'s or \'s in the path, split by them - if '/' in path: - tokens = string.split(path, "/") - - #The last item in the token list is the directory name that we want - dir = tokens[len(tokens)-1] + else: + #Check to see if the path ends in a "/" If it does, strip it off + if path[-1:] == "/": + path = path[:-1] - dir = string.replace (dir, " ", "_") - - #Build the section header name by bookending dir with '[' and ']' - dir_header = "[" + dir + "]" + #If there are any /'s or \'s in the path, split by them + if '/' in path: + tokens = string.split(path, "/") + + #The last item in the token list is the directory name that we want + dir = tokens[len(tokens)-1] + + dir = string.replace (dir, " ", "_") + + #Build the section header name by bookending dir with '[' and ']' + dir_header = "[" + dir + "]" + else: + dir_header = "[" + sharename + "]" #If there's already a section header with this name, then start adding number to it #until it's a unique name if dir_header in self.samba_data.getShareHeaders(): count = 1 - while dir_header in self.samba_data.getShareHeaders(): - dir_header = "[" + dir + "-" + str(count) + "]" - count = count + 1 + while dir_header in self.samba_data.getShareHeaders(): + dir_header = "[" + dir + "-" + str(count) + "]" + count = count + 1 #Ok, things are good now. Start adding to the share_store iter = self.ParentClass.share_store.append() @@ -354,6 +369,13 @@ dir = self.dir_entry.get_text() dir = string.strip(dir) + # Get the sharename and strip off any whitespace + sharename = string.strip(self.sharename_entry.get_text()) + + # Question: Are there other characters that are invalid for the sharename? + sharename = string.replace (sharename, "[", "") + sharename = string.replace (sharename, "]", "") + #Check to see if directory exists if not self.checkDirectoryValidity(dir): return @@ -404,8 +426,16 @@ self.ParentClass.changeValue("valid users", "None", parent) self.ParentClass.changeValue("invalid users", "None", parent) - - + # parent contains [the old sharename] of course + # If the new name differs from the old one, we will need to rename + oldsharename = string.strip (parent,"\n[]") + if sharename != oldsharename: + self.ParentClass.share_store.set_value(self.edit_iter, 3, "[" + sharename + "]") + self.ParentClass.changeSectionHeader (oldsharename, sharename) + self.samba_file_list = self.ParentClass.samba_data.getList() + for line in self.samba_file_list: + if line.type == sambaToken.SambaToken.SAMBA_TOKEN_KEYVAL and line.parent == "[" + oldsharename + "]": + line.parent = "[" + sharename + "]" self.ParentClass.share_store.set_value(self.edit_iter, 0, dir) self.ParentClass.changeValue("path", dir, parent) @@ -457,5 +487,3 @@ def userRadioToggled(self, *args): self.valid_users_treeview.set_sensitive(self.user_access_radio.get_active()) - - Index: src/system-config-samba.glade =================================================================== RCS file: /usr/local/CVS/redhat-config-samba/src/system-config-samba.glade,v retrieving revision 1.4 diff -u -r1.4 system-config-samba.glade --- src/system-config-samba.glade 23 Mar 2004 20:54:11 -0000 1.4 +++ src/system-config-samba.glade 27 May 2004 20:34:17 -0000 @@ -11,6 +11,11 @@ <property name="modal">True</property> <property name="resizable">True</property> <property name="destroy_with_parent">False</property> + <property name="decorated">True</property> + <property name="skip_taskbar_hint">False</property> + <property name="skip_pager_hint">False</property> + <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <child> <widget class="GtkHPaned" id="hpaned1"> @@ -643,6 +648,11 @@ <property name="modal">True</property> <property name="resizable">True</property> <property name="destroy_with_parent">False</property> + <property name="decorated">True</property> + <property name="skip_taskbar_hint">False</property> + <property name="skip_pager_hint">False</property> + <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <child> <widget class="GtkVBox" id="vbox1"> @@ -1064,6 +1074,7 @@ <property name="label">gtk-cancel</property> <property name="use_stock">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> <signal name="clicked" handler="on_basic_cancel_button_clicked" last_modification_time="Mon, 15 Jul 2002 20:11:19 GMT"/> </widget> </child> @@ -1076,6 +1087,7 @@ <property name="label">gtk-ok</property> <property name="use_stock">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> <signal name="clicked" handler="on_basic_ok_button_clicked" last_modification_time="Mon, 15 Jul 2002 20:11:40 GMT"/> </widget> </child> @@ -1099,6 +1111,11 @@ <property name="modal">True</property> <property name="resizable">True</property> <property name="destroy_with_parent">False</property> + <property name="decorated">True</property> + <property name="skip_taskbar_hint">False</property> + <property name="skip_pager_hint">False</property> + <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <child> <widget class="GtkVBox" id="vbox5"> @@ -1131,6 +1148,7 @@ <property name="label" translatable="yes">_Add User</property> <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> <signal name="clicked" handler="on_add_user_button_clicked"/> </widget> </child> @@ -1143,6 +1161,7 @@ <property name="label" translatable="yes">_Edit User</property> <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> <signal name="clicked" handler="on_edit_user_button_clicked"/> </widget> </child> @@ -1155,6 +1174,7 @@ <property name="label" translatable="yes">_Delete User</property> <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> <signal name="clicked" handler="on_delete_user_button_clicked"/> </widget> </child> @@ -1198,6 +1218,7 @@ <property name="label">gtk-ok</property> <property name="use_stock">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> <signal name="clicked" handler="on_users_ok_button_clicked"/> </widget> </child> @@ -1219,6 +1240,11 @@ <property name="modal">True</property> <property name="resizable">True</property> <property name="destroy_with_parent">False</property> + <property name="decorated">True</property> + <property name="skip_taskbar_hint">False</property> + <property name="skip_pager_hint">False</property> + <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <child> <widget class="GtkVBox" id="vbox6"> @@ -1446,6 +1472,7 @@ <property name="label">gtk-cancel</property> <property name="use_stock">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> <signal name="clicked" handler="on_add_user_cancel_button_clicked"/> </widget> </child> @@ -1458,6 +1485,7 @@ <property name="label">gtk-ok</property> <property name="use_stock">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> <signal name="clicked" handler="on_add_user_ok_button_clicked"/> </widget> </child> @@ -1479,6 +1507,11 @@ <property name="modal">False</property> <property name="resizable">True</property> <property name="destroy_with_parent">False</property> + <property name="decorated">True</property> + <property name="skip_taskbar_hint">False</property> + <property name="skip_pager_hint">False</property> + <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <child> <widget class="GtkVBox" id="vbox8"> @@ -1507,13 +1540,59 @@ <child> <widget class="GtkTable" id="table7"> <property name="visible">True</property> - <property name="n_rows">2</property> + <property name="n_rows">3</property> <property name="n_columns">2</property> <property name="homogeneous">False</property> <property name="row_spacing">6</property> <property name="column_spacing">6</property> <child> + <widget class="GtkEntry" id="description_entry"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">True</property> + <property name="visibility">True</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char" translatable="yes">*</property> + <property name="activates_default">False</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label51"> + <property name="visible">True</property> + <property name="label" translatable="yes">D_escription:</property> + <property name="use_underline">True</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_CENTER</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="mnemonic_widget">description_entry</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> <widget class="GtkHBox" id="hbox1"> <property name="visible">True</property> <property name="homogeneous">False</property> @@ -1545,6 +1624,7 @@ <property name="label" translatable="yes">Brow_se...</property> <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> <signal name="clicked" handler="on_share_browse_button_clicked"/> </widget> <packing> @@ -1557,8 +1637,8 @@ <packing> <property name="left_attach">1</property> <property name="right_attach">2</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> </packing> </child> @@ -1579,40 +1659,39 @@ <packing> <property name="left_attach">0</property> <property name="right_attach">1</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> <property name="x_options">fill</property> <property name="y_options"></property> </packing> </child> <child> - <widget class="GtkLabel" id="label51"> + <widget class="GtkLabel" id="label75"> <property name="visible">True</property> - <property name="label" translatable="yes">D_escription:</property> - <property name="use_underline">True</property> + <property name="label" translatable="yes">Share name</property> + <property name="use_underline">False</property> <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> <property name="wrap">False</property> <property name="selectable">False</property> <property name="xalign">0</property> <property name="yalign">0.5</property> <property name="xpad">0</property> <property name="ypad">0</property> - <property name="mnemonic_widget">description_entry</property> </widget> <packing> <property name="left_attach">0</property> <property name="right_attach">1</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> <property name="x_options">fill</property> <property name="y_options"></property> </packing> </child> <child> - <widget class="GtkEntry" id="description_entry"> + <widget class="GtkEntry" id="sharename_entry"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="editable">True</property> @@ -1626,8 +1705,8 @@ <packing> <property name="left_attach">1</property> <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> <property name="y_options"></property> </packing> </child> @@ -1678,6 +1757,7 @@ <property name="label" translatable="yes">_Read-only</property> <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> <property name="active">False</property> <property name="inconsistent">False</property> <property name="draw_indicator">True</property> @@ -1696,6 +1776,7 @@ <property name="label" translatable="yes">Read / _Write</property> <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> <property name="active">False</property> <property name="inconsistent">False</property> <property name="draw_indicator">True</property> @@ -1747,6 +1828,7 @@ <property name="label" translatable="yes">O_nly allow access to specific users</property> <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> <property name="active">True</property> <property name="inconsistent">False</property> <property name="draw_indicator">True</property> @@ -1765,6 +1847,10 @@ <property name="yalign">0.5</property> <property name="xscale">0.9</property> <property name="yscale">1</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">0</property> + <property name="right_padding">0</property> <child> <widget class="GtkScrolledWindow" id="scrolledwindow2"> @@ -1802,6 +1888,7 @@ <property name="label" translatable="yes">A_llow access to everyone</property> <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> <property name="active">False</property> <property name="inconsistent">False</property> <property name="draw_indicator">True</property> @@ -1860,6 +1947,7 @@ <property name="label">gtk-cancel</property> <property name="use_stock">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> <signal name="clicked" handler="on_share_cancel_button_clicked" last_modification_time="Mon, 15 Jul 2002 20:12:27 GMT"/> </widget> </child> @@ -1872,6 +1960,7 @@ <property name="label">gtk-ok</property> <property name="use_stock">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> <signal name="clicked" handler="on_share_ok_button_clicked" last_modification_time="Mon, 15 Jul 2002 20:12:36 GMT"/> </widget> </child> @@ -1893,6 +1982,11 @@ <property name="modal">False</property> <property name="resizable">True</property> <property name="destroy_with_parent">False</property> + <property name="decorated">True</property> + <property name="skip_taskbar_hint">False</property> + <property name="skip_pager_hint">False</property> + <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <child> <widget class="GtkVBox" id="vbox12"> @@ -2016,6 +2110,7 @@ <property name="label" translatable="yes">Read</property> <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> <property name="active">False</property> <property name="inconsistent">False</property> <property name="draw_indicator">True</property> @@ -2037,6 +2132,7 @@ <property name="label" translatable="yes">Read</property> <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> <property name="active">False</property> <property name="inconsistent">False</property> <property name="draw_indicator">True</property> @@ -2058,6 +2154,7 @@ <property name="label" translatable="yes">Read</property> <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> <property name="active">False</property> <property name="inconsistent">False</property> <property name="draw_indicator">True</property> @@ -2079,6 +2176,7 @@ <property name="label" translatable="yes">Write</property> <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> <property name="active">False</property> <property name="inconsistent">False</property> <property name="draw_indicator">True</property> @@ -2100,6 +2198,7 @@ <property name="label" translatable="yes">Write</property> <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> <property name="active">False</property> <property name="inconsistent">False</property> <property name="draw_indicator">True</property> @@ -2121,6 +2220,7 @@ <property name="label" translatable="yes">Write</property> <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> <property name="active">False</property> <property name="inconsistent">False</property> <property name="draw_indicator">True</property> @@ -2142,6 +2242,7 @@ <property name="label" translatable="yes">Execute</property> <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> <property name="active">False</property> <property name="inconsistent">False</property> <property name="draw_indicator">True</property> @@ -2163,6 +2264,7 @@ <property name="label" translatable="yes">Execute</property> <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> <property name="active">False</property> <property name="inconsistent">False</property> <property name="draw_indicator">True</property> @@ -2184,6 +2286,7 @@ <property name="label" translatable="yes">Execute</property> <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> <property name="active">False</property> <property name="inconsistent">False</property> <property name="draw_indicator">True</property> @@ -2227,6 +2330,7 @@ <property name="label">gtk-cancel</property> <property name="use_stock">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> <signal name="clicked" handler="on_share_cancel_button_clicked" last_modification_time="Mon, 15 Jul 2002 20:12:27 GMT"/> </widget> </child> @@ -2239,6 +2343,7 @@ <property name="label">gtk-ok</property> <property name="use_stock">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> <signal name="clicked" handler="on_share_ok_button_clicked" last_modification_time="Mon, 15 Jul 2002 20:12:36 GMT"/> </widget> </child>
-- Fedora-config-list mailing list Fedora-config-list@xxxxxxxxxx http://www.redhat.com/mailman/listinfo/fedora-config-list