aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/exchange-operations/exchange-send-options.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/exchange-operations/exchange-send-options.c')
-rw-r--r--plugins/exchange-operations/exchange-send-options.c239
1 files changed, 221 insertions, 18 deletions
diff --git a/plugins/exchange-operations/exchange-send-options.c b/plugins/exchange-operations/exchange-send-options.c
index 68bfc89fce..e9dacc7d22 100644
--- a/plugins/exchange-operations/exchange-send-options.c
+++ b/plugins/exchange-operations/exchange-send-options.c
@@ -24,11 +24,15 @@
#include <string.h>
#include <glib.h>
+#include <libedataserverui/e-name-selector.h>
+#include <libedataserverui/e-contact-store.h>
+#include "exchange-operations.h"
+#include <e-util/e-error.h>
#include <gtk/gtksignal.h>
#include <gtk/gtktogglebutton.h>
#include <gtk/gtk.h>
#include <libgnome/libgnome.h>
-#include <glib/gi18n.h>
+#include <libgnome/gnome-i18n.h>
#include <glade/glade.h>
#include "e-util/e-util-private.h"
@@ -42,6 +46,9 @@ struct _ExchangeSendOptionsDialogPrivate {
/*Widgets*/
GtkWidget *main;
+
+ /*name selector dialog*/
+ ENameSelector *proxy_name_selector;
/*Importance*/
GtkWidget *importance;
@@ -49,12 +56,18 @@ struct _ExchangeSendOptionsDialogPrivate {
/*Sensitivity*/
GtkWidget *sensitivity;
+ /*Send_as_delegate_enabled*/
+ GtkWidget *delegate_enabled;
+
/*Read Receipt*/
GtkWidget *read_receipt;
/*Delivery Receipt*/
GtkWidget *delivery_receipt;
-
+
+ /*User button*/
+ GtkWidget *button_user;
+
/*Label Widgets*/
GtkWidget *importance_label;
GtkWidget *sensitivity_label;
@@ -74,22 +87,88 @@ enum {
static guint signals[LAST_SIGNAL] = {0};
-
-static void
+/* exchange_send_options_get_widgets_data(ExchangeSendOptionsDialog *sod)
+ Return Value:This function returns a -1 if an error occurs. In case of error-free operation a 1 is returned.
+*/
+static int
exchange_send_options_get_widgets_data (ExchangeSendOptionsDialog *sod)
{
ExchangeSendOptionsDialogPrivate *priv;
ExchangeSendOptions *options;
+ const char *address, *email, *name;
+ guint count=0;
+ ENameSelectorEntry *name_selector_entry;
+ EDestinationStore *destination_store;
+ GList *destinations, *tmp;
+
priv = sod->priv;
options = sod->options;
+ /* This block helps us fetch the address of the delegator(s). If no delegator is selected or more
+ than one delegatee has been selected then an info dialog is popped up to help the user.
+ */
+ if(gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->delegate_enabled))) {
+
+ name_selector_entry = e_name_selector_peek_section_entry (priv->proxy_name_selector, "Add User");
+ destination_store = e_name_selector_entry_peek_destination_store (E_NAME_SELECTOR_ENTRY (name_selector_entry));
+ destinations = e_destination_store_list_destinations (destination_store);
+ tmp = destinations;
+
+ email = NULL;
+
+ /* The temporary variables address, email, and name are needed to fetch the list items.
+ Only the valid one is then copied into the storage variables. The "count" variable
+ helps us keep a count of the exact number of items in the list. The g_list_length(GList *)
+ produced ambiguous results. Hence count is used :)
+ */
+ for (; tmp != NULL; tmp = g_list_next (tmp)) {
+ address = g_strdup ((char *) e_destination_get_address (tmp->data));
+ email = g_strdup ((char *) e_destination_get_email (tmp->data));
+ name = g_strdup (e_destination_get_name (tmp->data));
+ if (g_str_equal (email, ""))
+ continue;
+ count++;
+
+ options->delegate_address = address;
+ options->delegate_name = name;
+ options->delegate_email = email;
+ }
+
+ if(count == 0) {
+ e_error_run ((GtkWindow *) priv->main,
+ "org-gnome-exchange-operations:no-delegate-selected", NULL, NULL);
+ gtk_widget_grab_focus ((GtkWidget *) name_selector_entry);
+ options->delegate_address = NULL;
+ options->delegate_name = NULL;
+ options->delegate_email = NULL;
+ return -1;
+ }
+
+ if(count > 1) {
+ e_error_run ((GtkWindow *)priv->main,
+ "org-gnome-exchange-operations:more-delegates-selected", NULL, NULL);
+ gtk_widget_grab_focus ((GtkWidget *) name_selector_entry);
+ options->delegate_address = NULL;
+ options->delegate_name = NULL;
+ options->delegate_email = NULL;
+ return -1;
+ }
+ }
+
options->importance = gtk_combo_box_get_active ((GtkComboBox *)priv->importance);
options->sensitivity = gtk_combo_box_get_active ((GtkComboBox *)priv->sensitivity);
- options->delivery_enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->delivery_receipt));
- options->read_enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->read_receipt));
+ options->send_as_del_enabled = gtk_toggle_button_get_active (
+ GTK_TOGGLE_BUTTON (priv->delegate_enabled));
+ options->delivery_enabled = gtk_toggle_button_get_active (
+ GTK_TOGGLE_BUTTON (priv->delivery_receipt));
+
+ options->read_enabled = gtk_toggle_button_get_active (
+ GTK_TOGGLE_BUTTON (priv->read_receipt));
+
+ return 1;
}
static gboolean
@@ -107,6 +186,8 @@ get_widgets (ExchangeSendOptionsDialog *sod)
priv->importance = EXCHANGE ("imp_combo_box");
priv->sensitivity = EXCHANGE ("sensitivity_combo_box");
+ priv->button_user = EXCHANGE ("button-user");
+ priv->delegate_enabled = EXCHANGE ("del_enabled_check");
priv->read_receipt = EXCHANGE ("read_check_button");
priv->delivery_receipt = EXCHANGE ("delivery_check_button");
priv->importance_label = EXCHANGE ("Importance_label");
@@ -116,6 +197,8 @@ get_widgets (ExchangeSendOptionsDialog *sod)
return (priv->importance
&&priv->sensitivity
+ &&priv->button_user
+ &&priv->delegate_enabled
&&priv->read_receipt
&&priv->delivery_receipt
&&priv->importance_label
@@ -127,6 +210,8 @@ exchange_send_options_fill_widgets_with_data (ExchangeSendOptionsDialog *sod)
{
ExchangeSendOptionsDialogPrivate *priv;
ExchangeSendOptions *options;
+ ENameSelectorEntry *name_selector_entry;
+
priv = sod->priv;
options = sod->options;
@@ -137,11 +222,26 @@ exchange_send_options_fill_widgets_with_data (ExchangeSendOptionsDialog *sod)
gtk_combo_box_set_active ((GtkComboBox *) priv->importance, options->importance);
gtk_combo_box_set_active ((GtkComboBox *) priv->sensitivity, options->sensitivity);
+
+ name_selector_entry = e_name_selector_peek_section_entry (priv->proxy_name_selector, "Add User");
+
+ if(options->send_as_del_enabled) {
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->delegate_enabled), TRUE);
+ gtk_widget_set_sensitive ((GtkWidget *)name_selector_entry, TRUE);
+ gtk_widget_set_sensitive ((GtkWidget *)priv->button_user, TRUE);
+ }
+
+ else {
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->delegate_enabled), FALSE);
+ gtk_widget_set_sensitive ((GtkWidget *)name_selector_entry, FALSE);
+ gtk_widget_set_sensitive ((GtkWidget *)priv->button_user, FALSE);
+ }
if (options->read_enabled)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->read_receipt), TRUE);
else
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->read_receipt), FALSE);
+
if (options->delivery_enabled)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->delivery_receipt), TRUE);
else
@@ -189,37 +289,104 @@ static void exchange_send_options_cb (GtkDialog *dialog, gint state, gpointer fu
sod = func_data;
priv = sod->priv;
- switch (state) {
+ switch (state) {
case GTK_RESPONSE_OK:
- exchange_send_options_get_widgets_data (sod);
+ if(exchange_send_options_get_widgets_data (sod) < 0)
+ return;
case GTK_RESPONSE_CANCEL:
- gtk_widget_hide (priv->main);
- gtk_widget_destroy (priv->main);
- g_object_unref (priv->xml);
- break;
+ gtk_widget_hide (priv->main);
+ gtk_widget_destroy (priv->main);
+ g_object_unref (priv->xml);
+ break;
case GTK_RESPONSE_HELP:
- gnome_help_display (
+ gnome_help_display (
"evolution.xml", priv->help_section, &error);
if (error != NULL) {
g_warning ("%s", error->message);
g_error_free (error);
}
- break;
+ break;
}
g_signal_emit (G_OBJECT (func_data), signals[SOD_RESPONSE], 0, state);
}
+
+/* This function acts as a listener for the toggling of "send_as_a_delegate" button. This is needed to
+ sensitize the name_selector_entry and the User Button
+*/
+static void
+delegate_option_toggled (GtkCheckButton *button, gpointer func_data)
+{
+ ExchangeSendOptionsDialogPrivate *priv;
+ ExchangeSendOptionsDialog *sod;
+ ENameSelectorEntry *name_selector_entry;
+ ExchangeSendOptions *options;
+
+ sod=func_data;
+ priv=sod->priv;
+ options=sod->options;
+
+ name_selector_entry = e_name_selector_peek_section_entry (priv->proxy_name_selector, "Add User");
+
+ if(gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->delegate_enabled))) {
+ gtk_widget_set_sensitive ((GtkWidget *) name_selector_entry, TRUE);
+ gtk_widget_set_sensitive ((GtkWidget *) priv->button_user, TRUE);
+ }
+
+ else {
+ gtk_widget_set_sensitive ((GtkWidget *) name_selector_entry, FALSE);
+ gtk_widget_set_sensitive ((GtkWidget *) priv->button_user, FALSE);
+ }
+
+}
+
+static void
+addressbook_dialog_response (ENameSelectorDialog *name_selector_dialog, gint response, gpointer user_data)
+{
+ gtk_widget_hide (GTK_WIDGET (name_selector_dialog));
+}
+
+static void
+addressbook_entry_changed (GtkWidget *entry, gpointer user_data)
+{
+}
+
+/* This function invokes the name selector dialog
+*/
+static void
+address_button_clicked (GtkButton *button, gpointer func_data)
+{
+
+ ExchangeSendOptionsDialogPrivate *priv;
+ ExchangeSendOptionsDialog *sod;
+ ENameSelectorDialog *name_selector_dialog;
+
+ sod=func_data;
+ priv=sod->priv;
+
+ name_selector_dialog = e_name_selector_peek_dialog (priv->proxy_name_selector);
+ gtk_widget_show (GTK_WIDGET (name_selector_dialog));
+}
gboolean
exchange_sendoptions_dialog_run (ExchangeSendOptionsDialog *sod, GtkWidget *parent)
-{
+{
ExchangeSendOptionsDialogPrivate *priv;
+ ExchangeSendOptions *options;
+
GtkWidget *toplevel;
gchar *filename;
+ EDestinationStore *destination_store;
+ ENameSelectorDialog *name_selector_dialog;
+ ENameSelectorModel *name_selector_model;
+ ENameSelectorEntry *name_selector_entry;
+ EDestination *des;
+ GtkWidget *name_box;
g_return_val_if_fail (sod != NULL || EXCHANGE_IS_SENDOPTIONS_DIALOG (sod), FALSE);
priv = sod->priv;
+ options = sod->options;
filename = g_build_filename (EVOLUTION_GLADEDIR,
"exchange-send-options.glade",
@@ -243,11 +410,44 @@ exchange_sendoptions_dialog_run (ExchangeSendOptionsDialog *sod, GtkWidget *pare
gtk_window_set_transient_for (GTK_WINDOW (toplevel),
GTK_WINDOW (parent));
+ priv->proxy_name_selector = e_name_selector_new ();
+ name_selector_dialog = e_name_selector_peek_dialog (priv->proxy_name_selector);
+
+ name_selector_model = e_name_selector_peek_model (priv->proxy_name_selector);
+ e_name_selector_model_add_section (name_selector_model, "Add User", "Add User", NULL);
+
exchange_send_options_fill_widgets_with_data (sod);
+
+ if(options->delegate_address) {
+ e_name_selector_model_peek_section (name_selector_model, "Add User", NULL, &destination_store);
+ des = e_destination_new ();
+ e_destination_set_email (des, options->delegate_email);
+ e_destination_set_name (des, options->delegate_name);
+ e_destination_store_append_destination (destination_store, des);
+ g_object_unref (des);
+ }
+
+ g_signal_connect ((GtkButton *) priv->button_user, "clicked",
+ G_CALLBACK (address_button_clicked), sod);
+ g_signal_connect (name_selector_dialog, "response",
+ G_CALLBACK (addressbook_dialog_response), sod);
+ g_signal_connect (GTK_DIALOG (priv->main), "response",
+ G_CALLBACK(exchange_send_options_cb), sod);
+ g_signal_connect ((GtkCheckButton *) priv->delegate_enabled, "toggled",
+ G_CALLBACK(delegate_option_toggled), sod);
+
+ name_selector_entry = e_name_selector_peek_section_entry (priv->proxy_name_selector,
+ "Add User");
+ g_signal_connect (name_selector_entry, "changed", G_CALLBACK (addressbook_entry_changed), sod);
- g_signal_connect (GTK_DIALOG (priv->main), "response", G_CALLBACK(exchange_send_options_cb), sod);
-
- gtk_window_set_modal ((GtkWindow *)priv->main, TRUE);
+ /* The name box is just a container. The name_selector_entry is added to it. This Widget
+ is created dynamically*/
+ name_box = glade_xml_get_widget (priv->xml, "del_name_box");
+ gtk_container_add ((GtkContainer *) name_box, (GtkWidget *) name_selector_entry);
+ gtk_widget_show ((GtkWidget *) name_selector_entry);
+ gtk_widget_grab_focus ((GtkWidget *) name_selector_entry);
+
+ gtk_window_set_modal ((GtkWindow *) priv->main, TRUE);
gtk_widget_show (priv->main);
return TRUE;
@@ -291,6 +491,7 @@ exchange_sendoptions_dialog_init (GObject *object)
sod->priv = priv;
sod->options = new;
+ sod->options->send_as_del_enabled = FALSE;
sod->options->delivery_enabled = FALSE;
sod->options->read_enabled = FALSE;
sod->options->importance = E_IMP_NORMAL;
@@ -302,6 +503,8 @@ exchange_sendoptions_dialog_init (GObject *object)
priv->sensitivity = NULL;
priv->sensitivity_label = NULL;
priv->importance_label = NULL;
+ priv->button_user = NULL;
+ priv->proxy_name_selector = NULL;
priv->read_receipt = NULL;
priv->delivery_receipt = NULL;