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
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"
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
)
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
),
84 "halign", GTK_ALIGN_END
,
86 "valign", GTK_ALIGN_CENTER
,
89 gtk_widget_show (*out_label_widget
);
93 e_comp_editor_property_part_summary_init (ECompEditorPropertyPartSummary
*part_summary
)
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
)
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
);
160 ecepp_location_load_list (GtkEntry
*entry
)
162 GtkEntryCompletion
*completion
;
164 gchar
*filename
, *contents
= NULL
;
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
)) {
181 if (!g_file_get_contents (filename
, &contents
, NULL
, &error
)) {
184 "%s: Failed to load locations list '%s': %s",
185 G_STRFUNC
, filename
, error
->message
);
186 g_error_free (error
);
193 locations
= g_strsplit (contents
, "\n", 0);
201 store
= GTK_LIST_STORE (gtk_entry_completion_get_model (completion
));
202 while (locations
[row
] && *locations
[row
]) {
204 gtk_list_store_append (store
, &iter
);
205 gtk_list_store_set (store
, &iter
, 0, locations
[row
], -1);
209 g_strfreev (locations
);
215 ecepp_location_save_list (GtkEntry
*entry
)
217 GtkEntryCompletion
*completion
;
220 const gchar
*current_location
;
221 gchar
*filename
, *stored_content
= NULL
;
222 gboolean needs_save
= TRUE
;
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);
236 g_warning ("%s: Failed to create %s: %s", G_STRFUNC
, filename
, g_strerror (errno
));
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
)) {
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
);
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
);
277 g_file_set_contents (filename
, contents
->str
, -1, &error
);
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
);
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
),
328 "halign", GTK_ALIGN_END
,
330 "valign", GTK_ALIGN_CENTER
,
333 gtk_widget_show (*out_label_widget
);
335 ecepp_location_load_list (GTK_ENTRY (*out_edit_widget
));
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
));
360 e_comp_editor_property_part_location_init (ECompEditorPropertyPartLocation
*part_location
)
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
)
421 ecepp_categories_button_clicked_cb (GtkButton
*button
,
424 g_return_if_fail (GTK_IS_ENTRY (entry
));
426 e_categories_config_open_dialog_for_entry (entry
);
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
;
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
),
463 "halign", GTK_ALIGN_END
,
465 "valign", GTK_ALIGN_CENTER
,
468 gtk_widget_show (*out_label_widget
);
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
);
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
)
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
),
566 "halign", GTK_ALIGN_END
,
568 "valign", GTK_ALIGN_START
,
571 g_object_set (G_OBJECT (*out_edit_widget
),
573 "halign", GTK_ALIGN_FILL
,
575 "valign", GTK_ALIGN_FILL
,
576 "height-request", 100,
579 gtk_widget_show (*out_label_widget
);
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
))));
605 e_comp_editor_property_part_description_init (ECompEditorPropertyPartDescription
*part_description
)
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
)
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
),
692 "halign", GTK_ALIGN_END
,
694 "valign", GTK_ALIGN_CENTER
,
697 gtk_widget_show (*out_label_widget
);
701 e_comp_editor_property_part_url_init (ECompEditorPropertyPartUrl
*part_url
)
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
;
755 struct _ECompEditorPropertyPartDatetimeLabeledClass
{
756 ECompEditorPropertyPartDatetimeClass parent_class
;
759 GType
e_comp_editor_property_part_datetime_labeled_get_type (void) G_GNUC_CONST
;
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
)
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
),
797 "halign", GTK_ALIGN_END
,
799 "valign", GTK_ALIGN_CENTER
,
802 gtk_widget_show (*out_label_widget
);
806 ecepp_datetime_labeled_set_property (GObject
*object
,
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
);
824 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, property_id
, pspec
);
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
);
841 e_comp_editor_property_part_datetime_labeled_init (ECompEditorPropertyPartDatetimeLabeled
*part_datetime_labeled
)
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 (
860 DATETIME_LABELED_PROP_LABEL
,
861 g_param_spec_string (
864 "Label of the datetime",
867 G_PARAM_CONSTRUCT_ONLY
|
868 G_PARAM_STATIC_STRINGS
));
872 e_comp_editor_property_part_datetime_labeled_setup (ECompEditorPropertyPartDatetimeLabeled
*part_datetime_labeled
,
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
)
913 e_comp_editor_property_part_dtstart_init (ECompEditorPropertyPartDtstart
*part_dtstart
)
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
,
932 gboolean allow_no_date_set
)
934 ECompEditorPropertyPart
*part
;
936 part
= g_object_new (E_TYPE_COMP_EDITOR_PROPERTY_PART_DTSTART
,
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
);
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
)
974 e_comp_editor_property_part_dtend_init (ECompEditorPropertyPartDtend
*part_dtend
)
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
,
993 gboolean allow_no_date_set
)
995 ECompEditorPropertyPart
*part
;
997 part
= g_object_new (E_TYPE_COMP_EDITOR_PROPERTY_PART_DTEND
,
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
);
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
)
1035 e_comp_editor_property_part_due_init (ECompEditorPropertyPartDue
*part_due
)
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:"),
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
);
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
)
1095 e_comp_editor_property_part_completed_init (ECompEditorPropertyPartCompleted
*part_completed
)
1100 e_comp_editor_property_part_completed_class_init (ECompEditorPropertyPartCompletedClass
*klass
)
1102 ECompEditorPropertyPartDatetimeClass
*part_datetime_class
;
1104 part_datetime_class
= E_COMP_EDITOR_PROPERTY_PART_DATETIME_CLASS (klass
);
1105 part_datetime_class
->ical_prop_kind
= ICAL_COMPLETED_PROPERTY
;
1106 part_datetime_class
->ical_new_func
= icalproperty_new_completed
;
1107 part_datetime_class
->ical_set_func
= icalproperty_set_completed
;
1108 part_datetime_class
->ical_get_func
= icalproperty_get_completed
;
1111 ECompEditorPropertyPart
*
1112 e_comp_editor_property_part_completed_new (gboolean date_only
,
1113 gboolean allow_no_date_set
)
1115 ECompEditorPropertyPart
*part
;
1117 part
= g_object_new (E_TYPE_COMP_EDITOR_PROPERTY_PART_COMPLETED
,
1118 "label", C_("ECompEditor", "Date _completed:"),
1121 e_comp_editor_property_part_datetime_labeled_setup (
1122 E_COMP_EDITOR_PROPERTY_PART_DATETIME_LABELED (part
),
1123 date_only
, allow_no_date_set
);
1128 /* ************************************************************************* */
1130 ECompEditorPropertyPart
*
1131 e_comp_editor_property_part_classification_new (void)
1133 ECompEditorPropertyPartPickerMap map
[] = {
1134 { ICAL_CLASS_PUBLIC
, NC_("ECompEditor", "Public"), FALSE
, NULL
},
1135 { ICAL_CLASS_PRIVATE
, NC_("ECompEditor", "Private"), FALSE
, NULL
},
1136 { ICAL_CLASS_CONFIDENTIAL
, NC_("ECompEditor", "Confidential"), FALSE
, NULL
}
1138 GSettings
*settings
;
1139 ECompEditorPropertyPart
*part
;
1140 gboolean classify_private
;
1141 gint ii
, n_elems
= G_N_ELEMENTS (map
);
1143 for (ii
= 0; ii
< n_elems
; ii
++) {
1144 map
[ii
].description
= g_dpgettext2 (GETTEXT_PACKAGE
, "ECompEditor", map
[ii
].description
);
1147 settings
= e_util_ref_settings ("org.gnome.evolution.calendar");
1148 classify_private
= g_settings_get_boolean (settings
, "classify-private");
1149 g_object_unref (settings
);
1151 part
= e_comp_editor_property_part_picker_with_map_new (map
, n_elems
,
1152 C_("ECompEditor", "C_lassification:"),
1153 ICAL_CLASS_PROPERTY
,
1154 (ECompEditorPropertyPartPickerMapICalNewFunc
) icalproperty_new_class
,
1155 (ECompEditorPropertyPartPickerMapICalSetFunc
) icalproperty_set_class
,
1156 (ECompEditorPropertyPartPickerMapICalGetFunc
) icalproperty_get_class
);
1158 e_comp_editor_property_part_picker_with_map_set_selected (
1159 E_COMP_EDITOR_PROPERTY_PART_PICKER_WITH_MAP (part
),
1160 classify_private
? ICAL_CLASS_PRIVATE
: ICAL_CLASS_PUBLIC
);
1165 /* ************************************************************************* */
1167 ECompEditorPropertyPart
*
1168 e_comp_editor_property_part_status_new (void)
1170 ECompEditorPropertyPartPickerMap map
[] = {
1171 { ICAL_STATUS_NONE
, NC_("ECompEditor", "Not Started"), TRUE
, NULL
},
1172 { ICAL_STATUS_INPROCESS
, NC_("ECompEditor", "In Progress"), FALSE
, NULL
},
1173 { ICAL_STATUS_COMPLETED
, NC_("ECompEditor", "Completed"), FALSE
, NULL
},
1174 { ICAL_STATUS_CANCELLED
, NC_("ECompEditor", "Cancelled"), FALSE
, NULL
}
1176 gint ii
, n_elems
= G_N_ELEMENTS (map
);
1178 for (ii
= 0; ii
< n_elems
; ii
++) {
1179 map
[ii
].description
= g_dpgettext2 (GETTEXT_PACKAGE
, "ECompEditor", map
[ii
].description
);
1182 return e_comp_editor_property_part_picker_with_map_new (map
, n_elems
,
1183 C_("ECompEditor", "_Status:"),
1184 ICAL_STATUS_PROPERTY
,
1185 (ECompEditorPropertyPartPickerMapICalNewFunc
) icalproperty_new_status
,
1186 (ECompEditorPropertyPartPickerMapICalSetFunc
) icalproperty_set_status
,
1187 (ECompEditorPropertyPartPickerMapICalGetFunc
) icalproperty_get_status
);
1190 /* ************************************************************************* */
1193 ecepp_priority_matches (gint map_value
,
1194 gint component_value
)
1196 if (map_value
== component_value
)
1199 if (component_value
== 0)
1200 return map_value
== 0;
1201 else if (component_value
<= 4)
1202 return map_value
== 3;
1203 else if (component_value
== 5)
1204 return map_value
== 5;
1206 return map_value
== 7;
1209 ECompEditorPropertyPart
*
1210 e_comp_editor_property_part_priority_new (void)
1212 ECompEditorPropertyPartPickerMap map
[] = {
1213 { 0, NC_("ECompEditor", "Undefined"), TRUE
, ecepp_priority_matches
},
1214 { 3, NC_("ECompEditor", "High"), FALSE
, ecepp_priority_matches
},
1215 { 5, NC_("ECompEditor", "Normal"), FALSE
, ecepp_priority_matches
},
1216 { 7, NC_("ECompEditor", "Low"), FALSE
, ecepp_priority_matches
}
1218 gint ii
, n_elems
= G_N_ELEMENTS (map
);
1220 for (ii
= 0; ii
< n_elems
; ii
++) {
1221 map
[ii
].description
= g_dpgettext2 (GETTEXT_PACKAGE
, "ECompEditor", map
[ii
].description
);
1224 return e_comp_editor_property_part_picker_with_map_new (map
, n_elems
,
1225 C_("ECompEditor", "Priorit_y:"),
1226 ICAL_PRIORITY_PROPERTY
,
1227 icalproperty_new_priority
,
1228 icalproperty_set_priority
,
1229 icalproperty_get_priority
);
1232 /* ************************************************************************* */
1234 #define E_TYPE_COMP_EDITOR_PROPERTY_PART_PERCENTCOMPLETE \
1235 (e_comp_editor_property_part_percentcomplete_get_type ())
1236 #define E_COMP_EDITOR_PROPERTY_PART_PERCENTCOMPLETE(obj) \
1237 (G_TYPE_CHECK_INSTANCE_CAST \
1238 ((obj), E_TYPE_COMP_EDITOR_PROPERTY_PART_PERCENTCOMPLETE, ECompEditorPropertyPartPercentcomplete))
1239 #define E_IS_COMP_EDITOR_PROPERTY_PART_PERCENTCOMPLETE(obj) \
1240 (G_TYPE_CHECK_INSTANCE_TYPE \
1241 ((obj), E_TYPE_COMP_EDITOR_PROPERTY_PART_PERCENTCOMPLETE))
1243 typedef struct _ECompEditorPropertyPartPercentcomplete ECompEditorPropertyPartPercentcomplete
;
1244 typedef struct _ECompEditorPropertyPartPercentcompleteClass ECompEditorPropertyPartPercentcompleteClass
;
1246 struct _ECompEditorPropertyPartPercentcomplete
{
1247 ECompEditorPropertyPartSpin parent
;
1250 struct _ECompEditorPropertyPartPercentcompleteClass
{
1251 ECompEditorPropertyPartSpinClass parent_class
;
1254 GType
e_comp_editor_property_part_percentcomplete_get_type (void) G_GNUC_CONST
;
1256 G_DEFINE_TYPE (ECompEditorPropertyPartPercentcomplete
, e_comp_editor_property_part_percentcomplete
, E_TYPE_COMP_EDITOR_PROPERTY_PART_SPIN
)
1259 ecepp_percentcomplete_create_widgets (ECompEditorPropertyPart
*property_part
,
1260 GtkWidget
**out_label_widget
,
1261 GtkWidget
**out_edit_widget
)
1263 ECompEditorPropertyPartClass
*part_class
;
1265 g_return_if_fail (E_IS_COMP_EDITOR_PROPERTY_PART_PERCENTCOMPLETE (property_part
));
1266 g_return_if_fail (out_label_widget
!= NULL
);
1267 g_return_if_fail (out_edit_widget
!= NULL
);
1269 part_class
= E_COMP_EDITOR_PROPERTY_PART_CLASS (e_comp_editor_property_part_percentcomplete_parent_class
);
1270 g_return_if_fail (part_class
!= NULL
);
1271 g_return_if_fail (part_class
->create_widgets
!= NULL
);
1273 *out_label_widget
= NULL
;
1275 part_class
->create_widgets (property_part
, out_label_widget
, out_edit_widget
);
1276 g_return_if_fail (*out_label_widget
== NULL
);
1277 g_return_if_fail (*out_edit_widget
!= NULL
);
1279 *out_label_widget
= gtk_label_new_with_mnemonic (C_("ECompEditor", "Percent complete:"));
1280 gtk_label_set_mnemonic_widget (GTK_LABEL (*out_label_widget
), *out_edit_widget
);
1282 g_object_set (G_OBJECT (*out_label_widget
),
1284 "halign", GTK_ALIGN_END
,
1286 "valign", GTK_ALIGN_CENTER
,
1289 gtk_widget_show (*out_label_widget
);
1293 e_comp_editor_property_part_percentcomplete_init (ECompEditorPropertyPartPercentcomplete
*part_percentcomplete
)
1298 e_comp_editor_property_part_percentcomplete_class_init (ECompEditorPropertyPartPercentcompleteClass
*klass
)
1300 ECompEditorPropertyPartSpinClass
*part_spin_class
;
1301 ECompEditorPropertyPartClass
*part_class
;
1303 part_spin_class
= E_COMP_EDITOR_PROPERTY_PART_SPIN_CLASS (klass
);
1304 part_spin_class
->ical_prop_kind
= ICAL_PERCENTCOMPLETE_PROPERTY
;
1305 part_spin_class
->ical_new_func
= icalproperty_new_percentcomplete
;
1306 part_spin_class
->ical_set_func
= icalproperty_set_percentcomplete
;
1307 part_spin_class
->ical_get_func
= icalproperty_get_percentcomplete
;
1309 part_class
= E_COMP_EDITOR_PROPERTY_PART_CLASS (klass
);
1310 part_class
->create_widgets
= ecepp_percentcomplete_create_widgets
;
1313 ECompEditorPropertyPart
*
1314 e_comp_editor_property_part_percentcomplete_new (void)
1316 ECompEditorPropertyPart
*part
;
1318 part
= g_object_new (E_TYPE_COMP_EDITOR_PROPERTY_PART_PERCENTCOMPLETE
, NULL
);
1320 e_comp_editor_property_part_spin_set_range (E_COMP_EDITOR_PROPERTY_PART_SPIN (part
), 0, 100);
1325 /* ************************************************************************* */
1327 #define E_TYPE_COMP_EDITOR_PROPERTY_PART_TIMEZONE \
1328 (e_comp_editor_property_part_timezone_get_type ())
1329 #define E_COMP_EDITOR_PROPERTY_PART_TIMEZONE(obj) \
1330 (G_TYPE_CHECK_INSTANCE_CAST \
1331 ((obj), E_TYPE_COMP_EDITOR_PROPERTY_PART_TIMEZONE, ECompEditorPropertyPartTimezone))
1332 #define E_IS_COMP_EDITOR_PROPERTY_PART_TIMEZONE(obj) \
1333 (G_TYPE_CHECK_INSTANCE_TYPE \
1334 ((obj), E_TYPE_COMP_EDITOR_PROPERTY_PART_TIMEZONE))
1336 typedef struct _ECompEditorPropertyPartTimezone ECompEditorPropertyPartTimezone
;
1337 typedef struct _ECompEditorPropertyPartTimezoneClass ECompEditorPropertyPartTimezoneClass
;
1339 struct _ECompEditorPropertyPartTimezone
{
1340 ECompEditorPropertyPart parent
;
1343 struct _ECompEditorPropertyPartTimezoneClass
{
1344 ECompEditorPropertyPartClass parent_class
;
1347 GType
e_comp_editor_property_part_timezone_get_type (void) G_GNUC_CONST
;
1349 G_DEFINE_TYPE (ECompEditorPropertyPartTimezone
, e_comp_editor_property_part_timezone
, E_TYPE_COMP_EDITOR_PROPERTY_PART
)
1352 ecepp_timezone_create_widgets (ECompEditorPropertyPart
*property_part
,
1353 GtkWidget
**out_label_widget
,
1354 GtkWidget
**out_edit_widget
)
1356 g_return_if_fail (E_IS_COMP_EDITOR_PROPERTY_PART_TIMEZONE (property_part
));
1357 g_return_if_fail (out_label_widget
!= NULL
);
1358 g_return_if_fail (out_edit_widget
!= NULL
);
1360 *out_label_widget
= gtk_label_new_with_mnemonic (C_("ECompEditor", "Time _zone:"));
1362 g_object_set (G_OBJECT (*out_label_widget
),
1364 "halign", GTK_ALIGN_END
,
1366 "valign", GTK_ALIGN_CENTER
,
1369 gtk_widget_show (*out_label_widget
);
1371 *out_edit_widget
= e_timezone_entry_new ();
1372 e_timezone_entry_set_timezone (E_TIMEZONE_ENTRY (*out_edit_widget
), calendar_config_get_icaltimezone ());
1374 gtk_widget_show (*out_edit_widget
);
1376 gtk_label_set_mnemonic_widget (GTK_LABEL (*out_label_widget
), *out_edit_widget
);
1378 g_signal_connect_swapped (*out_edit_widget
, "changed",
1379 G_CALLBACK (e_comp_editor_property_part_emit_changed
), property_part
);
1383 ecepp_timezone_fill_widget (ECompEditorPropertyPart
*property_part
,
1384 icalcomponent
*component
)
1386 struct icaltimetype (* get_func
) (const icalproperty
*prop
);
1389 g_return_if_fail (E_IS_COMP_EDITOR_PROPERTY_PART_TIMEZONE (property_part
));
1391 get_func
= icalproperty_get_dtstart
;
1392 prop
= icalcomponent_get_first_property (component
, ICAL_DTSTART_PROPERTY
);
1395 get_func
= icalproperty_get_dtend
;
1396 prop
= icalcomponent_get_first_property (component
, ICAL_DTEND_PROPERTY
);
1400 get_func
= icalproperty_get_due
;
1401 prop
= icalcomponent_get_first_property (component
, ICAL_DUE_PROPERTY
);
1405 struct icaltimetype itt
;
1407 itt
= get_func (prop
);
1409 GtkWidget
*edit_widget
;
1411 edit_widget
= e_comp_editor_property_part_get_edit_widget (property_part
);
1412 g_return_if_fail (E_IS_TIMEZONE_ENTRY (edit_widget
));
1414 e_timezone_entry_set_timezone (E_TIMEZONE_ENTRY (edit_widget
), (icaltimezone
*) itt
.zone
);
1420 ecepp_timezone_fill_component (ECompEditorPropertyPart
*property_part
,
1421 icalcomponent
*component
)
1423 /* Nothing to do here, this is sort-of virtual property part */
1427 e_comp_editor_property_part_timezone_init (ECompEditorPropertyPartTimezone
*part_timezone
)
1432 e_comp_editor_property_part_timezone_class_init (ECompEditorPropertyPartTimezoneClass
*klass
)
1434 ECompEditorPropertyPartClass
*part_class
;
1436 part_class
= E_COMP_EDITOR_PROPERTY_PART_CLASS (klass
);
1437 part_class
->create_widgets
= ecepp_timezone_create_widgets
;
1438 part_class
->fill_widget
= ecepp_timezone_fill_widget
;
1439 part_class
->fill_component
= ecepp_timezone_fill_component
;
1442 ECompEditorPropertyPart
*
1443 e_comp_editor_property_part_timezone_new (void)
1445 return g_object_new (E_TYPE_COMP_EDITOR_PROPERTY_PART_TIMEZONE
, NULL
);
1448 /* ************************************************************************* */
1450 #define E_TYPE_COMP_EDITOR_PROPERTY_PART_TRANSPARENCY \
1451 (e_comp_editor_property_part_transparency_get_type ())
1452 #define E_COMP_EDITOR_PROPERTY_PART_TRANSPARENCY(obj) \
1453 (G_TYPE_CHECK_INSTANCE_CAST \
1454 ((obj), E_TYPE_COMP_EDITOR_PROPERTY_PART_TRANSPARENCY, ECompEditorPropertyPartTransparency))
1455 #define E_IS_COMP_EDITOR_PROPERTY_PART_TRANSPARENCY(obj) \
1456 (G_TYPE_CHECK_INSTANCE_TYPE \
1457 ((obj), E_TYPE_COMP_EDITOR_PROPERTY_PART_TRANSPARENCY))
1459 typedef struct _ECompEditorPropertyPartTransparency ECompEditorPropertyPartTransparency
;
1460 typedef struct _ECompEditorPropertyPartTransparencyClass ECompEditorPropertyPartTransparencyClass
;
1462 struct _ECompEditorPropertyPartTransparency
{
1463 ECompEditorPropertyPart parent
;
1466 struct _ECompEditorPropertyPartTransparencyClass
{
1467 ECompEditorPropertyPartClass parent_class
;
1470 GType
e_comp_editor_property_part_transparency_get_type (void) G_GNUC_CONST
;
1472 G_DEFINE_TYPE (ECompEditorPropertyPartTransparency
, e_comp_editor_property_part_transparency
, E_TYPE_COMP_EDITOR_PROPERTY_PART
)
1475 ecepp_transparency_create_widgets (ECompEditorPropertyPart
*property_part
,
1476 GtkWidget
**out_label_widget
,
1477 GtkWidget
**out_edit_widget
)
1479 g_return_if_fail (E_IS_COMP_EDITOR_PROPERTY_PART_TRANSPARENCY (property_part
));
1480 g_return_if_fail (out_label_widget
!= NULL
);
1481 g_return_if_fail (out_edit_widget
!= NULL
);
1483 *out_label_widget
= NULL
;
1485 *out_edit_widget
= gtk_check_button_new_with_mnemonic (C_("ECompEditor", "Show time as _busy"));
1487 g_object_set (G_OBJECT (*out_edit_widget
),
1489 "halign", GTK_ALIGN_FILL
,
1491 "valign", GTK_ALIGN_CENTER
,
1494 gtk_widget_show (*out_edit_widget
);
1496 g_signal_connect_swapped (*out_edit_widget
, "toggled",
1497 G_CALLBACK (e_comp_editor_property_part_emit_changed
), property_part
);
1501 ecepp_transparency_fill_widget (ECompEditorPropertyPart
*property_part
,
1502 icalcomponent
*component
)
1504 GtkWidget
*edit_widget
;
1507 g_return_if_fail (E_IS_COMP_EDITOR_PROPERTY_PART_TRANSPARENCY (property_part
));
1509 edit_widget
= e_comp_editor_property_part_get_edit_widget (property_part
);
1510 g_return_if_fail (GTK_IS_CHECK_BUTTON (edit_widget
));
1512 prop
= icalcomponent_get_first_property (component
, ICAL_TRANSP_PROPERTY
);
1514 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (edit_widget
),
1515 icalproperty_get_transp (prop
) == ICAL_TRANSP_OPAQUE
);
1517 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (edit_widget
), TRUE
);
1522 ecepp_transparency_fill_component (ECompEditorPropertyPart
*property_part
,
1523 icalcomponent
*component
)
1525 GtkWidget
*edit_widget
;
1527 icalproperty_transp value
;
1529 g_return_if_fail (E_IS_COMP_EDITOR_PROPERTY_PART_TRANSPARENCY (property_part
));
1531 edit_widget
= e_comp_editor_property_part_get_edit_widget (property_part
);
1532 g_return_if_fail (GTK_IS_CHECK_BUTTON (edit_widget
));
1534 value
= gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (edit_widget
)) ? ICAL_TRANSP_OPAQUE
: ICAL_TRANSP_TRANSPARENT
;
1536 prop
= icalcomponent_get_first_property (component
, ICAL_TRANSP_PROPERTY
);
1538 icalproperty_set_transp (prop
, value
);
1540 prop
= icalproperty_new_transp (value
);
1541 icalcomponent_add_property (component
, prop
);
1546 e_comp_editor_property_part_transparency_init (ECompEditorPropertyPartTransparency
*part_transparency
)
1551 e_comp_editor_property_part_transparency_class_init (ECompEditorPropertyPartTransparencyClass
*klass
)
1553 ECompEditorPropertyPartClass
*part_class
;
1555 part_class
= E_COMP_EDITOR_PROPERTY_PART_CLASS (klass
);
1556 part_class
->create_widgets
= ecepp_transparency_create_widgets
;
1557 part_class
->fill_widget
= ecepp_transparency_fill_widget
;
1558 part_class
->fill_component
= ecepp_transparency_fill_component
;
1561 ECompEditorPropertyPart
*
1562 e_comp_editor_property_part_transparency_new (void)
1564 return g_object_new (E_TYPE_COMP_EDITOR_PROPERTY_PART_TRANSPARENCY
, NULL
);
1567 /* ************************************************************************* */