[california/wip/725768-colors] First pass at adding colors to California
- From: Jim Nelson <jnelson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [california/wip/725768-colors] First pass at adding colors to California
- Date: Wed, 12 Mar 2014 00:45:45 +0000 (UTC)
commit e356cf1d14e47dd7684ddb3227cbafe25f75dd2c
Author: Jim Nelson <jim yorba org>
Date: Tue Mar 11 17:44:34 2014 -0700
First pass at adding colors to California
src/backing/backing-calendar-source.vala | 7 +++++
src/backing/eds/backing-eds-calendar-source.vala | 31 ++++++++++++++++++++++
src/backing/eds/backing-eds-store.vala | 5 +++-
src/view/month/month-cell.vala | 3 +-
4 files changed, 44 insertions(+), 2 deletions(-)
---
diff --git a/src/backing/backing-calendar-source.vala b/src/backing/backing-calendar-source.vala
index 67ddd64..c38eb89 100644
--- a/src/backing/backing-calendar-source.vala
+++ b/src/backing/backing-calendar-source.vala
@@ -14,6 +14,13 @@ namespace California.Backing {
*/
public abstract class CalendarSource : Source {
+ /**
+ * The suggested color to use when displaying the { link CalendarSource} or information
+ * about or from it.
+ */
+ public Gdk.RGBA color { get; protected set;
+ default = Gdk.RGBA() { red = 0.0, green = 0.0, blue = 0.0, alpha = 1.0 }; }
+
protected CalendarSource(string title) {
base (title);
}
diff --git a/src/backing/eds/backing-eds-calendar-source.vala
b/src/backing/eds/backing-eds-calendar-source.vala
index d4e6ecc..0a29375 100644
--- a/src/backing/eds/backing-eds-calendar-source.vala
+++ b/src/backing/eds/backing-eds-calendar-source.vala
@@ -20,6 +20,37 @@ internal class EdsCalendarSource : CalendarSource {
this.eds_source = eds_source;
this.eds_calendar = eds_calendar;
+
+ // initial color property and monitor for future changes
+ update_calendar_color();
+ eds_calendar.notify["color"].connect(update_calendar_color);
+ }
+
+ ~EdsCalendarSource() {
+ eds_calendar.notify["color"].disconnect(update_calendar_color);
+ }
+
+ private void update_calendar_color() {
+ Gdk.Color rgb;
+ if (!Gdk.Color.parse(eds_calendar.color, out rgb)) {
+ debug("Unable to parse calendar color for %s: %s", to_string(), eds_calendar.color.to_string());
+
+ return;
+ }
+
+ Gdk.RGBA rgba = {
+ red: conv(rgb.red),
+ green: conv(rgb.green),
+ blue: conv(rgb.blue),
+ alpha: 1.0
+ };
+
+ color = rgba;
+ }
+
+ // compiler error if this calculation is done inline when initializing struct
+ private inline double conv(uint16 value) {
+ return (double) value / (double) uint16.MAX;
}
// Invoked by EdsStore prior to making it available outside of unit
diff --git a/src/backing/eds/backing-eds-store.vala b/src/backing/eds/backing-eds-store.vala
index 79c7173..49b9516 100644
--- a/src/backing/eds/backing-eds-store.vala
+++ b/src/backing/eds/backing-eds-store.vala
@@ -52,10 +52,13 @@ internal class EdsStore : Store {
}
private async void add_eds_source_async(E.Source eds_source) {
+ if (!eds_source.enabled)
+ return;
+
// only interested in calendars for now
E.SourceCalendar? eds_calendar =
eds_source.get_extension(E.SOURCE_EXTENSION_CALENDAR) as E.SourceCalendar;
- if (eds_calendar == null)
+ if (eds_calendar == null || !eds_calendar.selected)
return;
EdsCalendarSource calendar = new EdsCalendarSource(eds_source, eds_calendar);
diff --git a/src/view/month/month-cell.vala b/src/view/month/month-cell.vala
index ff7e0d9..71bb9c8 100644
--- a/src/view/month/month-cell.vala
+++ b/src/view/month/month-cell.vala
@@ -252,7 +252,8 @@ public class Cell : Gtk.EventBox {
text = "%s %s".printf(local_start.to_pretty_time_string(PRETTY_TIME_FLAGS), event.summary);
}
- Pango.Layout layout = draw_line_of_text(ctx, line_number, RGBA_DAY_OF_MONTH, text);
+ Pango.Layout layout = draw_line_of_text(ctx, line_number, event.calendar_source.color,
+ text);
line_to_event.set(line_number++, event);
event.set_data<string?>(KEY_TOOLTIP, layout.is_ellipsized() ? text : null);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]