mirror of
https://github.com/gryf/pygtktalog.git
synced 2025-12-17 19:40:21 +01:00
* Added markers for folding code.
* Added dialog for adding directory into katalog.
This commit is contained in:
82
mainwin.py
82
mainwin.py
@@ -369,7 +369,8 @@ _count=0
|
|||||||
|
|
||||||
class PyGTKtalog:
|
class PyGTKtalog:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
""" init"""
|
||||||
|
# {{{ init
|
||||||
self.conf = Config()
|
self.conf = Config()
|
||||||
self.conf.load()
|
self.conf.load()
|
||||||
|
|
||||||
@@ -425,39 +426,48 @@ class PyGTKtalog:
|
|||||||
self.window.resize(self.conf.confd['wx'],self.conf.confd['wy'])
|
self.window.resize(self.conf.confd['wx'],self.conf.confd['wy'])
|
||||||
|
|
||||||
# sygnały:
|
# sygnały:
|
||||||
dic = {"on_main_destroy_event" :self.doQuit,
|
dic = {"on_main_destroy_event" :self.doQuit,
|
||||||
"on_quit1_activate" :self.doQuit,
|
"on_quit1_activate" :self.doQuit,
|
||||||
"on_tb_quit_clicked" :self.doQuit,
|
"on_tb_quit_clicked" :self.doQuit,
|
||||||
"on_new1_activate" :self.newDB,
|
"on_new1_activate" :self.newDB,
|
||||||
"on_tb_new_clicked" :self.newDB,
|
"on_tb_new_clicked" :self.newDB,
|
||||||
"on_add_cd_activate" :self.addCD,
|
"on_add_cd_activate" :self.addCD,
|
||||||
"on_tb_addcd_clicked" :self.addCD,
|
"on_tb_addcd_clicked" :self.addCD,
|
||||||
"on_about1_activate" :self.about,
|
"on_add_directory1_activate" :self.addDirectory,
|
||||||
"on_properties1_activate":self.preferences,
|
"on_about1_activate" :self.about,
|
||||||
"on_status_bar1_activate":self.toggle_status_bar,
|
"on_properties1_activate" :self.preferences,
|
||||||
"on_toolbar1_activate" :self.toggle_toolbar,
|
"on_status_bar1_activate" :self.toggle_status_bar,
|
||||||
|
"on_toolbar1_activate" :self.toggle_toolbar,
|
||||||
}
|
}
|
||||||
|
|
||||||
# connect signals
|
# connect signals
|
||||||
self.pygtkcat.signal_autoconnect(dic)
|
self.pygtkcat.signal_autoconnect(dic)
|
||||||
self.window.connect("delete_event", self.deleteEvent)
|
self.window.connect("delete_event", self.deleteEvent)
|
||||||
|
#}}}
|
||||||
|
|
||||||
def toggle_toolbar(self,widget):
|
def toggle_toolbar(self,widget):
|
||||||
|
"""toggle visibility of toolbar bar"""
|
||||||
|
#{{{
|
||||||
self.conf.confd['showtoolbar'] = self.menu_toolbar.get_active()
|
self.conf.confd['showtoolbar'] = self.menu_toolbar.get_active()
|
||||||
if self.menu_toolbar.get_active():
|
if self.menu_toolbar.get_active():
|
||||||
self.toolbar.show()
|
self.toolbar.show()
|
||||||
else:
|
else:
|
||||||
self.toolbar.hide()
|
self.toolbar.hide()
|
||||||
|
#}}}
|
||||||
|
|
||||||
def toggle_status_bar(self,widget):
|
def toggle_status_bar(self,widget):
|
||||||
|
"""toggle visibility of statusbat and progress bar"""
|
||||||
|
#{{{
|
||||||
self.conf.confd['showstatusbar'] = self.menu_statusbar.get_active()
|
self.conf.confd['showstatusbar'] = self.menu_statusbar.get_active()
|
||||||
if self.menu_statusbar.get_active():
|
if self.menu_statusbar.get_active():
|
||||||
self.statusprogress.show()
|
self.statusprogress.show()
|
||||||
else:
|
else:
|
||||||
self.statusprogress.hide()
|
self.statusprogress.hide()
|
||||||
|
#}}}
|
||||||
|
|
||||||
def storeSettings(self):
|
def storeSettings(self):
|
||||||
"""Store window size and pane position in config file (using config object)"""
|
"""Store window size and pane position in config file (using config object)"""
|
||||||
|
#{{{
|
||||||
if self.conf.confd['savewin']:
|
if self.conf.confd['savewin']:
|
||||||
self.conf.confd['wx'], self.conf.confd['wy'] = self.window.get_size()
|
self.conf.confd['wx'], self.conf.confd['wy'] = self.window.get_size()
|
||||||
|
|
||||||
@@ -467,13 +477,17 @@ class PyGTKtalog:
|
|||||||
self.conf.confd['h'],self.conf.confd['v'] = hpan.get_position(), vpan.get_position()
|
self.conf.confd['h'],self.conf.confd['v'] = hpan.get_position(), vpan.get_position()
|
||||||
|
|
||||||
self.conf.save()
|
self.conf.save()
|
||||||
return
|
#}}}
|
||||||
|
|
||||||
def preferences(self,widget):
|
def preferences(self,widget):
|
||||||
|
"""display preferences window"""
|
||||||
|
#{{{
|
||||||
a = Preferences()
|
a = Preferences()
|
||||||
|
#}}}
|
||||||
|
|
||||||
def doQuit(self, widget):
|
def doQuit(self, widget):
|
||||||
"""quit and save window parameters to config file"""
|
"""quit and save window parameters to config file"""
|
||||||
|
#{{{
|
||||||
try:
|
try:
|
||||||
if widget.title:
|
if widget.title:
|
||||||
pass
|
pass
|
||||||
@@ -490,9 +504,11 @@ class PyGTKtalog:
|
|||||||
self.storeSettings()
|
self.storeSettings()
|
||||||
gtk.main_quit()
|
gtk.main_quit()
|
||||||
return False
|
return False
|
||||||
|
#}}}
|
||||||
|
|
||||||
def newDB(self,widget):
|
def newDB(self,widget):
|
||||||
"""create database in temporary place"""
|
"""create database in temporary place"""
|
||||||
|
#{{{
|
||||||
try:
|
try:
|
||||||
if self.unsaved_project:
|
if self.unsaved_project:
|
||||||
if self.conf.confd['confirmabandon']:
|
if self.conf.confd['confirmabandon']:
|
||||||
@@ -524,10 +540,11 @@ class PyGTKtalog:
|
|||||||
#self.detailplaceholder.add_with_viewport(self.details)
|
#self.detailplaceholder.add_with_viewport(self.details)
|
||||||
#self.details.show()
|
#self.details.show()
|
||||||
return
|
return
|
||||||
|
#}}}
|
||||||
|
|
||||||
def deleteEvent(self, widget, event, data=None):
|
def deleteEvent(self, widget, event, data=None):
|
||||||
"""checkout actual database changed. If so, do the necessary ask."""
|
"""checkout actual database changed. If so, do the necessary ask."""
|
||||||
# check if any unsaved project is on go.
|
#{{{ check if any unsaved project is on go.
|
||||||
try:
|
try:
|
||||||
if self.unsaved_project:
|
if self.unsaved_project:
|
||||||
if self.conf.confd['confirmquit']:
|
if self.conf.confd['confirmquit']:
|
||||||
@@ -538,12 +555,27 @@ class PyGTKtalog:
|
|||||||
pass
|
pass
|
||||||
self.storeSettings()
|
self.storeSettings()
|
||||||
return False
|
return False
|
||||||
|
#}}}
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
"""show window and run app"""
|
||||||
|
#{{{
|
||||||
self.window.show();
|
self.window.show();
|
||||||
gtk.main()
|
gtk.main()
|
||||||
|
#}}}
|
||||||
|
|
||||||
|
def addDirectory(self,widget):
|
||||||
|
"""add directory structure from given location"""
|
||||||
|
#{{{
|
||||||
|
obj = dialogs.PointDirectoryToAdd()
|
||||||
|
res = obj.run()
|
||||||
|
print res
|
||||||
|
self.scan(res[1])
|
||||||
|
#}}}
|
||||||
|
|
||||||
def addCD(self,widget):
|
def addCD(self,widget):
|
||||||
|
"""add directory structure from cd/dvd disc"""
|
||||||
|
#{{{
|
||||||
mount = deviceHelper.volmount(self.conf.confd['cd'])
|
mount = deviceHelper.volmount(self.conf.confd['cd'])
|
||||||
if mount == 'ok':
|
if mount == 'ok':
|
||||||
guessed_label = deviceHelper.volname(self.conf.confd['cd'])
|
guessed_label = deviceHelper.volname(self.conf.confd['cd'])
|
||||||
@@ -565,8 +597,11 @@ class PyGTKtalog:
|
|||||||
dialogs.Wrn("error unmounting device - pyGTKtalog","Cannot unmount device pointed to %s.\nLast umount message:\n<tt>%s</tt>" % (self.conf.confd['cd'],msg))
|
dialogs.Wrn("error unmounting device - pyGTKtalog","Cannot unmount device pointed to %s.\nLast umount message:\n<tt>%s</tt>" % (self.conf.confd['cd'],msg))
|
||||||
else:
|
else:
|
||||||
dialogs.Wrn("error mounting device - pyGTKtalog","Cannot mount device pointed to %s.\nLast mount message:\n<tt>%s</tt>" % (self.conf.confd['cd'],mount))
|
dialogs.Wrn("error mounting device - pyGTKtalog","Cannot mount device pointed to %s.\nLast mount message:\n<tt>%s</tt>" % (self.conf.confd['cd'],mount))
|
||||||
|
#}}}
|
||||||
|
|
||||||
def scan(self,path):
|
def scan(self,path):
|
||||||
|
"""scan content of the given path"""
|
||||||
|
#{{{
|
||||||
global _count
|
global _count
|
||||||
_count= 0
|
_count= 0
|
||||||
mime = mimetypes.MimeTypes()
|
mime = mimetypes.MimeTypes()
|
||||||
@@ -582,6 +617,8 @@ class PyGTKtalog:
|
|||||||
count = 1
|
count = 1
|
||||||
|
|
||||||
def recurse(path,name,wobj,date=0,frac=0):
|
def recurse(path,name,wobj,date=0,frac=0):
|
||||||
|
"""recursive scans the path"""
|
||||||
|
#{{{
|
||||||
global _count
|
global _count
|
||||||
|
|
||||||
walker = os.walk(path)
|
walker = os.walk(path)
|
||||||
@@ -618,6 +655,7 @@ class PyGTKtalog:
|
|||||||
f.add_member(fileObj(name=i, size=st.st_size, filetype="r", mtime=st.st_mtime))
|
f.add_member(fileObj(name=i, size=st.st_size, filetype="r", mtime=st.st_mtime))
|
||||||
|
|
||||||
return f
|
return f
|
||||||
|
#}}}
|
||||||
|
|
||||||
fileobj = recurse(path,'/',self,0,frac)
|
fileobj = recurse(path,'/',self,0,frac)
|
||||||
|
|
||||||
@@ -626,7 +664,11 @@ class PyGTKtalog:
|
|||||||
self.sbid = self.status.push(self.sbSearchCId, "Idle")
|
self.sbid = self.status.push(self.sbSearchCId, "Idle")
|
||||||
|
|
||||||
self.progress.set_fraction(0)
|
self.progress.set_fraction(0)
|
||||||
|
#}}}
|
||||||
|
|
||||||
def about(self,widget):
|
def about(self,widget):
|
||||||
|
"""simple about dialog"""
|
||||||
|
#{{{
|
||||||
dialogs.Abt("pyGTKtalog", __version__, "About", ["Roman 'gryf' Dobosz"], licence)
|
dialogs.Abt("pyGTKtalog", __version__, "About", ["Roman 'gryf' Dobosz"], licence)
|
||||||
|
#}}}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user