gnome-schedule r1119 - in branches/x-output-support: . src



Author: gauteh
Date: Sat Dec 13 19:15:51 2008
New Revision: 1119
URL: http://svn.gnome.org/viewvc/gnome-schedule?rev=1119&view=rev

Log:
template respects output setting, in crontab

Modified:
   branches/x-output-support/ChangeLog
   branches/x-output-support/src/crontab.py
   branches/x-output-support/src/crontabEditor.py
   branches/x-output-support/src/mainWindow.py
   branches/x-output-support/src/template.py
   branches/x-output-support/src/template_chooser.py
   branches/x-output-support/src/template_manager.py

Modified: branches/x-output-support/src/crontab.py
==============================================================================
--- branches/x-output-support/src/crontab.py	(original)
+++ branches/x-output-support/src/crontab.py	Sat Dec 13 19:15:51 2008
@@ -746,19 +746,15 @@
 		os.unlink (path)
 		
 		
-	#TODO: check into
-	#if a command his lenght is to long the last part is removed 
 	def __make_preview__ (self, str, preview_len = 0):
 		if preview_len == 0:
 			preview_len = self.preview_len
-		cnt = 0
-		result = ""
-		for a in str:
-			if cnt <= preview_len:
-				result = result + a
-			cnt = cnt + 1
-		if cnt > preview_len:
-			result = result + "..."
-		result = result.replace ("&", "&amp;")
+	
+		str = str.replace ("&", "&amp")
+
+		if len (str) <= preview_len:
+			return str
+		else:
+			return str[:preview_len] + "..."
 
 

Modified: branches/x-output-support/src/crontabEditor.py
==============================================================================
--- branches/x-output-support/src/crontabEditor.py	(original)
+++ branches/x-output-support/src/crontabEditor.py	Sat Dec 13 19:15:51 2008
@@ -76,10 +76,10 @@
 		
 		self.cb_output = self.xml.get_widget ("combo_output")
 		self.cb_o_model = gtk.ListStore (gobject.TYPE_STRING, gobject.TYPE_INT)
-		self.cb_o_model.append ([_("Default behaviour"), 0])
-		self.cb_o_model.append ([_("Supress output"), 1])
-		self.cb_o_model.append ([_("X application"), 2])
-		self.cb_o_model.append ([_("X application: supress output"), 3])
+		self.cb_o_model.append ([self.ParentClass.output_strings[0], 0])
+		self.cb_o_model.append ([self.ParentClass.output_strings[1], 1])
+		self.cb_o_model.append ([self.ParentClass.output_strings[2], 2])
+		self.cb_o_model.append ([self.ParentClass.output_strings[3], 3])
 		self.cb_output.set_model (self.cb_o_model)
 		cell = gtk.CellRendererText ()
 		self.cb_output.pack_start (cell, True)

Modified: branches/x-output-support/src/mainWindow.py
==============================================================================
--- branches/x-output-support/src/mainWindow.py	(original)
+++ branches/x-output-support/src/mainWindow.py	Sat Dec 13 19:15:51 2008
@@ -66,6 +66,14 @@
 		
 		self.noevents = False
 					
+		# Common string representation for the different output modes
+		self.output_strings = [
+								_("Default behaviour"),
+								_("Supress output"), 
+								_("X application"), 
+								_("X application: supress output"),
+						]
+
 		#start the backend where all the user configuration is stored
 		self.backend = data.ConfigBackend(self, "gconf")
 		self.template = template.Template (self, self.backend)

Modified: branches/x-output-support/src/template.py
==============================================================================
--- branches/x-output-support/src/template.py	(original)
+++ branches/x-output-support/src/template.py	Sat Dec 13 19:15:51 2008
@@ -72,7 +72,7 @@
 		self.gconf_client.unset("/apps/gnome-schedule/templates/crontab/%s/title" % (str (template_id)))
 		self.gconf_client.unset("/apps/gnome-schedule/templates/crontab/%s/command" % (str (template_id)))
 		self.gconf_client.unset("/apps/gnome-schedule/templates/crontab/%s/timeexpression" % (str (template_id)))
-		self.gconf_client.unset("/apps/gnome-schedule/templates/crontab/%s/nooutput" % (str (template_id)))
+		self.gconf_client.unset("/apps/gnome-schedule/templates/crontab/%s/output" % (str (template_id)))
 			
 		if newstring == "   ":
 			self.gconf_client.unset ("/apps/gnome-schedule/templates/crontab/installed")
@@ -90,7 +90,7 @@
 			self.gconf_client.set_int ("/apps/gnome-schedule/templates/crontab/last_id", i)
 			return i
 			
-	def savetemplate_crontab (self, template_id, title, command, nooutput, timeexpression):	
+	def savetemplate_crontab (self, template_id, title, command, output, timeexpression):	
 
 		if (template_id == 0):
 			template_id = self.create_new_id_crontab ()
@@ -98,7 +98,7 @@
 		self.gconf_client.set_string("/apps/gnome-schedule/templates/crontab/%s/timeexpression" % (str (template_id)), timeexpression)
 		self.gconf_client.set_string("/apps/gnome-schedule/templates/crontab/%s/title" % (str (template_id)), title)
 		self.gconf_client.set_string("/apps/gnome-schedule/templates/crontab/%s/command" % (str (template_id)), command)
-		self.gconf_client.set_bool("/apps/gnome-schedule/templates/crontab/%s/nooutput" % (str (template_id)), nooutput)
+		self.gconf_client.set_int("/apps/gnome-schedule/templates/crontab/%s/output" % (str (template_id)), output)
 		
 		installed = self.gconf_client.get_string("/apps/gnome-schedule/templates/crontab/installed")
 		if installed == None:
@@ -134,9 +134,9 @@
 			try:
 				command = self.gconf_client.get_string("/apps/gnome-schedule/templates/crontab/%s/command" % (str (template_id)))
 				title = self.gconf_client.get_string("/apps/gnome-schedule/templates/crontab/%s/title" % (str (template_id)))
-				nooutput = self.gconf_client.get_bool("/apps/gnome-schedule/templates/" + type + "/%s/nooutput" % (template_id))
+				output = self.gconf_client.get_int("/apps/gnome-schedule/templates/" + type + "/%s/output" % (str (template_id)))
 				timeexpression = self.gconf_client.get_string("/apps/gnome-schedule/templates/" + type + "/%s/timeexpression" % (template_id))
-				return template_id, title, command, nooutput, timeexpression
+				return template_id, title, command, output, timeexpression
 	
 			except Exception, ex:
 				return False
@@ -192,15 +192,17 @@
 		s = "<b>" + _("Title:") + "</b> " + title + "\n<b>" + _("Command:") + "</b> " + command
 		return s
 		
-	def format_crontab (self, title, command, nooutput, timeexpression):
+	def format_crontab (self, title, command, output, timeexpression):
 		command = self.parent.crontab.__make_preview__ (command)
 		if self.parent.edit_mode == "simple":
 			# hehe.. :)
 			timeexpression = timeexpression + " echo hehe"
 			minute, hour, dom, moy, dow, hehe = self.parent.crontab.parse (timeexpression, True)
 			timeexpression = self.parent.crontab.__easy__ (minute, hour, dom, moy, dow)
+
 		s = "<b>" + _("Title:") + "</b> " + title + "\n<b>" + _("Run:") + "</b> " + timeexpression + "\n<b>" + _("Command:") + "</b> " + command
-		if nooutput:
-			s = s + " <i>(" + _("No output") + ")</i>"
+
+		if output:
+			s = (s + " <i>(" + "%s"  + ")</i>") % (str (self.parent.output_strings[output]))
 		
 		return s

Modified: branches/x-output-support/src/template_chooser.py
==============================================================================
--- branches/x-output-support/src/template_chooser.py	(original)
+++ branches/x-output-support/src/template_chooser.py	Sat Dec 13 19:15:51 2008
@@ -101,8 +101,8 @@
 			for id in crontab:
 				t = self.template.gettemplate ("crontab", int (id))
 				if t != False:
-					id2, title, command, nooutput, timeexpression = t
-					formatted = self.template.format_crontab (title, command, nooutput, timeexpression)
+					id2, title, command, output, timeexpression = t
+					formatted = self.template.format_crontab (title, command, output, timeexpression)
 					iter = self.treemodel.append ([int (id), "crontab", _("Recurrent"), formatted, self.parent.bigiconcrontab])
 					
 					
@@ -131,8 +131,8 @@
 			elif type == "crontab":
 				t = self.template.gettemplate ("crontab", int (id))
 				if t != False:
-					id2, title, command, nooutput, timeexpression = t
-					self.parent.crontab_editor.showadd_template (self.transient, title, command, nooutput, timeexpression)
+					id2, title, command, output, timeexpression = t
+					self.parent.crontab_editor.showadd_template (self.transient, title, command, output, timeexpression)
 			
 			self.widget.hide ()
 		

Modified: branches/x-output-support/src/template_manager.py
==============================================================================
--- branches/x-output-support/src/template_manager.py	(original)
+++ branches/x-output-support/src/template_manager.py	Sat Dec 13 19:15:51 2008
@@ -106,8 +106,8 @@
 			for id in crontab:
 				t = self.template.gettemplate ("crontab", int (id))
 				if t != False:
-					id2, title, command, nooutput, timeexpression = t
-					formatted = self.template.format_crontab (title, command, nooutput, timeexpression)
+					id2, title, command, output, timeexpression = t
+					formatted = self.template.format_crontab (title, command, output, timeexpression)
 					iter = self.treemodel.append ([int (id), "crontab", _("Recurrent"), formatted, self.parent.bigiconcrontab])
 					
 	def on_edit_clicked (self, *args):
@@ -124,12 +124,12 @@
 			elif type == "crontab":
 				t = self.template.gettemplate ("crontab", int (id)	)
 				if t != False:
-					id2, title, command, nooutput, timeexpression = t
-					self.parent.crontab_editor.showedit_template (self.widget, id2, title, command, nooutput, timeexpression)
+					id2, title, command, output, timeexpression = t
+					self.parent.crontab_editor.showedit_template (self.widget, id2, title, command, output, timeexpression)
 		self.reload_tv ()
 		
 	def on_new_clicked (self, *args):
-		relf.parent.addWindow.ShowAddWindow (self.widget, 1)
+		self.parent.addWindow.ShowAddWindow (self.widget, 1)
 	
 	def on_delete_clicked (self, *args):
 		store, iter = self.treeview.get_selection().get_selected()
@@ -170,8 +170,8 @@
 			elif type == "crontab":
 				t = self.template.gettemplate ("crontab", int (id)	)
 				if t != False:
-					id2, title, command, nooutput, timeexpression = t
-					self.parent.crontab_editor.showadd_template (self.widget, title, command, nooutput, timeexpression)
+					id2, title, command, output, timeexpression = t
+					self.parent.crontab_editor.showadd_template (self.widget, title, command, output, timeexpression)
 		
 			self.widget.hide ()
 		



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]