The patch gives a fourth option on the Runlevel menu ("All"). This allows you to edit all 3 levels on the same screen. It is not the default option and at startup will default to one of the other three. There is a screenshot at: http://www.cs.man.ac.uk/~brejc8/temp/sevices.png
This is my first time programming python so I probably did something wrong (or at least not safely/optimally). At startup all 7 init level columns are initiated but the runlevel menu selects which ones are visible (3, 4, 5, 3-5). It is possible to view all or any (0-6) levels by adding or changing the menu options. I did a bit of testing but I again stress I am very (2 days) new to this.
Minor points:
I removed columns from class CheckList (allowing two text fields) as I thought this might become confusing and the second field wasn't used anyway.
Glade has changed the numbers of images as well as adding a load of stuff. I think this is because I am using a newer version but this shouldn't change anything.
-- Charlie Brej APT Group, Dept. Computer Science, University of Manchester Web: http://www.cs.man.ac.uk/~brejc8/ Tel: +44 161 275 6844 Mail: IT302, Manchester University, Manchester, M13 9PL, UK
Index: src/checklist.py =================================================================== RCS file: /usr/local/CVS/redhat-config-services/src/checklist.py,v retrieving revision 1.2 diff -u -3 -p -r1.2 checklist.py --- src/checklist.py 5 Feb 2004 23:27:42 -0000 1.2 +++ src/checklist.py 15 Feb 2005 19:25:53 -0000 @@ -22,42 +22,33 @@ class CheckList (gtk.TreeView): """A class (derived from gtk.TreeView) that provides a list of checkbox / text string pairs""" - # override this to make your own columns if necessary - def create_columns(self, columns): - # add the string columns to the tree view widget - for i in range(1, columns + 1): - renderer = gtk.CellRendererText() - column = gtk.TreeViewColumn('Text', renderer, text=i) - column.set_clickable(gtk.FALSE) - self.append_column(column) - # XXX need to handle the multicolumn case better still.... - def __init__ (self, columns = 1, custom_store=None): + def __init__ (self, custom_store=None): if not custom_store: - self.store = gtk.TreeStore(gobject.TYPE_BOOLEAN, - gobject.TYPE_STRING, - gobject.TYPE_STRING) + self.store = gtk.TreeStore(gobject.TYPE_BOOLEAN,gobject.TYPE_BOOLEAN,gobject.TYPE_BOOLEAN,gobject.TYPE_BOOLEAN, + gobject.TYPE_BOOLEAN,gobject.TYPE_BOOLEAN,gobject.TYPE_BOOLEAN,gobject.TYPE_STRING) else: self.store = custom_store - + gtk.TreeView.__init__ (self, self.store) - # XXX we only handle two text columns right now - if custom_store == None and columns > 2: - raise RuntimeError, "CheckList supports a maximum of 2 columns" - - self.columns = columns - - self.checkboxrenderer = gtk.CellRendererToggle() - column = gtk.TreeViewColumn('', self.checkboxrenderer, active=0) - column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) - column.set_fixed_width(40) - column.set_clickable(gtk.TRUE) - self.checkboxrenderer.connect ("toggled", self.toggled_item) - self.append_column(column) + self.checkboxrenderer = [None,None,None,None,None,None,None,None] + + for i in range(0, 7): + self.checkboxrenderer[i] = gtk.CellRendererToggle() + column = gtk.TreeViewColumn("Init %d" % i, self.checkboxrenderer[i], active=i) + column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) + column.set_fixed_width(40) + column.set_clickable(gtk.TRUE) + self.checkboxrenderer[i].connect ("toggled", self.toggled_item, i) + self.append_column(column) + - self.create_columns(columns) + renderer = gtk.CellRendererText() + column = gtk.TreeViewColumn('Text', renderer, text=7) + column.set_clickable(gtk.FALSE) + self.append_column(column) self.set_rules_hint(gtk.FALSE) self.set_headers_visible(gtk.FALSE) @@ -68,32 +59,29 @@ class CheckList (gtk.TreeView): # iterate over them all self.num_rows = 0 - def append_row (self, textList, init_value): + def append_row (self, text, init_valueList): """Add a row to the list. text: text to display in the row init_value: initial state of the indicator""" - textList = ("",) + textList iter = self.store.append(None) - self.store.set_value(iter, 0, init_value) + for i in range(0, 7): + self.store.set_value(iter, i, int(init_valueList[i])) # add the text for the number of columns we have - i = 1 - for text in textList[1:self.columns + 1]: - self.store.set_value(iter, i, textList[i]) - i = i + 1 + self.store.set_value(iter, 7, text) self.num_rows = self.num_rows + 1 - def toggled_item(self, data, row): + def toggled_item(self, data, row, column): """Set a function to be called when the value of a row is toggled. The function will be called with two arguments, the clicked item in the row and a string for which row was clicked.""" iter = self.store.get_iter((int(row),)) - val = self.store.get_value(iter, 0) - self.store.set_value(iter, 0, not val) + val = self.store.get_value(iter, column) + self.store.set_value(iter, column, not val) def clear (self): @@ -102,12 +90,12 @@ class CheckList (gtk.TreeView): self.num_rows = 0 - def get_active(self, row): + def get_active(self, row, column): """Return FALSE or TRUE as to whether or not the row is toggled similar to GtkToggleButtons""" iter = self.store.get_iter((row,)) - return self.store.get_value(iter, 0) + return self.store.get_value(iter, column) def set_active(self, row, is_active): @@ -121,7 +109,7 @@ class CheckList (gtk.TreeView): "Get the text from row and column" iter = self.store.get_iter((row,)) - return self.store.get_value(iter, column) + return self.store.get_value(iter, 7) def set_column_title(self, column, title): @@ -154,6 +142,21 @@ class CheckList (gtk.TreeView): col = self.get_column(column) if col: col.set_sizing(sizing) + + def set_column_visible(self, column, visible): + "Set the column visibility" + + col = self.get_column(column) + if col: + col.set_visible(visible) + + def set_headers_visible(self, visible): + "Set the column visibility" + + if visible != 0: + gtk.TreeView.set_headers_visible(self, gtk.TRUE) + else: + gtk.TreeView.set_headers_visible(self, gtk.FALSE) def set_column_sort_id(self, column, id): "Set the sort id of column to id" Index: src/serviceconf.glade =================================================================== RCS file: /usr/local/CVS/redhat-config-services/src/serviceconf.glade,v retrieving revision 1.18 diff -u -3 -p -r1.18 serviceconf.glade --- src/serviceconf.glade 24 Mar 2004 16:59:37 -0000 1.18 +++ src/serviceconf.glade 15 Feb 2005 19:25:53 -0000 @@ -104,6 +104,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_DIALOG</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <property name="has_separator">True</property> <child internal-child="vbox"> @@ -123,6 +128,7 @@ <property name="can_default">True</property> <property name="can_focus">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> <property name="response_id">-9</property> <child> @@ -132,6 +138,10 @@ <property name="yalign">0.5</property> <property name="xscale">0</property> <property name="yscale">0</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="GtkHBox" id="hbox1"> @@ -191,6 +201,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> <property name="response_id">-6</property> </widget> </child> @@ -203,6 +214,7 @@ <property name="label">gtk-save</property> <property name="use_stock">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> <property name="response_id">-8</property> </widget> </child> @@ -226,6 +238,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="relief">GTK_RELIEF_NONE</property> + <property name="focus_on_click">True</property> <child> <widget class="GtkImage" id="image44"> @@ -249,6 +262,8 @@ <child> <widget class="GtkEventBox" id="eventbox1"> <property name="visible">True</property> + <property name="visible_window">True</property> + <property name="above_child">False</property> <child> <widget class="GtkLabel" id="label4"> @@ -291,6 +306,11 @@ Do you want to save the changes?</proper <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_DIALOG</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <property name="has_separator">True</property> <child internal-child="vbox"> @@ -312,6 +332,7 @@ Do you want to save the changes?</proper <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> <property name="response_id">-6</property> </widget> </child> @@ -324,6 +345,7 @@ Do you want to save the changes?</proper <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> <property name="response_id">-5</property> </widget> </child> @@ -393,7 +415,7 @@ Do you want to save the changes?</proper </widget> <widget class="GtkWindow" id="winMain"> - <property name="width_request">550</property> + <property name="width_request">600</property> <property name="height_request">450</property> <property name="visible">True</property> <property name="title" translatable="yes">Service Configuration</property> @@ -402,6 +424,11 @@ Do you want to save the changes?</proper <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="vbox2"> @@ -432,7 +459,7 @@ Do you want to save the changes?</proper <accelerator key="s" modifiers="GDK_CONTROL_MASK" signal="activate"/> <child internal-child="image"> - <widget class="GtkImage" id="image112"> + <widget class="GtkImage" id="image176"> <property name="visible">True</property> <property name="stock">gtk-save</property> <property name="icon_size">1</property> @@ -454,7 +481,7 @@ Do you want to save the changes?</proper <accelerator key="l" modifiers="GDK_CONTROL_MASK" signal="activate"/> <child internal-child="image"> - <widget class="GtkImage" id="image113"> + <widget class="GtkImage" id="image177"> <property name="visible">True</property> <property name="stock">gtk-undo</property> <property name="icon_size">1</property> @@ -468,7 +495,7 @@ Do you want to save the changes?</proper </child> <child> - <widget class="GtkMenuItem" id="separator2"> + <widget class="GtkSeparatorMenuItem" id="separator2"> <property name="visible">True</property> </widget> </child> @@ -481,7 +508,7 @@ Do you want to save the changes?</proper <signal name="activate" handler="on_mnuExit_activate" last_modification_time="Tue, 16 Mar 2004 19:59:51 GMT"/> <child internal-child="image"> - <widget class="GtkImage" id="image114"> + <widget class="GtkImage" id="image178"> <property name="visible">True</property> <property name="stock">gtk-quit</property> <property name="icon_size">1</property> @@ -538,7 +565,7 @@ Do you want to save the changes?</proper <signal name="activate" handler="on_add_service_activate" last_modification_time="Wed, 09 Jul 2003 13:25:47 GMT"/> <child internal-child="image"> - <widget class="GtkImage" id="image115"> + <widget class="GtkImage" id="image179"> <property name="visible">True</property> <property name="stock">gtk-add</property> <property name="icon_size">1</property> @@ -559,7 +586,7 @@ Do you want to save the changes?</proper <signal name="activate" handler="on_delete_service_activate" last_modification_time="Wed, 09 Jul 2003 13:25:47 GMT"/> <child internal-child="image"> - <widget class="GtkImage" id="image116"> + <widget class="GtkImage" id="image180"> <property name="visible">True</property> <property name="stock">gtk-delete</property> <property name="icon_size">1</property> @@ -573,7 +600,7 @@ Do you want to save the changes?</proper </child> <child> - <widget class="GtkMenuItem" id="separator4"> + <widget class="GtkSeparatorMenuItem" id="separator4"> <property name="visible">True</property> </widget> </child> @@ -587,9 +614,9 @@ Do you want to save the changes?</proper <accelerator key="s" modifiers="GDK_CONTROL_MASK | GDK_MOD1_MASK" signal="activate"/> <child internal-child="image"> - <widget class="GtkImage" id="image117"> + <widget class="GtkImage" id="image181"> <property name="visible">True</property> - <property name="stock">gtk-go-forward</property> + <property name="stock">gtk-media-forward</property> <property name="icon_size">1</property> <property name="xalign">0.5</property> <property name="yalign">0.5</property> @@ -609,7 +636,7 @@ Do you want to save the changes?</proper <accelerator key="t" modifiers="GDK_CONTROL_MASK | GDK_MOD1_MASK" signal="activate"/> <child internal-child="image"> - <widget class="GtkImage" id="image118"> + <widget class="GtkImage" id="image182"> <property name="visible">True</property> <property name="stock">gtk-stop</property> <property name="icon_size">1</property> @@ -631,7 +658,7 @@ Do you want to save the changes?</proper <accelerator key="r" modifiers="GDK_CONTROL_MASK | GDK_MOD1_MASK" signal="activate"/> <child internal-child="image"> - <widget class="GtkImage" id="image119"> + <widget class="GtkImage" id="image183"> <property name="visible">True</property> <property name="stock">gtk-refresh</property> <property name="icon_size">1</property> @@ -663,7 +690,7 @@ Do you want to save the changes?</proper <property name="visible">True</property> <property name="label" translatable="yes">Runlevel _3</property> <property name="use_underline">True</property> - <property name="active">False</property> + <property name="active">True</property> <signal name="toggled" handler="on_optRL3_toggled" last_modification_time="Tue, 04 Mar 2003 18:28:41 GMT"/> <accelerator key="3" modifiers="GDK_CONTROL_MASK" signal="activate"/> </widget> @@ -686,12 +713,24 @@ Do you want to save the changes?</proper <property name="visible">True</property> <property name="label" translatable="yes">Runlevel _5</property> <property name="use_underline">True</property> - <property name="active">True</property> + <property name="active">False</property> <property name="group">optRL3</property> <signal name="toggled" handler="on_optRL5_toggled" last_modification_time="Tue, 04 Mar 2003 18:29:19 GMT"/> <accelerator key="5" modifiers="GDK_CONTROL_MASK" signal="activate"/> </widget> </child> + + <child> + <widget class="GtkRadioMenuItem" id="optRLA"> + <property name="visible">True</property> + <property name="label" translatable="yes">Runlevel _All</property> + <property name="use_underline">True</property> + <property name="active">False</property> + <property name="group">optRL3</property> + <signal name="toggled" handler="on_optRLA_toggled" last_modification_time="Mon, 14 Feb 2005 14:46:50 GMT"/> + <accelerator key="0" modifiers="GDK_CONTROL_MASK" signal="activate"/> + </widget> + </child> </widget> </child> </widget> @@ -715,7 +754,7 @@ Do you want to save the changes?</proper <accelerator key="F1" modifiers="0" signal="activate"/> <child internal-child="image"> - <widget class="GtkImage" id="image120"> + <widget class="GtkImage" id="image184"> <property name="visible">True</property> <property name="stock">gtk-help</property> <property name="icon_size">1</property> @@ -745,6 +784,7 @@ Do you want to save the changes?</proper <property name="orientation">GTK_ORIENTATION_HORIZONTAL</property> <property name="toolbar_style">GTK_TOOLBAR_BOTH</property> <property name="tooltips">True</property> + <property name="show_arrow">True</property> <child> <placeholder/> @@ -846,7 +886,7 @@ Do you want to save the changes?</proper <child> <widget class="GtkScrolledWindow" id="swindow"> <property name="border_width">2</property> - <property name="width_request">150</property> + <property name="width_request">220</property> <property name="visible">True</property> <property name="hscrollbar_policy">GTK_POLICY_NEVER</property> <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> @@ -886,6 +926,8 @@ Do you want to save the changes?</proper <property name="border_width">2</property> <property name="visible">True</property> <property name="editable">False</property> + <property name="overwrite">False</property> + <property name="accepts_tab">True</property> <property name="justification">GTK_JUSTIFY_LEFT</property> <property name="wrap_mode">GTK_WRAP_WORD</property> <property name="cursor_visible">True</property> @@ -948,6 +990,8 @@ Do you want to save the changes?</proper <property name="border_width">2</property> <property name="visible">True</property> <property name="editable">False</property> + <property name="overwrite">False</property> + <property name="accepts_tab">True</property> <property name="justification">GTK_JUSTIFY_LEFT</property> <property name="wrap_mode">GTK_WRAP_WORD</property> <property name="cursor_visible">True</property> Index: src/serviceconf.py =================================================================== RCS file: /usr/local/CVS/redhat-config-services/src/serviceconf.py,v retrieving revision 1.41 diff -u -3 -p -r1.41 serviceconf.py --- src/serviceconf.py 28 Jan 2005 13:31:09 -0000 1.41 +++ src/serviceconf.py 15 Feb 2005 19:25:54 -0000 @@ -164,6 +164,7 @@ class Gui: "on_optRL3_toggled" : self.on_optRL3_toggled, "on_optRL4_toggled" : self.on_optRL4_toggled, "on_optRL5_toggled" : self.on_optRL5_toggled , + "on_optRLA_toggled" : self.on_optRLA_toggled , "on_pmnStart_activate" : self.on_btnStart_clicked, "on_pmnStop_activate" : self.on_btnStop_clicked, "on_pmnRestart_activate" : self.on_btnRestart_clicked } ) @@ -184,10 +185,7 @@ class Gui: self.optRL3 = self.xml.get_widget("optRL3") self.optRL4 = self.xml.get_widget("optRL4") self.optRL5 = self.xml.get_widget("optRL5") - - self.optRL3= self.xml.get_widget("optRL3") - self.optRL4= self.xml.get_widget("optRL4") - self.optRL5= self.xml.get_widget("optRL5") + self.optRLA = self.xml.get_widget("optRLA") #toolbars self.tbrSave = self.xml.get_widget("tbrSave") @@ -257,9 +255,10 @@ class Gui: self.clstServices.get_selection ().connect ("changed", self.changed,None) self.clstServices.connect("button_press_event", self.local_button_press_cb) - self.clstServices.checkboxrenderer.connect("toggled", self.toggled_service) - self.clstServices.set_column_title(0,_("Start at Boot")) - self.clstServices.set_column_title(1,_("Services")) + for i in range(0, 7): + self.clstServices.checkboxrenderer[i].connect("toggled", self.toggled_service) + self.clstServices.set_column_title(i,"Init" " %d" % i) + self.clstServices.set_column_title(7,_("Services")) #self.clstServices.set_column_justification(0,GTK.JUSTIFY_CENTER) #self.clstServices.set_column_justification(1,GTK.JUSTIFY_LEFT) #self.clstServices.set_column_auto_resize(0,1) @@ -267,20 +266,37 @@ class Gui: self.popup_menu = gtk.MenuItem() + + + self.optRL3.set_active(0) + self.optRL4.set_active(0) + self.optRL5.set_active(0) + self.optRLA.set_active(0) + + self.clstServices.set_column_visible(0, 0) + self.clstServices.set_column_visible(1, 0) + self.clstServices.set_column_visible(2, 0) + self.clstServices.set_column_visible(3, 0) + self.clstServices.set_column_visible(4, 0) + self.clstServices.set_column_visible(5, 0) + self.clstServices.set_column_visible(6, 0) if self.editing_runlevel == "3" or self.editing_runlevel == "2" or self.editing_runlevel == "1": + self.clstServices.set_column_visible(3, 1) self.optRL3.set_active(1) - elif self.editing_runlevel == "5" : - self.optRL5.set_active(1) - elif self.editing_runlevel == "4" : + self.clstServices.set_column_visible(4, 1) self.optRL4.set_active(1) + else: + self.clstServices.set_column_visible(5, 1) + self.optRL5.set_active(1) + self.save_revert_sensitive(0) self.clstServices.get_selection().select_path ((0,)) self.changed(self.clstServices.get_selection(), None) - self.current_selected_service = self.clstServices.get_text(0,1) + self.current_selected_service = self.clstServices.get_text(0,7) self.winMain.show() @@ -315,13 +331,13 @@ class Gui: gtk.main_iteration() else: gtk.mainiteration() - self.allservices, self.dict_services = self.ServiceMethods.get_service_list(self.editing_runlevel, idle_func) + self.allservices, self.dict_services = self.ServiceMethods.get_service_list(idle_func) self.dict_services_orig = self.ServiceMethods.dict_services_orig self.lblEditing.set_text(_("Editing Runlevel: ") + self.editing_runlevel) self.already_init = 1 for servicename in self.allservices: - self.clstServices.append_row((servicename, ""), int(self.dict_services[servicename][0][int(self.editing_runlevel)])) + self.clstServices.append_row(servicename, self.dict_services[servicename][0]) self.winMain.set_sensitive(1) self.winMain.get_toplevel().window.set_cursor(gtk.gdk.Cursor(gtk.gdk.LEFT_PTR)) @@ -334,7 +350,7 @@ class Gui: (model, iter) = result if iter != None: row = model.get_path(iter)[0] - self.text_in_row = self.clstServices.get_text(int(row),1) + self.text_in_row = self.clstServices.get_text(int(row),7) self.set_text_buffer() self.set_text_status() @@ -367,28 +383,25 @@ class Gui: message=result[1] self.txtStatusBuffer.set_text(message.strip()) - def toggled_service(self, data, row): + def toggled_service(self, column, row): """Populates txtDesc with the service description of the service selected in clstServices""" - self.text_in_row = self.clstServices.get_text(int(row),1) - current_runlevel = int(self.editing_runlevel) - self.current_selected = self.clstServices.get_text(int(row),1) + self.text_in_row = self.clstServices.get_text(int(row),7) + self.current_selected = self.clstServices.get_text(int(row),7) #make sure we aren't updating if self.am_updating != 1: # enables and disables the save and revert buttons/menus # if something has been changed from it's orig setting + self.save_revert_sensitive(0) for i in range(0,len(self.ServiceMethods.dict_services_orig)): - self.checking_service = self.clstServices.get_text(i,1) - service_enabled = int("%d" % self.clstServices.get_active(i)) + self.checking_service = self.clstServices.get_text(i,7) - - if service_enabled == self.ServiceMethods.dict_services_orig[self.checking_service][0][current_runlevel]: - self.save_revert_sensitive(0) - - elif service_enabled != self.ServiceMethods.dict_services_orig[self.checking_service][0][current_runlevel]: - self.save_revert_sensitive(1) - break + for level in range(0, 7): + service_enabled = int("%d" % self.clstServices.get_active(i, level)) + if service_enabled != self.ServiceMethods.dict_services_orig[self.checking_service][0][level]: + self.save_revert_sensitive(1) + return self.text_in_row return self.text_in_row @@ -424,6 +437,14 @@ class Gui: return gtk.TRUE self.editing_runlevel = "3" self.lblEditing.set_text(_("Editing Runlevel: ") + self.editing_runlevel) + self.clstServices.set_column_visible(0, 0) + self.clstServices.set_column_visible(1, 0) + self.clstServices.set_column_visible(2, 0) + self.clstServices.set_column_visible(3, 1) + self.clstServices.set_column_visible(4, 0) + self.clstServices.set_column_visible(5, 0) + self.clstServices.set_column_visible(6, 0) + self.clstServices.set_headers_visible(0) self.populateList() @@ -441,13 +462,16 @@ class Gui: return gtk.TRUE self.editing_runlevel = "4" self.lblEditing.set_text(_("Editing Runlevel: ") + self.editing_runlevel) + self.clstServices.set_column_visible(0, 0) + self.clstServices.set_column_visible(1, 0) + self.clstServices.set_column_visible(2, 0) + self.clstServices.set_column_visible(3, 0) + self.clstServices.set_column_visible(4, 1) + self.clstServices.set_column_visible(5, 0) + self.clstServices.set_column_visible(6, 0) + self.clstServices.set_headers_visible(0) self.populateList() - def on_edit_runlevel(self, button): - self.optRL3.set_sensitive(not self.dirty) - self.optRL4.set_sensitive(not self.dirty) - self.optRL5.set_sensitive(not self.dirty) - def on_optRL5_toggled(self, button): """calls populateList() to repopulate the checklist for runlevel 5""" if self.previous==button: @@ -460,8 +484,44 @@ class Gui: return gtk.TRUE self.editing_runlevel = "5" self.lblEditing.set_text(_("Editing Runlevel: ") + self.editing_runlevel) + self.clstServices.set_column_visible(0, 0) + self.clstServices.set_column_visible(1, 0) + self.clstServices.set_column_visible(2, 0) + self.clstServices.set_column_visible(3, 0) + self.clstServices.set_column_visible(4, 0) + self.clstServices.set_column_visible(5, 1) + self.clstServices.set_column_visible(6, 0) + self.clstServices.set_headers_visible(0) + self.populateList() + + def on_optRLA_toggled(self, button): + """calls populateList() to repopulate the checklist for all runlevels""" + if self.previous==button: + return + if button.get_active() != gtk.TRUE: + self.previous=button + return + if self.check_dirty() == gtk.RESPONSE_CANCEL: + self.previous.set_active(1) + return gtk.TRUE + self.editing_runlevel = "All" + self.lblEditing.set_text(_("Editing Runlevel: ") + _("All")) + self.clstServices.set_column_visible(0, 0) + self.clstServices.set_column_visible(1, 0) + self.clstServices.set_column_visible(2, 0) + self.clstServices.set_column_visible(3, 1) + self.clstServices.set_column_visible(4, 1) + self.clstServices.set_column_visible(5, 1) + self.clstServices.set_column_visible(6, 0) + self.clstServices.set_headers_visible(1) self.populateList() + def on_edit_runlevel(self, button): + self.optRL3.set_sensitive(not self.dirty) + self.optRL4.set_sensitive(not self.dirty) + self.optRL5.set_sensitive(not self.dirty) + self.optRLA.set_sensitive(not self.dirty) + def check_dirty(self): rc=gtk.RESPONSE_YES """Check to see if the user has any unsaved changes.""" @@ -544,10 +604,11 @@ class Gui: def on_mnuSave_clicked(self, args): """Commits the changes made for each service""" for i in range(0,len(self.ServiceMethods.dict_services)): - servicename = self.clstServices.get_text(i,1) - service_enabled = "%d" % self.clstServices.get_active(i) - self.ServiceMethods.save_changes(servicename, service_enabled, self.editing_runlevel) - + servicename = self.clstServices.get_text(i,7) + for level in range(0, 7): + service_enabled = int("%d" % self.clstServices.get_active(i, level)) + if service_enabled != self.ServiceMethods.dict_services_orig[servicename][0][level]: + self.ServiceMethods.save_changes(servicename, service_enabled, level) self.save_revert_sensitive(0) def quit(self,arg1=None,arg2=None): @@ -570,7 +631,7 @@ class Gui: """calls ServiceMethods.service_action_results and displays the results in a dialog box""" self.winMain.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH)) - results = self.ServiceMethods.service_action_results(servicename, action_type, self.editing_runlevel) + results = self.ServiceMethods.service_action_results(servicename, action_type, self.ServiceMethods.get_runlevel()) if int(results[0]) != 0: dlg = gtk.MessageDialog(self.winMain, 0, gtk.MESSAGE_ERROR, @@ -626,8 +687,8 @@ class Gui: def local_button_press_cb (self, clist, event): """checks to see if the third mouse button was clicked. If it was, then bring up the popup menu""" row=clist.get_path_at_pos (int(event.x),int(event.y))[0][0] - self.text_in_row = self.clstServices.get_text(int(row),1) - self.current_selected = self.clstServices.get_text(int(row),1) + self.text_in_row = self.clstServices.get_text(int(row),7) + self.current_selected = self.clstServices.get_text(int(row),7) self.set_text_buffer() self.set_text_status() if (event.button == 3): Index: src/servicemethods.py =================================================================== RCS file: /usr/local/CVS/redhat-config-services/src/servicemethods.py,v retrieving revision 1.22 diff -u -3 -p -r1.22 servicemethods.py --- src/servicemethods.py 4 Jan 2005 16:48:13 -0000 1.22 +++ src/servicemethods.py 15 Feb 2005 19:25:54 -0000 @@ -87,19 +87,15 @@ class ServiceMethods: #runlevel = self.get_runlevel() dirlist = os.listdir("/etc/rc.d/rc%s" % editing_runlevel + ".d") - have_match = -1 + have_match = 0 - while have_match == -1: - #for i in range(0,len(dirlist)): - for direntry in dirlist: - # check for start links only, we don't care if there is a kill link - if re.match(r'^[S][0-9][0-9]' + servicename, direntry ): - have_match = 1 - break - # no match - if have_match != 1: - have_match = 0 - + #for i in range(0,len(dirlist)): + for direntry in dirlist: + # check for start links only, we don't care if there is a kill link + if re.match(r'^[S][0-9][0-9]' + servicename, direntry ): + have_match = 1 + break + return have_match @@ -182,7 +178,7 @@ class ServiceMethods: - def get_service_list(self, editing_runlevel, idle_func): + def get_service_list(self, idle_func): """populates the self.dict_services, self.dict_services_orig dictionaries and the self.allservices list with service information including whether or not a service is configured to start in runlevels 0-6, as well as whether it is an xinetd service, as well as service descriptions.""" self.dict_services= {} # this will be an unmodified self.dict_services @@ -244,8 +240,6 @@ class ServiceMethods: runlevels[i] = 0 else: runlevels[i] = 1 - # configured = 1 if configured already - # configured = self.check_if_on(servicename, editing_runlevel) self.dict_services[servicename] = [runlevels, 0, self.get_descriptions(initscript)] self.dict_services_orig[servicename] = [runlevels, 0] @@ -307,20 +301,10 @@ class ServiceMethods: #check to make sure we are an initscript and not an xinetd service if int(self.dict_services[servicename][1]) == 0: - # if it's toggled on - if self.dict_services[servicename][0][int(editing_runlevel)] == "1": - self.chkconfig_add_del(servicename, 1, editing_runlevel) - # if it's toggled off - elif self.dict_services[servicename][0][int(editing_runlevel)] == "0": - self.chkconfig_add_del(servicename, 0, editing_runlevel) + self.chkconfig_add_del(servicename, service_enabled, editing_runlevel) # for xinetd services - elif int(self.dict_services[servicename][1]) == 1: - # if it's toggled on - if self.dict_services[servicename][0][int(editing_runlevel)] == "1": - self.xinet_add_del(servicename, 1) - # if it's toggled off - elif self.dict_services[servicename][0][int(editing_runlevel)] == "0": - self.xinet_add_del(servicename, 0) + else: + self.xinet_add_del(servicename, service_enabled)
-- Fedora-config-list mailing list Fedora-config-list@xxxxxxxxxx http://www.redhat.com/mailman/listinfo/fedora-config-list