Package iceprod :: Package client :: Package gtk :: Module GtkProjects
[hide private]
[frames] | no frames]

Source Code for Module iceprod.client.gtk.GtkProjects

  1  #!/bin/env python 
  2  #   copyright  (c) 2005 
  3  #   the icecube collaboration 
  4  #   $Id: $ 
  5  # 
  6  #   @version $Revision: $ 
  7  #   @date $Date: $ 
  8  #   @author Juan Carlos Diaz Velez <juancarlos@icecube.wisc.edu> 
  9  #       @brief Project Frame for GtkIcetraConfig application 
 10  ######################################################################### 
 11  from iceprod.core.dataclasses import Project 
 12  from GtkProjectDisplay import GtkProjectDisplay 
 13  from GtkProjectEditor import * 
 14  from GtkProjectList import GtkProjectList  
 15  import sys 
 16  import pygtk 
 17  pygtk.require('2.0') 
 18  import gtk, gobject 
 19  from GtkIPModule import * 
 20   
21 -class GtkProjects(GtkIPModule):
22
23 - def commit_changes(self, b):
24 if self.box: 25 self.box.commit_changes(None,None) 26 self.box.destroy() 27 if self.hbbox: 28 self.hbbox.destroy() 29 30 self.edit = not self.edit 31 self.box = GtkProjectDisplay(self.icetray,self.db) 32 self.box.set_text_buffer(self.textbuffer) 33 self.pack_start(self.box) 34 b0 = gtk.Button('Edit') 35 b0.connect('clicked', self.edit_projects) 36 37 b1 = gtk.Button('Add Project',stock=gtk.STOCK_ADD) 38 b1.connect('clicked', self.add_project, self.box ) 39 40 self.hbbox = gtk.HButtonBox() 41 self.hbbox.pack_start(b0, False, False, 1) 42 # self.hbbox.pack_start(b1, False, False, 1) 43 44 self.pack_start(self.hbbox, False) 45 self.show_all()
46
47 - def cancel_edit_projects(self, b):
48 if self.box: 49 self.box.destroy() 50 if self.hbbox: 51 self.hbbox.destroy() 52 53 self.edit = not self.edit 54 self.box = GtkProjectDisplay(self.icetray,self.db) 55 self.box.set_text_buffer(self.textbuffer) 56 57 58 self.pack_start(self.box) 59 60 b0 = gtk.Button('Edit') 61 b0.connect('clicked', self.edit_projects) 62 b1 = gtk.Button('Add Project',stock=gtk.STOCK_ADD) 63 b1.connect('clicked', self.add_project, self.box) 64 65 self.hbbox = gtk.HButtonBox() 66 self.hbbox.pack_start(b0, False, False, 1) 67 # self.hbbox.pack_start(b1, False, False, 1) 68 69 self.pack_start(self.hbbox, False) 70 self.show_all()
71
72 - def edit_projects(self, b):
73 if self.box: 74 self.box.destroy() 75 if self.hbbox: 76 self.hbbox.destroy() 77 78 try: 79 self.edit = not self.edit 80 self.box = GtkProjectEditor(self.icetray,self.db) 81 self.box.set_text_buffer(self.textbuffer) 82 self.pack_start(self.box) 83 84 b0 = gtk.Button('Cancel') 85 b0.connect('clicked', self.cancel_edit_projects) 86 87 b1 = gtk.Button('Commit Changes') 88 b1.connect('clicked', self.commit_changes) 89 90 self.hbbox = gtk.HButtonBox() 91 self.hbbox.pack_start(b0, False, False, 1) 92 self.hbbox.pack_start(b1, False, False, 1) 93 self.pack_start(self.hbbox, False) 94 self.show_all() 95 except NotConnectedException, except_msg: 96 self.cancel_edit_projects(b)
97
98 - def SetPrinter(self,printer):
99 self.printer = printer
100
101 - def set_text_buffer(self,textbuffer):
102 self.textbuffer = textbuffer
103
104 - def reload(self,icetray):
105 self.icetray = icetray 106 self.cancel_edit_projects(None) 107
108 - def write_text_buffer(self,text):
109 if self.textbuffer: 110 self.textbuffer.set_text(text) 111 else: 112 self.printer(str(text)) 113
114 - def basic_printer(self,text):
115 print text 116
117 - def __init__(self,icetray,db):
118 # create a liststore with three int columns 119 gtk.VBox.__init__(self) 120 self.icetray = icetray 121 self.box = None 122 self.hbbox = None 123 self.edit = False 124 self.db = db 125 self.textbuffer = None 126 self.printer = self.basic_printer 127 self.cancel_edit_projects(None)
128
129 - def add_project(self, b, pjdisplay):
130 metaproject = pjdisplay.GetSelected() 131 if metaproject.GetId() > 0: 132 self.plist = GtkProjectList(metaproject,self.db,self) 133 self.plist.SetPrinter(self.printer)
134