evolution-3.6.4/calendar/gui/dialogs/recur-comp.c

No issues found

  1 /*
  2  * Evolution calendar - Recurring calendar component dialog
  3  *
  4  * This program is free software; you can redistribute it and/or
  5  * modify it under the terms of the GNU Lesser General Public
  6  * License as published by the Free Software Foundation; either
  7  * version 2 of the License, or (at your option) version 3.
  8  *
  9  * This program is distributed in the hope that it will be useful,
 10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 12  * Lesser General Public License for more details.
 13  *
 14  * You should have received a copy of the GNU Lesser General Public
 15  * License along with the program; if not, see <http://www.gnu.org/licenses/>
 16  *
 17  *
 18  * Authors:
 19  *		JP Rosevear <jpr@ximian.com>
 20  *
 21  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
 22  *
 23  */
 24 
 25 #ifdef HAVE_CONFIG_H
 26 #include <config.h>
 27 #endif
 28 
 29 #include <glib/gi18n.h>
 30 #include "recur-comp.h"
 31 
 32 gboolean
 33 recur_component_dialog (ECalClient *client,
 34                         ECalComponent *comp,
 35                         CalObjModType *mod,
 36                         GtkWindow *parent,
 37                         gboolean delegated)
 38 {
 39 	gchar *str;
 40 	GtkWidget *dialog, *rb_this, *rb_prior, *rb_future, *rb_all, *hbox;
 41 	GtkWidget *placeholder, *vbox;
 42 	GtkWidget *content_area;
 43 	ECalComponentVType vtype;
 44 	gboolean ret;
 45 
 46 	g_return_val_if_fail (E_IS_CAL_COMPONENT (comp), FALSE);
 47 
 48 	vtype = e_cal_component_get_vtype (comp);
 49 
 50 	switch (vtype) {
 51 	case E_CAL_COMPONENT_EVENT:
 52 		if (!delegated)
 53 			str = g_strdup_printf (_("You are modifying a recurring event. What would you like to modify?"));
 54 		else
 55 			str = g_strdup_printf (_("You are delegating a recurring event. What would you like to delegate?"));
 56 		break;
 57 
 58 	case E_CAL_COMPONENT_TODO:
 59 		str = g_strdup_printf (_("You are modifying a recurring task. What would you like to modify?"));
 60 		break;
 61 
 62 	case E_CAL_COMPONENT_JOURNAL:
 63 		str = g_strdup_printf (_("You are modifying a recurring memo. What would you like to modify?"));
 64 		break;
 65 
 66 	default:
 67 		g_message ("recur_component_dialog(): Cannot handle object of type %d", vtype);
 68 		return FALSE;
 69 	}
 70 
 71 	dialog = gtk_message_dialog_new (parent, 0, GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, "%s", str);
 72 	g_free (str);
 73 	gtk_window_set_resizable (GTK_WINDOW (dialog), TRUE);
 74 
 75 	content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
 76 
 77 	hbox = gtk_hbox_new (FALSE, 12);
 78 	gtk_container_add (GTK_CONTAINER (content_area), hbox);
 79 
 80 	placeholder = gtk_label_new ("");
 81 	gtk_widget_set_size_request (placeholder, 48, 48);
 82 	gtk_box_pack_start (GTK_BOX (hbox), placeholder, FALSE, FALSE, 0);
 83 	gtk_widget_show (placeholder);
 84 
 85 	vbox = gtk_vbox_new (FALSE, 6);
 86 	gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
 87 	gtk_widget_show (vbox);
 88 
 89 	rb_this = gtk_radio_button_new_with_label (NULL, _("This Instance Only"));
 90 	gtk_container_add (GTK_CONTAINER (vbox), rb_this);
 91 
 92 	if (!e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_NO_THISANDPRIOR)) {
 93 		rb_prior = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (rb_this), _("This and Prior Instances"));
 94 		gtk_container_add (GTK_CONTAINER (vbox), rb_prior);
 95 	} else
 96 		rb_prior = NULL;
 97 
 98 	if (!e_client_check_capability (E_CLIENT (client), CAL_STATIC_CAPABILITY_NO_THISANDFUTURE)) {
 99 		rb_future = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (rb_this), _("This and Future Instances"));
100 		gtk_container_add (GTK_CONTAINER (vbox), rb_future);
101 	} else
102 		rb_future = NULL;
103 
104 	rb_all = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (rb_this), _("All Instances"));
105 	gtk_container_add (GTK_CONTAINER (vbox), rb_all);
106 
107 	gtk_widget_show_all (hbox);
108 
109 	placeholder = gtk_label_new ("");
110 	gtk_box_pack_start (GTK_BOX (content_area), placeholder, FALSE, FALSE, 0);
111 	gtk_widget_show (placeholder);
112 
113 	ret = gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK;
114 
115 	if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (rb_this)))
116 		*mod = CALOBJ_MOD_THIS;
117 	else if (rb_prior && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (rb_prior)))
118 		*mod = CALOBJ_MOD_THISANDPRIOR;
119 	else if (rb_future && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (rb_future)))
120 		*mod = CALOBJ_MOD_THISANDFUTURE;
121 	else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (rb_all))) {
122 		*mod = CALOBJ_MOD_ALL;
123 
124 	}
125 
126 	gtk_widget_destroy (dialog);
127 
128 	return ret;
129 }