I#37 - Color support for iCalendar entries
[evolution.git] / src / calendar / gui / e-comp-editor-property-parts.c
blobb279a0ba2d98156070fbcb1d885e34ce7e05283e
1 /*
2 * Copyright (C) 2015 Red Hat, Inc. (www.redhat.com)
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by
6 * the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 * for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #include "evolution-config.h"
20 #include <errno.h>
21 #include <glib/gi18n-lib.h>
23 #include <libedataserver/libedataserver.h>
24 #include <e-util/e-util.h>
26 #include "calendar-config.h"
27 #include "e-timezone-entry.h"
29 #include "e-comp-editor-property-part.h"
30 #include "e-comp-editor-property-parts.h"
32 /* ************************************************************************* */
34 #define E_TYPE_COMP_EDITOR_PROPERTY_PART_SUMMARY \
35 (e_comp_editor_property_part_summary_get_type ())
36 #define E_COMP_EDITOR_PROPERTY_PART_SUMMARY(obj) \
37 (G_TYPE_CHECK_INSTANCE_CAST \
38 ((obj), E_TYPE_COMP_EDITOR_PROPERTY_PART_SUMMARY, ECompEditorPropertyPartSummary))
39 #define E_IS_COMP_EDITOR_PROPERTY_PART_SUMMARY(obj) \
40 (G_TYPE_CHECK_INSTANCE_TYPE \
41 ((obj), E_TYPE_COMP_EDITOR_PROPERTY_PART_SUMMARY))
43 typedef struct _ECompEditorPropertyPartSummary ECompEditorPropertyPartSummary;
44 typedef struct _ECompEditorPropertyPartSummaryClass ECompEditorPropertyPartSummaryClass;
46 struct _ECompEditorPropertyPartSummary {
47 ECompEditorPropertyPartString parent;
50 struct _ECompEditorPropertyPartSummaryClass {
51 ECompEditorPropertyPartStringClass parent_class;
54 GType e_comp_editor_property_part_summary_get_type (void) G_GNUC_CONST;
56 G_DEFINE_TYPE (ECompEditorPropertyPartSummary, e_comp_editor_property_part_summary, E_TYPE_COMP_EDITOR_PROPERTY_PART_STRING)
58 static void
59 ecepp_summary_create_widgets (ECompEditorPropertyPart *property_part,
60 GtkWidget **out_label_widget,
61 GtkWidget **out_edit_widget)
63 ECompEditorPropertyPartClass *part_class;
65 g_return_if_fail (E_IS_COMP_EDITOR_PROPERTY_PART_SUMMARY (property_part));
66 g_return_if_fail (out_label_widget != NULL);
67 g_return_if_fail (out_edit_widget != NULL);
69 part_class = E_COMP_EDITOR_PROPERTY_PART_CLASS (e_comp_editor_property_part_summary_parent_class);
70 g_return_if_fail (part_class != NULL);
71 g_return_if_fail (part_class->create_widgets != NULL);
73 *out_label_widget = NULL;
75 part_class->create_widgets (property_part, out_label_widget, out_edit_widget);
76 g_return_if_fail (*out_label_widget == NULL);
77 g_return_if_fail (*out_edit_widget != NULL);
79 *out_label_widget = gtk_label_new_with_mnemonic (C_("ECompEditor", "_Summary:"));
80 gtk_label_set_mnemonic_widget (GTK_LABEL (*out_label_widget), *out_edit_widget);
82 g_object_set (G_OBJECT (*out_label_widget),
83 "hexpand", FALSE,
84 "halign", GTK_ALIGN_END,
85 "vexpand", FALSE,
86 "valign", GTK_ALIGN_CENTER,
87 NULL);
89 gtk_widget_show (*out_label_widget);
92 static void
93 e_comp_editor_property_part_summary_init (ECompEditorPropertyPartSummary *part_summary)
97 static void
98 e_comp_editor_property_part_summary_class_init (ECompEditorPropertyPartSummaryClass *klass)
100 ECompEditorPropertyPartStringClass *part_string_class;
101 ECompEditorPropertyPartClass *part_class;
103 part_string_class = E_COMP_EDITOR_PROPERTY_PART_STRING_CLASS (klass);
104 part_string_class->entry_type = E_TYPE_SPELL_ENTRY;
105 part_string_class->ical_prop_kind = ICAL_SUMMARY_PROPERTY;
106 part_string_class->ical_new_func = icalproperty_new_summary;
107 part_string_class->ical_set_func = icalproperty_set_summary;
108 part_string_class->ical_get_func = icalproperty_get_summary;
110 part_class = E_COMP_EDITOR_PROPERTY_PART_CLASS (klass);
111 part_class->create_widgets = ecepp_summary_create_widgets;
114 ECompEditorPropertyPart *
115 e_comp_editor_property_part_summary_new (EFocusTracker *focus_tracker)
117 ECompEditorPropertyPart *property_part;
119 property_part = g_object_new (E_TYPE_COMP_EDITOR_PROPERTY_PART_SUMMARY, NULL);
121 e_comp_editor_property_part_string_attach_focus_tracker (
122 E_COMP_EDITOR_PROPERTY_PART_STRING (property_part), focus_tracker);
124 return property_part;
127 /* ************************************************************************* */
129 #define E_TYPE_COMP_EDITOR_PROPERTY_PART_LOCATION \
130 (e_comp_editor_property_part_location_get_type ())
131 #define E_COMP_EDITOR_PROPERTY_PART_LOCATION(obj) \
132 (G_TYPE_CHECK_INSTANCE_CAST \
133 ((obj), E_TYPE_COMP_EDITOR_PROPERTY_PART_LOCATION, ECompEditorPropertyPartLocation))
134 #define E_IS_COMP_EDITOR_PROPERTY_PART_LOCATION(obj) \
135 (G_TYPE_CHECK_INSTANCE_TYPE \
136 ((obj), E_TYPE_COMP_EDITOR_PROPERTY_PART_LOCATION))
138 typedef struct _ECompEditorPropertyPartLocation ECompEditorPropertyPartLocation;
139 typedef struct _ECompEditorPropertyPartLocationClass ECompEditorPropertyPartLocationClass;
141 struct _ECompEditorPropertyPartLocation {
142 ECompEditorPropertyPartString parent;
145 struct _ECompEditorPropertyPartLocationClass {
146 ECompEditorPropertyPartStringClass parent_class;
149 GType e_comp_editor_property_part_location_get_type (void) G_GNUC_CONST;
151 G_DEFINE_TYPE (ECompEditorPropertyPartLocation, e_comp_editor_property_part_location, E_TYPE_COMP_EDITOR_PROPERTY_PART_STRING)
153 static gchar *
154 ecepp_location_get_locations_filename (gboolean config_dir_only)
156 return g_build_filename (e_get_user_config_dir (), "calendar", config_dir_only ? NULL : "locations", NULL);
159 static void
160 ecepp_location_load_list (GtkEntry *entry)
162 GtkEntryCompletion *completion;
163 GtkListStore *store;
164 gchar *filename, *contents = NULL;
165 gchar **locations;
166 gint row;
167 GError *error = NULL;
169 g_return_if_fail (GTK_IS_ENTRY (entry));
171 completion = gtk_entry_get_completion (entry);
172 g_return_if_fail (completion != NULL);
174 filename = ecepp_location_get_locations_filename (FALSE);
176 if (!g_file_test (filename, G_FILE_TEST_EXISTS)) {
177 g_free (filename);
178 return;
181 if (!g_file_get_contents (filename, &contents, NULL, &error)) {
182 if (error != NULL) {
183 g_warning (
184 "%s: Failed to load locations list '%s': %s",
185 G_STRFUNC, filename, error->message);
186 g_error_free (error);
189 g_free (filename);
190 return;
193 locations = g_strsplit (contents, "\n", 0);
194 if (!locations) {
195 g_free (contents);
196 g_free (filename);
197 return;
200 row = 0;
201 store = GTK_LIST_STORE (gtk_entry_completion_get_model (completion));
202 while (locations[row] && *locations[row]) {
203 GtkTreeIter iter;
204 gtk_list_store_append (store, &iter);
205 gtk_list_store_set (store, &iter, 0, locations[row], -1);
206 row++;
209 g_strfreev (locations);
210 g_free (contents);
211 g_free (filename);
214 static void
215 ecepp_location_save_list (GtkEntry *entry)
217 GtkEntryCompletion *completion;
218 GtkTreeModel *model;
219 GtkTreeIter iter;
220 const gchar *current_location;
221 gchar *filename, *stored_content = NULL;
222 gboolean needs_save = TRUE;
223 GString *contents;
224 GError *error = NULL;
226 g_return_if_fail (GTK_IS_ENTRY (entry));
228 completion = gtk_entry_get_completion (entry);
229 g_return_if_fail (completion != NULL);
231 filename = ecepp_location_get_locations_filename (TRUE);
233 if (!g_file_test (filename, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
234 gint r = g_mkdir_with_parents (filename, 0700);
235 if (r < 0) {
236 g_warning ("%s: Failed to create %s: %s", G_STRFUNC, filename, g_strerror (errno));
237 g_free (filename);
238 return;
242 g_free (filename);
244 filename = ecepp_location_get_locations_filename (FALSE);
245 current_location = gtk_entry_get_text (entry);
247 /* Put current locatin on the very top of the list */
248 contents = g_string_new (current_location);
249 if (contents->len > 0)
250 g_string_append_c (contents, '\n');
252 model = gtk_entry_completion_get_model (completion);
253 if (gtk_tree_model_get_iter_first (model, &iter)) {
254 gint i = 0;
255 do {
256 gchar *str;
258 gtk_tree_model_get (model, &iter, 0, &str, -1);
260 /* Skip the current location */
261 if (str && *str && g_ascii_strcasecmp (str, current_location) != 0)
262 g_string_append_printf (contents, "%s\n", str);
264 g_free (str);
266 i++;
268 } while (gtk_tree_model_iter_next (model, &iter) && (i < 20));
271 if (g_file_get_contents (filename, &stored_content, NULL, NULL)) {
272 needs_save = g_strcmp0 (stored_content, contents->str) != 0;
273 g_free (stored_content);
276 if (needs_save) {
277 g_file_set_contents (filename, contents->str, -1, &error);
278 if (error != NULL) {
279 g_warning (
280 "%s: Failed to save locations '%s': %s",
281 G_STRFUNC, filename, error->message);
282 g_error_free (error);
286 g_string_free (contents, TRUE);
287 g_free (filename);
290 static void
291 ecepp_location_create_widgets (ECompEditorPropertyPart *property_part,
292 GtkWidget **out_label_widget,
293 GtkWidget **out_edit_widget)
295 ECompEditorPropertyPartClass *part_class;
296 GtkEntryCompletion *completion;
297 GtkListStore *list_store;
299 g_return_if_fail (E_IS_COMP_EDITOR_PROPERTY_PART_LOCATION (property_part));
300 g_return_if_fail (out_label_widget != NULL);
301 g_return_if_fail (out_edit_widget != NULL);
303 part_class = E_COMP_EDITOR_PROPERTY_PART_CLASS (e_comp_editor_property_part_location_parent_class);
304 g_return_if_fail (part_class != NULL);
305 g_return_if_fail (part_class->create_widgets != NULL);
307 *out_label_widget = NULL;
309 part_class->create_widgets (property_part, out_label_widget, out_edit_widget);
311 g_return_if_fail (*out_label_widget == NULL);
312 g_return_if_fail (*out_edit_widget != NULL);
314 completion = gtk_entry_completion_new ();
316 list_store = gtk_list_store_new (1, G_TYPE_STRING);
317 gtk_entry_completion_set_model (completion, GTK_TREE_MODEL (list_store));
318 gtk_entry_completion_set_text_column (completion, 0);
320 gtk_entry_set_completion (GTK_ENTRY (*out_edit_widget), completion);
321 g_object_unref (completion);
323 *out_label_widget = gtk_label_new_with_mnemonic (C_("ECompEditor", "_Location:"));
324 gtk_label_set_mnemonic_widget (GTK_LABEL (*out_label_widget), *out_edit_widget);
326 g_object_set (G_OBJECT (*out_label_widget),
327 "hexpand", FALSE,
328 "halign", GTK_ALIGN_END,
329 "vexpand", FALSE,
330 "valign", GTK_ALIGN_CENTER,
331 NULL);
333 gtk_widget_show (*out_label_widget);
335 ecepp_location_load_list (GTK_ENTRY (*out_edit_widget));
338 static void
339 ecepp_location_fill_component (ECompEditorPropertyPart *property_part,
340 icalcomponent *component)
342 ECompEditorPropertyPartClass *part_class;
343 GtkWidget *edit_widget;
345 g_return_if_fail (E_IS_COMP_EDITOR_PROPERTY_PART_LOCATION (property_part));
347 part_class = E_COMP_EDITOR_PROPERTY_PART_CLASS (e_comp_editor_property_part_location_parent_class);
348 g_return_if_fail (part_class != NULL);
349 g_return_if_fail (part_class->fill_component != NULL);
351 part_class->fill_component (property_part, component);
353 edit_widget = e_comp_editor_property_part_get_edit_widget (property_part);
354 g_return_if_fail (GTK_IS_ENTRY (edit_widget));
356 ecepp_location_save_list (GTK_ENTRY (edit_widget));
359 static void
360 e_comp_editor_property_part_location_init (ECompEditorPropertyPartLocation *part_location)
364 static void
365 e_comp_editor_property_part_location_class_init (ECompEditorPropertyPartLocationClass *klass)
367 ECompEditorPropertyPartStringClass *part_string_class;
368 ECompEditorPropertyPartClass *part_class;
370 part_string_class = E_COMP_EDITOR_PROPERTY_PART_STRING_CLASS (klass);
371 part_string_class->ical_prop_kind = ICAL_LOCATION_PROPERTY;
372 part_string_class->ical_new_func = icalproperty_new_location;
373 part_string_class->ical_set_func = icalproperty_set_location;
374 part_string_class->ical_get_func = icalproperty_get_location;
376 part_class = E_COMP_EDITOR_PROPERTY_PART_CLASS (klass);
377 part_class->create_widgets = ecepp_location_create_widgets;
378 part_class->fill_component = ecepp_location_fill_component;
381 ECompEditorPropertyPart *
382 e_comp_editor_property_part_location_new (EFocusTracker *focus_tracker)
384 ECompEditorPropertyPart *property_part;
386 property_part = g_object_new (E_TYPE_COMP_EDITOR_PROPERTY_PART_LOCATION, NULL);
388 e_comp_editor_property_part_string_attach_focus_tracker (
389 E_COMP_EDITOR_PROPERTY_PART_STRING (property_part), focus_tracker);
391 return property_part;
394 /* ************************************************************************* */
396 #define E_TYPE_COMP_EDITOR_PROPERTY_PART_CATEGORIES \
397 (e_comp_editor_property_part_categories_get_type ())
398 #define E_COMP_EDITOR_PROPERTY_PART_CATEGORIES(obj) \
399 (G_TYPE_CHECK_INSTANCE_CAST \
400 ((obj), E_TYPE_COMP_EDITOR_PROPERTY_PART_CATEGORIES, ECompEditorPropertyPartCategories))
401 #define E_IS_COMP_EDITOR_PROPERTY_PART_CATEGORIES(obj) \
402 (G_TYPE_CHECK_INSTANCE_TYPE \
403 ((obj), E_TYPE_COMP_EDITOR_PROPERTY_PART_CATEGORIES))
405 typedef struct _ECompEditorPropertyPartCategories ECompEditorPropertyPartCategories;
406 typedef struct _ECompEditorPropertyPartCategoriesClass ECompEditorPropertyPartCategoriesClass;
408 struct _ECompEditorPropertyPartCategories {
409 ECompEditorPropertyPartString parent;
412 struct _ECompEditorPropertyPartCategoriesClass {
413 ECompEditorPropertyPartStringClass parent_class;
416 GType e_comp_editor_property_part_categories_get_type (void) G_GNUC_CONST;
418 G_DEFINE_TYPE (ECompEditorPropertyPartCategories, e_comp_editor_property_part_categories, E_TYPE_COMP_EDITOR_PROPERTY_PART_STRING)
420 static void
421 ecepp_categories_button_clicked_cb (GtkButton *button,
422 GtkEntry *entry)
424 g_return_if_fail (GTK_IS_ENTRY (entry));
426 e_categories_config_open_dialog_for_entry (entry);
429 static void
430 ecepp_categories_create_widgets (ECompEditorPropertyPart *property_part,
431 GtkWidget **out_label_widget,
432 GtkWidget **out_edit_widget)
434 ECompEditorPropertyPartClass *part_class;
435 GtkEntryCompletion *completion;
436 GtkWidget *button;
438 g_return_if_fail (E_IS_COMP_EDITOR_PROPERTY_PART_CATEGORIES (property_part));
439 g_return_if_fail (out_label_widget != NULL);
440 g_return_if_fail (out_edit_widget != NULL);
442 part_class = E_COMP_EDITOR_PROPERTY_PART_CLASS (e_comp_editor_property_part_categories_parent_class);
443 g_return_if_fail (part_class != NULL);
444 g_return_if_fail (part_class->create_widgets != NULL);
446 *out_label_widget = NULL;
448 part_class->create_widgets (property_part, out_label_widget, out_edit_widget);
449 g_return_if_fail (*out_label_widget == NULL);
450 g_return_if_fail (*out_edit_widget != NULL);
452 completion = e_category_completion_new ();
453 gtk_entry_set_completion (GTK_ENTRY (*out_edit_widget), completion);
454 g_object_unref (completion);
456 button = gtk_button_new_with_mnemonic (C_("ECompEditor", "_Categories..."));
457 g_signal_connect (button, "clicked", G_CALLBACK (ecepp_categories_button_clicked_cb), *out_edit_widget);
459 *out_label_widget = button;
461 g_object_set (G_OBJECT (*out_label_widget),
462 "hexpand", FALSE,
463 "halign", GTK_ALIGN_END,
464 "vexpand", FALSE,
465 "valign", GTK_ALIGN_CENTER,
466 NULL);
468 gtk_widget_show (*out_label_widget);
471 static void
472 e_comp_editor_property_part_categories_init (ECompEditorPropertyPartCategories *part_categories)
474 e_comp_editor_property_part_string_set_is_multivalue (
475 E_COMP_EDITOR_PROPERTY_PART_STRING (part_categories), TRUE);
478 static void
479 e_comp_editor_property_part_categories_class_init (ECompEditorPropertyPartCategoriesClass *klass)
481 ECompEditorPropertyPartStringClass *part_string_class;
482 ECompEditorPropertyPartClass *part_class;
484 part_string_class = E_COMP_EDITOR_PROPERTY_PART_STRING_CLASS (klass);
485 part_string_class->ical_prop_kind = ICAL_CATEGORIES_PROPERTY;
486 part_string_class->ical_new_func = icalproperty_new_categories;
487 part_string_class->ical_set_func = icalproperty_set_categories;
488 part_string_class->ical_get_func = icalproperty_get_categories;
490 part_class = E_COMP_EDITOR_PROPERTY_PART_CLASS (klass);
491 part_class->create_widgets = ecepp_categories_create_widgets;
494 ECompEditorPropertyPart *
495 e_comp_editor_property_part_categories_new (EFocusTracker *focus_tracker)
497 ECompEditorPropertyPart *property_part;
499 property_part = g_object_new (E_TYPE_COMP_EDITOR_PROPERTY_PART_CATEGORIES, NULL);
501 e_comp_editor_property_part_string_attach_focus_tracker (
502 E_COMP_EDITOR_PROPERTY_PART_STRING (property_part), focus_tracker);
504 return property_part;
507 /* ************************************************************************* */
509 #define E_TYPE_COMP_EDITOR_PROPERTY_PART_DESCRIPTION \
510 (e_comp_editor_property_part_description_get_type ())
511 #define E_COMP_EDITOR_PROPERTY_PART_DESCRIPTION(obj) \
512 (G_TYPE_CHECK_INSTANCE_CAST \
513 ((obj), E_TYPE_COMP_EDITOR_PROPERTY_PART_DESCRIPTION, ECompEditorPropertyPartDescription))
514 #define E_IS_COMP_EDITOR_PROPERTY_PART_DESCRIPTION(obj) \
515 (G_TYPE_CHECK_INSTANCE_TYPE \
516 ((obj), E_TYPE_COMP_EDITOR_PROPERTY_PART_DESCRIPTION))
518 typedef struct _ECompEditorPropertyPartDescription ECompEditorPropertyPartDescription;
519 typedef struct _ECompEditorPropertyPartDescriptionClass ECompEditorPropertyPartDescriptionClass;
521 struct _ECompEditorPropertyPartDescription {
522 ECompEditorPropertyPartString parent;
525 struct _ECompEditorPropertyPartDescriptionClass {
526 ECompEditorPropertyPartStringClass parent_class;
529 GType e_comp_editor_property_part_description_get_type (void) G_GNUC_CONST;
531 G_DEFINE_TYPE (ECompEditorPropertyPartDescription, e_comp_editor_property_part_description, E_TYPE_COMP_EDITOR_PROPERTY_PART_STRING)
533 static void
534 ecepp_description_create_widgets (ECompEditorPropertyPart *property_part,
535 GtkWidget **out_label_widget,
536 GtkWidget **out_edit_widget)
538 ECompEditorPropertyPartClass *part_class;
539 GtkTextView *text_view;
541 g_return_if_fail (E_IS_COMP_EDITOR_PROPERTY_PART_DESCRIPTION (property_part));
542 g_return_if_fail (out_label_widget != NULL);
543 g_return_if_fail (out_edit_widget != NULL);
545 part_class = E_COMP_EDITOR_PROPERTY_PART_CLASS (e_comp_editor_property_part_description_parent_class);
546 g_return_if_fail (part_class != NULL);
547 g_return_if_fail (part_class->create_widgets != NULL);
549 *out_label_widget = NULL;
551 part_class->create_widgets (property_part, out_label_widget, out_edit_widget);
552 g_return_if_fail (*out_label_widget == NULL);
553 g_return_if_fail (*out_edit_widget != NULL);
555 *out_label_widget = gtk_label_new_with_mnemonic (C_("ECompEditor", "_Description:"));
556 gtk_label_set_mnemonic_widget (GTK_LABEL (*out_label_widget), *out_edit_widget);
558 text_view = GTK_TEXT_VIEW (gtk_bin_get_child (GTK_BIN (*out_edit_widget)));
559 gtk_text_view_set_wrap_mode (text_view, GTK_WRAP_WORD);
560 gtk_text_view_set_monospace (text_view, TRUE);
561 e_buffer_tagger_connect (text_view);
562 e_spell_text_view_attach (text_view);
564 g_object_set (G_OBJECT (*out_label_widget),
565 "hexpand", FALSE,
566 "halign", GTK_ALIGN_END,
567 "vexpand", FALSE,
568 "valign", GTK_ALIGN_START,
569 NULL);
571 g_object_set (G_OBJECT (*out_edit_widget),
572 "hexpand", TRUE,
573 "halign", GTK_ALIGN_FILL,
574 "vexpand", TRUE,
575 "valign", GTK_ALIGN_FILL,
576 "height-request", 100,
577 NULL);
579 gtk_widget_show (*out_label_widget);
582 static void
583 ecepp_description_fill_widget (ECompEditorPropertyPart *property_part,
584 icalcomponent *component)
586 ECompEditorPropertyPartClass *part_class;
587 GtkWidget *edit_widget;
589 g_return_if_fail (E_IS_COMP_EDITOR_PROPERTY_PART_DESCRIPTION (property_part));
590 g_return_if_fail (component != NULL);
592 part_class = E_COMP_EDITOR_PROPERTY_PART_CLASS (e_comp_editor_property_part_description_parent_class);
593 g_return_if_fail (part_class != NULL);
594 g_return_if_fail (part_class->fill_widget != NULL);
596 part_class->fill_widget (property_part, component);
598 edit_widget = e_comp_editor_property_part_get_edit_widget (property_part);
599 g_return_if_fail (GTK_IS_SCROLLED_WINDOW (edit_widget));
601 e_buffer_tagger_update_tags (GTK_TEXT_VIEW (gtk_bin_get_child (GTK_BIN (edit_widget))));
604 static void
605 e_comp_editor_property_part_description_init (ECompEditorPropertyPartDescription *part_description)
609 static void
610 e_comp_editor_property_part_description_class_init (ECompEditorPropertyPartDescriptionClass *klass)
612 ECompEditorPropertyPartStringClass *part_string_class;
613 ECompEditorPropertyPartClass *part_class;
615 part_string_class = E_COMP_EDITOR_PROPERTY_PART_STRING_CLASS (klass);
616 part_string_class->entry_type = GTK_TYPE_TEXT_VIEW;
617 part_string_class->ical_prop_kind = ICAL_DESCRIPTION_PROPERTY;
618 part_string_class->ical_new_func = icalproperty_new_description;
619 part_string_class->ical_set_func = icalproperty_set_description;
620 part_string_class->ical_get_func = icalproperty_get_description;
622 part_class = E_COMP_EDITOR_PROPERTY_PART_CLASS (klass);
623 part_class->create_widgets = ecepp_description_create_widgets;
624 part_class->fill_widget = ecepp_description_fill_widget;
627 ECompEditorPropertyPart *
628 e_comp_editor_property_part_description_new (EFocusTracker *focus_tracker)
630 ECompEditorPropertyPart *property_part;
632 property_part = g_object_new (E_TYPE_COMP_EDITOR_PROPERTY_PART_DESCRIPTION, NULL);
634 e_comp_editor_property_part_string_attach_focus_tracker (
635 E_COMP_EDITOR_PROPERTY_PART_STRING (property_part), focus_tracker);
637 return property_part;
640 /* ************************************************************************* */
642 #define E_TYPE_COMP_EDITOR_PROPERTY_PART_URL \
643 (e_comp_editor_property_part_url_get_type ())
644 #define E_COMP_EDITOR_PROPERTY_PART_URL(obj) \
645 (G_TYPE_CHECK_INSTANCE_CAST \
646 ((obj), E_TYPE_COMP_EDITOR_PROPERTY_PART_URL, ECompEditorPropertyPartUrl))
647 #define E_IS_COMP_EDITOR_PROPERTY_PART_URL(obj) \
648 (G_TYPE_CHECK_INSTANCE_TYPE \
649 ((obj), E_TYPE_COMP_EDITOR_PROPERTY_PART_URL))
651 typedef struct _ECompEditorPropertyPartUrl ECompEditorPropertyPartUrl;
652 typedef struct _ECompEditorPropertyPartUrlClass ECompEditorPropertyPartUrlClass;
654 struct _ECompEditorPropertyPartUrl {
655 ECompEditorPropertyPartString parent;
658 struct _ECompEditorPropertyPartUrlClass {
659 ECompEditorPropertyPartStringClass parent_class;
662 GType e_comp_editor_property_part_url_get_type (void) G_GNUC_CONST;
664 G_DEFINE_TYPE (ECompEditorPropertyPartUrl, e_comp_editor_property_part_url, E_TYPE_COMP_EDITOR_PROPERTY_PART_STRING)
666 static void
667 ecepp_url_create_widgets (ECompEditorPropertyPart *property_part,
668 GtkWidget **out_label_widget,
669 GtkWidget **out_edit_widget)
671 ECompEditorPropertyPartClass *part_class;
673 g_return_if_fail (E_IS_COMP_EDITOR_PROPERTY_PART_URL (property_part));
674 g_return_if_fail (out_label_widget != NULL);
675 g_return_if_fail (out_edit_widget != NULL);
677 part_class = E_COMP_EDITOR_PROPERTY_PART_CLASS (e_comp_editor_property_part_url_parent_class);
678 g_return_if_fail (part_class != NULL);
679 g_return_if_fail (part_class->create_widgets != NULL);
681 *out_label_widget = NULL;
683 part_class->create_widgets (property_part, out_label_widget, out_edit_widget);
684 g_return_if_fail (*out_label_widget == NULL);
685 g_return_if_fail (*out_edit_widget != NULL);
687 *out_label_widget = gtk_label_new_with_mnemonic (C_("ECompEditor", "_Web page:"));
688 gtk_label_set_mnemonic_widget (GTK_LABEL (*out_label_widget), *out_edit_widget);
690 g_object_set (G_OBJECT (*out_label_widget),
691 "hexpand", FALSE,
692 "halign", GTK_ALIGN_END,
693 "vexpand", FALSE,
694 "valign", GTK_ALIGN_CENTER,
695 NULL);
697 gtk_widget_show (*out_label_widget);
700 static void
701 e_comp_editor_property_part_url_init (ECompEditorPropertyPartUrl *part_url)
705 static void
706 e_comp_editor_property_part_url_class_init (ECompEditorPropertyPartUrlClass *klass)
708 ECompEditorPropertyPartStringClass *part_string_class;
709 ECompEditorPropertyPartClass *part_class;
711 part_string_class = E_COMP_EDITOR_PROPERTY_PART_STRING_CLASS (klass);
712 part_string_class->entry_type = E_TYPE_URL_ENTRY;
713 part_string_class->ical_prop_kind = ICAL_URL_PROPERTY;
714 part_string_class->ical_new_func = icalproperty_new_url;
715 part_string_class->ical_set_func = icalproperty_set_url;
716 part_string_class->ical_get_func = icalproperty_get_url;
718 part_class = E_COMP_EDITOR_PROPERTY_PART_CLASS (klass);
719 part_class->create_widgets = ecepp_url_create_widgets;
722 ECompEditorPropertyPart *
723 e_comp_editor_property_part_url_new (EFocusTracker *focus_tracker)
725 ECompEditorPropertyPart *property_part;
727 property_part = g_object_new (E_TYPE_COMP_EDITOR_PROPERTY_PART_URL, NULL);
729 e_comp_editor_property_part_string_attach_focus_tracker (
730 E_COMP_EDITOR_PROPERTY_PART_STRING (property_part), focus_tracker);
732 return property_part;
735 /* ************************************************************************* */
737 #define E_TYPE_COMP_EDITOR_PROPERTY_PART_DATETIME_LABELED \
738 (e_comp_editor_property_part_datetime_labeled_get_type ())
739 #define E_COMP_EDITOR_PROPERTY_PART_DATETIME_LABELED(obj) \
740 (G_TYPE_CHECK_INSTANCE_CAST \
741 ((obj), E_TYPE_COMP_EDITOR_PROPERTY_PART_DATETIME_LABELED, ECompEditorPropertyPartDatetimeLabeled))
742 #define E_IS_COMP_EDITOR_PROPERTY_PART_DATETIME_LABELED(obj) \
743 (G_TYPE_CHECK_INSTANCE_TYPE \
744 ((obj), E_TYPE_COMP_EDITOR_PROPERTY_PART_DATETIME_LABELED))
746 typedef struct _ECompEditorPropertyPartDatetimeLabeled ECompEditorPropertyPartDatetimeLabeled;
747 typedef struct _ECompEditorPropertyPartDatetimeLabeledClass ECompEditorPropertyPartDatetimeLabeledClass;
749 struct _ECompEditorPropertyPartDatetimeLabeled {
750 ECompEditorPropertyPartDatetime parent;
752 gchar *label;
755 struct _ECompEditorPropertyPartDatetimeLabeledClass {
756 ECompEditorPropertyPartDatetimeClass parent_class;
759 GType e_comp_editor_property_part_datetime_labeled_get_type (void) G_GNUC_CONST;
761 enum {
762 DATETIME_LABELED_PROP_0,
763 DATETIME_LABELED_PROP_LABEL
766 G_DEFINE_ABSTRACT_TYPE (ECompEditorPropertyPartDatetimeLabeled, e_comp_editor_property_part_datetime_labeled, E_TYPE_COMP_EDITOR_PROPERTY_PART_DATETIME)
768 static void
769 ecepp_datetime_labeled_create_widgets (ECompEditorPropertyPart *property_part,
770 GtkWidget **out_label_widget,
771 GtkWidget **out_edit_widget)
773 ECompEditorPropertyPartDatetimeLabeled *part_datetime_labeled;
774 ECompEditorPropertyPartClass *part_class;
776 g_return_if_fail (E_IS_COMP_EDITOR_PROPERTY_PART_DATETIME_LABELED (property_part));
777 g_return_if_fail (out_label_widget != NULL);
778 g_return_if_fail (out_edit_widget != NULL);
780 part_class = E_COMP_EDITOR_PROPERTY_PART_CLASS (e_comp_editor_property_part_datetime_labeled_parent_class);
781 g_return_if_fail (part_class != NULL);
782 g_return_if_fail (part_class->create_widgets != NULL);
784 part_datetime_labeled = E_COMP_EDITOR_PROPERTY_PART_DATETIME_LABELED (property_part);
786 *out_label_widget = NULL;
788 part_class->create_widgets (property_part, out_label_widget, out_edit_widget);
789 g_return_if_fail (*out_label_widget == NULL);
790 g_return_if_fail (*out_edit_widget != NULL);
792 *out_label_widget = gtk_label_new_with_mnemonic (part_datetime_labeled->label);
793 gtk_label_set_mnemonic_widget (GTK_LABEL (*out_label_widget), *out_edit_widget);
795 g_object_set (G_OBJECT (*out_label_widget),
796 "hexpand", FALSE,
797 "halign", GTK_ALIGN_END,
798 "vexpand", FALSE,
799 "valign", GTK_ALIGN_CENTER,
800 NULL);
802 gtk_widget_show (*out_label_widget);
805 static void
806 ecepp_datetime_labeled_set_property (GObject *object,
807 guint property_id,
808 const GValue *value,
809 GParamSpec *pspec)
811 ECompEditorPropertyPartDatetimeLabeled *part_datetime_labeled;
813 g_return_if_fail (E_IS_COMP_EDITOR_PROPERTY_PART_DATETIME_LABELED (object));
815 part_datetime_labeled = E_COMP_EDITOR_PROPERTY_PART_DATETIME_LABELED (object);
817 switch (property_id) {
818 case DATETIME_LABELED_PROP_LABEL:
819 g_free (part_datetime_labeled->label);
820 part_datetime_labeled->label = g_value_dup_string (value);
821 return;
824 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
827 static void
828 ecepp_datetime_labeled_finalize (GObject *object)
830 ECompEditorPropertyPartDatetimeLabeled *part_datetime_labeled;
832 part_datetime_labeled = E_COMP_EDITOR_PROPERTY_PART_DATETIME_LABELED (object);
834 g_free (part_datetime_labeled->label);
835 part_datetime_labeled->label = NULL;
837 G_OBJECT_CLASS (e_comp_editor_property_part_datetime_labeled_parent_class)->finalize (object);
840 static void
841 e_comp_editor_property_part_datetime_labeled_init (ECompEditorPropertyPartDatetimeLabeled *part_datetime_labeled)
845 static void
846 e_comp_editor_property_part_datetime_labeled_class_init (ECompEditorPropertyPartDatetimeLabeledClass *klass)
848 ECompEditorPropertyPartClass *part_class;
849 GObjectClass *object_class;
851 part_class = E_COMP_EDITOR_PROPERTY_PART_CLASS (klass);
852 part_class->create_widgets = ecepp_datetime_labeled_create_widgets;
854 object_class = G_OBJECT_CLASS (klass);
855 object_class->set_property = ecepp_datetime_labeled_set_property;
856 object_class->finalize = ecepp_datetime_labeled_finalize;
858 g_object_class_install_property (
859 object_class,
860 DATETIME_LABELED_PROP_LABEL,
861 g_param_spec_string (
862 "label",
863 "Label",
864 "Label of the datetime",
865 NULL,
866 G_PARAM_WRITABLE |
867 G_PARAM_CONSTRUCT_ONLY |
868 G_PARAM_STATIC_STRINGS));
871 static void
872 e_comp_editor_property_part_datetime_labeled_setup (ECompEditorPropertyPartDatetimeLabeled *part_datetime_labeled,
873 gboolean date_only,
874 gboolean allow_no_date_set)
876 ECompEditorPropertyPartDatetime *part_datetime;
878 g_return_if_fail (E_IS_COMP_EDITOR_PROPERTY_PART_DATETIME_LABELED (part_datetime_labeled));
880 part_datetime = E_COMP_EDITOR_PROPERTY_PART_DATETIME (part_datetime_labeled);
882 e_comp_editor_property_part_datetime_set_date_only (part_datetime, date_only);
883 e_comp_editor_property_part_datetime_set_allow_no_date_set (part_datetime, allow_no_date_set);
886 /* ************************************************************************* */
888 #define E_TYPE_COMP_EDITOR_PROPERTY_PART_DTSTART \
889 (e_comp_editor_property_part_dtstart_get_type ())
890 #define E_COMP_EDITOR_PROPERTY_PART_DTSTART(obj) \
891 (G_TYPE_CHECK_INSTANCE_CAST \
892 ((obj), E_TYPE_COMP_EDITOR_PROPERTY_PART_DTSTART, ECompEditorPropertyPartDtstart))
893 #define E_IS_COMP_EDITOR_PROPERTY_PART_DTSTART(obj) \
894 (G_TYPE_CHECK_INSTANCE_TYPE \
895 ((obj), E_TYPE_COMP_EDITOR_PROPERTY_PART_DTSTART))
897 typedef struct _ECompEditorPropertyPartDtstart ECompEditorPropertyPartDtstart;
898 typedef struct _ECompEditorPropertyPartDtstartClass ECompEditorPropertyPartDtstartClass;
900 struct _ECompEditorPropertyPartDtstart {
901 ECompEditorPropertyPartDatetimeLabeled parent;
904 struct _ECompEditorPropertyPartDtstartClass {
905 ECompEditorPropertyPartDatetimeLabeledClass parent_class;
908 GType e_comp_editor_property_part_dtstart_get_type (void) G_GNUC_CONST;
910 G_DEFINE_TYPE (ECompEditorPropertyPartDtstart, e_comp_editor_property_part_dtstart, E_TYPE_COMP_EDITOR_PROPERTY_PART_DATETIME_LABELED)
912 static void
913 e_comp_editor_property_part_dtstart_init (ECompEditorPropertyPartDtstart *part_dtstart)
917 static void
918 e_comp_editor_property_part_dtstart_class_init (ECompEditorPropertyPartDtstartClass *klass)
920 ECompEditorPropertyPartDatetimeClass *part_datetime_class;
922 part_datetime_class = E_COMP_EDITOR_PROPERTY_PART_DATETIME_CLASS (klass);
923 part_datetime_class->ical_prop_kind = ICAL_DTSTART_PROPERTY;
924 part_datetime_class->ical_new_func = icalproperty_new_dtstart;
925 part_datetime_class->ical_set_func = icalproperty_set_dtstart;
926 part_datetime_class->ical_get_func = icalproperty_get_dtstart;
929 ECompEditorPropertyPart *
930 e_comp_editor_property_part_dtstart_new (const gchar *label,
931 gboolean date_only,
932 gboolean allow_no_date_set)
934 ECompEditorPropertyPart *part;
936 part = g_object_new (E_TYPE_COMP_EDITOR_PROPERTY_PART_DTSTART,
937 "label", label,
938 NULL);
940 e_comp_editor_property_part_datetime_labeled_setup (
941 E_COMP_EDITOR_PROPERTY_PART_DATETIME_LABELED (part),
942 date_only, allow_no_date_set);
944 return part;
947 /* ************************************************************************* */
949 #define E_TYPE_COMP_EDITOR_PROPERTY_PART_DTEND \
950 (e_comp_editor_property_part_dtend_get_type ())
951 #define E_COMP_EDITOR_PROPERTY_PART_DTEND(obj) \
952 (G_TYPE_CHECK_INSTANCE_CAST \
953 ((obj), E_TYPE_COMP_EDITOR_PROPERTY_PART_DTEND, ECompEditorPropertyPartDtend))
954 #define E_IS_COMP_EDITOR_PROPERTY_PART_DTEND(obj) \
955 (G_TYPE_CHECK_INSTANCE_TYPE \
956 ((obj), E_TYPE_COMP_EDITOR_PROPERTY_PART_DTEND))
958 typedef struct _ECompEditorPropertyPartDtend ECompEditorPropertyPartDtend;
959 typedef struct _ECompEditorPropertyPartDtendClass ECompEditorPropertyPartDtendClass;
961 struct _ECompEditorPropertyPartDtend {
962 ECompEditorPropertyPartDatetimeLabeled parent;
965 struct _ECompEditorPropertyPartDtendClass {
966 ECompEditorPropertyPartDatetimeLabeledClass parent_class;
969 GType e_comp_editor_property_part_dtend_get_type (void) G_GNUC_CONST;
971 G_DEFINE_TYPE (ECompEditorPropertyPartDtend, e_comp_editor_property_part_dtend, E_TYPE_COMP_EDITOR_PROPERTY_PART_DATETIME_LABELED)
973 static void
974 e_comp_editor_property_part_dtend_init (ECompEditorPropertyPartDtend *part_dtend)
978 static void
979 e_comp_editor_property_part_dtend_class_init (ECompEditorPropertyPartDtendClass *klass)
981 ECompEditorPropertyPartDatetimeClass *part_datetime_class;
983 part_datetime_class = E_COMP_EDITOR_PROPERTY_PART_DATETIME_CLASS (klass);
984 part_datetime_class->ical_prop_kind = ICAL_DTEND_PROPERTY;
985 part_datetime_class->ical_new_func = icalproperty_new_dtend;
986 part_datetime_class->ical_set_func = icalproperty_set_dtend;
987 part_datetime_class->ical_get_func = icalproperty_get_dtend;
990 ECompEditorPropertyPart *
991 e_comp_editor_property_part_dtend_new (const gchar *label,
992 gboolean date_only,
993 gboolean allow_no_date_set)
995 ECompEditorPropertyPart *part;
997 part = g_object_new (E_TYPE_COMP_EDITOR_PROPERTY_PART_DTEND,
998 "label", label,
999 NULL);
1001 e_comp_editor_property_part_datetime_labeled_setup (
1002 E_COMP_EDITOR_PROPERTY_PART_DATETIME_LABELED (part),
1003 date_only, allow_no_date_set);
1005 return part;
1008 /* ************************************************************************* */
1010 #define E_TYPE_COMP_EDITOR_PROPERTY_PART_DUE \
1011 (e_comp_editor_property_part_due_get_type ())
1012 #define E_COMP_EDITOR_PROPERTY_PART_DUE(obj) \
1013 (G_TYPE_CHECK_INSTANCE_CAST \
1014 ((obj), E_TYPE_COMP_EDITOR_PROPERTY_PART_DUE, ECompEditorPropertyPartDue))
1015 #define E_IS_COMP_EDITOR_PROPERTY_PART_DUE(obj) \
1016 (G_TYPE_CHECK_INSTANCE_TYPE \
1017 ((obj), E_TYPE_COMP_EDITOR_PROPERTY_PART_DUE))
1019 typedef struct _ECompEditorPropertyPartDue ECompEditorPropertyPartDue;
1020 typedef struct _ECompEditorPropertyPartDueClass ECompEditorPropertyPartDueClass;
1022 struct _ECompEditorPropertyPartDue {
1023 ECompEditorPropertyPartDatetimeLabeled parent;
1026 struct _ECompEditorPropertyPartDueClass {
1027 ECompEditorPropertyPartDatetimeLabeledClass parent_class;
1030 GType e_comp_editor_property_part_due_get_type (void) G_GNUC_CONST;
1032 G_DEFINE_TYPE (ECompEditorPropertyPartDue, e_comp_editor_property_part_due, E_TYPE_COMP_EDITOR_PROPERTY_PART_DATETIME_LABELED)
1034 static void
1035 e_comp_editor_property_part_due_init (ECompEditorPropertyPartDue *part_due)
1039 static void
1040 e_comp_editor_property_part_due_class_init (ECompEditorPropertyPartDueClass *klass)
1042 ECompEditorPropertyPartDatetimeClass *part_datetime_class;
1044 part_datetime_class = E_COMP_EDITOR_PROPERTY_PART_DATETIME_CLASS (klass);
1045 part_datetime_class->ical_prop_kind = ICAL_DUE_PROPERTY;
1046 part_datetime_class->ical_new_func = icalproperty_new_due;
1047 part_datetime_class->ical_set_func = icalproperty_set_due;
1048 part_datetime_class->ical_get_func = icalproperty_get_due;
1051 ECompEditorPropertyPart *
1052 e_comp_editor_property_part_due_new (gboolean date_only,
1053 gboolean allow_no_date_set)
1055 ECompEditorPropertyPart *part;
1057 part = g_object_new (E_TYPE_COMP_EDITOR_PROPERTY_PART_DUE,
1058 "label", C_("ECompEditor", "D_ue date:"),
1059 NULL);
1061 e_comp_editor_property_part_datetime_labeled_setup (
1062 E_COMP_EDITOR_PROPERTY_PART_DATETIME_LABELED (part),
1063 date_only, allow_no_date_set);
1065 return part;
1068 /* ************************************************************************* */
1070 #define E_TYPE_COMP_EDITOR_PROPERTY_PART_COMPLETED \
1071 (e_comp_editor_property_part_completed_get_type ())
1072 #define E_COMP_EDITOR_PROPERTY_PART_COMPLETED(obj) \
1073 (G_TYPE_CHECK_INSTANCE_CAST \
1074 ((obj), E_TYPE_COMP_EDITOR_PROPERTY_PART_COMPLETED, ECompEditorPropertyPartCompleted))
1075 #define E_IS_COMP_EDITOR_PROPERTY_PART_COMPLETED(obj) \
1076 (G_TYPE_CHECK_INSTANCE_TYPE \
1077 ((obj), E_TYPE_COMP_EDITOR_PROPERTY_PART_COMPLETED))
1079 typedef struct _ECompEditorPropertyPartCompleted ECompEditorPropertyPartCompleted;
1080 typedef struct _ECompEditorPropertyPartCompletedClass ECompEditorPropertyPartCompletedClass;
1082 struct _ECompEditorPropertyPartCompleted {
1083 ECompEditorPropertyPartDatetimeLabeled parent;
1086 struct _ECompEditorPropertyPartCompletedClass {
1087 ECompEditorPropertyPartDatetimeLabeledClass parent_class;
1090 GType e_comp_editor_property_part_completed_get_type (void) G_GNUC_CONST;
1092 G_DEFINE_TYPE (ECompEditorPropertyPartCompleted, e_comp_editor_property_part_completed, E_TYPE_COMP_EDITOR_PROPERTY_PART_DATETIME_LABELED)
1094 static void
1095 e_comp_editor_property_part_completed_ensure_date_time (struct icaltimetype *pvalue)
1097 if (!pvalue || !pvalue->is_date)
1098 return;
1100 pvalue->is_date = 0;
1101 pvalue->hour = 0;
1102 pvalue->minute = 0;
1103 pvalue->second = 0;
1104 pvalue->zone = icaltimezone_get_utc_timezone ();
1107 static icalproperty *
1108 e_comp_editor_property_part_completed_new_func_wrapper (struct icaltimetype value)
1110 e_comp_editor_property_part_completed_ensure_date_time (&value);
1112 return icalproperty_new_completed (value);
1115 static void
1116 e_comp_editor_property_part_completed_set_func_wrapper (icalproperty *prop,
1117 struct icaltimetype value)
1119 e_comp_editor_property_part_completed_ensure_date_time (&value);
1121 return icalproperty_set_completed (prop, value);
1124 static void
1125 e_comp_editor_property_part_completed_init (ECompEditorPropertyPartCompleted *part_completed)
1129 static void
1130 e_comp_editor_property_part_completed_class_init (ECompEditorPropertyPartCompletedClass *klass)
1132 ECompEditorPropertyPartDatetimeClass *part_datetime_class;
1134 part_datetime_class = E_COMP_EDITOR_PROPERTY_PART_DATETIME_CLASS (klass);
1135 part_datetime_class->ical_prop_kind = ICAL_COMPLETED_PROPERTY;
1136 part_datetime_class->ical_new_func = e_comp_editor_property_part_completed_new_func_wrapper;
1137 part_datetime_class->ical_set_func = e_comp_editor_property_part_completed_set_func_wrapper;
1138 part_datetime_class->ical_get_func = icalproperty_get_completed;
1141 ECompEditorPropertyPart *
1142 e_comp_editor_property_part_completed_new (gboolean date_only,
1143 gboolean allow_no_date_set)
1145 ECompEditorPropertyPart *part;
1147 part = g_object_new (E_TYPE_COMP_EDITOR_PROPERTY_PART_COMPLETED,
1148 "label", C_("ECompEditor", "Date _completed:"),
1149 NULL);
1151 e_comp_editor_property_part_datetime_labeled_setup (
1152 E_COMP_EDITOR_PROPERTY_PART_DATETIME_LABELED (part),
1153 date_only, allow_no_date_set);
1155 return part;
1158 /* ************************************************************************* */
1160 ECompEditorPropertyPart *
1161 e_comp_editor_property_part_classification_new (void)
1163 ECompEditorPropertyPartPickerMap map[] = {
1164 { ICAL_CLASS_PUBLIC, NC_("ECompEditor", "Public"), FALSE, NULL },
1165 { ICAL_CLASS_PRIVATE, NC_("ECompEditor", "Private"), FALSE, NULL },
1166 { ICAL_CLASS_CONFIDENTIAL, NC_("ECompEditor", "Confidential"), FALSE, NULL }
1168 GSettings *settings;
1169 ECompEditorPropertyPart *part;
1170 gboolean classify_private;
1171 gint ii, n_elems = G_N_ELEMENTS (map);
1173 for (ii = 0; ii < n_elems; ii++) {
1174 map[ii].description = g_dpgettext2 (GETTEXT_PACKAGE, "ECompEditor", map[ii].description);
1177 settings = e_util_ref_settings ("org.gnome.evolution.calendar");
1178 classify_private = g_settings_get_boolean (settings, "classify-private");
1179 g_object_unref (settings);
1181 part = e_comp_editor_property_part_picker_with_map_new (map, n_elems,
1182 C_("ECompEditor", "C_lassification:"),
1183 ICAL_CLASS_PROPERTY,
1184 (ECompEditorPropertyPartPickerMapICalNewFunc) icalproperty_new_class,
1185 (ECompEditorPropertyPartPickerMapICalSetFunc) icalproperty_set_class,
1186 (ECompEditorPropertyPartPickerMapICalGetFunc) icalproperty_get_class);
1188 e_comp_editor_property_part_picker_with_map_set_selected (
1189 E_COMP_EDITOR_PROPERTY_PART_PICKER_WITH_MAP (part),
1190 classify_private ? ICAL_CLASS_PRIVATE : ICAL_CLASS_PUBLIC);
1192 return part;
1195 /* ************************************************************************* */
1197 ECompEditorPropertyPart *
1198 e_comp_editor_property_part_status_new (void)
1200 ECompEditorPropertyPartPickerMap map[] = {
1201 { ICAL_STATUS_NONE, NC_("ECompEditor", "Not Started"), TRUE, NULL },
1202 { ICAL_STATUS_INPROCESS, NC_("ECompEditor", "In Progress"), FALSE, NULL },
1203 { ICAL_STATUS_COMPLETED, NC_("ECompEditor", "Completed"), FALSE, NULL },
1204 { ICAL_STATUS_CANCELLED, NC_("ECompEditor", "Cancelled"), FALSE, NULL }
1206 gint ii, n_elems = G_N_ELEMENTS (map);
1208 for (ii = 0; ii < n_elems; ii++) {
1209 map[ii].description = g_dpgettext2 (GETTEXT_PACKAGE, "ECompEditor", map[ii].description);
1212 return e_comp_editor_property_part_picker_with_map_new (map, n_elems,
1213 C_("ECompEditor", "_Status:"),
1214 ICAL_STATUS_PROPERTY,
1215 (ECompEditorPropertyPartPickerMapICalNewFunc) icalproperty_new_status,
1216 (ECompEditorPropertyPartPickerMapICalSetFunc) icalproperty_set_status,
1217 (ECompEditorPropertyPartPickerMapICalGetFunc) icalproperty_get_status);
1220 /* ************************************************************************* */
1222 static gboolean
1223 ecepp_priority_matches (gint map_value,
1224 gint component_value)
1226 if (map_value == component_value)
1227 return TRUE;
1229 if (component_value == 0)
1230 return map_value == 0;
1231 else if (component_value <= 4)
1232 return map_value == 3;
1233 else if (component_value == 5)
1234 return map_value == 5;
1235 else
1236 return map_value == 7;
1239 ECompEditorPropertyPart *
1240 e_comp_editor_property_part_priority_new (void)
1242 ECompEditorPropertyPartPickerMap map[] = {
1243 { 0, NC_("ECompEditor", "Undefined"), TRUE, ecepp_priority_matches },
1244 { 3, NC_("ECompEditor", "High"), FALSE, ecepp_priority_matches },
1245 { 5, NC_("ECompEditor", "Normal"), FALSE, ecepp_priority_matches },
1246 { 7, NC_("ECompEditor", "Low"), FALSE, ecepp_priority_matches }
1248 gint ii, n_elems = G_N_ELEMENTS (map);
1250 for (ii = 0; ii < n_elems; ii++) {
1251 map[ii].description = g_dpgettext2 (GETTEXT_PACKAGE, "ECompEditor", map[ii].description);
1254 return e_comp_editor_property_part_picker_with_map_new (map, n_elems,
1255 C_("ECompEditor", "Priorit_y:"),
1256 ICAL_PRIORITY_PROPERTY,
1257 icalproperty_new_priority,
1258 icalproperty_set_priority,
1259 icalproperty_get_priority);
1262 /* ************************************************************************* */
1264 #define E_TYPE_COMP_EDITOR_PROPERTY_PART_PERCENTCOMPLETE \
1265 (e_comp_editor_property_part_percentcomplete_get_type ())
1266 #define E_COMP_EDITOR_PROPERTY_PART_PERCENTCOMPLETE(obj) \
1267 (G_TYPE_CHECK_INSTANCE_CAST \
1268 ((obj), E_TYPE_COMP_EDITOR_PROPERTY_PART_PERCENTCOMPLETE, ECompEditorPropertyPartPercentcomplete))
1269 #define E_IS_COMP_EDITOR_PROPERTY_PART_PERCENTCOMPLETE(obj) \
1270 (G_TYPE_CHECK_INSTANCE_TYPE \
1271 ((obj), E_TYPE_COMP_EDITOR_PROPERTY_PART_PERCENTCOMPLETE))
1273 typedef struct _ECompEditorPropertyPartPercentcomplete ECompEditorPropertyPartPercentcomplete;
1274 typedef struct _ECompEditorPropertyPartPercentcompleteClass ECompEditorPropertyPartPercentcompleteClass;
1276 struct _ECompEditorPropertyPartPercentcomplete {
1277 ECompEditorPropertyPartSpin parent;
1280 struct _ECompEditorPropertyPartPercentcompleteClass {
1281 ECompEditorPropertyPartSpinClass parent_class;
1284 GType e_comp_editor_property_part_percentcomplete_get_type (void) G_GNUC_CONST;
1286 G_DEFINE_TYPE (ECompEditorPropertyPartPercentcomplete, e_comp_editor_property_part_percentcomplete, E_TYPE_COMP_EDITOR_PROPERTY_PART_SPIN)
1288 static void
1289 ecepp_percentcomplete_create_widgets (ECompEditorPropertyPart *property_part,
1290 GtkWidget **out_label_widget,
1291 GtkWidget **out_edit_widget)
1293 ECompEditorPropertyPartClass *part_class;
1295 g_return_if_fail (E_IS_COMP_EDITOR_PROPERTY_PART_PERCENTCOMPLETE (property_part));
1296 g_return_if_fail (out_label_widget != NULL);
1297 g_return_if_fail (out_edit_widget != NULL);
1299 part_class = E_COMP_EDITOR_PROPERTY_PART_CLASS (e_comp_editor_property_part_percentcomplete_parent_class);
1300 g_return_if_fail (part_class != NULL);
1301 g_return_if_fail (part_class->create_widgets != NULL);
1303 *out_label_widget = NULL;
1305 part_class->create_widgets (property_part, out_label_widget, out_edit_widget);
1306 g_return_if_fail (*out_label_widget == NULL);
1307 g_return_if_fail (*out_edit_widget != NULL);
1309 *out_label_widget = gtk_label_new_with_mnemonic (C_("ECompEditor", "Percent complete:"));
1310 gtk_label_set_mnemonic_widget (GTK_LABEL (*out_label_widget), *out_edit_widget);
1312 g_object_set (G_OBJECT (*out_label_widget),
1313 "hexpand", FALSE,
1314 "halign", GTK_ALIGN_END,
1315 "vexpand", FALSE,
1316 "valign", GTK_ALIGN_CENTER,
1317 NULL);
1319 gtk_widget_show (*out_label_widget);
1322 static void
1323 e_comp_editor_property_part_percentcomplete_init (ECompEditorPropertyPartPercentcomplete *part_percentcomplete)
1327 static void
1328 e_comp_editor_property_part_percentcomplete_class_init (ECompEditorPropertyPartPercentcompleteClass *klass)
1330 ECompEditorPropertyPartSpinClass *part_spin_class;
1331 ECompEditorPropertyPartClass *part_class;
1333 part_spin_class = E_COMP_EDITOR_PROPERTY_PART_SPIN_CLASS (klass);
1334 part_spin_class->ical_prop_kind = ICAL_PERCENTCOMPLETE_PROPERTY;
1335 part_spin_class->ical_new_func = icalproperty_new_percentcomplete;
1336 part_spin_class->ical_set_func = icalproperty_set_percentcomplete;
1337 part_spin_class->ical_get_func = icalproperty_get_percentcomplete;
1339 part_class = E_COMP_EDITOR_PROPERTY_PART_CLASS (klass);
1340 part_class->create_widgets = ecepp_percentcomplete_create_widgets;
1343 ECompEditorPropertyPart *
1344 e_comp_editor_property_part_percentcomplete_new (void)
1346 ECompEditorPropertyPart *part;
1348 part = g_object_new (E_TYPE_COMP_EDITOR_PROPERTY_PART_PERCENTCOMPLETE, NULL);
1350 e_comp_editor_property_part_spin_set_range (E_COMP_EDITOR_PROPERTY_PART_SPIN (part), 0, 100);
1352 return part;
1355 /* ************************************************************************* */
1357 #define E_TYPE_COMP_EDITOR_PROPERTY_PART_TIMEZONE \
1358 (e_comp_editor_property_part_timezone_get_type ())
1359 #define E_COMP_EDITOR_PROPERTY_PART_TIMEZONE(obj) \
1360 (G_TYPE_CHECK_INSTANCE_CAST \
1361 ((obj), E_TYPE_COMP_EDITOR_PROPERTY_PART_TIMEZONE, ECompEditorPropertyPartTimezone))
1362 #define E_IS_COMP_EDITOR_PROPERTY_PART_TIMEZONE(obj) \
1363 (G_TYPE_CHECK_INSTANCE_TYPE \
1364 ((obj), E_TYPE_COMP_EDITOR_PROPERTY_PART_TIMEZONE))
1366 typedef struct _ECompEditorPropertyPartTimezone ECompEditorPropertyPartTimezone;
1367 typedef struct _ECompEditorPropertyPartTimezoneClass ECompEditorPropertyPartTimezoneClass;
1369 struct _ECompEditorPropertyPartTimezone {
1370 ECompEditorPropertyPart parent;
1373 struct _ECompEditorPropertyPartTimezoneClass {
1374 ECompEditorPropertyPartClass parent_class;
1377 GType e_comp_editor_property_part_timezone_get_type (void) G_GNUC_CONST;
1379 G_DEFINE_TYPE (ECompEditorPropertyPartTimezone, e_comp_editor_property_part_timezone, E_TYPE_COMP_EDITOR_PROPERTY_PART)
1381 static void
1382 ecepp_timezone_create_widgets (ECompEditorPropertyPart *property_part,
1383 GtkWidget **out_label_widget,
1384 GtkWidget **out_edit_widget)
1386 g_return_if_fail (E_IS_COMP_EDITOR_PROPERTY_PART_TIMEZONE (property_part));
1387 g_return_if_fail (out_label_widget != NULL);
1388 g_return_if_fail (out_edit_widget != NULL);
1390 *out_label_widget = gtk_label_new_with_mnemonic (C_("ECompEditor", "Time _zone:"));
1392 g_object_set (G_OBJECT (*out_label_widget),
1393 "hexpand", FALSE,
1394 "halign", GTK_ALIGN_END,
1395 "vexpand", FALSE,
1396 "valign", GTK_ALIGN_CENTER,
1397 NULL);
1399 gtk_widget_show (*out_label_widget);
1401 *out_edit_widget = e_timezone_entry_new ();
1402 e_timezone_entry_set_timezone (E_TIMEZONE_ENTRY (*out_edit_widget), calendar_config_get_icaltimezone ());
1404 gtk_widget_show (*out_edit_widget);
1406 gtk_label_set_mnemonic_widget (GTK_LABEL (*out_label_widget), *out_edit_widget);
1408 g_signal_connect_swapped (*out_edit_widget, "changed",
1409 G_CALLBACK (e_comp_editor_property_part_emit_changed), property_part);
1412 static void
1413 ecepp_timezone_fill_widget (ECompEditorPropertyPart *property_part,
1414 icalcomponent *component)
1416 struct icaltimetype (* get_func) (const icalproperty *prop);
1417 icalproperty *prop;
1419 g_return_if_fail (E_IS_COMP_EDITOR_PROPERTY_PART_TIMEZONE (property_part));
1421 get_func = icalproperty_get_dtstart;
1422 prop = icalcomponent_get_first_property (component, ICAL_DTSTART_PROPERTY);
1424 if (!prop) {
1425 get_func = icalproperty_get_dtend;
1426 prop = icalcomponent_get_first_property (component, ICAL_DTEND_PROPERTY);
1429 if (!prop) {
1430 get_func = icalproperty_get_due;
1431 prop = icalcomponent_get_first_property (component, ICAL_DUE_PROPERTY);
1434 if (prop) {
1435 struct icaltimetype itt;
1437 itt = get_func (prop);
1438 if (itt.zone) {
1439 GtkWidget *edit_widget;
1441 edit_widget = e_comp_editor_property_part_get_edit_widget (property_part);
1442 g_return_if_fail (E_IS_TIMEZONE_ENTRY (edit_widget));
1444 e_timezone_entry_set_timezone (E_TIMEZONE_ENTRY (edit_widget), (icaltimezone *) itt.zone);
1449 static void
1450 ecepp_timezone_fill_component (ECompEditorPropertyPart *property_part,
1451 icalcomponent *component)
1453 /* Nothing to do here, this is sort-of virtual property part */
1456 static void
1457 e_comp_editor_property_part_timezone_init (ECompEditorPropertyPartTimezone *part_timezone)
1461 static void
1462 e_comp_editor_property_part_timezone_class_init (ECompEditorPropertyPartTimezoneClass *klass)
1464 ECompEditorPropertyPartClass *part_class;
1466 part_class = E_COMP_EDITOR_PROPERTY_PART_CLASS (klass);
1467 part_class->create_widgets = ecepp_timezone_create_widgets;
1468 part_class->fill_widget = ecepp_timezone_fill_widget;
1469 part_class->fill_component = ecepp_timezone_fill_component;
1472 ECompEditorPropertyPart *
1473 e_comp_editor_property_part_timezone_new (void)
1475 return g_object_new (E_TYPE_COMP_EDITOR_PROPERTY_PART_TIMEZONE, NULL);
1478 /* ************************************************************************* */
1480 #define E_TYPE_COMP_EDITOR_PROPERTY_PART_TRANSPARENCY \
1481 (e_comp_editor_property_part_transparency_get_type ())
1482 #define E_COMP_EDITOR_PROPERTY_PART_TRANSPARENCY(obj) \
1483 (G_TYPE_CHECK_INSTANCE_CAST \
1484 ((obj), E_TYPE_COMP_EDITOR_PROPERTY_PART_TRANSPARENCY, ECompEditorPropertyPartTransparency))
1485 #define E_IS_COMP_EDITOR_PROPERTY_PART_TRANSPARENCY(obj) \
1486 (G_TYPE_CHECK_INSTANCE_TYPE \
1487 ((obj), E_TYPE_COMP_EDITOR_PROPERTY_PART_TRANSPARENCY))
1489 typedef struct _ECompEditorPropertyPartTransparency ECompEditorPropertyPartTransparency;
1490 typedef struct _ECompEditorPropertyPartTransparencyClass ECompEditorPropertyPartTransparencyClass;
1492 struct _ECompEditorPropertyPartTransparency {
1493 ECompEditorPropertyPart parent;
1496 struct _ECompEditorPropertyPartTransparencyClass {
1497 ECompEditorPropertyPartClass parent_class;
1500 GType e_comp_editor_property_part_transparency_get_type (void) G_GNUC_CONST;
1502 G_DEFINE_TYPE (ECompEditorPropertyPartTransparency, e_comp_editor_property_part_transparency, E_TYPE_COMP_EDITOR_PROPERTY_PART)
1504 static void
1505 ecepp_transparency_create_widgets (ECompEditorPropertyPart *property_part,
1506 GtkWidget **out_label_widget,
1507 GtkWidget **out_edit_widget)
1509 g_return_if_fail (E_IS_COMP_EDITOR_PROPERTY_PART_TRANSPARENCY (property_part));
1510 g_return_if_fail (out_label_widget != NULL);
1511 g_return_if_fail (out_edit_widget != NULL);
1513 *out_label_widget = NULL;
1515 *out_edit_widget = gtk_check_button_new_with_mnemonic (C_("ECompEditor", "Show time as _busy"));
1517 g_object_set (G_OBJECT (*out_edit_widget),
1518 "hexpand", FALSE,
1519 "halign", GTK_ALIGN_FILL,
1520 "vexpand", FALSE,
1521 "valign", GTK_ALIGN_CENTER,
1522 NULL);
1524 gtk_widget_show (*out_edit_widget);
1526 g_signal_connect_swapped (*out_edit_widget, "toggled",
1527 G_CALLBACK (e_comp_editor_property_part_emit_changed), property_part);
1530 static void
1531 ecepp_transparency_fill_widget (ECompEditorPropertyPart *property_part,
1532 icalcomponent *component)
1534 GtkWidget *edit_widget;
1535 icalproperty *prop;
1537 g_return_if_fail (E_IS_COMP_EDITOR_PROPERTY_PART_TRANSPARENCY (property_part));
1539 edit_widget = e_comp_editor_property_part_get_edit_widget (property_part);
1540 g_return_if_fail (GTK_IS_CHECK_BUTTON (edit_widget));
1542 prop = icalcomponent_get_first_property (component, ICAL_TRANSP_PROPERTY);
1543 if (prop) {
1544 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (edit_widget),
1545 icalproperty_get_transp (prop) == ICAL_TRANSP_OPAQUE);
1546 } else {
1547 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (edit_widget), TRUE);
1551 static void
1552 ecepp_transparency_fill_component (ECompEditorPropertyPart *property_part,
1553 icalcomponent *component)
1555 GtkWidget *edit_widget;
1556 icalproperty *prop;
1557 icalproperty_transp value;
1559 g_return_if_fail (E_IS_COMP_EDITOR_PROPERTY_PART_TRANSPARENCY (property_part));
1561 edit_widget = e_comp_editor_property_part_get_edit_widget (property_part);
1562 g_return_if_fail (GTK_IS_CHECK_BUTTON (edit_widget));
1564 value = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (edit_widget)) ? ICAL_TRANSP_OPAQUE : ICAL_TRANSP_TRANSPARENT;
1566 prop = icalcomponent_get_first_property (component, ICAL_TRANSP_PROPERTY);
1567 if (prop) {
1568 icalproperty_set_transp (prop, value);
1569 } else {
1570 prop = icalproperty_new_transp (value);
1571 icalcomponent_add_property (component, prop);
1575 static void
1576 e_comp_editor_property_part_transparency_init (ECompEditorPropertyPartTransparency *part_transparency)
1580 static void
1581 e_comp_editor_property_part_transparency_class_init (ECompEditorPropertyPartTransparencyClass *klass)
1583 ECompEditorPropertyPartClass *part_class;
1585 part_class = E_COMP_EDITOR_PROPERTY_PART_CLASS (klass);
1586 part_class->create_widgets = ecepp_transparency_create_widgets;
1587 part_class->fill_widget = ecepp_transparency_fill_widget;
1588 part_class->fill_component = ecepp_transparency_fill_component;
1591 ECompEditorPropertyPart *
1592 e_comp_editor_property_part_transparency_new (void)
1594 return g_object_new (E_TYPE_COMP_EDITOR_PROPERTY_PART_TRANSPARENCY, NULL);
1597 /* ************************************************************************* */
1599 #define E_TYPE_COMP_EDITOR_PROPERTY_PART_COLOR \
1600 (e_comp_editor_property_part_color_get_type ())
1601 #define E_COMP_EDITOR_PROPERTY_PART_COLOR(obj) \
1602 (G_TYPE_CHECK_INSTANCE_CAST \
1603 ((obj), E_TYPE_COMP_EDITOR_PROPERTY_PART_COLOR, ECompEditorPropertyPartColor))
1604 #define E_IS_COMP_EDITOR_PROPERTY_PART_COLOR(obj) \
1605 (G_TYPE_CHECK_INSTANCE_TYPE \
1606 ((obj), E_TYPE_COMP_EDITOR_PROPERTY_PART_COLOR))
1608 typedef struct _ECompEditorPropertyPartColor ECompEditorPropertyPartColor;
1609 typedef struct _ECompEditorPropertyPartColorClass ECompEditorPropertyPartColorClass;
1611 struct _ECompEditorPropertyPartColor {
1612 ECompEditorPropertyPart parent;
1615 struct _ECompEditorPropertyPartColorClass {
1616 ECompEditorPropertyPartClass parent_class;
1619 GType e_comp_editor_property_part_color_get_type (void) G_GNUC_CONST;
1621 G_DEFINE_TYPE (ECompEditorPropertyPartColor, e_comp_editor_property_part_color, E_TYPE_COMP_EDITOR_PROPERTY_PART)
1623 static void
1624 ecepp_color_create_widgets (ECompEditorPropertyPart *property_part,
1625 GtkWidget **out_label_widget,
1626 GtkWidget **out_edit_widget)
1628 GdkRGBA rgba;
1630 g_return_if_fail (E_IS_COMP_EDITOR_PROPERTY_PART_COLOR (property_part));
1631 g_return_if_fail (out_label_widget != NULL);
1632 g_return_if_fail (out_edit_widget != NULL);
1634 rgba.red = 0.0;
1635 rgba.green = 0.0;
1636 rgba.blue = 0.0;
1637 rgba.alpha = 0.001;
1639 *out_label_widget = NULL;
1641 /* Translators: This 'None' is meant for 'Color' in calendar component editor, like 'None color' */
1642 *out_edit_widget = e_color_combo_new_defaults (&rgba, C_("ECompEditor", "None"));
1644 g_object_set (G_OBJECT (*out_edit_widget),
1645 "hexpand", FALSE,
1646 "halign", GTK_ALIGN_START,
1647 "vexpand", FALSE,
1648 "valign", GTK_ALIGN_CENTER,
1649 NULL);
1651 gtk_widget_show (*out_edit_widget);
1653 g_signal_connect_swapped (*out_edit_widget, "activated",
1654 G_CALLBACK (e_comp_editor_property_part_emit_changed), property_part);
1657 static void
1658 ecepp_color_fill_widget (ECompEditorPropertyPart *property_part,
1659 icalcomponent *component)
1661 #ifdef HAVE_ICAL_COLOR_PROPERTY
1662 GtkWidget *edit_widget;
1663 icalproperty *prop;
1664 gboolean color_set = FALSE;
1666 g_return_if_fail (E_IS_COMP_EDITOR_PROPERTY_PART_COLOR (property_part));
1668 edit_widget = e_comp_editor_property_part_get_edit_widget (property_part);
1669 g_return_if_fail (E_IS_COLOR_COMBO (edit_widget));
1671 prop = icalcomponent_get_first_property (component, ICAL_COLOR_PROPERTY);
1672 if (prop) {
1673 const gchar *color = icalproperty_get_color (prop);
1674 GdkRGBA rgba;
1676 if (color && gdk_rgba_parse (&rgba, color)) {
1677 e_color_combo_set_current_color (E_COLOR_COMBO (edit_widget), &rgba);
1678 color_set = TRUE;
1682 if (!color_set) {
1683 GdkRGBA rgba;
1685 rgba.red = 0.0;
1686 rgba.green = 0.0;
1687 rgba.blue = 0.0;
1688 rgba.alpha = 0.001;
1690 e_color_combo_set_current_color (E_COLOR_COMBO (edit_widget), &rgba);
1692 #endif
1695 static void
1696 ecepp_color_fill_component (ECompEditorPropertyPart *property_part,
1697 icalcomponent *component)
1699 #ifdef HAVE_ICAL_COLOR_PROPERTY
1700 GtkWidget *edit_widget;
1701 icalproperty *prop;
1702 GdkRGBA rgba;
1704 g_return_if_fail (E_IS_COMP_EDITOR_PROPERTY_PART_COLOR (property_part));
1706 edit_widget = e_comp_editor_property_part_get_edit_widget (property_part);
1707 g_return_if_fail (E_IS_COLOR_COMBO (edit_widget));
1709 rgba.red = 0.0;
1710 rgba.green = 0.0;
1711 rgba.blue = 0.0;
1712 rgba.alpha = 0.001;
1714 e_color_combo_get_current_color (E_COLOR_COMBO (edit_widget), &rgba);
1716 prop = icalcomponent_get_first_property (component, ICAL_COLOR_PROPERTY);
1718 if (rgba.alpha <= 1.0 - 1e-9) {
1719 if (prop) {
1720 icalcomponent_remove_property (component, prop);
1721 icalproperty_free (prop);
1723 } else {
1724 gchar *str;
1726 str = gdk_rgba_to_string (&rgba);
1727 if (str) {
1728 if (prop) {
1729 icalproperty_set_color (prop, str);
1730 } else {
1731 prop = icalproperty_new_color (str);
1732 icalcomponent_add_property (component, prop);
1735 g_free (str);
1736 } else {
1737 g_warning ("%s: Failed to convert RGBA (%f,%f,%f,%f) to string", G_STRFUNC, rgba.red, rgba.green, rgba.blue, rgba.alpha);
1740 #endif
1743 static void
1744 e_comp_editor_property_part_color_init (ECompEditorPropertyPartColor *part_color)
1748 static void
1749 e_comp_editor_property_part_color_class_init (ECompEditorPropertyPartColorClass *klass)
1751 ECompEditorPropertyPartClass *part_class;
1753 part_class = E_COMP_EDITOR_PROPERTY_PART_CLASS (klass);
1754 part_class->create_widgets = ecepp_color_create_widgets;
1755 part_class->fill_widget = ecepp_color_fill_widget;
1756 part_class->fill_component = ecepp_color_fill_component;
1759 ECompEditorPropertyPart *
1760 e_comp_editor_property_part_color_new (void)
1762 #ifdef HAVE_ICAL_COLOR_PROPERTY
1763 return g_object_new (E_TYPE_COMP_EDITOR_PROPERTY_PART_COLOR, NULL);
1764 #else
1765 return NULL;
1766 #endif