Sync - Federico

svn path=/trunk/; revision=10293
parent 2e156596
......@@ -19,6 +19,10 @@
variables for camel/Makefile to make camel-lock-helper
setuid/setgid.
2001-06-15 Federico Mena Quintero <federico@ximian.com>
* configure.in (AC_OUTPUT): Added views/calendar/Makefile.
2001-06-11 JP Rosevear <jpr@ximian.com>
* configure.in: One slight db3 check correction
......
......@@ -41,6 +41,35 @@
(conduit_get_gpilot_conduit):
Tweaked for some gnome-pilot api changes
2001-06-15 Federico Mena Quintero <federico@ximian.com>
* gui/calendar-view.[ch]: New files with the generic calendar view
object. It sucks that we have to implement at least two classes
to define a GalView and its factory.
* gui/calendar-view-factory.[ch]: New files; factory for calendar
views.
* gui/gnome-cal.h (GnomeCalendarViewType): Moved from gnome-cal.c
and renamed from ViewType. We no longer use strings to identify
the view types.
* gui/gnome-cal.c (gnome_calendar_get_view_type): New function.
(set_view): Renamed from gnome_calendar_set_view_internal().
(gnome_calendar_set_query): Made public; renamed from set_query().
(gnome_calendar_setup_view_menus): New function to set up the view
collection and the GalViewMenus.
(gnome_calendar_discard_view_menus): New function to discard them.
* gui/calendar-commands.c (calendar_control_activate): Set up the
GalView menus.
(calendar_control_deactivate): Discard the GalView menus.
* gui/e-day-view.c: #include <gtk/gtkinvisible.h>
* gui/dialogs/comp-editor.c (comp_editor_get_type): The type info
structure should be static.
2001-06-15 Rodrigo Moya <rodrigo@ximian.com>
* gui/e-day-view.c (selection_received): generate a new UID
......
......@@ -53,6 +53,10 @@ evolution_calendar_SOURCES = \
calendar-commands.h \
calendar-model.c \
calendar-model.h \
calendar-view.c \
calendar-view.h \
calendar-view-factory.c \
calendar-view-factory.h \
comp-util.c \
comp-util.h \
control-factory.c \
......
......@@ -75,7 +75,7 @@ new_event_cb (BonoboUIComponent *uic, gpointer data, const char *path)
{
GnomeCalendar *gcal;
time_t dtstart, dtend;
gcal = GNOME_CALENDAR (data);
gnome_calendar_get_current_time_range (gcal, &dtstart, &dtend);
gnome_calendar_new_appointment_for (gcal, dtstart, dtend, TRUE);
......@@ -86,21 +86,29 @@ static void
print (GnomeCalendar *gcal, gboolean preview)
{
time_t start;
const char *view;
GnomeCalendarViewType view_type;
PrintView print_view;
gnome_calendar_get_current_time_range (gcal, &start, NULL);
view = gnome_calendar_get_current_view_name (gcal);
view_type = gnome_calendar_get_view (gcal);
if (strcmp (view, "dayview") == 0)
switch (view_type) {
case GNOME_CAL_DAY_VIEW:
print_view = PRINT_VIEW_DAY;
else if (strcmp (view, "workweekview") == 0 || strcmp (view, "weekview") == 0)
break;
case GNOME_CAL_WORK_WEEK_VIEW:
case GNOME_CAL_WEEK_VIEW:
print_view = PRINT_VIEW_WEEK;
else if (strcmp (view, "monthview") == 0)
break;
case GNOME_CAL_MONTH_VIEW:
print_view = PRINT_VIEW_MONTH;
else {
break;
default:
g_assert_not_reached ();
print_view = PRINT_VIEW_DAY;
return;
}
print_calendar (gcal, preview, start, print_view);
......@@ -216,7 +224,7 @@ show_day_view_clicked (BonoboUIComponent *uic, gpointer data, const char *path)
gcal = GNOME_CALENDAR (data);
gnome_calendar_set_view (gcal, "dayview", FALSE, TRUE);
gnome_calendar_set_view (gcal, GNOME_CAL_DAY_VIEW, FALSE, TRUE);
}
static void
......@@ -226,7 +234,7 @@ show_work_week_view_clicked (BonoboUIComponent *uic, gpointer data, const char *
gcal = GNOME_CALENDAR (data);
gnome_calendar_set_view (gcal, "workweekview", FALSE, TRUE);
gnome_calendar_set_view (gcal, GNOME_CAL_WORK_WEEK_VIEW, FALSE, TRUE);
}
static void
......@@ -236,7 +244,7 @@ show_week_view_clicked (BonoboUIComponent *uic, gpointer data, const char *path)
gcal = GNOME_CALENDAR (data);
gnome_calendar_set_view (gcal, "weekview", FALSE, TRUE);
gnome_calendar_set_view (gcal, GNOME_CAL_WEEK_VIEW, FALSE, TRUE);
}
static void
......@@ -246,7 +254,7 @@ show_month_view_clicked (BonoboUIComponent *uic, gpointer data, const char *path
gcal = GNOME_CALENDAR (data);
gnome_calendar_set_view (gcal, "monthview", FALSE, TRUE);
gnome_calendar_set_view (gcal, GNOME_CAL_MONTH_VIEW, FALSE, TRUE);
}
......@@ -366,12 +374,12 @@ static BonoboUIVerb verbs [] = {
BONOBO_UI_VERB ("EditNewAppointment", new_appointment_cb),
BONOBO_UI_VERB ("EditNewEvent", new_event_cb),
BONOBO_UI_VERB ("CalendarPreferences", properties_cmd),
BONOBO_UI_VERB ("CalendarPrev", previous_clicked),
BONOBO_UI_VERB ("CalendarToday", today_clicked),
BONOBO_UI_VERB ("CalendarNext", next_clicked),
BONOBO_UI_VERB ("CalendarGoto", goto_clicked),
BONOBO_UI_VERB ("ShowDayView", show_day_view_clicked),
BONOBO_UI_VERB ("ShowWorkWeekView", show_work_week_view_clicked),
BONOBO_UI_VERB ("ShowWeekView", show_week_view_clicked),
......@@ -399,7 +407,7 @@ static EPixmap pixmaps [] =
void
calendar_control_activate (BonoboControl *control,
GnomeCalendar *cal)
GnomeCalendar *gcal)
{
Bonobo_UIContainer remote_uih;
BonoboUIComponent *uic;
......@@ -426,9 +434,8 @@ calendar_control_activate (BonoboControl *control,
/* This makes the appropriate radio button in the toolbar active. */
gnome_calendar_update_view_buttons (cal);
#endif
bonobo_ui_component_add_verb_list_with_data (
uic, verbs, cal);
bonobo_ui_component_add_verb_list_with_data (uic, verbs, gcal);
bonobo_ui_component_freeze (uic, NULL);
......@@ -438,15 +445,19 @@ calendar_control_activate (BonoboControl *control,
e_pixmaps_update (uic, pixmaps);
gnome_calendar_setup_view_menus (gcal, uic);
bonobo_ui_component_thaw (uic, NULL);
}
void
calendar_control_deactivate (BonoboControl *control)
calendar_control_deactivate (BonoboControl *control, GnomeCalendar *gcal)
{
BonoboUIComponent *uic = bonobo_control_get_ui_component (control);
g_assert (uic != NULL);
gnome_calendar_discard_view_menus (gcal);
bonobo_ui_component_rm (uic, "/", NULL);
bonobo_ui_component_unset_container (uic);
}
......
......@@ -34,9 +34,8 @@ void update_all_config_settings (void);
GnomeCalendar *new_calendar (void);
void calendar_control_activate (BonoboControl *control,
GnomeCalendar *cal);
void calendar_control_deactivate (BonoboControl *control);
void calendar_control_activate (BonoboControl *control, GnomeCalendar *gcal);
void calendar_control_deactivate (BonoboControl *control, GnomeCalendar *gcal);
void calendar_goto_today (GnomeCalendar *gcal);
......
/* Evolution calendar - Generic view factory for calendar views
*
* Copyright (C) 2001 Ximian, Inc.
*
* Author: Federico Mena-Quintero <federico@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 <libgnome/gnome-defs.h>
#include <libgnome/gnome-i18n.h>
#include "calendar-view-factory.h"
#include "calendar-view.h"
/* Private part of the CalendarViewFactory structure */
struct _CalendarViewFactoryPrivate {
/* Type of views created by this factory */
GnomeCalendarViewType view_type;
};
static void calendar_view_factory_class_init (CalendarViewFactoryClass *class);
static void calendar_view_factory_init (CalendarViewFactory *cal_view_factory);
static void calendar_view_factory_destroy (GtkObject *object);
static const char *calendar_view_factory_get_title (GalViewFactory *factory);
static const char *calendar_view_factory_get_type_code (GalViewFactory *factory);
static GalView *calendar_view_factory_new_view (GalViewFactory *factory, const char *name);
static GalViewFactoryClass *parent_class = NULL;
/**
* calendar_view_factory_get_type:
*
* Registers the #CalendarViewFactory class if necessary, and returns the type
* ID associated to it.
*
* Return value: The type ID of the #CalendarViewFactory class.
**/
GtkType
calendar_view_factory_get_type (void)
{
static GtkType calendar_view_factory_type;
if (!calendar_view_factory_type) {
static const GtkTypeInfo calendar_view_factory_info = {
"CalendarViewFactory",
sizeof (CalendarViewFactory),
sizeof (CalendarViewFactoryClass),
(GtkClassInitFunc) calendar_view_factory_class_init,
(GtkObjectInitFunc) calendar_view_factory_init,
NULL, /* reserved_1 */
NULL, /* reserved_2 */
(GtkClassInitFunc) NULL
};
calendar_view_factory_type = gtk_type_unique (GAL_VIEW_FACTORY_TYPE,
&calendar_view_factory_info);
}
return calendar_view_factory_type;
}
/* Class initialization function for the calendar view factory */
static void
calendar_view_factory_class_init (CalendarViewFactoryClass *class)
{
GalViewFactoryClass *gal_view_factory_class;
GtkObjectClass *object_class;
parent_class = gtk_type_class (GAL_VIEW_FACTORY_TYPE);
gal_view_factory_class = (GalViewFactoryClass *) class;
object_class = (GtkObjectClass *) class;
gal_view_factory_class->get_title = calendar_view_factory_get_title;
gal_view_factory_class->get_type_code = calendar_view_factory_get_type_code;
gal_view_factory_class->new_view = calendar_view_factory_new_view;
object_class->destroy = calendar_view_factory_destroy;
}
/* Object initialization class for the calendar view factory */
static void
calendar_view_factory_init (CalendarViewFactory *cal_view_factory)
{
CalendarViewFactoryPrivate *priv;
priv = g_new0 (CalendarViewFactoryPrivate, 1);
cal_view_factory->priv = priv;
}
/* Destroy method for the calendar view factory */
static void
calendar_view_factory_destroy (GtkObject *object)
{
CalendarViewFactory *cal_view_factory;
CalendarViewFactoryPrivate *priv;
g_return_if_fail (object != NULL);
g_return_if_fail (IS_CALENDAR_VIEW_FACTORY (object));
cal_view_factory = CALENDAR_VIEW_FACTORY (object);
priv = cal_view_factory->priv;
g_free (priv);
cal_view_factory->priv = NULL;
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
/* get_title method for the calendar view factory */
static const char *
calendar_view_factory_get_title (GalViewFactory *factory)
{
CalendarViewFactory *cal_view_factory;
CalendarViewFactoryPrivate *priv;
cal_view_factory = CALENDAR_VIEW_FACTORY (factory);
priv = cal_view_factory->priv;
switch (priv->view_type) {
case GNOME_CAL_DAY_VIEW:
return _("Day View");
case GNOME_CAL_WORK_WEEK_VIEW:
return _("Work Week View");
case GNOME_CAL_WEEK_VIEW:
return _("Week View");
case GNOME_CAL_MONTH_VIEW:
return _("Month View");
default:
g_assert_not_reached ();
return NULL;
}
}
/* get_type_code method for the calendar view factory */
static const char *
calendar_view_factory_get_type_code (GalViewFactory *factory)
{
CalendarViewFactory *cal_view_factory;
CalendarViewFactoryPrivate *priv;
cal_view_factory = CALENDAR_VIEW_FACTORY (factory);
priv = cal_view_factory->priv;
switch (priv->view_type) {
case GNOME_CAL_DAY_VIEW:
return "day_view";
case GNOME_CAL_WORK_WEEK_VIEW:
return "work_week_view";
case GNOME_CAL_WEEK_VIEW:
return "week_view";
case GNOME_CAL_MONTH_VIEW:
return "month_view";
default:
g_assert_not_reached ();
return NULL;
}
}
/* new_view method for the calendar view factory */
static GalView *
calendar_view_factory_new_view (GalViewFactory *factory, const char *name)
{
CalendarViewFactory *cal_view_factory;
CalendarViewFactoryPrivate *priv;
CalendarView *cal_view;
cal_view_factory = CALENDAR_VIEW_FACTORY (factory);
priv = cal_view_factory->priv;
cal_view = calendar_view_new (priv->view_type, name);
return GAL_VIEW (cal_view);
}
/**
* calendar_view_factory_construct:
* @cal_view_factory: A calendar view factory.
* @view_type: Type of calendar views that the factory will create.
*
* Constructs a calendar view factory by setting the type of views it will
* create.
*
* Return value: The same value as @cal_view_factory.
**/
CalendarViewFactory *
calendar_view_factory_construct (CalendarViewFactory *cal_view_factory,
GnomeCalendarViewType view_type)
{
CalendarViewFactoryPrivate *priv;
g_return_val_if_fail (cal_view_factory != NULL, NULL);
g_return_val_if_fail (IS_CALENDAR_VIEW_FACTORY (cal_view_factory), NULL);
priv = cal_view_factory->priv;
priv->view_type = view_type;
return cal_view_factory;
}
/**
* calendar_view_factory_new:
* @view_type: Type of calendar views that the factory will create.
*
* Creates a new factory for calendar views.
*
* Return value: A newly-created calendar view factory.
**/
CalendarViewFactory *
calendar_view_factory_new (GnomeCalendarViewType view_type)
{
CalendarViewFactory *cal_view_factory;
cal_view_factory = gtk_type_new (TYPE_CALENDAR_VIEW_FACTORY);
return calendar_view_factory_construct (cal_view_factory, view_type);
}
/* Evolution calendar - Generic view factory for calendar views
*
* Copyright (C) 2001 Ximian, Inc.
*
* Author: Federico Mena-Quintero <federico@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.
*/
#ifndef CALENDAR_VIEW_FACTORY_H
#define CALENDAR_VIEW_FACTORY_H
#include <libgnome/gnome-defs.h>
#include <gal/menus/gal-view-factory.h>
#include "gnome-cal.h"
BEGIN_GNOME_DECLS
#define TYPE_CALENDAR_VIEW_FACTORY (calendar_view_factory_get_type ())
#define CALENDAR_VIEW_FACTORY(obj) (GTK_CHECK_CAST ((obj), TYPE_CALENDAR_VIEW_FACTORY, \
CalendarViewFactory))
#define CALENDAR_VIEW_FACTORY_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), \
TYPE_CALENDAR_VIEW_FACTORY, CalendarViewClass))
#define IS_CALENDAR_VIEW_FACTORY(obj) (GTK_CHECK_TYPE ((obj), TYPE_CALENDAR_VIEW_FACTORY))
#define IS_CALENDAR_VIEW_FACTORY_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), \
TYPE_CALENDAR_VIEW_FACTORY))
typedef struct _CalendarViewFactoryPrivate CalendarViewFactoryPrivate;
typedef struct {
GalViewFactory factory;
/* Private data */
CalendarViewFactoryPrivate *priv;
} CalendarViewFactory;
typedef struct {
GalViewFactoryClass parent_class;
} CalendarViewFactoryClass;
GtkType calendar_view_factory_get_type (void);
CalendarViewFactory *calendar_view_factory_construct (CalendarViewFactory *cal_view_factory,
GnomeCalendarViewType view_type);
CalendarViewFactory *calendar_view_factory_new (GnomeCalendarViewType view_type);
END_GNOME_DECLS
#endif
/* Evolution calendar - Generic view object for calendar views
*
* Copyright (C) 2001 Ximian, Inc.
*
* Author: Federico Mena-Quintero <federico@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 "calendar-view.h"
/* Private part of the CalendarView structure */
struct _CalendarViewPrivate {
/* Type of the view */
GnomeCalendarViewType view_type;
/* Title of the view */
char *title;
};
static void calendar_view_class_init (CalendarViewClass *class);
static void calendar_view_init (CalendarView *cview);
static void calendar_view_destroy (GtkObject *object);
static void calendar_view_edit (GalView *view);
static void calendar_view_load (GalView *view, const char *filename);
static void calendar_view_save (GalView *view, const char *filename);
static const char *calendar_view_get_title (GalView *view);
static void calendar_view_set_title (GalView *view, const char *title);
static const char *calendar_view_get_type_code (GalView *view);
static GalView *calendar_view_clone (GalView *view);
static GalViewClass *parent_class = NULL;
/**
* calendar_view_get_type:
*
* Registers the #CalendarView class if necessary, and returns the type ID
* associated to it.
*
* Return value: The type ID of the #CalendarView class.
**/
GtkType
calendar_view_get_type (void)
{
static GtkType calendar_view_type;
if (!calendar_view_type) {
static const GtkTypeInfo calendar_view_info = {
"CalendarView",
sizeof (CalendarView),
sizeof (CalendarViewClass),
(GtkClassInitFunc) calendar_view_class_init,
(GtkObjectInitFunc) calendar_view_init,
NULL, /* reserved_1 */
NULL, /* reserved_2 */
(GtkClassInitFunc) NULL
};
calendar_view_type = gtk_type_unique (GAL_VIEW_TYPE, &calendar_view_info);
}
return calendar_view_type;
}
/* Class initialization function for the calendar view */
static void
calendar_view_class_init (CalendarViewClass *class)
{
GalViewClass *gal_view_class;
GtkObjectClass *object_class;
parent_class = gtk_type_class (GAL_VIEW_TYPE);
gal_view_class = (GalViewClass *) class;
object_class = (GtkObjectClass *) class;
gal_view_class->edit = calendar_view_edit;
gal_view_class->load = calendar_view_load;
gal_view_class->save = calendar_view_save;
gal_view_class->get_title = calendar_view_get_title;
gal_view_class->set_title = calendar_view_set_title;
gal_view_class->get_type_code = calendar_view_get_type_code;
gal_view_class->clone = calendar_view_clone;
object_class->destroy = calendar_view_destroy;
}
/* Object initialization function for the calendar view */
static void
calendar_view_init (CalendarView *cal_view)
{
CalendarViewPrivate *priv;
priv = g_new0 (CalendarViewPrivate, 1);
cal_view->priv = priv;
priv->title = NULL;
}
/* Destroy method for the calendar view */
static void
calendar_view_destroy (GtkObject *object)
{
CalendarView *cal_view;
CalendarViewPrivate *priv;
g_return_if_fail (object != NULL);
g_return_if_fail (IS_CALENDAR_VIEW (object));
cal_view = CALENDAR_VIEW (object);
priv = cal_view->priv;
if (priv->title) {
g_free (priv->title);
priv->title = NULL;
}
g_free (priv);
cal_view->priv = NULL;
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
/* edit method of the calendar view */
static void
calendar_view_edit (GalView *view)
{
/* nothing */
}
/* load method of the calendar view */
static void
calendar_view_load (GalView *view, const char *filename)
{
/* nothing */
}
/* save method of the calendar view */
static void
calendar_view_save (GalView *view, const char *filename)
{
/* nothing */
}
/* get_title method of the calendar view */
static const char *
calendar_view_get_title (GalView *view)
{
CalendarView *cal_view;
CalendarViewPrivate *priv;
cal_view = CALENDAR_VIEW (view);
priv = cal_view->priv;
return priv->title;
}
/* set_title method of the calendar view */
static void
calendar_view_set_title (GalView *view, const char *title)
{
CalendarView *cal_view;
CalendarViewPrivate *priv;
cal_view = CALENDAR_VIEW (view);
priv = cal_view->priv;
if (priv->title)
g_free (priv->title);
priv->title = g_strdup (title);
}
/* get_type_code method for the calendar view */
static const char *
calendar_view_get_type_code (GalView *view)
{
CalendarView *cal_view;
CalendarViewPrivate *priv;
cal_view = CALENDAR_VIEW (view);
priv = cal_view->priv;
switch (priv->view_type) {
case GNOME_CAL_DAY_VIEW:
return "day_view";
case GNOME_CAL_WORK_WEEK_VIEW:
return "work_week_view";
case GNOME_CAL_WEEK_VIEW:
return "week_view";