# HG changeset patch # User fabien # Date 1075604725 18000 # Node ID fab56cacf4bc9439509ecf7e16c1fe9a79a5db1d [svn] Premi��re version de immsview. diff -r 000000000000 -r fab56cacf4bc immsview --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/immsview Sat Jan 31 22:05:25 2004 -0500 @@ -0,0 +1,125 @@ +#!/usr/bin/python + +# Copyright (C) 2004 by Fabien Ninoles + +# IMMSView 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, or (at your option) +# any later version. + +# IMMSView 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 GNU Emacs; see the file COPYING. If not, write to the +# Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# TODO: +# * IMMS: +# - Add Artist, Title, SID, etc. +# - Add composed rating +# - Columns ordering (should pass to GTK probably for this). +# - Rating edition +# * XMMS: +# - current song display +# - selecting a song +# - getting current playlist +# - editing playlist +# * File support: +# - adding, deleting, suppressing a file (including updating other +# interface). + +import sys +import os +import sqlite +import Tkinter +import ScrolledText +import gettext + +gettext.bindtextdomain('immsview', '/usr/share/immsview/LANG') +gettext.textdomain('immsview') +_ = gettext.gettext + +_dbname = os.environ['HOME'] + '/.imms/imms.db' + +class IMMSDb: + def __init__(self): + self.cx = sqlite.connect(_dbname) + def commit(self): + self.cx.commit() + def get_ratings(self, min = 0, max = 250): + cu = self.cx.cursor() + cu.execute('''SELECT Rating.uid, Rating.rating + FROM Rating + WHERE Rating.rating >= %d + AND Rating.rating <= %d + ORDER BY Rating.rating;''' % (min, max)) + return cu.fetchall() + def get_library_uid(self, uid): + cu = self.cx.cursor() + cu.execute('''SELECT Library.path + FROM Library + WHERE Library.uid = %d;''' % (uid,)) + return cu.fetchone() + def get_library_by_path(self, path): + cu = self.cx.cursor() + cu.execute('''SELECT Library.uid, Library.sid + FROM Library + WHERE Library.path = '%s';''' % (path)) + +class IMMSView(Tkinter.Frame): + def __init__(self, master = None): + Tkinter.Frame.__init__(self, master) + self.db = IMMSDb() + self.create_widgets() + def create_widgets(self): + lf = Tkinter.Frame(self) + lf.pack(expand = 1, fill = Tkinter.BOTH, side = Tkinter.LEFT) + self.lb = Tkinter.Listbox(lf, relief = Tkinter.RAISED) + self.lb.pack(expand = 1, side = Tkinter.TOP, fill = Tkinter.BOTH) + xsb = Tkinter.Scrollbar(lf, orient = Tkinter.HORIZONTAL) + xsb.pack({'fill' : Tkinter.X, 'side' : Tkinter.BOTTOM}) + ysb = Tkinter.Scrollbar(self) + ysb.pack({'fill' : Tkinter.Y, 'side' : Tkinter.RIGHT}) + + ysb['command'] = self.lb.yview + xsb['command'] = self.lb.xview + self.lb['yscrollcommand'] = ysb.set + self.lb['xscrollcommand'] = xsb.set + + self.refresh() + def refresh(self): + rates = self.db.get_ratings() + self.lb.delete(0,self.lb.size()) + for rate in rates: + lib = self.db.get_library_uid(rate[0]) + self.lb.insert(-1, "%4d - %s" % (rate[1], lib[0])) + self.db.commit() + self.lb.see(0) +class IMMSToolbar(Tkinter.Frame): + def __init__(self, master = None): + Tkinter.Frame.__init__(self, master) + self.refresh_command = None + self.create_widgets() + def create_widgets(self): + button = Tkinter.Button(self, text = _('Refresh'), + command = self.do_refresh) + button.pack(side = Tkinter.LEFT) + button = Tkinter.Button(self, text = _('Plot'), command = self.plot) + button.pack(side = Tkinter.LEFT) + def plot(): + os.system('exec immsplot &') + def do_refresh(self): + if (self.refresh_command): + self.refresh_command() + +root = Tkinter.Tk() +iview = IMMSView(root) +iview.pack(side = Tkinter.BOTTOM, expand = 1, fill = Tkinter.BOTH) +toolbar = IMMSToolbar() +toolbar.refresh_command = iview.refresh +toolbar.pack(side = Tkinter.TOP, fill = Tkinter.X) +root.mainloop() diff -r 000000000000 -r fab56cacf4bc immsview.glade --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/immsview.glade Sat Jan 31 22:05:25 2004 -0500 @@ -0,0 +1,231 @@ + + + + + + + True + window1 + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + False + + + + True + False + 0 + + + + True + GTK_SHADOW_OUT + GTK_POS_LEFT + GTK_POS_TOP + + + + True + + + + True + _Fichier + True + + + + + + + True + gtk-new + True + + + + + + + True + gtk-open + True + + + + + + + True + gtk-save + True + + + + + + + True + gtk-save-as + True + + + + + + + True + + + + + + True + gtk-quit + True + + + + + + + + + + + True + _Édition + True + + + + + + + True + gtk-cut + True + + + + + + + True + gtk-copy + True + + + + + + + True + gtk-paste + True + + + + + + + True + gtk-delete + True + + + + + + + + + + + True + _Vue + True + + + + + + + + + + + True + _Aide + True + + + + + + + True + À _propos + True + + + + + + + + + + + + 0 + False + True + + + + + + True + True + GTK_POLICY_ALWAYS + GTK_POLICY_ALWAYS + GTK_SHADOW_NONE + GTK_CORNER_TOP_LEFT + + + + True + True + True + False + False + True + + + + + 0 + True + True + + + + + + True + True + + + 0 + False + False + + + + + + + diff -r 000000000000 -r fab56cacf4bc immsview.gladep --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/immsview.gladep Sat Jan 31 22:05:25 2004 -0500 @@ -0,0 +1,8 @@ + + + + + Immsview + immsview + FALSE +