aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/dialogs/schedule-page.c
diff options
context:
space:
mode:
authorJP Rosevear <jpr@ximian.com>2001-09-19 12:33:33 +0800
committerJP Rosevear <jpr@src.gnome.org>2001-09-19 12:33:33 +0800
commitd639a620a6438ea93787cedfe9f3eb87014275a3 (patch)
tree602d9156e8e33197fc27752d8fb976cce99d896c /calendar/gui/dialogs/schedule-page.c
parentd284de85386149adba1e94f1b05b6b2d631e8585 (diff)
downloadgsoc2013-evolution-d639a620a6438ea93787cedfe9f3eb87014275a3.tar.gz
gsoc2013-evolution-d639a620a6438ea93787cedfe9f3eb87014275a3.tar.zst
gsoc2013-evolution-d639a620a6438ea93787cedfe9f3eb87014275a3.zip
A page that shows the meeting time selector and free/busy data for
2001-09-18 JP Rosevear <jpr@ximian.com> * gui/dialogs/schedule-page.*: A page that shows the meeting time selector and free/busy data for attendees * gui/dialogs/meeting-page.c: use the meeting model to track/edit attendees, remove table value conversion routines and simple table routines (set_attendees): take a pointer array (meeting_page_destroy): destroy the pointer array, save state (meeting_page_init): new pointer array (meeting_page_fill_widgets): don't null the deleted attendees field (popup_delegate_cb): array add (popup_delete_cb): array add (cleanup_attendees): iterate over the array to unref now (meeting_page_fill_widgets): don't null out fields, no need to add attendees here (invite_entry_changed): use e_meeting_attendee routines (popup_delegate_cb): ditto (popup_delete_cb): ditto (meeting_page_new): take new arg and pass it to construct (meeting_page_construct): take new arg, use e-meeting-model routines to construct table * gui/dialogs/task-editor.c (task_editor_init): new meeting model (task_editor_destroy): unref the model * gui/dialogs/event-editor.c (event_editor_init): make new model and pass it to meeting and schedule pages (event_editor_set_cal_client): virtual function, set meeting model client (event_editor_edit_comp): add the attendees to the model (event_editor_destroy): unref model * gui/dialogs/comp-editor.h: add virtual function * gui/dialogs/comp-editor.c (comp_editor_set_cal_client): make set_cal_client a virutal function * gui/e-meeting-types.h: generally useful type defines * gui/e-meeting-time-sel*.[hc]: Move here and use an e-table for the attendee list and extract display information from the new meeting model and attendees * gui/e-meeting-time-sel.etspec: spec for the table * gui/e-meeting-attendee.[hc]: meeting attendees for the model, with to/from conversions for CalComponentAttendee structure, emits changed signal and allows getting and setting of free busy periods * gui/e-meeting-model.[hc]: move the model out on its own * gui/e-itip-control.c (write_error_html): clean up warnings svn path=/trunk/; revision=12968
Diffstat (limited to 'calendar/gui/dialogs/schedule-page.c')
-rw-r--r--calendar/gui/dialogs/schedule-page.c402
1 files changed, 402 insertions, 0 deletions
diff --git a/calendar/gui/dialogs/schedule-page.c b/calendar/gui/dialogs/schedule-page.c
new file mode 100644
index 0000000000..42510e0b5a
--- /dev/null
+++ b/calendar/gui/dialogs/schedule-page.c
@@ -0,0 +1,402 @@
+/* Evolution calendar - Scheduling page
+ *
+ * Copyright (C) 2001 Ximian, Inc.
+ *
+ * Authors: Federico Mena-Quintero <federico@ximian.com>
+ * Miguel de Icaza <miguel@ximian.com>
+ * Seth Alves <alves@hungry.com>
+ * JP Rosevear <jpr@ximian.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib.h>
+#include <liboaf/liboaf.h>
+#include <bonobo/bonobo-control.h>
+#include <bonobo/bonobo-widget.h>
+#include <bonobo/bonobo-exception.h>
+#include <gtk/gtksignal.h>
+#include <gtk/gtktogglebutton.h>
+#include <gtk/gtkvbox.h>
+#include <gtk/gtkwindow.h>
+#include <libgnome/gnome-defs.h>
+#include <libgnome/gnome-i18n.h>
+#include <libgnomeui/gnome-stock.h>
+#include <libgnomeui/gnome-dialog-util.h>
+#include <glade/glade.h>
+#include <gal/e-table/e-cell-combo.h>
+#include <gal/e-table/e-cell-text.h>
+#include <gal/e-table/e-table-simple.h>
+#include <gal/e-table/e-table-scrolled.h>
+#include <gal/widgets/e-unicode.h>
+#include <gal/widgets/e-popup-menu.h>
+#include <gal/widgets/e-gui-utils.h>
+#include <widgets/misc/e-dateedit.h>
+#include <e-util/e-dialog-widgets.h>
+#include <e-destination.h>
+#include "Evolution-Addressbook-SelectNames.h"
+#include "../e-meeting-time-sel.h"
+#include "../itip-utils.h"
+#include "comp-editor-util.h"
+#include "e-delegate-dialog.h"
+#include "schedule-page.h"
+
+
+
+/* Private part of the SchedulePage structure */
+struct _SchedulePagePrivate {
+ /* Glade XML data */
+ GladeXML *xml;
+
+ /* Widgets from the Glade file */
+ GtkWidget *main;
+
+ /* Model */
+ EMeetingModel *model;
+
+ /* Selector */
+ EMeetingTimeSelector *sel;
+
+ gboolean updating;
+};
+
+
+
+static void schedule_page_class_init (SchedulePageClass *class);
+static void schedule_page_init (SchedulePage *spage);
+static void schedule_page_destroy (GtkObject *object);
+
+static GtkWidget *schedule_page_get_widget (CompEditorPage *page);
+static void schedule_page_focus_main_widget (CompEditorPage *page);
+static void schedule_page_fill_widgets (CompEditorPage *page, CalComponent *comp);
+static void schedule_page_fill_component (CompEditorPage *page, CalComponent *comp);
+
+static void model_row_changed_cb (ETableModel *etm, int row, gpointer data);
+static void row_count_changed_cb (ETableModel *etm, int row, int count, gpointer data);
+
+static CompEditorPageClass *parent_class = NULL;
+
+
+
+/**
+ * schedule_page_get_type:
+ *
+ * Registers the #SchedulePage class if necessary, and returns the type ID
+ * associated to it.
+ *
+ * Return value: The type ID of the #SchedulePage class.
+ **/
+GtkType
+schedule_page_get_type (void)
+{
+ static GtkType schedule_page_type;
+
+ if (!schedule_page_type) {
+ static const GtkTypeInfo schedule_page_info = {
+ "SchedulePage",
+ sizeof (SchedulePage),
+ sizeof (SchedulePageClass),
+ (GtkClassInitFunc) schedule_page_class_init,
+ (GtkObjectInitFunc) schedule_page_init,
+ NULL, /* reserved_1 */
+ NULL, /* reserved_2 */
+ (GtkClassInitFunc) NULL
+ };
+
+ schedule_page_type =
+ gtk_type_unique (TYPE_COMP_EDITOR_PAGE,
+ &schedule_page_info);
+ }
+
+ return schedule_page_type;
+}
+
+/* Class initialization function for the schedule page */
+static void
+schedule_page_class_init (SchedulePageClass *class)
+{
+ CompEditorPageClass *editor_page_class;
+ GtkObjectClass *object_class;
+
+ editor_page_class = (CompEditorPageClass *) class;
+ object_class = (GtkObjectClass *) class;
+
+ parent_class = gtk_type_class (TYPE_COMP_EDITOR_PAGE);
+
+ editor_page_class->get_widget = schedule_page_get_widget;
+ editor_page_class->focus_main_widget = schedule_page_focus_main_widget;
+ editor_page_class->fill_widgets = schedule_page_fill_widgets;
+ editor_page_class->fill_component = schedule_page_fill_component;
+ editor_page_class->set_summary = NULL;
+ editor_page_class->set_dates = NULL;
+
+ object_class->destroy = schedule_page_destroy;
+}
+
+/* Object initialization function for the schedule page */
+static void
+schedule_page_init (SchedulePage *spage)
+{
+ SchedulePagePrivate *priv;
+
+ priv = g_new0 (SchedulePagePrivate, 1);
+ spage->priv = priv;
+
+ priv->xml = NULL;
+
+ priv->main = NULL;
+
+ priv->updating = FALSE;
+}
+
+/* Destroy handler for the schedule page */
+static void
+schedule_page_destroy (GtkObject *object)
+{
+ SchedulePage *spage;
+ SchedulePagePrivate *priv;
+
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (IS_SCHEDULE_PAGE (object));
+
+ spage = SCHEDULE_PAGE (object);
+ priv = spage->priv;
+
+ if (priv->xml) {
+ gtk_object_unref (GTK_OBJECT (priv->xml));
+ priv->xml = NULL;
+ }
+
+ gtk_object_unref (GTK_OBJECT (priv->model));
+
+ g_free (priv);
+ spage->priv = NULL;
+
+ if (GTK_OBJECT_CLASS (parent_class)->destroy)
+ (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+}
+
+
+
+/* get_widget handler for the schedule page */
+static GtkWidget *
+schedule_page_get_widget (CompEditorPage *page)
+{
+ SchedulePage *spage;
+ SchedulePagePrivate *priv;
+
+ spage = SCHEDULE_PAGE (page);
+ priv = spage->priv;
+
+ return priv->main;
+}
+
+/* focus_main_widget handler for the schedule page */
+static void
+schedule_page_focus_main_widget (CompEditorPage *page)
+{
+ SchedulePage *spage;
+ SchedulePagePrivate *priv;
+
+ spage = SCHEDULE_PAGE (page);
+ priv = spage->priv;
+
+ gtk_widget_grab_focus (GTK_WIDGET (priv->sel));
+}
+
+/* Fills the widgets with default values */
+static void
+clear_widgets (SchedulePage *spage)
+{
+ SchedulePagePrivate *priv;
+
+ priv = spage->priv;
+}
+
+/* fill_widgets handler for the schedule page */
+static void
+schedule_page_fill_widgets (CompEditorPage *page, CalComponent *comp)
+{
+ SchedulePage *spage;
+ SchedulePagePrivate *priv;
+ GSList *attendees;
+
+ spage = SCHEDULE_PAGE (page);
+ priv = spage->priv;
+
+ priv->updating = TRUE;
+
+ /* Clean the screen */
+ clear_widgets (spage);
+
+ /* Attendees */
+ cal_component_get_attendee_list (comp, &attendees);
+
+ /* So the comp editor knows we need to send if anything changes */
+ if (attendees != NULL)
+ comp_editor_page_notify_needs_send (COMP_EDITOR_PAGE (spage));
+
+ cal_component_free_attendee_list (attendees);
+
+ priv->updating = FALSE;
+}
+
+/* fill_component handler for the schedule page */
+static void
+schedule_page_fill_component (CompEditorPage *page, CalComponent *comp)
+{
+ SchedulePage *spage;
+ SchedulePagePrivate *priv;
+
+ spage = SCHEDULE_PAGE (page);
+ priv = spage->priv;
+}
+
+
+
+/* Gets the widgets from the XML file and returns if they are all available. */
+static gboolean
+get_widgets (SchedulePage *spage)
+{
+ SchedulePagePrivate *priv;
+
+ priv = spage->priv;
+
+#define GW(name) glade_xml_get_widget (priv->xml, name)
+
+ priv->main = GW ("schedule-page");
+ if (!priv->main)
+ return FALSE;
+
+ gtk_widget_ref (priv->main);
+ gtk_widget_unparent (priv->main);
+
+#undef GW
+
+ return TRUE;
+}
+
+/* Hooks the widget signals */
+static void
+init_widgets (SchedulePage *spage)
+{
+ SchedulePagePrivate *priv;
+
+ priv = spage->priv;
+
+ gtk_signal_connect (GTK_OBJECT (priv->model), "model_row_changed",
+ GTK_SIGNAL_FUNC (model_row_changed_cb), spage);
+ gtk_signal_connect (GTK_OBJECT (priv->model), "model_rows_inserted",
+ GTK_SIGNAL_FUNC (row_count_changed_cb), spage);
+ gtk_signal_connect (GTK_OBJECT (priv->model), "model_rows_deleted",
+ GTK_SIGNAL_FUNC (row_count_changed_cb), spage);
+}
+
+
+
+/**
+ * schedule_page_construct:
+ * @spage: An schedule page.
+ *
+ * Constructs an schedule page by loading its Glade data.
+ *
+ * Return value: The same object as @spage, or NULL if the widgets could not
+ * be created.
+ **/
+SchedulePage *
+schedule_page_construct (SchedulePage *spage, EMeetingModel *emm)
+{
+ SchedulePagePrivate *priv;
+
+ priv = spage->priv;
+
+ priv->xml = glade_xml_new (EVOLUTION_GLADEDIR
+ "/schedule-page.glade", NULL);
+ if (!priv->xml) {
+ g_message ("schedule_page_construct(): "
+ "Could not load the Glade XML file!");
+ return NULL;
+ }
+
+ if (!get_widgets (spage)) {
+ g_message ("schedule_page_construct(): "
+ "Could not find all widgets in the XML file!");
+ return NULL;
+ }
+
+ /* Model */
+ gtk_object_ref (GTK_OBJECT (emm));
+ priv->model = emm;
+
+ /* Selector */
+ priv->sel = E_MEETING_TIME_SELECTOR (e_meeting_time_selector_new (emm));
+ gtk_widget_show (GTK_WIDGET (priv->sel));
+ gtk_box_pack_start (GTK_BOX (priv->main), GTK_WIDGET (priv->sel), TRUE, TRUE, 2);
+
+ /* Init the widget signals */
+ init_widgets (spage);
+
+ return spage;
+}
+
+/**
+ * schedule_page_new:
+ *
+ * Creates a new schedule page.
+ *
+ * Return value: A newly-created schedule page, or NULL if the page could
+ * not be created.
+ **/
+SchedulePage *
+schedule_page_new (EMeetingModel *emm)
+{
+ SchedulePage *spage;
+
+ spage = gtk_type_new (TYPE_SCHEDULE_PAGE);
+ if (!schedule_page_construct (spage, emm)) {
+ gtk_object_unref (GTK_OBJECT (spage));
+ return NULL;
+ }
+
+ return spage;
+}
+
+static void
+model_row_changed_cb (ETableModel *etm, int row, gpointer data)
+{
+ SchedulePage *spage = SCHEDULE_PAGE (data);
+ SchedulePagePrivate *priv;
+
+ priv = spage->priv;
+
+ if (!priv->updating)
+ comp_editor_page_notify_changed (COMP_EDITOR_PAGE (spage));
+}
+
+static void
+row_count_changed_cb (ETableModel *etm, int row, int count, gpointer data)
+{
+ SchedulePage *spage = SCHEDULE_PAGE (data);
+ SchedulePagePrivate *priv;
+
+ priv = spage->priv;
+
+ if (!priv->updating)
+ comp_editor_page_notify_changed (COMP_EDITOR_PAGE (spage));
+}