Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/library.py
blob: 6b0eafb19f5c60a3143899d204f68284c8f44709 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# 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
from gettext import gettext as _

from sugar.graphics.toolbutton import ToolButton
from sugar.graphics.toggletoolbutton import ToggleToolButton
from sugar.activity.activity import ActivityToolbox
from sugar.graphics.toolcombobox import ToolComboBox

from GUI_Components.Compound_Widgets.Library_View import Library_View
from GUI_Components.Compound_Widgets.toolbar import WidgetItem

class View(gtk.EventBox): #Library_View):
    def __init__(self):
        gtk.EventBox.__init__(self)
        #Library_View.__init__(self)

        """

        def get_source_article(self):
            return self.librarypanel.get_source()
        
        def set_source_article(self, article):
            self.librarypanel.set_source(article)   
        
        def get_working_article(self):
            return self.librarypanel.get_working()
        
        def set_working_article(self, article):
            self.librarypanel.set_working(article)


        # Set up dummy library if appropriate
        IO_Manager().install_library()

        themes = IO_Manager().get_themes()
        if "Wikipedia Articles" in themes:
            i = themes.index("Wikipedia Articles")
            del themes[i]
            
        wikiarticles = IO_Manager().get_pages_in_theme("Wikipedia Articles")
        for theme in themes:
            articles = IO_Manager().get_pages_in_theme(theme)
            for article in articles:
                if ignore == True:
                    break
                for wikiarticle in wikiarticles:
                    if article in wikiarticle:
                        self.source = IO_Manager().load_article(wikiarticle, "Wikipedia Articles")
                        self.working = IO_Manager().load_article(article, theme) 
                        logger.debug("loading source %s from %s" %
                                (wikiarticle, "Wikipedia Articles"))
                        logger.debug("loading edit %s from %s" %
                                (article, theme))
                        ignore = True
        """

class Toolbar(gtk.Toolbar):
    def __init__(self, library):
        gtk.Toolbar.__init__(self)
        self.library = library
        return

        wikimenu = ToolComboBox(label_text=_('Get article from:'))
        wikimenu.combo.connect('changed', self._wikimenu_changed_cb)
        for i in sorted(WIKI.keys()):
            wikimenu.combo.append_item(WIKI[i], i)
        self.insert(wikimenu, -1)
        wikimenu.show()

        searchentry = gtk.Entry()
        searchentry.set_size_request(int(gtk.gdk.screen_width() / 4), -1)
        searchentry.set_text(_("Article name"))
        searchentry.connect('changed', self._search_activate_cb)
        searchentry_item = WidgetItem(searchentry)
        self.insert(searchentry_item, -1)
        searchentry_item.show()

        self.searchbutton = ToolButton('search', tooltip=_('Find article'))
        self.searchbutton.connect("clicked", self.library.commence_retrieval,
                searchentry, self.library.statusbar, wikimenu, WIKI)
        self.insert(self.searchbutton, -1)
        self.searchbutton.show()

        separator = gtk.SeparatorToolItem()
        self.insert(separator, -1)
        separator.show()

        new = ToolButton('add', tooltip=_('New article'))
        new.connect("clicked", self._new_clicked_cb)
        self.insert(new, -1)
        new.show()

        erase = ToolButton('edit-delete', tooltip=_('Delete selected articles'))
        erase.connect("clicked", self._erase_clicked_cb)
        self.insert(erase, -1)
        erase.show()

        separator = gtk.SeparatorToolItem()
        self.insert(separator, -1)
        separator.show()

        publish = ToolButton('filesave', tooltip=_('Publish selected articles'))
        publish.connect("clicked", self._publish_clicked_cb)
        self.insert(publish, -1)
        publish.show()

    def _publish_clicked_cb(self):
        pass

    def _erase_clicked_cb(self):
        pass

    def _new_clicked_cb(self):
        pass

    def _search_activate_cb(self, widget):
        self.searchbutton.emit("clicked")

    def _wikimenu_changed_cb(self, widget, data):
        self.searchbutton.emit("clicked")

WIKI = { _("English Wikipedia")         : "en.wikipedia.org", 
         _("Simple English Wikipedia")  : "simple.wikipedia.org", 
         _("German Wikipedia")          : "de.wikipedia.org" }