aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/dialogs/event-editor.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@src.gnome.org>2008-07-16 02:34:59 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2008-07-16 02:34:59 +0800
commitac0c655f3f2a8e47b0cca877aabae66421c58187 (patch)
treedd86bd195dff93b54184840e7beca7ffa5a11e99 /calendar/gui/dialogs/event-editor.c
parentc049cedd6969d77649db15b71f4ba112d4a2c065 (diff)
downloadgsoc2013-evolution-ac0c655f3f2a8e47b0cca877aabae66421c58187.tar
gsoc2013-evolution-ac0c655f3f2a8e47b0cca877aabae66421c58187.tar.gz
gsoc2013-evolution-ac0c655f3f2a8e47b0cca877aabae66421c58187.tar.bz2
gsoc2013-evolution-ac0c655f3f2a8e47b0cca877aabae66421c58187.tar.lz
gsoc2013-evolution-ac0c655f3f2a8e47b0cca877aabae66421c58187.tar.xz
gsoc2013-evolution-ac0c655f3f2a8e47b0cca877aabae66421c58187.tar.zst
gsoc2013-evolution-ac0c655f3f2a8e47b0cca877aabae66421c58187.zip
Migrate CompEditor, CompEditorPage, and the various subclasses from
BonoboUI to GtkUIManager. See bug #542125. svn path=/branches/kill-bonobo/; revision=35746
Diffstat (limited to 'calendar/gui/dialogs/event-editor.c')
-rw-r--r--calendar/gui/dialogs/event-editor.c945
1 files changed, 364 insertions, 581 deletions
diff --git a/calendar/gui/dialogs/event-editor.c b/calendar/gui/dialogs/event-editor.c
index 4b739565b7..1547a67f0e 100644
--- a/calendar/gui/dialogs/event-editor.c
+++ b/calendar/gui/dialogs/event-editor.c
@@ -30,16 +30,22 @@
#include <string.h>
#include <glade/glade.h>
#include <glib/gi18n.h>
+
#include <misc/e-dateedit.h>
#include <e-util/e-icon-factory.h>
+#include <e-util/e-plugin-ui.h>
#include <e-util/e-util-private.h>
#include <evolution-shell-component-utils.h>
+
#include "event-page.h"
#include "recurrence-page.h"
#include "schedule-page.h"
#include "cancel-comp.h"
#include "event-editor.h"
-#include "../calendar-config.h"
+
+#define EVENT_EDITOR_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), TYPE_EVENT_EDITOR, EventEditorPrivate))
struct _EventEditorPrivate {
EventPage *event_page;
@@ -49,620 +55,465 @@ struct _EventEditorPrivate {
GtkWidget *sched_window;
EMeetingStore *model;
- gboolean is_meeting;
gboolean meeting_shown;
gboolean updating;
};
-
+/* Extends the UI definition in CompEditor */
+static const gchar *ui =
+"<ui>"
+" <menubar action='main-menu'>"
+" <menu action='view-menu'>"
+" <menuitem action='view-type'/>"
+" <menuitem action='view-status'/>"
+" <menuitem action='view-role'/>"
+" <menuitem action='view-rsvp'/>"
+" <separator/>"
+" <menuitem action='view-time-zone'/>"
+" <menuitem action='view-categories'/>"
+" </menu>"
+" <menu action='insert-menu'>"
+" <menuitem action='send-options'/>"
+" </menu>"
+" <menu action='options-menu'>"
+" <menuitem action='alarms'/>"
+" <menuitem action='show-time-busy'/>"
+" <menuitem action='all-day-event'/>"
+" <menu action='classification-menu'>"
+" <menuitem action='classify-public'/>"
+" <menuitem action='classify-private'/>"
+" <menuitem action='classify-confidential'/>"
+" </menu>"
+" <menuitem action='recurrence'/>"
+" <menuitem action='free-busy'/>"
+" </menu>"
+" </menubar>"
+" <toolbar name='main-toolbar'>"
+" <toolitem action='alarms'/>"
+" <toolitem action='all-day-event'/>"
+" <toolitem action='recurrence'/>"
+" <toolitem action='free-busy'/>"
+" </toolbar>"
+"</ui>";
-static void event_editor_set_e_cal (CompEditor *editor, ECal *client);
static void event_editor_edit_comp (CompEditor *editor, ECalComponent *comp);
static gboolean event_editor_send_comp (CompEditor *editor, ECalComponentItipMethod method);
-static void event_editor_finalize (GObject *object);
-
-static void model_row_change_insert_cb (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data);
-static void model_row_delete_cb (GtkTreeModel *model, GtkTreePath *path, gpointer data);
-static gboolean window_delete_event (GtkWidget *widget, GdkEvent *event, gpointer user_data);
-static void create_schedule_page (EventEditor *ee);
G_DEFINE_TYPE (EventEditor, event_editor, TYPE_COMP_EDITOR)
-/* Class initialization function for the event editor */
static void
-event_editor_class_init (EventEditorClass *klass)
+create_schedule_page (CompEditor *editor)
{
- GObjectClass *gobject_class;
- CompEditorClass *editor_class;
+ EventEditorPrivate *priv;
+ ENameSelector *name_selector;
+ CompEditorPage *page;
- gobject_class = (GObjectClass *) klass;
- editor_class = (CompEditorClass *) klass;
+ priv = EVENT_EDITOR_GET_PRIVATE (editor);
- editor_class->set_e_cal = event_editor_set_e_cal;
- editor_class->edit_comp = event_editor_edit_comp;
- editor_class->send_comp = event_editor_send_comp;
+ priv->sched_window = gtk_dialog_new_with_buttons (
+ _("Free/Busy"), GTK_WINDOW (editor), GTK_DIALOG_MODAL,
+ GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
- gobject_class->finalize = event_editor_finalize;
-}
+ g_signal_connect (
+ priv->sched_window, "response",
+ G_CALLBACK (gtk_widget_hide), NULL);
+ g_signal_connect (
+ priv->sched_window, "delete-event",
+ G_CALLBACK (gtk_widget_hide_on_delete), NULL);
-static void
-init_widgets (EventEditor *ee)
-{
- EventEditorPrivate *priv;
+ priv->sched_page = schedule_page_new (priv->model, editor);
+ page = COMP_EDITOR_PAGE (priv->sched_page);
+ g_object_ref_sink (priv->sched_page);
+ gtk_container_add (
+ GTK_CONTAINER (GTK_DIALOG (priv->sched_window)->vbox),
+ comp_editor_page_get_widget (page));
- priv = ee->priv;
+ name_selector = event_page_get_name_selector (priv->event_page);
+ schedule_page_set_name_selector (priv->sched_page, name_selector);
- g_signal_connect((priv->model), "row_changed",
- G_CALLBACK (model_row_change_insert_cb), ee);
- g_signal_connect((priv->model), "row_inserted",
- G_CALLBACK (model_row_change_insert_cb), ee);
- g_signal_connect((priv->model), "row_deleted",
- G_CALLBACK (model_row_delete_cb), ee);
-}
+ comp_editor_append_page (editor, page, NULL, FALSE);
+ schedule_page_update_free_busy (priv->sched_page);
-static void
-client_changed_cb (CompEditorPage *page, ECal *client, gpointer user_data)
-{
- //set_menu_sens (EVENT_EDITOR (user_data));
+ gtk_widget_show_all (priv->sched_window);
}
static void
-menu_view_role_cb (BonoboUIComponent *component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- gpointer user_data)
+action_alarms_cb (GtkAction *action,
+ EventEditor *editor)
{
- EventEditor *ee = (EventEditor *) user_data;
-
- if (type != Bonobo_UIComponent_STATE_CHANGED)
- return;
- event_page_set_view_role (ee->priv->event_page, atoi(state));
- calendar_config_set_show_role (atoi(state));
+ event_page_show_alarm (editor->priv->event_page);
}
static void
-menu_view_status_cb (BonoboUIComponent *component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- gpointer user_data)
+action_all_day_event_cb (GtkToggleAction *action,
+ EventEditor *editor)
{
- EventEditor *ee = (EventEditor *) user_data;
-
- if (type != Bonobo_UIComponent_STATE_CHANGED)
- return;
+ gboolean active;
- event_page_set_view_status (ee->priv->event_page, atoi(state));
- calendar_config_set_show_status (atoi(state));
+ active = gtk_toggle_action_get_active (action);
+ event_page_set_all_day_event (editor->priv->event_page, active);
}
static void
-menu_view_type_cb (BonoboUIComponent *component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- gpointer user_data)
+action_free_busy_cb (GtkAction *action,
+ EventEditor *editor)
{
- EventEditor *ee = (EventEditor *) user_data;
-
- if (type != Bonobo_UIComponent_STATE_CHANGED)
- return;
- event_page_set_view_type (ee->priv->event_page, atoi(state));
- calendar_config_set_show_type (atoi(state));
+ if (editor->priv->sched_window == NULL)
+ create_schedule_page (COMP_EDITOR (editor));
+ else
+ gtk_widget_show (editor->priv->sched_window);
}
static void
-menu_view_rsvp_cb (BonoboUIComponent *component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- gpointer user_data)
+action_recurrence_cb (GtkAction *action,
+ EventEditor *editor)
{
- EventEditor *ee = (EventEditor *) user_data;
-
- if (type != Bonobo_UIComponent_STATE_CHANGED)
- return;
- event_page_set_view_rsvp (ee->priv->event_page, atoi(state));
- calendar_config_set_show_rsvp (atoi(state));
+ gtk_widget_show (editor->priv->recur_window);
}
static void
-menu_action_alarm_cb (BonoboUIComponent *component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- gpointer user_data)
+action_send_options_cb (GtkAction *action,
+ EventEditor *editor)
{
- EventEditor *ee = (EventEditor *) user_data;
-
- event_page_show_alarm (ee->priv->event_page);
+ event_page_sendoptions_clicked_cb (editor->priv->event_page);
}
static void
-menu_show_time_busy_cb (BonoboUIComponent *component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- gpointer user_data)
+action_show_time_busy_cb (GtkToggleAction *action,
+ EventEditor *editor)
{
- EventEditor *ee = (EventEditor *) user_data;
-
- if (type != Bonobo_UIComponent_STATE_CHANGED)
- return;
+ gboolean active;
- event_page_set_show_time_busy (ee->priv->event_page, atoi(state));
+ active = gtk_toggle_action_get_active (action);
+ event_page_set_show_time_busy (editor->priv->event_page, active);
}
-static void
-menu_all_day_event_cb (BonoboUIComponent *component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- gpointer user_data)
-{
- EventEditor *ee = (EventEditor *) user_data;
+static GtkActionEntry event_entries[] = {
- if (type != Bonobo_UIComponent_STATE_CHANGED)
- return;
- event_page_set_all_day_event (ee->priv->event_page, atoi(state));
-}
+ { "alarms",
+ "appointment-soon",
+ N_("_Alarms"),
+ NULL,
+ N_("Click here to set or unset alarms for this event"),
+ G_CALLBACK (action_alarms_cb) },
-static void
-menu_show_time_zone_cb (BonoboUIComponent *component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- gpointer user_data)
-{
- EventEditor *ee = (EventEditor *) user_data;
+ { "recurrence",
+ "stock_task-recurring",
+ N_("_Recurrence"),
+ NULL,
+ N_("Make this a recurring event"),
+ G_CALLBACK (action_recurrence_cb) },
- if (type != Bonobo_UIComponent_STATE_CHANGED)
- return;
- event_page_set_show_timezone (ee->priv->event_page, atoi(state));
- calendar_config_set_show_timezone (atoi(state));
-}
+ { "send-options",
+ NULL,
+ N_("Send Options"),
+ NULL,
+ N_("Insert advanced send options"),
+ G_CALLBACK (action_send_options_cb) }
+};
-static void
-menu_show_categories_cb (BonoboUIComponent *component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- gpointer user_data)
-{
- EventEditor *ee = (EventEditor *) user_data;
+static GtkToggleActionEntry event_toggle_entries[] = {
+
+ { "all-day-event",
+ "stock_new-24h-appointment",
+ N_("All _Day Event"),
+ NULL,
+ N_("Toggles whether to have All Day Event"),
+ G_CALLBACK (action_all_day_event_cb),
+ FALSE },
+
+ { "show-time-busy",
+ NULL,
+ N_("Show Time as _Busy"),
+ NULL,
+ N_("Toggles whether to show time as busy"),
+ G_CALLBACK (action_show_time_busy_cb),
+ FALSE }
+};
- if (type != Bonobo_UIComponent_STATE_CHANGED)
- return;
+static GtkActionEntry meeting_entries[] = {
- event_page_set_show_categories (ee->priv->event_page, atoi(state));
- calendar_config_set_show_categories (atoi(state));
-}
+ { "free-busy",
+ "query-free-busy",
+ N_("_Free/Busy"),
+ NULL,
+ N_("Query free / busy information for the attendees"),
+ G_CALLBACK (action_free_busy_cb) }
+};
static void
-menu_class_public_cb (BonoboUIComponent *ui_component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- gpointer user_data)
+event_editor_client_changed_cb (EventEditor *ee)
{
- EventEditor *ee = (EventEditor *) user_data;
- if (state[0] == '0')
- return;
-
- comp_editor_page_notify_changed (COMP_EDITOR_PAGE (ee->priv->event_page));
+ ECal *client;
- event_page_set_classification (ee->priv->event_page, E_CAL_COMPONENT_CLASS_PUBLIC);
+ client = comp_editor_get_client (COMP_EDITOR (ee));
+ e_meeting_store_set_e_cal (ee->priv->model, client);
}
static void
-menu_class_private_cb (BonoboUIComponent *ui_component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- gpointer user_data)
+event_editor_model_changed_cb (EventEditor *ee)
{
- EventEditor *ee = (EventEditor *) user_data;
- if (state[0] == '0')
- return;
-
- comp_editor_page_notify_changed (COMP_EDITOR_PAGE (ee->priv->event_page));
-
- event_page_set_classification (ee->priv->event_page, E_CAL_COMPONENT_CLASS_PRIVATE);
+ if (!ee->priv->updating) {
+ comp_editor_set_changed (COMP_EDITOR (ee), TRUE);
+ comp_editor_set_needs_send (COMP_EDITOR (ee), TRUE);
+ }
}
-static void
-menu_class_confidential_cb (BonoboUIComponent *ui_component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- gpointer user_data)
+static GObject *
+event_editor_constructor (GType type,
+ guint n_construct_properties,
+ GObjectConstructParam *construct_properties)
{
- EventEditor *ee = (EventEditor *) user_data;
- if (state[0] == '0')
- return;
-
- comp_editor_page_notify_changed (COMP_EDITOR_PAGE (ee->priv->event_page));
-
- event_page_set_classification (ee->priv->event_page, E_CAL_COMPONENT_CLASS_CONFIDENTIAL);
-}
+ GObject *object;
+ CompEditor *editor;
+ CompEditorFlags flags;
+ CompEditorPage *page;
+ EventEditorPrivate *priv;
+ GtkActionGroup *action_group;
+ ECal *client;
+ gboolean is_meeting;
-static void
-menu_action_recurrence_cb (BonoboUIComponent *ui_component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- gpointer user_data)
-{
- EventEditor *ee = (EventEditor *) user_data;
+ /* Chain up to parent's constructor() method. */
+ object = G_OBJECT_CLASS (event_editor_parent_class)->constructor (
+ type, n_construct_properties, construct_properties);
- gtk_widget_show (ee->priv->recur_window);
-}
+ editor = COMP_EDITOR (object);
+ priv = EVENT_EDITOR_GET_PRIVATE (object);
-static void
-menu_action_freebusy_cb (BonoboUIComponent *ui_component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- gpointer user_data)
-{
- EventEditor *ee = (EventEditor *) user_data;
+ client = comp_editor_get_client (editor);
+ flags = comp_editor_get_flags (editor);
+ action_group = comp_editor_get_action_group (editor, "coordinated");
- if (!ee->priv->sched_window)
- create_schedule_page (ee);
- else
- gtk_widget_show (ee->priv->sched_window);
-}
+ is_meeting = flags & COMP_EDITOR_MEETING;
-static void
-menu_action_alarm_cmd (BonoboUIComponent *uic,
- void *data,
- const char *path)
-{
- EventEditor *ee = (EventEditor *) data;
+ gtk_action_group_set_visible (action_group, is_meeting);
- event_page_show_alarm (ee->priv->event_page);
-}
+ priv->event_page = event_page_new (priv->model, editor);
+ g_object_ref_sink (priv->event_page);
+ comp_editor_append_page (
+ editor, COMP_EDITOR_PAGE (priv->event_page),
+ _("Appoint_ment"), TRUE);
+
+ priv->recur_window = gtk_dialog_new_with_buttons (
+ _("Recurrence"), GTK_WINDOW (editor), GTK_DIALOG_MODAL,
+ GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
+ g_signal_connect (
+ priv->recur_window, "response",
+ G_CALLBACK (gtk_widget_hide), NULL);
+ g_signal_connect (
+ priv->recur_window, "delete-event",
+ G_CALLBACK(gtk_widget_hide_on_delete), NULL);
+
+ priv->recur_page = recurrence_page_new (editor);
+ page = COMP_EDITOR_PAGE (priv->recur_page);
+ g_object_ref_sink (priv->recur_page);
+ gtk_container_add (
+ GTK_CONTAINER ((GTK_DIALOG (priv->recur_window)->vbox)),
+ comp_editor_page_get_widget (page));
+ gtk_widget_show_all (gtk_bin_get_child (GTK_BIN (priv->recur_window)));
+ comp_editor_append_page (editor, page, NULL, FALSE);
-static void
-menu_all_day_event_cmd (BonoboUIComponent *uic,
- void *data,
- const char *path)
-{
- /* TODO
- EventEditor *ee = (EventEditor *) data;
+ if (is_meeting) {
- event_page_set_all_day_event (ee->priv->event_page, atoi(state));*/
-}
+ if (e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_REQ_SEND_OPTIONS))
+ event_page_show_options (priv->event_page);
-static void
-menu_show_time_zone_cmd (BonoboUIComponent *uic,
- void *data,
- const char *path)
-{
- /* TODO
- EventEditor *ee = (EventEditor *) data;
+ comp_editor_set_group_item (editor, TRUE);
+ if (!((flags & COMP_EDITOR_USER_ORG) || (flags & COMP_EDITOR_DELEGATE)|| (flags & COMP_EDITOR_NEW_ITEM))) {
+ GtkAction *action;
- event_page_set_show_timezone (ee->priv->event_page, atoi(state));
- calendar_config_set_show_timezone (atoi(state)); */
-}
+ action = comp_editor_get_action (editor, "free-busy");
+ gtk_action_set_visible (action, FALSE);
+ }
-static void
-menu_action_recurrence_cmd (BonoboUIComponent *uic,
- void *data,
- const char *path)
-{
- EventEditor *ee = (EventEditor *) data;
+ event_page_set_meeting (priv->event_page, TRUE);
+ priv->meeting_shown=TRUE;
+ }
- gtk_widget_show (ee->priv->recur_window);
+ return object;
}
static void
-create_schedule_page (EventEditor *ee)
+event_editor_dispose (GObject *object)
{
- ENameSelector *name_selector;
EventEditorPrivate *priv;
- ECal *ecal = NULL;
- priv = ee->priv;
+ priv = EVENT_EDITOR_GET_PRIVATE (object);
- priv->sched_window = gtk_dialog_new_with_buttons (_("Free/Busy"),
- (GtkWindow *) ee, GTK_DIALOG_MODAL,
- "gtk-close", GTK_RESPONSE_CLOSE,
- NULL);
- priv->sched_page = schedule_page_new (priv->model);
- g_object_ref_sink (priv->sched_page);
- gtk_container_add (GTK_CONTAINER (GTK_DIALOG(priv->sched_window)->vbox), comp_editor_page_get_widget (COMP_EDITOR_PAGE (priv->sched_page)));
+ if (priv->event_page) {
+ g_object_unref (priv->event_page);
+ priv->event_page = NULL;
+ }
- g_signal_connect (priv->sched_window, "response", G_CALLBACK(gtk_widget_hide), NULL);
- g_signal_connect ((GtkWidget *) priv->sched_window, "delete-event", G_CALLBACK(window_delete_event), NULL);
- name_selector = event_page_get_name_selector (priv->event_page);
- schedule_page_set_name_selector (priv->sched_page, name_selector);
+ if (priv->recur_page) {
+ g_object_unref (priv->recur_page);
+ priv->recur_page = NULL;
+ }
- ecal = comp_editor_get_e_cal (COMP_EDITOR (ee));
- comp_editor_page_set_e_cal (COMP_EDITOR_PAGE (priv->sched_page), ecal);
- comp_editor_append_page (COMP_EDITOR (ee), COMP_EDITOR_PAGE (priv->sched_page), NULL, FALSE);
- schedule_page_update_free_busy (priv->sched_page);
+ if (priv->sched_page) {
+ g_object_unref (priv->sched_page);
+ priv->sched_page = NULL;
+ }
- gtk_widget_show_all (priv->sched_window);
+ if (priv->model) {
+ g_object_unref (priv->model);
+ priv->model = NULL;
+ }
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (event_editor_parent_class)->dispose (object);
}
static void
-menu_action_freebusy_cmd (BonoboUIComponent *uic,
- void *data,
- const char *path)
+event_editor_show_categories (CompEditor *editor,
+ gboolean visible)
{
- EventEditor *ee = (EventEditor *) data;
+ EventEditorPrivate *priv;
- if (!ee->priv->sched_window)
- create_schedule_page (ee);
- else
- gtk_widget_show (ee->priv->sched_window);
+ priv = EVENT_EDITOR_GET_PRIVATE (editor);
+
+ event_page_set_show_categories (priv->event_page, visible);
}
static void
-menu_insert_send_options_cmd (BonoboUIComponent *uic,
- void *data,
- const char *path)
+event_editor_show_role (CompEditor *editor,
+ gboolean visible)
{
- EventEditor *ee = (EventEditor *) data;
+ EventEditorPrivate *priv;
- event_page_sendoptions_clicked_cb (ee->priv->event_page);
+ priv = EVENT_EDITOR_GET_PRIVATE (editor);
+
+ event_page_set_view_role (priv->event_page, visible);
}
-static BonoboUIVerb verbs [] = {
- BONOBO_UI_VERB ("ActionAlarm", menu_action_alarm_cmd),
- BONOBO_UI_VERB ("ActionAllDayEvent", menu_all_day_event_cmd),
- BONOBO_UI_VERB ("ViewTimeZone", menu_show_time_zone_cmd),
- BONOBO_UI_VERB ("ActionRecurrence", menu_action_recurrence_cmd),
- BONOBO_UI_VERB ("ActionFreeBusy", menu_action_freebusy_cmd),
- BONOBO_UI_VERB ("InsertSendOptions", menu_insert_send_options_cmd),
+static void
+event_editor_show_rsvp (CompEditor *editor,
+ gboolean visible)
+{
+ EventEditorPrivate *priv;
- BONOBO_UI_VERB_END
-};
+ priv = EVENT_EDITOR_GET_PRIVATE (editor);
-static EPixmap pixmaps[] = {
- /* NOTE: If adding removing elements in this array, make sure
- * the indexes of the two elements where the pathname to the
- * icons is filled in at run-time in event_editor_init() are
- * updated, too.
- */
- E_PIXMAP ("/commands/ActionAlarm", "stock_alarm", E_ICON_SIZE_MENU),
- E_PIXMAP ("/commands/ActionRecurrence", "stock_task-recurring", E_ICON_SIZE_MENU),
-
- E_PIXMAP ("/Toolbar/ActionAlarm", "stock_alarm", E_ICON_SIZE_LARGE_TOOLBAR),
- E_PIXMAP ("/Toolbar/ActionAllDayEvent", "stock_new-24h-appointment", E_ICON_SIZE_LARGE_TOOLBAR),
- E_PIXMAP ("/Toolbar/ViewTimeZone", "stock_timezone", E_ICON_SIZE_LARGE_TOOLBAR),
- E_PIXMAP ("/Toolbar/ActionRecurrence", "stock_task-recurring", E_ICON_SIZE_LARGE_TOOLBAR),
-
- /* These two will have an absolute path to the png file filled
- * in at run-time, see event_editor_init().
- */
- E_PIXMAP ("/Toolbar/ActionFreeBusy", NULL, E_ICON_SIZE_LARGE_TOOLBAR),
- E_PIXMAP ("/commands/ActionFreeBusy", NULL, E_ICON_SIZE_MENU),
- E_PIXMAP_END
-};
+ event_page_set_view_rsvp (priv->event_page, visible);
+}
-/* Object initialization function for the event editor */
static void
-event_editor_init (EventEditor *ee)
+event_editor_show_status (CompEditor *editor,
+ gboolean visible)
{
EventEditorPrivate *priv;
- CompEditor *editor = COMP_EDITOR(ee);
- gboolean status;
- char *xmlfile;
-
- priv = g_new0 (EventEditorPrivate, 1);
- ee->priv = priv;
-
- priv->model = E_MEETING_STORE (e_meeting_store_new ());
- priv->meeting_shown = TRUE;
- priv->updating = FALSE;
- priv->is_meeting = FALSE;
-
- bonobo_ui_component_freeze (editor->uic, NULL);
-
- bonobo_ui_component_add_verb_list_with_data (editor->uic, verbs, ee);
-
- xmlfile = g_build_filename (EVOLUTION_UIDIR,
- "evolution-event-editor.xml",
- NULL);
- bonobo_ui_util_set_ui (editor->uic, PREFIX,
- xmlfile,
- "evolution-event-editor", NULL);
- g_free (xmlfile);
-
- /* Hide send options */
- bonobo_ui_component_set_prop (
- editor->uic, "/commands/InsertSendOptions",
- "hidden", "1", NULL);
-
- /* Show hide the status fields */
- status = calendar_config_get_show_status ();
- bonobo_ui_component_set_prop (
- editor->uic, "/commands/ViewStatus",
- "state", status ? "1" : "0", NULL);
- bonobo_ui_component_add_listener (
- editor->uic, "ViewStatus",
- menu_view_status_cb, editor);
-
- /* Show hide the type fields */
- status = calendar_config_get_show_type ();
- bonobo_ui_component_set_prop (
- editor->uic, "/commands/ViewType",
- "state", status ? "1" : "0", NULL);
- bonobo_ui_component_add_listener (
- editor->uic, "ViewType",
- menu_view_type_cb, editor);
-
- /* Show hide the role fields */
- status = calendar_config_get_show_role ();
- bonobo_ui_component_set_prop (
- editor->uic, "/commands/ViewRole",
- "state", status ? "1" : "0", NULL);
- bonobo_ui_component_add_listener (
- editor->uic, "ViewRole",
- menu_view_role_cb, editor);
-
- /* Show hide the rsvp fields */
- status = calendar_config_get_show_rsvp ();
- bonobo_ui_component_set_prop (
- editor->uic, "/commands/ViewRSVP",
- "state", status ? "1" : "0", NULL);
- bonobo_ui_component_add_listener (
- editor->uic, "ViewRSVP",
- menu_view_rsvp_cb, editor);
-
- bonobo_ui_component_add_listener (
- editor->uic, "ActionAlarm",
- menu_action_alarm_cb, editor);
-
- bonobo_ui_component_add_listener (
- editor->uic, "ActionAllDayEvent",
- menu_all_day_event_cb, editor);
-
- bonobo_ui_component_add_listener (
- editor->uic, "ActionShowTimeBusy",
- menu_show_time_busy_cb, editor);
-
- status = calendar_config_get_show_timezone ();
- bonobo_ui_component_set_prop (
- editor->uic, "/commands/ViewTimeZone",
- "state", status ? "1" : "0", NULL);
- bonobo_ui_component_add_listener (
- editor->uic, "ViewTimeZone",
- menu_show_time_zone_cb, editor);
-
- status = calendar_config_get_show_categories ();
- bonobo_ui_component_set_prop (
- editor->uic, "/commands/ViewCategories",
- "state", status ? "1" : "0", NULL);
- bonobo_ui_component_add_listener (
- editor->uic, "ViewCategories",
- menu_show_categories_cb, editor);
-
- bonobo_ui_component_set_prop (
- editor->uic, "/commands/ActionClassPublic",
- "state", "1", NULL);
- bonobo_ui_component_add_listener (
- editor->uic, "ActionClassPublic",
- menu_class_public_cb, editor);
- bonobo_ui_component_add_listener (
- editor->uic, "ActionClassPrivate",
- menu_class_private_cb, editor);
- bonobo_ui_component_add_listener (
- editor->uic, "ActionClassConfidential",
- menu_class_confidential_cb, editor);
-
- bonobo_ui_component_add_listener (
- editor->uic, "ActionRecurrence",
- menu_action_recurrence_cb, editor);
- bonobo_ui_component_add_listener (
- editor->uic, "ActionFreeBusy",
- menu_action_freebusy_cb, editor);
-
- /* NOTE: Make sure the 6 and 7 below correspond to the correct
- * elements in the pixmaps array.
- */
- if (!pixmaps[6].name) {
- pixmaps[6].name = g_build_filename (EVOLUTION_ICONSDIR, "query-free-busy.png", NULL);
- pixmaps[7].name = g_build_filename (EVOLUTION_ICONSDIR, "query-free-busy.png", NULL);
- }
- e_pixmaps_update (editor->uic, pixmaps);
- bonobo_ui_component_thaw (editor->uic, NULL);
+ priv = EVENT_EDITOR_GET_PRIVATE (editor);
- comp_editor_set_help_section (COMP_EDITOR (ee), "usage-calendar-apts");
+ event_page_set_view_status (priv->event_page, visible);
}
-/* Handler for the delete event. It hides the window without destroying it.
- Connected to the recur dialog and Free busy dialog */
-static gboolean
-window_delete_event (GtkWidget *widget, GdkEvent *event, gpointer user_data)
+static void
+event_editor_show_time_zone (CompEditor *editor,
+ gboolean visible)
{
- gtk_widget_hide (widget);
+ EventEditorPrivate *priv;
+
+ priv = EVENT_EDITOR_GET_PRIVATE (editor);
- return TRUE;
+ event_page_set_show_timezone (priv->event_page, visible);
}
-EventEditor *
-event_editor_construct (EventEditor *ee, ECal *client)
+static void
+event_editor_show_type (CompEditor *editor,
+ gboolean visible)
{
EventEditorPrivate *priv;
- CompEditor *editor = COMP_EDITOR (ee);
- guint32 flags = comp_editor_get_flags (editor);
-
- priv = ee->priv;
- priv->event_page = event_page_new (priv->model, client, COMP_EDITOR(ee)->uic);
- g_object_ref_sink (priv->event_page);
- comp_editor_append_page (COMP_EDITOR (ee),
- COMP_EDITOR_PAGE (priv->event_page),
- _("Appoint_ment"), TRUE);
- g_signal_connect (G_OBJECT (priv->event_page), "client_changed",
- G_CALLBACK (client_changed_cb), ee);
-
- priv->recur_window = gtk_dialog_new_with_buttons (_("Recurrence"),
- (GtkWindow *) ee, GTK_DIALOG_MODAL,
- "gtk-close", GTK_RESPONSE_CLOSE,
- NULL);
- g_signal_connect (priv->recur_window, "response", G_CALLBACK (gtk_widget_hide), NULL);
- g_signal_connect ((GtkWidget *) priv->recur_window, "delete-event", G_CALLBACK(window_delete_event), NULL);
- priv->recur_page = recurrence_page_new ();
- g_object_ref_sink (priv->recur_page);
- gtk_container_add ((GtkContainer *) (GTK_DIALOG (priv->recur_window)->vbox),
- comp_editor_page_get_widget (COMP_EDITOR_PAGE (priv->recur_page)));
- gtk_widget_show_all (gtk_bin_get_child (GTK_BIN (priv->recur_window)));
- comp_editor_append_page (COMP_EDITOR (ee), COMP_EDITOR_PAGE (priv->recur_page), NULL, FALSE);
- if (priv->is_meeting) {
-
- if (e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_REQ_SEND_OPTIONS))
- event_page_show_options (priv->event_page);
+ priv = EVENT_EDITOR_GET_PRIVATE (editor);
- comp_editor_set_group_item (COMP_EDITOR (ee), TRUE);
- if (!((flags & COMP_EDITOR_USER_ORG) || (flags & COMP_EDITOR_DELEGATE)|| (flags & COMP_EDITOR_NEW_ITEM)))
- bonobo_ui_component_set_prop (editor->uic, "/commands/ActionFreeBusy", "hidden", "1", NULL);
+ event_page_set_view_type (priv->event_page, visible);
+}
- event_page_set_meeting (priv->event_page, TRUE);
- priv->meeting_shown=TRUE;
- } else {
- bonobo_ui_component_set_prop (editor->uic, "/commands/ActionFreeBusy", "hidden", "1", NULL);
- bonobo_ui_component_set_prop (editor->uic, "/commands/ViewAttendee", "hidden", "1", NULL);
- bonobo_ui_component_set_prop (editor->uic, "/commands/ViewRole", "hidden", "1", NULL);
- bonobo_ui_component_set_prop (editor->uic, "/commands/ViewRSVP", "hidden", "1", NULL);
- bonobo_ui_component_set_prop (editor->uic, "/commands/ViewType", "hidden", "1", NULL);
- bonobo_ui_component_set_prop (editor->uic, "/commands/ViewStatus", "hidden", "1", NULL);
- bonobo_ui_component_set_prop (editor->uic, "/menu/View/AttendeeOptions/timezonesep", "hidden", "1", NULL);
- }
+static void
+event_editor_class_init (EventEditorClass *class)
+{
+ GObjectClass *object_class;
+ CompEditorClass *editor_class;
- comp_editor_set_e_cal (COMP_EDITOR (ee), client);
+ g_type_class_add_private (class, sizeof (EventEditorPrivate));
- init_widgets (ee);
- gtk_window_set_default_size (GTK_WINDOW (ee), 300, 225);
+ object_class = G_OBJECT_CLASS (class);
+ object_class->constructor = event_editor_constructor;
+ object_class->dispose = event_editor_dispose;
- return ee;
+ editor_class = COMP_EDITOR_CLASS (class);
+ editor_class->help_section = "usage-calendar-apts";
+ editor_class->edit_comp = event_editor_edit_comp;
+ editor_class->send_comp = event_editor_send_comp;
+ editor_class->show_categories = event_editor_show_categories;
+ editor_class->show_role = event_editor_show_role;
+ editor_class->show_rsvp = event_editor_show_rsvp;
+ editor_class->show_status = event_editor_show_status;;
+ editor_class->show_time_zone = event_editor_show_time_zone;
+ editor_class->show_type = event_editor_show_type;
}
static void
-event_editor_set_e_cal (CompEditor *editor, ECal *client)
+event_editor_init (EventEditor *ee)
{
- EventEditor *ee;
- EventEditorPrivate *priv;
+ CompEditor *editor = COMP_EDITOR (ee);
+ GtkUIManager *manager;
+ GtkActionGroup *action_group;
+ GtkAction *action;
+ GError *error = NULL;
+
+ ee->priv = EVENT_EDITOR_GET_PRIVATE (ee);
+ ee->priv->model = E_MEETING_STORE (e_meeting_store_new ());
+ ee->priv->meeting_shown = TRUE;
+ ee->priv->updating = FALSE;
+
+ action_group = comp_editor_get_action_group (editor, "individual");
+ gtk_action_group_add_actions (
+ action_group, event_entries,
+ G_N_ELEMENTS (event_entries), ee);
+ gtk_action_group_add_toggle_actions (
+ action_group, event_toggle_entries,
+ G_N_ELEMENTS (event_toggle_entries), ee);
+
+ action_group = comp_editor_get_action_group (editor, "coordinated");
+ gtk_action_group_add_actions (
+ action_group, meeting_entries,
+ G_N_ELEMENTS (meeting_entries), ee);
+
+ manager = comp_editor_get_ui_manager (editor);
+ gtk_ui_manager_add_ui_from_string (manager, ui, -1, &error);
+ e_plugin_ui_register_manager ("event-editor", manager, ee);
+
+ if (error != NULL) {
+ g_critical ("%s: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ }
+
+ /* Hide send options. */
+ action = comp_editor_get_action (editor, "send-options");
+ gtk_action_set_visible (action, FALSE);
- ee = EVENT_EDITOR (editor);
- priv = ee->priv;
+ g_signal_connect (
+ ee, "notify::client",
+ G_CALLBACK (event_editor_client_changed_cb), NULL);
- e_meeting_store_set_e_cal (priv->model, client);
+ g_signal_connect_swapped (
+ ee->priv->model, "row_changed",
+ G_CALLBACK (event_editor_model_changed_cb), ee);
+ g_signal_connect_swapped (
+ ee->priv->model, "row_inserted",
+ G_CALLBACK (event_editor_model_changed_cb), ee);
+ g_signal_connect_swapped (
+ ee->priv->model, "row_deleted",
+ G_CALLBACK (event_editor_model_changed_cb), ee);
- if (COMP_EDITOR_CLASS (event_editor_parent_class)->set_e_cal)
- COMP_EDITOR_CLASS (event_editor_parent_class)->set_e_cal (editor, client);
+ gtk_window_set_default_size (GTK_WINDOW (ee), 300, 225);
}
static void
event_editor_edit_comp (CompEditor *editor, ECalComponent *comp)
{
- EventEditor *ee;
EventEditorPrivate *priv;
ECalComponentOrganizer organizer;
gboolean delegate;
@@ -670,8 +521,7 @@ event_editor_edit_comp (CompEditor *editor, ECalComponent *comp)
ECal *client;
GSList *attendees = NULL;
- ee = EVENT_EDITOR (editor);
- priv = ee->priv;
+ priv = EVENT_EDITOR_GET_PRIVATE (editor);
priv->updating = TRUE;
delegate = (comp_editor_get_flags (COMP_EDITOR (editor)) & COMP_EDITOR_DELEGATE);
@@ -689,7 +539,7 @@ event_editor_edit_comp (CompEditor *editor, ECalComponent *comp)
if (COMP_EDITOR_CLASS (event_editor_parent_class)->edit_comp)
COMP_EDITOR_CLASS (event_editor_parent_class)->edit_comp (editor, comp);
- client = comp_editor_get_e_cal (COMP_EDITOR (editor));
+ client = comp_editor_get_client (editor);
/* Get meeting related stuff */
e_cal_component_get_organizer (comp, &organizer);
@@ -703,7 +553,10 @@ event_editor_edit_comp (CompEditor *editor, ECalComponent *comp)
user_email = itip_get_comp_attendee (comp, client);
if (!priv->meeting_shown) {
- bonobo_ui_component_set_prop (editor->uic, "/commands/ActionFreeBusy", "hidden", "0", NULL);
+ GtkAction *action;
+
+ action = comp_editor_get_action (editor, "free-busy");
+ gtk_action_set_visible (action, TRUE);
}
if (!(delegate && e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_DELEGATE_TO_MANY))) {
@@ -756,7 +609,7 @@ event_editor_edit_comp (CompEditor *editor, ECalComponent *comp)
}
e_cal_component_free_attendee_list (attendees);
- comp_editor_set_needs_send (COMP_EDITOR (ee), priv->meeting_shown && (itip_organizer_is_user (comp, client) || itip_sentby_is_user (comp)));
+ comp_editor_set_needs_send (editor, priv->meeting_shown && (itip_organizer_is_user (comp, client) || itip_sentby_is_user (comp)));
priv->updating = FALSE;
}
@@ -764,11 +617,10 @@ event_editor_edit_comp (CompEditor *editor, ECalComponent *comp)
static gboolean
event_editor_send_comp (CompEditor *editor, ECalComponentItipMethod method)
{
- EventEditor *ee = EVENT_EDITOR (editor);
EventEditorPrivate *priv;
ECalComponent *comp = NULL;
- priv = ee->priv;
+ priv = EVENT_EDITOR_GET_PRIVATE (editor);
/* Don't cancel more than once or when just publishing */
if (method == E_CAL_COMPONENT_METHOD_PUBLISH ||
@@ -785,10 +637,7 @@ event_editor_send_comp (CompEditor *editor, ECalComponentItipMethod method)
client, NULL, NULL, NULL);
g_object_unref (comp);
- if (!result)
- return FALSE;
- else
- return TRUE;
+ return result;
}
parent:
@@ -798,45 +647,6 @@ event_editor_send_comp (CompEditor *editor, ECalComponentItipMethod method)
return FALSE;
}
-/* Destroy handler for the event editor */
-static void
-event_editor_finalize (GObject *object)
-{
- EventEditor *ee;
- EventEditorPrivate *priv;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (IS_EVENT_EDITOR (object));
-
- ee = EVENT_EDITOR (object);
- priv = ee->priv;
-
- if (priv->event_page) {
- g_object_unref (priv->event_page);
- priv->event_page = NULL;
- }
-
- if (priv->recur_page) {
- g_object_unref (priv->recur_page);
- priv->recur_page = NULL;
- }
-
- if (priv->sched_page) {
- g_object_unref (priv->sched_page);
- priv->sched_page = NULL;
- }
-
- if (priv->model) {
- g_object_unref (priv->model);
- priv->model = NULL;
- }
-
- g_free (priv);
-
- if (G_OBJECT_CLASS (event_editor_parent_class)->finalize)
- (* G_OBJECT_CLASS (event_editor_parent_class)->finalize) (object);
-}
-
/**
* event_editor_new:
* @client: a ECal
@@ -846,67 +656,40 @@ event_editor_finalize (GObject *object)
* Return value: A newly-created event editor dialog, or NULL if the event
* editor could not be created.
**/
-EventEditor *
+CompEditor *
event_editor_new (ECal *client, CompEditorFlags flags)
{
- EventEditor *ee;
+ g_return_val_if_fail (E_IS_CAL (client), NULL);
- ee = EVENT_EDITOR (g_object_new (TYPE_EVENT_EDITOR, NULL));
- ee->priv->is_meeting = flags & COMP_EDITOR_MEETING;
- comp_editor_set_flags (COMP_EDITOR (ee), flags);
- return event_editor_construct (ee, client);
+ return g_object_new (
+ TYPE_EVENT_EDITOR,
+ "flags", flags, "client", client, NULL);
}
-static void
-show_meeting (EventEditor *ee)
+void
+event_editor_show_meeting (EventEditor *ee)
{
- EventEditorPrivate *priv;
- CompEditor *editor = COMP_EDITOR (ee);
- CompEditorFlags flags = comp_editor_get_flags (editor);
-
- priv = ee->priv;
-
- event_page_set_meeting (priv->event_page, TRUE);
- if (!priv->meeting_shown) {
- bonobo_ui_component_set_prop (editor->uic, "/commands/ActionFreeBusy", "hidden", "0", NULL);
+ CompEditor *editor;
+ CompEditorFlags flags;
- priv->meeting_shown = TRUE;
+ g_return_if_fail (IS_EVENT_EDITOR (ee));
- comp_editor_set_changed (COMP_EDITOR (ee), FALSE);
- comp_editor_set_needs_send (COMP_EDITOR (ee), priv->meeting_shown);
- }
+ editor = COMP_EDITOR (ee);
+ flags = comp_editor_get_flags (editor);
- if (!(flags & COMP_EDITOR_NEW_ITEM) && !(flags & COMP_EDITOR_USER_ORG))
- gtk_drag_dest_unset (GTK_WIDGET (editor));
-}
+ event_page_set_meeting (ee->priv->event_page, TRUE);
+ if (!ee->priv->meeting_shown) {
+ GtkAction *action;
-void
-event_editor_show_meeting (EventEditor *ee)
-{
- g_return_if_fail (ee != NULL);
- g_return_if_fail (IS_EVENT_EDITOR (ee));
+ action = comp_editor_get_action (editor, "free-busy");
+ gtk_action_set_visible (action, TRUE);
- show_meeting (ee);
-}
+ ee->priv->meeting_shown = TRUE;
-static void
-model_changed (EventEditor *ee)
-{
- if (!ee->priv->updating) {
- comp_editor_set_changed (COMP_EDITOR (ee), TRUE);
- comp_editor_set_needs_send (COMP_EDITOR (ee), TRUE);
+ comp_editor_set_changed (editor, FALSE);
+ comp_editor_set_needs_send (editor, TRUE);
}
-}
-static void
-model_row_change_insert_cb (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
-{
- model_changed (EVENT_EDITOR (data));
-}
-
-static void
-model_row_delete_cb (GtkTreeModel *model, GtkTreePath *path, gpointer data)
-{
- model_changed (EVENT_EDITOR (data));
+ if (!(flags & COMP_EDITOR_NEW_ITEM) && !(flags & COMP_EDITOR_USER_ORG))
+ gtk_drag_dest_unset (GTK_WIDGET (editor));
}
-