diff options
author | Gonzalo Odiard <godiard@gmail.com> | 2013-04-12 11:25:24 (GMT) |
---|---|---|
committer | Gonzalo Odiard <godiard@gmail.com> | 2013-04-12 11:25:24 (GMT) |
commit | 5b0b4bf9e55eed42d8dd138d5b8cf438c27cd2dc (patch) | |
tree | 2e9d528433b4b52afea5dc8ad8f91705b03026b2 | |
parent | cdb6b535d9209df540e5da657300326131bf67bc (diff) |
Manage the case of Globes without text (Images)
The class Imagen is a Globo, but with texto = None. This patch
contemplate all the cases where text can be None.
Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
-rw-r--r-- | globos.py | 31 | ||||
-rw-r--r-- | historietaactivity.py | 6 | ||||
-rw-r--r-- | persistencia.py | 33 | ||||
-rw-r--r-- | toolbar.py | 10 |
4 files changed, 44 insertions, 36 deletions
@@ -71,7 +71,8 @@ class Globo: def set_selected(self, selected): logging.error('Set selected %s', selected) self.selec = selected - self.texto.set_edition_mode(selected) + if self.texto is not None: + self.texto.set_edition_mode(selected) def imprimir(self, context): #dibujo al globo de dialogo @@ -126,7 +127,8 @@ class Globo: context.restore() # se dibuja el correspondiente texto - self.texto.imprimir(context) + if self.texto is not None: + self.texto.imprimir(context) self.dibujar_controles(context) def dibujar_controles(self, context): @@ -203,7 +205,8 @@ class Globo: else: self.y = self.alto - self.texto.mover_a(self.x, self.y) + if self.texto is not None: + self.texto.mover_a(self.x, self.y) def get_cursor_type(self, x, y): cursor = None @@ -232,7 +235,8 @@ class Globo: (self.y - self.alto) < y < (self.y + self.alto): self.selec = True - self.texto.mostrar_cursor = True + if self.texto is not None: + self.texto.mostrar_cursor = True #Obtiene la posicion donde se selecciono con el mouse self.dx = self.x - x @@ -320,7 +324,8 @@ class Globo: def set_dimension(self, x, y, rect): # set the text in edition mode to use the textview # to meassure the minimal size needed - self.texto.set_edition_mode(True) + if self.texto is not None: + self.texto.set_edition_mode(True) # if I am changing the size from the right or from the bottom # change x / y to calculate like if changing from @@ -352,8 +357,13 @@ class Globo: new_height = rect.height - self.y # try resize the text object - ancho_text, alto_text = self.calc_area_texto(new_width, new_height) - self.texto.set_dimension(ancho_text, alto_text) + if self.texto is not None: + ancho_text, alto_text = self.calc_area_texto(new_width, new_height) + self.texto.set_dimension(ancho_text, alto_text) + else: + # if there are not text object, the size can be changed + self.ancho = new_width + self.alto = new_height def calc_area_texto(self, width, height): """ @@ -367,8 +377,9 @@ class Globo: """ Calculate the min globe size, based in the text size """ - self.ancho = self.texto.ancho / (1 - 12 / (self.radio * 1.0)) - self.alto = self.texto.alto / (1 - 12 / (self.radio * 1.0)) + if self.texto is not None: + self.ancho = self.texto.ancho / (1 - 12 / (self.radio * 1.0)) + self.alto = self.texto.alto / (1 - 12 / (self.radio * 1.0)) def girar(self): if (self.__class__ == Rectangulo): @@ -719,7 +730,7 @@ class Imagen(Globo): self.icon_buffer = _IconBuffer() self.icon_buffer.file_name = os.path.join(appdir, imagen) self.icon_buffer.stroke_color = '#000000' - self.texto = CuadroTexto(self, 20, 20, font_name) + self.texto = None def set_selected(self, selected): self.selec = selected diff --git a/historietaactivity.py b/historietaactivity.py index ae9e7c1..1a389c3 100644 --- a/historietaactivity.py +++ b/historietaactivity.py @@ -518,13 +518,13 @@ class ComicBox(Gtk.EventBox): self.show_all() def set_globo_activo(self, globo): - if globo == None: - if self._globo_activo != None: + if globo is None: + if self._globo_activo is not None: self._globo_activo.set_selected(False) else: globo.set_selected(True) self._globo_activo = globo - if (globo != None): + if globo is not None and globo.texto is not None: self._page._text_toolbar.setToolbarState(globo.texto) def redraw(self): diff --git a/persistencia.py b/persistencia.py index dda4829..5681568 100644 --- a/persistencia.py +++ b/persistencia.py @@ -57,19 +57,15 @@ class Persistence: if (globo.__class__ == globos.Imagen): globoData['image_name'] = globo.image_name globoData['x'], globoData['y'] = globo.x, globo.y - #globoData.ancho_text, globoData.alto_text = - #globo.ancho_text, globo.alto_text - globoData['text_width'] = globo.texto.ancho - globoData['text_height'] = globo.texto.alto - globoData['text_text'] = globo.texto.text - globoData['text_color'] = globo.texto.color + if globo.texto is not None: + globoData['text_width'] = globo.texto.ancho + globoData['text_height'] = globo.texto.alto + globoData['text_text'] = globo.texto.text + globoData['text_color'] = globo.texto.color - globoData['text_font_description'] =\ - globo.texto.font_description - - #globoData['text_show_border'] = globo.texto.mostrar_borde - #globoData['text_show_cursor'] = globo.texto.mostrar_cursor + globoData['text_font_description'] = \ + globo.texto.font_description boxData['globes'].append(globoData) pageData['boxs'].append(boxData) @@ -157,7 +153,7 @@ class Persistence: x=globo_x, y=globo_y) globo.direccion = globo_direccion - if globo != None: + if globo is not None: globo.radio = globoData['radio'] globo.ancho, globo.alto = globoData['width'], \ globoData['height'] @@ -168,13 +164,14 @@ class Persistence: globo.x, globo.y = globoData['x'], globoData['y'] - globo.texto.ancho = globoData['text_width'] - globo.texto.alto = globoData['text_height'] - globo.texto.text = globoData['text_text'] - globo.texto.color = globoData['text_color'] + if (tipo_globo != 'IMAGE'): + globo.texto.ancho = globoData['text_width'] + globo.texto.alto = globoData['text_height'] + globo.texto.text = globoData['text_text'] + globo.texto.color = globoData['text_color'] - globo.texto.set_font_description( - globoData['text_font_description']) + globo.texto.set_font_description( + globoData['text_font_description']) box.globos.append(globo) @@ -303,20 +303,20 @@ class TextToolbar(Gtk.Toolbar): def _bold_cb(self, button): globo_activo = self._page.get_globo_activo() - if (globo_activo != None): + if globo_activo is not None and globo_activo.texto is not None: globo_activo.texto.bold = not globo_activo.texto.bold self._page.get_active_box().redraw() def _italic_cb(self, button): globo_activo = self._page.get_globo_activo() - if (globo_activo != None): + if globo_activo is not None and globo_activo.texto is not None: globo_activo.texto.italic = not globo_activo.texto.italic self._page.get_active_box().redraw() # para la version 0.82 def _text_color_cb(self, button): globo_activo = self._page.get_globo_activo() - if (globo_activo != None): + if globo_activo is not None and globo_activo.texto is not None: color = self._text_color.get_color() texto = globo_activo.texto texto.color = (color.red, color.green, color.blue) @@ -327,7 +327,7 @@ class TextToolbar(Gtk.Toolbar): size = int(self._font_sizes[self._font_size_combo.get_active()]) logger.debug('Setting font size: %d', size) globo_activo = self._page.get_globo_activo() - if (globo_activo != None): + if globo_activo is not None and globo_activo.texto is not None: globo_activo.texto.font_size = size globo_activo.texto.alto_renglon = size self._page.get_active_box().redraw() @@ -337,7 +337,7 @@ class TextToolbar(Gtk.Toolbar): font_name = self._font_combo.get_font_name() logger.debug('Setting font name: %s', font_name) globo_activo = self._page.get_globo_activo() - if (globo_activo != None): + if globo_activo is not None and globo_activo.texto is not None: globo_activo.texto.font_type = font_name self._page.selected_font_name = font_name self._page.get_active_box().redraw() |