aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/dialogs/memo-page.c
diff options
context:
space:
mode:
authorSuman Manjunath <msuman@novell.com>2007-08-13 18:40:23 +0800
committerChenthill Palanisamy <pchen@src.gnome.org>2007-08-13 18:40:23 +0800
commit98087d1543dff4c0f1cf70b88c634ebe3bcbb656 (patch)
treefd6998b832ed6bb60398da9872e5b8922694baa5 /calendar/gui/dialogs/memo-page.c
parent7701d36a65aba3e183fe30e6a0818c5405eb1f46 (diff)
downloadgsoc2013-evolution-98087d1543dff4c0f1cf70b88c634ebe3bcbb656.tar
gsoc2013-evolution-98087d1543dff4c0f1cf70b88c634ebe3bcbb656.tar.gz
gsoc2013-evolution-98087d1543dff4c0f1cf70b88c634ebe3bcbb656.tar.bz2
gsoc2013-evolution-98087d1543dff4c0f1cf70b88c634ebe3bcbb656.tar.lz
gsoc2013-evolution-98087d1543dff4c0f1cf70b88c634ebe3bcbb656.tar.xz
gsoc2013-evolution-98087d1543dff4c0f1cf70b88c634ebe3bcbb656.tar.zst
gsoc2013-evolution-98087d1543dff4c0f1cf70b88c634ebe3bcbb656.zip
reviewed by: Chenthill Palanisamy <pchenthill@novell.com>
2007-08-13 Suman Manjunath <msuman@novell.com> reviewed by: Chenthill Palanisamy <pchenthill@novell.com> * gui/dialogs/event-page.c: (event_page_init), (sensitize_widgets), (get_current_account), (event_page_fill_widgets), (event_page_fill_component), (existing_attendee), (event_page_set_info_string), (get_widgets), (source_changed_cb), (init_widgets), (event_page_select_organizer), (event_page_construct): * gui/dialogs/event-page.glade: * gui/dialogs/memo-page.c: (memo_page_init), * (sensitize_widgets), (memo_page_fill_widgets), (get_current_account), (memo_page_fill_component), (memo_page_set_info_string), (get_widgets), (source_changed_cb), (init_widgets), (memo_page_select_organizer), (memo_page_construct): * gui/dialogs/memo-page.glade: * gui/dialogs/task-page.c: (task_page_init), * (sensitize_widgets), (get_current_account), (task_page_fill_widgets), (task_page_fill_component), (existing_attendee), (task_page_set_info_string), (get_widgets), (source_changed_cb), (init_widgets), (task_page_select_organizer), (task_page_construct): * gui/dialogs/task-page.glade: Add a label on the top to show * information string for calendar, task and memo editors. It would be shown while operating on subscribed user's folder items. * gui/itip-utils.c: (itip_send_comp), (reply_to_calendar_comp): * A utility function sanitize_component has been removed. The sentby parameter is set in the event pages. --This line, and those below, will be ignored-- M calendar/gui/dialogs/task-page.glade M calendar/gui/dialogs/task-page.c M calendar/gui/dialogs/task-page.h M calendar/gui/dialogs/event-page.glade M calendar/gui/dialogs/memo-page.glade M calendar/gui/dialogs/event-page.c M calendar/gui/dialogs/event-page.h M calendar/gui/dialogs/memo-page.c M calendar/gui/dialogs/memo-page.h M calendar/gui/itip-utils.c M calendar/ChangeLog svn path=/trunk/; revision=33996
Diffstat (limited to 'calendar/gui/dialogs/memo-page.c')
-rw-r--r--calendar/gui/dialogs/memo-page.c165
1 files changed, 141 insertions, 24 deletions
diff --git a/calendar/gui/dialogs/memo-page.c b/calendar/gui/dialogs/memo-page.c
index 816144042c..6c50cc029f 100644
--- a/calendar/gui/dialogs/memo-page.c
+++ b/calendar/gui/dialogs/memo-page.c
@@ -70,6 +70,11 @@ struct _MemoPagePrivate {
ECalComponentClassification classification;
+ /* Generic informative messages placeholder */
+ GtkWidget *info_hbox;
+ GtkWidget *info_icon;
+ GtkWidget *info_string;
+
/* Organizer */
GtkWidget *org_label;
GtkWidget *org_combo;
@@ -114,6 +119,7 @@ static GtkWidget *memo_page_get_widget (CompEditorPage *page);
static void memo_page_focus_main_widget (CompEditorPage *page);
static gboolean memo_page_fill_widgets (CompEditorPage *page, ECalComponent *comp);
static gboolean memo_page_fill_component (CompEditorPage *page, ECalComponent *comp);
+static void memo_page_select_organizer (MemoPage *mpage, const char *backend_address);
G_DEFINE_TYPE (MemoPage, memo_page, TYPE_COMP_EDITOR_PAGE)
@@ -163,6 +169,10 @@ memo_page_init (MemoPage *mpage)
priv->categories_btn = NULL;
priv->categories = NULL;
+ priv->info_hbox = NULL;
+ priv->info_icon = NULL;
+ priv->info_string = NULL;
+
priv->updating = FALSE;
}
@@ -300,8 +310,10 @@ sensitize_widgets (MemoPage *mpage)
priv = mpage->priv;
- if (!e_cal_is_read_only (COMP_EDITOR_PAGE (mpage)->client, &read_only, NULL))
- read_only = TRUE;
+ /* The list of organizers is set to be non-editable. Otherwise any
+ * change in the displayed list causes an 'Account not found' error.
+ */
+ gtk_editable_set_editable (GTK_EDITABLE (GTK_COMBO (priv->org_combo)->entry), FALSE);
gtk_text_view_set_editable (GTK_TEXT_VIEW (priv->memo_content), sensitize);
gtk_widget_set_sensitive (priv->start_date, sensitize);
@@ -310,8 +322,6 @@ sensitize_widgets (MemoPage *mpage)
gtk_editable_set_editable (GTK_EDITABLE (priv->summary_entry), sensitize);
if (COMP_EDITOR_PAGE (mpage)->flags & COMP_EDITOR_IS_SHARED) {
- gtk_editable_set_editable (GTK_EDITABLE (GTK_COMBO (priv->org_combo)->entry), sensitize);
-
if (priv->to_entry) {
gtk_editable_set_editable (GTK_EDITABLE (priv->to_entry), !read_only);
gtk_widget_grab_focus (priv->to_entry);
@@ -420,7 +430,7 @@ memo_page_fill_widgets (CompEditorPage *page, ECalComponent *comp)
else
string = g_strdup (strip);
- if (itip_organizer_is_user (comp, page->client)) {
+ if (itip_organizer_is_user (comp, page->client) || itip_sentby_is_user (comp)) {
} else {
list = g_list_append (list, string);
gtk_combo_set_popdown_strings (GTK_COMBO (priv->org_combo), list);
@@ -575,7 +585,7 @@ get_current_account (MemoPage *page)
EAccount *a = (EAccount *)e_iterator_get(it);
char *full = g_strdup_printf("%s <%s>", a->id->name, a->id->address);
- if (!strcmp (full, str)) {
+ if (!g_ascii_strcasecmp (full, str)) {
g_free (full);
g_object_unref (it);
@@ -707,7 +717,12 @@ memo_page_fill_component (CompEditorPage *page, ECalComponent *comp)
ECalComponentOrganizer organizer = {NULL, NULL, NULL, NULL};
EAccount *a;
- gchar *addr = NULL;
+ gchar *backend_addr = NULL, *org_addr = NULL, *sentby = NULL;
+
+ e_cal_get_cal_address (page->client, &backend_addr, NULL);
+
+ /* Organizer strings */
+ memo_page_select_organizer (mpage, backend_addr);
/* Find the identity for the organizer or sentby field */
a = get_current_account (mpage);
@@ -725,16 +740,25 @@ memo_page_fill_component (CompEditorPage *page, ECalComponent *comp)
return FALSE;
}
- addr = g_strdup_printf ("MAILTO:%s", a->id->address);
+ if (!backend_addr || !g_ascii_strcasecmp (backend_addr, a->id->address)) {
+ org_addr = g_strdup_printf ("MAILTO:%s", a->id->address);
+ organizer.value = org_addr;
+ organizer.cn = a->id->name;
+ } else {
+ org_addr = g_strdup_printf ("MAILTO:%s", backend_addr);
+ sentby = g_strdup_printf ("MAILTO:%s", a->id->address);
+ organizer.value = org_addr;
+ organizer.sentby = sentby;
+ };
- organizer.value = addr;
- organizer.cn = a->id->name;
e_cal_component_set_organizer (comp, &organizer);
if (page->flags & COMP_EDITOR_PAGE_NEW_ITEM)
comp_editor_page_notify_needs_send (page);
- g_free (addr);
+ g_free (backend_addr);
+ g_free (org_addr);
+ g_free (sentby);
}
return TRUE;
@@ -752,6 +776,23 @@ memo_page_set_show_categories (MemoPage *page, gboolean state)
}
}
+/*If the msg has some value set, the icon should always be set */
+void
+memo_page_set_info_string (MemoPage *mpage, const gchar *icon, const gchar *msg)
+{
+ MemoPagePrivate *priv;
+
+ priv = mpage->priv;
+
+ gtk_image_set_from_stock (GTK_IMAGE (priv->info_icon), icon, GTK_ICON_SIZE_BUTTON);
+ gtk_label_set_text (GTK_LABEL(priv->info_string), msg);
+
+ if (msg && icon)
+ gtk_widget_show (priv->info_hbox);
+ else
+ gtk_widget_hide (priv->info_hbox);
+}
+
/* Gets the widgets from the XML file and returns if they are all available. */
static gboolean
get_widgets (MemoPage *mpage)
@@ -781,6 +822,10 @@ get_widgets (MemoPage *mpage)
g_object_ref (priv->main);
gtk_container_remove (GTK_CONTAINER (priv->main->parent), priv->main);
+ priv->info_hbox = GW ("generic-info");
+ priv->info_icon = GW ("generic-info-image");
+ priv->info_string = GW ("generic-info-msgs");
+
priv->org_label = GW ("org-label");
priv->org_combo = GW ("org-combo");
@@ -871,6 +916,17 @@ source_changed_cb (GtkWidget *widget, ESource *source, gpointer data)
comp_editor_notify_client_changed (
COMP_EDITOR (gtk_widget_get_toplevel (priv->main)),
client);
+
+ if (client) {
+ gchar *backend_addr = NULL;
+
+ e_cal_get_cal_address(client, &backend_addr, NULL);
+ if (backend_addr) {
+ memo_page_select_organizer (mpage, backend_addr);
+ g_free (backend_addr);
+ }
+ }
+
sensitize_widgets (mpage);
}
}
@@ -946,6 +1002,9 @@ init_widgets (MemoPage *mpage)
priv = mpage->priv;
+ /* Generic informative messages */
+ gtk_widget_hide (priv->info_hbox);
+
/* Summary */
g_signal_connect((priv->summary_entry), "changed",
G_CALLBACK (summary_changed_cb), mpage);
@@ -1020,6 +1079,69 @@ get_to_entry (ENameSelector *name_selector)
return GTK_WIDGET (name_selector_entry);
}
+static void
+memo_page_select_organizer (MemoPage *mpage, const char *backend_address)
+{
+ MemoPagePrivate *priv;
+ EIterator *it;
+ EAccount *def_account;
+ EAccount *a;
+ gboolean subscribed_cal = FALSE;
+ ESource *source = NULL;
+ const char *user_addr = NULL;
+
+ memo_page_set_info_string (mpage, NULL, NULL);
+
+ priv = mpage->priv;
+ if (COMP_EDITOR_PAGE (mpage)->client)
+ source = e_cal_get_source (COMP_EDITOR_PAGE (mpage)->client);
+ if (source)
+ user_addr = e_source_get_property (source, "subscriber");
+
+ if (user_addr)
+ subscribed_cal = TRUE;
+ else
+ user_addr = backend_address;
+
+ def_account = itip_addresses_get_default();
+ for (it = e_list_get_iterator((EList *)priv->accounts);
+ e_iterator_is_valid(it);
+ e_iterator_next(it)) {
+ gchar *full = NULL;
+
+ a = (EAccount *)e_iterator_get(it);
+ full = g_strdup_printf("%s <%s>", a->id->name, a->id->address);
+
+ /* Note that the address specified by the backend gets
+ * precedence over the default mail address.
+ */
+ if (user_addr && !g_ascii_strcasecmp (user_addr, a->id->address)) {
+ if (priv->default_address)
+ g_free (priv->default_address);
+
+ priv->default_address = full;
+ } else if (a == def_account && !priv->default_address)
+ priv->default_address = full;
+ }
+ g_object_unref(it);
+
+ if (priv->default_address) {
+ if (COMP_EDITOR_PAGE (mpage)->flags & COMP_EDITOR_PAGE_NEW_ITEM) {
+ gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (priv->org_combo)->entry), priv->default_address);
+ /* FIXME: Use accessor functions to access private members of a GtkCombo widget */
+ gtk_widget_set_sensitive (GTK_WIDGET (GTK_COMBO (priv->org_combo)->button), TRUE);
+ }
+ if (subscribed_cal) {
+ /* Translators: This string is used when we are creating a Memo
+ on behalf of some other user */
+ memo_page_set_info_string (mpage, GTK_STOCK_DIALOG_INFO,
+ g_strdup_printf(_("You are acting on behalf of %s"), backend_address));
+ /* FIXME: Use accessor functions to access private members of a GtkCombo widget */
+ gtk_widget_set_sensitive (GTK_WIDGET (GTK_COMBO (priv->org_combo)->button), FALSE);
+ }
+ } else
+ g_warning ("No potential organizers!");
+}
/**
* memo_page_construct:
@@ -1041,6 +1163,7 @@ memo_page_construct (MemoPage *mpage)
EAccount *def_account;
EAccount *a;
CompEditorPageFlags flags = COMP_EDITOR_PAGE (mpage)->flags;
+ ECal *client = COMP_EDITOR_PAGE (mpage)->client;
priv = mpage->priv;
@@ -1062,32 +1185,26 @@ memo_page_construct (MemoPage *mpage)
return NULL;
}
+ /* Address information */
+ if (client && !e_cal_get_cal_address (client, &backend_address, NULL))
+ return NULL;
+
if (flags & COMP_EDITOR_PAGE_IS_SHARED) {
priv->accounts = itip_addresses_get ();
def_account = itip_addresses_get_default();
for (it = e_list_get_iterator((EList *)priv->accounts);
e_iterator_is_valid(it);
e_iterator_next(it)) {
- char *full;
+ gchar *full = NULL;
a = (EAccount *)e_iterator_get(it);
full = g_strdup_printf("%s <%s>", a->id->name, a->id->address);
address_strings = g_list_append(address_strings, full);
-
- /* Note that the address specified by the backend gets
- * precedence over the default mail address.
- */
- if (backend_address && !strcmp (backend_address, a->id->address)) {
- if (priv->default_address)
- g_free (priv->default_address);
-
- priv->default_address = g_strdup (full);
- } else if (a == def_account && !priv->default_address) {
- priv->default_address = g_strdup (full);
- }
}
+ memo_page_select_organizer (mpage, backend_address);
+
if (backend_address)
g_free (backend_address);