[tryton-debian-vcs] goocalendar branch upstream updated. upstream/0.2-1-g6619d3c
Mathias Behrle
tryton-debian-vcs at alioth.debian.org
Thu Dec 1 18:52:04 UTC 2016
The following commit has been merged in the upstream branch:
https://alioth.debian.org/plugins/scmgit/cgi-bin/gitweb.cgi/?p=tryton/goocalendar.git;a=commitdiff;h=upstream/0.2-1-g6619d3c
commit 6619d3ce90a099f3ca6055af324ac3e8ec3c6019
Author: Mathias Behrle <mathiasb at m9s.biz>
Date: Thu Dec 1 17:36:30 2016 +0100
Adding upstream version 0.3.
Signed-off-by: Mathias Behrle <mathiasb at m9s.biz>
diff --git a/CHANGELOG b/CHANGELOG
index 686d84b..6e79fa4 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,7 @@
+Version 0.3 - 2016-11-28
+* Add support for goocanvas >= 2.0
+* Add colors and font-desc properties to Calendar
+
Version 0.2 - 2015-02-11
* Bug fixes (see mercurial logs for details)
diff --git a/GooCalendar.egg-info/PKG-INFO b/GooCalendar.egg-info/PKG-INFO
index 6c63d99..82cc67e 100644
--- a/GooCalendar.egg-info/PKG-INFO
+++ b/GooCalendar.egg-info/PKG-INFO
@@ -1,12 +1,11 @@
Metadata-Version: 1.1
Name: GooCalendar
-Version: 0.2
+Version: 0.3
Summary: A calendar widget for GTK using PyGoocanvas
-Home-page: http://code.google.com/p/goocalendar/
+Home-page: https://goocalendar.tryton.org/
Author: Cédric Krier
Author-email: cedric.krier at b2ck.com
License: GPL-2
-Download-URL: http://code.google.com/p/goocalendar/downloads/
Description: GooCalendar
===========
diff --git a/INSTALL b/INSTALL
index 281d620..a9bd8ce 100644
--- a/INSTALL
+++ b/INSTALL
@@ -5,7 +5,8 @@ Prerequisites
-------------
* Python (http://www.python.org/)
- * PyGoocanvas (https://live.gnome.org/PyGoocanvas)
+ * GooCanvas >= 2.0 (https://wiki.gnome.org/Projects/GooCanvas)
+ * Optional: PyGoocanvas (https://wiki.gnome.org/Projects/PyGoocanvas)
Installation
------------
diff --git a/PKG-INFO b/PKG-INFO
index 6c63d99..82cc67e 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,12 +1,11 @@
Metadata-Version: 1.1
Name: GooCalendar
-Version: 0.2
+Version: 0.3
Summary: A calendar widget for GTK using PyGoocanvas
-Home-page: http://code.google.com/p/goocalendar/
+Home-page: https://goocalendar.tryton.org/
Author: Cédric Krier
Author-email: cedric.krier at b2ck.com
License: GPL-2
-Download-URL: http://code.google.com/p/goocalendar/downloads/
Description: GooCalendar
===========
diff --git a/doc/conf.py b/doc/conf.py
index c84904f..a2d8511 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -46,9 +46,9 @@ copyright = u'2012, Samuel Abels, Cédric Krier, Antoine Smolders'
# built documents.
#
# The short X.Y version.
-version = '0.2'
+version = '0.3'
# The full version, including alpha/beta/rc tags.
-release = '0.2'
+release = '0.3'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
diff --git a/doc/index.rst b/doc/index.rst
index 76b8c97..845f766 100644
--- a/doc/index.rst
+++ b/doc/index.rst
@@ -244,6 +244,40 @@ Instance signals:
*...*
additional user parameters (if any).
+Instance properties:
+
+``text-color``
+
+ The color of the text. Default: #2E3634
+
+``inactive-text-color``
+
+ The color of the inactive text. Default: #8B8F8E
+
+``border-color``
+
+ The color of border. Default: #D2D0D2
+
+``selected-border-color``
+
+ The color of selected border. Default: #5EC590
+
+``inactive-border-color``
+
+ The color of inactive border. Default: #E8E7E8
+
+``body-color``
+
+ The color of the body. Default: white
+
+``today-body-color``
+
+ The color of the today body. Default: ivory
+
+``font-desc``
+
+ The attributes specifying which font to use.
+
.. _eventstore:
EventStore Objects
diff --git a/goocalendar/__init__.py b/goocalendar/__init__.py
index 734f93f..56da494 100644
--- a/goocalendar/__init__.py
+++ b/goocalendar/__init__.py
@@ -1,7 +1,18 @@
-#This file is part of GooCalendar. The COPYRIGHT file at the top level of
-#this repository contains the full copyright notices and license terms.
+# This file is part of GooCalendar. The COPYRIGHT file at the top level of
+# this repository contains the full copyright notices and license terms.
+import goocanvas
+import pango
+
+if not hasattr(goocanvas, 'Text'):
+ goocanvas.Text = goocanvas.CanvasText
+
+if hasattr(pango, 'Rectangle'):
+ def getitem(self, i):
+ return [self.x, self.y, self.width, self.height][i]
+ pango.Rectangle.__getitem__ = getitem
+
from ._calendar import Calendar
from ._event import Event, EventStore
__all__ = ['Calendar', 'EventStore', 'Event']
-__version__ = '0.2'
+__version__ = '0.3'
diff --git a/goocalendar/_calendar.py b/goocalendar/_calendar.py
index ba2c4f8..9edfdce 100644
--- a/goocalendar/_calendar.py
+++ b/goocalendar/_calendar.py
@@ -1,5 +1,5 @@
-#This file is part of GooCalendar. The COPYRIGHT file at the top level of
-#this repository contains the full copyright notices and license terms.
+# This file is part of GooCalendar. The COPYRIGHT file at the top level of
+# this repository contains the full copyright notices and license terms.
import datetime
import calendar
import math
@@ -18,9 +18,43 @@ class Calendar(goocanvas.Canvas):
AVAILABLE_VIEWS = ["month", "week"]
MIN_PER_LEVEL = 15 # Number of minutes per graduation for drag and drop
+ __gproperties__ = {
+ 'text-color': (gobject.TYPE_STRING, '#2E3634', "Text Color",
+ "The color of the text", gobject.PARAM_READWRITE),
+ 'inactive-text-color': (gobject.TYPE_STRING, '#8B8F8E',
+ "Inactive Text Color", "The color of the inactive text",
+ gobject.PARAM_READWRITE),
+ 'border-color': (gobject.TYPE_STRING, '#D2D0D2', "Border Color",
+ "The color of border", gobject.PARAM_READWRITE),
+ 'selected-border-color': (gobject.TYPE_STRING, '#5EC590',
+ "Selected Border Color", "The color of selected border",
+ gobject.PARAM_READWRITE),
+ 'inactive-border-color': (gobject.TYPE_STRING, '#E8E7E8',
+ "Inactive Border Color", "The color of inactive border",
+ gobject.PARAM_READWRITE),
+ 'body-color': (gobject.TYPE_STRING, 'white', "Body Color",
+ "The color of the body", gobject.PARAM_READWRITE),
+ 'today-body-color': (gobject.TYPE_STRING, 'ivory', "Today Body Color",
+ "The color of the today body", gobject.PARAM_READWRITE),
+ # TODO font
+ 'font-desc': (gobject.TYPE_PYOBJECT, "Font Description",
+ "The attributes specifying which font to use",
+ gobject.PARAM_READWRITE),
+ }
+
def __init__(self, event_store=None, view="month", time_format="%H:%M",
firstweekday=calendar.SUNDAY):
super(Calendar, self).__init__()
+ self.__props = {
+ 'text-color': '#2E3634',
+ 'inactive-text-color': '#8B8F8E',
+ 'border-color': '#D2D0D2',
+ 'selected-border-color': '#5EC590',
+ 'inactive-border-color': '#E8E7E8',
+ 'body-color': 'white',
+ 'today-body-color': 'ivory',
+ }
+ self._font_desc = None
self._selected_day = None
self._bg_rect = None
self._timeline = None
@@ -48,7 +82,10 @@ class Calendar(goocanvas.Canvas):
self.selected_date = datetime.date.today()
self.time_format = time_format
self.set_bounds(0, 0, 200, 200)
- self.set_flags(gtk.CAN_FOCUS)
+ if hasattr(self, 'set_flags'):
+ self.set_flags(gtk.CAN_FOCUS)
+ else:
+ self.set_can_focus(True)
self.set_events(gtk.gdk.EXPOSURE_MASK
| gtk.gdk.BUTTON_PRESS_MASK
| gtk.gdk.BUTTON_RELEASE_MASK
@@ -65,20 +102,36 @@ class Calendar(goocanvas.Canvas):
# Initialize background, timeline and days and add them to canvas
root = self.get_root_item()
- style = self.get_style()
- color = util.color_to_string(style.bg[gtk.STATE_PRELIGHT])
self._bg_rect = goocanvas.Rect(parent=root, x=0, y=0,
- stroke_color=color, fill_color=color)
+ stroke_color='white', fill_color='white')
self._timeline = TimelineItem(self, time_format=self.time_format)
- root.add_child(self._timeline)
+ root.add_child(self._timeline, -1)
self.days = []
while len(self.days) < 42: # 6 rows of 7 days
box = DayItem(self)
- root.add_child(box)
+ root.add_child(box, -1)
box.connect('button_press_event',
self.on_day_item_button_press_event)
self.days.append(box)
+ def do_set_property(self, prop, value):
+ if prop.name == 'font-desc':
+ self._font_desc = value
+ else:
+ self.__props[prop.name] = value
+
+ def do_get_property(self, prop):
+ if prop.name == 'font-desc':
+ if self._font_desc is None:
+ if hasattr(self, 'get_style_context'):
+ return self.get_style_context().get_font(
+ gtk.STATE_FLAG_NORMAL)
+ else:
+ return self.get_style().font_desc
+ return self._font_desc
+ else:
+ return self.__props[prop.name]
+
def select(self, new_date):
cal = calendar.Calendar(self.firstweekday)
if hasattr(new_date, 'date'):
@@ -209,14 +262,7 @@ class Calendar(goocanvas.Canvas):
"""
Draws the currently selected week.
"""
- style = self.get_style()
- pango_size = style.font_desc.get_size()
- text_color = util.color_to_string(style.fg[gtk.STATE_NORMAL])
- border_color = util.color_to_string(style.mid[gtk.STATE_NORMAL])
- body_color = util.color_to_string(style.light[gtk.STATE_ACTIVE])
- selected_border_color = util.color_to_string(
- style.mid[gtk.STATE_SELECTED])
- today_body_color = 'ivory'
+ pango_size = self.props.font_desc.get_size()
x, y, w, h = self.get_bounds()
timeline_w = self._timeline.width
caption_size = max(len(day_name) for day_name in calendar.day_name)
@@ -246,13 +292,13 @@ class Calendar(goocanvas.Canvas):
# Highlight the day according to it's selection.
selected = current_date == self.selected_date
if selected:
- the_border_color = selected_border_color
+ the_border_color = self.props.selected_border_color
else:
- the_border_color = border_color
+ the_border_color = self.props.border_color
if current_date == datetime.date.today():
- the_body_color = today_body_color
+ the_body_color = self.props.today_body_color
else:
- the_body_color = body_color
+ the_body_color = self.props.body_color
# Draw.
box = self.days[weekno * 7 + dayno]
@@ -265,8 +311,8 @@ class Calendar(goocanvas.Canvas):
box.full_border = selected
box.border_color = the_border_color
box.body_color = the_body_color
- box.title_text_color = text_color
- box.event_text_color = text_color
+ box.title_text_color = self.props.text_color
+ box.event_text_color = self.props.text_color
box.set_property('visibility', goocanvas.ITEM_VISIBLE)
box.update()
@@ -278,25 +324,14 @@ class Calendar(goocanvas.Canvas):
"""
Draws the currently selected month.
"""
- style = self.get_style()
x1, y1, w, h = self.get_bounds()
- pango_size = style.font_desc.get_size()
+ pango_size = self.props.font_desc.get_size()
caption_size = max(len(day_name) for day_name in calendar.day_name)
caption_size += 3 # The needed space for the date before the day_name
day_width_min = caption_size * pango_size / pango.SCALE
day_width_max = w / 7
self._day_width = max(day_width_min, day_width_max)
self._day_height = h / 6
- text_color = util.color_to_string(style.fg[gtk.STATE_NORMAL])
- inactive_text_color = util.color_to_string(
- style.fg[gtk.STATE_INSENSITIVE])
- border_color = util.color_to_string(style.mid[gtk.STATE_NORMAL])
- selected_border_color = util.color_to_string(
- style.mid[gtk.STATE_SELECTED])
- inactive_border_color = util.color_to_string(
- style.bg[gtk.STATE_PRELIGHT])
- body_color = util.color_to_string(style.light[gtk.STATE_ACTIVE])
- today_body_color = 'ivory'
# Hide the timeline.
if self._timeline is not None:
@@ -311,20 +346,20 @@ class Calendar(goocanvas.Canvas):
# The color depends on whether each day is part of the
# current month.
if (not util.same_month(date, self.selected_date)):
- the_border_color = inactive_border_color
- the_text_color = inactive_text_color
+ the_border_color = self.props.inactive_border_color
+ the_text_color = self.props.inactive_text_color
else:
- the_border_color = border_color
- the_text_color = text_color
+ the_border_color = self.props.border_color
+ the_text_color = self.props.text_color
# Highlight the day according to it's selection.
selected = date == self.selected_date
if selected:
- the_border_color = selected_border_color
+ the_border_color = self.props.selected_border_color
if date == datetime.date.today():
- the_body_color = today_body_color
+ the_body_color = self.props.today_body_color
else:
- the_body_color = body_color
+ the_body_color = self.props.body_color
# Draw a box for the day.
box = self.days[weekno * 7 + dayno]
@@ -404,7 +439,7 @@ class Calendar(goocanvas.Canvas):
def draw_events(self):
# Clear previous events.
for item in self._event_items:
- self.get_root_item().remove_child(item)
+ item.remove()
self._event_items = []
for day in self.days:
day.lines.clear()
@@ -488,7 +523,7 @@ class Calendar(goocanvas.Canvas):
event_item.connect('motion_notify_event',
self.on_event_item_motion_notified)
self._event_items.append(event_item)
- self.get_root_item().add_child(event_item)
+ self.get_root_item().add_child(event_item, -1)
event_item.x = day.x
event_item.left_border = day.x + 2
event_item.y = day.y + (free_line + 1) * day.line_height
@@ -520,18 +555,14 @@ class Calendar(goocanvas.Canvas):
return
# Redraw the timeline.
- style = self.get_style()
- text_color = util.color_to_string(style.fg[gtk.STATE_NORMAL])
- border_color = util.color_to_string(style.mid[gtk.STATE_NORMAL])
- body_color = util.color_to_string(style.light[gtk.STATE_ACTIVE])
self._timeline.set_property('visibility', goocanvas.ITEM_VISIBLE)
x, y, w, h = self.get_bounds()
self._timeline.x = x
self._timeline.y = max_y
self._timeline.height = h - max_y - 2
- self._timeline.line_color = body_color
- self._timeline.bg_color = border_color
- self._timeline.text_color = text_color
+ self._timeline.line_color = self.props.body_color
+ self._timeline.bg_color = self.props.border_color
+ self._timeline.text_color = self.props.text_color
self._timeline.update()
width, height = self.get_size_request()
min_line_height = self._timeline.min_line_height
@@ -557,7 +588,7 @@ class Calendar(goocanvas.Canvas):
remaining_events = day_events[:]
while len(remaining_events) > 0:
columns.append([remaining_events[0]])
- for event in remaining_events:
+ for event in remaining_events[1:]:
intersections = util.count_intersections(columns[-1],
event.start, event.end)
if intersections == 0:
@@ -594,7 +625,7 @@ class Calendar(goocanvas.Canvas):
event_item.connect('motion_notify_event',
self.on_event_item_motion_notified)
self._event_items.append(event_item)
- self.get_root_item().add_child(event_item)
+ self.get_root_item().add_child(event_item, -1)
y_off1 = top_offset_mins * self.minute_height
y_off2 = bottom_offset_mins * self.minute_height
column_width = day.width / parallel
@@ -719,7 +750,7 @@ class Calendar(goocanvas.Canvas):
else:
for item in event_item.event.event_items:
if item != event_item:
- self.get_root_item().remove_child(item)
+ item.remove()
self._event_items.remove(item)
event_item.height = 2 * self._line_height
@@ -753,7 +784,7 @@ class Calendar(goocanvas.Canvas):
elif self.view == 'month':
for item in event_item.event.event_items:
if item != event_item:
- self.get_root_item().remove_child(item)
+ item.remove()
self._event_items.remove(item)
else:
event_item.event.start += daysdelta
@@ -941,10 +972,7 @@ class DayItem(goocanvas.Group):
week_day = self.date.weekday()
day_name = calendar.day_name[week_day]
caption = '%s %s' % (self.date.day, day_name)
- style = self._cal.get_style()
- font_descr = style.font_desc.copy()
- font = font_descr.to_string()
- self.text.set_property('font', font)
+ self.text.set_property('font-desc', self._cal.props.font_desc)
self.text.set_property('text', caption)
logical_height = self.text.get_natural_extents()[1][3]
line_height = int(math.ceil(float(logical_height) / pango.SCALE))
@@ -1024,7 +1052,7 @@ class EventItem(goocanvas.Group):
self.width = kwargs.get('width')
self.height = kwargs.get('height')
self.bg_color = kwargs.get('bg_color')
- self.text_color = kwargs.get('text_color')
+ self.text_color = kwargs.get('text_color', 'black')
self.event = kwargs.get('event')
self.type = kwargs.get('type', 'leftright')
self.time_format = kwargs.get('time_format')
@@ -1034,10 +1062,7 @@ class EventItem(goocanvas.Group):
# Create canvas items.
self.box = goocanvas.Rect(parent=self)
self.text = goocanvas.Text(parent=self)
- style = self._cal.get_style()
- font_descr = style.font_desc.copy()
- self.font = font_descr.to_string()
- self.text.set_property('font', self.font)
+ self.text.set_property('font-desc', self._cal.props.font_desc)
logical_height = self.text.get_natural_extents()[1][3]
self.line_height = logical_height / pango.SCALE
@@ -1239,7 +1264,7 @@ class TimelineItem(goocanvas.Group):
line_height = self.min_line_height
if line_height < self.height / 24:
line_height = self.height / 24
- pango_size = self._cal.get_style().font_desc.get_size()
+ pango_size = self._cal.props.font_desc.get_size()
padding_top = (line_height - pango_size / pango.SCALE) / 2
padding_top -= int(math.ceil(float(self.ink_padding_top) /
pango.SCALE))
@@ -1247,12 +1272,11 @@ class TimelineItem(goocanvas.Group):
return line_height
def _compute_width(self):
- style = self._cal.get_style()
- font = style.font_desc
+ font_desc = self._cal.props.font_desc
ink_padding_left = 0
ink_max_width = 0
for n in range(24):
- self._timeline_text[n].set_property('font', font)
+ self._timeline_text[n].set_property('font-desc', font_desc)
natural_extents = self._timeline_text[n].get_natural_extents()
ink_rect = natural_extents[0]
ink_padding_left = max(ink_padding_left, ink_rect[0])
diff --git a/goocalendar/_event.py b/goocalendar/_event.py
index 7d8f59b..6f3fb86 100644
--- a/goocalendar/_event.py
+++ b/goocalendar/_event.py
@@ -1,5 +1,5 @@
-#This file is part of GooCalendar. The COPYRIGHT file at the top level of
-#this repository contains the full copyright notices and license terms.
+# This file is part of GooCalendar. The COPYRIGHT file at the top level of
+# this repository contains the full copyright notices and license terms.
import gobject
import util
@@ -15,6 +15,8 @@ class Event(object):
def __init__(self, caption, start, end=None, **kwargs):
assert caption is not None
assert start is not None
+ if end is not None:
+ assert start <= end
self.id = None
self.caption = caption
self.start = start
diff --git a/goocalendar/util.py b/goocalendar/util.py
index af61ad8..f8196ec 100644
--- a/goocalendar/util.py
+++ b/goocalendar/util.py
@@ -1,5 +1,5 @@
-#This file is part of GooCalendar. The COPYRIGHT file at the top level of
-#this repository contains the full copyright notices and license terms.
+# This file is part of GooCalendar. The COPYRIGHT file at the top level of
+# this repository contains the full copyright notices and license terms.
import sys
import datetime
@@ -91,7 +91,8 @@ def event_intersects(event, start, end=None):
event_end = event.end if event.end else event.start
return ((event.start >= start and event.start < end)
or (event_end > start and event_end <= end)
- or (event.start < start and event_end > end))
+ or (event.start < start and event_end > end)
+ or (event.start == start and event_end == end))
def get_intersection_list(list, start, end):
diff --git a/setup.py b/setup.py
index 21393ff..9b76fcc 100644
--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-#This file is part of GooCalendar. The COPYRIGHT file at the top level of
-#this repository contains the full copyright notices and license terms.
+# This file is part of GooCalendar. The COPYRIGHT file at the top level of
+# this repository contains the full copyright notices and license terms.
import os
from setuptools import setup, find_packages
@@ -11,13 +11,12 @@ def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
setup(name='GooCalendar',
- version='0.2',
+ version='0.3',
author='Cédric Krier',
author_email='cedric.krier at b2ck.com',
- url='http://code.google.com/p/goocalendar/',
+ url='https://goocalendar.tryton.org/',
description='A calendar widget for GTK using PyGoocanvas',
long_description=read('README'),
- download_url='http://code.google.com/p/goocalendar/downloads/',
packages=find_packages(),
classifiers=[
'Development Status :: 5 - Production/Stable',
--
goocalendar
More information about the tryton-debian-vcs
mailing list