Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCristian García <cristian99garcia@gmail.com>2013-04-19 00:04:49 (GMT)
committer Cristian García <cristian99garcia@gmail.com>2013-04-19 00:04:49 (GMT)
commit1ce0fa553ad6e13ae5b91fc8c3a6bf13148c62cd (patch)
treeb33d55235fa7aac67051fbb63d1eb8aaa3c9e083
parent86832793666cd99c6a344db258894ea580804f99 (diff)
Configurando colores para Sugar
-rw-r--r--CExplorer.py93
-rw-r--r--CExplorer.pycbin8796 -> 9540 bytes
-rw-r--r--Widgets.py42
-rw-r--r--Widgets.pycbin12549 -> 13430 bytes
-rw-r--r--window.py42
5 files changed, 117 insertions, 60 deletions
diff --git a/CExplorer.py b/CExplorer.py
index 7f8f735..316022c 100644
--- a/CExplorer.py
+++ b/CExplorer.py
@@ -20,6 +20,19 @@ from sugar3.activity.widgets import ActivityToolbarButton
from sugar3.graphics.toolbarbox import ToolbarBox
from sugar3.graphics.toolbutton import ToolButton
+screen = Gdk.Screen.get_default()
+css_provider = Gtk.CssProvider()
+
+style_path = 'CExplorer.css'
+
+css_provider.load_from_path(style_path)
+context = Gtk.StyleContext()
+
+context.add_provider_for_screen(
+ screen,
+ css_provider,
+ Gtk.STYLE_PROVIDER_PRIORITY_USER)
+
class CExplorer(activity.Activity):
@@ -44,9 +57,6 @@ class CExplorer(activity.Activity):
self.area_montajes = Wid.Area_de_Montajes(self)
self.area = Wid.Area(self)
- self.entrada.connect('activate', self.nueva_direccion)
- self.entrada.connect('icon-release', self.nueva_direccion)
-
#****** Toolbar ******
toolbarbox = ToolbarBox()
activity_button = ActivityToolbarButton(self)
@@ -60,12 +70,6 @@ class CExplorer(activity.Activity):
b_refresh = ToolButton(Gtk.STOCK_REFRESH)
b_ocults = Gtk.ToolButton(Gtk.STOCK_YES)
- b_harddisk.connect('clicked', self.nueva_direccion, '/')
- b_home.connect('clicked', self.nueva_direccion, '~')
- b_go_up.connect('clicked', self.abrir_arriba)
- b_refresh.connect('clicked', self.update)
- b_ocults.connect('clicked', self.change_ocultos)
-
b_harddisk.set_tooltip_text('Abrir al directorio raíz')
b_home.set_tooltip_text('Abrir al directorio personal')
b_go_up.set_tooltip_text('Abrir al la carpeta contenedora de la actual')
@@ -104,6 +108,13 @@ class CExplorer(activity.Activity):
self.entrada.activate()
+ self.entrada.connect('activate', self.nueva_direccion)
+ self.area_montajes.connect('change-directory', self.abrir_desde_widget)
+ b_harddisk.connect('clicked', self.nueva_direccion, '/')
+ b_home.connect('clicked', self.nueva_direccion, '~')
+ b_go_up.connect('clicked', self.abrir_arriba)
+ b_refresh.connect('clicked', self.update)
+ b_ocults.connect('clicked', self.change_ocultos)
self.connect('destroy', Gtk.main_quit)
self.connect('key-press-event', self.tecla_presionada)
self.connect('change-directory', self.borrar_todo)
@@ -114,6 +125,8 @@ class CExplorer(activity.Activity):
def abrir(self, directorio):
"""Abre el directorio especificado"""
+ texto = False
+
if os.path.isdir(directorio) or os.path.ismount(directorio):
# Sí es que no exíste, devolverá False
@@ -150,10 +163,29 @@ class CExplorer(activity.Activity):
self.area.agregar(archivo, self.direccion)
elif os.path.isfile(directorio):
- print 'La dirección es un archivo'
+ Archivos.intentar_abrir(directorio)
+ self.estado_cambiado()
else:
- print 'La dirección no existe'
+ texto = 'inexistente'
+
+ if texto:
+ dialogo = DialogoError(str(texto), directorio, self)
+
+ dialogo.show_all()
+
+ try:
+ self.abrir(self.direccion)
+
+ except:
+ try:
+ direccion = Archivos.get_direccion_arriba(self.direccion)
+ self.abrir(direccion)
+
+ except:
+ self.abrir(os.path.expanduser('~'))
+
+ self.estado_cambiado()
def tecla_presionada(self, widget, event):
@@ -180,10 +212,20 @@ class CExplorer(activity.Activity):
if lectura and escritura:
self.borrar_archivo()
+ elif tecla == 65293:
+ self.abrir(direccion)
+
+ elif tecla == 65288:
+ self.abrir_arriba()
+
if tecla == 43:
if lectura and escritura:
self.crear_directorio()
+ def abrir_desde_widget(self, widget, direccion):
+
+ self.abrir(direccion)
+
def crear_directorio(self, *args):
lectura, escritura, ejecucion = Archivos.get_permisos(self.direccion)
@@ -203,6 +245,10 @@ class CExplorer(activity.Activity):
borrar.connect('borrado', self.update)
borrar.show_all()
+ def state_changed(self, widget, state):
+
+ pass
+
def preferencias(self, *args):
direccion = self.get_nueva_direccion()
@@ -248,23 +294,9 @@ class CExplorer(activity.Activity):
def abrir_arriba(self, *args):
"""Abre la carpeta que contiene la actual"""
- list = self.direccion.split('/')
-
- try:
- direccion = '/'
- numero = len(list) - 1
- while not bool(list[numero]):
- numero -= 1
-
- for directorio in list[:numero]:
- if directorio:
- direccion = direccion + directorio + '/'
-
- except IndexError:
- direccion = '/'
+ self.direccion = Archivos.get_carpeta_contenedora(self.direccion)
- self.direccion = direccion
- self.entrada.set_text(direccion)
+ self.entrada.set_text(self.direccion)
self.entrada.activate()
self.update()
@@ -274,14 +306,11 @@ class CExplorer(activity.Activity):
self.ocultos = not self.ocultos
if self.ocultos:
- stock = Gtk.STOCK_NO
- widget.set_tooltip_text('No mostrar archivos ocultos')
+ widget.set_icon_name(Gtk.STOCK_NO)
else:
- stock = Gtk.STOCK_YES
- widget.set_tooltip_text('Mostrar archivos ocultos')
+ widget.set_icon_name(Gtk.STOCK_YES)
- widget.set_icon_name(stock)
self.update()
def get_nueva_direccion(self):
diff --git a/CExplorer.pyc b/CExplorer.pyc
index b8bdad3..7383820 100644
--- a/CExplorer.pyc
+++ b/CExplorer.pyc
Binary files differ
diff --git a/Widgets.py b/Widgets.py
index 776f3ca..c6c5896 100644
--- a/Widgets.py
+++ b/Widgets.py
@@ -18,6 +18,9 @@ class Area_de_Montajes(Gtk.TreeView):
"""Parte de la entana en la que se muestran
los montajes actualmente introducidos"""
+ __gsinglas__ = {'change-directory': (GObject.SIGNAL_RUN_FIRST,
+ GObject.TYPE_NONE, (GObject.TYPE_STRING,))}
+
def __init__(self, padre):
"""Inicia la clase"""
@@ -129,7 +132,7 @@ class Area_de_Montajes(Gtk.TreeView):
def abrir(self, widget, direccion):
"""Abre la dirección del montaje seleccionado"""
- self.padre.abrir(direccion)
+ self.emit('change-directory', direccion)
def copiar(self, widget, direccion):
@@ -147,7 +150,7 @@ class Area(Gtk.IconView):
__gsignals__ = {
'cambio-de-direccion': (GObject.SIGNAL_RUN_FIRST,
GObject.TYPE_NONE, (GObject.TYPE_STRING,)),
- 'cambio-de-texto': (GObject.SIGNAL_RUN_FIRST,
+ 'cambio-de-mensaje': (GObject.SIGNAL_RUN_FIRST,
GObject.TYPE_NONE, (GObject.TYPE_STRING,))}
def __init__(self, padre):
@@ -187,8 +190,8 @@ class Area(Gtk.IconView):
archivos = Archivos.get_tamanio(direccion)
string = ' - ' + archivos
- self.padre.b_estado.set_text('Se ha seleccionado: ',
- direccion, string)
+ mensaje = 'se ha seleccionada: ' + direccion + string
+ self.emit('cambio-de-mensaje', mensaje)
else:
self.padre.b_estado.set_text('')
@@ -240,7 +243,10 @@ class Area(Gtk.IconView):
self.emit('cambio-de-direccion', direccion)
except TypeError:
- # Solo sucede cuando se le hace clic fuera de un iter
+
+ # Solo sucede cuando se le hace clic fuera de un iter,
+ # por eso lo dejo pasar
+
pass
def crear_menu_emergente(self, boton, tiempo, path):
@@ -283,7 +289,7 @@ class Area(Gtk.IconView):
def abrir(self, widget, direccion):
"""Abre la dirección del montaje seleccionado"""
- self.padre.abrir(direccion)
+ self.emit('change-directory', direccion)
def copiar(self, widget, direccion):
@@ -303,8 +309,32 @@ class Entrada(Gtk.Entry):
Gtk.Entry.__init__(self)
+ self.modelo = Gtk.ListStore(str)
+ completion = Gtk.EntryCompletion()
+
+ completion.set_model(self.modelo)
+ completion.set_text_column(0)
+
self.set_size_request(400, 40)
self.set_text(direccion)
+ self.set_placeholder_text(os.path.expanduser('Dirección'))
+ self.set_completion(completion)
+
+ self.connect('changed', self.changed)
+
+ def changed(self, widget):
+
+ texto = widget.get_text()
+
+ if os.path.exists(texto) and not os.path.isfile(texto) and texto[-1] == '/':
+ lista = os.listdir(texto)
+
+ self.modelo.clear()
+
+ for x in lista:
+ self.modelo.append([texto + x])
+
+ self.show_all()
class Barra_de_Estado(Gtk.Statusbar):
diff --git a/Widgets.pyc b/Widgets.pyc
index 6454bdf..c07a610 100644
--- a/Widgets.pyc
+++ b/Widgets.pyc
Binary files differ
diff --git a/window.py b/window.py
index 1e72ef9..261624a 100644
--- a/window.py
+++ b/window.py
@@ -25,7 +25,7 @@ screen = Gdk.Screen.get_default()
css_provider = Gtk.CssProvider()
style_path = 'CExplorer.css'
-
+
css_provider.load_from_path(style_path)
context = Gtk.StyleContext()
@@ -35,9 +35,6 @@ context.add_provider_for_screen(
Gtk.STYLE_PROVIDER_PRIORITY_USER)
-Gdk.threads_init()
-
-
class CExplorer(Gtk.Window):
__gsignals__ = {
@@ -67,8 +64,7 @@ class CExplorer(Gtk.Window):
self.area = Area(self)
self.spinner = Gtk.Spinner()
- self.entrada.connect('activate', self.nueva_direccion)
- self.entrada.connect('icon-release', self.nueva_direccion)
+ self.entrada.modify_fg(Gtk.StateType.NORMAL, Gdk.color_parse("red"))
#****** Toolbar ******
toolbar = Gtk.Toolbar()
@@ -87,15 +83,6 @@ class CExplorer(Gtk.Window):
b_preferences = Gtk.ToolButton()
item = Gtk.ToolItem()
- b_harddisk.connect('clicked', self.nueva_direccion, '/')
- b_home.connect('clicked', self.nueva_direccion, '~')
- b_go_up.connect('clicked', self.abrir_arriba)
- b_refresh.connect('clicked', self.update)
- b_ocults.connect('clicked', self.change_ocultos)
- b_create.connect('clicked', self.crear_directorio)
- b_remove.connect('clicked', self.borrar_archivo)
- b_preferences.connect('clicked', self.preferencias)
-
b_harddisk.set_tooltip_text('Dirigirse al directorio raíz')
b_home.set_tooltip_text('Dirigirse al directorio personal')
b_go_up.set_tooltip_text('Dirigirse al directorio anterior al actual')
@@ -125,14 +112,25 @@ class CExplorer(Gtk.Window):
paned.pack1(scrolled_montajes, False, True)
paned.pack2(scrolled, True, True)
- self.entrada.activate()
-
+ self.entrada.connect('activate', self.nueva_direccion)
self.area.connect('cambio-de-direccion', self.abrir_desde_widget)
+ self.area.connect('cambio-de-mensaje', self.cambio_de_mensaje)
self.connect('destroy', Gtk.main_quit)
self.connect('key-press-event', self.tecla_presionada)
self.connect('change-directory', self.borrar_todo)
self.connect('estado-cambiado', self.estado_cambiado)
+ b_harddisk.connect('clicked', self.nueva_direccion, '/')
+ b_home.connect('clicked', self.nueva_direccion, '~')
+ b_go_up.connect('clicked', self.abrir_arriba)
+ b_refresh.connect('clicked', self.update)
+ b_ocults.connect('clicked', self.change_ocultos)
+ b_create.connect('clicked', self.crear_directorio)
+ b_remove.connect('clicked', self.borrar_archivo)
+ b_preferences.connect('clicked', self.preferencias)
+
+ self.abrir(self.direccion)
+
self.add(self.vbox)
self.show_all()
@@ -179,7 +177,6 @@ class CExplorer(Gtk.Window):
elif os.path.isfile(directorio):
Archivos.intentar_abrir(directorio)
- self.estado_cambiado()
else:
texto = 'inexistente'
@@ -200,8 +197,6 @@ class CExplorer(Gtk.Window):
except:
self.abrir(os.path.expanduser('~'))
- self.estado_cambiado()
-
self.emit('estado-cambiado', 'parado')
def estado_cambiado(self, widget, estado):
@@ -215,7 +210,6 @@ class CExplorer(Gtk.Window):
def tecla_presionada(self, widget, event):
tecla = event.keyval
- print tecla
direccion = self.direccion
if direccion[-1] != '/':
@@ -223,7 +217,7 @@ class CExplorer(Gtk.Window):
lectura, escritura, ejecucion = Archivos.get_permisos(self.direccion)
- if self.area.get_selected_items():
+ if self.area.get_selected_items() and self.area.has_focus():
path = self.area.get_selected_items()[0]
iter = self.area.modelo.get_iter(path)
@@ -311,6 +305,10 @@ class CExplorer(Gtk.Window):
self.area.borrar_area()
self.b_estado.borrar()
+ def cambio_de_mensaje(self, widget, mensaje):
+
+ self.b_estado.set_text(mensaje)
+
def update(self, *args):
"""Recarga el directorio acual"""