~cseslam/tahrir/trunk

« back to all changes in this revision

Viewing changes to tahrir/home.py

  • Committer: Eslam Mostafa
  • Date: 2012-09-20 03:01:13 UTC
  • Revision ID: cseslam@gmail.com-20120920030113-lhy117if96dj611f
erase old tahrir

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from gi.repository import Gtk, Gio, GdkPixbuf
2
 
 
3
 
class Home(Gtk.Box):
4
 
    def __init__(self, window):
5
 
        self.window = window
6
 
        Gtk.Box.__init__(self)
7
 
        left_arrow = Arrow('left')
8
 
        center = Center(window)
9
 
        right_arrow = Arrow('right')
10
 
        self.pack_start(left_arrow, False, True, 0)
11
 
        self.pack_start(center, True, True, 0)
12
 
        self.pack_start(right_arrow, False, True, 0)
13
 
        center.grab_focus()
14
 
        self.show_all()
15
 
     
16
 
class Arrow(Gtk.Box):
17
 
    def __init__(self, direction):
18
 
        Gtk.Box.__init__(self)
19
 
        if direction == 'left':
20
 
            gicon = Gio.ThemedIcon.new_with_default_fallbacks('go-previous-symbolic')
21
 
        elif direction == 'right':
22
 
            gicon = Gio.ThemedIcon.new_with_default_fallbacks('go-next-symbolic')
23
 
        image = Gtk.Image.new_from_gicon(gicon, Gtk.IconSize.DIALOG)
24
 
        button = Gtk.Button()
25
 
        button.set_image(image)
26
 
        button.set_relief(Gtk.ReliefStyle.NONE)
27
 
        self.pack_start(button, False, False, 0)
28
 
        button.set_can_focus(False)        
29
 
        
30
 
        
31
 
class Center(Gtk.IconView):
32
 
    def __init__(self, window):
33
 
        Gtk.IconView.__init__(self)
34
 
        self.window = window
35
 
        self.model = Gtk.ListStore(GdkPixbuf.Pixbuf, str)
36
 
        self.set_model(self.model)
37
 
        self.set_pixbuf_column(0)
38
 
        self.set_text_column(1)
39
 
        self.model.append([self.get_icon('gtk-new'), 'New Document'])
40
 
        self.model.append([self.get_icon('gtk-open'), 'Open File'])
41
 
        self.connect('item-activated', self._on_item_activated)
42
 
        
43
 
    def get_icon(self, name):
44
 
        image = Gtk.Image.new_from_stock(name, Gtk.IconSize.DIALOG)
45
 
        icon = image.get_pixbuf()
46
 
        return icon
47
 
        
48
 
    def _on_item_activated(self, iconview, path):      
49
 
        if self.model[path][1] == 'New Document':
50
 
            self.window.request_new_operation(None)
51
 
        
52