Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/GUI_Components/Image_Pane.py
blob: 8ebff6423f5c3ab7ae267490a0d869e84421607f (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
# Copyright (C) IBM Corporation 2008 
import pygtk
pygtk.require('2.0')
import gtk
from GUI_Components.Pane import Pane
from GUI_Components.Compound_Widgets.Editing_View import Editing_View
from GUI_Components.Compound_Widgets.Gallery_View import Gallery_View
from Processing.Article.Article import Article
from Processing.IO_Manager import IO_Manager

class Image_Pane(Pane):
    """
    Created by Christopher Leonard
    
    See __init__.py for overview of panes.
    
    The Image Pane gives a side-by-side view of the source article and edit article.
    The left hand side shows images in the source article.  These can be dragged into
    the edit article.
    """
    
    def __init__(self):
        Pane.__init__(self)
        self.name = "Images"    
        
        self.panel = gtk.HBox()
        self.panel.set_homogeneous(True)
        self.panel.show()
        self.gallery = Gallery_View()
        self.panel.pack_start(self.gallery)
        self.editarticle = Editing_View()
        self.panel.pack_start(self.editarticle)
        self.editarticle.show_all()

        self.gallery._source_article = None
        
        self.toolbar = gtk.Toolbar()
        """
        Snapping has been turned off in the Editable Textbox, so we no longer
        make use of snapping.  This has been left in case we turn it back on.
        
        
        self.combobox = gtk.combo_box_new_text()
        self.combobox.append_text("Nothing")
        self.combobox.append_text("Sentences")
        self.combobox.append_text("Paragraphs")
        self.combobox.append_text("Sections")
        self.combobox.connect("changed", self.selection_mode_changed, None)
        self.combobox.set_active(1)
        self.combobox.show()
        
        self.combocontainer = gtk.ToolItem()
        self.combocontainer.add(self.combobox)
        self.toolbar.insert(self.combocontainer, -1)
        self.combocontainer.show()
        """
        
    def selection_mode_changed(self, widget, data):
        current_selection = widget.get_active_text()
        if current_selection == "Nothing":
            self.editarticle.set_full_edit_mode()
        elif current_selection == "Sentences":
            self.editarticle.set_sentence_selection_mode()
        elif current_selection == "Paragraphs":
            self.editarticle.set_paragraph_selection_mode()
        elif current_selection == "Sections":
            self.editarticle.set_section_selection_mode()
        
        
    def set_source_article(self, source):
        print "source received.  title: %s, theme: %s" % (source.article_title, source.article_theme)
        current = self.gallery._source_article
        self.gallery._source_article = source
        if source and source.article_title:
            source.article_theme = "Wikipedia Articles"
            if current:
                if current.article_title == source.article_title and current.article_theme == source.article_theme:
                    print "same"
                    return
            self.gallery.current_index = 0
            if source.image_list != []:
                print "setting images"
                self.gallery.set_image_list(source.image_list)
                self.gallery.get_first_item()
                
                self.gallery.theme = "Wikipedia Articles"
                self.gallery.source_article_id = source.source_article_id
                print source.image_list
            else:
                self.gallery.imagenumberlabel.set_label("")
                self.gallery.image.clear()
                self.gallery.caption.set_text("This article does not have any images")
        else:
            self.gallery.imagenumberlabel.set_label("")
            self.gallery.caption.set_text("Please select a Wikipedia article from the menu above")
    
    def get_source_article(self):
        return self.gallery._source_article
         
    def get_working_article(self):
        article = self.editarticle.textbox.get_article()
        #data = article.getData()
        return article
    
    def set_working_article(self, article):
        print "working received, title %s theme %s " % (article.article_title, article.article_theme)
        self.editarticle.articletitle.set_markup("<span size='medium'><b>Theme:</b>  %s   \n<b>Article:</b>  %s</span>"%(article.article_theme, article.article_title))
        if article == None:
            article = Article()
        self.editarticle.textbox.set_article(article)
        if article.article_theme == None:
            article.article_theme = "My Articles"
        theme_list = IO_Manager().get_pages_in_theme("Wikipedia Articles")
        self.gallery.theme = "Wikipedia Articles"        
        count = -1
        self.gallery.articlemenu.get_model().clear()
        
        for item in theme_list:
            count += 1 
            self.gallery.articlemenu.append_text(item)
            if self.gallery._source_article != None and item == self.gallery._source_article.article_title:
                self.gallery.articlemenu.set_active(count)