Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
GooCalendar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tryton
GooCalendar
Commits
521a9d6f
Commit
521a9d6f
authored
12 years ago
by
Antoine Smolders
Browse files
Options
Downloads
Patches
Plain Diff
ZOOM_MONTH andd ZOOM_WEEK integers are replaced by strings "month" and "week"
parent
e39abbe6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
GooCalendar/Calendar.py
+17
-18
17 additions, 18 deletions
GooCalendar/Calendar.py
GooCalendar/EventItem.py
+1
-1
1 addition, 1 deletion
GooCalendar/EventItem.py
with
18 additions
and
19 deletions
GooCalendar/Calendar.py
+
17
−
18
View file @
521a9d6f
...
...
@@ -16,6 +16,5 @@
class
Calendar
(
goocanvas
.
Canvas
):
ZOOM_MONTH
=
1
ZOOM_WEEK
=
2
ZOOM_LEVELS
=
[
"
month
"
,
"
week
"
]
...
...
@@ -21,5 +20,5 @@
def
__init__
(
self
,
event_store
=
None
,
zoom
=
ZOOM_MONTH
):
def
__init__
(
self
,
event_store
=
None
,
zoom
=
"
month
"
):
super
(
Calendar
,
self
).
__init__
()
self
.
cal
=
calendar
.
Calendar
(
calendar
.
SUNDAY
)
self
.
today
=
time
.
localtime
(
time
.
time
())[:
3
]
...
...
@@ -34,6 +33,7 @@
self
.
_event_added_sigid
=
None
self
.
set_event_store
(
event_store
)
self
.
event_items
=
[]
assert
zoom
in
self
.
ZOOM_LEVELS
self
.
zoom
=
zoom
self
.
set_bounds
(
0
,
0
,
200
,
200
)
self
.
set_flags
(
gtk
.
CAN_FOCUS
)
...
...
@@ -69,5 +69,5 @@
old_day
=
self
.
selected_day
self
.
selected_date
=
new_date
[:
3
]
page_changed
=
False
if
self
.
zoom
==
self
.
ZOOM_MONTH
:
if
self
.
zoom
==
"
month
"
:
page_changed
=
old_date
[
1
]
!=
new_date
[
1
]
...
...
@@ -73,5 +73,5 @@
page_changed
=
old_date
[
1
]
!=
new_date
[
1
]
if
self
.
zoom
==
self
.
ZOOM_WEEK
:
if
self
.
zoom
==
"
week
"
:
page_changed
=
True
# Good enough for now...
# This is slow: When the month was changed we need to update
...
...
@@ -112,5 +112,5 @@
def
select_previous_page
(
self
):
date
=
datetime
.
datetime
(
*
self
.
selected_date
)
if
self
.
zoom
==
self
.
ZOOM_MONTH
:
if
self
.
zoom
==
"
month
"
:
selected_date
=
util
.
previous_month
(
self
.
cal
,
date
).
timetuple
()[:
3
]
...
...
@@ -116,7 +116,7 @@
selected_date
=
util
.
previous_month
(
self
.
cal
,
date
).
timetuple
()[:
3
]
elif
self
.
zoom
==
self
.
ZOOM_WEEK
:
elif
self
.
zoom
==
"
week
"
:
selected_date
=
util
.
previous_week
(
self
.
cal
,
date
).
timetuple
()[:
3
]
self
.
select_from_tuple
(
selected_date
)
def
select_next_page
(
self
):
date
=
datetime
.
datetime
(
*
self
.
selected_date
)
...
...
@@ -118,7 +118,7 @@
selected_date
=
util
.
previous_week
(
self
.
cal
,
date
).
timetuple
()[:
3
]
self
.
select_from_tuple
(
selected_date
)
def
select_next_page
(
self
):
date
=
datetime
.
datetime
(
*
self
.
selected_date
)
if
self
.
zoom
==
self
.
ZOOM_MONTH
:
if
self
.
zoom
==
"
month
"
:
date
=
util
.
next_month
(
self
.
cal
,
date
)
...
...
@@ -124,6 +124,6 @@
date
=
util
.
next_month
(
self
.
cal
,
date
)
elif
self
.
zoom
==
self
.
ZOOM_WEEK
:
elif
self
.
zoom
==
"
week
"
:
date
=
util
.
next_week
(
self
.
cal
,
date
)
self
.
select
(
date
)
def
set_zoom
(
self
,
level
):
...
...
@@ -126,10 +126,9 @@
date
=
util
.
next_week
(
self
.
cal
,
date
)
self
.
select
(
date
)
def
set_zoom
(
self
,
level
):
if
level
not
in
[
self
.
ZOOM_MONTH
,
self
.
ZOOM_WEEK
]:
raise
Exception
(
'
Invalid zoom level
'
)
self
.
zoom
=
int
(
level
)
assert
level
in
self
.
ZOOM_LEVELS
self
.
zoom
=
level
self
.
update
()
def
get_selected_date
(
self
):
...
...
@@ -167,5 +166,5 @@
if
not
self
.
realized
:
return
self
.
draw_background
()
if
self
.
zoom
==
self
.
ZOOM_MONTH
:
if
self
.
zoom
==
"
month
"
:
self
.
draw_month
()
...
...
@@ -171,5 +170,5 @@
self
.
draw_month
()
elif
self
.
zoom
==
self
.
ZOOM_WEEK
:
elif
self
.
zoom
==
"
week
"
:
self
.
draw_week
()
self
.
draw_events
()
...
...
@@ -330,7 +329,7 @@
end
=
event
.
end
.
timetuple
()[:
3
]
days
=
[]
for
weekno
,
week
in
enumerate
(
weeks
):
if
self
.
zoom
==
self
.
ZOOM_WEEK
:
if
self
.
zoom
==
"
week
"
:
weekdays
=
[
date
.
timetuple
()[:
3
]
for
date
in
week
]
if
self
.
selected_date
not
in
weekdays
:
continue
...
...
@@ -368,7 +367,7 @@
if
not
self
.
event_store
:
return
if
self
.
zoom
==
self
.
ZOOM_MONTH
:
if
self
.
zoom
==
"
month
"
:
weeks
=
util
.
my_monthdatescalendar
(
self
.
cal
,
*
self
.
selected_date
)
dates
=
[]
for
week
in
weeks
:
...
...
@@ -388,7 +387,7 @@
non_all_day_events
=
[]
for
event
in
events
:
# Handle non-all-day events differently in week mode.
if
self
.
zoom
==
self
.
ZOOM_WEEK
and
not
event
.
all_day
:
if
self
.
zoom
==
"
week
"
and
not
event
.
all_day
:
non_all_day_events
.
append
(
event
)
continue
...
...
@@ -450,7 +449,7 @@
event_item
.
type
=
'
leftright
'
event_item
.
update
()
if
self
.
zoom
!=
self
.
ZOOM_WEEK
:
if
self
.
zoom
!=
"
week
"
:
return
# Redraw the timeline.
...
...
This diff is collapsed.
Click to expand it.
GooCalendar/EventItem.py
+
1
−
1
View file @
521a9d6f
...
...
@@ -31,7 +31,7 @@
self
.
update
()
def
update
(
self
):
if
self
.
event
.
all_day
or
self
.
cal
.
zoom
==
self
.
cal
.
ZOOM_MONTH
:
if
self
.
event
.
all_day
or
self
.
cal
.
zoom
==
"
month
"
:
self
.
update_all_day_event
()
else
:
self
.
update_event
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment