From: Ed Page Date: Fri, 19 Mar 2010 00:16:28 +0000 (-0500) Subject: Further cleanup X-Git-Url: http://git.maemo.org/git/?p=multilist;a=commitdiff_plain;h=12fac216db91b68c67ddad1dbd6523c10927ca73 Further cleanup --- diff --git a/src/libmultilist.py b/src/libmultilist.py index fc5956e..a9f18d1 100755 --- a/src/libmultilist.py +++ b/src/libmultilist.py @@ -69,97 +69,6 @@ class multilistclass(hildonize.get_app_class()): _user_data = os.path.join(os.path.expanduser("~"), ".%s" % constants.__app_name__) _user_settings = "%s/settings.ini" % _user_data - def on_key_press(self, widget, event, *args): - RETURN_TYPES = (gtk.keysyms.Return, gtk.keysyms.ISO_Enter, gtk.keysyms.KP_Enter) - isCtrl = bool(event.get_state() & gtk.gdk.CONTROL_MASK) - if ( - event.keyval == gtk.keysyms.F6 or - event.keyval in RETURN_TYPES and isCtrl - ): - # The "Full screen" hardware key has been pressed - if self.window_in_fullscreen: - self.window.unfullscreen () - else: - self.window.fullscreen () - return True - #elif event.keyval == gtk.keysyms.f and isCtrl: - # self._toggle_search() - # return True - elif ( - event.keyval in (gtk.keysyms.w, gtk.keysyms.q) and - event.get_state() & gtk.gdk.CONTROL_MASK - ): - self._window.destroy() - elif event.keyval == gtk.keysyms.l and event.get_state() & gtk.gdk.CONTROL_MASK: - with open(constants._user_logpath_, "r") as f: - logLines = f.xreadlines() - log = "".join(logLines) - self._clipboard.set_text(str(log)) - return True - - def on_window_state_change(self, widget, event, *args): - if event.new_window_state & gtk.gdk.WINDOW_STATE_FULLSCREEN: - self.window_in_fullscreen = True - else: - self.window_in_fullscreen = False - - def speichereAlles(self,data=None,data2=None): - logging.info("Speichere alles") - - def ladeAlles(self,data=None,data2=None): - logging.info("Lade alles") - - def beforeSync(self,data=None,data2=None): - logging.info("Lade alles") - - def sync_finished(self,data=None,data2=None): - self.selection.comboList_changed() - self.selection.comboCategory_changed() - self.liststorehandler.update_list() - - def prepare_sync_dialog(self): - self.sync_dialog = gtk.Dialog(_("Sync"),None,gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,(gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)) - - self.sync_dialog.set_position(gtk.WIN_POS_CENTER) - sync=libsync.Sync(self.db,self.window,50503) - sync.connect("syncFinished",self.sync_finished) - self.sync_dialog.vbox.pack_start(sync, True, True, 0) - self.sync_dialog.set_size_request(500,350) - self.sync_dialog.vbox.show_all() - sync.connect("syncFinished",self.sync_finished) - - def sync_notes(self,widget=None,data=None): - if self.sync_dialog==None: - self.prepare_sync_dialog() - self.sync_dialog.run() - self.sync_dialog.hide() - - def show_columns_dialog(self,widget=None,data=None): - col_dialog = gtk.Dialog(_("Choose columns"),self.window,gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)) - - col_dialog.set_position(gtk.WIN_POS_CENTER) - cols=libview.Columns_dialog(self.db,self.liststorehandler) - - col_dialog.vbox.pack_start(cols, True, True, 0) - col_dialog.set_size_request(500,350) - col_dialog.vbox.show_all() - - resp=col_dialog.run() - col_dialog.hide() - if resp==gtk.RESPONSE_ACCEPT: - logging.info("changing columns") - cols.save_column_setting() - self.view.reload_view() - #children=self.vbox.get_children() - #while len(children)>1: - # self.vbox.remove(children[1]) - - #self.vbox.pack_end(self.bottombar, expand=True, fill=True, padding=0) - #self.vbox.pack_end(view, expand=True, fill=True, padding=0) - #self.vbox.pack_end(self.selection, expand=False, fill=True, padding=0) - - col_dialog.destroy() - def __init__(self): super(multilistclass, self).__init__() self._clipboard = gtk.clipboard_get() @@ -293,6 +202,97 @@ class multilistclass(hildonize.get_app_class()): self.prepare_sync_dialog() self.ladeAlles() + def on_key_press(self, widget, event, *args): + RETURN_TYPES = (gtk.keysyms.Return, gtk.keysyms.ISO_Enter, gtk.keysyms.KP_Enter) + isCtrl = bool(event.get_state() & gtk.gdk.CONTROL_MASK) + if ( + event.keyval == gtk.keysyms.F6 or + event.keyval in RETURN_TYPES and isCtrl + ): + # The "Full screen" hardware key has been pressed + if self.window_in_fullscreen: + self.window.unfullscreen () + else: + self.window.fullscreen () + return True + #elif event.keyval == gtk.keysyms.f and isCtrl: + # self._toggle_search() + # return True + elif ( + event.keyval in (gtk.keysyms.w, gtk.keysyms.q) and + event.get_state() & gtk.gdk.CONTROL_MASK + ): + self._window.destroy() + elif event.keyval == gtk.keysyms.l and event.get_state() & gtk.gdk.CONTROL_MASK: + with open(constants._user_logpath_, "r") as f: + logLines = f.xreadlines() + log = "".join(logLines) + self._clipboard.set_text(str(log)) + return True + + def on_window_state_change(self, widget, event, *args): + if event.new_window_state & gtk.gdk.WINDOW_STATE_FULLSCREEN: + self.window_in_fullscreen = True + else: + self.window_in_fullscreen = False + + def speichereAlles(self,data=None,data2=None): + logging.info("Speichere alles") + + def ladeAlles(self,data=None,data2=None): + logging.info("Lade alles") + + def beforeSync(self,data=None,data2=None): + logging.info("Lade alles") + + def sync_finished(self,data=None,data2=None): + self.selection.comboList_changed() + self.selection.comboCategory_changed() + self.liststorehandler.update_list() + + def prepare_sync_dialog(self): + self.sync_dialog = gtk.Dialog(_("Sync"),None,gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,(gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)) + + self.sync_dialog.set_position(gtk.WIN_POS_CENTER) + sync=libsync.Sync(self.db,self.window,50503) + sync.connect("syncFinished",self.sync_finished) + self.sync_dialog.vbox.pack_start(sync, True, True, 0) + self.sync_dialog.set_size_request(500,350) + self.sync_dialog.vbox.show_all() + sync.connect("syncFinished",self.sync_finished) + + def sync_notes(self,widget=None,data=None): + if self.sync_dialog==None: + self.prepare_sync_dialog() + self.sync_dialog.run() + self.sync_dialog.hide() + + def show_columns_dialog(self,widget=None,data=None): + col_dialog = gtk.Dialog(_("Choose columns"),self.window,gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)) + + col_dialog.set_position(gtk.WIN_POS_CENTER) + cols=libview.Columns_dialog(self.db,self.liststorehandler) + + col_dialog.vbox.pack_start(cols, True, True, 0) + col_dialog.set_size_request(500,350) + col_dialog.vbox.show_all() + + resp=col_dialog.run() + col_dialog.hide() + if resp==gtk.RESPONSE_ACCEPT: + logging.info("changing columns") + cols.save_column_setting() + self.view.reload_view() + #children=self.vbox.get_children() + #while len(children)>1: + # self.vbox.remove(children[1]) + + #self.vbox.pack_end(self.bottombar, expand=True, fill=True, padding=0) + #self.vbox.pack_end(view, expand=True, fill=True, padding=0) + #self.vbox.pack_end(self.selection, expand=False, fill=True, padding=0) + + col_dialog.destroy() + def destroy(self, widget=None, data=None): try: self.speichereAlles() diff --git a/src/libselection.py b/src/libselection.py index 9ab8651..db56c04 100644 --- a/src/libselection.py +++ b/src/libselection.py @@ -1,45 +1,52 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- - + """ - This file is part of Multilist. - - Multilist is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Multilist is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Multilist. If not, see . - - Copyright (C) 2008 Christoph Würstle +This file is part of Multilist. + +Multilist is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +Multilist is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Multilist. If not, see . + +Copyright (C) 2008 Christoph Würstle """ import gobject -import time import logging import gtk +try: + _ +except NameError: + _ = lambda x: x + + +_moduleLogger = logging.getLogger(__name__) + + class Selection(gtk.HBox): - + __gsignals__ = { - 'changed' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,(gobject.TYPE_STRING,gobject.TYPE_STRING)), + 'changed' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,(gobject.TYPE_STRING,gobject.TYPE_STRING)), #'changedCategory': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,(gobject.TYPE_STRING,gobject.TYPE_STRING)) - } + } def load(self): model=self.comboList.get_model() model.clear() #self.comboList.remove(0) - - + sql="SELECT DISTINCT list FROM items ORDER BY list" rows=self.db.ladeSQL(sql) if ((rows!=None)and(len(rows)>0)): @@ -47,7 +54,7 @@ class Selection(gtk.HBox): self.comboList.append_text(row[0]) else: self.comboList.append_text("default") - + s=self.db.ladeDirekt("comboListText") if s!="": self.comboList.get_child().set_text(s) @@ -59,34 +66,32 @@ class Selection(gtk.HBox): #print "reload categories" while len(self.comboCategory.get_model())>0: self.comboCategory.remove_text(0) - + sql="SELECT DISTINCT category FROM items WHERE list=? ORDER BY category" rows=self.db.ladeSQL(sql,(self.get_list(),)) - + self.comboCategory.append_text(_("all")) if ((rows!=None)and(len(rows)>0)): for row in rows: if (row[0]!=_("all")): self.comboCategory.append_text(row[0]) - + s=self.db.ladeDirekt("comboCategoryText"+self.comboList.get_child().get_text()) if len(s)>0: self.comboCategory.get_child().set_text(s) else: self.comboCategory.set_active(0) - + self.emit("changed","list","") self.db.speichereDirekt("comboListText",self.comboList.get_child().get_text()) - - def comboCategory_changed(self, widget=None, data=None): - #logging.info("Klasse geaendert zu ") + #_moduleLogger.info("Klasse geaendert zu ") #self.hauptRegister.set_current_page(0) self.emit("changed","category","") if self.comboCategory.get_active()>-1: self.db.speichereDirekt("comboCategoryText"+self.comboList.get_child().get_text(),self.comboCategory.get_child().get_text()) - + def radioActive_changed(self, widget, data=None): self.emit("changed","radio","") @@ -111,19 +116,16 @@ class Selection(gtk.HBox): if found==False: self.comboList.append_text(self.get_list()) self.comboList.set_active(len(self.comboList.get_model())-1) - def lade(self): - logging.warning("Laden der aktuellen position noch nicht implementiert") + _moduleLogger.warning("Laden der aktuellen position noch nicht implementiert") - def speichere(self): - logging.warning("Speichern der aktuellen position noch nicht implementiert") - - + _moduleLogger.warning("Speichern der aktuellen position noch nicht implementiert") + def getIsHildon(self): return self.isHildon - + def get_category(self,select=False): s=self.comboCategory.get_child().get_text() if s==_("all"): @@ -135,57 +137,50 @@ class Selection(gtk.HBox): return s def set_category(self,category): self.comboCategory.get_child().set_text(category) - + def set_list(self,listname): self.comboList.get_child().set_text(listname) - + def get_list(self): return self.comboList.get_child().get_text() - - def get_status(self): #return self.comboCategory.get_child().get_text() if self.radio_all.get_active()==True: return "-1" else: return "0" - - + def __init__(self,db,isHildon): gtk.HBox.__init__(self,homogeneous=False, spacing=3) - + self.db=db self.isHildon=isHildon - - logging.info("libSelection, init") - - + + _moduleLogger.info("libSelection, init") + label=gtk.Label(_("List:")) self.pack_start(label, expand=False, fill=True, padding=0) - + self.comboList = gtk.combo_box_entry_new_text() self.comboList.set_size_request(180,-1) self.pack_start(self.comboList, expand=False, fill=True, padding=0) - + label=gtk.Label(_(" Category:")) self.pack_start(label, expand=False, fill=True, padding=0) - + self.comboCategory = gtk.combo_box_entry_new_text() self.comboCategory.set_size_request(180,-1) self.pack_start(self.comboCategory, expand=False, fill=True, padding=0) - + self.comboList.connect("changed", self.comboList_changed, None) self.comboCategory.connect("changed", self.comboCategory_changed, None) - + label=gtk.Label(_(" View:")) self.pack_start(label, expand=False, fill=True, padding=0) - + self.radio_all=gtk.RadioButton(group=None, label=_("All"), use_underline=True) self.pack_start(self.radio_all, expand=False, fill=True, padding=0) self.radio_active=gtk.RadioButton(group=self.radio_all, label=_("Active"), use_underline=True) self.pack_start(self.radio_active, expand=False, fill=True, padding=0) self.radio_all.connect("toggled",self.radioActive_changed, None) - - - diff --git a/src/libspeichern.py b/src/libspeichern.py index e887340..c98bae7 100644 --- a/src/libspeichern.py +++ b/src/libspeichern.py @@ -1,23 +1,23 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- - + """ - This file is part of Multilist. - - Multilist is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Multilist is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Multilist. If not, see . - - Copyright (C) 2008 Christoph Würstle +This file is part of Multilist. + +Multilist is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +Multilist is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Multilist. If not, see . + +Copyright (C) 2008 Christoph Würstle """ import time @@ -29,12 +29,45 @@ import shutil import os import logging -class Speichern(): +try: + _ +except NameError: + _ = lambda x: x + + +_moduleLogger = logging.getLogger(__name__) + + +class Speichern(object): + + def __init__(self): + home_dir = os.path.expanduser('~') + filename=os.path.join(home_dir, ".multilist.dat") + self.d = shelve.open(filename) + self.openDB() + + def close(self): + try: + self.d.close() + except: + pass + try: + self.cur.close() + except: + pass + try: + self.conn.close() + except: + pass + _moduleLogger.info("Alle Daten gespeichert") + + def __del__(self): + self.close() + def speichereDirekt(self,schluessel,daten): self.d[schluessel]=daten - logging.info("speichereDirekt "+str(schluessel)+" "+str(daten)+" lesen: "+str(self.d[schluessel])) + _moduleLogger.info("speichereDirekt "+str(schluessel)+" "+str(daten)+" lesen: "+str(self.d[schluessel])) - def ladeDirekt(self,schluessel,default=""): #print "ladeDirekt",schluessel, "Schluessel vorhanden",self.d.has_key(schluessel) if (self.d.has_key(schluessel)==True): @@ -43,8 +76,7 @@ class Speichern(): return data else: return default - - + def speichereSQL(self,sql,tupel=None,commit=True,host="self",log=True,pcdatum=None,rowid=""): #print "speichereSQL:",sql,tupel try: @@ -53,8 +85,8 @@ class Speichern(): self.cur.execute(sql) else: self.cur.execute(sql,tupel) - programSQLError=False - + programSQLError=False + #print int(time.time()), sql, pickle.dumps(tupel), host if (log==True): strtupel=[] @@ -62,26 +94,24 @@ class Speichern(): for t in tupel: strtupel.append(str(t)) - if pcdatum==None: pcdatum=int(time.time()) self.cur.execute("INSERT INTO logtable ( pcdatum,sql,param,host,rowid ) VALUES (?,?,?,?,?)",(pcdatum, sql, string.join(strtupel," <> "), host,str(rowid) )) - if (commit==True): self.conn.commit() - + if (commit==True): + self.conn.commit() return True except: s=str(sys.exc_info()) if (s.find(" already exists")==-1): #if len(s)>0: if (programSQLError==True): - logging.error("speichereSQL-Exception "+str(sys.exc_info())+" "+str(sql)+" "+str(tupel)) + _moduleLogger.error("speichereSQL-Exception "+str(sys.exc_info())+" "+str(sql)+" "+str(tupel)) else: - logging.error("speichereSQL-Exception in Logging!!!! :"+str(sys.exc_info())+" "+str(sql)+" "+str(tupel)) + _moduleLogger.error("speichereSQL-Exception in Logging!!!! :"+str(sys.exc_info())+" "+str(sql)+" "+str(tupel)) return False def commitSQL(self): self.conn.commit() - - + def ladeSQL(self,sql,tupel=None): #print sql,tupel try: @@ -91,9 +121,9 @@ class Speichern(): self.cur.execute(sql,tupel) return self.cur.fetchall() except: - logging.error("ladeSQL-Exception "+str(sys.exc_info())+" "+str(sql)+" "+str(tupel)) + _moduleLogger.error("ladeSQL-Exception "+str(sys.exc_info())+" "+str(sql)+" "+str(tupel)) return () - + def ladeHistory(self,sql_condition,param_condition): sql="SELECT * FROM logtable WHERE sql LIKE '%"+str(sql_condition)+"%' AND param LIKE '%"+str(param_condition)+"%'" rows=self.ladeSQL(sql) @@ -104,21 +134,21 @@ class Speichern(): datum=time.strftime("%d.%m.%y %H:%M:%S", (time.localtime(rows[i][1]))) erg.append([rows[i][1],datum,rows[i][2],rows[i][3],rows[i][3].split(" <> ")]) #pcdatum #datum #sql # Param_org #param - + i+=1 - + return erg - + def delHistory(self,sql_condition,param_condition,exceptTheLastXSeconds=0): pcdatum=int(time.time())-exceptTheLastXSeconds sql="DELETE FROM logtable WHERE sql LIKE '%"+str(sql_condition)+"%' AND param LIKE '%"+str(param_condition)+"%' AND pcdatum. - - Copyright (C) 2008 Christoph Würstle +This file is part of Multilist. + +Multilist is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +Multilist is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Multilist. If not, see . + +Copyright (C) 2008 Christoph Würstle """ -import gobject import time -import string import gtk -import sys import logging -import libspeichern - - + +try: + _ +except NameError: + _ = lambda x: x + + +_moduleLogger = logging.getLogger(__name__) + + class sqlDialog(gtk.Dialog): - - def exportSQL(self,filename): - f = open(filename, 'w') - msgstring="" - sql="SELECT pcdatum,sql,param FROM logtable WHERE pcdatum>? ORDER BY pcdatum DESC" - rows=self.db.ladeSQL(sql,(time.time()-2*24*3600,)) - for row in rows: - pcdatum,sql,param = row - datum=str(time.strftime("%d.%m.%y %H:%M:%S ", (time.localtime(pcdatum)))) - f.write( datum +"\t" + sql + "\t\t" + param+ "\n") - - - f.close() - - + def __init__(self,db): self.db=db - - logging.info("sqldialog, init") - + + _moduleLogger.info("sqldialog, init") + gtk.Dialog.__init__(self,_("SQL History (the past two days):"),None,gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,(gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)) - - + self.add_button(_("Export"), 444) - self.set_position(gtk.WIN_POS_CENTER) - - + self.set_position(gtk.WIN_POS_CENTER) + self.liststore = gtk.ListStore(str, str, str) - # create the TreeView using liststore - self.treeview = gtk.TreeView(self.liststore) - + # create the TreeView using liststore + self.treeview = gtk.TreeView(self.liststore) + # create a CellRenderers to render the data - self.cell1 = gtk.CellRendererText() - self.cell2 = gtk.CellRendererText() + self.cell1 = gtk.CellRendererText() + self.cell2 = gtk.CellRendererText() self.cell3 = gtk.CellRendererText() #self.cell1.set_property('markup', 1) - - # create the TreeViewColumns to display the data - self.tvcolumn1 = gtk.TreeViewColumn(_('Date')) - self.tvcolumn2 = gtk.TreeViewColumn(_('SQL')) + + # create the TreeViewColumns to display the data + self.tvcolumn1 = gtk.TreeViewColumn(_('Date')) + self.tvcolumn2 = gtk.TreeViewColumn(_('SQL')) self.tvcolumn3 = gtk.TreeViewColumn(_('Parameter')) - - # add columns to treeview - self.treeview.append_column(self.tvcolumn1) - self.treeview.append_column(self.tvcolumn2) + + # add columns to treeview + self.treeview.append_column(self.tvcolumn1) + self.treeview.append_column(self.tvcolumn2) self.treeview.append_column(self.tvcolumn3) - - + self.tvcolumn1.pack_start(self.cell1, True) - self.tvcolumn2.pack_start(self.cell2, True) + self.tvcolumn2.pack_start(self.cell2, True) self.tvcolumn3.pack_start(self.cell3, True) - + self.tvcolumn1.set_attributes(self.cell1, text=0) #Spalten setzten hier!!!! self.tvcolumn2.set_attributes(self.cell2, text=1) self.tvcolumn3.set_attributes(self.cell3, text=2) - # make treeview searchable - #self.treeview.set_search_column(0) + # make treeview searchable + #self.treeview.set_search_column(0) #self.tvcolumn.set_sort_column_id(0) - + # Allow NOT drag and drop reordering of rows - self.treeview.set_reorderable(False) - + self.treeview.set_reorderable(False) + scrolled_window = gtk.ScrolledWindow() scrolled_window.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC) scrolled_window.add(self.treeview) #self.pack_start(scrolled_window, expand=True, fill=True, padding=0) - - + self.vbox.pack_start(scrolled_window, True, True, 0) - - self.vbox.show_all() - + + self.vbox.show_all() + msgstring="" sql="SELECT pcdatum,sql,param FROM logtable WHERE pcdatum>? ORDER BY pcdatum DESC" rows=db.ladeSQL(sql,(time.time()-3*24*3600,)) @@ -118,8 +104,17 @@ class sqlDialog(gtk.Dialog): i+=1 if (i>50): break - + self.set_size_request(500,400) - - - + + def exportSQL(self,filename): + f = open(filename, 'w') + msgstring="" + sql="SELECT pcdatum,sql,param FROM logtable WHERE pcdatum>? ORDER BY pcdatum DESC" + rows=self.db.ladeSQL(sql,(time.time()-2*24*3600,)) + for row in rows: + pcdatum,sql,param = row + datum=str(time.strftime("%d.%m.%y %H:%M:%S ", (time.localtime(pcdatum)))) + f.write( datum +"\t" + sql + "\t\t" + param+ "\n") + + f.close() diff --git a/src/libsync.py b/src/libsync.py index a793a16..be26474 100755 --- a/src/libsync.py +++ b/src/libsync.py @@ -2,101 +2,187 @@ # -*- coding: utf-8 -*- """ - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . """ -import gobject -import time -import string -from SimpleXMLRPCServer import SimpleXMLRPCServer -import random -import socket -socket.setdefaulttimeout(60) # Timeout auf 60 sec. setzen -import xmlrpclib +import sys import select -#import fcntl -import struct -import gtk import uuid -import sys +import time +import string +from SimpleXMLRPCServer import SimpleXMLRPCServer +import socket +import xmlrpclib import logging -import libspeichern - - +import gobject +import gtk + + +try: + _ +except NameError: + _ = lambda x: x + + +_moduleLogger = logging.getLogger(__name__) +socket.setdefaulttimeout(60) # Timeout auf 60 sec. setzen + + class ProgressDialog(gtk.Dialog): - - def pulse(self): - #self.progressbar.pulse() - pass - + def __init__(self,title=_("Sync process"), parent=None): gtk.Dialog.__init__(self,title,parent,gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,()) - - logging.info("ProgressDialog, init") - + + _moduleLogger.info("ProgressDialog, init") + label=gtk.Label(_("Sync process running...please wait")) self.vbox.pack_start(label, True, True, 0) label=gtk.Label(_("(this can take some minutes)")) self.vbox.pack_start(label, True, True, 0) - + #self.progressbar=gtk.ProgressBar() #self.vbox.pack_start(self.progressbar, True, True, 0) - + #self.set_keep_above(True) - self.vbox.show_all() + self.vbox.show_all() self.show() - -class Sync(gtk.VBox): - + + def pulse(self): + #self.progressbar.pulse() + pass + + +class Sync(gtk.VBox): + __gsignals__ = { - 'syncFinished' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,(gobject.TYPE_STRING,)), + 'syncFinished' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,(gobject.TYPE_STRING,)), 'syncBeforeStart' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,(gobject.TYPE_STRING,)), - } - + } + + def __init__(self,db,parentwindow,port): + gtk.VBox.__init__(self,homogeneous=False, spacing=0) + + _moduleLogger.info("Sync, init") + self.db=db + self.progress=None + self.server=None + self.port=int(port) + self.parentwindow=parentwindow + self.concernedRows=None + + #print "Sync, 2" + #sql = "DROP TABLE sync" + #self.db.speichereSQL(sql,log=False) + + sql = "CREATE TABLE sync (id INTEGER PRIMARY KEY, syncpartner TEXT, uuid TEXT, pcdatum INTEGER)" + self.db.speichereSQL(sql,log=False) + + #print "Sync, 3" + + sql="SELECT uuid,pcdatum FROM sync WHERE syncpartner=?" + rows=self.db.ladeSQL(sql,("self",)) #Eigene Id feststellen + + #print "Sync, 3a" + if (rows==None)or(len(rows)!=1): + sql="DELETE FROM sync WHERE syncpartner=?" + self.db.speichereSQL(sql,("self",),log=False) + + #uuid1=uuid() + #print "Sync, 3b" + + #print "Sync, 3bb" + self.sync_uuid=str(uuid.uuid4()) + sql="INSERT INTO sync (syncpartner,uuid,pcdatum) VALUES (?,?,?)" + self.db.speichereSQL(sql,("self",str(self.sync_uuid),int(time.time())),log=False) + #print "Sync, 3c" + else: + sync_uuid,pcdatum = rows[0] + self.sync_uuid=sync_uuid + #print "x1" + #print "Sync, 4" + + frame=gtk.Frame(_("Local SyncServer (port ")+str(self.port)+")") + self.comboIP=gtk.combo_box_entry_new_text() + self.comboIP.append_text("") #self.get_ip_address("eth0")) + #self.comboIP.append_text(self.get_ip_address("eth1")) #fixme + #self.comboIP.append_text(self.get_ip_address("eth2")) + #self.comboIP.append_text(self.get_ip_address("eth3")) + #print "Sync, 4d" + #self.comboIP.append_text(self.get_ip_address("wlan0")) + #self.comboIP.append_text(self.get_ip_address("wlan1")) + + #print "Sync, 4e" + + frame.add(self.comboIP) + serverbutton=gtk.ToggleButton(_("Start SyncServer")) + serverbutton.connect("clicked",self.startServer,(None,)) + self.pack_start(frame, expand=False, fill=True, padding=1) + self.pack_start(serverbutton, expand=False, fill=True, padding=1) + self.syncServerStatusLabel=gtk.Label(_("Syncserver not running")) + self.pack_start(self.syncServerStatusLabel, expand=False, fill=True, padding=1) + + frame=gtk.Frame(_("RemoteSync-Server (Port ")+str(self.port)+")") + self.comboRemoteIP=gtk.combo_box_entry_new_text() + self.comboRemoteIP.append_text("192.168.0.?") + self.comboRemoteIP.append_text("192.168.1.?") + self.comboRemoteIP.append_text("192.168.176.?") + frame.add(self.comboRemoteIP) + syncbutton=gtk.Button(_("Connect to remote SyncServer")) + syncbutton.connect("clicked",self.syncButton,(None,)) + self.pack_start(frame, expand=False, fill=True, padding=1) + self.pack_start(syncbutton, expand=False, fill=True, padding=1) + self.syncStatusLabel=gtk.Label(_("no sync process (at the moment)")) + self.pack_start(self.syncStatusLabel, expand=False, fill=True, padding=1) + + #self.comboRemoteIP.set_text_column("Test") + self.comboRemoteIP.get_child().set_text(self.db.ladeDirekt("syncRemoteIP")) + self.comboIP.get_child().set_text(self.db.ladeDirekt("syncServerIP")) + + #load + if (self.db.ladeDirekt("startSyncServer",False)==True): + serverbutton.set_active(True) + def changeSyncStatus(self,active,title): self.syncStatusLabel.set_text(title) if active==True: if self.progress==None: self.progress=ProgressDialog(parent=self.parentwindow) self.emit("syncBeforeStart","syncBeforeStart") - - else: if self.progress!=None: - self.progress.hide() + self.progress.hide() self.progress.destroy() self.progress=None self.emit("syncFinished","syncFinished") - + def pulse(self): if self.progress!=None: self.progress.pulse() #if self.server!=None: # self.server.pulse() - - + def getUeberblickBox(self): frame=gtk.Frame(_("Query")) return frame - + def handleRPC(self): try: if (self.rpcserver==None): return False except: return False - + while (len(self.poll.poll(0))>0): self.rpcserver.handle_request() return True @@ -110,54 +196,52 @@ class Sync(gtk.VBox): #except: # ip=socket.gethostbyname(socket.gethostname()) # s.close() - + #return ip FixME - + def getLastSyncDate(self,sync_uuid): sql="SELECT syncpartner,pcdatum FROM sync WHERE uuid=?" rows=self.db.ladeSQL(sql,(sync_uuid,)) - if (rows!=None)and(len(rows)==1): + if (rows!=None)and(len(rows)==1): syncpartner,pcdatum = rows[0] else: pcdatum=-1 - logging.info("LastSyncDatum: "+str(pcdatum)+" Jetzt "+str(int(time.time()))) + _moduleLogger.info("LastSyncDatum: "+str(pcdatum)+" Jetzt "+str(int(time.time()))) return pcdatum - - + def check4commit(self,newSQL,lastdate): - logging.info("check4commit 1") + _moduleLogger.info("check4commit 1") if self.concernedRows==None: - logging.info("check4commit Updatung concernedRows") + _moduleLogger.info("check4commit Updatung concernedRows") sql="SELECT pcdatum,rowid FROM logtable WHERE pcdatum>? ORDER BY pcdatum DESC" self.concernedRows=self.db.ladeSQL(sql,(lastdate,)) - - + if (self.concernedRows!=None)and(len(self.concernedRows)>0): - #logging.info("check4commit 2") + #_moduleLogger.info("check4commit 2") id1, pcdatum,sql, param, host, rowid = newSQL - + if len(rowid)>0: for x in self.concernedRows: - #logging.info("check4commit 3") + #_moduleLogger.info("check4commit 3") if (x[1]==rowid): if (x[0]>pcdatum): - logging.info("newer sync entry, ignoring old one") - #logging.info("check4commit 9.1") + _moduleLogger.info("newer sync entry, ignoring old one") + #_moduleLogger.info("check4commit 9.1") return False else: - #logging.info("check4commit 9.2") + #_moduleLogger.info("check4commit 9.2") return True - - #logging.info("check4commit 9.3") + + #_moduleLogger.info("check4commit 9.3") return True - + def writeSQLTupel(self,newSQLs,lastdate): if (newSQLs==None): return - + self.concernedRows=None pausenzaehler=0 - logging.info("writeSQLTupel got "+str(len(newSQLs))+" sql tupels") + _moduleLogger.info("writeSQLTupel got "+str(len(newSQLs))+" sql tupels") for newSQL in newSQLs: #print "" #print "SQL1: ",newSQL[1] @@ -169,68 +253,66 @@ class Sync(gtk.VBox): param=string.split(newSQL[3]," <> ") else: param=None - + if (len(newSQL)>2): commitSQL=True if (newSQL[5]!=None)and(len(newSQL[5])>0): commitSQL=self.check4commit(newSQL,lastdate) - + if (commitSQL==True): self.db.speichereSQL(newSQL[2],param,commit=False,pcdatum=newSQL[1],rowid=newSQL[5]) - else: - logging.error("writeSQLTupel: Error") - + else: + _moduleLogger.error("writeSQLTupel: Error") + pausenzaehler+=1 if (pausenzaehler % 10)==0: self.pulse() while (gtk.events_pending()): - gtk.main_iteration(); - - logging.info("Alle SQLs an sqlite geschickt, commiting now") + gtk.main_iteration(); + + _moduleLogger.info("Alle SQLs an sqlite geschickt, commiting now") self.db.commitSQL() - logging.info("Alle SQLs commited") - - + _moduleLogger.info("Alle SQLs commited") + def doSync(self,sync_uuid,pcdatum,newSQLs,pcdatumjetzt): #print uuid,pcdatum,newSQLs - #logging.info("doSync 0") + #_moduleLogger.info("doSync 0") self.changeSyncStatus(True,_("sync process running")) self.pulse() - #logging.info("doSync 1") - + #_moduleLogger.info("doSync 1") + while (gtk.events_pending()): - gtk.main_iteration(); + gtk.main_iteration(); diff=time.time()-pcdatumjetzt if diff<0: diff=diff*(-1) if diff>30: return -1 - - logging.info("doSync read sqls") + + _moduleLogger.info("doSync read sqls") sql="SELECT * FROM logtable WHERE pcdatum>?" rows=self.db.ladeSQL(sql,(pcdatum,)) - logging.info("doSync read sqls") + _moduleLogger.info("doSync read sqls") self.writeSQLTupel(newSQLs,pcdatum) - logging.info("doSync wrote "+str(len(newSQLs))+" sqls") - logging.info("doSync sending "+str(len(rows))+" sqls") + _moduleLogger.info("doSync wrote "+str(len(newSQLs))+" sqls") + _moduleLogger.info("doSync sending "+str(len(rows))+" sqls") i=0 return rows - + def getRemoteSyncUUID(self): return self.sync_uuid - - + def startServer(self, widget, data=None): #Starte RPCServer self.db.speichereDirekt("syncServerIP",self.comboIP.get_child().get_text()) - + if (widget.get_active()==True): - logging.info("Starting Server") - + _moduleLogger.info("Starting Server") + try: ip=self.comboIP.get_child().get_text() - self.rpcserver = SimpleXMLRPCServer((ip, self.port),allow_none=True) + self.rpcserver = SimpleXMLRPCServer((ip, self.port),allow_none=True) self.rpcserver.register_function(pow) self.rpcserver.register_function(self.getLastSyncDate) self.rpcserver.register_function(self.doSync) @@ -241,37 +323,36 @@ class Sync(gtk.VBox): self.poll.register(self.rpcserver.fileno()) gobject.timeout_add(1000, self.handleRPC) self.syncServerStatusLabel.set_text(_("Syncserver running...")) - + #save self.db.speichereDirekt("startSyncServer",True) - + except: s=str(sys.exc_info()) - logging.error("libsync: could not start server. Error: "+s) + _moduleLogger.error("libsync: could not start server. Error: "+s) mbox=gtk.MessageDialog(None,gtk.DIALOG_MODAL,gtk.MESSAGE_ERROR,gtk.BUTTONS_OK,_("Sync server could not start. Please check IP and port.")) #gtk.DIALOG_MODAL mbox.set_modal(False) - response=mbox.run() - mbox.hide() - mbox.destroy() + response=mbox.run() + mbox.hide() + mbox.destroy() widget.set_active(False) - else: - logging.info("Stopping Server") + _moduleLogger.info("Stopping Server") try: - del self.rpcserver + del self.rpcserver except: pass self.syncServerStatusLabel.set_text(_("Syncserver not running...")) #save self.db.speichereDirekt("startSyncServer",False) - + def doSaveFinalTime(self,sync_uuid,pcdatum=None): if (pcdatum==None): pcdatum=int(time.time()) if (time.time()>pcdatum): pcdatum=int(time.time()) #größere Zeit nehmen - + self.pulse() - + #fime save time+uuid sql="DELETE FROM sync WHERE uuid=?" self.db.speichereSQL(sql,(sync_uuid,),log=False) @@ -280,157 +361,58 @@ class Sync(gtk.VBox): self.pulse() self.changeSyncStatus(False,_("no sync process (at the moment)")) return (self.sync_uuid,pcdatum) - - + def syncButton(self, widget, data=None): - logging.info("Syncing") + _moduleLogger.info("Syncing") #sql="DELETE FROM logtable WHERE sql LIKE externeStundenplanung" #self.db.speichereSQL(sql) - + self.changeSyncStatus(True,_("sync process running")) while (gtk.events_pending()): - gtk.main_iteration(); + gtk.main_iteration(); self.db.speichereDirekt("syncRemoteIP",self.comboRemoteIP.get_child().get_text()) try: - self.server = xmlrpclib.ServerProxy("http://"+self.comboRemoteIP.get_child().get_text()+":"+str(self.port),allow_none=True) + self.server = xmlrpclib.ServerProxy("http://"+self.comboRemoteIP.get_child().get_text()+":"+str(self.port),allow_none=True) #lastDate=server.getLastSyncDate(str(self.sync_uuid)) server_sync_uuid=self.server.getRemoteSyncUUID() lastDate=self.getLastSyncDate(str(server_sync_uuid)) - + #print ("LastSyncDate: "+str(lastDate)+" Now: "+str(int(time.time()))) - + sql="SELECT * FROM logtable WHERE pcdatum>?" rows=self.db.ladeSQL(sql,(lastDate,)) - - logging.info("loaded concerned rows") - + + _moduleLogger.info("loaded concerned rows") + newSQLs=self.server.doSync(self.sync_uuid,lastDate,rows,time.time()) - - logging.info("did do sync, processing sqls now") + + _moduleLogger.info("did do sync, processing sqls now") if newSQLs!=-1: self.writeSQLTupel(newSQLs,lastDate) - + sync_uuid, finalpcdatum=self.server.doSaveFinalTime(self.sync_uuid) self.doSaveFinalTime(sync_uuid, finalpcdatum) - + self.changeSyncStatus(False,_("no sync process (at the moment)")) - + mbox = gtk.MessageDialog(None,gtk.DIALOG_MODAL,gtk.MESSAGE_INFO,gtk.BUTTONS_OK,_("Synchronization successfully completed")) - response = mbox.run() - mbox.hide() - mbox.destroy() + response = mbox.run() + mbox.hide() + mbox.destroy() else: - logging.warning("Zeitdiff zu groß/oder anderer db-Fehler") + _moduleLogger.warning("Zeitdiff zu groß/oder anderer db-Fehler") self.changeSyncStatus(False,_("no sync process (at the moment)")) mbox = gtk.MessageDialog(None,gtk.DIALOG_MODAL,gtk.MESSAGE_INFO,gtk.BUTTONS_OK,_("The clocks are not synchronized between stations")) - response = mbox.run() - mbox.hide() - mbox.destroy() + response = mbox.run() + mbox.hide() + mbox.destroy() except: - logging.warning("Sync connect failed") + _moduleLogger.warning("Sync connect failed") self.changeSyncStatus(False,_("no sync process (at the moment)")) mbox = gtk.MessageDialog(None,gtk.DIALOG_MODAL,gtk.MESSAGE_INFO,gtk.BUTTONS_OK,_("Sync failed, reason: ")+unicode(sys.exc_info()[1][1])) - response = mbox.run() - mbox.hide() - mbox.destroy() + response = mbox.run() + mbox.hide() + mbox.destroy() self.server=None self.server=None - - - - - def __init__(self,db,parentwindow,port): - gtk.VBox.__init__(self,homogeneous=False, spacing=0) - - logging.info("Sync, init") - self.db=db - self.progress=None - self.server=None - self.port=int(port) - self.parentwindow=parentwindow - self.concernedRows=None - - #print "Sync, 2" - #sql = "DROP TABLE sync" - #self.db.speichereSQL(sql,log=False) - - sql = "CREATE TABLE sync (id INTEGER PRIMARY KEY, syncpartner TEXT, uuid TEXT, pcdatum INTEGER)" - self.db.speichereSQL(sql,log=False) - - #print "Sync, 3" - - sql="SELECT uuid,pcdatum FROM sync WHERE syncpartner=?" - rows=self.db.ladeSQL(sql,("self",)) #Eigene Id feststellen - - #print "Sync, 3a" - if (rows==None)or(len(rows)!=1): - sql="DELETE FROM sync WHERE syncpartner=?" - self.db.speichereSQL(sql,("self",),log=False) - - #uuid1=uuid() - #print "Sync, 3b" - - #print "Sync, 3bb" - self.sync_uuid=str(uuid.uuid4()) - sql="INSERT INTO sync (syncpartner,uuid,pcdatum) VALUES (?,?,?)" - self.db.speichereSQL(sql,("self",str(self.sync_uuid),int(time.time())),log=False) - #print "Sync, 3c" - else: - sync_uuid,pcdatum = rows[0] - self.sync_uuid=sync_uuid - #print "x1" - - - - #print "Sync, 4" - - - frame=gtk.Frame(_("Local SyncServer (port ")+str(self.port)+")") - - - - self.comboIP=gtk.combo_box_entry_new_text() - - - self.comboIP.append_text("") #self.get_ip_address("eth0")) - #self.comboIP.append_text(self.get_ip_address("eth1")) #fixme - #self.comboIP.append_text(self.get_ip_address("eth2")) - #self.comboIP.append_text(self.get_ip_address("eth3")) - #print "Sync, 4d" - #self.comboIP.append_text(self.get_ip_address("wlan0")) - #self.comboIP.append_text(self.get_ip_address("wlan1")) - - #print "Sync, 4e" - - frame.add(self.comboIP) - serverbutton=gtk.ToggleButton(_("Start SyncServer")) - serverbutton.connect("clicked",self.startServer,(None,)) - self.pack_start(frame, expand=False, fill=True, padding=1) - self.pack_start(serverbutton, expand=False, fill=True, padding=1) - self.syncServerStatusLabel=gtk.Label(_("Syncserver not running")) - self.pack_start(self.syncServerStatusLabel, expand=False, fill=True, padding=1) - - frame=gtk.Frame(_("RemoteSync-Server (Port ")+str(self.port)+")") - self.comboRemoteIP=gtk.combo_box_entry_new_text() - self.comboRemoteIP.append_text("192.168.0.?") - self.comboRemoteIP.append_text("192.168.1.?") - self.comboRemoteIP.append_text("192.168.176.?") - frame.add(self.comboRemoteIP) - syncbutton=gtk.Button(_("Connect to remote SyncServer")) - syncbutton.connect("clicked",self.syncButton,(None,)) - self.pack_start(frame, expand=False, fill=True, padding=1) - self.pack_start(syncbutton, expand=False, fill=True, padding=1) - self.syncStatusLabel=gtk.Label(_("no sync process (at the moment)")) - self.pack_start(self.syncStatusLabel, expand=False, fill=True, padding=1) - - - #self.comboRemoteIP.set_text_column("Test") - self.comboRemoteIP.get_child().set_text(self.db.ladeDirekt("syncRemoteIP")) - self.comboIP.get_child().set_text(self.db.ladeDirekt("syncServerIP")) - - #load - if (self.db.ladeDirekt("startSyncServer",False)==True): - serverbutton.set_active(True) - - #print "Sync, 9" diff --git a/src/libview.py b/src/libview.py index 481464c..db42d31 100644 --- a/src/libview.py +++ b/src/libview.py @@ -1,115 +1,114 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- - + """ - This file is part of Multilist. - - Multilist is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Multilist is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Multilist. If not, see . - - Copyright (C) 2008 Christoph Würstle +This file is part of Multilist. + +Multilist is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +Multilist is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Multilist. If not, see . + +Copyright (C) 2008 Christoph Würstle """ - + import gtk import gobject import logging import pango -import libliststorehandler - + + +try: + _ +except NameError: + _ = lambda x: x + + +_moduleLogger = logging.getLogger(__name__) + class Columns_dialog(gtk.VBox): - - def is_col_selected(self, icol): - children=self.framebox.get_children() - if icol5: default="0" else: @@ -466,7 +485,6 @@ class View(gtk.VBox): self.tvcolumn[i] = gtk.TreeViewColumn(self.liststorehandler.get_colname(i),self.cell[i]) self.cell[i].connect( 'status_changed', self.col_toggled) self.tvcolumn[i].set_attributes( self.cell[i], status=i) - elif (i==3)or(i==4)or(i==6): self.cell[i] = gtk.CellRendererCombo() self.tvcolumn[i] = gtk.TreeViewColumn(self.liststorehandler.get_colname(i),self.cell[i]) @@ -480,84 +498,28 @@ class View(gtk.VBox): self.tvcolumn[i] = gtk.TreeViewColumn(self.liststorehandler.get_colname(i),self.cell[i]) self.cell[i].set_property('editable',True) self.cell[i].set_property('editable-set',True) - self.cell[i].connect("edited", self.col_edited,i) + self.cell[i].connect("edited", self.col_edited,i) #self.cell[i].connect("editing-canceled", self.col_edited2,i) self.tvcolumn[i].set_attributes(self.cell[i], text=i) self.cell[i].set_property('cell-background', 'lightgray') self.tvcolumn[i].set_sort_column_id(i) self.tvcolumn[i].set_resizable(True) - - + if (i>0): - self.treeview.append_column(self.tvcolumn[i]) - - - # Allow NOT drag and drop reordering of rows - self.treeview.set_reorderable(False) - - + self.treeview.append_column(self.tvcolumn[i]) + + # Allow NOT drag and drop reordering of rows + self.treeview.set_reorderable(False) + if self.scrolled_window != None: self.scrolled_window.destroy() - + self.scrolled_window = gtk.ScrolledWindow() self.scrolled_window.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC) self.scrolled_window.add(self.treeview) self.pack_start(self.scrolled_window, expand=True, fill=True, padding=0) self.loadList() - - self.show_all() - - def __init__(self,db,liststorehandler,parent_window): - - self.db=db - self.parent_window=parent_window - self.liststorehandler = liststorehandler - - - gtk.VBox.__init__(self,homogeneous=False, spacing=0) - - logging.info("libview, init") - - self.scrolled_window = None - self.reload_view() - - - - - - """ - bearbeitenFrame=gtk.Frame("Verteilung kopieren nach") - bearbeitenvBox=gtk.VBox(homogeneous=False, spacing=0) - - bearbeitenhBox=gtk.HBox(homogeneous=False, spacing=0) - self.comboKlassen = gtk.combo_box_new_text() - bearbeitenhBox.pack_start(self.comboKlassen, expand=False, fill=True, padding=0) - button=gtk.Button("Kopieren") - button.connect("clicked", self.kopiereStoffverteilung, None) - bearbeitenhBox.pack_start(button, expand=False, fill=True, padding=0) - - label=gtk.Label(" ") - bearbeitenhBox.pack_start(label, expand=False, fill=True, padding=0) - - button=gtk.Button("Export in CSV-Datei") - button.connect("clicked", self.exportStoffverteilung, None) - bearbeitenhBox.pack_start(button, expand=False, fill=True, padding=0) - - bearbeitenvBox.pack_start(bearbeitenhBox, expand=False, fill=True, padding=0) - - - bearbeitenFrame.add(bearbeitenvBox) - self.pack_start(bearbeitenFrame, expand=False, fill=True, padding=0) - """ - - #self.connect("unmap", self.speichere) - #self.connect("map", self.ladeWirklich) - - #self.show_all() - - - - #print "libstoffverteilung 9: ",time.clock() + self.show_all()