From 0cdc7fd02ffd17d8e78c242f5fd386f6b0e969c3 Mon Sep 17 00:00:00 2001 From: Alexandre Antonino Gonçalves Martinazzo Date: Thu, 13 Sep 2007 21:50:32 +0000 Subject: Changed some private attributes into public ones and vice-versa (OficinaActivity.area; OficinaActivity.textview; OficinaActivity.fixed; OficinaActivity._bg) --- diff --git a/Area.py b/Area.py index 8306779..2391fee 100644 --- a/Area.py +++ b/Area.py @@ -267,17 +267,17 @@ class Area(gtk.DrawingArea): elif self.estadoTexto is 1: try: # This works for a gtk.Entry - text = self.janela._textview.get_text() + text = self.janela.textview.get_text() except AttributeError: # This works for a gtk.TextView - buf = self.janela._textview.get_buffer() + buf = self.janela.textview.get_buffer() start, end = buf.get_bounds() text = buf.get_text(start, end) if text is not None: self.d.text(widget,event) self.estadoTexto = 0 - self.janela._textview.hide() + self.janela.textview.hide() if not self.selmove or self.tool['name'] != 'marquee-rectangular': self.oldx, self.oldy = coords diff --git a/Desenho.py b/Desenho.py index 771195a..72ec259 100644 --- a/Desenho.py +++ b/Desenho.py @@ -524,21 +524,21 @@ class Desenho: if widget.estadoTexto == 0: widget.estadoTexto = 1 - widget.janela._fixed.move(widget.janela._textview, int(event.x)+200, int(event.y)+100) + widget.janela.fixed.move(widget.janela.textview, int(event.x)+200, int(event.y)+100) # Area size has changed... - #widget.janela._fixed.move(widget.janela._textview, int(event.x), int(event.y)) - widget.janela._textview.show() - widget.janela._textview.grab_focus() + #widget.janela.fixed.move(widget.janela.textview, int(event.x), int(event.y)) + widget.janela.textview.show() + widget.janela.textview.grab_focus() else: widget.estadoTexto = 0 try: # This works for a gtk.Entry - text = widget.janela._textview.get_text() + text = widget.janela.textview.get_text() except AttributeError: # This works for a gtk.TextView - buf = widget.janela._textview.get_buffer() + buf = widget.janela.textview.get_buffer() start, end = buf.get_bounds() text = buf.get_text(start, end) @@ -547,9 +547,9 @@ class Desenho: widget.pixmap.draw_layout(widget.gc, widget.oldx, widget.oldy, layout) widget.pixmap_temp.draw_layout(widget.gc, widget.oldx, widget.oldy, layout) - widget.janela._textview.hide() + widget.janela.textview.hide() try: - widget.janela._textview.set_text('') + widget.janela.textview.set_text('') except AttributeError: buf.set_text('') diff --git a/OficinaActivity.py b/OficinaActivity.py index d5727e0..08355c2 100644 --- a/OficinaActivity.py +++ b/OficinaActivity.py @@ -83,8 +83,9 @@ class OficinaActivity(activity.Activity): os.chdir(activity.get_bundle_path()) #print activity.get_bundle_path() - self._fixed = gtk.Fixed() - self._area = Area(self) + # These attributes are used in other classes, so they should be public + self.fixed = gtk.Fixed() + self.area = Area(self) toolbox = Toolbox(self) self.set_toolbox(toolbox) @@ -96,44 +97,33 @@ class OficinaActivity(activity.Activity): color = gtk.gdk.color_parse("white") - self._fixed.modify_bg(gtk.STATE_NORMAL, color) + self.fixed.modify_bg(gtk.STATE_NORMAL, color) - self.bg = gtk.Image() - self.bg.set_from_file('./icons/bg.svg') - self._fixed.put(self.bg, 200, 100) - self.bg.show() + self._bg = gtk.Image() + self._bg.set_from_file('./icons/bg.svg') + self.fixed.put(self._bg, 200, 100) + self._bg.show() - self._textview = gtk.TextView() + self.textview = gtk.TextView() # If we use this, text viewer will have constant size, we don't want that - #self._textview.set_size_request(100,100) + #self.textview.set_size_request(100,100) - self._fixed.put(self._area, 200 , 100) + self.fixed.put(self.area, 200 , 100) # Area size increased - #self._fixed.put(self._area, 0 , 0) + #self.fixed.put(self.area, 0 , 0) - sw.add_with_viewport(self._fixed) - self._area.show() - self._fixed.show() + sw.add_with_viewport(self.fixed) + self.area.show() + self.fixed.show() - self._fixed.put(self._textview, 0, 0) - self._textview.hide() + self.fixed.put(self.textview, 0, 0) + self.textview.hide() sw.show() # setting scrolledwindow as activity canvas... self.set_canvas(sw) -# # Setting a default tool -# initial_tool = { -# 'name' : 'pencil', -# 'line size' : 2, -# 'fill color' : None, -# 'stroke color' : None, -# 'line shape' : 'circle', -# 'fill' : True, -# 'vertices' : None -# } -# self._area.set_tool(initial_tool) def read_file(self, file_path): '''Read file from Sugar Journal. @@ -145,7 +135,7 @@ class OficinaActivity(activity.Activity): logging.debug('reading file %s', file_path) # logging.debug(file_path) - self._area.loadImage(file_path, self._area, False) + self.area.loadImage(file_path, self.area, False) @@ -159,9 +149,9 @@ class OficinaActivity(activity.Activity): logging.debug('saving as PNG') logging.debug('writting file %s', file_path) - width, height = self._area.window.get_size() + width, height = self.area.window.get_size() pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, width, height) - pixbuf.get_from_drawable(self._area.pixmap, gtk.gdk.colormap_get_system(), 0, 0, 0, 0, -1, -1) + pixbuf.get_from_drawable(self.area.pixmap, gtk.gdk.colormap_get_system(), 0, 0, 0, 0, -1, -1) self.metadata['mime_type'] = 'image/png' pixbuf.save(file_path, 'png', {}) diff --git a/toolbox.py b/toolbox.py index 3af9b4d..dad84ad 100644 --- a/toolbox.py +++ b/toolbox.py @@ -135,23 +135,23 @@ class DrawEditToolbar(EditToolbar): - self._activity._area.connect('undo', self._on_signal_undo_cb) - self._activity._area.connect('redo', self._on_signal_redo_cb) - self._activity._area.connect('selected', self._on_signal_copy_cb) - self._activity._area.connect('action-saved', self._on_signal_action_saved_cb) + self._activity.area.connect('undo', self._on_signal_undo_cb) + self._activity.area.connect('redo', self._on_signal_redo_cb) + self._activity.area.connect('selected', self._on_signal_copy_cb) + self._activity.area.connect('action-saved', self._on_signal_action_saved_cb) def _undo_cb(self, widget, data=None): - self._activity._area.undo() + self._activity.area.undo() def _redo_cb(self, widget, data=None): - self._activity._area.redo() + self._activity.area.redo() def _copy_cb(self, widget, data=None): - self._activity._area.copy() + self._activity.area.copy() def _paste_cb(self, widget, data=None): - self._activity._area.past() + self._activity.area.past() def _on_signal_undo_cb(self, widget, data=None): self._verify_sensitive_buttons() @@ -167,15 +167,15 @@ class DrawEditToolbar(EditToolbar): ##define when a button is active def _verify_sensitive_buttons(self): - self.undo.set_sensitive( self._activity._area.can_undo() ) - self.redo.set_sensitive( self._activity._area.can_redo() ) - self.copy.set_sensitive( self._activity._area.is_selected() ) + self.undo.set_sensitive( self._activity.area.can_undo() ) + self.redo.set_sensitive( self._activity.area.can_redo() ) + self.copy.set_sensitive( self._activity.area.is_selected() ) #TODO: it is not possible to verify these yet. - #self.copy.set_sensitive( self._activity._area.can_copy() ) - #self.paste.set_sensitive( self._activity._area.can_paste() ) + #self.copy.set_sensitive( self._activity.area.can_copy() ) + #self.paste.set_sensitive( self._activity.area.can_paste() ) def _clear_all_cb(self, widget, data=None): - self._activity._area.clear() + self._activity.area.clear() ##Determine Tools of the Toolbar class ToolsToolbar(gtk.Toolbar): @@ -471,7 +471,7 @@ class ToolsToolbar(gtk.Toolbar): # Creating a CheckButton named "Fill". fill_checkbutton = gtk.CheckButton(_('Fill')) fill_checkbutton.show() - #fill_checkbutton.set_active(self._activity._area.fill) + #fill_checkbutton.set_active(self._activity.area.fill) fill_checkbutton.set_active(self._TOOL_POLYGON['fill']) fill_checkbutton.connect('toggled', self._on_fill_checkbutton_toggled, widget, self._TOOL_POLYGON) @@ -519,7 +519,7 @@ class ToolsToolbar(gtk.Toolbar): new_color = self._stroke_color.get_color() tool['stroke color'] = self._stroke_color.alloc_color(new_color) - self._activity._area.set_tool(tool) + self._activity.area.set_tool(tool) #setting cursor: Moved to Area @@ -530,7 +530,7 @@ class ToolsToolbar(gtk.Toolbar): logging.debug('Checkbutton is Active: %s', checkbutton.get_active() ) # New method for setting tools - #self._activity._area.fill = checkbutton.get_active() + #self._activity.area.fill = checkbutton.get_active() tool['fill'] = checkbutton.get_active() self.set_tool(tool=tool) @@ -542,7 +542,7 @@ class ToolsToolbar(gtk.Toolbar): @param checkbutton @param data """ - self._activity._area.fill = checkbutton.get_active() + self._activity.area.fill = checkbutton.get_active() def _on_color_set(self, colorbutton, tool): logging.debug('toolbox.ToolsToolbar._on_color_set') @@ -613,7 +613,7 @@ class ComboStrokeSize(ToolComboBox): self.set_stroke_size(size) def set_stroke_size(self, size): - self._activity._area.configure_line(size) + self._activity.area.configure_line(size) def get_size(self): model = self.combo.get_model() @@ -634,12 +634,12 @@ class ButtonFillColor(gtk.ColorButton): self.set_fill_color(color) def alloc_color(self, color): - colormap = self._activity._area.get_colormap() + colormap = self._activity.area.get_colormap() return colormap.alloc_color(color.red, color.green, color.blue) def set_fill_color(self, color): new_color = self.alloc_color(color) - self._activity._area._set_fill_color(new_color) + self._activity.area._set_fill_color(new_color) ##Class to manage the Stroke Color of a Button class ButtonStrokeColor(gtk.ColorButton): @@ -655,12 +655,12 @@ class ButtonStrokeColor(gtk.ColorButton): self.set_stroke_color(color) def alloc_color(self, color): - colormap = self._activity._area.get_colormap() + colormap = self._activity.area.get_colormap() return colormap.alloc_color(color.red, color.green, color.blue) def set_stroke_color(self, color): new_color = self.alloc_color(color) - self._activity._area._set_stroke_color(new_color) + self._activity.area._set_stroke_color(new_color) ##Make the Shapes Toolbar class ShapesToolbar(gtk.Toolbar): @@ -735,7 +735,7 @@ class ShapesToolbar(gtk.Toolbar): 'stroke color' : None, 'line shape' : 'circle', 'fill' : True, - 'vertices' : None + 'vertices' : 5 } _SHAPE_RECTANGLE = { 'name' : 'rectangle', @@ -941,7 +941,7 @@ class ShapesToolbar(gtk.Toolbar): fill_color = self._fill_color.get_color() tool['fill color'] = self._fill_color.alloc_color(fill_color) - self._activity._area.set_tool(tool) + self._activity.area.set_tool(tool) #setting cursor: moved to Area @@ -954,7 +954,7 @@ class ShapesToolbar(gtk.Toolbar): def _on_vertices_value_changed(self, spinbutton, tool): - #self._activity._area.polygon_sides = spinbutton.get_value_as_int() + #self._activity.area.polygon_sides = spinbutton.get_value_as_int() tool['vertices'] = spinbutton.get_value_as_int() self.set_tool(tool=tool) @@ -965,7 +965,7 @@ class ShapesToolbar(gtk.Toolbar): def _on_fill_checkbutton_toggled(self, checkbutton, tool): logging.debug('Checkbutton is Active: %s', checkbutton.get_active() ) - #self._activity._area.fill = checkbutton.get_active() + #self._activity.area.fill = checkbutton.get_active() tool['fill'] = checkbutton.get_active() self.set_tool(tool=tool) @@ -1106,7 +1106,7 @@ class ShapesToolbar(gtk.Toolbar): # @param checkbutton # @param data # """ -# self._activity._area.fill = checkbutton.get_active() +# self._activity.area.fill = checkbutton.get_active() def _configure_palette_shape_line(self): logging.debug('Creating palette to shape line') @@ -1183,18 +1183,9 @@ class TextToolbar(gtk.Toolbar): def set_tool(self, widget, tool): #FIXME: this callback must change as others buttons get enabled -# self._activity._area.tool = tool -# -# color = self._text_color.get_color() -# self._text_color.set_fill_color(color) -# -# # setting cursor -# pixbuf = gtk.gdk.pixbuf_new_from_file('./images/text.png') -# cursor = gtk.gdk.Cursor(gtk.gdk.display_get_default() , pixbuf, 6, 21) -# self._activity._area.window.set_cursor(cursor) new_color = self._text_color.get_color() tool['fill color'] = self._text_color.alloc_color(new_color) - self._activity._area.set_tool(tool) + self._activity.area.set_tool(tool) ##Make the Images Toolbar @@ -1253,16 +1244,16 @@ class ImageToolbar(gtk.Toolbar): # self._object_width.connect('clicked', self.resize, activity, 'object-width', self._OBJECT_WIDTH) def rotate_left(self, widget, activity): - #activity._area._rotate_left(widget) + #activity.area._rotate_left(widget) pass def _resize(self, spinButton, tool, activity): size = spinButton.get_value_as_int() - if activity._area.tool == 'marquee-rectangular' and activity._area.selmove: + if activity.area.tool == 'marquee-rectangular' and activity.area.selmove: if tool == "object-height": - activity._area.d.resizeSelection(activity._area,1., float(size)/100) + activity.area.d.resizeSelection(activity.area,1., float(size)/100) elif tool == "object-width": - activity._area.d.resizeSelection(activity._area,float(size)/100, 1.) + activity.area.d.resizeSelection(activity.area,float(size)/100, 1.) def _configure_palette_resize(self, widget, tool, activity): """Set palette for a tool - width or height @@ -1314,7 +1305,7 @@ class ImageToolbar(gtk.Toolbar): logging.debug(file_path) #file_path = decode_path((file_path,))[0] #open(activity, file_path) - activity._area.loadImage(file_path,widget,True) + activity.area.loadImage(file_path,widget,True) elif response == gtk.RESPONSE_CANCEL: logging.debug('Closed, no files selected') @@ -1379,11 +1370,11 @@ class EffectsToolbar(gtk.Toolbar): ##Make the colors be in grayscale def grayscale(self, widget): - self._activity._area.grayscale(widget) + self._activity.area.grayscale(widget) ##Like the brush, but change it color when painting def rainbow(self, widget): - self._activity._area.set_tool(self._EFFECT_RAINBOW) + self._activity.area.set_tool(self._EFFECT_RAINBOW) # setting cursor: moved to Area @@ -1455,7 +1446,7 @@ class EffectsToolbar(gtk.Toolbar): def _on_size_value_changed(self, spinbutton, tool): # size = spinbutton.get_value_as_int() -# self._activity._area.configure_line(size) +# self._activity.area.configure_line(size) tool['line size'] = spinbutton.get_value_as_int() self.rainbow(self._effect_rainbow) -- cgit v0.9.1