[gnome-calendar] utils: add dialog to modify recurring events
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] utils: add dialog to modify recurring events
- Date: Sat, 10 Jun 2017 01:34:34 +0000 (UTC)
commit cbc9fe7be165e32974295675c9890187966f7f3f
Author: Yash Singh <yashdev10p gmail com>
Date: Thu Jun 8 18:16:19 2017 +0530
utils: add dialog to modify recurring events
Whenever a user chooses to modify an event which is
recurring, a new dialog will open automatically when
the user clicks 'Done' or 'Delete' in edit-dialog,
after making the desired changes. This new dialog
will ask the user to choose the set of events to
which the changes will be applied. The options
include 'This Event Only', 'Subsequent Events'
and 'All Events'. The function returns true and
the changes take place only if the user chooses any
option other than 'Cancel' or <Alt+F4>.
https://bugzilla.gnome.org/show_bug.cgi?id=782755
src/gcal-utils.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/gcal-utils.h | 4 +++
2 files changed, 84 insertions(+), 0 deletions(-)
---
diff --git a/src/gcal-utils.c b/src/gcal-utils.c
index c3cb35d..384860d 100644
--- a/src/gcal-utils.c
+++ b/src/gcal-utils.c
@@ -1150,3 +1150,83 @@ is_source_enabled (ESource *source)
return e_source_selectable_get_selected (selectable);
}
+
+/**
+ * ask_recurrence_modification_type:
+ * @parent: a #GtkWidget
+ * @modtype: an #ECalObjModType
+ * @source: an #ESource
+ *
+ * Assigns the appropriate modtype while modifying an event
+ * based on user's choice in the GtkMessageDialog that pops up.
+ * The modtype helps the user choose the part of recurrent events
+ * to modify. Such as Only This Event, Subsequent events
+ * or All events.
+ *
+ * Returns: %TRUE if user chooses appropriate option and
+ * @modtype is assigned, %FALSE otherwise.
+ */
+gboolean
+ask_recurrence_modification_type (GtkWidget *parent,
+ ECalObjModType *modtype,
+ ESource source)
+{
+ GtkWidget *dialog;
+ GtkDialogFlags flags;
+ gint result;
+ gboolean is_set;
+ EClient *client;
+
+ flags = GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT;
+ *modtype = E_CAL_OBJ_MOD_THIS;
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW (parent),
+ flags,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_NONE,
+ _("The event you are trying to modify is recurring. The changes you have
selected should be applied to:"));
+
+ gtk_dialog_add_buttons (GTK_DIALOG (dialog),
+ _("_Cancel"),
+ GTK_RESPONSE_CANCEL,
+ _("_Only This Event"),
+ GTK_RESPONSE_ACCEPT,
+ NULL);
+
+ client = g_object_get_data (G_OBJECT (&source), "client");
+
+ if (!e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_NO_THISANDFUTURE))
+ gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Subsequent events"), GTK_RESPONSE_OK);
+
+ gtk_dialog_add_button (GTK_DIALOG (dialog), _("_All events"), GTK_RESPONSE_YES);
+
+ gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent));
+
+ result = gtk_dialog_run (GTK_DIALOG (dialog));
+
+ switch (result)
+ {
+ case GTK_RESPONSE_CANCEL:
+ is_set = FALSE;
+ break;
+ case GTK_RESPONSE_ACCEPT:
+ *modtype = E_CAL_OBJ_MOD_THIS;
+ is_set = TRUE;
+ break;
+ case GTK_RESPONSE_OK:
+ *modtype = E_CAL_OBJ_MOD_THIS_AND_FUTURE;
+ is_set = TRUE;
+ break;
+ case GTK_RESPONSE_YES:
+ *modtype = E_CAL_OBJ_MOD_ALL;
+ is_set = TRUE;
+ break;
+ default:
+ is_set = FALSE;
+ break;
+ }
+
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+
+ return is_set;
+}
diff --git a/src/gcal-utils.h b/src/gcal-utils.h
index b4ab0ce..37b1d82 100644
--- a/src/gcal-utils.h
+++ b/src/gcal-utils.h
@@ -139,4 +139,8 @@ gboolean should_change_date_for_scroll (gdouble
gboolean is_source_enabled (ESource *source);
+gboolean ask_recurrence_modification_type (GtkWidget *parent,
+ ECalObjModType *modtype,
+ ESource source);
+
#endif // __GCAL_UTILS_H__
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]