Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorflavio <fdanesse@gmail.com>2013-10-25 13:39:17 (GMT)
committer flavio <fdanesse@gmail.com>2013-10-25 13:39:17 (GMT)
commit30afd55ed2c00111f2bee5e9c77654cc2edc03e2 (patch)
treefc406a715cd0bfd0a28f6e85a7b5bf20ea7fb7f1
parent33e7325ae7fd9658dde2ddb966413733c38f864c (diff)
Mantener configuración de formato y vistas por defectogtk2
-rw-r--r--Widgets.py9
-rw-r--r--WorkPanel.py71
2 files changed, 39 insertions, 41 deletions
diff --git a/Widgets.py b/Widgets.py
index ca68241..e64b15f 100644
--- a/Widgets.py
+++ b/Widgets.py
@@ -1711,7 +1711,8 @@ class DialogoFormato(gtk.Dialog):
title = "Seleccione una tipografía",
parent = parent_window,
flags = gtk.DIALOG_MODAL,
- buttons = ("Aceptar", gtk.RESPONSE_ACCEPT,
+ buttons = (
+ "Aceptar", gtk.RESPONSE_ACCEPT,
"Cancelar", gtk.RESPONSE_CANCEL))
self.tamano = tamanio
@@ -1805,10 +1806,8 @@ class DialogoFormato(gtk.Dialog):
gtk.POLICY_AUTOMATIC,
gtk.POLICY_AUTOMATIC)
- tamanos = [8, 9, 10, 11, 12,
- 14, 16, 20, 22, 24, 26,
- 28, 36, 48, 72]
-
+ tamanos = range(6,30)
+
### seteo por defecto
iter = tree.get_model().get_iter_first()
path = 0
diff --git a/WorkPanel.py b/WorkPanel.py
index d1ce40e..db34183 100644
--- a/WorkPanel.py
+++ b/WorkPanel.py
@@ -269,6 +269,12 @@ class Notebook_SourceView(gtk.Notebook):
gtk.Notebook.__init__(self)
+ self.config = {
+ 'fuente':'Monospace',
+ 'tamanio':10,
+ 'numeracion':False,
+ }
+
self.set_scrollable(True)
self.show_all()
@@ -341,7 +347,7 @@ class Notebook_SourceView(gtk.Notebook):
buf = buffer.get_text(inicio, fin, 0)
if not buf: self.remove(pagina)
- sourceview = SourceView()
+ sourceview = SourceView(self.config)
hbox = gtk.HBox()
label = gtk.Label("Sin título")
@@ -416,32 +422,35 @@ class Notebook_SourceView(gtk.Notebook):
### Ver.
if accion == "Numeracion":
for pagina in paginas:
+ self.config['numeracion'] = valor
view = pagina.get_child()
- view.set_accion(accion, valor)
+ view.set_accion(accion, self.config['numeracion'])
elif accion == "Aumentar":
for pagina in paginas:
+ self.config['tamanio'] += 1
+
view = pagina.get_child()
- view.set_formato(tamanio=1)
+ view.set_formato(
+ self.config['fuente'],
+ self.config['tamanio'])
elif accion == "Disminuir":
for pagina in paginas:
+ if self.config['tamanio'] > 6:
+ self.config['tamanio'] -= 1
+
view = pagina.get_child()
- view.set_formato(tamanio=-1)
+ view.set_formato(
+ self.config['fuente'],
+ self.config['tamanio'])
### Código.
elif accion == "Formato":
- scrolled = paginas[self.get_current_page()]
- source = scrolled.get_children()[0]
-
- description = source.get_pango_context().get_font_description()
-
- nombre = description.get_family()
- size = description.get_size()/1000
-
dialogo = DialogoFormato(
parent_window = self.get_toplevel(),
- fuente = nombre, tamanio = size)
+ fuente = self.config['fuente'],
+ tamanio = self.config['tamanio'])
respuesta = dialogo.run()
@@ -450,13 +459,15 @@ class Notebook_SourceView(gtk.Notebook):
if respuesta == gtk.RESPONSE_ACCEPT:
res = dialogo.obtener_fuente()
+ self.config['fuente'] = res[0]
+ self.config['tamanio'] = res[1]
+
for pagina in paginas:
view = pagina.get_child()
view.set_formato(
- tamanio=res[1],
- fuente=res[0],
- dialogo=True)
+ self.config['fuente'],
+ self.config['tamanio'])
else:
sourceview.set_accion(accion)
@@ -533,7 +544,7 @@ class SourceView(gtksourceview2.View):
Visor de código para archivos abiertos.
"""
- def __init__(self):
+ def __init__(self, config):
gtksourceview2.View.__init__(self)
@@ -543,6 +554,8 @@ class SourceView(gtksourceview2.View):
self.lenguaje = False
self.tab = " "
+ self.set_show_line_numbers(config['numeracion'])
+
self.lenguaje_manager = gtksourceview2.LanguageManager()
self.lenguajes = {}
@@ -554,7 +567,8 @@ class SourceView(gtksourceview2.View):
self.set_tab_width(4)
self.set_auto_indent(True)
- self.modify_font(pango.FontDescription('Monospace 10'))
+ font = "%s %s" % (config['fuente'], config['tamanio'])
+ self.modify_font(pango.FontDescription(font))
self.show_all()
@@ -746,7 +760,7 @@ class SourceView(gtksourceview2.View):
### Forzando actualización de Introspección.
self.get_parent().get_parent().emit('new_select', self, True)
- def set_formato(self, fuente=None, tamanio=None, dialogo=False):
+ def set_formato(self, fuente, tamanio):
"""
Setea el formato de la fuente.
@@ -754,24 +768,9 @@ class SourceView(gtksourceview2.View):
fuente es: 'Monospace 10'
"""
- if not fuente and not tamanio: return
+ if not fuente or not tamanio: return
- description = self.get_pango_context().get_font_description()
-
- nombre = description.get_family()
- size = description.get_size()/1000
-
- if type(tamanio) == int and not dialogo:
- size += tamanio
-
- if not fuente:
- fuente = "%s %s" % (nombre, size)
-
- if not dialogo:
- self.modify_font(pango.FontDescription("%s" % fuente))
-
- else:
- self.modify_font(pango.FontDescription("%s %s" % (fuente, tamanio)))
+ self.modify_font(pango.FontDescription("%s %s" % (fuente, tamanio)))
def set_accion(self, accion, valor = True):
"""