diff --git a/pygtktalog.py b/pygtktalog.py index 94ba096..0fa1554 100644 --- a/pygtktalog.py +++ b/pygtktalog.py @@ -1,18 +1,40 @@ # This Python file uses the following encoding: utf-8 +# +# Author: Roman 'gryf' Dobosz gryf@elysium.pl +# +# Copyright (C) 2007 by Roman 'gryf' Dobosz +# +# This file is part of pyGTKtalog. +# +# 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 2 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, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# ------------------------------------------------------------------------- + +import gtk def setup_path(): - """Sets up the python include paths to include src""" - import os.path - import sys - - if sys.argv[0]: - top_dir = os.path.dirname(os.path.abspath(sys.argv[0])) - sys.path = [os.path.join(top_dir, "src")] + sys.path - pass + """Sets up the python include paths to include needed directories""" + import os.path; import sys + from src.utils.globals import TOPDIR + sys.path = [os.path.join(TOPDIR, "src")] + sys.path return -if __name__ == "__main__": - setup_path() + +def check_requirements(): + """Checks versions and other requirements""" + import gtkmvc; gtkmvc.require("1.2.0") import sys import os @@ -20,7 +42,7 @@ if __name__ == "__main__": try: from models.m_config import ConfigModel except: - print "Some fundamental files are missing. try runnig pyGTKtalog in his root directory" + print "Some fundamental files are missing. Try runnig pyGTKtalog in his root directory" sys.exit(1) conf = ConfigModel() @@ -37,10 +59,7 @@ if __name__ == "__main__": import gtk import gtk.glade except: - print "You need to install pyGTK or GTKv2 ", - print "or set your PYTHONPATH correctly." - print "try: export PYTHONPATH=", - print "/usr/local/lib/python2.2/site-packages/" + print "You need to install pyGTK v2.10.x or newer.", sys.exit(1) try: @@ -67,14 +86,25 @@ if __name__ == "__main__": except: print "You'll need Python Imaging Library (PIL), if you want to make thumbnails" sys.exit(1) - + return + +def get_parameters(): + """Determine application command line options, return db full pathname""" + import sys, os + # if we've got two arguments, shell script passed through command line + # options: current path and probably filename of compressed db + if len(sys.argv) > 2: + return os.path.join(sys.argv[1],sys.argv[2]) + return False + +def main(*args, **kargs): from models.m_main import MainModel - from controllers.c_main import MainController + from ctrls.c_main import MainController from views.v_main import MainView m = MainModel() - if len(sys.argv) > 2: - m.open(os.path.join(sys.argv[1],sys.argv[2])) + if args and args[0]: + m.open(args[0]) c = MainController(m) v = MainView(c) @@ -86,3 +116,10 @@ if __name__ == "__main__": m.cleanup() gtk.main_quit pass + return + +if __name__ == "__main__": + setup_path() + check_requirements() + main(get_parameters()) + pass diff --git a/src/__init__.py b/src/__init__.py index 8349638..5e9f6f7 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -1,3 +1,25 @@ +# This Python file uses the following encoding: utf-8 +# +# Author: Roman 'gryf' Dobosz gryf@elysium.pl +# +# Copyright (C) 2007 by Roman 'gryf' Dobosz +# +# This file is part of pyGTKtalog. +# +# 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 2 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, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# ------------------------------------------------------------------------- -__all__ = ["models", "views", "controllers", "utils"] diff --git a/src/ctrls/__init__.py b/src/ctrls/__init__.py index e69de29..5e9f6f7 100644 --- a/src/ctrls/__init__.py +++ b/src/ctrls/__init__.py @@ -0,0 +1,25 @@ +# This Python file uses the following encoding: utf-8 +# +# Author: Roman 'gryf' Dobosz gryf@elysium.pl +# +# Copyright (C) 2007 by Roman 'gryf' Dobosz +# +# This file is part of pyGTKtalog. +# +# 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 2 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, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# ------------------------------------------------------------------------- + + diff --git a/src/ctrls/c_config.py b/src/ctrls/c_config.py index 1f6d075..388a67e 100644 --- a/src/ctrls/c_config.py +++ b/src/ctrls/c_config.py @@ -1,6 +1,26 @@ # This Python file uses the following encoding: utf-8 -import utils._importer -import utils.globals +# +# Author: Roman 'gryf' Dobosz gryf@elysium.pl +# +# Copyright (C) 2007 by Roman 'gryf' Dobosz +# +# This file is part of pyGTKtalog. +# +# 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 2 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, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# ------------------------------------------------------------------------- from gtkmvc import Controller import gtk diff --git a/src/ctrls/c_main.py b/src/ctrls/c_main.py index 69294b4..1308846 100644 --- a/src/ctrls/c_main.py +++ b/src/ctrls/c_main.py @@ -1,4 +1,26 @@ # This Python file uses the following encoding: utf-8 +# +# Author: Roman 'gryf' Dobosz gryf@elysium.pl +# +# Copyright (C) 2007 by Roman 'gryf' Dobosz +# +# This file is part of pyGTKtalog. +# +# 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 2 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, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# ------------------------------------------------------------------------- __version__ = "0.7" licence = \ @@ -7,8 +29,6 @@ GPL v2 http://www.gnu.org/licenses/gpl.txt """ -import utils._importer -import utils.globals import os.path from utils import deviceHelper from gtkmvc import Controller @@ -62,7 +82,7 @@ class MainController(Controller): # ustaw domyślne właściwości dla poszczególnych widżetów self.view['main'].set_title('pyGTKtalog'); - self.view['main'].set_icon_list(gtk.gdk.pixbuf_new_from_file("pixmaps/mainicon.png")) +# self.view['main'].set_icon_list(gtk.gdk.pixbuf_new_from_file("pixmaps/mainicon.png")) #self.view['detailplace'].set_sensitive(False) self.view['details'].hide() self.view['exifTab'].hide() @@ -310,6 +330,9 @@ class MainController(Controller): return def on_update1_activate(self, menu_item): + """Update disc under cursor position""" + + # determine origin label and filepath path = self.view['discs'].get_cursor() filepath, label = self.model.get_label_and_filepath(path) diff --git a/src/models/__init__.py b/src/models/__init__.py index e69de29..5e9f6f7 100644 --- a/src/models/__init__.py +++ b/src/models/__init__.py @@ -0,0 +1,25 @@ +# This Python file uses the following encoding: utf-8 +# +# Author: Roman 'gryf' Dobosz gryf@elysium.pl +# +# Copyright (C) 2007 by Roman 'gryf' Dobosz +# +# This file is part of pyGTKtalog. +# +# 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 2 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, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# ------------------------------------------------------------------------- + + diff --git a/src/models/m_config.py b/src/models/m_config.py index 89d62c1..77b0690 100644 --- a/src/models/m_config.py +++ b/src/models/m_config.py @@ -1,6 +1,27 @@ # This Python file uses the following encoding: utf-8 -import utils._importer -import utils.globals +# +# Author: Roman 'gryf' Dobosz gryf@elysium.pl +# +# Copyright (C) 2007 by Roman 'gryf' Dobosz +# +# This file is part of pyGTKtalog. +# +# 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 2 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, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# ------------------------------------------------------------------------- + from gtkmvc import Model import sys diff --git a/src/models/m_main.py b/src/models/m_main.py index 7ca4e5d..70a9e50 100644 --- a/src/models/m_main.py +++ b/src/models/m_main.py @@ -1,7 +1,27 @@ # This Python file uses the following encoding: utf-8 +# +# Author: Roman 'gryf' Dobosz gryf@elysium.pl +# +# Copyright (C) 2007 by Roman 'gryf' Dobosz +# +# This file is part of pyGTKtalog. +# +# 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 2 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, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# ------------------------------------------------------------------------- -import utils._importer -import utils.globals from gtkmvc.model_mt import ModelMT try: diff --git a/src/utils/__init__.py b/src/utils/__init__.py index 11d1287..5e9f6f7 100644 --- a/src/utils/__init__.py +++ b/src/utils/__init__.py @@ -1,3 +1,25 @@ +# This Python file uses the following encoding: utf-8 +# +# Author: Roman 'gryf' Dobosz gryf@elysium.pl +# +# Copyright (C) 2007 by Roman 'gryf' Dobosz +# +# This file is part of pyGTKtalog. +# +# 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 2 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, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# ------------------------------------------------------------------------- -__all__ = ["globals", "_importer"] diff --git a/src/utils/_importer.py b/src/utils/_importer.py deleted file mode 100644 index 8a92aac..0000000 --- a/src/utils/_importer.py +++ /dev/null @@ -1,44 +0,0 @@ -# Author: Roberto Cavada -# -# Copyright (c) 2006 by Roberto Cavada -# -# pygtkmvc is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2 of the License, or (at your option) any later version. -# -# pygtkmvc 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 -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. -# -# For more information on pygtkmvc see -# or email to the author . -# Please report bugs to . - - - -# ====================================================================== -# This module is used only as a utility to import gtkmvc when not -# installed. - -import utils.globals - -if __name__ != "__main__": - try: import gtkmvc - except: - import os.path; import sys - - rel_path = os.path.join(utils.globals.TOP_DIR, "..") - top_dir = os.path.dirname(os.path.abspath(rel_path)) - sys.path = [top_dir] + sys.path - import gtkmvc - pass - - gtkmvc.require("1.0.0") -pass - diff --git a/src/utils/deviceHelper.py b/src/utils/deviceHelper.py index d2c0c8d..18c0866 100644 --- a/src/utils/deviceHelper.py +++ b/src/utils/deviceHelper.py @@ -1,4 +1,26 @@ # This Python file uses the following encoding: utf-8 +# +# Author: Roman 'gryf' Dobosz gryf@elysium.pl +# +# Copyright (C) 2007 by Roman 'gryf' Dobosz +# +# This file is part of pyGTKtalog. +# +# 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 2 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, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# ------------------------------------------------------------------------- """ device (cd, dvd) helper """ diff --git a/src/utils/globals.py b/src/utils/globals.py index 38291ff..bffb292 100644 --- a/src/utils/globals.py +++ b/src/utils/globals.py @@ -1,33 +1,39 @@ -# Author: Roberto Cavada +# This Python file uses the following encoding: utf-8 # -# Copyright (c) 2006 by Roberto Cavada +# Author: Roman 'gryf' Dobosz gryf@elysium.pl # -# pygtkmvc is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2 of the License, or (at your option) any later version. +# Copyright (C) 2007 by Roman 'gryf' Dobosz # -# pygtkmvc is distributed in the hope that it will be useful, +# This file is part of pyGTKtalog. +# +# 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 2 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 -# Lesser General Public License for more details. +# 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 Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. -# -# For more information on pygtkmvc see -# or email to the author . -# Please report bugs to . +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# ------------------------------------------------------------------------- import os.path import sys if sys.argv[0]: top_dir = os.path.dirname(os.path.abspath(sys.argv[0])) else: top_dir = "." - -# A set of global vars -TOP_DIR = top_dir -GLADE_DIR = os.path.join(TOP_DIR, "glade") +# ---------------------------------------------------------------------- +TOPDIR = top_dir +RESOURCES_DIR = os.path.join(TOPDIR, "resources") +GLADE_DIR = os.path.join(RESOURCES_DIR, "glade") +STYLES_DIR = os.path.join(RESOURCES_DIR, "styles") +APPL_SHORT_NAME = "pycolector" +APPL_VERSION = (1, 0, 0) +# ---------------------------------------------------------------------- + diff --git a/src/views/__init__.py b/src/views/__init__.py index e69de29..5e9f6f7 100644 --- a/src/views/__init__.py +++ b/src/views/__init__.py @@ -0,0 +1,25 @@ +# This Python file uses the following encoding: utf-8 +# +# Author: Roman 'gryf' Dobosz gryf@elysium.pl +# +# Copyright (C) 2007 by Roman 'gryf' Dobosz +# +# This file is part of pyGTKtalog. +# +# 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 2 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, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# ------------------------------------------------------------------------- + + diff --git a/src/views/v_config.py b/src/views/v_config.py index 348db61..f4b1d46 100644 --- a/src/views/v_config.py +++ b/src/views/v_config.py @@ -1,9 +1,30 @@ # This Python file uses the following encoding: utf-8 +# +# Author: Roman 'gryf' Dobosz gryf@elysium.pl +# +# Copyright (C) 2007 by Roman 'gryf' Dobosz +# +# This file is part of pyGTKtalog. +# +# 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 2 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, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# ------------------------------------------------------------------------- -import utils._importer -import utils.globals from gtkmvc import View import os.path +import utils.globals class ConfigView(View): """Preferences window from glade file """ diff --git a/src/views/v_dialogs.py b/src/views/v_dialogs.py index cf6318c..046ff45 100644 --- a/src/views/v_dialogs.py +++ b/src/views/v_dialogs.py @@ -1,7 +1,30 @@ # This Python file uses the following encoding: utf-8 +# +# Author: Roman 'gryf' Dobosz gryf@elysium.pl +# +# Copyright (C) 2007 by Roman 'gryf' Dobosz +# +# This file is part of pyGTKtalog. +# +# 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 2 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, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# ------------------------------------------------------------------------- import gtk import os +import utils.globals class Qst(object): """Show simple dialog for questions @@ -92,7 +115,7 @@ class Abt(object): class InputDiskLabel(object): """Sepcific dialog for quering user for a disc label""" def __init__(self, label=""): - self.gladefile = "glade/dialogs.glade" + self.gladefile = os.path.join(utils.globals.GLADE_DIR, "dialogs.glade") self.label = "" if label!= None: self.label = label @@ -111,7 +134,7 @@ class InputDiskLabel(object): class PointDirectoryToAdd(object): """Sepcific dialog for quering user for selecting directory to add""" def __init__(self,volname='',dirname=''): - self.gladefile = "glade/dialogs.glade" + self.gladefile = os.path.join(utils.globals.GLADE_DIR, "dialogs.glade") self.gladexml = gtk.glade.XML(self.gladefile, "addDirDialog") self.volname = self.gladexml.get_widget("dirvolname") self.volname.set_text(volname) diff --git a/src/views/v_main.py b/src/views/v_main.py index 45125fa..3a8ab50 100644 --- a/src/views/v_main.py +++ b/src/views/v_main.py @@ -1,9 +1,30 @@ # This Python file uses the following encoding: utf-8 +# +# Author: Roman 'gryf' Dobosz gryf@elysium.pl +# +# Copyright (C) 2007 by Roman 'gryf' Dobosz +# +# This file is part of pyGTKtalog. +# +# 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 2 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, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# ------------------------------------------------------------------------- -import utils._importer -import utils.globals from gtkmvc import View import os.path +import utils.globals class MainView(View): """This handles only the graphical representation of the