From b65e8f416c4f36d5ba3273e8ae8acac2436dfd06 Mon Sep 17 00:00:00 2001 From: Chenthill Palanisamy Date: Sat, 28 Jul 2007 21:51:31 +0000 Subject: Fixes #268162. svn path=/trunk/; revision=33877 --- plugins/calendar-http/ChangeLog | 11 ++++ plugins/calendar-http/calendar-http.c | 69 ++++++++++++++++++++++ .../org-gnome-calendar-http.eplug.xml | 4 ++ 3 files changed, 84 insertions(+) diff --git a/plugins/calendar-http/ChangeLog b/plugins/calendar-http/ChangeLog index 16968f8182..839d2ca8fb 100644 --- a/plugins/calendar-http/ChangeLog +++ b/plugins/calendar-http/ChangeLog @@ -1,3 +1,14 @@ +2007-07-25 Milan Crha + + ** Fix for bug #268162 + + * org-gnome-calendar-http.eplug.xml: + Added new entry for username. + * calendar-http.c: (e_calendar_http_auth): + Creates and setup entry for username. + * calendar-http.c: (username_changed): + New callback when user changes username entry content. + 2007-03-20 Matthew Barnes ** Fixes part of bug #419524 diff --git a/plugins/calendar-http/calendar-http.c b/plugins/calendar-http/calendar-http.c index 755f13db2d..a8016e4dc2 100644 --- a/plugins/calendar-http/calendar-http.c +++ b/plugins/calendar-http/calendar-http.c @@ -40,6 +40,8 @@ GtkWidget *e_calendar_http_url (EPlugin *epl, EConfigHookItemFactoryData *data); GtkWidget *e_calendar_http_refresh (EPlugin *epl, EConfigHookItemFactoryData *data); gboolean e_calendar_http_check (EPlugin *epl, EConfigHookPageCheckData *data); GtkWidget * e_calendar_http_secure (EPlugin *epl, EConfigHookItemFactoryData *data); +GtkWidget *e_calendar_http_auth (EPlugin *epl, EConfigHookItemFactoryData *data); + static gchar * print_uri_noproto (EUri *uri) { @@ -352,6 +354,73 @@ e_calendar_http_secure (EPlugin *epl, EConfigHookItemFactoryData *data) return secure_setting; } +static void +username_changed (GtkEntry *entry, ESource *source) +{ + const gchar *username; + + username = gtk_entry_get_text (GTK_ENTRY (entry)); + + if (username && username[0]) { + e_source_set_property (source, "auth", "1"); + e_source_set_property (source, "username", username); + } else { + e_source_set_property (source, "auth", NULL); + e_source_set_property (source, "username", NULL); + } +} + +GtkWidget * +e_calendar_http_auth (EPlugin *epl, EConfigHookItemFactoryData *data) +{ + static GtkWidget *label; + GtkWidget *entry, *parent; + int row; + ECalConfigTargetSource *t = (ECalConfigTargetSource *) data->target; + ESource *source = t->source; + EUri *uri; + char* uri_text; + static GtkWidget *hidden = NULL; + + if (!hidden) + hidden = gtk_label_new (""); + + if (data->old) + gtk_widget_destroy (label); + + uri_text = e_source_get_uri (t->source); + uri = e_uri_new (uri_text); + g_free (uri_text); + if ((strcmp (uri->protocol, "http") && + strcmp (uri->protocol, "https") && + strcmp (uri->protocol, "webcal"))) { + e_uri_free (uri); + return hidden; + } + e_uri_free (uri); + + parent = data->parent; + + row = ((GtkTable*)parent)->nrows; + + label = gtk_label_new_with_mnemonic (_("Userna_me:")); + gtk_widget_show (label); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0); + gtk_table_attach (GTK_TABLE (parent), label, 0, 1, row, row+1, GTK_FILL, GTK_SHRINK, 0, 0); + + uri_text = e_source_get_property (t->source, "username"); + + entry = gtk_entry_new (); + gtk_widget_show (entry); + gtk_entry_set_text (GTK_ENTRY (entry), uri_text ? uri_text : ""); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry); + g_signal_connect (G_OBJECT (entry), "changed", G_CALLBACK (username_changed), t->source); + + gtk_table_attach (GTK_TABLE (parent), entry, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0); + + return entry; +} + gboolean e_calendar_http_check (EPlugin *epl, EConfigHookPageCheckData *data) { diff --git a/plugins/calendar-http/org-gnome-calendar-http.eplug.xml b/plugins/calendar-http/org-gnome-calendar-http.eplug.xml index 0d7e45b836..3d4f885aec 100644 --- a/plugins/calendar-http/org-gnome-calendar-http.eplug.xml +++ b/plugins/calendar-http/org-gnome-calendar-http.eplug.xml @@ -20,6 +20,10 @@ type="item_table" path="00.general/00.source/50.secure" factory="e_calendar_http_secure"/> +