/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to olive/frontend/gtk/__init__.py

  • Committer: Szilveszter Farkas (Phanatic)
  • Date: 2006-07-16 23:51:20 UTC
  • mto: (0.14.1 main) (93.1.1 win32.bialix)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: Szilveszter.Farkas@gmail.com-20060716235120-0ea07ea7fc6e9330
2006-07-17  Szilveszter Farkas <Szilveszter.Farkas@gmail.com>

    * setup.py: some tweaks
    * olive-gtk: added main executable
    * olive/frontend/gtk/handler.py: signal handler class added (OliveHandler)
    * olive/frontend/gtk/__init__.py: main GTK class added (OliveGtk)
    * olive.glade: GTK UI description added (generated by Glade)
    * oliveicon2.png: icon added

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2006 by Szilveszter Farkas (Phanatic) <szilveszter.farkas@gmail.com>
 
2
 
 
3
# This program is free software; you can redistribute it and/or modify
 
4
# it under the terms of the GNU General Public License as published by
 
5
# the Free Software Foundation; either version 2 of the License, or
 
6
# (at your option) any later version.
 
7
 
 
8
# This program is distributed in the hope that it will be useful,
 
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
# GNU General Public License for more details.
 
12
 
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program; if not, write to the Free Software
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
16
 
 
17
import sys
 
18
 
 
19
try:
 
20
        import pygtk
 
21
        pygtk.require("2.0")
 
22
except:
 
23
        pass
 
24
try:
 
25
        import gtk
 
26
        import gtk.glade
 
27
except:
 
28
        sys.exit(1)
 
29
 
 
30
from olive.frontend.gtk.handler import OliveHandler
 
31
 
 
32
# Olive GTK UI version
 
33
__version__ = '0.1'
 
34
 
 
35
class OliveGtk:
 
36
    """ The main Olive GTK frontend class. This is called when launching the
 
37
    program."""
 
38
    
 
39
    def __init__(self):
 
40
        # Load the glade file
 
41
        self.gladefile = "/usr/share/olive/olive.glade"
 
42
        self.toplevel = gtk.glade.XML(self.gladefile, "window_main")
 
43
        
 
44
        handler = OliveHandler(self.gladefile)
 
45
        
 
46
        # Dictionary for signal_autoconnect
 
47
        dic = { "on_window_main_destroy": gtk.main_quit,
 
48
                "on_about_activate": handler.about }
 
49
        
 
50
        # Connect the signals to the handlers
 
51
        self.toplevel.signal_autoconnect(dic)
 
52
        
 
53
        # Load default data into the panels
 
54
        self.treeview_left = self.toplevel.get_widget('treeview_left')
 
55
        self.treeview_right = self.toplevel.get_widget('treeview_right')
 
56
        self.load_left()
 
57
        self.load_right()
 
58
    
 
59
    def load_left(self):
 
60
        """ Load data into the left panel. (Bookmarks) """
 
61
        pass
 
62
        
 
63
    def load_right(self):
 
64
        """ Load data into the right panel. (Filelist) """
 
65
        import os
 
66
        import os.path
 
67
        
 
68
        # Create ListStore
 
69
        liststore = gtk.ListStore(str, str)
 
70
        
 
71
        dirs = []
 
72
        files = []
 
73
        
 
74
        # Fill the appropriate lists
 
75
        for item in os.listdir('.'):
 
76
            if os.path.isdir(item):
 
77
                dirs.append(item)
 
78
            else:
 
79
                files.append(item)
 
80
            
 
81
        # Sort'em
 
82
        dirs.sort()
 
83
        files.sort()
 
84
        
 
85
        # Add'em to the ListStore
 
86
        for item in dirs:    
 
87
            liststore.append(['D', item])
 
88
        for item in files:
 
89
            liststore.append(['', item])
 
90
        
 
91
        # Create the columns and add them to the TreeView
 
92
        self.treeview_right.set_model(liststore)
 
93
        tvcolumn_filename = gtk.TreeViewColumn('Filename')
 
94
        tvcolumn_filetype = gtk.TreeViewColumn('Type')
 
95
        self.treeview_right.append_column(tvcolumn_filetype)
 
96
        self.treeview_right.append_column(tvcolumn_filename)
 
97
        
 
98
        # Set up the cells
 
99
        cell = gtk.CellRendererText()
 
100
        tvcolumn_filetype.pack_start(cell, True)
 
101
        tvcolumn_filetype.add_attribute(cell, 'text', 0)
 
102
        tvcolumn_filename.pack_start(cell, True)
 
103
        tvcolumn_filename.add_attribute(cell, 'text', 1)