~cseslam/tahrir/trunk

« back to all changes in this revision

Viewing changes to tahrir/app.py

  • Committer: Eslam Mostafa
  • Date: 2013-05-07 03:25:59 UTC
  • Revision ID: cseslam@gmail.com-20130507032559-tvixouwrxcmue00b
refine code and use camelCase

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
import sys
2
2
from gi.repository import Gtk
3
3
from window import TahrirWindow
 
4
from document import Document
4
5
 
5
6
class TahrirApp(Gtk.Application):
6
7
    def __init__(self):
7
8
        Gtk.Application.__init__(self)
 
9
        self.documents = [];
 
10
        self.docsCount = 0;
 
11
 
 
12
    def newDocument(self, filename):
 
13
        doc = Document()
 
14
        if(filename != None):
 
15
            doc.setFilename(filename)
 
16
            doc.fetchTitle()
 
17
            doc.fetchContent()
 
18
        self.docsCount += 1
 
19
        title = doc.get_title()
 
20
        doc.set_modified(False)
 
21
        self._win.notebook.append_page(doc, Gtk.Label(_(title)))
 
22
        self._win.toolbar.documentsBox.append(str(self.docs_count),title)
 
23
        self._win.toolbar.documentsBox.set_active_id(str(self.docs_count))
 
24
        self._win.notebook.set_current_page(-1)
 
25
        self._win.notebook.show_all()
8
26
 
9
27
    def do_startup(self):
10
28
        Gtk.Application.do_startup(self)
11
29
 
12
30
    def do_activate(self):
13
 
        self.win = TahrirWindow(self)
14
 
        self.win.present()
 
31
        self._win = TahrirWindow(self)
 
32
        self._win.present()
15
33
 
16
34
if __name__ == '__main__':
17
35
    app = TahrirApp()