2
# -*- coding: utf-8 -*-
5
__date__ ='$19/02/2012$'
8
# Copyright (C) 2011,2012 Lorenzo Carbonell
9
# lorenzo.carbonell.cerezo@gmail.com
11
# This program is free software: you can redistribute it and/or modify
12
# it under the terms of the GNU General Public License as published by
13
# the Free Software Foundation, either version 3 of the License, or
14
# (at your option) any later version.
16
# This program is distributed in the hope that it will be useful,
17
# but WITHOUT ANY WARRANTY; without even the implied warranty of
18
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
# GNU General Public License for more details.
21
# You should have received a copy of the GNU General Public License
22
# along with this program. If not, see <http://www.gnu.org/licenses/>.
27
from gi.repository import Gtk, Gdk
33
from configurator import Configuration
34
from googlecalendarapi import GoogleCalendar
35
from logindialog import LoginDialog
38
locale.setlocale(locale.LC_ALL, '')
39
gettext.bindtextdomain(comun.APP, comun.LANGDIR)
40
gettext.textdomain(comun.APP)
43
DAY_OF_WEEK = [_('Monday'),_('Tuesday'),_('Wednesday'),_('Thursday'),_('Friday'),_('Saturday'),_('Sunday')]
45
def first_day_of_month(adatetime):
46
adatetime = adatetime.replace(day=1)
47
return adatetime.weekday()
49
class DayWidget(Gtk.VBox):
50
def __init__(self,adate=None):
51
Gtk.VBox.__init__(self)
52
self.set_size_request(150, 100)
53
scrolledwindow = Gtk.ScrolledWindow()
54
scrolledwindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
55
scrolledwindow.set_shadow_type(Gtk.ShadowType.ETCHED_OUT)
56
self.pack_start(scrolledwindow,True,True,0)
57
self.store = Gtk.ListStore(str, object,str)
58
self.treeview = Gtk.TreeView(self.store)
59
self.column = Gtk.TreeViewColumn('', Gtk.CellRendererText(), text=0, background=2)
60
self.treeview.append_column(self.column)
61
scrolledwindow.add(self.treeview)
65
def set_date(self,adate):
67
self.column.set_title(str(adate.day))
75
def set_events(self,events):
76
configuration = Configuration()
80
if 'summary' in event.keys():
81
label = event['summary']
82
if configuration.has(event['calendar_id']):
83
color = configuration.get(event['calendar_id'])
86
self.store.append([label,event,color])
87
def set_background_color(self,color):
88
self.treeview.modify_bg(Gtk.StateType.NORMAL, color)
91
class AddCalendarWindow(Gtk.Dialog):
93
title = comun.APPNAME + ' | '+_('Calendar')
94
Gtk.Dialog.__init__(self,title,None,Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,(Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT,Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT))
95
self.set_size_request(300, 50)
96
self.set_resizable(False)
97
self.set_icon_from_file(comun.ICON)
98
self.connect('destroy', self.close_application)
100
vbox0 = Gtk.VBox(spacing = 5)
101
vbox0.set_border_width(5)
102
self.get_content_area().add(vbox0)
107
table1 = Gtk.Table(rows = 1, columns = 2, homogeneous = False)
108
table1.set_border_width(2)
109
table1.set_col_spacings(2)
110
table1.set_row_spacings(2)
113
label = Gtk.Label(_('Calendar name')+':')
114
label.set_alignment(0.,0.5)
115
table1.attach(label,0,1,0,1,xoptions = Gtk.AttachOptions.SHRINK, yoptions = Gtk.AttachOptions.SHRINK)
117
self.entry = Gtk.Entry()
118
self.entry.set_width_chars(30)
119
table1.attach(self.entry,1,2,0,1,xoptions = Gtk.AttachOptions.FILL, yoptions = Gtk.AttachOptions.FILL)
123
def close_application(self,widget):
126
if __name__ == "__main__":
127
p = AddCalendarWindow()
128
if p.run() == Gtk.ResponseType.ACCEPT: