summaryrefslogtreecommitdiff
path: root/community/dates/0001-Replaced-the-calls-to-the-deprecated-functions-e_sou.patch
blob: e7fce46f39ade95ef4d173fb2286c07a60f30953 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
From 7771e0b3d75b4ba04756d6c6ffc03d644df2db5f Mon Sep 17 00:00:00 2001
From: Lucas Hermann Negri <lucashnegri@gmail.com>
Date: Wed, 13 Oct 2010 18:49:20 -0300
Subject: [PATCH] Replaced the calls to the deprecated functions e_source_{set,get}_color
 with the new API (e_source_{set,peek}_color_spec).

---
 src/dates_gtk.c  |   40 ++++++++++++----------------------------
 src/dates_main.c |    2 +-
 src/dates_view.c |   10 ++++------
 3 files changed, 17 insertions(+), 35 deletions(-)

diff --git a/src/dates_gtk.c b/src/dates_gtk.c
index 78e71bb..403bc25 100644
--- a/src/dates_gtk.c
+++ b/src/dates_gtk.c
@@ -1016,7 +1016,6 @@ calendar_do_new_dialog (GtkWindow *parent, DatesData *d)
 			GtkTreeIter iter;
 			GError *error = NULL;
 			const gchar *relative_uri;
-			guint32 new_colour;
 
 #ifdef WITH_HILDON
 			GdkColor *hildon_color;
@@ -1055,7 +1054,8 @@ calendar_do_new_dialog (GtkWindow *parent, DatesData *d)
 			source = e_source_new (name, relative_uri);
 
 #ifdef USE_OWL
-			new_colour = owl_colour_button_get_colour (OWL_COLOUR_BUTTON (color_button));
+            guint32 new_colour = owl_colour_button_get_colour (OWL_COLOUR_BUTTON (color_button));
+            e_source_set_color (source, new_colour);
 #else
 
 #ifdef WITH_HILDON
@@ -1063,17 +1063,11 @@ calendar_do_new_dialog (GtkWindow *parent, DatesData *d)
 #else
 			gtk_color_button_get_color (GTK_COLOR_BUTTON(color_button), &colour);
 #endif
-			new_colour = (guint8)(colour.red >> 8);
-			new_colour <<= 8;
-			new_colour |= (guint8)(colour.green >> 8);
-			new_colour <<= 8;
-			new_colour |= (guint8)(colour.blue >> 8);
-			new_colour <<= 8;
+			gchar *n_color = gdk_color_to_string (&colour);
+            e_source_set_color_spec (source, n_color);
+            g_free(n_color);
 #endif
 
-			/* Set the colour */
-			e_source_set_color (source, new_colour);
-
 			/* Set the group for the source */
 			e_source_set_group (source, group);
 			e_source_group_add_source (group, source, 0);
@@ -1169,7 +1163,6 @@ calendar_do_edit_dialog (GtkWindow *parent, ESource *source, DatesData *d)
 	ESourceGroup *group;
 
 	GdkColor colour;
-	guint32 raw_colour;
 
 	const gchar *name = NULL;
 	const gchar *uri = NULL;
@@ -1335,12 +1328,8 @@ calendar_do_edit_dialog (GtkWindow *parent, ESource *source, DatesData *d)
 	gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
 
 	/* Get the colour from the the source */
-	e_source_get_color (source, &raw_colour);
-
-	/* Munge this into something usable */
-	colour.red = (guint16)(((raw_colour & 0xff0000) >> 16) << 8);
-	colour.green = (guint16)(((raw_colour & 0xff00) >> 8) << 8);
-	colour.blue = (guint16)(((raw_colour & 0xff) << 8));
+	const gchar* spec = e_source_peek_color_spec(source);
+    gdk_color_parse(spec, &colour);
 
 	/* Now we need to allocate the colour */
 	gdk_colormap_alloc_color (gdk_colormap_get_system (), &colour, TRUE, TRUE);
@@ -1440,26 +1429,21 @@ calendar_do_edit_dialog (GtkWindow *parent, ESource *source, DatesData *d)
 			 * Next we need to pack the GDK colour into guint32
 			 * for eds
 			 */
-			guint32 new_colour = 0;
 
 			GError *error = NULL;
 #ifdef USE_OWL
-			new_colour = owl_colour_button_get_colour (OWL_COLOUR_BUTTON (color_button));
+			guint32 new_colour = owl_colour_button_get_colour (OWL_COLOUR_BUTTON (color_button));
+            e_source_set_color (source, new_colour);
 #else
 #ifdef WITH_HILDON
 			hildon_color_button_get_color (HILDON_COLOR_BUTTON(color_button), &colour);
 #else
 			gtk_color_button_get_color (GTK_COLOR_BUTTON(color_button), &colour);
 #endif			
-			new_colour = (guint8)(colour.red >> 8);
-			new_colour <<= 8;
-			new_colour |= (guint8)(colour.green >> 8);
-			new_colour <<= 8;
-			new_colour |= (guint8)(colour.blue >> 8);
-			new_colour <<= 8;
+			gchar *n_color = gdk_color_to_string (&colour);
+            e_source_set_color_spec (source, n_color);
+            g_free(n_color);
 #endif
-			/* Update the colour */
-			e_source_set_color (source, new_colour);
 
 			/* And the name */
 			e_source_set_name (source, (gtk_entry_get_text (GTK_ENTRY (name_entry))));
diff --git a/src/dates_main.c b/src/dates_main.c
index ce05fe8..1f7770d 100644
--- a/src/dates_main.c
+++ b/src/dates_main.c
@@ -112,7 +112,7 @@ dates_load_calendars (DatesData *d)
 		system_source = e_source_new (_("Personal"), "system");
 
 		/* Default Evolution colour */
-		e_source_set_color (system_source, 0xBECEDD);
+		e_source_set_color_spec (system_source, "#BECEDD");
 
 		/* Set the group for the source and put it in the group */
 		e_source_set_group (system_source, local_group);
diff --git a/src/dates_view.c b/src/dates_view.c
index d65db2f..9d28a15 100644
--- a/src/dates_view.c
+++ b/src/dates_view.c
@@ -4846,7 +4846,6 @@ dates_view_add_calendar (DatesView *view, ECal *ecal)
 	DatesViewPrivate *priv = DATES_VIEW_GET_PRIVATE (view);
 	DatesViewCalendar *cal;
 	ESource *source;
-	guint32 colour;
 /*	GError *error = NULL;*/
 	
 	g_return_if_fail (E_IS_CAL (ecal));
@@ -4876,12 +4875,11 @@ dates_view_add_calendar (DatesView *view, ECal *ecal)
 	cal->text_gc = gdk_gc_new (
 		GDK_DRAWABLE (priv->main->window));
 
-	if (e_source_get_color (source, &colour)) {
+    const gchar* spec = e_source_peek_color_spec (source);
+	if (spec) {
 		GdkColor gcolour, dgcolour, tgcolour;
-		gcolour.red = ((colour & 0xFF0000) >> 16) * 0x101;
-		gcolour.green = ((colour & 0xFF00) >> 8)  * 0x101;
-		gcolour.blue = (colour & 0xFF) * 0x101;
-
+		gdk_color_parse(spec, &gcolour);
+        
 		/* This is simplified sRGB -> LAB conversion; we do not need it
 		 * entirely precise, as we are only going to chose between
 		 * black or white text based on the L value.
-- 
1.7.3.1