diff options
author | JP Rosevear <jpr@ximian.com> | 2001-07-07 04:27:31 +0800 |
---|---|---|
committer | JP Rosevear <jpr@src.gnome.org> | 2001-07-07 04:27:31 +0800 |
commit | ea8185e64b61fd8d97ecd8e4745698d4020f2a5f (patch) | |
tree | c1e0b30978bc10b0f26fe4cbfd72560596d243db | |
parent | ff91646452fd4bcddbfc1d6acc5d18c99cf021f6 (diff) | |
download | gsoc2013-evolution-ea8185e64b61fd8d97ecd8e4745698d4020f2a5f.tar gsoc2013-evolution-ea8185e64b61fd8d97ecd8e4745698d4020f2a5f.tar.gz gsoc2013-evolution-ea8185e64b61fd8d97ecd8e4745698d4020f2a5f.tar.bz2 gsoc2013-evolution-ea8185e64b61fd8d97ecd8e4745698d4020f2a5f.tar.lz gsoc2013-evolution-ea8185e64b61fd8d97ecd8e4745698d4020f2a5f.tar.xz gsoc2013-evolution-ea8185e64b61fd8d97ecd8e4745698d4020f2a5f.tar.zst gsoc2013-evolution-ea8185e64b61fd8d97ecd8e4745698d4020f2a5f.zip |
actually clear some widgets and hide/show widgets in the default setup
2001-07-06 JP Rosevear <jpr@ximian.com>
* gui/dialogs/meeting-page.c (clear_widgets): actually clear some
widgets and hide/show widgets in the default setup
(meeting_page_destroy): destroy the address lists
(meeting_page_fill_widgets): allow the user to select among their
identities as a new organizer, or show the existing organizer as
label
(meeting_page_fill_component): set the "MAILTO:" bit of the
organizer to match spec, set CN properly if we know it
(get_widgets): load new widgets
(other_clicked_cb): handle "Other Organizer" click
(change_clicked_cb): handle "Change Organizer" click
(init_widgets): listen for clicks on new buttons
* gui/dialogs/comp-editor.c (comp_editor_remove_page): remove the
page from our internal list and unref it
* gui/itip-utils.c (itip_addresses_get): get the configure mail
identities
(itip_addresses_free): free a list of identities returned by
itip_addresses_get
* gui/itip-utils.h: remove obsolete protos, and new protos
* gui/gnome-cal.html: Remove ancient file
svn path=/trunk/; revision=10856
-rw-r--r-- | calendar/ChangeLog | 27 | ||||
-rw-r--r-- | calendar/gui/dialogs/comp-editor.c | 3 | ||||
-rw-r--r-- | calendar/gui/dialogs/meeting-page.c | 177 | ||||
-rw-r--r-- | calendar/gui/dialogs/meeting-page.glade | 252 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.html | 44 | ||||
-rw-r--r-- | calendar/gui/itip-utils.c | 110 | ||||
-rw-r--r-- | calendar/gui/itip-utils.h | 17 |
7 files changed, 511 insertions, 119 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 73f284ee82..4b6172ee1d 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,30 @@ +2001-07-06 JP Rosevear <jpr@ximian.com> + + * gui/dialogs/meeting-page.c (clear_widgets): actually clear some + widgets and hide/show widgets in the default setup + (meeting_page_destroy): destroy the address lists + (meeting_page_fill_widgets): allow the user to select among their + identities as a new organizer, or show the existing organizer as + label + (meeting_page_fill_component): set the "MAILTO:" bit of the + organizer to match spec, set CN properly if we know it + (get_widgets): load new widgets + (other_clicked_cb): handle "Other Organizer" click + (change_clicked_cb): handle "Change Organizer" click + (init_widgets): listen for clicks on new buttons + + * gui/dialogs/comp-editor.c (comp_editor_remove_page): remove the + page from our internal list and unref it + + * gui/itip-utils.c (itip_addresses_get): get the configure mail + identities + (itip_addresses_free): free a list of identities returned by + itip_addresses_get + + * gui/itip-utils.h: remove obsolete protos, and new protos + + * gui/gnome-cal.html: Remove ancient file + 2001-07-04 Federico Mena Quintero <federico@ximian.com> Fixes bug #4018 and what would be the analogous bugs for the other diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c index 829b536ded..9668e538aa 100644 --- a/calendar/gui/dialogs/comp-editor.c +++ b/calendar/gui/dialogs/comp-editor.c @@ -336,6 +336,9 @@ comp_editor_remove_page (CompEditor *editor, CompEditorPage *page) page_widget = comp_editor_page_get_widget (page); page_num = gtk_notebook_page_num (priv->notebook, page_widget); gtk_notebook_remove_page (priv->notebook, page_num); + + priv->pages = g_list_remove (priv->pages, page); + gtk_object_unref (GTK_OBJECT (page)); } /** diff --git a/calendar/gui/dialogs/meeting-page.c b/calendar/gui/dialogs/meeting-page.c index 9e9e3e96db..2c0dcc9fd5 100644 --- a/calendar/gui/dialogs/meeting-page.c +++ b/calendar/gui/dialogs/meeting-page.c @@ -26,6 +26,9 @@ #include <config.h> #endif +#include <glib.h> +#include <libgnome/gnome-defs.h> +#include <libgnome/gnome-i18n.h> #include <liboaf/liboaf.h> #include <bonobo/bonobo-control.h> #include <bonobo/bonobo-widget.h> @@ -39,10 +42,10 @@ #include <gal/e-table/e-table-scrolled.h> #include <gal/widgets/e-unicode.h> #include <widgets/misc/e-dateedit.h> -#include <widgets/meeting-time-sel/e-meeting-time-sel.h> #include <e-util/e-dialog-widgets.h> -#include <addressbook/gui/component/select-names/Evolution-Addressbook-SelectNames.h> +#include "../Evolution-Addressbook-SelectNames.h" #include "../component-factory.h" +#include "../itip-utils.h" #include "comp-editor-util.h" #include "meeting-page.h" @@ -119,19 +122,36 @@ struct attendee { struct _MeetingPagePrivate { /* List of attendees */ GSList *attendees; + + /* List of identities */ + GList *addresses; + GList *address_strings; + gchar *default_address; /* Glade XML data */ GladeXML *xml; /* Widgets from the Glade file */ GtkWidget *main; + GtkWidget *organizer_table; GtkWidget *organizer; + GtkWidget *organizer_lbl; + GtkWidget *other_organizer; + GtkWidget *other_organizer_lbl; + GtkWidget *other_organizer_btn; + GtkWidget *existing_organizer_table; + GtkWidget *existing_organizer; + GtkWidget *existing_organizer_btn; GtkWidget *invite; /* E Table stuff */ ETableModel *model; GtkWidget *etable; + /* For handling who the organizer is */ + gboolean other; + gboolean existing; + /* For handling the invite button */ GNOME_Evolution_Addressbook_SelectNames corba_select_names; @@ -245,6 +265,9 @@ meeting_page_destroy (GtkObject *object) mpage = MEETING_PAGE (object); priv = mpage->priv; + itip_addresses_free (priv->addresses); + g_list_free (priv->address_strings); + filename = g_strdup_printf ("%s/config/et-header-meeting-page", evolution_dir); real_table = e_table_scrolled_get_table (E_TABLE_SCROLLED (priv->etable)); @@ -298,6 +321,19 @@ clear_widgets (MeetingPage *mpage) MeetingPagePrivate *priv; priv = mpage->priv; + + gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (priv->organizer)->entry), ""); + gtk_entry_set_text (GTK_ENTRY (priv->other_organizer), ""); + gtk_label_set_text (GTK_LABEL (priv->existing_organizer), "None"); + + gtk_widget_show (priv->organizer_table); + gtk_widget_hide (priv->existing_organizer_table); + + gtk_widget_hide (priv->other_organizer_lbl); + gtk_widget_hide (priv->other_organizer); + + priv->existing = FALSE; + priv->other = FALSE; } /* fill_widgets handler for the task page */ @@ -308,6 +344,7 @@ meeting_page_fill_widgets (CompEditorPage *page, CalComponent *comp) MeetingPagePrivate *priv; CalComponentOrganizer organizer; GSList *attendees, *l; + GList *l2; mpage = MEETING_PAGE (page); priv = mpage->priv; @@ -317,9 +354,37 @@ meeting_page_fill_widgets (CompEditorPage *page, CalComponent *comp) /* Clean the screen */ clear_widgets (mpage); + /* Organizer */ cal_component_get_organizer (comp, &organizer); - e_dialog_editable_set (priv->organizer, organizer.value); + priv->addresses = itip_addresses_get (); + for (l2 = priv->addresses; l2 != NULL; l2 = l2->next) { + ItipAddress *a = l2->data; + + priv->address_strings = g_list_append (priv->address_strings, a->full); + if (a->default_address) + priv->default_address = a->full; + } + gtk_combo_set_popdown_strings (GTK_COMBO (priv->organizer), priv->address_strings); + + if (organizer.value != NULL) { + gchar *s = e_utf8_to_gtk_string (priv->existing_organizer, organizer.value); + + gtk_widget_hide (priv->organizer_table); + gtk_widget_show (priv->existing_organizer_table); + gtk_widget_hide (priv->invite); + + gtk_label_set_text (GTK_LABEL (priv->existing_organizer), s); + g_free (s); + + priv->existing = TRUE; + } else { + gtk_widget_hide (priv->other_organizer_lbl); + gtk_widget_hide (priv->other_organizer); + + e_dialog_editable_set (GTK_COMBO (priv->organizer)->entry, priv->default_address); + } + /* Attendees */ cal_component_get_attendee_list (comp, &attendees); for (l = attendees; l != NULL; l = l->next) { CalComponentAttendee *att = l->data; @@ -361,26 +426,53 @@ meeting_page_fill_component (CompEditorPage *page, CalComponent *comp) MeetingPagePrivate *priv; CalComponentOrganizer organizer = {NULL, NULL, NULL, NULL}; GSList *attendees = NULL, *l; - gchar *str; mpage = MEETING_PAGE (page); priv = mpage->priv; - str = e_dialog_editable_get (priv->organizer); - if (str == NULL || strlen (str) == 0) { - if (str != NULL) + if (!priv->existing) { + gchar *addr = NULL, *cn = NULL; + GList *l; + + if (priv->other) { + addr = e_dialog_editable_get (priv->other_organizer); + } else { + gchar *str = e_dialog_editable_get (GTK_COMBO (priv->organizer)->entry); + for (l = priv->addresses; l != NULL; l = l->next) { + ItipAddress *a = l->data; + + if (!strcmp (a->full, str)) { + addr = g_strdup (a->address); + cn = g_strdup (a->name); + } + } g_free (str); - return; - } + } + + if (addr == NULL || strlen (addr) == 0) { + g_free (addr); + g_free (cn); + return; + } else { + gchar *tmp; + + tmp = addr; + addr = g_strdup_printf ("MAILTO:%s", addr); + g_free (tmp); + } - organizer.value = str; - cal_component_set_organizer (comp, &organizer); - g_free (str); + organizer.value = addr; + organizer.cn = cn; + cal_component_set_organizer (comp, &organizer); + g_free (addr); + g_free (cn); + } for (l = priv->attendees; l != NULL; l = l->next) { struct attendee *attendee = l->data; CalComponentAttendee *att = g_new0 (CalComponentAttendee, 1); + att->value = attendee->address; att->member = (attendee->member && *attendee->member) ? attendee->member : NULL; att->cutype= attendee->cutype; @@ -420,13 +512,29 @@ get_widgets (MeetingPage *mpage) gtk_widget_ref (priv->main); gtk_widget_unparent (priv->main); + priv->organizer_table = GW ("organizer-table"); priv->organizer = GW ("organizer"); + priv->organizer_lbl = GW ("organizer-label"); + priv->other_organizer = GW ("other-organizer"); + priv->other_organizer_lbl = GW ("other-organizer-label"); + priv->other_organizer_btn = GW ("other-organizer-button"); + priv->existing_organizer_table = GW ("existing-organizer-table"); + priv->existing_organizer = GW ("existing-organizer"); + priv->existing_organizer_btn = GW ("existing-organizer-button"); priv->invite = GW ("invite"); #undef GW return (priv->invite - && priv->organizer); + && priv->organizer_table + && priv->organizer + && priv->organizer_lbl + && priv->other_organizer + && priv->other_organizer_lbl + && priv->other_organizer_btn + && priv->existing_organizer_table + && priv->existing_organizer + && priv->existing_organizer_btn); } static void @@ -520,6 +628,44 @@ field_changed_cb (GtkWidget *widget, gpointer data) comp_editor_page_notify_changed (COMP_EDITOR_PAGE (mpage)); } +/* Function called to make the organizer other than the user */ +static void +other_clicked_cb (GtkWidget *widget, gpointer data) +{ + MeetingPage *mpage; + MeetingPagePrivate *priv; + + mpage = MEETING_PAGE (data); + priv = mpage->priv; + + gtk_widget_show (priv->other_organizer_lbl); + gtk_widget_show (priv->other_organizer); + + gtk_label_set_text (GTK_LABEL (priv->organizer_lbl), _("Sent By:")); + + priv->other = TRUE; +} + +/* Function called to change the organizer */ +static void +change_clicked_cb (GtkWidget *widget, gpointer data) +{ + MeetingPage *mpage; + MeetingPagePrivate *priv; + + mpage = MEETING_PAGE (data); + priv = mpage->priv; + + gtk_widget_show (priv->organizer_table); + gtk_widget_hide (priv->existing_organizer_table); + gtk_widget_show (priv->invite); + + gtk_combo_set_popdown_strings (GTK_COMBO (priv->organizer), priv->address_strings); + e_dialog_editable_set (GTK_COMBO (priv->organizer)->entry, priv->default_address); + + priv->existing = FALSE; +} + /* Function called to invite more people */ static void invite_cb (GtkWidget *widget, gpointer data) @@ -554,6 +700,11 @@ init_widgets (MeetingPage *mpage) gtk_signal_connect (GTK_OBJECT (priv->organizer), "changed", GTK_SIGNAL_FUNC (field_changed_cb), mpage); + gtk_signal_connect (GTK_OBJECT (priv->other_organizer_btn), "clicked", + GTK_SIGNAL_FUNC (other_clicked_cb), mpage); + gtk_signal_connect (GTK_OBJECT (priv->existing_organizer_btn), "clicked", + GTK_SIGNAL_FUNC (change_clicked_cb), mpage); + /* Invite button */ gtk_signal_connect (GTK_OBJECT (priv->invite), "clicked", GTK_SIGNAL_FUNC (invite_cb), mpage); diff --git a/calendar/gui/dialogs/meeting-page.glade b/calendar/gui/dialogs/meeting-page.glade index 4e23c16f67..de57779044 100644 --- a/calendar/gui/dialogs/meeting-page.glade +++ b/calendar/gui/dialogs/meeting-page.glade @@ -27,15 +27,15 @@ <widget> <class>GtkVBox</class> <name>meeting-page</name> - <border_width>5</border_width> + <border_width>4</border_width> <homogeneous>False</homogeneous> <spacing>4</spacing> <widget> - <class>GtkHBox</class> - <name>hbox1</name> + <class>GtkVBox</class> + <name>vbox1</name> <homogeneous>False</homogeneous> - <spacing>4</spacing> + <spacing>0</spacing> <child> <padding>0</padding> <expand>False</expand> @@ -43,39 +43,241 @@ </child> <widget> - <class>GtkLabel</class> - <name>label1</name> - <label>Organizer</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> + <class>GtkTable</class> + <name>organizer-table</name> + <border_width>4</border_width> + <rows>2</rows> + <columns>3</columns> + <homogeneous>False</homogeneous> + <row_spacing>0</row_spacing> + <column_spacing>4</column_spacing> <child> <padding>0</padding> - <expand>False</expand> - <fill>False</fill> + <expand>True</expand> + <fill>True</fill> </child> + + <widget> + <class>GtkCombo</class> + <name>organizer</name> + <value_in_list>True</value_in_list> + <ok_if_empty>False</ok_if_empty> + <case_sensitive>False</case_sensitive> + <use_arrows>True</use_arrows> + <use_arrows_always>False</use_arrows_always> + <items></items> + <child> + <left_attach>1</left_attach> + <right_attach>2</right_attach> + <top_attach>0</top_attach> + <bottom_attach>1</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>True</xexpand> + <yexpand>False</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>False</yfill> + </child> + + <widget> + <class>GtkEntry</class> + <child_name>GtkCombo:entry</child_name> + <name>entry2</name> + <can_focus>True</can_focus> + <editable>True</editable> + <text_visible>True</text_visible> + <text_max_length>0</text_max_length> + <text></text> + </widget> + </widget> + + <widget> + <class>GtkButton</class> + <name>other-organizer-button</name> + <can_focus>True</can_focus> + <label>Other Organizer</label> + <child> + <left_attach>2</left_attach> + <right_attach>3</right_attach> + <top_attach>0</top_attach> + <bottom_attach>1</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>False</xexpand> + <yexpand>False</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>False</xfill> + <yfill>False</yfill> + </child> + </widget> + + <widget> + <class>GtkEntry</class> + <name>other-organizer</name> + <can_focus>True</can_focus> + <editable>True</editable> + <text_visible>True</text_visible> + <text_max_length>0</text_max_length> + <text></text> + <child> + <left_attach>1</left_attach> + <right_attach>2</right_attach> + <top_attach>1</top_attach> + <bottom_attach>2</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>True</xexpand> + <yexpand>False</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>False</yfill> + </child> + </widget> + + <widget> + <class>GtkLabel</class> + <name>organizer-label</name> + <label>Organizer:</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + <child> + <left_attach>0</left_attach> + <right_attach>1</right_attach> + <top_attach>0</top_attach> + <bottom_attach>1</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>False</xexpand> + <yexpand>False</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>False</yfill> + </child> + </widget> + + <widget> + <class>GtkLabel</class> + <name>other-organizer-label</name> + <label>Organizer:</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + <child> + <left_attach>0</left_attach> + <right_attach>1</right_attach> + <top_attach>1</top_attach> + <bottom_attach>2</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>False</xexpand> + <yexpand>False</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>False</yfill> + </child> + </widget> </widget> <widget> - <class>GtkEntry</class> - <name>organizer</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> + <class>GtkTable</class> + <name>existing-organizer-table</name> + <border_width>4</border_width> + <rows>1</rows> + <columns>3</columns> + <homogeneous>False</homogeneous> + <row_spacing>0</row_spacing> + <column_spacing>4</column_spacing> <child> <padding>0</padding> <expand>True</expand> <fill>True</fill> </child> - </widget> - <widget> - <class>Placeholder</class> + <widget> + <class>GtkLabel</class> + <name>label1</name> + <label>Organizer:</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + <child> + <left_attach>0</left_attach> + <right_attach>1</right_attach> + <top_attach>0</top_attach> + <bottom_attach>1</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>False</xexpand> + <yexpand>False</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>False</xfill> + <yfill>False</yfill> + </child> + </widget> + + <widget> + <class>GtkButton</class> + <name>existing-organizer-button</name> + <can_focus>True</can_focus> + <label>Change Organizer</label> + <child> + <left_attach>2</left_attach> + <right_attach>3</right_attach> + <top_attach>0</top_attach> + <bottom_attach>1</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>False</xexpand> + <yexpand>False</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>False</xfill> + <yfill>False</yfill> + </child> + </widget> + + <widget> + <class>GtkLabel</class> + <name>existing-organizer</name> + <label>None</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + <child> + <left_attach>1</left_attach> + <right_attach>2</right_attach> + <top_attach>0</top_attach> + <bottom_attach>1</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>True</xexpand> + <yexpand>False</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>False</yfill> + </child> + </widget> </widget> </widget> diff --git a/calendar/gui/gnome-cal.html b/calendar/gui/gnome-cal.html deleted file mode 100644 index 5a7d0a537f..0000000000 --- a/calendar/gui/gnome-cal.html +++ /dev/null @@ -1,44 +0,0 @@ -<!-- Some simple instructions on how to use the help browser --> -<BODY> -<!-- <TITLE>GNOME Calendar Documentation</TITLE> --> -<H2> GNOME Calendar Documentation </H2> -<p> -The GNOME calendar program is the calendaring program of the GNOME -system. It uses the vCalendar standard for transfering calendar -information (and is also the on-disk format used). - -<p> - -<a name="cmdline"> -<h2>Command line options</h2> - -Several options are available on the command line, they are: -<ul> - <li><tt>--events</tt> Displays the events for the date - specified (or today, if no date is specified). - - <li><tt>--from DATE</tt> Define the beginning of the range for - the event display, or the startup day on the calenday views. - By default, the event will span the whole day specified in - DATE. - - <li><tt>--to DATE</tt> Define the range end for the event - display. If this is not specified, it will default to the end - of the day specified by the <tt>--from</tt> option. - - <li><tt>--file FILE</tt> Set the calendar to the FILE - specified on the command line. - - <li><tt>--todo</tt> Dumps the to-do values to standard output. -</ul> - -<p> - -DATE is interpreted as being in the local time- zone, unless a -specific timezone is specified. Examples of valid date specifications -include: "1 month ago", "2 hours ago", "400000 seconds ago", "last -year", "last Monday", "yesterday", "a fortnight ago", "3/31/92 -10:00:07 PST", "January 23, 1987 10:05pm", "22:00 GMT". - -</BODY> - diff --git a/calendar/gui/itip-utils.c b/calendar/gui/itip-utils.c index b3566e51cf..5c0f040812 100644 --- a/calendar/gui/itip-utils.c +++ b/calendar/gui/itip-utils.c @@ -21,8 +21,11 @@ * USA */ +#include <bonobo/bonobo-exception.h> #include <bonobo/bonobo-object.h> #include <bonobo/bonobo-object-client.h> +#include <bonobo/bonobo-moniker-util.h> +#include <bonobo-conf/bonobo-config-database.h> #include <libgnome/gnome-defs.h> #include <libgnome/gnome-i18n.h> #include <libgnomeui/gnome-dialog.h> @@ -56,48 +59,91 @@ static icalproperty_method itip_methods_enum[] = { ICAL_METHOD_DECLINECOUNTER, }; -gchar *partstat_values[] = { - "Needs action", - "Accepted", - "Declined", - "Tentative", - "Delegated", - "Completed", - "In Progress", - "Unknown" -}; +static void +error_dialog (gchar *str) +{ + GtkWidget *dlg; + + dlg = gnome_error_dialog (str); + gnome_dialog_run_and_close (GNOME_DIALOG (dlg)); +} -gchar *role_values[] = { - "Chair", - "Required Participant", - "Optional Participant", - "Non-Participant" -}; +GList * +itip_addresses_get (void) +{ + static Bonobo_ConfigDatabase db = NULL; + CORBA_Environment ev; + GList *addresses = NULL; + gboolean have_default = FALSE; + gint len, i; + + if (db == NULL) { + CORBA_exception_init (&ev); + + db = bonobo_get_object ("wombat:", + "Bonobo/ConfigDatabase", + &ev); + + if (BONOBO_EX (&ev) || db == CORBA_OBJECT_NIL) { + CORBA_exception_free (&ev); + return NULL; + } + + CORBA_exception_free (&ev); + } + + len = bonobo_config_get_long_with_default (db, "/Mail/Accounts/num", 0, NULL); + for (i = 0; i < len; i++) { + ItipAddress *a; + gchar *path; + + a = g_new0 (ItipAddress, 1); + /* get the identity info */ + path = g_strdup_printf ("/Mail/Accounts/identity_name_%d", i); + a->name = bonobo_config_get_string (db, path, NULL); + g_free (path); -/* Note that I have to iterate and check myself because - ical_property_get_xxx_parameter doesn't take into account the - kind of parameter for which you wish to search! */ -icalparameter * -get_icalparam_by_type (icalproperty *prop, icalparameter_kind kind) -{ - icalparameter *param; + path = g_strdup_printf ("/Mail/Accounts/identity_address_%d", i); + a->address = bonobo_config_get_string (db, path, NULL); + g_free (path); - for (param = icalproperty_get_first_parameter (prop, ICAL_ANY_PARAMETER); - param != NULL && icalparameter_isa (param) != kind; - param = icalproperty_get_next_parameter (prop, ICAL_ANY_PARAMETER) ); + path = g_strdup_printf ("/Mail/Accounts/account_is_default_%d", i); + a->default_address = !have_default && bonobo_config_get_boolean (db, path, NULL); - return param; + if (a->default_address) + have_default = TRUE; + g_free (path); + + a->full = g_strdup_printf ("%s <%s>", a->name, a->address); + addresses = g_list_append (addresses, a); + } + + /* If nothing was marked as default */ + if (!have_default && addresses != NULL) { + ItipAddress *a = addresses->data; + + a->default_address = TRUE; + } + + return addresses; } -static void -error_dialog (gchar *str) +void +itip_addresses_free (GList *addresses) { - GtkWidget *dlg; + GList *l; - dlg = gnome_error_dialog (str); - gnome_dialog_run_and_close (GNOME_DIALOG (dlg)); + for (l = addresses; l != NULL; l = l->next) { + ItipAddress *a = l->data; + + g_free (a->name); + g_free (a->address); + g_free (a->full); + g_free (a); + } + g_list_free (addresses); } void diff --git a/calendar/gui/itip-utils.h b/calendar/gui/itip-utils.h index b51696876f..fcf53aada6 100644 --- a/calendar/gui/itip-utils.h +++ b/calendar/gui/itip-utils.h @@ -8,11 +8,6 @@ #include <glib.h> #include <cal-util/cal-component.h> -extern gchar *partstat_values[]; -extern gchar *role_values[]; - -icalparameter * get_icalparam_by_type (icalproperty *prop, icalparameter_kind kind); - typedef enum { CAL_COMPONENT_METHOD_PUBLISH, CAL_COMPONENT_METHOD_REQUEST, @@ -24,6 +19,18 @@ typedef enum { CAL_COMPONENT_METHOD_DECLINECOUNTER } CalComponentItipMethod; +typedef struct { + gchar *name; + gchar *address; + gchar *full; + + gboolean default_address; +} ItipAddress; + +GList *itip_addresses_get (void); +void itip_addresses_free (GList *addresses); + void itip_send_comp (CalComponentItipMethod method, CalComponent *comp); + #endif |