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
This commit is contained in:
Yash Singh
2017-06-09 22:33:46 -03:00
committed by Georges Basile Stavracas Neto
parent 3503f16b09
commit cbc9fe7be1
2 changed files with 84 additions and 0 deletions
+80
View File
@@ -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;
}
+4
View File
@@ -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__