Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Moonwidgets.py
diff options
context:
space:
mode:
Diffstat (limited to 'Moonwidgets.py')
-rw-r--r--Moonwidgets.py156
1 files changed, 82 insertions, 74 deletions
diff --git a/Moonwidgets.py b/Moonwidgets.py
index 2281916..f50a262 100644
--- a/Moonwidgets.py
+++ b/Moonwidgets.py
@@ -30,38 +30,48 @@
# Traducciones a Español:
# Ana Cichero <ana.cichero@gmail.com> CeibalJAM! - Uruguay
-import gtk, pygtk, gobject, math, time, os, calendar
+import math
+import time
+import os
+import calendar
+
+import gi
+from gi.repository import Gtk
+from gi.repository import Gdk
+from gi.repository import GdkPixbuf
+from gi.repository import GObject
+
from gettext import gettext as _
import MoonGlobals as MG
-class CalendarButton(gtk.EventBox):
+class CalendarButton(Gtk.EventBox):
__gsignals__ = {
- "clicked":(gobject.SIGNAL_RUN_FIRST,
- gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT, )),
- "clickederecho":(gobject.SIGNAL_RUN_FIRST,
- gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT, ))}
+ "clicked":(GObject.SIGNAL_RUN_FIRST,
+ GObject.TYPE_NONE, (GObject.TYPE_PYOBJECT, )),
+ "clickederecho":(GObject.SIGNAL_RUN_FIRST,
+ GObject.TYPE_NONE, (GObject.TYPE_PYOBJECT, ))}
def __init__(self, anio, mes, d, hora):
- gtk.EventBox.__init__(self)
+ Gtk.EventBox.__init__(self)
self.set_visible_window(True)
- self.modify_bg(gtk.STATE_NORMAL, MG.BACKGROUND)
+ self.modify_bg(Gtk.StateType.NORMAL, MG.BACKGROUND)
self.add_events(
- gtk.gdk.BUTTON_PRESS_MASK |
- gtk.gdk.BUTTON_RELEASE_MASK |
- gtk.gdk.POINTER_MOTION_MASK |
- gtk.gdk.ENTER_NOTIFY_MASK |
- gtk.gdk.LEAVE_NOTIFY_MASK)
+ Gdk.EventMask.BUTTON_PRESS_MASK |
+ Gdk.EventMask.BUTTON_RELEASE_MASK |
+ Gdk.EventMask.POINTER_MOTION_MASK |
+ Gdk.EventMask.ENTER_NOTIFY_MASK |
+ Gdk.EventMask.LEAVE_NOTIFY_MASK)
self.imagen_size = 50
self.image_pixmap = None
icono = os.path.join(MG.ICONOS,"moon.jpg")
- self.moon_stamp = gtk.gdk.pixbuf_new_from_file(icono)
- self.image = gtk.Image()
- self.fixed = gtk.Fixed()
+ self.moon_stamp = GdkPixbuf.Pixbuf.new_from_file(icono)
+ self.image = Gtk.Image()
+ self.fixed = Gtk.Fixed()
self.hemisphere_view = _('Sur')
self.show_grid = False
@@ -92,9 +102,9 @@ class CalendarButton(gtk.EventBox):
mes= meses[t.tm_mon -1]
dia= dias[t.tm_wday]
fecha= "%s %s de %s de %s" % (dia, self.dia, mes, self.anio)
- self.set_tooltip(fecha)
- label = gtk.Label(str(self.dia))
- label.modify_fg(gtk.STATE_NORMAL, MG.FOREGROUND)
+ self.set_tooltip_text(fecha)
+ label = Gtk.Label(str(self.dia))
+ label.modify_fg(Gtk.StateType.NORMAL, MG.FOREGROUND)
self.fixed.put(label, 0, 0)
self.connect("button_press_event", self.button_press)
@@ -121,13 +131,6 @@ class CalendarButton(gtk.EventBox):
self.emit("clickederecho", event)
# --------------------------- EVENTOS --------------------------
- # --------------------------- SETEOS ---------------------------
- def set_tooltip(self, texto):
-
- tooltips = gtk.Tooltips()
- tooltips.set_tip(self, texto, tip_private=None)
- # --------------------------- SETEOS ---------------------------
-
def toggle_grid_clicked(self, widget= None):
if self.show_grid == True:
@@ -152,17 +155,18 @@ class CalendarButton(gtk.EventBox):
self.actualizar()
def actualizar(self):
-
+ pass
+ '''
if self.dia <= 0: return
- self.image_pixmap = gtk.gdk.Pixmap(self.window, self.imagen_size, self.imagen_size)
+ self.image_pixmap = Gtk.gdk.Pixmap(self.window, self.imagen_size, self.imagen_size)
gc = self.image_pixmap.new_gc(foreground=MG.BACKGROUND)
self.image.set_from_pixmap(self.image_pixmap, None)
self.image_pixmap.draw_rectangle(gc, True, 0, 0, self.imagen_size, self.imagen_size)
# Create a 1bit shadow mask
- mask_pixmap = gtk.gdk.Pixmap(None, self.imagen_size, self.imagen_size, depth=1)
+ mask_pixmap = Gtk.gdk.Pixmap(None, self.imagen_size, self.imagen_size, depth=1)
kgc = mask_pixmap.new_gc(foreground=MG.BACKGROUND)
wgc = mask_pixmap.new_gc(foreground=MG.FOREGROUND)
@@ -170,10 +174,10 @@ class CalendarButton(gtk.EventBox):
mask_pixmap = self.draw_fase_moon(mask_pixmap, kgc, wgc)
maskgc = self.image_pixmap.new_gc(clip_mask=mask_pixmap)
- moon_pixbuf = self.moon_stamp.scale_simple(self.imagen_size, self.imagen_size, gtk.gdk.INTERP_BILINEAR)
+ moon_pixbuf = self.moon_stamp.scale_simple(self.imagen_size, self.imagen_size, Gtk.gdk.INTERP_BILINEAR)
# Composite bright Moon image and semi-transparant Moon for shadow detail
- dark_pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, self.imagen_size, self.imagen_size)
+ dark_pixbuf = Gtk.gdk.Pixbuf(Gtk.gdk.COLORSPACE_RGB, True, 8, self.imagen_size, self.imagen_size)
dark_pixbuf.fill(0x00000000)
uno = (self.data_model.next_lunar_eclipse_sec == -1 and self.data_model.last_lunar_eclipse_sec > 7200)
@@ -181,7 +185,7 @@ class CalendarButton(gtk.EventBox):
tres = min([self.data_model.next_lunar_eclipse_sec, self.data_model.last_lunar_eclipse_sec]) > 7200
if uno or dos or tres: #print "Normal Moon phase render"
- moon_pixbuf.composite(dark_pixbuf, 0, 0, self.imagen_size, self.imagen_size, 0, 0, 1, 1, gtk.gdk.INTERP_BILINEAR, 127)
+ moon_pixbuf.composite(dark_pixbuf, 0, 0, self.imagen_size, self.imagen_size, 0, 0, 1, 1, Gtk.gdk.INTERP_BILINEAR, 127)
self.image_pixmap.draw_pixbuf(gc, dark_pixbuf, 0, 0, 0, 0) # parte oscura
self.image_pixmap.draw_pixbuf(maskgc, moon_pixbuf, 0, 0, 0, 0) # parte iluminada
@@ -197,31 +201,32 @@ class CalendarButton(gtk.EventBox):
self.data_model.last_lunar_eclipse_sec]) / 7200.0 * 256
moon_pixbuf.composite(dark_pixbuf, 0, 0, self.imagen_size, self.imagen_size,
- 0, 0, 1, 1, gtk.gdk.INTERP_BILINEAR, int(196 - eclipse_alpha / 2))
+ 0, 0, 1, 1, Gtk.gdk.INTERP_BILINEAR, int(196 - eclipse_alpha / 2))
self.image_pixmap.draw_pixbuf(gc, dark_pixbuf, 0, 0, 0, 0)
- dark_pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, self.imagen_size, self.imagen_size)
+ dark_pixbuf = Gtk.gdk.Pixbuf(Gtk.gdk.COLORSPACE_RGB, True, 8, self.imagen_size, self.imagen_size)
moon_pixbuf.composite(dark_pixbuf, 0, 0, self.imagen_size, self.imagen_size,
- 0, 0, 1, 1, gtk.gdk.INTERP_BILINEAR, int(eclipse_alpha))
- rgc = self.image_pixmap.new_gc(foreground=MG.BLUEGREENMASK, function=gtk.gdk.AND)
+ 0, 0, 1, 1, Gtk.gdk.INTERP_BILINEAR, int(eclipse_alpha))
+ rgc = self.image_pixmap.new_gc(foreground=MG.BLUEGREENMASK, function=Gtk.gdk.AND)
self.image_pixmap.draw_rectangle(rgc, True, 0, 0, self.imagen_size, self.imagen_size)
self.image_pixmap.draw_pixbuf(gc, dark_pixbuf, 0, 0, 0, 0)
if self.hemisphere_view == _('Sur'):
#print "Rotate final image for a view from Norte or Sur hemisphere"
- rot_pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, self.imagen_size, self.imagen_size)
+ rot_pixbuf = Gtk.gdk.Pixbuf(Gtk.gdk.COLORSPACE_RGB, False, 8, self.imagen_size, self.imagen_size)
rot_pixbuf.get_from_drawable(self.image_pixmap, self.image_pixmap.get_colormap(), 0, 0, 0, 0, -1, -1)
- rot_pixbuf = rot_pixbuf.rotate_simple(gtk.gdk.PIXBUF_ROTATE_UPSIDEDOWN)
+ rot_pixbuf = rot_pixbuf.rotate_simple(Gtk.gdk.PIXBUF_ROTATE_UPSIDEDOWN)
self.image_pixmap.draw_pixbuf(gc, rot_pixbuf, 0, 0, 0, 0)
if self.show_grid: self.draw_grid(_("SNWE"))
else:
- if self.show_grid: self.draw_grid(_("NSEW"))
+ if self.show_grid: self.draw_grid(_("NSEW"))'''
def draw_grid(self, compass_text):
-
+ pass
+ '''
# Draw Selenographic grid line data.
rgc = self.image_pixmap.new_gc(foreground=MG.RED)
bgc = self.image_pixmap.new_gc(foreground=MG.BLUE)
@@ -289,10 +294,11 @@ class CalendarButton(gtk.EventBox):
pango_layout.set_text(compass_text[2])
self.image_pixmap.draw_layout(rgc, 72 + 15, 36 + 15, pango_layout)
pango_layout.set_text(compass_text[3])
- self.image_pixmap.draw_layout(rgc, 15, 36 + 15, pango_layout)
+ self.image_pixmap.draw_layout(rgc, 15, 36 + 15, pango_layout)'''
def draw_fase_moon(self, mask_pixmap, kgc, wgc):
-
+ pass
+ '''
if self.data_model.phase_of_moon <= .25:
#print "New Moon to First Quarter"
phase_shadow_adjust = self.data_model.phase_of_moon - abs(math.sin(self.data_model.phase_of_moon * math.pi * 4) / 18.0)
@@ -321,7 +327,7 @@ class CalendarButton(gtk.EventBox):
mask_pixmap.draw_rectangle(wgc, True, 0, 0, self.imagen_size/2, self.imagen_size) # mitad de luna blanca
mask_pixmap.draw_arc(kgc, True, self.imagen_size/2 - int(arc_scale / 2), 0, arc_scale, self.imagen_size, 5760, 11520)
- return mask_pixmap
+ return mask_pixmap'''
class DataModel():
@@ -451,13 +457,13 @@ class DataModel():
else:
return _("New Moon")
-class MoonCalendar(gtk.AspectFrame):
+class MoonCalendar(Gtk.AspectFrame):
def __init__(self):
- gtk.AspectFrame.__init__(self)
+ Gtk.AspectFrame.__init__(self)
- self.modify_bg(gtk.STATE_NORMAL, MG.BACKGROUND)
+ self.modify_bg(Gtk.StateType.NORMAL, MG.BACKGROUND)
self.anio = None
self.mes = None
self.fecha = None
@@ -471,52 +477,54 @@ class MoonCalendar(gtk.AspectFrame):
def layout(self):
- base = gtk.VBox()
- caja_control = gtk.HBox()
+ base = Gtk.VBox()
+ caja_control = Gtk.HBox()
- view_tool_bar = gtk.Toolbar()
- view_tool_bar.modify_bg(gtk.STATE_NORMAL, MG.BACKGROUND)
+ view_tool_bar = Gtk.Toolbar()
+ view_tool_bar.modify_bg(Gtk.StateType.NORMAL, MG.BACKGROUND)
- boton = gtk.ToggleToolButton()
- pixbuf= gtk.gdk.pixbuf_new_from_file_at_size(os.path.join(MG.ICONOS,'flecha-ico.svg'), 32, 32)
- imagen = gtk.Image()
+ boton = Gtk.ToggleToolButton()
+ boton.connect('clicked', self.anterior)
+ pixbuf= GdkPixbuf.Pixbuf.new_from_file_at_size(os.path.join(MG.ICONOS,'flecha-ico.svg'), 32, 32)
+ imagen = Gtk.Image()
imagen.set_from_pixbuf(pixbuf)
boton.set_icon_widget(imagen)
imagen.show()
boton.show()
- view_tool_bar.append_item("", "", "",boton, self.anterior, user_data=None)
- boton.modify_bg(gtk.STATE_NORMAL, MG.BACKGROUND)
+ view_tool_bar.insert(boton, -1)
+ boton.modify_bg(Gtk.StateType.NORMAL, MG.BACKGROUND)
caja_control.pack_start(view_tool_bar, False, False, 0)
- self.label_mes = gtk.Label()
- self.label_mes.modify_bg(gtk.STATE_NORMAL, MG.BACKGROUND)
- self.label_mes.modify_fg(gtk.STATE_NORMAL, MG.FOREGROUND)
+ self.label_mes = Gtk.Label()
+ self.label_mes.modify_bg(Gtk.StateType.NORMAL, MG.BACKGROUND)
+ self.label_mes.modify_fg(Gtk.StateType.NORMAL, MG.FOREGROUND)
self.label_mes.show()
caja_control.pack_start(self.label_mes, True, True, 0)
- view_tool_bar = gtk.Toolbar()
- view_tool_bar.modify_bg(gtk.STATE_NORMAL, MG.BACKGROUND)
+ view_tool_bar = Gtk.Toolbar()
+ view_tool_bar.modify_bg(Gtk.StateType.NORMAL, MG.BACKGROUND)
- boton = gtk.ToggleToolButton()
- pixbuf= gtk.gdk.pixbuf_new_from_file_at_size(os.path.join(MG.ICONOS,'flecha-ico.svg'), 32, 32)
+ boton = Gtk.ToggleToolButton()
+ boton.connect('clicked', self.siguiente)
+ pixbuf= GdkPixbuf.Pixbuf.new_from_file_at_size(os.path.join(MG.ICONOS,'flecha-ico.svg'), 32, 32)
pixbuf= pixbuf.flip(1)
- imagen = gtk.Image()
+ imagen = Gtk.Image()
imagen.set_from_pixbuf(pixbuf)
boton.set_icon_widget(imagen)
imagen.show()
boton.show()
- view_tool_bar.append_item("", "", "",boton, self.siguiente, user_data=None)
- boton.modify_bg(gtk.STATE_NORMAL, MG.BACKGROUND)
+ view_tool_bar.insert(boton, -1)
+ boton.modify_bg(Gtk.StateType.NORMAL, MG.BACKGROUND)
caja_control.pack_end(view_tool_bar, False, False, 0)
- caja_dias = gtk.HBox()
+ caja_dias = Gtk.HBox()
for dia in [_("Lun"), _("Mar"), _("Mie"), _("Jue"), _("Vie"), _("Sáb"), _("Dom")]:
- label = gtk.Label(dia)
- label.modify_fg(gtk.STATE_NORMAL, MG.FOREGROUND)
+ label = Gtk.Label(dia)
+ label.modify_fg(Gtk.StateType.NORMAL, MG.FOREGROUND)
caja_dias.pack_start(label, True, True, 0)
self.matriz = MatrizMoonCalendar()
@@ -587,15 +595,15 @@ class MoonCalendar(gtk.AspectFrame):
boton.toggle_hemisphere_clicked()
if actualizar: boton.actualizar()
-class MatrizMoonCalendar(gtk.EventBox):
+class MatrizMoonCalendar(Gtk.EventBox):
def __init__(self):
- gtk.EventBox.__init__(self)
+ Gtk.EventBox.__init__(self)
self.set_visible_window(True)
- self.modify_bg(gtk.STATE_NORMAL, MG.BACKGROUND)
- self.fixed = gtk.Fixed()
+ self.modify_bg(Gtk.StateType.NORMAL, MG.BACKGROUND)
+ self.fixed = Gtk.Fixed()
self.add(self.fixed)
self.show_all()
@@ -608,7 +616,7 @@ class MatrizMoonCalendar(gtk.EventBox):
self.fixes = []
self.calendarbuttons = []
self.tamanioboton = 0
- self.connect("expose_event", self.repaint)
+ self.connect("draw", self.repaint)
def repaint(self, widget= None, event= None):
@@ -642,7 +650,7 @@ class MatrizMoonCalendar(gtk.EventBox):
child.destroy()
for sem in self.semanas:
listadias = []
- fixed = gtk.Fixed()
+ fixed = Gtk.Fixed()
self.fixes.append(fixed)
self.fixed.put(fixed, 0,0)
for dia in sem: