aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--calendar/ChangeLog17
-rw-r--r--calendar/gui/dialogs/event-page.c89
-rw-r--r--calendar/gui/dialogs/memo-page.c129
-rw-r--r--calendar/gui/dialogs/task-page.c123
4 files changed, 159 insertions, 199 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 2b46cba108..78014243c0 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,20 @@
+2007-09-09 Suman Manjunath <msuman@novell.com>
+
+ * gui/dialogs/event-page.c: (event_page_init),
+ (event_page_finalize), (clear_widgets),
+ (event_page_fill_component), (source_changed_cb),
+ (event_page_select_organizer), (event_page_construct):
+ * gui/dialogs/memo-page.c: (memo_page_init), (memo_page_finalize),
+ (clear_widgets), (memo_page_fill_widgets),
+ (memo_page_fill_component), (source_changed_cb),
+ (set_subscriber_info_string), (memo_page_select_organizer),
+ (memo_page_construct):
+ * gui/dialogs/task-page.c: (task_page_init), (task_page_finalize),
+ (clear_widgets), (task_page_fill_widgets),
+ (task_page_fill_component), (task_page_set_info_string),
+ (source_changed_cb), (set_subscriber_info_string),
+ (task_page_select_organizer), (task_page_construct): code cleanup.
+
2007-09-07 Gilles Dartiguelongue <gdartigu@svn.gnome.org>
* gui/e-itip-control.c: (insert_boxes), (insert_ok):
diff --git a/calendar/gui/dialogs/event-page.c b/calendar/gui/dialogs/event-page.c
index 6f760ba096..44ea244dce 100644
--- a/calendar/gui/dialogs/event-page.c
+++ b/calendar/gui/dialogs/event-page.c
@@ -81,6 +81,7 @@ struct _EventPagePrivate {
GtkWidget *location_label;
EAccountList *accounts;
+ GList *address_strings;
EMeetingAttendee *ia;
char *default_address;
char *user_add;
@@ -253,6 +254,7 @@ event_page_init (EventPage *epage)
priv->comp = NULL;
priv->accounts = NULL;
+ priv->address_strings = NULL;
priv->ia = NULL;
priv->default_address = NULL;
priv->invite = NULL;
@@ -286,6 +288,7 @@ event_page_finalize (GObject *object)
{
EventPage *epage;
EventPagePrivate *priv;
+ GList *l;
g_return_if_fail (object != NULL);
g_return_if_fail (IS_EVENT_PAGE (object));
@@ -293,6 +296,10 @@ event_page_finalize (GObject *object)
epage = EVENT_PAGE (object);
priv = epage->priv;
+ for (l = priv->address_strings; l != NULL; l = l->next)
+ g_free (l->data);
+ g_list_free (priv->address_strings);
+
if (priv->comp != NULL)
g_object_unref (priv->comp);
@@ -320,9 +327,6 @@ event_page_finalize (GObject *object)
priv->alarm_list_dlg_widget = NULL;
- g_free (priv->default_address);
- priv->default_address = NULL;
-
g_free (priv);
epage->priv = NULL;
@@ -589,9 +593,6 @@ clear_widgets (EventPage *epage)
/* Categories */
e_dialog_editable_set (priv->categories, NULL);
-
- if (priv->default_address)
- gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (priv->organizer)->entry), priv->default_address);
}
static gboolean
@@ -1501,13 +1502,10 @@ event_page_fill_component (CompEditorPage *page, ECalComponent *comp)
if (!priv->existing) {
EAccount *a;
- gchar *backend_addr, *org_addr = NULL, *sentby = NULL;
+ gchar *backend_addr = NULL, *org_addr = NULL, *sentby = NULL;
e_cal_get_cal_address (priv->client, &backend_addr, NULL);
- /* FIXME need not set Organizer strings here */
- event_page_select_organizer (epage, backend_addr);
-
/* Find the identity for the organizer or sentby field */
a = get_current_account (epage);
@@ -1524,7 +1522,7 @@ event_page_fill_component (CompEditorPage *page, ECalComponent *comp)
return FALSE;
}
- if (!backend_addr || !g_ascii_strcasecmp (backend_addr, a->id->address)) {
+ if (!(backend_addr && *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;
@@ -2741,14 +2739,10 @@ source_changed_cb (GtkWidget *widget, ESource *source, gpointer data)
e_cal_get_cal_address(client, &backend_addr, NULL);
- if (backend_addr && *backend_addr) {
-
- if (priv->is_meeting)
- event_page_select_organizer (epage, backend_addr);
-
- set_subscriber_info_string (epage, backend_addr);
- }
+ if (backend_addr && priv->is_meeting)
+ event_page_select_organizer (epage, backend_addr);
+ set_subscriber_info_string (epage, backend_addr);
g_free (backend_addr);
}
@@ -2759,7 +2753,6 @@ source_changed_cb (GtkWidget *widget, ESource *source, gpointer data)
}
}
-
static void
set_subscriber_info_string (EventPage *epage, const char *backend_address)
{
@@ -3152,13 +3145,17 @@ static void
event_page_select_organizer (EventPage *epage, const char *backend_address)
{
EventPagePrivate *priv;
- EIterator *it;
+ GList *l;
EAccount *def_account;
- EAccount *a;
+ const char *def_address;
gboolean subscribed_cal = FALSE;
ESource *source = NULL;
const char *user_addr = NULL;
+ def_account = itip_addresses_get_default();
+ if (def_account)
+ def_address = g_strdup_printf("%s <%s>", def_account->id->name, def_account->id->address);
+
priv = epage->priv;
if (COMP_EDITOR_PAGE (epage)->client)
source = e_cal_get_source (COMP_EDITOR_PAGE (epage)->client);
@@ -3170,40 +3167,22 @@ event_page_select_organizer (EventPage *epage, const char *backend_address)
else
user_addr = backend_address;
- /*FIXME find the organizer using the address strings which is set in org combo box */
- 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);
+ priv->default_address = NULL;
+ for (l = priv->address_strings; l != NULL; l = l->next)
+ if (g_strrstr ((gchar *) l->data, user_addr) != NULL) {
+ priv->default_address = (gchar *) l->data;
+ break;
+ }
- /* 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;
- else
- g_free (full);
- }
- g_object_unref(it);
+ if (!priv->default_address && def_account)
+ priv->default_address = def_address;
if (priv->default_address) {
if (!priv->comp || !e_cal_component_has_organizer (priv->comp)) {
gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (priv->organizer)->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->organizer)->button), TRUE);
+ gtk_widget_set_sensitive (GTK_WIDGET (GTK_COMBO (priv->organizer)->button), !subscribed_cal);
}
- if (subscribed_cal)
- /* FIXME: Use accessor functions to access private members of a GtkCombo widget */
- gtk_widget_set_sensitive (GTK_WIDGET (GTK_COMBO (priv->organizer)->button), FALSE);
} else
g_warning ("No potential organizers!");
}
@@ -3222,8 +3201,6 @@ event_page_construct (EventPage *epage, EMeetingStore *model, ECal *client)
{
EventPagePrivate *priv;
EIterator *it;
- EAccount *def_account;
- GList *address_strings = NULL, *l;
EAccount *a;
char *gladefile;
@@ -3251,7 +3228,6 @@ event_page_construct (EventPage *epage, EMeetingStore *model, ECal *client)
}
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)) {
@@ -3260,21 +3236,16 @@ event_page_construct (EventPage *epage, EMeetingStore *model, ECal *client)
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);
+ priv->address_strings = g_list_append(priv->address_strings, full);
}
g_object_unref(it);
- if (address_strings)
- gtk_combo_set_popdown_strings (GTK_COMBO (priv->organizer), address_strings);
+ if (priv->address_strings)
+ gtk_combo_set_popdown_strings (GTK_COMBO (priv->organizer), priv->address_strings);
else
g_warning ("No potential organizers!");
- for (l = address_strings; l != NULL; l = l->next)
- g_free (l->data);
- g_list_free (address_strings);
-
-
if (!init_widgets (epage)) {
g_message ("event_page_construct(): "
"Could not initialize the widgets!");
diff --git a/calendar/gui/dialogs/memo-page.c b/calendar/gui/dialogs/memo-page.c
index 88fd418ad6..ac94a0ccf8 100644
--- a/calendar/gui/dialogs/memo-page.c
+++ b/calendar/gui/dialogs/memo-page.c
@@ -97,6 +97,7 @@ struct _MemoPagePrivate {
GtkWidget *source_selector;
+ GList *address_strings;
char *default_address;
ENameSelector *name_selector;
@@ -120,6 +121,7 @@ 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);
+static void set_subscriber_info_string (MemoPage *mpage, const char *backend_address);
G_DEFINE_TYPE (MemoPage, memo_page, TYPE_COMP_EDITOR_PAGE)
@@ -174,6 +176,9 @@ memo_page_init (MemoPage *mpage)
priv->info_string = NULL;
priv->updating = FALSE;
+
+ priv->address_strings = NULL;
+ priv->default_address = NULL;
}
/* Destroy handler for the memo page */
@@ -182,6 +187,7 @@ memo_page_finalize (GObject *object)
{
MemoPage *mpage;
MemoPagePrivate *priv;
+ GList *l;
g_return_if_fail (object != NULL);
g_return_if_fail (IS_MEMO_PAGE (object));
@@ -189,6 +195,10 @@ memo_page_finalize (GObject *object)
mpage = MEMO_PAGE (object);
priv = mpage->priv;
+ for (l = priv->address_strings; l != NULL; l = l->next)
+ g_free (l->data);
+ g_list_free (priv->address_strings);
+
if (priv->main)
g_object_unref (priv->main);
@@ -197,11 +207,6 @@ memo_page_finalize (GObject *object)
priv->xml = NULL;
}
- if (priv->default_address) {
- g_free (priv->default_address);
- priv->default_address = NULL;
- }
-
g_free (priv);
mpage->priv = NULL;
@@ -279,9 +284,6 @@ clear_widgets (MemoPage *mpage)
/* Categories */
e_dialog_editable_set (priv->categories, NULL);
-
- if (priv->default_address)
- gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (priv->org_combo)->entry), priv->default_address);
}
void
@@ -349,6 +351,7 @@ memo_page_fill_widgets (CompEditorPage *page, ECalComponent *comp)
ECalComponentDateTime d;
GSList *l;
const char *categories;
+ gchar *backend_addr = NULL;
ESource *source;
mpage = MEMO_PAGE (page);
@@ -416,6 +419,9 @@ memo_page_fill_widgets (CompEditorPage *page, ECalComponent *comp)
e_cal_component_get_categories (comp, &categories);
e_dialog_editable_set (priv->categories, categories);
+ e_cal_get_cal_address (COMP_EDITOR_PAGE (mpage)->client, &backend_addr, NULL);
+ set_subscriber_info_string (mpage, backend_addr);
+
if (e_cal_component_has_organizer (comp)) {
ECalComponentOrganizer organizer;
@@ -441,6 +447,9 @@ memo_page_fill_widgets (CompEditorPage *page, ECalComponent *comp)
}
}
+ if (backend_addr)
+ g_free (backend_addr);
+
/* Source */
source = e_cal_get_source (page->client);
e_source_option_menu_select (E_SOURCE_OPTION_MENU (priv->source_selector), source);
@@ -723,9 +732,6 @@ memo_page_fill_component (CompEditorPage *page, ECalComponent *comp)
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);
@@ -742,7 +748,7 @@ memo_page_fill_component (CompEditorPage *page, ECalComponent *comp)
return FALSE;
}
- if (!backend_addr || !g_ascii_strcasecmp (backend_addr, a->id->address)) {
+ if (!(backend_addr && *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;
@@ -751,7 +757,7 @@ memo_page_fill_component (CompEditorPage *page, ECalComponent *comp)
sentby = g_strdup_printf ("MAILTO:%s", a->id->address);
organizer.value = org_addr;
organizer.sentby = sentby;
- };
+ }
e_cal_component_set_organizer (comp, &organizer);
@@ -923,10 +929,12 @@ source_changed_cb (GtkWidget *widget, ESource *source, gpointer data)
gchar *backend_addr = NULL;
e_cal_get_cal_address(client, &backend_addr, NULL);
- if (backend_addr) {
+
+ if (backend_addr && (COMP_EDITOR_PAGE (mpage)->flags & COMP_EDITOR_PAGE_IS_SHARED))
memo_page_select_organizer (mpage, backend_addr);
- g_free (backend_addr);
- }
+
+ set_subscriber_info_string (mpage, backend_addr);
+ g_free (backend_addr);
}
sensitize_widgets (mpage);
@@ -934,6 +942,23 @@ source_changed_cb (GtkWidget *widget, ESource *source, gpointer data)
}
}
+static void
+set_subscriber_info_string (MemoPage *mpage, const char *backend_address)
+{
+ ECal *client = COMP_EDITOR_PAGE (mpage)->client;
+ ESource *source;
+
+ source = e_cal_get_source (client);
+
+ if (e_source_get_property (source, "subscriber"))
+ /* 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));
+ else
+ memo_page_set_info_string (mpage, NULL, NULL);
+}
+
/*sets the current focused widget */
static gboolean
widget_focus_in_cb (GtkWidget *widget, GdkEventFocus *event, gpointer data)
@@ -1085,14 +1110,16 @@ static void
memo_page_select_organizer (MemoPage *mpage, const char *backend_address)
{
MemoPagePrivate *priv;
- EIterator *it;
+ GList *l;
EAccount *def_account;
- EAccount *a;
+ const char *def_address;
gboolean subscribed_cal = FALSE;
ESource *source = NULL;
const char *user_addr = NULL;
- memo_page_set_info_string (mpage, NULL, NULL);
+ def_account = itip_addresses_get_default();
+ if (def_account)
+ def_address = g_strdup_printf("%s <%s>", def_account->id->name, def_account->id->address);
priv = mpage->priv;
if (COMP_EDITOR_PAGE (mpage)->client)
@@ -1105,41 +1132,21 @@ memo_page_select_organizer (MemoPage *mpage, const char *backend_address)
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);
+ priv->default_address = NULL;
+ for (l = priv->address_strings; l != NULL; l = l->next)
+ if (g_strrstr ((gchar *) l->data, user_addr) != NULL) {
+ priv->default_address = (gchar *) l->data;
+ break;
+ }
+
+ if (!priv->default_address && def_account)
+ priv->default_address = def_address;
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);
+ gtk_widget_set_sensitive (GTK_WIDGET (GTK_COMBO (priv->org_combo)->button), !subscribed_cal);
}
} else
g_warning ("No potential organizers!");
@@ -1158,14 +1165,10 @@ MemoPage *
memo_page_construct (MemoPage *mpage)
{
MemoPagePrivate *priv;
- char *backend_address = NULL;
EIterator *it;
char *gladefile;
- GList *address_strings = NULL, *l;
- EAccount *def_account;
EAccount *a;
CompEditorPageFlags flags = COMP_EDITOR_PAGE (mpage)->flags;
- ECal *client = COMP_EDITOR_PAGE (mpage)->client;
priv = mpage->priv;
@@ -1187,13 +1190,8 @@ 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)) {
@@ -1202,25 +1200,16 @@ memo_page_construct (MemoPage *mpage)
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);
+ priv->address_strings = g_list_append(priv->address_strings, full);
}
- memo_page_select_organizer (mpage, backend_address);
-
- if (backend_address)
- g_free (backend_address);
-
g_object_unref(it);
- if (address_strings)
- gtk_combo_set_popdown_strings (GTK_COMBO (priv->org_combo), address_strings);
+ if (priv->address_strings)
+ gtk_combo_set_popdown_strings (GTK_COMBO (priv->org_combo), priv->address_strings);
else
g_warning ("No potential organizers!");
- for (l = address_strings; l != NULL; l = l->next)
- g_free (l->data);
- g_list_free (address_strings);
-
gtk_widget_show (priv->org_label);
gtk_widget_show (priv->org_combo);
diff --git a/calendar/gui/dialogs/task-page.c b/calendar/gui/dialogs/task-page.c
index 90596973fc..ef63889a93 100644
--- a/calendar/gui/dialogs/task-page.c
+++ b/calendar/gui/dialogs/task-page.c
@@ -68,6 +68,7 @@ struct _TaskPagePrivate {
GtkWidget *main;
EAccountList *accounts;
+ GList *address_strings;
EMeetingAttendee *ia;
char *default_address;
char *user_add;
@@ -149,6 +150,7 @@ static gboolean task_page_fill_timezones (CompEditorPage *page, GHashTable *time
static void task_page_set_summary (CompEditorPage *page, const char *summary);
static void task_page_set_dates (CompEditorPage *page, CompEditorPageDates *dates);
static void task_page_select_organizer (TaskPage *tpage, const char *backend_address);
+static void set_subscriber_info_string (TaskPage *tpage, const char *backend_address);
G_DEFINE_TYPE (TaskPage, task_page, TYPE_COMP_EDITOR_PAGE)
@@ -211,13 +213,13 @@ task_page_init (TaskPage *tpage)
priv->comp = NULL;
priv->accounts = NULL;
+ priv->address_strings = NULL;
priv->ia = NULL;
priv->default_address = NULL;
priv->invite = NULL;
priv->model = NULL;
priv->list_view = NULL;
- priv->default_address = NULL;
}
static void
@@ -235,6 +237,7 @@ task_page_finalize (GObject *object)
{
TaskPage *tpage;
TaskPagePrivate *priv;
+ GList *l;
g_return_if_fail (object != NULL);
g_return_if_fail (IS_TASK_PAGE (object));
@@ -242,6 +245,10 @@ task_page_finalize (GObject *object)
tpage = TASK_PAGE (object);
priv = tpage->priv;
+ for (l = priv->address_strings; l != NULL; l = l->next)
+ g_free (l->data);
+ g_list_free (priv->address_strings);
+
if (priv->main)
g_object_unref (priv->main);
@@ -342,9 +349,6 @@ clear_widgets (TaskPage *tpage)
/* Categories */
e_dialog_editable_set (priv->categories, NULL);
-
- gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (priv->organizer)->entry), priv->default_address);
-
}
void
@@ -528,6 +532,7 @@ task_page_fill_widgets (CompEditorPage *page, ECalComponent *comp)
icalcomponent *icalcomp;
const char *categories, *uid;
icaltimezone *zone, *default_zone;
+ gchar *backend_addr = NULL;
ESource *source;
tpage = TASK_PAGE (page);
@@ -675,14 +680,15 @@ task_page_fill_widgets (CompEditorPage *page, ECalComponent *comp)
source = e_cal_get_source (page->client);
e_source_option_menu_select (E_SOURCE_OPTION_MENU (priv->source_selector), source);
+ e_cal_get_cal_address (COMP_EDITOR_PAGE (tpage)->client, &backend_addr, NULL);
+ set_subscriber_info_string (tpage, backend_addr);
+
if (priv->is_assignment) {
ECalComponentOrganizer organizer;
- gchar *backend_addr = NULL;
priv->user_add = itip_get_comp_attendee (comp, COMP_EDITOR_PAGE (tpage)->client);
/* Organizer strings */
- e_cal_get_cal_address (COMP_EDITOR_PAGE (tpage)->client, &backend_addr, NULL);
task_page_select_organizer (tpage, backend_addr);
/* If there is an existing organizer show it properly */
@@ -742,12 +748,12 @@ task_page_fill_widgets (CompEditorPage *page, ECalComponent *comp)
e_meeting_attendee_set_status (priv->ia, ICAL_PARTSTAT_ACCEPTED);
e_meeting_list_view_add_attendee_to_name_selector (E_MEETING_LIST_VIEW (priv->list_view), priv->ia);
}
-
}
- if (backend_addr)
- g_free (backend_addr);
}
+ if (backend_addr)
+ g_free (backend_addr);
+
priv->updating = FALSE;
sensitize_widgets (tpage);
@@ -928,9 +934,6 @@ task_page_fill_component (CompEditorPage *page, ECalComponent *comp)
e_cal_get_cal_address (page->client, &backend_addr, NULL);
- /* FIXME need not set organizer strings here */
- task_page_select_organizer (tpage, backend_addr);
-
/* Find the identity for the organizer or sentby field */
a = get_current_account (tpage);
@@ -947,7 +950,7 @@ task_page_fill_component (CompEditorPage *page, ECalComponent *comp)
return FALSE;
}
- if (!backend_addr || !g_ascii_strcasecmp (backend_addr, a->id->address)) {
+ if (!(backend_addr && *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;
@@ -1412,8 +1415,7 @@ task_page_set_info_string (TaskPage *tpage, const gchar *icon, const gchar *msg)
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
@@ -1735,9 +1737,10 @@ source_changed_cb (GtkWidget *widget, ESource *source, gpointer data)
e_cal_get_cal_address(client, &backend_addr, NULL);
- if (backend_addr && *backend_addr)
+ if (backend_addr && priv->is_assignment)
task_page_select_organizer (tpage, backend_addr);
+ set_subscriber_info_string (tpage, backend_addr);
g_free (backend_addr);
}
@@ -1746,6 +1749,23 @@ source_changed_cb (GtkWidget *widget, ESource *source, gpointer data)
}
}
+static void
+set_subscriber_info_string (TaskPage *tpage, const char *backend_address)
+{
+ ECal *client = COMP_EDITOR_PAGE (tpage)->client;
+ ESource *source;
+
+ source = e_cal_get_source (client);
+
+ if (e_source_get_property (source, "subscriber"))
+ /* Translators: This string is used when we are creating a Task
+ on behalf of some other user */
+ task_page_set_info_string (tpage, GTK_STOCK_DIALOG_INFO,
+ g_strdup_printf(_("You are acting on behalf of %s"), backend_address));
+ else
+ task_page_set_info_string (tpage, NULL, NULL);
+}
+
void
task_page_sendoptions_clicked_cb (TaskPage *tpage)
{
@@ -1891,14 +1911,16 @@ static void
task_page_select_organizer (TaskPage *tpage, const char *backend_address)
{
TaskPagePrivate *priv;
- EIterator *it;
+ GList *l;
EAccount *def_account;
- EAccount *a;
+ const char *def_address;
gboolean subscribed_cal = FALSE;
ESource *source = NULL;
const char *user_addr = NULL;
- task_page_set_info_string (tpage, NULL, NULL);
+ def_account = itip_addresses_get_default();
+ if (def_account)
+ def_address = g_strdup_printf("%s <%s>", def_account->id->name, def_account->id->address);
priv = tpage->priv;
if (COMP_EDITOR_PAGE (tpage)->client)
@@ -1911,43 +1933,21 @@ task_page_select_organizer (TaskPage *tpage, const char *backend_address)
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 = NULL;
+ for (l = priv->address_strings; l != NULL; l = l->next)
+ if (g_strrstr ((gchar *) l->data, user_addr) != NULL) {
+ priv->default_address = (gchar *) l->data;
+ break;
+ }
- priv->default_address = full;
- } else if (a == def_account && !priv->default_address)
- priv->default_address = full;
- }
- g_object_unref(it);
+ if (!priv->default_address && def_account)
+ priv->default_address = def_address;
if (priv->default_address) {
if (!priv->comp || !e_cal_component_has_organizer (priv->comp)) {
gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (priv->organizer)->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->organizer)->button), TRUE);
- }
-
- /*FIXME do not set the info string here */
- if (subscribed_cal) {
- /* Translators: This string is used when we are creating a Task
- on behalf of some other user */
- task_page_set_info_string (tpage, 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->organizer)->button), FALSE);
+ gtk_widget_set_sensitive (GTK_WIDGET (GTK_COMBO (priv->organizer)->button), !subscribed_cal);
}
} else
g_warning ("No potential organizers!");
@@ -1966,10 +1966,7 @@ TaskPage *
task_page_construct (TaskPage *tpage, EMeetingStore *model, ECal *client)
{
TaskPagePrivate *priv;
- char *backend_address = NULL;
EIterator *it;
- EAccount *def_account;
- GList *address_strings = NULL, *l;
EAccount *a;
char *gladefile;
@@ -1995,12 +1992,8 @@ task_page_construct (TaskPage *tpage, EMeetingStore *model, ECal *client)
"Could not find all widgets in the XML file!");
return NULL;
}
- /* Address information */
- if (!e_cal_get_cal_address (client, &backend_address, NULL))
- return NULL;
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)) {
@@ -2009,26 +2002,16 @@ task_page_construct (TaskPage *tpage, EMeetingStore *model, ECal *client)
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);
+ priv->address_strings = g_list_append(priv->address_strings, full);
}
- task_page_select_organizer (tpage, backend_address);
-
- if (backend_address)
- g_free (backend_address);
-
g_object_unref(it);
- if (address_strings)
- gtk_combo_set_popdown_strings (GTK_COMBO (priv->organizer), address_strings);
+ if (priv->address_strings)
+ gtk_combo_set_popdown_strings (GTK_COMBO (priv->organizer), priv->address_strings);
else
g_warning ("No potential organizers!");
- for (l = address_strings; l != NULL; l = l->next)
- g_free (l->data);
- g_list_free (address_strings);
-
-
if (!init_widgets (tpage)) {
g_message ("task_page_construct(): "
"Could not initialize the widgets!");