aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui
diff options
context:
space:
mode:
Diffstat (limited to 'calendar/gui')
-rw-r--r--calendar/gui/alarm-notify/alarm-notify-dialog.c354
-rw-r--r--calendar/gui/alarm-notify/alarm-queue.c167
-rw-r--r--calendar/gui/calendar-component.c254
-rw-r--r--calendar/gui/comp-editor-factory.c17
-rw-r--r--calendar/gui/dialogs/alarm-list-dialog.c4
-rw-r--r--calendar/gui/dialogs/comp-editor.c778
-rw-r--r--calendar/gui/dialogs/event-page.c131
-rw-r--r--calendar/gui/dialogs/event-page.glade71
-rw-r--r--calendar/gui/dialogs/meeting-page.c87
-rw-r--r--calendar/gui/dialogs/recurrence-page.c39
-rw-r--r--calendar/gui/dialogs/task-page.glade82
-rw-r--r--calendar/gui/e-cal-list-view.c20
-rw-r--r--calendar/gui/e-cal-model-calendar.c86
-rw-r--r--calendar/gui/e-cal-model-tasks.c60
-rw-r--r--calendar/gui/e-cal-model.c244
-rw-r--r--calendar/gui/e-calendar-table.c447
-rw-r--r--calendar/gui/e-calendar-view.c443
-rw-r--r--calendar/gui/e-day-view-config.c19
-rw-r--r--calendar/gui/e-day-view.c328
-rw-r--r--calendar/gui/e-itip-control.c29
-rw-r--r--calendar/gui/e-meeting-time-sel.c98
-rw-r--r--calendar/gui/e-week-view-event-item.c38
-rw-r--r--calendar/gui/e-week-view.c312
-rw-r--r--calendar/gui/gnome-cal.c409
-rw-r--r--calendar/gui/itip-utils.c77
-rw-r--r--calendar/gui/migration.c19
-rw-r--r--calendar/gui/print.c143
-rw-r--r--calendar/gui/tasks-component.c182
28 files changed, 2107 insertions, 2831 deletions
diff --git a/calendar/gui/alarm-notify/alarm-notify-dialog.c b/calendar/gui/alarm-notify/alarm-notify-dialog.c
index 8d60fb7c70..a84e13f66b 100644
--- a/calendar/gui/alarm-notify/alarm-notify-dialog.c
+++ b/calendar/gui/alarm-notify/alarm-notify-dialog.c
@@ -23,7 +23,6 @@
#include <stdio.h>
#include <string.h>
#include <gtk/gtkdialog.h>
-#include <gtk/gtkimage.h>
#include <gtk/gtklabel.h>
#include <gtk/gtkspinbutton.h>
#include <gtk/gtksignal.h>
@@ -35,6 +34,8 @@
#endif
#include <glade/glade.h>
#include <e-util/e-time-utils.h>
+#include <gtkhtml/gtkhtml.h>
+#include <gtkhtml/gtkhtml-stream.h>
#include <libecal/e-cal-time-util.h>
#include "alarm-notify-dialog.h"
#include "config-data.h"
@@ -42,43 +43,237 @@
#include <e-util/e-icon-factory.h>
+GtkWidget *make_html_display (gchar *widget_name, char *s1, char *s2, int scroll, int shadow);
+
/* The useful contents of the alarm notify dialog */
typedef struct {
GladeXML *xml;
GtkWidget *dialog;
- GtkWidget *title;
+ GtkWidget *close;
+ GtkWidget *snooze;
+ GtkWidget *edit;
GtkWidget *snooze_time;
- GtkWidget *minutes_label;
- GtkWidget *description;
- GtkWidget *location;
- GtkWidget *start;
- GtkWidget *end;
+ GtkWidget *html;
AlarmNotifyFunc func;
gpointer func_data;
} AlarmNotify;
-enum {
- AN_RESPONSE_EDIT = 0,
- AN_RESPONSE_SNOOZE = 1
-};
-
+/* Callback used when the notify dialog is destroyed */
+static void
+dialog_destroy_cb (GtkObject *object, gpointer data)
+{
+ AlarmNotify *an;
+
+ an = data;
+ g_object_unref (an->xml);
+ g_free (an);
+}
+
+/* Delete_event handler for the alarm notify dialog */
+static gint
+delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data)
+{
+ AlarmNotify *an;
+
+ an = data;
+ g_assert (an->func != NULL);
+
+ (* an->func) (ALARM_NOTIFY_CLOSE, -1, an->func_data);
+
+ gtk_widget_destroy (widget);
+ return TRUE;
+}
+
+/* Callback for the close button */
+static void
+close_clicked_cb (GtkWidget *widget, gpointer data)
+{
+ AlarmNotify *an;
+
+ an = data;
+ g_assert (an->func != NULL);
+
+ (* an->func) (ALARM_NOTIFY_CLOSE, -1, an->func_data);
+
+ gtk_widget_destroy (an->dialog);
+}
+
+/* Callback for the snooze button */
static void
-an_update_minutes_label (GtkSpinButton *sb, gpointer data)
+snooze_clicked_cb (GtkWidget *widget, gpointer data)
{
AlarmNotify *an;
- char *new_label;
- int snooze_timeout;
+ int snooze_time;
+
+ an = data;
+ g_assert (an->func != NULL);
- an = (AlarmNotify *) data;
+ snooze_time = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (an->snooze_time));
+ (* an->func) (ALARM_NOTIFY_SNOOZE, snooze_time, an->func_data);
- snooze_timeout = gtk_spin_button_get_value_as_int (sb);
- new_label = g_strdup (ngettext ("minute", "minutes", snooze_timeout));
- gtk_label_set_text (GTK_LABEL (an->minutes_label), new_label);
- g_free (new_label);
+ gtk_widget_destroy (an->dialog);
+}
+
+/* Callback for the edit button */
+static void
+edit_clicked_cb (GtkWidget *widget, gpointer data)
+{
+ AlarmNotify *an;
+
+ an = data;
+ g_assert (an->func != NULL);
+
+ (* an->func) (ALARM_NOTIFY_EDIT, -1, an->func_data);
+
+ gtk_widget_destroy (an->dialog);
+}
+
+static void
+url_requested_cb (GtkHTML *html, const char *url, GtkHTMLStream *stream, gpointer data)
+{
+
+ if (!strncmp ("file:///", url, strlen ("file:///"))) {
+ FILE *fp;
+ const char *filename = url + strlen ("file://");
+ char buf[4096];
+ size_t len;
+
+ fp = fopen (filename, "r");
+
+ if (fp == NULL) {
+ g_warning ("Error opening image: %s\n", url);
+ gtk_html_stream_close (stream, GTK_HTML_STREAM_ERROR);
+ return;
+ }
+
+ while ((len = fread (buf, 1, sizeof(buf), fp)) > 0)
+ gtk_html_stream_write (stream, buf, len);
+
+ if (feof (fp)) {
+ fclose (fp);
+ gtk_html_stream_close (stream, GTK_HTML_STREAM_OK);
+ return;
+ }
+
+ fclose (fp);
+ }
+
+ g_warning ("Error loading image");
+ gtk_html_stream_close (stream, GTK_HTML_STREAM_ERROR);
+ return;
+}
+
+GtkWidget *
+make_html_display (gchar *widget_name, char *s1, char *s2, int scroll, int shadow)
+{
+ GtkWidget *html, *scrolled_window;
+
+ gtk_widget_push_colormap (gdk_rgb_get_colormap ());
+
+ html = gtk_html_new();
+
+ gtk_html_set_default_content_type (GTK_HTML (html),
+ "charset=utf-8");
+ gtk_html_load_empty (GTK_HTML (html));
+
+ g_signal_connect (html, "url_requested",
+ G_CALLBACK (url_requested_cb),
+ NULL);
+
+ gtk_widget_pop_colormap();
+
+ scrolled_window = gtk_scrolled_window_new(NULL, NULL);
+
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
+ GTK_POLICY_AUTOMATIC,
+ GTK_POLICY_AUTOMATIC);
+
+
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
+ GTK_SHADOW_IN);
+
+ gtk_widget_set_size_request (scrolled_window, 300, 200);
+
+ gtk_container_add(GTK_CONTAINER (scrolled_window), html);
+
+ gtk_widget_show_all(scrolled_window);
+
+ g_object_set_data (G_OBJECT (scrolled_window), "html", html);
+ return scrolled_window;
+}
+
+static void
+write_times (GtkHTMLStream *stream, char *start, char *end)
+{
+ if (start)
+ gtk_html_stream_printf (stream, "<b>%s</b> %s<br>", _("Starting:"), start);
+ if (end)
+ gtk_html_stream_printf (stream, "<b>%s</b> %s<br>", _("Ending:"), end);
+
+}
+
+/* Creates a heading for the alarm notification dialog */
+static void
+write_html_heading (GtkHTMLStream *stream, const char *message,
+ ECalComponentVType vtype, time_t occur_start, time_t occur_end)
+{
+ char *start, *end;
+ char *bg_path = "file://" EVOLUTION_IMAGESDIR "/bcg.png";
+ gchar *image_path;
+ gchar *icon_path;
+ icaltimezone *current_zone;
+
+ icon_path = e_icon_factory_get_icon_filename ("stock_alarm", E_ICON_SIZE_DIALOG);
+ image_path = g_strdup_printf ("file://%s", icon_path);
+ g_free (icon_path);
+
+ /* Stringize the times */
+
+ current_zone = config_data_get_timezone ();
+
+ start = timet_to_str_with_zone (occur_start, current_zone);
+ end = timet_to_str_with_zone (occur_end, current_zone);
+
+ /* Write the header */
+
+ gtk_html_stream_printf (stream,
+ "<HTML><BODY background=\"%s\">"
+ "<TABLE WIDTH=\"100%%\">"
+ "<TR>"
+ "<TD><IMG SRC=\"%s\" ALIGN=\"top\" BORDER=\"0\"></TD>"
+ "<TD><H1>%s</H1></TD>"
+ "</TR>"
+ "</TABLE>",
+ bg_path,
+ image_path,
+ _("Evolution Alarm"));
+
+ gtk_html_stream_printf (stream, "<br><br><font size=\"+2\">%s</font><br><br>", message);
+
+ /* Write the times */
+
+ switch (vtype) {
+ case E_CAL_COMPONENT_EVENT:
+ write_times (stream, start, end);
+ break;
+
+ case E_CAL_COMPONENT_TODO:
+ write_times (stream, start, end);
+ break;
+
+ default:
+ /* Only VEVENTs and VTODOs can have alarms */
+ g_assert_not_reached ();
+ break;
+ }
+
+ g_free (start);
+ g_free (end);
+ g_free (image_path);
}
/**
@@ -87,9 +282,7 @@ an_update_minutes_label (GtkSpinButton *sb, gpointer data)
* @occur_start: Start of occurrence time for the event.
* @occur_end: End of occurrence time for the event.
* @vtype: Type of the component which corresponds to the alarm.
- * @summary: Short summary of the appointment
- * @description: Long description of the appointment
- * @location: Location of the appointment
+ * @message; Message to display in the dialog; usually comes from the component.
* @func: Function to be called when a dialog action is invoked.
* @func_data: Closure data for @func.
*
@@ -98,30 +291,23 @@ an_update_minutes_label (GtkSpinButton *sb, gpointer data)
*
* Return value: a pointer to the dialog structure if successful or NULL if an error occurs.
**/
-void
+gpointer
alarm_notify_dialog (time_t trigger, time_t occur_start, time_t occur_end,
- ECalComponentVType vtype, const char *summary,
- const char *description, const char *location,
+ ECalComponentVType vtype, const char *message,
AlarmNotifyFunc func, gpointer func_data)
{
AlarmNotify *an;
- GtkWidget *image;
+ GtkHTMLStream *stream;
icaltimezone *current_zone;
- char *title;
- char *start, *end;
- char *icon_path;
+ char *buf, *title;
GList *icon_list;
- int snooze_timeout;
- g_return_if_fail (trigger != -1);
+ g_return_val_if_fail (trigger != -1, NULL);
/* Only VEVENTs or VTODOs can have alarms */
- g_return_if_fail (vtype == E_CAL_COMPONENT_EVENT
- || vtype == E_CAL_COMPONENT_TODO);
- g_return_if_fail (summary != NULL);
- g_return_if_fail (description != NULL);
- g_return_if_fail (location != NULL);
- g_return_if_fail (func != NULL);
+ g_return_val_if_fail (vtype == E_CAL_COMPONENT_EVENT || vtype == E_CAL_COMPONENT_TODO, NULL);
+ g_return_val_if_fail (message != NULL, NULL);
+ g_return_val_if_fail (func != NULL, NULL);
an = g_new0 (AlarmNotify, 1);
@@ -132,61 +318,66 @@ alarm_notify_dialog (time_t trigger, time_t occur_start, time_t occur_end,
if (!an->xml) {
g_message ("alarm_notify_dialog(): Could not load the Glade XML file!");
g_free (an);
- return;
+ return NULL;
}
an->dialog = glade_xml_get_widget (an->xml, "alarm-notify");
- an->title = glade_xml_get_widget (an->xml, "title-label");
+ an->close = glade_xml_get_widget (an->xml, "close");
+ an->snooze = glade_xml_get_widget (an->xml, "snooze");
+ an->edit = glade_xml_get_widget (an->xml, "edit");
an->snooze_time = glade_xml_get_widget (an->xml, "snooze-time");
- an->minutes_label = glade_xml_get_widget (an->xml, "minutes-label");
- an->description = glade_xml_get_widget (an->xml, "description-label");
- an->location = glade_xml_get_widget (an->xml, "location-label");
- an->start = glade_xml_get_widget (an->xml, "start-label");
- an->end = glade_xml_get_widget (an->xml, "end-label");
-
- if (!(an->dialog && an->title && an->snooze_time
- && an->description && an->location && an->start && an->end)) {
+ an->html = g_object_get_data (G_OBJECT (glade_xml_get_widget (an->xml, "frame")), "html");
+
+ if (!(an->dialog && an->close && an->snooze && an->edit
+ && an->snooze_time)) {
g_message ("alarm_notify_dialog(): Could not find all widgets in Glade file!");
g_object_unref (an->xml);
g_free (an);
- return;
+ return NULL;
}
gtk_widget_realize (an->dialog);
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (an->dialog)->vbox), 0);
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (an->dialog)->action_area), 12);
- image = glade_xml_get_widget (an->xml, "alarm-image");
- icon_path = e_icon_factory_get_icon_filename ("stock_alarm", E_ICON_SIZE_DIALOG);
- gtk_image_set_from_file (GTK_IMAGE (image), icon_path);
- g_free (icon_path);
+ g_signal_connect (G_OBJECT (an->dialog), "destroy",
+ G_CALLBACK (dialog_destroy_cb),
+ an);
/* Title */
- gtk_window_set_title (GTK_WINDOW (an->dialog), summary);
+ current_zone = config_data_get_timezone ();
- /* Set the widget contents */
+ buf = timet_to_str_with_zone (trigger, current_zone);
+ title = g_strdup_printf (_("Alarm on %s"), buf);
+ g_free (buf);
- title = g_strdup_printf ("<big><b>%s</b></big>", summary);
- gtk_label_set_markup (GTK_LABEL (an->title), title);
+ gtk_window_set_title (GTK_WINDOW (an->dialog), title);
g_free (title);
- gtk_label_set_text (GTK_LABEL (an->description), description);
- gtk_label_set_text (GTK_LABEL (an->location), location);
+ /* html heading */
+ stream = gtk_html_begin (GTK_HTML (an->html));
+ write_html_heading (stream, message, vtype, occur_start, occur_end);
+ gtk_html_stream_close (stream, GTK_HTML_STREAM_OK);
- /* Stringize the times */
+ /* Connect actions */
- current_zone = config_data_get_timezone ();
+ g_signal_connect (an->dialog, "delete_event",
+ G_CALLBACK (delete_event_cb),
+ an);
- start = timet_to_str_with_zone (occur_start, current_zone);
- gtk_label_set_text (GTK_LABEL (an->start), start);
+ g_signal_connect (an->close, "clicked",
+ G_CALLBACK (close_clicked_cb),
+ an);
- end = timet_to_str_with_zone (occur_end, current_zone);
- gtk_label_set_text (GTK_LABEL (an->end), end);
+ g_signal_connect (an->snooze, "clicked",
+ G_CALLBACK (snooze_clicked_cb),
+ an);
+
+ g_signal_connect (an->edit, "clicked",
+ G_CALLBACK (edit_clicked_cb),
+ an);
- /* Set callback for updating the snooze "minutes" label */
- g_signal_connect (G_OBJECT (an->snooze_time), "value_changed",
- G_CALLBACK (an_update_minutes_label), an);
/* Run! */
if (!GTK_WIDGET_REALIZED (an->dialog))
@@ -199,20 +390,15 @@ alarm_notify_dialog (time_t trigger, time_t occur_start, time_t occur_end,
g_list_free (icon_list);
}
- switch (gtk_dialog_run (GTK_DIALOG (an->dialog))) {
- case AN_RESPONSE_EDIT:
- (* an->func) (ALARM_NOTIFY_EDIT, -1, an->func_data);
- break;
- case AN_RESPONSE_SNOOZE:
- snooze_timeout = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (an->snooze_time));
- (* an->func) (ALARM_NOTIFY_SNOOZE, snooze_timeout, an->func_data);
- break;
- case GTK_RESPONSE_CLOSE:
- case GTK_RESPONSE_DELETE_EVENT:
- break;
- }
- gtk_widget_destroy (an->dialog);
-
- g_object_unref (an->xml);
- g_free (an);
+ gtk_widget_show (an->dialog);
+ return an;
+}
+
+void
+alarm_notify_dialog_disable_buttons (gpointer dialog)
+{
+ AlarmNotify *an = dialog;
+
+ gtk_widget_set_sensitive (an->snooze, FALSE);
+ gtk_widget_set_sensitive (an->edit, FALSE);
}
diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c
index 9e1519d1a6..223fd6fa9f 100644
--- a/calendar/gui/alarm-notify/alarm-queue.c
+++ b/calendar/gui/alarm-notify/alarm-queue.c
@@ -51,7 +51,6 @@
#include "alarm-queue.h"
#include "config-data.h"
#include "util.h"
-#include "e-util/e-popup.h"
@@ -699,9 +698,7 @@ edit_component (ECal *client, ECalComponent *comp)
}
typedef struct {
- char *summary;
- char *description;
- char *location;
+ char *message;
gboolean blink_state;
gint blink_id;
time_t trigger;
@@ -732,6 +729,8 @@ on_dialog_objs_removed_cb (ECal *client, GList *objects, gpointer data)
continue;
if (!strcmp (uid, our_uid)) {
+ if (tray_data->alarm_dialog)
+ alarm_notify_dialog_disable_buttons (tray_data->alarm_dialog);
tray_data->cqa = NULL;
tray_data->alarm_id = NULL;
@@ -767,6 +766,7 @@ notify_dialog_cb (AlarmNotifyResult result, int snooze_mins, gpointer data)
g_assert_not_reached ();
}
+ tray_data->alarm_dialog = NULL;
gtk_widget_destroy (tray_data->tray_icon);
}
@@ -781,19 +781,9 @@ tray_icon_destroyed_cb (GtkWidget *tray, gpointer user_data)
if (tray_data->cqa != NULL)
remove_queued_alarm (tray_data->cqa, tray_data->alarm_id, TRUE, TRUE);
- if (tray_data->summary != NULL) {
- g_free (tray_data->summary);
- tray_data->summary = NULL;
- }
-
- if (tray_data->description != NULL) {
- g_free (tray_data->description);
- tray_data->description = NULL;
- }
-
- if (tray_data->location != NULL) {
- g_free (tray_data->location);
- tray_data->location = NULL;
+ if (tray_data->message != NULL) {
+ g_free (tray_data->message);
+ tray_data->message = NULL;
}
if (tray_data->blink_id)
@@ -810,37 +800,67 @@ tray_icon_destroyed_cb (GtkWidget *tray, gpointer user_data)
}
/* Callbacks. */
+static void
+add_popup_menu_item (GtkMenu *menu, const char *label, const char *pixmap,
+ GCallback callback, gpointer user_data)
+{
+ GtkWidget *item, *image;
+
+ if (pixmap) {
+ item = gtk_image_menu_item_new_with_label (label);
+
+ /* load the image */
+ if (g_file_test (pixmap, G_FILE_TEST_EXISTS))
+ image = gtk_image_new_from_file (pixmap);
+ else
+ image = gtk_image_new_from_stock (pixmap, GTK_ICON_SIZE_MENU);
+
+ if (image) {
+ gtk_widget_show (image);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
+ }
+ } else {
+ item = gtk_menu_item_new_with_label (label);
+ }
+
+ if (callback)
+ g_signal_connect (G_OBJECT (item), "activate", callback, user_data);
+
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+ gtk_widget_show (item);
+}
+
static gboolean
open_alarm_dialog (TrayIconData *tray_data)
{
QueuedAlarm *qa;
+ if (tray_data->alarm_dialog != NULL)
+ return FALSE;
+
qa = lookup_queued_alarm (tray_data->cqa, tray_data->alarm_id);
if (qa) {
gtk_widget_hide (tray_data->tray_icon);
- alarm_notify_dialog (tray_data->trigger,
- qa->instance->occur_start,
- qa->instance->occur_end,
- e_cal_component_get_vtype (tray_data->comp),
- tray_data->summary,
- tray_data->description,
- tray_data->location,
- notify_dialog_cb, tray_data);
+ tray_data->alarm_dialog = alarm_notify_dialog (
+ tray_data->trigger,
+ qa->instance->occur_start,
+ qa->instance->occur_end,
+ e_cal_component_get_vtype (tray_data->comp),
+ tray_data->message,
+ notify_dialog_cb, tray_data);
}
return TRUE;
}
static void
-popup_dismiss_cb (EPopup *ep, EPopupItem *pitem, void *data)
+popup_dismiss_cb (GtkWidget *widget, TrayIconData *tray_data)
{
- TrayIconData *tray_data = data;
-
gtk_widget_destroy (tray_data->tray_icon);
}
static void
-popup_dismiss_all_cb (EPopup *ep, EPopupItem *pitem, void *data)
+popup_dismiss_all_cb (GtkWidget *widget, TrayIconData *tray_data)
{
while (tray_icons_list != NULL) {
TrayIconData *tray_data = tray_icons_list->data;
@@ -852,25 +872,11 @@ popup_dismiss_all_cb (EPopup *ep, EPopupItem *pitem, void *data)
}
static void
-popup_open_cb (EPopup *ep, EPopupItem *pitem, void *data)
+popup_open_cb (GtkWidget *widget, TrayIconData *tray_data)
{
- TrayIconData *tray_data = data;
-
open_alarm_dialog (tray_data);
}
-static EPopupItem tray_items[] = {
- { E_POPUP_ITEM, "00.open", N_("Open"), popup_open_cb, NULL, GTK_STOCK_OPEN },
- { E_POPUP_ITEM, "10.dismiss", N_("Dismiss"), popup_dismiss_cb, NULL, NULL },
- { E_POPUP_ITEM, "20.dismissall", N_("Dismiss All"), popup_dismiss_all_cb, NULL, NULL },
-};
-
-static void
-tray_popup_free(EPopup *ep, GSList *items, void *data)
-{
- g_slist_free(items);
-}
-
static gint
tray_icon_clicked_cb (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
{
@@ -880,17 +886,17 @@ tray_icon_clicked_cb (GtkWidget *widget, GdkEventButton *event, gpointer user_da
if (event->button == 1) {
return open_alarm_dialog (tray_data);
} else if (event->button == 3) {
- GtkMenu *menu;
- GSList *menus = NULL;
- EPopup *ep;
- int i;
-
- ep = e_popup_new("org.gnome.evolution.alarmNotify.popup");
- for (i=0;i<sizeof(tray_items)/sizeof(tray_items[0]);i++)
- menus = g_slist_prepend(menus, &tray_items[i]);
- e_popup_add_items(ep, menus, NULL, tray_popup_free, tray_data);
- menu = e_popup_create_menu_once(ep, NULL, 0);
- gtk_menu_popup(menu, NULL, NULL, NULL, NULL, event->button, event->time);
+ GtkWidget *menu;
+
+ /* display popup menu */
+ menu = gtk_menu_new ();
+ add_popup_menu_item (GTK_MENU (menu), _("Open"), GTK_STOCK_OPEN,
+ G_CALLBACK (popup_open_cb), tray_data);
+ add_popup_menu_item (GTK_MENU (menu), _("Dismiss"), NULL,
+ G_CALLBACK (popup_dismiss_cb), tray_data);
+ add_popup_menu_item (GTK_MENU (menu), _("Dismiss All"), NULL,
+ G_CALLBACK (popup_dismiss_all_cb), tray_data);
+ gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, event->button, event->time);
return TRUE;
}
@@ -924,14 +930,15 @@ display_notification (time_t trigger, CompQueuedAlarms *cqa,
{
QueuedAlarm *qa;
ECalComponent *comp;
- const char *summary, *description, *location;
+ const char *message;
+ ECalComponentAlarm *alarm;
GtkWidget *tray_icon, *image, *ebox;
GtkTooltips *tooltips;
TrayIconData *tray_data;
ECalComponentText text;
- GSList *text_list;
char *str, *start_str, *end_str, *alarm_str;
icaltimezone *current_zone;
+ GdkPixbuf *pixbuf;
comp = cqa->alarms->comp;
qa = lookup_queued_alarm (cqa, alarm_id);
@@ -939,37 +946,29 @@ display_notification (time_t trigger, CompQueuedAlarms *cqa,
return;
/* get a sensible description for the event */
- e_cal_component_get_summary (comp, &text);
-
- if (text.value)
- summary = text.value;
- else
- summary = _("No summary available.");
+ alarm = e_cal_component_get_alarm (comp, qa->instance->auid);
+ g_assert (alarm != NULL);
- e_cal_component_get_description_list (comp, &text_list);
+ e_cal_component_alarm_get_description (alarm, &text);
+ e_cal_component_alarm_free (alarm);
- if (text_list) {
- text = *((ECalComponentText *)text_list->data);
- if (text.value)
- description = text.value;
- else
- description = _("No description available.");
- } else {
- description = _("No description available.");
+ if (text.value)
+ message = text.value;
+ else {
+ e_cal_component_get_summary (comp, &text);
+ if (text.value)
+ message = text.value;
+ else
+ message = _("No description available.");
}
- e_cal_component_free_text_list (text_list);
-
- e_cal_component_get_location (comp, &location);
-
- if (!location)
- location = _("No location information available.");
-
/* create the tray icon */
tooltips = gtk_tooltips_new ();
- tray_icon = GTK_WIDGET (egg_tray_icon_new (qa->instance->auid));
- image = e_icon_factory_get_image ("stock_appointment-reminder", E_ICON_SIZE_LARGE_TOOLBAR);
+ tray_icon = egg_tray_icon_new (qa->instance->auid);
+ pixbuf = e_icon_factory_get_icon ("stock_appointment-reminder", E_ICON_SIZE_LARGE_TOOLBAR);
+ image = gtk_image_new_from_pixbuf (pixbuf);
+ gdk_pixbuf_unref (pixbuf);
ebox = gtk_event_box_new ();
gtk_widget_show (image);
@@ -980,7 +979,7 @@ display_notification (time_t trigger, CompQueuedAlarms *cqa,
start_str = timet_to_str_with_zone (qa->instance->occur_start, current_zone);
end_str = timet_to_str_with_zone (qa->instance->occur_end, current_zone);
str = g_strdup_printf (_("Alarm on %s\n%s\nStarting at %s\nEnding at %s"),
- alarm_str, summary, start_str, end_str);
+ alarm_str, message, start_str, end_str);
gtk_tooltips_set_tip (GTK_TOOLTIPS (tooltips), ebox, str, str);
g_free (start_str);
g_free (end_str);
@@ -995,9 +994,7 @@ display_notification (time_t trigger, CompQueuedAlarms *cqa,
/* create the private structure */
tray_data = g_new0 (TrayIconData, 1);
- tray_data->summary = g_strdup (summary);
- tray_data->description = g_strdup (description);
- tray_data->location = g_strdup (location);
+ tray_data->message = g_strdup (message);
tray_data->trigger = trigger;
tray_data->cqa = cqa;
tray_data->alarm_id = alarm_id;
diff --git a/calendar/gui/calendar-component.c b/calendar/gui/calendar-component.c
index 2f641bcd4b..41d5a0c8ab 100644
--- a/calendar/gui/calendar-component.c
+++ b/calendar/gui/calendar-component.c
@@ -31,9 +31,7 @@
#include <bonobo/bonobo-i18n.h>
#include <bonobo/bonobo-exception.h>
#include <libical/icalvcal.h>
-#include <libedataserver/e-url.h>
#include <libecal/e-cal-time-util.h>
-#include <libedataserverui/e-source-selector.h>
#include <shell/e-user-creatable-items-handler.h>
#include "e-pub-utils.h"
#include "e-calendar-view.h"
@@ -51,11 +49,9 @@
#include "dialogs/comp-editor.h"
#include "dialogs/copy-source-dialog.h"
#include "dialogs/event-editor.h"
+#include "widgets/misc/e-source-selector.h"
#include "widgets/misc/e-info-label.h"
-#include "widgets/misc/e-error.h"
#include "e-util/e-icon-factory.h"
-#include "e-cal-menu.h"
-#include "e-cal-popup.h"
/* IDs for user creatable items */
#define CREATE_EVENT_ID "event"
@@ -312,127 +308,133 @@ update_primary_task_selection (CalendarComponentView *component_view)
/* Callbacks. */
static void
-copy_calendar_cb (EPopup *ep, EPopupItem *pitem, void *data)
+add_popup_menu_item (GtkMenu *menu, const char *label, const char *icon_name,
+ GCallback callback, gpointer user_data, gboolean sensitive)
+{
+ GtkWidget *item, *image;
+ GdkPixbuf *pixbuf;
+
+ if (icon_name) {
+ item = gtk_image_menu_item_new_with_label (label);
+
+ /* load the image */
+ pixbuf = e_icon_factory_get_icon (icon_name, E_ICON_SIZE_MENU);
+ image = gtk_image_new_from_pixbuf (pixbuf);
+
+ if (image) {
+ gtk_widget_show (image);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
+ }
+ } else {
+ item = gtk_menu_item_new_with_label (label);
+ }
+
+ if (callback)
+ g_signal_connect (G_OBJECT (item), "activate", callback, user_data);
+
+ if (!sensitive)
+ gtk_widget_set_sensitive (item, FALSE);
+
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+ gtk_widget_show (item);
+}
+
+static void
+copy_calendar_cb (GtkWidget *widget, CalendarComponentView *component_view)
{
- CalendarComponentView *component_view = data;
ESource *selected_source;
selected_source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (component_view->source_selector));
if (!selected_source)
return;
- copy_source_dialog (GTK_WINDOW (gtk_widget_get_toplevel (ep->target->widget)), selected_source, E_CAL_SOURCE_TYPE_EVENT);
+ copy_source_dialog (GTK_WINDOW (gtk_widget_get_toplevel (widget)), selected_source, E_CAL_SOURCE_TYPE_EVENT);
}
static void
-delete_calendar_cb (EPopup *ep, EPopupItem *pitem, void *data)
+delete_calendar_cb (GtkWidget *widget, CalendarComponentView *component_view)
{
- CalendarComponentView *component_view = data;
ESource *selected_source;
- ECal *cal;
- char *uri;
+ GtkWidget *dialog;
selected_source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (component_view->source_selector));
if (!selected_source)
return;
- if (e_error_run((GtkWindow *)gtk_widget_get_toplevel(ep->target->widget),
- "calendar:prompt-delete-calendar", e_source_peek_name(selected_source)) != GTK_RESPONSE_YES)
- return;
-
- /* first, ask the backend to remove the calendar */
- uri = e_source_get_uri (selected_source);
- cal = e_cal_model_get_client_for_uri (gnome_calendar_get_calendar_model (component_view->calendar), uri);
- if (!cal)
- cal = e_cal_new_from_uri (uri, E_CAL_SOURCE_TYPE_EVENT);
- g_free (uri);
- if (cal) {
- if (e_cal_remove (cal, NULL)) {
- if (e_source_selector_source_is_selected (E_SOURCE_SELECTOR (component_view->source_selector),
- selected_source)) {
- gnome_calendar_remove_source (component_view->calendar, E_CAL_SOURCE_TYPE_EVENT, selected_source);
- e_source_selector_unselect_source (E_SOURCE_SELECTOR (component_view->source_selector),
- selected_source);
+ /* create the confirmation dialog */
+ dialog = gtk_message_dialog_new (
+ GTK_WINDOW (gtk_widget_get_toplevel (widget)),
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_YES_NO,
+ _("Calendar '%s' will be removed. Are you sure you want to continue?"),
+ e_source_peek_name (selected_source));
+ if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_YES) {
+ ECal *cal;
+ char *uri;
+
+ /* first, ask the backend to remove the calendar */
+ uri = e_source_get_uri (selected_source);
+ cal = e_cal_model_get_client_for_uri (gnome_calendar_get_calendar_model (component_view->calendar), uri);
+ if (!cal)
+ cal = e_cal_new_from_uri (uri, E_CAL_SOURCE_TYPE_EVENT);
+ g_free (uri);
+ if (cal) {
+ if (e_cal_remove (cal, NULL)) {
+ if (e_source_selector_source_is_selected (E_SOURCE_SELECTOR (component_view->source_selector),
+ selected_source)) {
+ gnome_calendar_remove_source (component_view->calendar, E_CAL_SOURCE_TYPE_EVENT, selected_source);
+ e_source_selector_unselect_source (E_SOURCE_SELECTOR (component_view->source_selector),
+ selected_source);
+ }
+
+ e_source_group_remove_source (e_source_peek_group (selected_source), selected_source);
+ e_source_list_sync (component_view->source_list, NULL);
}
-
- e_source_group_remove_source (e_source_peek_group (selected_source), selected_source);
- e_source_list_sync (component_view->source_list, NULL);
}
}
+
+ gtk_widget_destroy (dialog);
}
static void
-new_calendar_cb (EPopup *ep, EPopupItem *pitem, void *data)
+new_calendar_cb (GtkWidget *widget, CalendarComponentView *component_view)
{
- calendar_setup_edit_calendar (GTK_WINDOW (gtk_widget_get_toplevel(ep->target->widget)), NULL, pitem->user_data);
+ calendar_setup_new_calendar (GTK_WINDOW (gtk_widget_get_toplevel (widget)));
}
static void
-edit_calendar_cb (EPopup *ep, EPopupItem *pitem, void *data)
+edit_calendar_cb (GtkWidget *widget, CalendarComponentView *component_view)
{
- CalendarComponentView *component_view = data;
ESource *selected_source;
selected_source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (component_view->source_selector));
if (!selected_source)
return;
- calendar_setup_edit_calendar (GTK_WINDOW (gtk_widget_get_toplevel(ep->target->widget)), selected_source, NULL);
+ calendar_setup_edit_calendar (GTK_WINDOW (gtk_widget_get_toplevel (widget)), selected_source);
}
-static EPopupItem ecc_source_popups[] = {
- { E_POPUP_ITEM, "10.new", N_("New Calendar"), new_calendar_cb, NULL, "stock_calendar", 0, 0 },
- { E_POPUP_ITEM, "15.copy", N_("Copy"), copy_calendar_cb, NULL, "stock_folder-copy", 0, E_CAL_POPUP_SOURCE_PRIMARY },
- { E_POPUP_ITEM, "20.delete", N_("Delete"), delete_calendar_cb, NULL, "stock_delete", 0, E_CAL_POPUP_SOURCE_USER|E_CAL_POPUP_SOURCE_PRIMARY },
- { E_POPUP_ITEM, "30.properties", N_("Properties..."), edit_calendar_cb, NULL, "stock_folder-properties", 0, E_CAL_POPUP_SOURCE_PRIMARY },
-};
-
static void
-ecc_source_popup_free(EPopup *ep, GSList *list, void *data)
+fill_popup_menu_cb (ESourceSelector *selector, GtkMenu *menu, CalendarComponentView *component_view)
{
- g_slist_free(list);
-}
-
-static gboolean
-popup_event_cb(ESourceSelector *selector, ESource *insource, GdkEventButton *event, CalendarComponentView *component_view)
-{
- ECalPopup *ep;
- ECalPopupTargetSource *t;
- GSList *menus = NULL;
- int i;
- GtkMenu *menu;
-
- /** @HookPoint-ECalPopup: Calendar Source Selector Context Menu
- * @Id: org.gnome.evolution.calendar.source.popup
- * @Class: org.gnome.evolution.calendar.popup:1.0
- * @Target: ECalPopupTargetSource
- *
- * The context menu on the source selector in the calendar window.
- */
- ep = e_cal_popup_new("org.gnome.evolution.calendar.source.popup");
- t = e_cal_popup_target_new_source(ep, selector);
- t->target.widget = (GtkWidget *)component_view->calendar;
-
- if (!insource) {
-
- ESourceGroup *group;
-
- group = e_source_selector_get_primary_source_group (selector);
- g_object_ref (group);
- ((EPopupItem) ecc_source_popups [0]).user_data = group;
- menus = g_slist_prepend (menus, &ecc_source_popups [0]);
- }
- else {
- for (i=1;i<sizeof(ecc_source_popups)/sizeof(ecc_source_popups[0]);i++)
- menus = g_slist_prepend(menus, &ecc_source_popups[i]);
- }
-
- e_popup_add_items((EPopup *)ep, menus, NULL, ecc_source_popup_free, component_view);
-
- menu = e_popup_create_menu_once((EPopup *)ep, (EPopupTarget *)t, 0);
- gtk_menu_popup(menu, NULL, NULL, NULL, NULL, event?event->button:0, event?event->time:gtk_get_current_event_time());
+ ESource *source;
+ gboolean sensitive, system;
+ const char *source_uri;
+
+ source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (component_view->source_selector));
+ sensitive = source ? TRUE : FALSE;
- return TRUE;
+ /* FIXME Gross hack, should have a property or something */
+ source_uri = e_source_peek_relative_uri (source);
+ system = source_uri && !strcmp ("system", source_uri);
+
+ add_popup_menu_item (menu, _("New Calendar"), "stock_calendar",
+ G_CALLBACK (new_calendar_cb), component_view, TRUE);
+ add_popup_menu_item (menu, _("Copy"), "stock_folder-copy",
+ G_CALLBACK (copy_calendar_cb), component_view, sensitive);
+ add_popup_menu_item (menu, _("Delete"), "stock_delete", G_CALLBACK (delete_calendar_cb), component_view, sensitive && !system);
+ add_popup_menu_item (menu, _("Properties..."), NULL, G_CALLBACK (edit_calendar_cb), component_view, sensitive);
}
static void
@@ -618,73 +620,9 @@ conf_changed_callback (GConfClient *client,
e_pub_publish (TRUE);
}
-/* Evolution::Component CORBA methods. */
-static void
-impl_handleURI (PortableServer_Servant servant, const char *uri, CORBA_Environment *ev)
-{
- CalendarComponent *calendar_component = CALENDAR_COMPONENT (bonobo_object_from_servant (servant));
- CalendarComponentPrivate *priv;
-
- priv = calendar_component->priv;
- if (!strncmp (uri, "calendar:", 9)) {
- EUri *euri = e_uri_new (uri);
- const char *p;
- char *header, *content;
- size_t len, clen;
- time_t start = -1, end = -1;
-
- p = euri->query;
- if (p) {
- while (*p) {
- len = strcspn (p, "=&");
-
- /* If it's malformed, give up. */
- if (p[len] != '=')
- break;
-
- header = (char *) p;
- header[len] = '\0';
- p += len + 1;
-
- clen = strcspn (p, "&");
-
- content = g_strndup (p, clen);
- if (!g_ascii_strcasecmp (header, "startdate")) {
- start = time_from_isodate (content);
- } else if (!g_ascii_strcasecmp (header, "enddate")) {
- end = time_from_isodate (content);
- }
-
- g_free (content);
-
- p += clen;
- if (*p == '&') {
- p++;
- if (!strcmp (p, "amp;"))
- p += 4;
- }
- }
-
- if (start != -1) {
- GList *l;
-
- if (end == -1)
- end = start;
-
- l = g_list_last (priv->views);
- if (l) {
- CalendarComponentView *view = l->data;
-
- gnome_calendar_set_selected_time_range (view->calendar, start, end);
- }
- }
- }
-
- e_uri_free (euri);
- }
-}
+/* Evolution::Component CORBA methods. */
static void
impl_upgradeFromVersion (PortableServer_Servant servant,
@@ -1055,7 +993,7 @@ create_new_event (CalendarComponent *calendar_component, CalendarComponentView *
ECalComponent *comp;
EventEditor *editor;
- editor = event_editor_new (ecal, is_meeting);
+ editor = event_editor_new (ecal);
comp = cal_comp_event_new_with_current_time (ecal, is_allday);
e_cal_component_commit_sequence (comp);
@@ -1107,7 +1045,6 @@ create_component_view (CalendarComponent *calendar_component)
GtkWidget *selector_scrolled_window, *vbox;
GtkWidget *statusbar_widget;
guint not;
- AtkObject *a11y;
priv = calendar_component->priv;
@@ -1120,9 +1057,7 @@ create_component_view (CalendarComponent *calendar_component)
/* Create sidebar selector */
component_view->source_selector = e_source_selector_new (calendar_component->priv->source_list);
- e_source_selector_set_select_new ((ESourceSelector *)component_view->source_selector, TRUE);
- a11y = gtk_widget_get_accessible (GTK_WIDGET (component_view->source_selector));
- atk_object_set_name (a11y, _("Calendar Source Selector"));
+ e_source_selector_set_select_new (component_view->source_selector, TRUE);
g_signal_connect (component_view->source_selector, "drag-motion", G_CALLBACK (selector_tree_drag_motion),
calendar_component);
@@ -1189,8 +1124,8 @@ create_component_view (CalendarComponent *calendar_component)
G_CALLBACK (source_selection_changed_cb), component_view);
g_signal_connect (component_view->source_selector, "primary_selection_changed",
G_CALLBACK (primary_source_selection_changed_cb), component_view);
- g_signal_connect (component_view->source_selector, "popup_event",
- G_CALLBACK (popup_event_cb), component_view);
+ g_signal_connect (component_view->source_selector, "fill_popup_menu",
+ G_CALLBACK (fill_popup_menu_cb), component_view);
/* Set up the "new" item handler */
component_view->creatable_items_handler = e_user_creatable_items_handler_new ("calendar", create_local_item_cb, calendar_component);
@@ -1443,7 +1378,6 @@ calendar_component_class_init (CalendarComponentClass *class)
epv->createControls = impl_createControls;
epv->_get_userCreatableItems = impl__get_userCreatableItems;
epv->requestCreateItem = impl_requestCreateItem;
- epv->handleURI = impl_handleURI;
object_class->dispose = impl_dispose;
object_class->finalize = impl_finalize;
diff --git a/calendar/gui/comp-editor-factory.c b/calendar/gui/comp-editor-factory.c
index 62d24f4467..71470ee648 100644
--- a/calendar/gui/comp-editor-factory.c
+++ b/calendar/gui/comp-editor-factory.c
@@ -26,7 +26,7 @@
#include <bonobo/bonobo-exception.h>
#include <bonobo/bonobo-i18n.h>
#include <evolution-calendar.h>
-#include <libedataserver/e-url.h>
+#include <e-util/e-url.h>
#include <libecal/e-cal.h>
#include "calendar-config.h"
#include "e-comp-editor-registry.h"
@@ -269,11 +269,11 @@ edit_existing (OpenClient *oc, const char *uid)
switch (vtype) {
case E_CAL_COMPONENT_EVENT:
- editor = COMP_EDITOR (event_editor_new (oc->client, e_cal_component_has_attendees (comp)));
+ editor = COMP_EDITOR (event_editor_new (oc->client));
break;
case E_CAL_COMPONENT_TODO:
- editor = COMP_EDITOR (task_editor_new (oc->client, e_cal_component_has_attendees (comp)));
+ editor = COMP_EDITOR (task_editor_new (oc->client));
break;
default:
@@ -311,19 +311,16 @@ edit_new (OpenClient *oc, const GNOME_Evolution_Calendar_CompEditorFactory_CompE
switch (type) {
case GNOME_Evolution_Calendar_CompEditorFactory_EDITOR_MODE_EVENT:
- editor = COMP_EDITOR (event_editor_new (oc->client, FALSE));
- comp = cal_comp_event_new_with_current_time (oc->client, FALSE);
- break;
case GNOME_Evolution_Calendar_CompEditorFactory_EDITOR_MODE_MEETING:
- editor = COMP_EDITOR (event_editor_new (oc->client, TRUE));
+ editor = COMP_EDITOR (event_editor_new (oc->client));
comp = cal_comp_event_new_with_current_time (oc->client, FALSE);
break;
case GNOME_Evolution_Calendar_CompEditorFactory_EDITOR_MODE_ALLDAY_EVENT:
- editor = COMP_EDITOR (event_editor_new (oc->client, FALSE));
+ editor = COMP_EDITOR (event_editor_new (oc->client));
comp = cal_comp_event_new_with_current_time (oc->client, TRUE);
break;
case GNOME_Evolution_Calendar_CompEditorFactory_EDITOR_MODE_TODO:
- editor = COMP_EDITOR (task_editor_new (oc->client, FALSE));
+ editor = COMP_EDITOR (task_editor_new (oc->client));
comp = get_default_task (oc->client);
break;
default:
@@ -478,7 +475,7 @@ open_client (CompEditorFactory *factory, ECalSourceType source_type, const char
g_hash_table_insert (priv->uri_client_hash, oc->uri, oc);
if (!e_cal_open (oc->client, FALSE, &error)) {
- g_warning (G_STRLOC ": %s", error->message);
+ g_warning (_("open_client(): %s"), error->message);
g_free (oc->uri);
g_object_unref (oc->client);
g_free (oc);
diff --git a/calendar/gui/dialogs/alarm-list-dialog.c b/calendar/gui/dialogs/alarm-list-dialog.c
index 88460e0935..31d98e6087 100644
--- a/calendar/gui/dialogs/alarm-list-dialog.c
+++ b/calendar/gui/dialogs/alarm-list-dialog.c
@@ -237,10 +237,6 @@ alarm_list_dialog_run (GtkWidget *parent, ECal *ecal, EAlarmList *list_store)
sensitize_buttons (&dialog);
- gtk_widget_ensure_style (dialog.toplevel);
- gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog.toplevel)->vbox), 0);
- gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog.toplevel)->action_area), 12);
-
icon_list = e_icon_factory_get_icon_list ("stock_calendar");
if (icon_list) {
gtk_window_set_icon_list (GTK_WINDOW (dialog.toplevel), icon_list);
diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c
index 4ba8900b3a..49b0a43715 100644
--- a/calendar/gui/dialogs/comp-editor.c
+++ b/calendar/gui/dialogs/comp-editor.c
@@ -29,7 +29,6 @@
#include <glib.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtkstock.h>
-#include <libgnome/libgnome.h>
#include <libgnome/gnome-i18n.h>
#include <libgnomeui/gnome-uidefs.h>
#include <libgnomeui/gnome-dialog.h>
@@ -38,16 +37,6 @@
#include <e-util/e-dialog-utils.h>
#include <e-util/e-icon-factory.h>
#include <evolution-shell-component-utils.h>
-
-#include <camel/camel-url.h>
-#include <camel/camel-exception.h>
-#include <camel/camel-folder.h>
-#include <camel/camel-stream-mem.h>
-#include <camel/camel-mime-message.h>
-
-#include "mail/mail-tools.h"
-#include "mail/em-popup.h"
-
#include "../print.h"
#include "../comp-util.h"
#include "save-comp.h"
@@ -58,13 +47,6 @@
#include "recur-comp.h"
#include "comp-editor.h"
-#include "cal-attachment-bar.h"
-#include "widgets/misc/e-expander.h"
-#include "widgets/misc/e-error.h"
-
-
-#define d(x) x
-
/* Private part of the CompEditor structure */
@@ -86,17 +68,6 @@ struct _CompEditorPrivate {
/* Notebook to hold the pages */
GtkNotebook *notebook;
-
- /* Attachment handling */
- GtkWidget *attachment_bar;
- GtkWidget *attachment_scrolled_window;
- GtkWidget *attachment_expander;
- GtkWidget *attachment_expander_label;
- GtkWidget *attachment_expander_icon;
- GtkWidget *attachment_expander_num;
-
- guint32 attachment_bar_visible : 1;
-
gboolean changed;
gboolean needs_send;
@@ -105,18 +76,16 @@ struct _CompEditorPrivate {
gboolean existing_org;
gboolean user_org;
- gboolean is_group_item;
gboolean warned;
-
- char *help_section;
};
+static void comp_editor_class_init (CompEditorClass *class);
+static void comp_editor_init (CompEditor *editor);
static gint comp_editor_key_press_event (GtkWidget *d, GdkEventKey *e);
static void comp_editor_finalize (GObject *object);
-static void comp_editor_show_help (CompEditor *editor);
static void real_set_e_cal (CompEditor *editor, ECal *client);
static void real_edit_comp (CompEditor *editor, ECalComponent *comp);
@@ -133,366 +102,12 @@ static void page_dates_changed_cb (GtkObject *obj, CompEditorPageDates *dates, g
static void obj_modified_cb (ECal *client, GList *objs, gpointer data);
static void obj_removed_cb (ECal *client, GList *uids, gpointer data);
-G_DEFINE_TYPE (CompEditor, comp_editor, GTK_TYPE_DIALOG);
-
-enum {
- DND_TYPE_MESSAGE_RFC822,
- DND_TYPE_X_UID_LIST,
- DND_TYPE_TEXT_URI_LIST,
- DND_TYPE_NETSCAPE_URL,
- DND_TYPE_TEXT_VCARD,
- DND_TYPE_TEXT_CALENDAR,
-};
-
-static GtkTargetEntry drop_types[] = {
- { "message/rfc822", 0, DND_TYPE_MESSAGE_RFC822 },
- { "x-uid-list", 0, DND_TYPE_X_UID_LIST },
- { "text/uri-list", 0, DND_TYPE_TEXT_URI_LIST },
- { "_NETSCAPE_URL", 0, DND_TYPE_NETSCAPE_URL },
- { "text/x-vcard", 0, DND_TYPE_TEXT_VCARD },
- { "text/calendar", 0, DND_TYPE_TEXT_CALENDAR },
-};
-
-#define num_drop_types (sizeof (drop_types) / sizeof (drop_types[0]))
-
-static struct {
- char *target;
- GdkAtom atom;
- guint32 actions;
-} drag_info[] = {
- { "message/rfc822", 0, GDK_ACTION_COPY },
- { "x-uid-list", 0, GDK_ACTION_ASK|GDK_ACTION_MOVE|GDK_ACTION_COPY },
- { "text/uri-list", 0, GDK_ACTION_COPY },
- { "_NETSCAPE_URL", 0, GDK_ACTION_COPY },
- { "text/x-vcard", 0, GDK_ACTION_COPY },
- { "text/calendar", 0, GDK_ACTION_COPY },
-};
-
-static void
-attach_message(CompEditor *editor, CamelMimeMessage *msg)
-{
- CamelMimePart *mime_part;
- const char *subject;
-
- mime_part = camel_mime_part_new();
- camel_mime_part_set_disposition(mime_part, "inline");
- subject = camel_mime_message_get_subject(msg);
- if (subject) {
- char *desc = g_strdup_printf(_("Attached message - %s"), subject);
-
- camel_mime_part_set_description(mime_part, desc);
- g_free(desc);
- } else
- camel_mime_part_set_description(mime_part, _("Attached message"));
-
- camel_medium_set_content_object((CamelMedium *)mime_part, (CamelDataWrapper *)msg);
- camel_mime_part_set_content_type(mime_part, "message/rfc822");
- cal_attachment_bar_attach_mime_part(CAL_ATTACHMENT_BAR(editor->priv->attachment_bar), mime_part);
- camel_object_unref(mime_part);
-}
-
-struct _drop_data {
- CompEditor *editor;
-
- GdkDragContext *context;
- /* Only selection->data and selection->length are valid */
- GtkSelectionData *selection;
-
- guint32 action;
- guint info;
- guint time;
-
- unsigned int move:1;
- unsigned int moved:1;
- unsigned int aborted:1;
-};
-
-static void
-drop_action(CompEditor *editor, GdkDragContext *context, guint32 action, GtkSelectionData *selection, guint info, guint time)
-{
- char *tmp, *str, **urls;
- CamelMimePart *mime_part;
- CamelStream *stream;
- CamelURL *url;
- CamelMimeMessage *msg;
- char *content_type;
- int i, success=FALSE, delete=FALSE;
-
- switch (info) {
- case DND_TYPE_MESSAGE_RFC822:
- d(printf ("dropping a message/rfc822\n"));
- /* write the message(s) out to a CamelStream so we can use it */
- stream = camel_stream_mem_new ();
- camel_stream_write (stream, selection->data, selection->length);
- camel_stream_reset (stream);
-
- msg = camel_mime_message_new ();
- if (camel_data_wrapper_construct_from_stream((CamelDataWrapper *)msg, stream) != -1) {
- attach_message(editor, msg);
- success = TRUE;
- delete = action == GDK_ACTION_MOVE;
- }
-
- camel_object_unref(msg);
- camel_object_unref(stream);
- break;
- case DND_TYPE_TEXT_URI_LIST:
- case DND_TYPE_NETSCAPE_URL:
- d(printf ("dropping a text/uri-list\n"));
- tmp = g_strndup (selection->data, selection->length);
- urls = g_strsplit (tmp, "\n", 0);
- g_free (tmp);
-
- for (i = 0; urls[i] != NULL; i++) {
- str = g_strstrip (urls[i]);
- if (urls[i][0] == '#') {
- g_free(str);
- continue;
- }
-
- if (!g_ascii_strncasecmp (str, "mailto:", 7)) {
- /* TODO does not handle mailto now */
- g_free (str);
- } else {
- url = camel_url_new (str, NULL);
- g_free (str);
-
- if (url == NULL)
- continue;
-
- if (!g_ascii_strcasecmp (url->protocol, "file"))
- cal_attachment_bar_attach
- (CAL_ATTACHMENT_BAR (editor->priv->attachment_bar),
- url->path);
-
- camel_url_free (url);
- }
- }
-
- g_free (urls);
- success = TRUE;
- break;
- case DND_TYPE_TEXT_VCARD:
- case DND_TYPE_TEXT_CALENDAR:
- content_type = gdk_atom_name (selection->type);
- d(printf ("dropping a %s\n", content_type));
-
- mime_part = camel_mime_part_new ();
- camel_mime_part_set_content (mime_part, selection->data, selection->length, content_type);
- camel_mime_part_set_disposition (mime_part, "inline");
-
- cal_attachment_bar_attach_mime_part
- (CAL_ATTACHMENT_BAR (editor->priv->attachment_bar),
- mime_part);
-
- camel_object_unref (mime_part);
- g_free (content_type);
-
- success = TRUE;
- break;
- case DND_TYPE_X_UID_LIST: {
- GPtrArray *uids;
- char *inptr, *inend;
- CamelFolder *folder;
- CamelException ex = CAMEL_EXCEPTION_INITIALISER;
-
- /* NB: This all runs synchronously, could be very slow/hang/block the ui */
-
- uids = g_ptr_array_new();
-
- inptr = selection->data;
- inend = selection->data + selection->length;
- while (inptr < inend) {
- char *start = inptr;
-
- while (inptr < inend && *inptr)
- inptr++;
-
- if (start > (char *)selection->data)
- g_ptr_array_add(uids, g_strndup(start, inptr-start));
-
- inptr++;
- }
-
- if (uids->len > 0) {
- folder = mail_tool_uri_to_folder(selection->data, 0, &ex);
- if (folder) {
- if (uids->len == 1) {
- msg = camel_folder_get_message(folder, uids->pdata[0], &ex);
- if (msg == NULL)
- goto fail;
- attach_message(editor, msg);
- } else {
- CamelMultipart *mp = camel_multipart_new();
- char *desc;
-
- camel_data_wrapper_set_mime_type((CamelDataWrapper *)mp, "multipart/digest");
- camel_multipart_set_boundary(mp, NULL);
- for (i=0;i<uids->len;i++) {
- msg = camel_folder_get_message(folder, uids->pdata[i], &ex);
- if (msg) {
- mime_part = camel_mime_part_new();
- camel_mime_part_set_disposition(mime_part, "inline");
- camel_medium_set_content_object((CamelMedium *)mime_part, (CamelDataWrapper *)msg);
- camel_mime_part_set_content_type(mime_part, "message/rfc822");
- camel_multipart_add_part(mp, mime_part);
- camel_object_unref(mime_part);
- camel_object_unref(msg);
- } else {
- camel_object_unref(mp);
- goto fail;
- }
- }
- mime_part = camel_mime_part_new();
- camel_medium_set_content_object((CamelMedium *)mime_part, (CamelDataWrapper *)mp);
- /* translators, this count will always be >1 */
- desc = g_strdup_printf(ngettext("Attached message", "%d attached messages", uids->len), uids->len);
- camel_mime_part_set_description(mime_part, desc);
- g_free(desc);
- cal_attachment_bar_attach_mime_part
- (CAL_ATTACHMENT_BAR(editor->priv->attachment_bar), mime_part);
- camel_object_unref(mime_part);
- camel_object_unref(mp);
- }
- success = TRUE;
- delete = action == GDK_ACTION_MOVE;
- fail:
- if (camel_exception_is_set(&ex)) {
- char *name;
-
- camel_object_get(folder, NULL, CAMEL_FOLDER_NAME, &name, NULL);
- e_error_run((GtkWindow *)editor, "mail-editor:attach-nomessages",
- name?name:(char *)selection->data, camel_exception_get_description(&ex), NULL);
- camel_object_free(folder, CAMEL_FOLDER_NAME, name);
- }
- camel_object_unref(folder);
- } else {
- e_error_run((GtkWindow *)editor, "mail-editor:attach-nomessages",
- selection->data, camel_exception_get_description(&ex), NULL);
- }
-
- camel_exception_clear(&ex);
- }
-
- g_ptr_array_free(uids, TRUE);
-
- break; }
- default:
- d(printf ("dropping an unknown\n"));
- break;
- }
-
- printf("Drag finished, success %d delete %d\n", success, delete);
-
- gtk_drag_finish(context, success, delete, time);
-}
-
-static void
-drop_popup_copy (EPopup *ep, EPopupItem *item, void *data)
-{
- struct _drop_data *m = data;
- drop_action(m->editor, m->context, GDK_ACTION_COPY, m->selection, m->info, m->time);
-}
-
-static void
-drop_popup_move (EPopup *ep, EPopupItem *item, void *data)
-{
- struct _drop_data *m = data;
- drop_action(m->editor, m->context, GDK_ACTION_MOVE, m->selection, m->info, m->time);
-}
-
-static void
-drop_popup_cancel(EPopup *ep, EPopupItem *item, void *data)
-{
- struct _drop_data *m = data;
- gtk_drag_finish(m->context, FALSE, FALSE, m->time);
-}
-
-static EPopupItem drop_popup_menu[] = {
- { E_POPUP_ITEM, "00.emc.02", N_("_Copy"), drop_popup_copy, NULL, "stock_mail-copy", 0 },
- { E_POPUP_ITEM, "00.emc.03", N_("_Move"), drop_popup_move, NULL, "stock_mail-move", 0 },
- { E_POPUP_BAR, "10.emc" },
- { E_POPUP_ITEM, "99.emc.00", N_("Cancel _Drag"), drop_popup_cancel, NULL, NULL, 0 },
-};
-
-static void
-drop_popup_free(EPopup *ep, GSList *items, void *data)
-{
- struct _drop_data *m = data;
-
- g_slist_free(items);
-
- g_object_unref(m->context);
- g_object_unref(m->editor);
- g_free(m->selection->data);
- g_free(m->selection);
- g_free(m);
-}
-
-static void
-drag_data_received (CompEditor *editor, GdkDragContext *context,
- int x, int y, GtkSelectionData *selection,
- guint info, guint time)
-{
- if (selection->data == NULL || selection->length == -1)
- return;
-
- if (context->action == GDK_ACTION_ASK) {
- EMPopup *emp;
- GSList *menus = NULL;
- GtkMenu *menu;
- int i;
- struct _drop_data *m;
-
- m = g_malloc0(sizeof(*m));
- m->context = context;
- g_object_ref(context);
- m->editor = editor;
- g_object_ref(editor);
- m->action = context->action;
- m->info = info;
- m->time = time;
- m->selection = g_malloc0(sizeof(*m->selection));
- m->selection->data = g_malloc(selection->length);
- memcpy(m->selection->data, selection->data, selection->length);
- m->selection->length = selection->length;
-
- emp = em_popup_new("org.gnome.evolution.mail.editor.popup.drop");
- for (i=0;i<sizeof(drop_popup_menu)/sizeof(drop_popup_menu[0]);i++)
- menus = g_slist_append(menus, &drop_popup_menu[i]);
-
- e_popup_add_items((EPopup *)emp, menus, NULL, drop_popup_free, m);
- menu = e_popup_create_menu_once((EPopup *)emp, NULL, 0);
- gtk_menu_popup(menu, NULL, NULL, NULL, NULL, 0, time);
- } else {
- drop_action(editor, context, context->action, selection, info, time);
- }
-}
+static GtkObjectClass *parent_class;
-static gboolean
-drag_motion(GObject *o, GdkDragContext *context, gint x, gint y, guint time, CompEditor *editor)
-{
- GList *targets;
- GdkDragAction action, actions = 0;
-
- for (targets = context->targets; targets; targets = targets->next) {
- int i;
-
- for (i=0;i<sizeof(drag_info)/sizeof(drag_info[0]);i++)
- if (targets->data == (void *)drag_info[i].atom)
- actions |= drag_info[i].actions;
- }
-
- actions &= context->actions;
- action = context->suggested_action;
- /* we default to copy */
- if (action == GDK_ACTION_ASK && (actions & (GDK_ACTION_MOVE|GDK_ACTION_COPY)) != (GDK_ACTION_MOVE|GDK_ACTION_COPY))
- action = GDK_ACTION_COPY;
+
- gdk_drag_status(context, action, time);
-
- return action != 0;
-}
+E_MAKE_TYPE (comp_editor, "CompEditor", CompEditor, comp_editor_class_init, comp_editor_init,
+ GTK_TYPE_DIALOG);
/* Class initialization function for the calendar component editor */
static void
@@ -500,13 +115,8 @@ comp_editor_class_init (CompEditorClass *klass)
{
GObjectClass *object_class;
GtkWidgetClass *widget_class;
- GObjectClass *gobject_class;
- int i;
-
- for (i=0;i<sizeof(drag_info)/sizeof(drag_info[0]);i++)
- drag_info[i].atom = gdk_atom_intern(drag_info[i].target, FALSE);
- gobject_class = G_OBJECT_CLASS(klass);
+ parent_class = g_type_class_peek_parent (klass);
object_class = G_OBJECT_CLASS (klass);
widget_class = GTK_WIDGET_CLASS (klass);
@@ -639,11 +249,6 @@ save_comp (CompEditor *editor)
/* send timezones */
g_hash_table_foreach (timezones, (GHFunc) send_timezone, editor);
g_hash_table_destroy (timezones);
-
- /* Attachments*/
-
- e_cal_component_set_attachment_list (priv->comp,
- cal_attachment_bar_get_attachment_list ((CalAttachmentBar *) priv->attachment_bar));
/* send the component to the server */
if (!cal_comp_is_on_server (priv->comp, priv->client)) {
@@ -730,7 +335,7 @@ prompt_to_save_changes (CompEditor *editor, gboolean send)
if (e_cal_component_is_instance (priv->comp))
if (!recur_component_dialog (priv->client, priv->comp, &priv->mod, GTK_WINDOW (editor)))
return FALSE;
-
+
if (send && save_comp_with_send (editor))
return TRUE;
else if (!send && save_comp (editor))
@@ -750,10 +355,9 @@ response_cb (GtkWidget *widget, int response, gpointer data)
{
CompEditor *editor = COMP_EDITOR (data);
CompEditorPrivate *priv;
- ECalComponentText text;
priv = editor->priv;
-
+
switch (response) {
case GTK_RESPONSE_OK:
commit_all_fields (editor);
@@ -761,206 +365,40 @@ response_cb (GtkWidget *widget, int response, gpointer data)
if (e_cal_component_is_instance (priv->comp))
if (!recur_component_dialog (priv->client, priv->comp, &priv->mod, GTK_WINDOW (editor)))
return;
-
- if (save_comp_with_send (editor)) {
-
- e_cal_component_get_summary (priv->comp, &text);
- if (!text.value) {
- if (!send_component_prompt_subject ((GtkWindow *) editor, priv->client, priv->comp))
- return;
- }
+ if (save_comp_with_send (editor))
close_dialog (editor);
- }
-
- break;
- case GTK_RESPONSE_HELP:
- comp_editor_show_help (editor);
-
break;
case GTK_RESPONSE_CANCEL:
+ case GTK_RESPONSE_DELETE_EVENT:
commit_all_fields (editor);
if (prompt_to_save_changes (editor, TRUE))
close_dialog (editor);
break;
- default:
- /* We handle delete event below */
- break;
}
}
-static int
-delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data)
-{
- CompEditor *editor = COMP_EDITOR (data);
- CompEditorPrivate *priv;
- ECalComponentText text;
-
- priv = editor->priv;
-
- commit_all_fields (editor);
-
- if (prompt_to_save_changes (editor, TRUE))
- close_dialog (editor);
-
- return TRUE;
-}
-
-static void
-attachment_bar_changed_cb (CalAttachmentBar *bar,
- void *data)
-{
- CompEditor *editor = COMP_EDITOR (data);
-
- guint attachment_num = cal_attachment_bar_get_num_attachments (
- CAL_ATTACHMENT_BAR (editor->priv->attachment_bar));
- if (attachment_num) {
- gchar *num_text = g_strdup_printf (
- ngettext ("<b>%d</b> File Attached", "<b>%d</b> Files Attached", attachment_num),
- attachment_num);
- gtk_label_set_markup (GTK_LABEL (editor->priv->attachment_expander_num),
- num_text);
- g_free (num_text);
-
- gtk_widget_show (editor->priv->attachment_expander_icon);
-
- } else {
- gtk_label_set_text (GTK_LABEL (editor->priv->attachment_expander_num), "");
- gtk_widget_hide (editor->priv->attachment_expander_icon);
- }
-
-
- /* Mark the editor as changed so it prompts about unsaved
- changes on close */
- comp_editor_set_changed (editor, TRUE);
-
-}
-
-static void
-attachment_bar_icon_clicked_cb (CalAttachmentBar *bar, void *data)
-{
- GnomeIconList *icon_list;
- GList *p;
- int num;
- char *attach_file_url;
- GError *error = NULL;
-
- icon_list = GNOME_ICON_LIST (bar);
- p = gnome_icon_list_get_selection (icon_list);
- if (p) {
- num = GPOINTER_TO_INT (p->data);
- attach_file_url = cal_attachment_bar_get_nth_attachment_filename (bar, num);
- /* launch the url now */
- /* TODO should send GError and handle error conditions
- * here */
- gnome_url_show (attach_file_url, &error);
- if (error)
- g_message ("DEBUG: Launch failed :(\n");
- g_free (attach_file_url); }
-}
-
-static void
-attachment_expander_activate_cb (EExpander *expander,
- void *data)
-{
- CompEditor *editor = COMP_EDITOR (data);
- gboolean show = e_expander_get_expanded (expander);
-
- /* Update the expander label */
- if (show)
- gtk_label_set_text_with_mnemonic (GTK_LABEL (editor->priv->attachment_expander_label),
- _("Hide _Attachment Bar (drop attachments here)"));
- else
- gtk_label_set_text_with_mnemonic (GTK_LABEL (editor->priv->attachment_expander_label),
- _("Show _Attachment Bar (drop attachments here)"));
-
-}
-
/* Creates the basic in the editor */
static void
setup_widgets (CompEditor *editor)
{
CompEditorPrivate *priv;
- GtkWidget *expander_hbox, *vbox;
- GdkPixbuf *attachment_pixbuf;
priv = editor->priv;
- /* Useful vbox */
- vbox = gtk_vbox_new (FALSE, 12);
- gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (editor)->vbox), vbox, TRUE, TRUE, 0);
- gtk_widget_show (vbox);
-
/* Notebook */
priv->notebook = GTK_NOTEBOOK (gtk_notebook_new ());
gtk_widget_show (GTK_WIDGET (priv->notebook));
- gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (priv->notebook),
- TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (editor)->vbox), GTK_WIDGET (priv->notebook),
+ TRUE, TRUE, 6);
/* Buttons */
gtk_dialog_add_button (GTK_DIALOG (editor), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
gtk_dialog_add_button (GTK_DIALOG (editor), GTK_STOCK_OK, GTK_RESPONSE_OK);
- gtk_dialog_add_button (GTK_DIALOG (editor), GTK_STOCK_HELP, GTK_RESPONSE_HELP);
gtk_dialog_set_response_sensitive (GTK_DIALOG (editor), GTK_RESPONSE_OK, FALSE);
g_signal_connect (editor, "response", G_CALLBACK (response_cb), editor);
- g_signal_connect (editor, "delete_event", G_CALLBACK (delete_event_cb), editor);
-
- /*Attachments */
- priv->attachment_scrolled_window = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (priv->attachment_scrolled_window),
- GTK_SHADOW_IN);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->attachment_scrolled_window),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
-
- priv->attachment_bar = cal_attachment_bar_new (NULL);
- GTK_WIDGET_SET_FLAGS (priv->attachment_bar, GTK_CAN_FOCUS);
- gtk_container_add (GTK_CONTAINER (priv->attachment_scrolled_window),
- priv->attachment_bar);
- gtk_widget_show (priv->attachment_bar);
- g_signal_connect (priv->attachment_bar, "changed",
- G_CALLBACK (attachment_bar_changed_cb), editor);
- g_signal_connect (GNOME_ICON_LIST (priv->attachment_bar), "button-release-event",
- G_CALLBACK (attachment_bar_icon_clicked_cb), NULL);
- priv->attachment_expander_label =
- gtk_label_new_with_mnemonic (_("Show _Attachment Bar (drop attachments here)"));
- priv->attachment_expander_num = gtk_label_new ("");
- gtk_label_set_use_markup (GTK_LABEL (priv->attachment_expander_num), TRUE);
- gtk_misc_set_alignment (GTK_MISC (priv->attachment_expander_label), 0.0, 0.5);
- gtk_misc_set_alignment (GTK_MISC (priv->attachment_expander_num), 1.0, 0.5);
- expander_hbox = gtk_hbox_new (FALSE, 0);
-
- attachment_pixbuf = e_icon_factory_get_icon ("stock_attach", E_ICON_SIZE_MENU);
- priv->attachment_expander_icon = gtk_image_new_from_pixbuf (attachment_pixbuf);
- gtk_misc_set_alignment (GTK_MISC (priv->attachment_expander_icon), 1, 0.5);
- gtk_widget_set_size_request (priv->attachment_expander_icon, 100, -1);
- g_object_unref (attachment_pixbuf);
-
- gtk_box_pack_start (GTK_BOX (expander_hbox), priv->attachment_expander_label,
- TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (expander_hbox), priv->attachment_expander_icon,
- TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (expander_hbox), priv->attachment_expander_num,
- TRUE, TRUE, 0);
- gtk_widget_show_all (expander_hbox);
- gtk_widget_hide (priv->attachment_expander_icon);
-
- priv->attachment_expander = e_expander_new ("");
- e_expander_set_label_widget (E_EXPANDER (priv->attachment_expander), expander_hbox);
- atk_object_set_name (gtk_widget_get_accessible (priv->attachment_expander), _("Attachment Button: Press space key to toggle attachment bar"));
-
- gtk_container_add (GTK_CONTAINER (priv->attachment_expander),
- priv->attachment_scrolled_window);
- gtk_box_pack_start (GTK_BOX (vbox), priv->attachment_expander,
- FALSE, FALSE, GNOME_PAD_SMALL);
- gtk_widget_show (priv->attachment_expander);
- e_expander_set_expanded (E_EXPANDER (priv->attachment_expander), FALSE);
- g_signal_connect_after (priv->attachment_expander, "activate",
- G_CALLBACK (attachment_expander_activate_cb), editor);
-
-
}
/* Object initialization function for the calendar component editor */
@@ -981,20 +419,8 @@ comp_editor_init (CompEditor *editor)
priv->existing_org = FALSE;
priv->user_org = FALSE;
priv->warned = FALSE;
- priv->is_group_item = FALSE;
- priv->help_section = g_strdup ("usage-calendar");
-
- /* DND support */
- gtk_drag_dest_set (GTK_WIDGET (editor), GTK_DEST_DEFAULT_ALL, drop_types, num_drop_types, GDK_ACTION_COPY|GDK_ACTION_ASK|GDK_ACTION_MOVE);
- g_signal_connect(editor, "drag_data_received", G_CALLBACK (drag_data_received), NULL);
- g_signal_connect(editor, "drag-motion", G_CALLBACK(drag_motion), editor);
gtk_window_set_type_hint (GTK_WINDOW (editor), GDK_WINDOW_TYPE_HINT_NORMAL);
- gtk_dialog_set_has_separator (GTK_DIALOG (editor), FALSE);
-
- gtk_widget_ensure_style (GTK_WIDGET (editor));
- gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (editor)->vbox), 0);
- gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (editor)->action_area), 12);
}
@@ -1009,8 +435,8 @@ comp_editor_key_press_event (GtkWidget *d, GdkEventKey *e)
}
#endif
- if (GTK_WIDGET_CLASS (comp_editor_parent_class)->key_press_event)
- return (* GTK_WIDGET_CLASS (comp_editor_parent_class)->key_press_event) (d, e);
+ if (GTK_WIDGET_CLASS (parent_class)->key_press_event)
+ return (* GTK_WIDGET_CLASS (parent_class)->key_press_event) (d, e);
return FALSE;
}
@@ -1026,8 +452,6 @@ comp_editor_finalize (GObject *object)
editor = COMP_EDITOR (object);
priv = editor->priv;
- g_free (priv->help_section);
-
if (priv->client) {
g_object_unref (priv->client);
priv->client = NULL;
@@ -1062,25 +486,8 @@ comp_editor_finalize (GObject *object)
g_free (priv);
editor->priv = NULL;
- if (G_OBJECT_CLASS (comp_editor_parent_class)->finalize)
- (* G_OBJECT_CLASS (comp_editor_parent_class)->finalize) (object);
-}
-
-static void
-comp_editor_show_help (CompEditor *editor)
-{
- GError *error = NULL;
- CompEditorPrivate *priv;
-
- priv = editor->priv;
-
- gnome_help_display_desktop (NULL,
- "evolution-" BASE_VERSION,
- "evolution-" BASE_VERSION ".xml",
- priv->help_section,
- &error);
- if (error != NULL)
- g_warning ("%s", error->message);
+ if (G_OBJECT_CLASS (parent_class)->finalize)
+ (* G_OBJECT_CLASS (parent_class)->finalize) (object);
}
@@ -1169,31 +576,6 @@ comp_editor_get_user_org (CompEditor *editor)
return priv->user_org;
}
-void
-comp_editor_set_group_item (CompEditor *editor, gboolean group_item)
-{
- CompEditorPrivate *priv;
-
- g_return_if_fail (editor != NULL);
- g_return_if_fail (IS_COMP_EDITOR (editor));
-
- priv = editor->priv;
-
- priv->is_group_item = group_item;
-}
-
-gboolean
-comp_editor_get_is_group_item (CompEditor *editor)
-{
- CompEditorPrivate *priv;
-
- g_return_val_if_fail (editor != NULL, FALSE);
- g_return_val_if_fail (IS_COMP_EDITOR (editor), FALSE);
-
- priv = editor->priv;
-
- return priv->is_group_item;
-}
/**
* comp_editor_set_changed:
@@ -1475,20 +857,9 @@ comp_editor_get_e_cal (CompEditor *editor)
return priv->client;
}
-void
-comp_editor_set_help_section (CompEditor *editor, const char *section)
-{
- CompEditorPrivate *priv;
-
- priv = editor->priv;
-
- g_free (priv->help_section);
- priv->help_section = g_strdup (section);
-}
-
/* Creates an appropriate title for the event editor dialog */
static char *
-make_title_from_comp (ECalComponent *comp, gboolean is_group_item)
+make_title_from_comp (ECalComponent *comp)
{
char *title;
const char *type_string;
@@ -1501,16 +872,10 @@ make_title_from_comp (ECalComponent *comp, gboolean is_group_item)
type = e_cal_component_get_vtype (comp);
switch (type) {
case E_CAL_COMPONENT_EVENT:
- if (is_group_item)
- type_string = _("Meeting - %s");
- else
- type_string = _("Appointment - %s");
+ type_string = _("Appointment - %s");
break;
case E_CAL_COMPONENT_TODO:
- if (is_group_item)
- type_string = _("Assigned Task - %s");
- else
- type_string = _("Task - %s");
+ type_string = _("Task - %s");
break;
case E_CAL_COMPONENT_JOURNAL:
type_string = _("Journal entry - %s");
@@ -1532,7 +897,7 @@ make_title_from_comp (ECalComponent *comp, gboolean is_group_item)
/* Creates an appropriate title for the event editor dialog */
static char *
-make_title_from_string (ECalComponent *comp, const char *str, gboolean is_group_item)
+make_title_from_string (ECalComponent *comp, const char *str)
{
char *title;
const char *type_string;
@@ -1544,16 +909,10 @@ make_title_from_string (ECalComponent *comp, const char *str, gboolean is_group_
type = e_cal_component_get_vtype (comp);
switch (type) {
case E_CAL_COMPONENT_EVENT:
- if (is_group_item)
- type_string = _("Meeting - %s");
- else
- type_string = _("Appointment - %s");
+ type_string = _("Appointment - %s");
break;
case E_CAL_COMPONENT_TODO:
- if (is_group_item)
- type_string = _("Assigned Task - %s");
- else
- type_string = _("Task - %s");
+ type_string = _("Task - %s");
break;
case E_CAL_COMPONENT_JOURNAL:
type_string = _("Journal entry - %s");
@@ -1601,7 +960,7 @@ set_title_from_comp (CompEditor *editor)
char *title;
priv = editor->priv;
- title = make_title_from_comp (priv->comp, priv->is_group_item);
+ title = make_title_from_comp (priv->comp);
gtk_window_set_title (GTK_WINDOW (editor), title);
g_free (title);
}
@@ -1613,7 +972,7 @@ set_title_from_string (CompEditor *editor, const char *str)
char *title;
priv = editor->priv;
- title = make_title_from_string (priv->comp, str, priv->is_group_item);
+ title = make_title_from_string (priv->comp, str);
gtk_window_set_title (GTK_WINDOW (editor), title);
g_free (title);
}
@@ -1644,15 +1003,6 @@ fill_widgets (CompEditor *editor)
priv = editor->priv;
- /*Check if attachments are available here and set them*/
- if (e_cal_component_has_attachments (priv->comp)) {
- GSList *attachment_list = NULL;
- e_cal_component_get_attachment_list (priv->comp, &attachment_list);
- cal_attachment_bar_set_attachment_list
- ((CalAttachmentBar *)priv->attachment_bar, attachment_list);
- e_expander_set_expanded (E_EXPANDER (priv->attachment_expander), TRUE);
- }
-
for (l = priv->pages; l != NULL; l = l->next)
comp_editor_page_fill_widgets (l->data, priv->comp);
}
@@ -1694,7 +1044,6 @@ static void
real_edit_comp (CompEditor *editor, ECalComponent *comp)
{
CompEditorPrivate *priv;
- const char *uid;
g_return_if_fail (editor != NULL);
g_return_if_fail (IS_COMP_EDITOR (editor));
@@ -1715,11 +1064,6 @@ real_edit_comp (CompEditor *editor, ECalComponent *comp)
set_title_from_comp (editor);
set_icon_from_comp (editor);
- e_cal_component_get_uid (comp, &uid);
- cal_attachment_bar_set_local_attachment_store ((CalAttachmentBar *) priv->attachment_bar,
- e_cal_get_local_attachment_store (priv->client));
- cal_attachment_bar_set_comp_uid (priv->attachment_bar, g_strdup (uid));
-
fill_widgets (editor);
listen_for_changes (editor);
@@ -1737,56 +1081,21 @@ real_send_comp (CompEditor *editor, ECalComponentItipMethod method)
priv = editor->priv;
- if (!e_cal_component_has_attachments (priv->comp)) {
- if (itip_send_comp (method, priv->comp, priv->client,
- NULL, NULL)) {
- tmp_comp = priv->comp;
- g_object_ref (tmp_comp);
- comp_editor_edit_comp (editor, tmp_comp);
- g_object_unref (tmp_comp);
-
- comp_editor_set_changed (editor, TRUE);
- save_comp (editor);
-
- return TRUE;
- }
-
- } else {
- /* Clone the component with attachments set to CID:... */
- ECalComponent *send_comp;
- int num_attachments, i;
- GSList *attach_list = NULL;
- GSList *mime_attach_list;
-
- send_comp = e_cal_component_clone (priv->comp);
- num_attachments = e_cal_component_get_num_attachments (send_comp);
+ if (itip_send_comp (method, priv->comp, priv->client, NULL)) {
+ tmp_comp = priv->comp;
+ g_object_ref (tmp_comp);
+ comp_editor_edit_comp (editor, tmp_comp);
+ g_object_unref (tmp_comp);
+
+ comp_editor_set_changed (editor, TRUE);
+ save_comp (editor);
- for (i = 0; i < num_attachments ; i++) {
- attach_list = g_slist_append (attach_list, g_strdup ("CID:..."));
- }
- e_cal_component_set_attachment_list (send_comp, attach_list);
-
- /* mime_attach_list is freed by itip_send_comp */
- mime_attach_list = comp_editor_get_mime_attach_list (editor);
- if (itip_send_comp (method, send_comp, priv->client,
- NULL, mime_attach_list)) {
- tmp_comp = priv->comp;
- g_object_ref (tmp_comp);
- comp_editor_edit_comp (editor, tmp_comp);
- g_object_unref (tmp_comp);
-
- comp_editor_set_changed (editor, TRUE);
- save_comp (editor);
- g_object_unref (send_comp);
- return TRUE;
- }
- g_object_unref (send_comp);
+ return TRUE;
}
comp_editor_set_changed (editor, TRUE);
-
- return FALSE;
+ return FALSE;
}
@@ -1911,22 +1220,6 @@ comp_editor_close (CompEditor *editor)
return close;
}
-
-/* Utility function to get the mime-attachment list from the attachment
- * bar for sending the comp via itip. The list and its contents must
- * be freed by the caller.
- */
-GSList *
-comp_editor_get_mime_attach_list (CompEditor *editor)
-{
- GSList *mime_attach_list;
-
- mime_attach_list = cal_attachment_bar_get_mime_attach_list
- ((CalAttachmentBar *)editor->priv->attachment_bar);
-
- return mime_attach_list;
-}
-
/* Brings attention to a window by raising it and giving it focus */
static void
raise_and_focus (GtkWidget *widget)
@@ -2099,4 +1392,3 @@ obj_removed_cb (ECal *client, GList *uids, gpointer data)
if (changed_component_dialog ((GtkWindow *) editor, priv->comp, TRUE, priv->changed))
close_dialog (editor);
}
-
diff --git a/calendar/gui/dialogs/event-page.c b/calendar/gui/dialogs/event-page.c
index f659ad71fe..6ae83fa6f0 100644
--- a/calendar/gui/dialogs/event-page.c
+++ b/calendar/gui/dialogs/event-page.c
@@ -33,12 +33,11 @@
#include <libgnome/gnome-i18n.h>
#include <glade/glade.h>
#include <gal/widgets/e-categories.h>
-#include <libedataserverui/e-source-option-menu.h>
#include "common/authentication.h"
#include "e-util/e-categories-config.h"
#include "e-util/e-dialog-widgets.h"
#include "widgets/misc/e-dateedit.h"
-#include "widgets/misc/e-send-options.h"
+#include "widgets/misc/e-source-option-menu.h"
#include <libecal/e-cal-time-util.h>
#include "../calendar-config.h"
#include "../e-timezone-entry.h"
@@ -47,7 +46,6 @@
#include "../e-alarm-list.h"
#include "alarm-list-dialog.h"
#include "event-page.h"
-#include "e-send-options-utils.h"
@@ -86,16 +84,11 @@ struct _EventPagePrivate {
GtkWidget *categories;
GtkWidget *source_selector;
-
- GtkWidget *sendoptions_frame;
- GtkWidget *sendoptions_button;
EAlarmList *alarm_list_store;
gboolean updating;
- gboolean sendoptions_shown;
- ESendOptionsDialog *sod;
char *old_summary;
CalUnits alarm_units;
int alarm_interval;
@@ -104,11 +97,12 @@ struct _EventPagePrivate {
start timezone is then changed, we updated the end timezone to the
same value, since 99% of events start and end in one timezone. */
gboolean sync_timezones;
- gboolean is_meeting;
};
+static void event_page_class_init (EventPageClass *class);
+static void event_page_init (EventPage *epage);
static void event_page_finalize (GObject *object);
static GtkWidget *event_page_get_widget (CompEditorPage *page);
@@ -119,7 +113,21 @@ static gboolean event_page_fill_timezones (CompEditorPage *page, GHashTable *tim
static void event_page_set_summary (CompEditorPage *page, const char *summary);
static void event_page_set_dates (CompEditorPage *page, CompEditorPageDates *dates);
-G_DEFINE_TYPE (EventPage, event_page, TYPE_COMP_EDITOR_PAGE);
+static CompEditorPageClass *parent_class = NULL;
+
+
+
+/**
+ * event_page_get_type:
+ *
+ * Registers the #EventPage class if necessary, and returns the type ID
+ * associated to it.
+ *
+ * Return value: The type ID of the #EventPage class.
+ **/
+
+E_MAKE_TYPE (event_page, "EventPage", EventPage, event_page_class_init, event_page_init,
+ TYPE_COMP_EDITOR_PAGE);
/* Class initialization function for the event page */
static void
@@ -131,6 +139,8 @@ event_page_class_init (EventPageClass *class)
editor_page_class = (CompEditorPageClass *) class;
object_class = (GObjectClass *) class;
+ parent_class = g_type_class_ref (TYPE_COMP_EDITOR_PAGE);
+
editor_page_class->get_widget = event_page_get_widget;
editor_page_class->focus_main_widget = event_page_focus_main_widget;
editor_page_class->fill_widgets = event_page_fill_widgets;
@@ -171,17 +181,11 @@ event_page_init (EventPage *epage)
priv->alarm_custom = NULL;
priv->categories_btn = NULL;
priv->categories = NULL;
- priv->sendoptions_frame = NULL;
- priv->sendoptions_button = NULL;
- priv->sod = NULL;
priv->alarm_interval = -1;
priv->updating = FALSE;
- priv->sendoptions_shown = FALSE;
- priv->is_meeting = FALSE;
priv->sync_timezones = FALSE;
-
}
/* Destroy handler for the event page */
@@ -210,17 +214,13 @@ event_page_finalize (GObject *object)
priv->alarm_list_store = NULL;
}
- if (priv->sod) {
- g_object_unref (priv->sod);
- priv->sod = NULL;
- }
g_free (priv->old_summary);
g_free (priv);
epage->priv = NULL;
- if (G_OBJECT_CLASS (event_page_parent_class)->finalize)
- (* G_OBJECT_CLASS (event_page_parent_class)->finalize) (object);
+ if (G_OBJECT_CLASS (parent_class)->finalize)
+ (* G_OBJECT_CLASS (parent_class)->finalize) (object);
}
@@ -635,41 +635,9 @@ sensitize_widgets (EventPage *epage)
else
gtk_widget_hide (priv->alarm_warning);
gtk_widget_set_sensitive (priv->categories_btn, !read_only);
- gtk_widget_set_sensitive (priv->sendoptions_button, !read_only);
gtk_entry_set_editable (GTK_ENTRY (priv->categories), !read_only);
}
-void
-event_page_hide_options (EventPage *page)
-{
- g_return_if_fail (IS_EVENT_PAGE (page));
-
- gtk_widget_hide (page->priv->sendoptions_frame);
-
- page->priv->sendoptions_shown = FALSE;
-}
-
-void
-event_page_show_options (EventPage *page)
-{
- g_return_if_fail (IS_EVENT_PAGE (page));
-
- gtk_widget_show (page->priv->sendoptions_frame);
-
- if (e_cal_get_static_capability (COMP_EDITOR_PAGE (page)->client, CAL_STATIC_CAPABILITY_NO_GEN_OPTIONS))
- e_sendoptions_set_need_general_options (page->priv->sod, FALSE);
-
- page->priv->sendoptions_shown = TRUE;
-}
-
-void
-event_page_set_meeting (EventPage *page, gboolean set)
-{
- g_return_if_fail (IS_EVENT_PAGE (page));
-
- page->priv->is_meeting = set;
-}
-
/* fill_widgets handler for the event page */
static gboolean
event_page_fill_widgets (CompEditorPage *page, ECalComponent *comp)
@@ -680,8 +648,7 @@ event_page_fill_widgets (CompEditorPage *page, ECalComponent *comp)
ECalComponentClassification cl;
ECalComponentTransparency transparency;
ECalComponentDateTime start_date, end_date;
- icalcomponent *icalcomp;
- const char *location, *uid = NULL;
+ const char *location;
const char *categories;
ESource *source;
GSList *l;
@@ -798,12 +765,6 @@ event_page_fill_widgets (CompEditorPage *page, ECalComponent *comp)
source = e_cal_get_source (page->client);
e_source_option_menu_select (E_SOURCE_OPTION_MENU (priv->source_selector), source);
- e_cal_component_get_uid (comp, &uid);
- if (e_cal_get_object (COMP_EDITOR_PAGE (epage)->client, uid, NULL, &icalcomp, NULL)) {
- icalcomponent_free (icalcomp);
- event_page_hide_options (epage);
- }
-
priv->updating = FALSE;
sensitize_widgets (epage);
@@ -967,10 +928,6 @@ event_page_fill_component (CompEditorPage *page, ECalComponent *comp)
busy = e_dialog_toggle_get (priv->show_time_as_busy);
e_cal_component_set_transparency (comp, busy ? E_CAL_COMPONENT_TRANSP_OPAQUE : E_CAL_COMPONENT_TRANSP_TRANSPARENT);
- /* send options */
- if (priv->sendoptions_shown && priv->sod)
- e_sendoptions_utils_fill_component (priv->sod, comp);
-
/* Alarm */
e_cal_component_remove_all_alarms (comp);
if (e_dialog_toggle_get (priv->alarm)) {
@@ -1181,9 +1138,6 @@ get_widgets (EventPage *epage)
priv->source_selector = GW ("source");
- priv->sendoptions_frame = GW ("send-options-frame");
- priv->sendoptions_button = GW ("send-options-button");
-
#undef GW
return (priv->summary
@@ -1201,9 +1155,7 @@ get_widgets (EventPage *epage)
&& priv->alarm_warning
&& priv->alarm_custom
&& priv->categories_btn
- && priv->categories
- && priv->sendoptions_frame
- && priv->sendoptions_button);
+ && priv->categories);
}
/* Callback used when the summary changes; we emit the notification signal. */
@@ -1612,28 +1564,6 @@ categories_clicked_cb (GtkWidget *button, gpointer data)
e_categories_config_open_dialog_for_entry (GTK_ENTRY (entry));
}
-static void
-e_sendoptions_clicked_cb (GtkWidget *button, gpointer data)
-{
- EventPage *epage;
- EventPagePrivate *priv;
- GtkWidget *toplevel;
- ESource *source;
-
- epage = EVENT_PAGE (data);
- priv = epage->priv;
-
- if (!priv->sod) {
- priv->sod = e_sendoptions_dialog_new ();
- source = e_source_option_menu_peek_selected (E_SOURCE_OPTION_MENU (priv->source_selector));
- e_sendoptions_utils_set_default_data (priv->sod, source, "calendar");
- priv->sod->data->initialized = TRUE;
- }
-
- toplevel = gtk_widget_get_toplevel (priv->main);
- e_sendoptions_dialog_run (priv->sod, toplevel, E_ITEM_CALENDAR);
-}
-
/* This is called when any field is changed; it notifies upstream. */
static void
field_changed_cb (GtkWidget *widget, gpointer data)
@@ -1685,11 +1615,6 @@ source_changed_cb (GtkWidget *widget, ESource *source, gpointer data)
comp_editor_notify_client_changed (
COMP_EDITOR (gtk_widget_get_toplevel (priv->main)),
client);
- if (e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_REQ_SEND_OPTIONS) && priv->is_meeting)
- event_page_show_options (epage);
- else
- event_page_hide_options (epage);
-
sensitize_widgets (epage);
}
}
@@ -1838,7 +1763,9 @@ init_widgets (EventPage *epage)
G_CALLBACK (summary_changed_cb), epage);
/* Description */
- text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->description));
+ text_buffer = gtk_text_buffer_new (NULL);
+ gtk_text_view_set_buffer (GTK_TEXT_VIEW (priv->description), text_buffer);
+ g_object_unref (text_buffer);
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (priv->description), GTK_WRAP_WORD);
@@ -1860,10 +1787,6 @@ init_widgets (EventPage *epage)
g_signal_connect((priv->categories_btn), "clicked",
G_CALLBACK (categories_clicked_cb), epage);
- /* send options button */
- g_signal_connect((priv->sendoptions_button), "clicked",
- G_CALLBACK (e_sendoptions_clicked_cb), epage);
-
/* Source selector */
g_signal_connect((priv->source_selector), "source_selected",
G_CALLBACK (source_changed_cb), epage);
diff --git a/calendar/gui/dialogs/event-page.glade b/calendar/gui/dialogs/event-page.glade
index 38dd6576cc..0cf8ad20df 100644
--- a/calendar/gui/dialogs/event-page.glade
+++ b/calendar/gui/dialogs/event-page.glade
@@ -197,9 +197,6 @@
<property name="right_margin">0</property>
<property name="indent">0</property>
<property name="text" translatable="yes"></property>
- <accessibility>
- <atkproperty name="AtkObject::accessible_name" translatable="yes">Event Description</atkproperty>
- </accessibility>
</widget>
</child>
</widget>
@@ -478,9 +475,6 @@
<property name="int1">0</property>
<property name="int2">0</property>
<property name="last_modification_time">Tue, 16 May 2000 19:11:05 GMT</property>
- <accessibility>
- <atkrelation target="start-time-label" type="labelled-by"/>
- </accessibility>
</widget>
<packing>
<property name="left_attach">1</property>
@@ -499,9 +493,6 @@
<property name="int1">0</property>
<property name="int2">0</property>
<property name="last_modification_time">Tue, 16 May 2000 19:11:10 GMT</property>
- <accessibility>
- <atkrelation target="end-time-label" type="labelled-by"/>
- </accessibility>
</widget>
<packing>
<property name="left_attach">1</property>
@@ -531,7 +522,7 @@
</child>
<child>
- <widget class="GtkLabel" id="start-time-label">
+ <widget class="GtkLabel" id="label57">
<property name="visible">True</property>
<property name="label" translatable="yes">_Start time:</property>
<property name="use_underline">True</property>
@@ -556,7 +547,7 @@
</child>
<child>
- <widget class="GtkLabel" id="end-time-label">
+ <widget class="GtkLabel" id="label58">
<property name="visible">True</property>
<property name="label" translatable="yes">_End time:</property>
<property name="use_underline">True</property>
@@ -831,64 +822,6 @@
<property name="fill">False</property>
</packing>
</child>
-
- <child>
- <widget class="GtkFrame" id="send-options-frame">
- <property name="label_xalign">0</property>
- <property name="label_yalign">0.5</property>
- <property name="shadow_type">GTK_SHADOW_NONE</property>
-
- <child>
- <widget class="GtkAlignment" id="alignment2">
- <property name="border_width">12</property>
- <property name="visible">True</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xscale">0.06</property>
- <property name="yscale">1</property>
- <property name="top_padding">0</property>
- <property name="bottom_padding">0</property>
- <property name="left_padding">0</property>
- <property name="right_padding">253</property>
-
- <child>
- <widget class="GtkButton" id="send-options-button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes">Ad_vanced send options</property>
- <property name="use_underline">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- </widget>
- </child>
- </widget>
- </child>
-
- <child>
- <widget class="GtkLabel" id="send-options-label">
- <property name="visible">True</property>
- <property name="label" translatable="yes">&lt;b&gt;Send Options&lt;/b&gt;</property>
- <property name="use_underline">False</property>
- <property name="use_markup">True</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- <packing>
- <property name="type">label_item</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
</widget>
</child>
</widget>
diff --git a/calendar/gui/dialogs/meeting-page.c b/calendar/gui/dialogs/meeting-page.c
index de66095724..c721f474a8 100644
--- a/calendar/gui/dialogs/meeting-page.c
+++ b/calendar/gui/dialogs/meeting-page.c
@@ -35,6 +35,8 @@
#include <libgnome/gnome-i18n.h>
#include <glade/glade.h>
#include <libgnomeui/gnome-stock-icons.h>
+#include <gal/util/e-util.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-utils.h>
@@ -48,7 +50,7 @@
#include "comp-editor-util.h"
#include "e-delegate-dialog.h"
#include "meeting-page.h"
-#include "../e-cal-popup.h"
+
/* Private part of the MeetingPage structure */
struct _MeetingPagePrivate {
@@ -93,6 +95,8 @@ struct _MeetingPagePrivate {
+static void meeting_page_class_init (MeetingPageClass *class);
+static void meeting_page_init (MeetingPage *mpage);
static void meeting_page_finalize (GObject *object);
static GtkWidget *meeting_page_get_widget (CompEditorPage *page);
@@ -100,7 +104,21 @@ static void meeting_page_focus_main_widget (CompEditorPage *page);
static gboolean meeting_page_fill_widgets (CompEditorPage *page, ECalComponent *comp);
static gboolean meeting_page_fill_component (CompEditorPage *page, ECalComponent *comp);
-G_DEFINE_TYPE (MeetingPage, meeting_page, TYPE_COMP_EDITOR_PAGE);
+static CompEditorPageClass *parent_class = NULL;
+
+
+
+/**
+ * meeting_page_get_type:
+ *
+ * Registers the #MeetingPage class if necessary, and returns the type ID
+ * associated to it.
+ *
+ * Return value: The type ID of the #MeetingPage class.
+ **/
+
+E_MAKE_TYPE (meeting_page, "MeetingPage", MeetingPage, meeting_page_class_init, meeting_page_init,
+ TYPE_COMP_EDITOR_PAGE);
/* Class initialization function for the task page */
static void
@@ -112,6 +130,8 @@ meeting_page_class_init (MeetingPageClass *class)
editor_page_class = (CompEditorPageClass *) class;
object_class = (GObjectClass *) class;
+ parent_class = g_type_class_ref (TYPE_COMP_EDITOR_PAGE);
+
editor_page_class->get_widget = meeting_page_get_widget;
editor_page_class->focus_main_widget = meeting_page_focus_main_widget;
editor_page_class->fill_widgets = meeting_page_fill_widgets;
@@ -252,8 +272,8 @@ meeting_page_finalize (GObject *object)
g_free (priv);
mpage->priv = NULL;
- if (G_OBJECT_CLASS (meeting_page_parent_class)->finalize)
- (* G_OBJECT_CLASS (meeting_page_parent_class)->finalize) (object);
+ if (G_OBJECT_CLASS (parent_class)->finalize)
+ (* G_OBJECT_CLASS (parent_class)->finalize) (object);
}
@@ -305,15 +325,12 @@ clear_widgets (MeetingPage *mpage)
static void
sensitize_widgets (MeetingPage *mpage)
{
- gboolean read_only = FALSE;
+ gboolean read_only, user_org;
MeetingPagePrivate *priv = mpage->priv;
- GError *error = NULL;
-
- if (!e_cal_is_read_only (COMP_EDITOR_PAGE (mpage)->client, &read_only, &error)) {
- if (error->code != E_CALENDAR_STATUS_BUSY)
- read_only = TRUE;
- g_error_free (error);
- }
+
+ if (!e_cal_is_read_only (COMP_EDITOR_PAGE (mpage)->client, &read_only, NULL))
+ read_only = TRUE;
+
gtk_widget_set_sensitive (priv->organizer, !read_only);
gtk_widget_set_sensitive (priv->existing_organizer_btn, !read_only);
gtk_widget_set_sensitive (priv->add, !read_only && priv->user_org);
@@ -758,9 +775,9 @@ client_changed_cb (CompEditorPage *page, ECal *client, gpointer user_data)
}
static void
-popup_delete_cb (EPopup *ep, EPopupItem *pitem, void *data)
+popup_delete_cb (GtkWidget *widget, gpointer data)
{
- MeetingPage *mpage = data;
+ MeetingPage *mpage = MEETING_PAGE (data);
MeetingPagePrivate *priv;
priv = mpage->priv;
@@ -773,20 +790,17 @@ enum {
CAN_DELETE = 4
};
-static EPopupItem context_menu_items[] = {
+static EPopupMenu context_menu[] = {
#if 0
- { E_POPUP_ITEM, "00.delegate", N_("_Delegate To..."), popup_delegate_cb, NULL, NULL, CAN_DELEGATE },
- { E_POPUP_BAR, "05.bar" },
+ E_POPUP_ITEM (N_("_Delegate To..."), G_CALLBACK (popup_delegate_cb), CAN_DELEGATE),
+
+ E_POPUP_SEPARATOR,
#endif
- { E_POPUP_ITEM, "10.delete", N_("_Remove"), popup_delete_cb, NULL, GTK_STOCK_REMOVE, CAN_DELETE },
+ E_POPUP_ITEM (N_("_Remove"), G_CALLBACK (popup_delete_cb), CAN_DELETE),
+
+ E_POPUP_TERMINATOR
};
-static void
-context_popup_free(EPopup *ep, GSList *items, void *data)
-{
- g_slist_free(items);
-}
-
static gint
button_press_event (GtkWidget *widget, GdkEventButton *event, MeetingPage *mpage)
{
@@ -796,11 +810,8 @@ button_press_event (GtkWidget *widget, GdkEventButton *event, MeetingPage *mpage
GtkTreePath *path;
GtkTreeIter iter;
char *address;
- int disable_mask = 0;
- GSList *menus = NULL;
- ECalPopup *ep;
- int i;
-
+ int disable_mask = 0, hide_mask = 0;
+
priv = mpage->priv;
/* only process right-clicks */
@@ -821,13 +832,16 @@ button_press_event (GtkWidget *widget, GdkEventButton *event, MeetingPage *mpage
if (e_meeting_attendee_get_edit_level (ia) != E_MEETING_ATTENDEE_EDIT_FULL)
disable_mask = CAN_DELETE;
+
+ /* FIXME: if you enable Delegate, then change index to '1'.
+ * (This has now been enabled). */
+ /* context_menu[1].pixmap_widget = gnome_stock_new_with_icon (GNOME_STOCK_MENU_TRASH); */
+ context_menu[0].pixmap_widget =
+ gtk_image_new_from_stock (GTK_STOCK_REMOVE, GTK_ICON_SIZE_MENU);
- ep = e_cal_popup_new("org.gnome.evolution.calendar.meeting.popup");
- for (i=0;i<sizeof(context_menu_items)/sizeof(context_menu_items[0]);i++)
- menus = g_slist_prepend(menus, &context_menu_items[i]);
-
- e_popup_add_items((EPopup *)ep, menus, NULL, context_popup_free, mpage);
- menu = e_popup_create_menu_once((EPopup *)ep, NULL, disable_mask);
+ menu = e_popup_menu_create (context_menu, disable_mask, hide_mask, mpage);
+ e_auto_kill_popup_menu_on_selection_done (menu);
+
gtk_menu_popup (menu, NULL, NULL, NULL, NULL, event->button, event->time);
return TRUE;
@@ -923,7 +937,8 @@ meeting_page_construct (MeetingPage *mpage, EMeetingStore *ems,
gtk_box_pack_start (GTK_BOX (priv->list_box), sw, TRUE, TRUE, 0);
/* Set the mnemonic widget for the Attendees label */
- gtk_label_set_mnemonic_widget (GTK_LABEL (priv->att_label), GTK_WIDGET (priv->list_view));
+ gtk_label_set_mnemonic_widget (GTK_LABEL (priv->att_label),
+ priv->list_view);
/* Init the widget signals */
init_widgets (mpage);
diff --git a/calendar/gui/dialogs/recurrence-page.c b/calendar/gui/dialogs/recurrence-page.c
index 07e3b6164b..921f3d32bd 100644
--- a/calendar/gui/dialogs/recurrence-page.c
+++ b/calendar/gui/dialogs/recurrence-page.c
@@ -198,6 +198,8 @@ struct _RecurrencePagePrivate {
+static void recurrence_page_class_init (RecurrencePageClass *class);
+static void recurrence_page_init (RecurrencePage *rpage);
static void recurrence_page_finalize (GObject *object);
static GtkWidget *recurrence_page_get_widget (CompEditorPage *page);
@@ -208,7 +210,21 @@ static void recurrence_page_set_dates (CompEditorPage *page, CompEditorPageDates
static void field_changed (RecurrencePage *apage);
-G_DEFINE_TYPE (RecurrencePage, recurrence_page, TYPE_COMP_EDITOR_PAGE);
+static CompEditorPageClass *parent_class = NULL;
+
+
+
+/**
+ * recurrence_page_get_type:
+ *
+ * Registers the #RecurrencePage class if necessary, and returns the type ID
+ * associated to it.
+ *
+ * Return value: The type ID of the #RecurrencePage class.
+ **/
+
+E_MAKE_TYPE (recurrence_page, "RecurrencePage", RecurrencePage, recurrence_page_class_init,
+ recurrence_page_init, TYPE_COMP_EDITOR_PAGE);
/* Class initialization function for the recurrence page */
static void
@@ -220,6 +236,8 @@ recurrence_page_class_init (RecurrencePageClass *class)
editor_page_class = (CompEditorPageClass *) class;
object_class = (GObjectClass *) class;
+ parent_class = g_type_class_ref(TYPE_COMP_EDITOR_PAGE);
+
editor_page_class->get_widget = recurrence_page_get_widget;
editor_page_class->focus_main_widget = recurrence_page_focus_main_widget;
editor_page_class->fill_widgets = recurrence_page_fill_widgets;
@@ -304,8 +322,8 @@ recurrence_page_finalize (GObject *object)
g_free (priv);
rpage->priv = NULL;
- if (G_OBJECT_CLASS (recurrence_page_parent_class)->finalize)
- (* G_OBJECT_CLASS (recurrence_page_parent_class)->finalize) (object);
+ if (G_OBJECT_CLASS (parent_class)->finalize)
+ (* G_OBJECT_CLASS (parent_class)->finalize) (object);
}
@@ -514,7 +532,7 @@ sensitize_buttons (RecurrencePage *rpage)
gint selected_rows;
RecurrencePagePrivate *priv;
icalcomponent *icalcomp;
- const char *uid;
+ char *uid;
priv = rpage->priv;
@@ -531,19 +549,6 @@ sensitize_buttons (RecurrencePage *rpage)
read_only = TRUE;
icalcomponent_free (icalcomp);
}
-
- if (!read_only) {
- GList *list;
-
- /* see if we have detached instances */
- if (e_cal_get_objects_for_uid (COMP_EDITOR_PAGE (rpage)->client, uid, &list, NULL)) {
- if (list && g_list_length (list) > 1)
- read_only = TRUE;
-
- g_list_foreach (list, (GFunc) g_object_unref, NULL);
- g_list_free (list);
- }
- }
}
if (!read_only)
diff --git a/calendar/gui/dialogs/task-page.glade b/calendar/gui/dialogs/task-page.glade
index 3415672ec2..cacc411a9e 100644
--- a/calendar/gui/dialogs/task-page.glade
+++ b/calendar/gui/dialogs/task-page.glade
@@ -26,7 +26,7 @@
<child>
<widget class="GtkLabel" id="label21">
<property name="visible">True</property>
- <property name="label" translatable="yes">&lt;b&gt;Basics&lt;/b&gt;</property>
+ <property name="label" translatable="yes">&lt;span weight=&quot;bold&quot;&gt;Basics&lt;/span&gt;</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
@@ -89,7 +89,7 @@
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
- <property name="invisible_char">*</property>
+ <property name="invisible_char" translatable="yes">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
@@ -274,11 +274,8 @@
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
- <property name="invisible_char">*</property>
+ <property name="invisible_char" translatable="yes">*</property>
<property name="activates_default">False</property>
- <accessibility>
- <atkproperty name="AtkObject::accessible_name" translatable="yes">Categories</atkproperty>
- </accessibility>
</widget>
<packing>
<property name="left_attach">1</property>
@@ -314,9 +311,6 @@
<property name="right_margin">0</property>
<property name="indent">0</property>
<property name="text" translatable="yes"></property>
- <accessibility>
- <atkproperty name="AtkObject::accessible_name" translatable="yes">Task Description</atkproperty>
- </accessibility>
</widget>
</child>
</widget>
@@ -372,7 +366,7 @@
<child>
<widget class="GtkLabel" id="label24">
<property name="visible">True</property>
- <property name="label" translatable="yes">&lt;b&gt;Date and Time&lt;/b&gt;</property>
+ <property name="label" translatable="yes">&lt;span weight=&quot;bold&quot;&gt;Date and Time&lt;/span&gt;</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
@@ -427,7 +421,7 @@
<property name="column_spacing">12</property>
<child>
- <widget class="GtkLabel" id="due-date-label">
+ <widget class="GtkLabel" id="label29">
<property name="visible">True</property>
<property name="label" translatable="yes">_Due date:</property>
<property name="use_underline">True</property>
@@ -452,7 +446,7 @@
</child>
<child>
- <widget class="GtkLabel" id="start-date-label">
+ <widget class="GtkLabel" id="label30">
<property name="visible">True</property>
<property name="label" translatable="yes">Sta_rt date:</property>
<property name="use_underline">True</property>
@@ -489,9 +483,6 @@
<property name="int1">0</property>
<property name="int2">0</property>
<property name="last_modification_time">Mon, 14 Jun 2004 18:16:07 GMT</property>
- <accessibility>
- <atkrelation target="due-date-label" type="labelled-by"/>
- </accessibility>
</widget>
<packing>
<property name="padding">0</property>
@@ -538,9 +529,6 @@
<property name="int1">0</property>
<property name="int2">0</property>
<property name="last_modification_time">Mon, 14 Jun 2004 18:16:13 GMT</property>
- <accessibility>
- <atkrelation target="start-date-label" type="labelled-by"/>
- </accessibility>
</widget>
<packing>
<property name="padding">0</property>
@@ -587,64 +575,6 @@
<property name="fill">False</property>
</packing>
</child>
-
- <child>
- <widget class="GtkFrame" id="send-options-frame">
- <property name="label_xalign">0</property>
- <property name="label_yalign">0.5</property>
- <property name="shadow_type">GTK_SHADOW_NONE</property>
-
- <child>
- <widget class="GtkAlignment" id="alignment1">
- <property name="border_width">12</property>
- <property name="visible">True</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xscale">0.11</property>
- <property name="yscale">1</property>
- <property name="top_padding">0</property>
- <property name="bottom_padding">0</property>
- <property name="left_padding">12</property>
- <property name="right_padding">0</property>
-
- <child>
- <widget class="GtkButton" id="send-options-button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes">Ad_vanced send options</property>
- <property name="use_underline">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- </widget>
- </child>
- </widget>
- </child>
-
- <child>
- <widget class="GtkLabel" id="send-options-label">
- <property name="visible">True</property>
- <property name="label" translatable="yes">&lt;b&gt;Send Options&lt;/b&gt;</property>
- <property name="use_underline">False</property>
- <property name="use_markup">True</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- <packing>
- <property name="type">label_item</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
</widget>
</child>
</widget>
diff --git a/calendar/gui/e-cal-list-view.c b/calendar/gui/e-cal-list-view.c
index d17f26889c..9ef25b92df 100644
--- a/calendar/gui/e-cal-list-view.c
+++ b/calendar/gui/e-cal-list-view.c
@@ -25,9 +25,7 @@
* ECalListView - display calendar events in an ETable.
*/
-#ifdef HAVE_CONFIG_H
#include <config.h>
-#endif
#include "e-cal-list-view.h"
#include "ea-calendar.h"
@@ -43,6 +41,7 @@
#include <gtk/gtkvscrollbar.h>
#include <gtk/gtkwindow.h>
#include <gal/widgets/e-gui-utils.h>
+#include <gal/util/e-util.h>
#include <gal/e-table/e-table-memory-store.h>
#include <gal/e-table/e-cell-checkbox.h>
#include <gal/e-table/e-cell-toggle.h>
@@ -71,6 +70,8 @@
#include "goto.h"
#include "misc.h"
+static void e_cal_list_view_class_init (ECalListViewClass *class);
+static void e_cal_list_view_init (ECalListView *cal_list_view);
static void e_cal_list_view_destroy (GtkObject *object);
static GList *e_cal_list_view_get_selected_events (ECalendarView *cal_view);
@@ -88,7 +89,10 @@ static gboolean e_cal_list_view_on_table_right_click (GtkWidget *table, gint
GdkEvent *event, gpointer data);
static void e_cal_list_view_cursor_change_cb (ETable *etable, gint row, gpointer data);
-G_DEFINE_TYPE (ECalListView, e_cal_list_view, E_TYPE_CALENDAR_VIEW);
+static GtkTableClass *parent_class; /* Should be ECalendarViewClass? */
+
+E_MAKE_TYPE (e_cal_list_view, "ECalListView", ECalListView, e_cal_list_view_class_init,
+ e_cal_list_view_init, e_calendar_view_get_type ());
static void
e_cal_list_view_class_init (ECalListViewClass *class)
@@ -97,6 +101,7 @@ e_cal_list_view_class_init (ECalListViewClass *class)
GtkWidgetClass *widget_class;
ECalendarViewClass *view_class;
+ parent_class = g_type_class_peek_parent (class);
object_class = (GtkObjectClass *) class;
widget_class = (GtkWidgetClass *) class;
view_class = (ECalendarViewClass *) class;
@@ -316,6 +321,7 @@ e_cal_list_view_new (void)
ECalModel *model;
model = E_CAL_MODEL (e_cal_model_calendar_new ());
+ e_cal_model_set_flags (model, E_CAL_MODEL_FLAGS_EXPAND_RECURRENCES);
cal_list_view = g_object_new (e_cal_list_view_get_type (), "model", model, NULL);
if (!e_cal_list_view_construct (cal_list_view)) {
@@ -358,16 +364,16 @@ e_cal_list_view_destroy (GtkObject *object)
cal_list_view->table_scrolled = NULL;
}
- GTK_OBJECT_CLASS (e_cal_list_view_parent_class)->destroy (object);
+ GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
static void
e_cal_list_view_show_popup_menu (ECalListView *cal_list_view, gint row, GdkEvent *gdk_event)
{
- GtkMenu *menu;
+ GtkMenu *popup;
- menu = e_calendar_view_create_popup_menu (E_CALENDAR_VIEW (cal_list_view));
- gtk_menu_popup(menu, NULL, NULL, NULL, NULL, gdk_event?gdk_event->button.button:0, gdk_event?gdk_event->button.time:gtk_get_current_event_time());
+ popup = e_calendar_view_create_popup_menu (E_CALENDAR_VIEW (cal_list_view));
+ e_popup_menu (popup, gdk_event);
}
static gboolean
diff --git a/calendar/gui/e-cal-model-calendar.c b/calendar/gui/e-cal-model-calendar.c
index b64dce21c6..63532c5be8 100644
--- a/calendar/gui/e-cal-model-calendar.c
+++ b/calendar/gui/e-cal-model-calendar.c
@@ -1,6 +1,7 @@
/* Evolution calendar - Data model for ETable
*
- * Copyright (C) 2004 Ximian, Inc.
+ * Copyright (C) 2000 Ximian, Inc.
+ * Copyright (C) 2000 Ximian, Inc.
*
* Authors: Rodrigo Moya <rodrigo@ximian.com>
*
@@ -18,23 +19,20 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*/
-#ifdef HAVE_CONFIG_H
#include <config.h>
-#endif
-
#include <string.h>
#include <libgnome/gnome-i18n.h>
+#include <gal/util/e-util.h>
#include "e-cal-model-calendar.h"
#include "e-cell-date-edit-text.h"
-#include "itip-utils.h"
#include "misc.h"
-#include "dialogs/recur-comp.h"
-#include "dialogs/send-comp.h"
struct _ECalModelCalendarPrivate {
};
-static void e_cal_model_calendar_finalize (GObject *object);
+static void ecmc_class_init (ECalModelCalendarClass *klass);
+static void ecmc_init (ECalModelCalendar *model, ECalModelCalendarClass *klass);
+static void ecmc_finalize (GObject *object);
static int ecmc_column_count (ETableModel *etm);
static void *ecmc_value_at (ETableModel *etm, int col, int row);
static void ecmc_set_value_at (ETableModel *etm, int col, int row, const void *value);
@@ -48,16 +46,21 @@ static char *ecmc_value_to_string (ETableModel *etm, int col, const void *value)
static void ecmc_fill_component_from_model (ECalModel *model, ECalModelComponent *comp_data,
ETableModel *source_model, gint row);
-G_DEFINE_TYPE (ECalModelCalendar, e_cal_model_calendar, E_TYPE_CAL_MODEL);
+static GObjectClass *parent_class = NULL;
+
+E_MAKE_TYPE (e_cal_model_calendar, "ECalModelCalendar", ECalModelCalendar, ecmc_class_init,
+ ecmc_init, E_TYPE_CAL_MODEL);
static void
-e_cal_model_calendar_class_init (ECalModelCalendarClass *klass)
+ecmc_class_init (ECalModelCalendarClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
ETableModelClass *etm_class = E_TABLE_MODEL_CLASS (klass);
ECalModelClass *model_class = E_CAL_MODEL_CLASS (klass);
- object_class->finalize = e_cal_model_calendar_finalize;
+ parent_class = g_type_class_peek_parent (klass);
+
+ object_class->finalize = ecmc_finalize;
etm_class->column_count = ecmc_column_count;
etm_class->value_at = ecmc_value_at;
@@ -73,7 +76,7 @@ e_cal_model_calendar_class_init (ECalModelCalendarClass *klass)
}
static void
-e_cal_model_calendar_init (ECalModelCalendar *model)
+ecmc_init (ECalModelCalendar *model, ECalModelCalendarClass *klass)
{
ECalModelCalendarPrivate *priv;
@@ -84,7 +87,7 @@ e_cal_model_calendar_init (ECalModelCalendar *model)
}
static void
-e_cal_model_calendar_finalize (GObject *object)
+ecmc_finalize (GObject *object)
{
ECalModelCalendarPrivate *priv;
ECalModelCalendar *model = (ECalModelCalendar *) object;
@@ -97,8 +100,8 @@ e_cal_model_calendar_finalize (GObject *object)
model->priv = NULL;
}
- if (G_OBJECT_CLASS (e_cal_model_calendar_parent_class)->finalize)
- G_OBJECT_CLASS (e_cal_model_calendar_parent_class)->finalize (object);
+ if (parent_class->finalize)
+ parent_class->finalize (object);
}
/* ETableModel methods */
@@ -115,7 +118,7 @@ get_dtend (ECalModelCalendar *model, ECalModelComponent *comp_data)
if (!comp_data->dtend) {
icalproperty *prop;
- icaltimezone *zone, *model_zone;
+ icaltimezone *zone;
gboolean got_zone = FALSE;
prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_DTEND_PROPERTY);
@@ -128,12 +131,11 @@ get_dtend (ECalModelCalendar *model, ECalModelComponent *comp_data)
&& e_cal_get_timezone (comp_data->client, icaltime_get_tzid (tt_end), &zone, NULL))
got_zone = TRUE;
- if (e_cal_model_get_flags (E_CAL_MODEL (model)) & E_CAL_MODEL_FLAGS_EXPAND_RECURRENCES) {
- if (got_zone) {
+ if ((e_cal_model_get_flags (E_CAL_MODEL (model)) & E_CAL_MODEL_FLAGS_EXPAND_RECURRENCES) &&
+ (e_cal_util_component_has_recurrences (comp_data->icalcomp))) {
+ if (got_zone)
tt_end = icaltime_from_timet_with_zone (comp_data->instance_end, tt_end.is_date, zone);
- if ((model_zone = e_cal_model_get_timezone (E_CAL_MODEL (model))))
- icaltimezone_convert_time (&tt_end, zone, model_zone);
- } else
+ else
tt_end = icaltime_from_timet (comp_data->instance_end, tt_end.is_date);
}
@@ -200,7 +202,7 @@ ecmc_value_at (ETableModel *etm, int col, int row)
g_return_val_if_fail (row >= 0 && row < e_table_model_row_count (etm), NULL);
if (col < E_CAL_MODEL_FIELD_LAST)
- return E_TABLE_MODEL_CLASS (e_cal_model_calendar_parent_class)->value_at (etm, col, row);
+ return E_TABLE_MODEL_CLASS (parent_class)->value_at (etm, col, row);
comp_data = e_cal_model_get_component_at (E_CAL_MODEL (model), row);
if (!comp_data)
@@ -333,8 +335,6 @@ static void
ecmc_set_value_at (ETableModel *etm, int col, int row, const void *value)
{
ECalModelComponent *comp_data;
- CalObjModType mod = CALOBJ_MOD_ALL;
- ECalComponent *comp;
ECalModelCalendar *model = (ECalModelCalendar *) etm;
g_return_if_fail (E_IS_CAL_MODEL_CALENDAR (model));
@@ -342,7 +342,7 @@ ecmc_set_value_at (ETableModel *etm, int col, int row, const void *value)
g_return_if_fail (row >= 0 && row < e_table_model_row_count (etm));
if (col < E_CAL_MODEL_FIELD_LAST) {
- E_TABLE_MODEL_CLASS (e_cal_model_calendar_parent_class)->set_value_at (etm, col, row, value);
+ E_TABLE_MODEL_CLASS (parent_class)->set_value_at (etm, col, row, value);
return;
}
@@ -350,20 +350,6 @@ ecmc_set_value_at (ETableModel *etm, int col, int row, const void *value)
if (!comp_data)
return;
- comp = e_cal_component_new ();
- if (!e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp))) {
- g_object_unref (comp);
- return;
- }
-
- /* ask about mod type */
- if (e_cal_component_is_instance (comp)) {
- if (!recur_component_dialog (comp_data->client, comp, &mod, NULL)) {
- g_object_unref (comp);
- return;
- }
- }
-
switch (col) {
case E_CAL_MODEL_CALENDAR_FIELD_DTEND :
set_dtend (comp_data, value);
@@ -376,18 +362,12 @@ ecmc_set_value_at (ETableModel *etm, int col, int row, const void *value)
break;
}
- if (e_cal_modify_object (comp_data->client, comp_data->icalcomp, CALOBJ_MOD_ALL, NULL)) {
- if (itip_organizer_is_user (comp, comp_data->client) &&
- send_component_dialog (NULL, comp_data->client, comp, FALSE))
- itip_send_comp (E_CAL_COMPONENT_METHOD_REQUEST, comp,
- comp_data->client, NULL, NULL);
- } else {
+ /* FIXME ask about mod type */
+ if (!e_cal_modify_object (comp_data->client, comp_data->icalcomp, CALOBJ_MOD_ALL, NULL)) {
g_warning (G_STRLOC ": Could not modify the object!");
/* FIXME Show error dialog */
}
-
- g_object_unref (comp);
}
static gboolean
@@ -400,7 +380,7 @@ ecmc_is_cell_editable (ETableModel *etm, int col, int row)
g_return_val_if_fail (row >= -1 || (row >= 0 && row < e_table_model_row_count (etm)), FALSE);
if (col < E_CAL_MODEL_FIELD_LAST)
- return E_TABLE_MODEL_CLASS (e_cal_model_calendar_parent_class)->is_cell_editable (etm, col, row);
+ return E_TABLE_MODEL_CLASS (parent_class)->is_cell_editable (etm, col, row);
switch (col) {
case E_CAL_MODEL_CALENDAR_FIELD_DTEND :
@@ -418,7 +398,7 @@ ecmc_duplicate_value (ETableModel *etm, int col, const void *value)
g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_CALENDAR_FIELD_LAST, NULL);
if (col < E_CAL_MODEL_FIELD_LAST)
- return E_TABLE_MODEL_CLASS (e_cal_model_calendar_parent_class)->duplicate_value (etm, col, value);
+ return E_TABLE_MODEL_CLASS (parent_class)->duplicate_value (etm, col, value);
switch (col) {
case E_CAL_MODEL_CALENDAR_FIELD_DTEND :
@@ -446,7 +426,7 @@ ecmc_free_value (ETableModel *etm, int col, void *value)
g_return_if_fail (col >= 0 && col < E_CAL_MODEL_CALENDAR_FIELD_LAST);
if (col < E_CAL_MODEL_FIELD_LAST) {
- E_TABLE_MODEL_CLASS (e_cal_model_calendar_parent_class)->free_value (etm, col, value);
+ E_TABLE_MODEL_CLASS (parent_class)->free_value (etm, col, value);
return;
}
@@ -466,7 +446,7 @@ ecmc_initialize_value (ETableModel *etm, int col)
g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_CALENDAR_FIELD_LAST, NULL);
if (col < E_CAL_MODEL_FIELD_LAST)
- return E_TABLE_MODEL_CLASS (e_cal_model_calendar_parent_class)->initialize_value (etm, col);
+ return E_TABLE_MODEL_CLASS (parent_class)->initialize_value (etm, col);
switch (col) {
case E_CAL_MODEL_CALENDAR_FIELD_DTEND :
@@ -485,7 +465,7 @@ ecmc_value_is_empty (ETableModel *etm, int col, const void *value)
g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_CALENDAR_FIELD_LAST, TRUE);
if (col < E_CAL_MODEL_FIELD_LAST)
- return E_TABLE_MODEL_CLASS (e_cal_model_calendar_parent_class)->value_is_empty (etm, col, value);
+ return E_TABLE_MODEL_CLASS (parent_class)->value_is_empty (etm, col, value);
switch (col) {
case E_CAL_MODEL_CALENDAR_FIELD_DTEND :
@@ -504,7 +484,7 @@ ecmc_value_to_string (ETableModel *etm, int col, const void *value)
g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_CALENDAR_FIELD_LAST, g_strdup (""));
if (col < E_CAL_MODEL_FIELD_LAST)
- return E_TABLE_MODEL_CLASS (e_cal_model_calendar_parent_class)->value_to_string (etm, col, value);
+ return E_TABLE_MODEL_CLASS (parent_class)->value_to_string (etm, col, value);
switch (col) {
case E_CAL_MODEL_CALENDAR_FIELD_DTEND :
diff --git a/calendar/gui/e-cal-model-tasks.c b/calendar/gui/e-cal-model-tasks.c
index 2ef9420788..508406c80d 100644
--- a/calendar/gui/e-cal-model-tasks.c
+++ b/calendar/gui/e-cal-model-tasks.c
@@ -1,6 +1,7 @@
/* Evolution calendar - Data model for ETable
*
- * Copyright (C) 2004 Ximian, Inc.
+ * Copyright (C) 2000 Ximian, Inc.
+ * Copyright (C) 2000 Ximian, Inc.
*
* Authors: Rodrigo Moya <rodrigo@ximian.com>
*
@@ -18,14 +19,12 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*/
-#ifdef HAVE_CONFIG_H
#include <config.h>
-#endif
-
#include <math.h>
#include <string.h>
#include <gtk/gtkmessagedialog.h>
#include <libgnome/gnome-i18n.h>
+#include <gal/util/e-util.h>
#include "calendar-config.h"
#include "e-cal-model-tasks.h"
#include "e-cell-date-edit-text.h"
@@ -34,7 +33,9 @@
struct _ECalModelTasksPrivate {
};
-static void e_cal_model_tasks_finalize (GObject *object);
+static void ecmt_class_init (ECalModelTasksClass *klass);
+static void ecmt_init (ECalModelTasks *model, ECalModelTasksClass *klass);
+static void ecmt_finalize (GObject *object);
static int ecmt_column_count (ETableModel *etm);
static void *ecmt_value_at (ETableModel *etm, int col, int row);
@@ -50,16 +51,21 @@ static const char *ecmt_get_color_for_component (ECalModel *model, ECalModelComp
static void ecmt_fill_component_from_model (ECalModel *model, ECalModelComponent *comp_data,
ETableModel *source_model, gint row);
-G_DEFINE_TYPE (ECalModelTasks, e_cal_model_tasks, E_TYPE_CAL_MODEL);
+static GObjectClass *parent_class = NULL;
+
+E_MAKE_TYPE (e_cal_model_tasks, "ECalModelTasks", ECalModelTasks, ecmt_class_init,
+ ecmt_init, E_TYPE_CAL_MODEL);
static void
-e_cal_model_tasks_class_init (ECalModelTasksClass *klass)
+ecmt_class_init (ECalModelTasksClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
ETableModelClass *etm_class = E_TABLE_MODEL_CLASS (klass);
ECalModelClass *model_class = E_CAL_MODEL_CLASS (klass);
- object_class->finalize = e_cal_model_tasks_finalize;
+ parent_class = g_type_class_peek_parent (klass);
+
+ object_class->finalize = ecmt_finalize;
etm_class->column_count = ecmt_column_count;
etm_class->value_at = ecmt_value_at;
@@ -76,7 +82,7 @@ e_cal_model_tasks_class_init (ECalModelTasksClass *klass)
}
static void
-e_cal_model_tasks_init (ECalModelTasks *model)
+ecmt_init (ECalModelTasks *model, ECalModelTasksClass *klass)
{
ECalModelTasksPrivate *priv;
@@ -87,7 +93,7 @@ e_cal_model_tasks_init (ECalModelTasks *model)
}
static void
-e_cal_model_tasks_finalize (GObject *object)
+ecmt_finalize (GObject *object)
{
ECalModelTasksPrivate *priv;
ECalModelTasks *model = (ECalModelTasks *) object;
@@ -100,8 +106,8 @@ e_cal_model_tasks_finalize (GObject *object)
model->priv = NULL;
}
- if (G_OBJECT_CLASS (e_cal_model_tasks_parent_class)->finalize)
- G_OBJECT_CLASS (e_cal_model_tasks_parent_class)->finalize (object);
+ if (parent_class->finalize)
+ parent_class->finalize (object);
}
/* ETableModel methods */
@@ -371,18 +377,8 @@ is_complete (ECalModelComponent *comp_data)
icalproperty *prop;
prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_COMPLETED_PROPERTY);
- if (prop)
- return TRUE;
-
- prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_PERCENTCOMPLETE_PROPERTY);
- if (prop && icalproperty_get_percentcomplete (prop) == 100)
- return TRUE;
- prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_STATUS_PROPERTY);
- if (prop && icalproperty_get_status (prop) == ICAL_STATUS_COMPLETED)
- return TRUE;
-
- return FALSE;
+ return prop ? TRUE : FALSE;
}
typedef enum {
@@ -476,7 +472,7 @@ ecmt_value_at (ETableModel *etm, int col, int row)
g_return_val_if_fail (row >= 0 && row < e_table_model_row_count (etm), NULL);
if (col < E_CAL_MODEL_FIELD_LAST)
- return E_TABLE_MODEL_CLASS (e_cal_model_tasks_parent_class)->value_at (etm, col, row);
+ return E_TABLE_MODEL_CLASS (parent_class)->value_at (etm, col, row);
comp_data = e_cal_model_get_component_at (E_CAL_MODEL (model), row);
if (!comp_data)
@@ -793,7 +789,7 @@ ecmt_set_value_at (ETableModel *etm, int col, int row, const void *value)
g_return_if_fail (row >= 0 && row < e_table_model_row_count (etm));
if (col < E_CAL_MODEL_FIELD_LAST) {
- E_TABLE_MODEL_CLASS (e_cal_model_tasks_parent_class)->set_value_at (etm, col, row, value);
+ E_TABLE_MODEL_CLASS (parent_class)->set_value_at (etm, col, row, value);
return;
}
@@ -850,7 +846,7 @@ ecmt_is_cell_editable (ETableModel *etm, int col, int row)
g_return_val_if_fail (row >= -1 || (row >= 0 && row < e_table_model_row_count (etm)), FALSE);
if (col < E_CAL_MODEL_FIELD_LAST)
- return E_TABLE_MODEL_CLASS (e_cal_model_tasks_parent_class)->is_cell_editable (etm, col, row);
+ return E_TABLE_MODEL_CLASS (parent_class)->is_cell_editable (etm, col, row);
switch (col) {
case E_CAL_MODEL_TASKS_FIELD_COMPLETED :
@@ -873,7 +869,7 @@ ecmt_duplicate_value (ETableModel *etm, int col, const void *value)
g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_TASKS_FIELD_LAST, NULL);
if (col < E_CAL_MODEL_FIELD_LAST)
- return E_TABLE_MODEL_CLASS (e_cal_model_tasks_parent_class)->duplicate_value (etm, col, value);
+ return E_TABLE_MODEL_CLASS (parent_class)->duplicate_value (etm, col, value);
switch (col) {
case E_CAL_MODEL_TASKS_FIELD_GEO :
@@ -909,7 +905,7 @@ ecmt_free_value (ETableModel *etm, int col, void *value)
g_return_if_fail (col >= 0 && col < E_CAL_MODEL_TASKS_FIELD_LAST);
if (col < E_CAL_MODEL_FIELD_LAST) {
- E_TABLE_MODEL_CLASS (e_cal_model_tasks_parent_class)->free_value (etm, col, value);
+ E_TABLE_MODEL_CLASS (parent_class)->free_value (etm, col, value);
return;
}
@@ -939,7 +935,7 @@ ecmt_initialize_value (ETableModel *etm, int col)
g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_TASKS_FIELD_LAST, NULL);
if (col < E_CAL_MODEL_FIELD_LAST)
- return E_TABLE_MODEL_CLASS (e_cal_model_tasks_parent_class)->initialize_value (etm, col);
+ return E_TABLE_MODEL_CLASS (parent_class)->initialize_value (etm, col);
switch (col) {
case E_CAL_MODEL_TASKS_FIELD_GEO :
@@ -971,7 +967,7 @@ ecmt_value_is_empty (ETableModel *etm, int col, const void *value)
priv = model->priv;
if (col < E_CAL_MODEL_FIELD_LAST)
- return E_TABLE_MODEL_CLASS (e_cal_model_tasks_parent_class)->value_is_empty (etm, col, value);
+ return E_TABLE_MODEL_CLASS (parent_class)->value_is_empty (etm, col, value);
switch (col) {
case E_CAL_MODEL_TASKS_FIELD_GEO :
@@ -1001,7 +997,7 @@ ecmt_value_to_string (ETableModel *etm, int col, const void *value)
g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_TASKS_FIELD_LAST, g_strdup (""));
if (col < E_CAL_MODEL_FIELD_LAST)
- return E_TABLE_MODEL_CLASS (e_cal_model_tasks_parent_class)->value_to_string (etm, col, value);
+ return E_TABLE_MODEL_CLASS (parent_class)->value_to_string (etm, col, value);
switch (col) {
case E_CAL_MODEL_TASKS_FIELD_GEO :
@@ -1044,7 +1040,7 @@ ecmt_get_color_for_component (ECalModel *model, ECalModelComponent *comp_data)
break;
}
- return E_CAL_MODEL_CLASS (e_cal_model_tasks_parent_class)->get_color_for_component (model, comp_data);
+ return E_CAL_MODEL_CLASS (parent_class)->get_color_for_component (model, comp_data);
}
static void
diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c
index f9e7de2003..87f23b2f45 100644
--- a/calendar/gui/e-cal-model.c
+++ b/calendar/gui/e-cal-model.c
@@ -1,6 +1,7 @@
/* Evolution calendar - Data model for ETable
*
- * Copyright (C) 2004 Novell, Inc.
+ * Copyright (C) 2000 Ximian, Inc.
+ * Copyright (C) 2000 Ximian, Inc.
*
* Authors: Rodrigo Moya <rodrigo@ximian.com>
*
@@ -25,6 +26,7 @@
#include <string.h>
#include <glib/garray.h>
#include <libgnome/gnome-i18n.h>
+#include <gal/util/e-util.h>
#include <e-util/e-time-utils.h>
#include <libecal/e-cal-time-util.h>
#include "comp-util.h"
@@ -74,6 +76,8 @@ struct _ECalModelPrivate {
gboolean use_24_hour_format;
};
+static void e_cal_model_class_init (ECalModelClass *klass);
+static void e_cal_model_init (ECalModel *model, ECalModelClass *klass);
static void e_cal_model_dispose (GObject *object);
static void e_cal_model_finalize (GObject *object);
@@ -105,7 +109,10 @@ enum {
static guint signals[LAST_SIGNAL] = { 0 };
-G_DEFINE_TYPE (ECalModel, e_cal_model, E_TABLE_MODEL_TYPE);
+static GObjectClass *parent_class = NULL;
+
+E_MAKE_TYPE (e_cal_model, "ECalModel", ECalModel, e_cal_model_class_init,
+ e_cal_model_init, E_TABLE_MODEL_TYPE);
static void
e_cal_model_class_init (ECalModelClass *klass)
@@ -113,6 +120,8 @@ e_cal_model_class_init (ECalModelClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
ETableModelClass *etm_class = E_TABLE_MODEL_CLASS (klass);
+ parent_class = g_type_class_peek_parent (klass);
+
object_class->dispose = e_cal_model_dispose;
object_class->finalize = e_cal_model_finalize;
@@ -151,7 +160,7 @@ e_cal_model_class_init (ECalModelClass *klass)
}
static void
-e_cal_model_init (ECalModel *model)
+e_cal_model_init (ECalModel *model, ECalModelClass *klass)
{
ECalModelPrivate *priv;
@@ -174,6 +183,46 @@ e_cal_model_init (ECalModel *model)
}
static void
+free_comp_data (ECalModelComponent *comp_data)
+{
+ g_return_if_fail (comp_data != NULL);
+
+ comp_data->client = NULL;
+
+ if (comp_data->icalcomp) {
+ icalcomponent_free (comp_data->icalcomp);
+ comp_data->icalcomp = NULL;
+ }
+
+ if (comp_data->dtstart) {
+ g_free (comp_data->dtstart);
+ comp_data->dtstart = NULL;
+ }
+
+ if (comp_data->dtend) {
+ g_free (comp_data->dtend);
+ comp_data->dtend = NULL;
+ }
+
+ if (comp_data->due) {
+ g_free (comp_data->due);
+ comp_data->due = NULL;
+ }
+
+ if (comp_data->completed) {
+ g_free (comp_data->completed);
+ comp_data->completed = NULL;
+ }
+
+ if (comp_data->color) {
+ g_free (comp_data->color);
+ comp_data->color = NULL;
+ }
+
+ g_free (comp_data);
+}
+
+static void
clear_objects_array (ECalModelPrivate *priv)
{
gint i;
@@ -183,9 +232,10 @@ clear_objects_array (ECalModelPrivate *priv)
comp_data = g_ptr_array_index (priv->objects, i);
g_assert (comp_data != NULL);
- e_cal_model_free_component_data (comp_data);
+ free_comp_data (comp_data);
}
+
g_ptr_array_set_size (priv->objects, 0);
}
@@ -221,8 +271,8 @@ e_cal_model_dispose (GObject *object)
priv->clients = NULL;
}
- if (G_OBJECT_CLASS (e_cal_model_parent_class)->dispose)
- G_OBJECT_CLASS (e_cal_model_parent_class)->dispose (object);
+ if (parent_class->dispose)
+ parent_class->dispose (object);
}
static void
@@ -245,8 +295,8 @@ e_cal_model_finalize (GObject *object)
g_free (priv);
- if (G_OBJECT_CLASS (e_cal_model_parent_class)->finalize)
- G_OBJECT_CLASS (e_cal_model_parent_class)->finalize (object);
+ if (parent_class->finalize)
+ parent_class->finalize (object);
}
/* ETableModel methods */
@@ -365,12 +415,11 @@ get_dtstart (ECalModel *model, ECalModelComponent *comp_data)
&& e_cal_get_timezone (comp_data->client, icaltime_get_tzid (tt_start), &zone, NULL))
got_zone = TRUE;
- if (e_cal_model_get_flags (model) & E_CAL_MODEL_FLAGS_EXPAND_RECURRENCES) {
- if (got_zone) {
+ if ((priv->flags & E_CAL_MODEL_FLAGS_EXPAND_RECURRENCES) &&
+ (e_cal_util_component_has_recurrences (comp_data->icalcomp))) {
+ if (got_zone)
tt_start = icaltime_from_timet_with_zone (comp_data->instance_start, tt_start.is_date, zone);
- if (priv->zone)
- icaltimezone_convert_time (&tt_start, zone, priv->zone);
- } else
+ else
tt_start = icaltime_from_timet (comp_data->instance_start, tt_start.is_date);
}
@@ -718,7 +767,7 @@ ecm_append_row (ETableModel *etm, ETableModel *source, int row)
g_return_if_fail (E_IS_CAL_MODEL (model));
g_return_if_fail (E_IS_TABLE_MODEL (source));
- memset (&comp_data, 0, sizeof (ECalModelComponent));
+ memset (&comp_data, 0, sizeof (comp_data));
comp_data.client = e_cal_model_get_default_client (model);
/* guard against saving before the calendar is open */
@@ -740,6 +789,7 @@ ecm_append_row (ETableModel *etm, ETableModel *source, int row)
model_class->fill_component_from_model (model, &comp_data, source, row);
}
+
if (!e_cal_create_object (comp_data.client, comp_data.icalcomp, NULL, NULL)) {
g_warning (G_STRLOC ": Could not create the object!");
@@ -1238,7 +1288,7 @@ search_by_uid_and_client (ECalModelPrivate *priv, ECal *client, const char *uid)
tmp_uid = icalcomponent_get_uid (comp_data->icalcomp);
if (tmp_uid && *tmp_uid) {
- if (comp_data->client == client && !strcmp (uid, tmp_uid))
+ if ((!client || comp_data->client == client) && !strcmp (uid, tmp_uid))
return comp_data;
}
}
@@ -1279,12 +1329,10 @@ add_instance_cb (ECalComponent *comp, time_t instance_start, time_t instance_end
e_table_model_pre_change (E_TABLE_MODEL (rdata->model));
comp_data = g_new0 (ECalModelComponent, 1);
- comp_data->client = g_object_ref (rdata->client);
- comp_data->icalcomp = icalcomponent_new_clone (e_cal_component_get_icalcomponent (comp));
+ comp_data->client = g_object_ref (e_cal_view_get_client (rdata->query));
+ comp_data->icalcomp = icalcomponent_new_clone (rdata->icalcomp);
comp_data->instance_start = instance_start;
comp_data->instance_end = instance_end;
- comp_data->dtstart = comp_data->dtend = comp_data->due = comp_data->completed = NULL;
- comp_data->color = NULL;
g_ptr_array_add (priv->objects, comp_data);
e_table_model_row_inserted (E_TABLE_MODEL (rdata->model), priv->objects->len - 1);
@@ -1293,26 +1341,6 @@ add_instance_cb (ECalComponent *comp, time_t instance_start, time_t instance_end
}
static void
-set_instance_times (ECalModelComponent *comp_data, icaltimezone *zone)
-{
- struct icaltimetype recur_time, start_time, end_time, itt;
-
- recur_time = icalcomponent_get_recurrenceid (comp_data->icalcomp);
- start_time = icalcomponent_get_dtstart (comp_data->icalcomp);
- end_time = icalcomponent_get_dtend (comp_data->icalcomp);
-
- if (e_cal_util_component_is_instance (comp_data->icalcomp)) {
- itt = icaltime_convert_to_zone (recur_time, icaltimezone_get_utc_timezone ());
- comp_data->instance_start = icaltime_as_timet (itt);
- } else {
- comp_data->instance_start = icaltime_as_timet (start_time);
- }
-
- comp_data->instance_end = comp_data->instance_start +
- (icaltime_as_timet (end_time) - icaltime_as_timet (start_time));
-}
-
-static void
e_cal_view_objects_added_cb (ECalView *query, GList *objects, gpointer user_data)
{
ECalModel *model = (ECalModel *) user_data;
@@ -1322,21 +1350,8 @@ e_cal_view_objects_added_cb (ECalView *query, GList *objects, gpointer user_data
priv = model->priv;
for (l = objects; l; l = l->next) {
- ECalModelComponent *comp_data;
-
- /* remove the components if they are already present and re-add them */
- while ((comp_data = search_by_uid_and_client (priv, e_cal_view_get_client (query),
- icalcomponent_get_uid (l->data)))) {
- int pos;
-
- pos = get_position_in_array (priv->objects, comp_data);
- e_table_model_row_deleted (E_TABLE_MODEL (model), pos);
-
- g_ptr_array_remove (priv->objects, comp_data);
- e_cal_model_free_component_data (comp_data);
- }
-
- if ((priv->flags & E_CAL_MODEL_FLAGS_EXPAND_RECURRENCES)) {
+ if ((priv->flags & E_CAL_MODEL_FLAGS_EXPAND_RECURRENCES) &&
+ e_cal_util_component_has_recurrences (l->data)) {
RecurrenceExpansionData rdata;
rdata.client = e_cal_view_get_client (query);
@@ -1348,14 +1363,13 @@ e_cal_view_objects_added_cb (ECalView *query, GList *objects, gpointer user_data
(ECalRecurInstanceFn) add_instance_cb,
&rdata);
} else {
+ ECalModelComponent *comp_data;
+
e_table_model_pre_change (E_TABLE_MODEL (model));
comp_data = g_new0 (ECalModelComponent, 1);
comp_data->client = g_object_ref (e_cal_view_get_client (query));
comp_data->icalcomp = icalcomponent_new_clone (l->data);
- set_instance_times (comp_data, priv->zone);
- comp_data->dtstart = comp_data->dtend = comp_data->due = comp_data->completed = NULL;
- comp_data->color = NULL;
g_ptr_array_add (priv->objects, comp_data);
e_table_model_row_inserted (E_TABLE_MODEL (model), priv->objects->len - 1);
@@ -1375,21 +1389,62 @@ e_cal_view_objects_modified_cb (ECalView *query, GList *objects, gpointer user_d
for (l = objects; l; l = l->next) {
ECalModelComponent *comp_data;
- /* remove all recurrences and re-add them after generating them */
- while ((comp_data = search_by_uid_and_client (priv, e_cal_view_get_client (query),
- icalcomponent_get_uid (l->data)))) {
- int pos;
+ if ((priv->flags & E_CAL_MODEL_FLAGS_EXPAND_RECURRENCES) &&
+ e_cal_util_component_has_recurrences (l->data)) {
+ GList node;
- pos = get_position_in_array (priv->objects, comp_data);
- e_table_model_row_deleted (E_TABLE_MODEL (model), pos);
+ /* remove all recurrences and re-add them after generating them */
+ while ((comp_data = search_by_uid_and_client (priv, e_cal_view_get_client (query),
+ icalcomponent_get_uid (l->data)))) {
+ int pos;
- g_ptr_array_remove (priv->objects, comp_data);
- e_cal_model_free_component_data (comp_data);
+ pos = get_position_in_array (priv->objects, comp_data);
+
+ g_ptr_array_remove (priv->objects, comp_data);
+ free_comp_data (comp_data);
+
+ e_table_model_row_deleted (E_TABLE_MODEL (model), pos);
+ }
+
+ node.prev = node.next = NULL;
+ node.data = l->data;
+ e_cal_view_objects_added_cb (query, &node, model);
+ } else {
+ e_table_model_pre_change (E_TABLE_MODEL (model));
+
+ comp_data = search_by_uid_and_client (priv, e_cal_view_get_client (query),
+ icalcomponent_get_uid (l->data));
+ if (!comp_data)
+ continue;
+
+ if (comp_data->icalcomp)
+ icalcomponent_free (comp_data->icalcomp);
+ if (comp_data->dtstart) {
+ g_free (comp_data->dtstart);
+ comp_data->dtstart = NULL;
+ }
+ if (comp_data->dtend) {
+ g_free (comp_data->dtend);
+ comp_data->dtend = NULL;
+ }
+ if (comp_data->due) {
+ g_free (comp_data->due);
+ comp_data->due = NULL;
+ }
+ if (comp_data->completed) {
+ g_free (comp_data->completed);
+ comp_data->completed = NULL;
+ }
+ if (comp_data->color) {
+ g_free (comp_data->color);
+ comp_data->color = NULL;
+ }
+
+ comp_data->icalcomp = icalcomponent_new_clone (l->data);
+
+ e_table_model_row_changed (E_TABLE_MODEL (model), get_position_in_array (priv->objects, comp_data));
}
}
-
- /* now re-add all objects */
- e_cal_view_objects_added_cb (query, objects, model);
}
static void
@@ -1410,10 +1465,11 @@ e_cal_view_objects_removed_cb (ECalView *query, GList *uids, gpointer user_data)
/* make sure we remove all objects with this UID */
while ((comp_data = search_by_uid_and_client (priv, e_cal_view_get_client (query), l->data))) {
pos = get_position_in_array (priv->objects, comp_data);
- e_table_model_row_deleted (E_TABLE_MODEL (model), pos);
-
+
g_ptr_array_remove (priv->objects, comp_data);
- e_cal_model_free_component_data (comp_data);
+ free_comp_data (comp_data);
+
+ e_table_model_row_deleted (E_TABLE_MODEL (model), pos);
}
}
}
@@ -1581,10 +1637,11 @@ remove_client_objects (ECalModel *model, ECalModelClient *client_data)
if (comp_data->client == client_data->client) {
e_table_model_pre_change (E_TABLE_MODEL (model));
- e_table_model_row_deleted (E_TABLE_MODEL (model), i - 1);
-
+
g_ptr_array_remove (model->priv->objects, comp_data);
- e_cal_model_free_component_data (comp_data);
+ free_comp_data (comp_data);
+
+ e_table_model_row_deleted (E_TABLE_MODEL (model), i - 1);
}
}
}
@@ -1684,8 +1741,8 @@ redo_queries (ECalModel *model)
/* clean up the current contents */
e_table_model_pre_change (E_TABLE_MODEL (model));
len = priv->objects->len;
- e_table_model_rows_deleted (E_TABLE_MODEL (model), 0, len);
clear_objects_array (priv);
+ e_table_model_rows_deleted (E_TABLE_MODEL (model), 0, len);
/* update the query for all clients */
for (l = priv->clients; l != NULL; l = l->next) {
@@ -1943,9 +2000,10 @@ copy_ecdv (ECellDateEditValue *ecdv)
{
ECellDateEditValue *new_ecdv;
+
new_ecdv = g_new0 (ECellDateEditValue, 1);
- new_ecdv->tt = ecdv ? ecdv->tt : icaltime_null_time ();
- new_ecdv->zone = ecdv ? ecdv->zone : NULL;
+ new_ecdv->tt = ecdv->tt;
+ new_ecdv->zone = ecdv->zone;
return new_ecdv;
}
@@ -1962,8 +2020,6 @@ e_cal_model_copy_component_data (ECalModelComponent *comp_data)
new_data = g_new0 (ECalModelComponent, 1);
- new_data->instance_start = comp_data->instance_start;
- new_data->instance_end = comp_data->instance_end;
if (comp_data->icalcomp)
new_data->icalcomp = icalcomponent_new_clone (comp_data->icalcomp);
if (comp_data->client)
@@ -1976,8 +2032,6 @@ e_cal_model_copy_component_data (ECalModelComponent *comp_data)
new_data->due = copy_ecdv (comp_data->due);
if (comp_data->completed)
new_data->completed = copy_ecdv (comp_data->completed);
- if (comp_data->color)
- new_data->color = g_strdup (comp_data->color);
return new_data;
}
@@ -1990,34 +2044,20 @@ e_cal_model_free_component_data (ECalModelComponent *comp_data)
{
g_return_if_fail (comp_data != NULL);
- if (comp_data->client) {
+ if (comp_data->client)
g_object_unref (comp_data->client);
- comp_data->client = NULL;
- }
- if (comp_data->icalcomp) {
+ if (comp_data->icalcomp)
icalcomponent_free (comp_data->icalcomp);
- comp_data->icalcomp = NULL;
- }
- if (comp_data->dtstart) {
+ if (comp_data->dtstart)
g_free (comp_data->dtstart);
- comp_data->dtstart = NULL;
- }
- if (comp_data->dtend) {
+ if (comp_data->dtend)
g_free (comp_data->dtend);
- comp_data->dtend = NULL;
- }
- if (comp_data->due) {
+ if (comp_data->due)
g_free (comp_data->due);
- comp_data->due = NULL;
- }
- if (comp_data->completed) {
+ if (comp_data->completed)
g_free (comp_data->completed);
- comp_data->completed = NULL;
- }
- if (comp_data->color) {
+ if (comp_data->color)
g_free (comp_data->color);
- comp_data->color = NULL;
- }
g_free (comp_data);
}
diff --git a/calendar/gui/e-calendar-table.c b/calendar/gui/e-calendar-table.c
index a3d50bb475..7eec950039 100644
--- a/calendar/gui/e-calendar-table.c
+++ b/calendar/gui/e-calendar-table.c
@@ -27,10 +27,7 @@
* Used for calendar events and tasks.
*/
-#ifdef HAVE_CONFIG_H
#include <config.h>
-#endif
-
#include <sys/stat.h>
#include <unistd.h>
#include <gnome.h>
@@ -39,6 +36,7 @@
#include <gal/e-table/e-cell-toggle.h>
#include <gal/e-table/e-cell-text.h>
#include <gal/e-table/e-cell-combo.h>
+#include <gal/widgets/e-popup-menu.h>
#include <e-util/e-dialog-utils.h>
#include <widgets/misc/e-cell-date-edit.h>
#include <widgets/misc/e-cell-percent.h>
@@ -54,7 +52,6 @@
#include "e-comp-editor-registry.h"
#include "print.h"
#include <e-util/e-icon-factory.h>
-#include "e-cal-popup.h"
extern ECompEditorRegistry *comp_editor_registry;
@@ -79,6 +76,22 @@ static gint e_calendar_table_on_right_click (ETable *table,
static gboolean e_calendar_table_on_popup_menu (GtkWidget *widget,
gpointer data);
+static void e_calendar_table_on_open_task (GtkWidget *menuitem,
+ gpointer data);
+static void e_calendar_table_on_save_as (GtkWidget *menuitem,
+ gpointer data);
+static void e_calendar_table_on_print_task (GtkWidget *menuitem,
+ gpointer data);
+static void e_calendar_table_on_cut (GtkWidget *menuitem,
+ gpointer data);
+static void e_calendar_table_on_copy (GtkWidget *menuitem,
+ gpointer data);
+static void e_calendar_table_on_paste (GtkWidget *menuitem,
+ gpointer data);
+static void e_calendar_table_on_assign (GtkWidget *menuitem,
+ gpointer data);
+static void e_calendar_table_on_forward (GtkWidget *menuitem,
+ gpointer data);
static gint e_calendar_table_on_key_press (ETable *table,
gint row,
gint col,
@@ -106,9 +119,11 @@ static const char* icon_names[E_CALENDAR_MODEL_NUM_ICONS] = {
};
static GdkPixbuf* icon_pixbufs[E_CALENDAR_MODEL_NUM_ICONS] = { 0 };
+static GtkTableClass *parent_class;
static GdkAtom clipboard_atom = GDK_NONE;
-G_DEFINE_TYPE (ECalendarTable, e_calendar_table, GTK_TYPE_TABLE);
+E_MAKE_TYPE (e_calendar_table, "ECalendarTable", ECalendarTable, e_calendar_table_class_init,
+ e_calendar_table_init, GTK_TYPE_TABLE);
static void
e_calendar_table_class_init (ECalendarTableClass *class)
@@ -116,6 +131,7 @@ e_calendar_table_class_init (ECalendarTableClass *class)
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
+ parent_class = g_type_class_peek_parent (class);
object_class = (GtkObjectClass *) class;
widget_class = (GtkWidgetClass *) class;
@@ -294,7 +310,6 @@ e_calendar_table_init (ECalendarTable *cal_table)
gint i;
GdkPixbuf *pixbuf;
GList *strings;
- AtkObject *a11y;
/* Create the model */
@@ -510,10 +525,6 @@ e_calendar_table_init (ECalendarTable *cal_table)
g_signal_connect (e_table, "right_click", G_CALLBACK (e_calendar_table_on_right_click), cal_table);
g_signal_connect (e_table, "key_press", G_CALLBACK (e_calendar_table_on_key_press), cal_table);
g_signal_connect (e_table, "popup_menu", G_CALLBACK (e_calendar_table_on_popup_menu), cal_table);
-
- a11y = gtk_widget_get_accessible (e_table);
- if (a11y)
- atk_object_set_name (a11y, _("Task Table"));
}
@@ -564,7 +575,7 @@ e_calendar_table_destroy (GtkObject *object)
cal_table->model = NULL;
}
- GTK_OBJECT_CLASS (e_calendar_table_parent_class)->destroy (object);
+ GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
/**
@@ -589,12 +600,10 @@ void
e_calendar_table_open_selected (ECalendarTable *cal_table)
{
ECalModelComponent *comp_data;
- icalproperty *prop;
comp_data = get_selected_comp (cal_table);
- prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_ATTENDEE_PROPERTY);
if (comp_data != NULL)
- open_task (cal_table, comp_data, prop ? TRUE : FALSE);
+ open_task (cal_table, comp_data, FALSE);
}
/**
@@ -753,21 +762,6 @@ e_calendar_table_delete_selected (ECalendarTable *cal_table)
}
/**
- * e_calendar_table_get_selected:
- * @cal_table:
- *
- * Get the currently selected ECalModelComponent's on the table.
- *
- * Return value: A GSList of the components, which should be
- * g_slist_free'd when finished with.
- **/
-GSList *
-e_calendar_table_get_selected (ECalendarTable *cal_table)
-{
- return get_selected_objects(cal_table);
-}
-
-/**
* e_calendar_table_cut_clipboard:
* @cal_table: A calendar table.
*
@@ -947,7 +941,7 @@ open_task (ECalendarTable *cal_table, ECalModelComponent *comp_data, gboolean as
if (tedit == NULL) {
ECalComponent *comp;
- tedit = COMP_EDITOR (task_editor_new (comp_data->client, assign));
+ tedit = COMP_EDITOR (task_editor_new (comp_data->client));
comp = e_cal_component_new ();
e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp));
@@ -966,11 +960,9 @@ static void
open_task_by_row (ECalendarTable *cal_table, int row)
{
ECalModelComponent *comp_data;
- icalproperty *prop;
comp_data = e_cal_model_get_component_at (cal_table->model, row);
- prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_ATTENDEE_PROPERTY);
- open_task (cal_table, comp_data, prop ? TRUE : FALSE);
+ open_task (cal_table, comp_data, FALSE);
}
static void
@@ -983,30 +975,223 @@ e_calendar_table_on_double_click (ETable *table,
open_task_by_row (cal_table, row);
}
-/* popup menu callbacks */
+/* Used from e_table_selected_row_foreach() */
+static void
+mark_row_complete_cb (int model_row, gpointer data)
+{
+ ECalendarTable *cal_table;
+
+ cal_table = E_CALENDAR_TABLE (data);
+ e_cal_model_tasks_mark_task_complete (E_CAL_MODEL_TASKS (cal_table->model), model_row);
+}
+/* Callback used for the "mark tasks as complete" menu item */
static void
-e_calendar_table_on_open_task (EPopup *ep, EPopupItem *pitem, void *data)
+mark_as_complete_cb (GtkWidget *menuitem, gpointer data)
{
- ECalendarTable *cal_table = data;
+ ECalendarTable *cal_table;
+ ETable *etable;
+
+ cal_table = E_CALENDAR_TABLE (data);
+
+ etable = e_table_scrolled_get_table (E_TABLE_SCROLLED (cal_table->etable));
+ e_table_selected_row_foreach (etable, mark_row_complete_cb, cal_table);
+}
+
+/* Opens the URL of the task */
+static void
+open_url_cb (GtkWidget *menuitem, gpointer data)
+{
+ ECalendarTable *cal_table;
ECalModelComponent *comp_data;
icalproperty *prop;
+ cal_table = E_CALENDAR_TABLE (data);
+
+ comp_data = get_selected_comp (cal_table);
+ if (!comp_data)
+ return;
+
+ prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_URL_PROPERTY);
+ if (!prop)
+ return;
+
+ gnome_url_show (icalproperty_get_url (prop), NULL);
+}
+
+/* Callback for the "delete tasks" menu item */
+static void
+delete_cb (GtkWidget *menuitem, gpointer data)
+{
+ ECalendarTable *cal_table;
+
+ cal_table = E_CALENDAR_TABLE (data);
+ e_calendar_table_delete_selected (cal_table);
+}
+
+
+enum {
+ MASK_SINGLE = 1 << 0, /* For commands that work on 1 task. */
+ MASK_MULTIPLE = 1 << 1, /* For commands for multiple tasks. */
+ MASK_EDITABLE = 1 << 2, /* For commands disabled in read-only folders */
+ MASK_ASSIGNABLE = 1 << 3, /* For non-task assignable backends */
+ MASK_LACKS_URL = 1 << 4 /* For tasks that don't have the URL property set */
+};
+
+
+static EPopupMenu tasks_popup_menu [] = {
+ E_POPUP_ITEM (N_("_Open"), GTK_SIGNAL_FUNC (e_calendar_table_on_open_task), MASK_SINGLE),
+ E_POPUP_ITEM (N_("Open _Web Page"), GTK_SIGNAL_FUNC (open_url_cb), MASK_SINGLE | MASK_LACKS_URL),
+ E_POPUP_ITEM (N_("_Save As..."), GTK_SIGNAL_FUNC (e_calendar_table_on_save_as), MASK_SINGLE),
+ E_POPUP_ITEM (N_("_Print..."), GTK_SIGNAL_FUNC (e_calendar_table_on_print_task), MASK_SINGLE),
+
+ E_POPUP_SEPARATOR,
+
+ E_POPUP_ITEM (N_("C_ut"), GTK_SIGNAL_FUNC (e_calendar_table_on_cut), MASK_EDITABLE),
+ E_POPUP_ITEM (N_("_Copy"), GTK_SIGNAL_FUNC (e_calendar_table_on_copy), 0),
+ E_POPUP_ITEM (N_("_Paste"), GTK_SIGNAL_FUNC (e_calendar_table_on_paste), MASK_EDITABLE),
+
+ E_POPUP_SEPARATOR,
+
+ E_POPUP_ITEM (N_("_Assign Task"), GTK_SIGNAL_FUNC (e_calendar_table_on_assign), MASK_SINGLE | MASK_EDITABLE | MASK_ASSIGNABLE),
+ E_POPUP_ITEM (N_("_Forward as iCalendar"), GTK_SIGNAL_FUNC (e_calendar_table_on_forward), MASK_SINGLE),
+ E_POPUP_ITEM (N_("_Mark as Complete"), GTK_SIGNAL_FUNC (mark_as_complete_cb), MASK_SINGLE | MASK_EDITABLE),
+ E_POPUP_ITEM (N_("_Mark Selected Tasks as Complete"), GTK_SIGNAL_FUNC (mark_as_complete_cb), MASK_MULTIPLE | MASK_EDITABLE),
+
+ E_POPUP_SEPARATOR,
+
+ E_POPUP_ITEM (N_("_Delete"), GTK_SIGNAL_FUNC (delete_cb), MASK_SINGLE | MASK_EDITABLE),
+ E_POPUP_ITEM (N_("_Delete Selected Tasks"), GTK_SIGNAL_FUNC (delete_cb), MASK_MULTIPLE | MASK_EDITABLE),
+
+ E_POPUP_TERMINATOR
+};
+
+static void
+setup_popup_icons (EPopupMenu *context_menu)
+{
+ gint i;
+
+ for (i = 0; context_menu[i].name; i++) {
+ GtkWidget *pixmap_widget = NULL;
+
+ if (!strcmp (context_menu[i].name, _("_Copy")))
+ pixmap_widget = gtk_image_new_from_stock (GTK_STOCK_COPY, GTK_ICON_SIZE_MENU);
+ else if (!strcmp (context_menu[i].name, _("C_ut")))
+ pixmap_widget = gtk_image_new_from_stock (GTK_STOCK_CUT, GTK_ICON_SIZE_MENU);
+ else if (!strcmp (context_menu[i].name, _("_Delete")) ||
+ !strcmp (context_menu[i].name, _("_Delete Selected Tasks")))
+ pixmap_widget = gtk_image_new_from_stock (GTK_STOCK_DELETE, GTK_ICON_SIZE_MENU);
+ else if (!strcmp (context_menu[i].name, _("_Open")))
+ pixmap_widget = gtk_image_new_from_stock (GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU);
+ else if (!strcmp (context_menu[i].name, _("_Paste")))
+ pixmap_widget = gtk_image_new_from_stock (GTK_STOCK_PASTE, GTK_ICON_SIZE_MENU);
+ else if (!strcmp (context_menu[i].name, _("_Print...")))
+ pixmap_widget = gtk_image_new_from_stock (GTK_STOCK_PRINT, GTK_ICON_SIZE_MENU);
+ else if (!strcmp (context_menu[i].name, _("_Save As...")))
+ pixmap_widget = gtk_image_new_from_stock (GTK_STOCK_SAVE_AS, GTK_ICON_SIZE_MENU);
+
+ if (pixmap_widget)
+ gtk_widget_show (pixmap_widget);
+ context_menu[i].pixmap_widget = pixmap_widget;
+ }
+}
+
+static gint
+e_calendar_table_show_popup_menu (ETable *table,
+ GdkEvent *gdk_event,
+ ECalendarTable *cal_table)
+{
+ int n_selected;
+ int hide_mask = 0;
+ int disable_mask = 0;
+ GtkMenu *gtk_menu;
+ icalproperty *prop;
+ GSList *selection;
+ ECalModelComponent *comp_data;
+ gboolean read_only = TRUE;
+
+ selection = get_selected_objects (cal_table);
+ if (!selection)
+ return TRUE;
+
+ comp_data = selection->data;
+ n_selected = g_slist_length (selection);
+ if (n_selected == 1) {
+ hide_mask = MASK_MULTIPLE;
+
+ /* See if the task has the URL property set */
+ prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_URL_PROPERTY);
+ if (!prop)
+ disable_mask |= MASK_LACKS_URL;
+ } else
+ hide_mask = MASK_SINGLE;
+
+ e_cal_is_read_only (comp_data->client, &read_only, NULL);
+ if (read_only)
+ disable_mask |= MASK_EDITABLE;
+
+ if (e_cal_get_static_capability (comp_data->client, CAL_STATIC_CAPABILITY_NO_TASK_ASSIGNMENT))
+ disable_mask |= MASK_ASSIGNABLE;
+
+ if (e_cal_get_static_capability (comp_data->client, CAL_STATIC_CAPABILITY_NO_CONV_TO_ASSIGN_TASK))
+ disable_mask |= MASK_ASSIGNABLE;
+
+ setup_popup_icons (tasks_popup_menu);
+ gtk_menu = e_popup_menu_create (tasks_popup_menu, disable_mask,
+ hide_mask, cal_table);
+
+ e_popup_menu (gtk_menu, gdk_event);
+
+ g_slist_free (selection);
+
+ return TRUE;
+}
+
+static gint
+e_calendar_table_on_right_click (ETable *table,
+ gint row,
+ gint col,
+ GdkEvent *event,
+ ECalendarTable *cal_table)
+{
+ return e_calendar_table_show_popup_menu (table, event, cal_table);
+}
+
+static gboolean
+e_calendar_table_on_popup_menu (GtkWidget *widget, gpointer data)
+{
+ ETable *table = E_TABLE(widget);
+ g_return_val_if_fail(table, FALSE);
+
+ return e_calendar_table_show_popup_menu (table, NULL,
+ E_CALENDAR_TABLE(data));
+}
+
+static void
+e_calendar_table_on_open_task (GtkWidget *menuitem,
+ gpointer data)
+{
+ ECalendarTable *cal_table;
+ ECalModelComponent *comp_data;
+
+ cal_table = E_CALENDAR_TABLE (data);
+
comp_data = get_selected_comp (cal_table);
- prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_ATTENDEE_PROPERTY);
if (comp_data)
- open_task (cal_table, comp_data, prop ? TRUE : FALSE);
+ open_task (cal_table, comp_data, FALSE);
}
static void
-e_calendar_table_on_save_as (EPopup *ep, EPopupItem *pitem, void *data)
+e_calendar_table_on_save_as (GtkWidget *widget, gpointer data)
{
- ECalendarTable *cal_table = data;
+ ECalendarTable *cal_table;
ECalModelComponent *comp_data;
char *filename;
char *ical_string;
FILE *file;
+ cal_table = E_CALENDAR_TABLE (data);
+
comp_data = get_selected_comp (cal_table);
if (comp_data == NULL)
return;
@@ -1033,12 +1218,14 @@ e_calendar_table_on_save_as (EPopup *ep, EPopupItem *pitem, void *data)
}
static void
-e_calendar_table_on_print_task (EPopup *ep, EPopupItem *pitem, void *data)
+e_calendar_table_on_print_task (GtkWidget *widget, gpointer data)
{
- ECalendarTable *cal_table = data;
+ ECalendarTable *cal_table;
ECalModelComponent *comp_data;
ECalComponent *comp;
+ cal_table = E_CALENDAR_TABLE (data);
+
comp_data = get_selected_comp (cal_table);
if (comp_data == NULL)
return;
@@ -1051,203 +1238,65 @@ e_calendar_table_on_print_task (EPopup *ep, EPopupItem *pitem, void *data)
}
static void
-e_calendar_table_on_cut (EPopup *ep, EPopupItem *pitem, void *data)
+e_calendar_table_on_cut (GtkWidget *menuitem, gpointer data)
{
- ECalendarTable *cal_table = data;
+ ECalendarTable *cal_table;
+ cal_table = E_CALENDAR_TABLE (data);
e_calendar_table_cut_clipboard (cal_table);
}
static void
-e_calendar_table_on_copy (EPopup *ep, EPopupItem *pitem, void *data)
+e_calendar_table_on_copy (GtkWidget *menuitem, gpointer data)
{
- ECalendarTable *cal_table = data;
+ ECalendarTable *cal_table;
+ cal_table = E_CALENDAR_TABLE (data);
e_calendar_table_copy_clipboard (cal_table);
}
static void
-e_calendar_table_on_paste (EPopup *ep, EPopupItem *pitem, void *data)
+e_calendar_table_on_paste (GtkWidget *menuitem, gpointer data)
{
- ECalendarTable *cal_table = data;
+ ECalendarTable *cal_table;
+ cal_table = E_CALENDAR_TABLE (data);
e_calendar_table_paste_clipboard (cal_table);
}
static void
-e_calendar_table_on_assign (EPopup *ep, EPopupItem *pitem, void *data)
+e_calendar_table_on_assign (GtkWidget *widget, gpointer data)
{
- ECalendarTable *cal_table = data;
+ ECalendarTable *cal_table;
ECalModelComponent *comp_data;
+ cal_table = E_CALENDAR_TABLE (data);
+
comp_data = get_selected_comp (cal_table);
if (comp_data)
open_task (cal_table, comp_data, TRUE);
}
static void
-e_calendar_table_on_forward (EPopup *ep, EPopupItem *pitem, void *data)
+e_calendar_table_on_forward (GtkWidget *widget, gpointer data)
{
- ECalendarTable *cal_table = data;
+ ECalendarTable *cal_table;
ECalModelComponent *comp_data;
+ cal_table = E_CALENDAR_TABLE (data);
+
comp_data = get_selected_comp (cal_table);
if (comp_data) {
ECalComponent *comp;
comp = e_cal_component_new ();
e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp));
- itip_send_comp (E_CAL_COMPONENT_METHOD_PUBLISH, comp, comp_data->client, NULL, NULL);
+ itip_send_comp (E_CAL_COMPONENT_METHOD_PUBLISH, comp, comp_data->client, NULL);
g_object_unref (comp);
}
}
-/* Used from e_table_selected_row_foreach() */
-static void
-mark_row_complete_cb (int model_row, gpointer data)
-{
- ECalendarTable *cal_table;
-
- cal_table = E_CALENDAR_TABLE (data);
- e_cal_model_tasks_mark_task_complete (E_CAL_MODEL_TASKS (cal_table->model), model_row);
-}
-
-/* Callback used for the "mark tasks as complete" menu item */
-static void
-mark_as_complete_cb (EPopup *ep, EPopupItem *pitem, void *data)
-{
- ECalendarTable *cal_table = data;
- ETable *etable;
-
- etable = e_table_scrolled_get_table (E_TABLE_SCROLLED (cal_table->etable));
- e_table_selected_row_foreach (etable, mark_row_complete_cb, cal_table);
-}
-
-/* Opens the URL of the task */
-static void
-open_url_cb (EPopup *ep, EPopupItem *pitem, void *data)
-{
- ECalendarTable *cal_table = data;
- ECalModelComponent *comp_data;
- icalproperty *prop;
-
- comp_data = get_selected_comp (cal_table);
- if (!comp_data)
- return;
-
- prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_URL_PROPERTY);
- if (!prop)
- return;
-
- gnome_url_show (icalproperty_get_url (prop), NULL);
-}
-
-/* Callback for the "delete tasks" menu item */
-static void
-delete_cb (EPopup *ep, EPopupItem *pitem, void *data)
-{
- ECalendarTable *cal_table = data;
-
- e_calendar_table_delete_selected (cal_table);
-}
-
-static EPopupItem tasks_popup_items [] = {
- { E_POPUP_ITEM, "00.open", N_("_Open"), e_calendar_table_on_open_task, NULL, GTK_STOCK_OPEN, E_CAL_POPUP_SELECT_ONE },
- { E_POPUP_ITEM, "05.openweb", N_("Open _Web Page"), open_url_cb, NULL, NULL, E_CAL_POPUP_SELECT_ONE, E_CAL_POPUP_SELECT_HASURL },
- { E_POPUP_ITEM, "10.saveas", N_("_Save As..."), e_calendar_table_on_save_as, NULL, GTK_STOCK_SAVE_AS, E_CAL_POPUP_SELECT_ONE },
- { E_POPUP_ITEM, "20.print", N_("_Print..."), e_calendar_table_on_print_task, NULL, GTK_STOCK_PRINT, E_CAL_POPUP_SELECT_ONE },
-
- { E_POPUP_BAR, "30.bar" },
-
- { E_POPUP_ITEM, "40.cut", N_("C_ut"), e_calendar_table_on_cut, NULL, GTK_STOCK_CUT, 0, E_CAL_POPUP_SELECT_EDITABLE },
- { E_POPUP_ITEM, "50.copy", N_("_Copy"), e_calendar_table_on_copy, NULL, GTK_STOCK_COPY, 0, 0 },
- { E_POPUP_ITEM, "60.paste", N_("_Paste"), e_calendar_table_on_paste, NULL, GTK_STOCK_PASTE, 0, E_CAL_POPUP_SELECT_EDITABLE },
-
- { E_POPUP_BAR, "70.bar" },
-
- { E_POPUP_ITEM, "80.assign", N_("_Assign Task"), e_calendar_table_on_assign, NULL, NULL, E_CAL_POPUP_SELECT_ONE, E_CAL_POPUP_SELECT_EDITABLE|E_CAL_POPUP_SELECT_ASSIGNABLE },
- { E_POPUP_ITEM, "90.forward", N_("_Forward as iCalendar"), e_calendar_table_on_forward, NULL, "stock_mail-forward", E_CAL_POPUP_SELECT_ONE },
- { E_POPUP_ITEM, "a0.markonecomplete", N_("_Mark as Complete"), mark_as_complete_cb, NULL, NULL, E_CAL_POPUP_SELECT_ONE, E_CAL_POPUP_SELECT_EDITABLE },
- { E_POPUP_ITEM, "b0.markmanycomplete", N_("_Mark Selected Tasks as Complete"), mark_as_complete_cb, NULL, NULL, E_CAL_POPUP_SELECT_MANY, E_CAL_POPUP_SELECT_EDITABLE },
-
- { E_POPUP_BAR, "c0.bar" },
-
- { E_POPUP_ITEM, "d0.delete", N_("_Delete"), delete_cb, NULL, GTK_STOCK_DELETE, E_CAL_POPUP_SELECT_ONE, E_CAL_POPUP_SELECT_EDITABLE },
- { E_POPUP_ITEM, "e0.deletemany", N_("_Delete Selected Tasks"), delete_cb, NULL, GTK_STOCK_DELETE, E_CAL_POPUP_SELECT_MANY, E_CAL_POPUP_SELECT_EDITABLE },
-};
-
-static void
-ect_popup_free(EPopup *ep, GSList *items, void *data)
-{
- g_slist_free(items);
-}
-
-static gint
-e_calendar_table_show_popup_menu (ETable *table,
- GdkEvent *gdk_event,
- ECalendarTable *cal_table)
-{
- GtkMenu *menu;
- GSList *selection, *l, *menus = NULL;
- GPtrArray *events;
- ECalPopup *ep;
- ECalPopupTargetSelect *t;
- int i;
-
- selection = get_selected_objects (cal_table);
- if (!selection)
- return TRUE;
-
- /** @HookPoint-ECalPopup: Tasks Table Context Menu
- * @Id: org.gnome.evolution.tasks.table.popup
- * @Class: org.gnome.evolution.calendar.popup:1.0
- * @Target: ECalPopupTargetSelect
- *
- * The context menu on the tasks table.
- */
- ep = e_cal_popup_new("org.gnome.evolution.tasks.table.popup");
-
- events = g_ptr_array_new();
- for (l=selection;l;l=g_slist_next(l))
- g_ptr_array_add(events, e_cal_model_copy_component_data((ECalModelComponent *)l->data));
- g_slist_free(selection);
-
- t = e_cal_popup_target_new_select(ep, cal_table->model, events);
- t->target.widget = (GtkWidget *)cal_table;
-
- for (i=0;i<sizeof(tasks_popup_items)/sizeof(tasks_popup_items[0]);i++)
- menus = g_slist_prepend(menus, &tasks_popup_items[i]);
- e_popup_add_items((EPopup *)ep, menus, NULL, ect_popup_free, cal_table);
-
- menu = e_popup_create_menu_once((EPopup *)ep, (EPopupTarget *)t, 0);
-
- gtk_menu_popup(menu, NULL, NULL, NULL, NULL, gdk_event?gdk_event->button.button:0,
- gdk_event?gdk_event->button.time:gtk_get_current_event_time());
-
- return TRUE;
-}
-
-static gint
-e_calendar_table_on_right_click (ETable *table,
- gint row,
- gint col,
- GdkEvent *event,
- ECalendarTable *cal_table)
-{
- return e_calendar_table_show_popup_menu (table, event, cal_table);
-}
-
-static gboolean
-e_calendar_table_on_popup_menu (GtkWidget *widget, gpointer data)
-{
- ETable *table = E_TABLE(widget);
- g_return_val_if_fail(table, FALSE);
-
- return e_calendar_table_show_popup_menu (table, NULL,
- E_CALENDAR_TABLE(data));
-}
-
static gint
e_calendar_table_on_key_press (ETable *table,
gint row,
@@ -1256,7 +1305,7 @@ e_calendar_table_on_key_press (ETable *table,
ECalendarTable *cal_table)
{
if (event->keyval == GDK_Delete) {
- delete_cb (NULL, NULL, cal_table);
+ delete_cb (NULL, cal_table);
return TRUE;
} else if ((event->keyval == GDK_o)
&&(event->state & GDK_CONTROL_MASK)) {
diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c
index 6c03060dda..169bac6131 100644
--- a/calendar/gui/e-calendar-view.c
+++ b/calendar/gui/e-calendar-view.c
@@ -21,10 +21,7 @@
* USA
*/
-#ifdef HAVE_CONFIG_H
#include <config.h>
-#endif
-
#include <string.h>
#include <time.h>
#include <gtk/gtkimage.h>
@@ -32,6 +29,7 @@
#include <gdk/gdkkeysyms.h>
#include <gtk/gtkbindings.h>
#include <libgnome/gnome-i18n.h>
+#include <gal/util/e-util.h>
#include <e-util/e-dialog-utils.h>
#include <e-util/e-icon-factory.h>
#include "e-calendar-marshal.h"
@@ -58,7 +56,6 @@
#include "print.h"
#include "goto.h"
#include "ea-calendar.h"
-#include "e-cal-popup.h"
/* Used for the status bar messages */
#define EVOLUTION_CALENDAR_PROGRESS_IMAGE "stock_calendar"
@@ -75,14 +72,20 @@ struct _ECalendarViewPrivate {
EActivityHandler *activity_handler;
guint activity_id;
+ /* The popup menu */
+ EPopupMenu *view_menu;
+
/* The default category */
char *default_category;
};
+static void e_calendar_view_class_init (ECalendarViewClass *klass);
+static void e_calendar_view_init (ECalendarView *cal_view, ECalendarViewClass *klass);
static void e_calendar_view_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
static void e_calendar_view_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
static void e_calendar_view_destroy (GtkObject *object);
+static GObjectClass *parent_class = NULL;
static GdkAtom clipboard_atom = GDK_NONE;
extern ECompEditorRegistry *comp_editor_registry;
@@ -107,8 +110,6 @@ enum {
static guint e_calendar_view_signals[LAST_SIGNAL] = { 0 };
-G_DEFINE_TYPE (ECalendarView, e_calendar_view, GTK_TYPE_TABLE);
-
static void
e_calendar_view_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
{
@@ -155,6 +156,8 @@ e_calendar_view_class_init (ECalendarViewClass *klass)
GtkBindingSet *binding_set;
+ parent_class = g_type_class_peek_parent (klass);
+
/* Method override */
gobject_class->set_property = e_calendar_view_set_property;
gobject_class->get_property = e_calendar_view_get_property;
@@ -370,7 +373,7 @@ e_calendar_view_add_event (ECalendarView *cal_view, ECal *client, time_t dtstart
send_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (cal_view)),
client, comp, TRUE)) {
itip_send_comp (E_CAL_COMPONENT_METHOD_REQUEST, comp,
- client, NULL, NULL);
+ client, NULL);
}
} else {
g_message (G_STRLOC ": Could not create the object!");
@@ -380,7 +383,7 @@ e_calendar_view_add_event (ECalendarView *cal_view, ECal *client, time_t dtstart
}
static void
-e_calendar_view_init (ECalendarView *cal_view)
+e_calendar_view_init (ECalendarView *cal_view, ECalendarViewClass *klass)
{
cal_view->priv = g_new0 (ECalendarViewPrivate, 1);
@@ -412,10 +415,13 @@ e_calendar_view_destroy (GtkObject *object)
cal_view->priv = NULL;
}
- if (GTK_OBJECT_CLASS (e_calendar_view_parent_class)->destroy)
- GTK_OBJECT_CLASS (e_calendar_view_parent_class)->destroy (object);
+ if (GTK_OBJECT_CLASS (parent_class)->destroy)
+ GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
+E_MAKE_TYPE (e_calendar_view, "ECalendarView", ECalendarView, e_calendar_view_class_init,
+ e_calendar_view_init, GTK_TYPE_TABLE);
+
GnomeCalendar *
e_calendar_view_get_calendar (ECalendarView *cal_view)
{
@@ -667,7 +673,7 @@ e_calendar_view_cut_clipboard (ECalendarView *cal_view)
&& cancel_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (cal_view)),
event->comp_data->client, comp, TRUE))
itip_send_comp (E_CAL_COMPONENT_METHOD_CANCEL, comp,
- event->comp_data->client, NULL, NULL);
+ event->comp_data->client, NULL);
e_cal_component_get_uid (comp, &uid);
e_cal_remove_object (event->comp_data->client, uid, &error);
@@ -823,14 +829,14 @@ delete_event (ECalendarView *cal_view, ECalendarViewEvent *event)
event->comp_data->client,
comp, TRUE))
itip_send_comp (E_CAL_COMPONENT_METHOD_CANCEL, comp,
- event->comp_data->client, NULL, NULL);
+ event->comp_data->client, NULL);
e_cal_component_get_uid (comp, &uid);
if (!uid || !*uid) {
g_object_unref (comp);
return;
}
-
+
e_cal_remove_object (event->comp_data->client, uid, &error);
delete_error_dialog (error, E_CAL_COMPONENT_EVENT);
g_clear_error (&error);
@@ -921,20 +927,8 @@ e_calendar_view_delete_selected_occurrence (ECalendarView *cal_view)
if (itip_organizer_is_user (comp, event->comp_data->client)
&& cancel_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (cal_view)),
event->comp_data->client,
- comp, TRUE)) {
- if (!e_cal_component_is_instance (comp)) {
- ECalComponentRange range;
-
- /* set the recurrence ID of the object we send */
- range.type = E_CAL_COMPONENT_RANGE_SINGLE;
- e_cal_component_get_dtstart (comp, &range.datetime);
- range.datetime.value->is_date = 1;
- e_cal_component_set_recurid (comp, &range);
-
- e_cal_component_free_datetime (&range.datetime);
- }
- itip_send_comp (E_CAL_COMPONENT_METHOD_CANCEL, comp, event->comp_data->client, NULL, NULL);
- }
+ comp, TRUE))
+ itip_send_comp (E_CAL_COMPONENT_METHOD_CANCEL, comp, event->comp_data->client, NULL);
e_cal_remove_object_with_mod (event->comp_data->client, uid, rid, CALOBJ_MOD_THIS, &error);
delete_error_dialog (error, E_CAL_COMPONENT_EVENT);
@@ -948,58 +942,57 @@ e_calendar_view_delete_selected_occurrence (ECalendarView *cal_view)
}
static void
-on_new_appointment (EPopup *ep, EPopupItem *pitem, void *data)
+on_new_appointment (GtkWidget *widget, gpointer user_data)
{
- ECalendarView *cal_view = data;
+ ECalendarView *cal_view = (ECalendarView *) user_data;
e_calendar_view_new_appointment (cal_view);
}
static void
-on_new_event (EPopup *ep, EPopupItem *pitem, void *data)
+on_new_event (GtkWidget *widget, gpointer user_data)
{
- ECalendarView *cal_view = data;
+ ECalendarView *cal_view = (ECalendarView *) user_data;
e_calendar_view_new_appointment_full (cal_view, TRUE, FALSE);
}
static void
-on_new_meeting (EPopup *ep, EPopupItem *pitem, void *data)
+on_new_meeting (GtkWidget *widget, gpointer user_data)
{
- ECalendarView *cal_view = data;
+ ECalendarView *cal_view = (ECalendarView *) user_data;
e_calendar_view_new_appointment_full (cal_view, FALSE, TRUE);
}
static void
-on_new_task (EPopup *ep, EPopupItem *pitem, void *data)
+on_new_task (GtkWidget *widget, gpointer user_data)
{
- ECalendarView *cal_view = data;
-
+ ECalendarView *cal_view = (ECalendarView *) user_data;
gnome_calendar_new_task (cal_view->priv->calendar);
}
static void
-on_goto_date (EPopup *ep, EPopupItem *pitem, void *data)
+on_goto_date (GtkWidget *widget, gpointer user_data)
{
- ECalendarView *cal_view = data;
+ ECalendarView *cal_view = E_CALENDAR_VIEW (user_data);
goto_dialog (cal_view->priv->calendar);
}
static void
-on_goto_today (EPopup *ep, EPopupItem *pitem, void *data)
+on_goto_today (GtkWidget *widget, gpointer user_data)
{
- ECalendarView *cal_view = data;
+ ECalendarView *cal_view = E_CALENDAR_VIEW (user_data);
calendar_goto_today (cal_view->priv->calendar);
}
static void
-on_edit_appointment (EPopup *ep, EPopupItem *pitem, void *data)
+on_edit_appointment (GtkWidget *widget, gpointer user_data)
{
- ECalendarView *cal_view = data;
GList *selected;
+ ECalendarView *cal_view = E_CALENDAR_VIEW (user_data);
selected = e_calendar_view_get_selected_events (cal_view);
if (selected) {
@@ -1007,21 +1000,22 @@ on_edit_appointment (EPopup *ep, EPopupItem *pitem, void *data)
if (event)
e_calendar_view_edit_appointment (cal_view, event->comp_data->client,
- event->comp_data->icalcomp,
- icalcomponent_get_first_property(event->comp_data->icalcomp, ICAL_ATTENDEE_PROPERTY));
+ event->comp_data->icalcomp, FALSE);
g_list_free (selected);
}
}
static void
-on_print (EPopup *ep, EPopupItem *pitem, void *data)
+on_print (GtkWidget *widget, gpointer user_data)
{
- ECalendarView *cal_view = data;
+ ECalendarView *cal_view;
time_t start, end;
GnomeCalendarViewType view_type;
PrintView print_view;
+ cal_view = E_CALENDAR_VIEW (user_data);
+
e_calendar_view_get_visible_time_range (cal_view, &start, &end);
view_type = gnome_calendar_get_view (cal_view->priv->calendar);
@@ -1048,15 +1042,17 @@ on_print (EPopup *ep, EPopupItem *pitem, void *data)
}
static void
-on_save_as (EPopup *ep, EPopupItem *pitem, void *data)
+on_save_as (GtkWidget *widget, gpointer user_data)
{
- ECalendarView *cal_view = data;
+ ECalendarView *cal_view;
GList *selected;
char *filename;
char *ical_string;
FILE *file;
ECalendarViewEvent *event;
+ cal_view = E_CALENDAR_VIEW (user_data);
+
selected = e_calendar_view_get_selected_events (cal_view);
if (!selected)
return;
@@ -1086,13 +1082,14 @@ on_save_as (EPopup *ep, EPopupItem *pitem, void *data)
}
static void
-on_print_event (EPopup *ep, EPopupItem *pitem, void *data)
+on_print_event (GtkWidget *widget, gpointer user_data)
{
- ECalendarView *cal_view = data;
+ ECalendarView *cal_view;
GList *selected;
ECalendarViewEvent *event;
ECalComponent *comp;
+ cal_view = E_CALENDAR_VIEW (user_data);
selected = e_calendar_view_get_selected_events (cal_view);
if (!selected)
return;
@@ -1114,23 +1111,22 @@ transfer_item_to (ECalendarViewEvent *event, ECal *dest_client, gboolean remove_
char *new_uid;
icalcomponent *orig_icalcomp;
icalproperty *icalprop;
-
+
uid = icalcomponent_get_uid (event->comp_data->icalcomp);
/* put the new object into the destination calendar */
if (e_cal_get_object (dest_client, uid, NULL, &orig_icalcomp, NULL)) {
icalcomponent_free (orig_icalcomp);
-
-
+
if (!e_cal_modify_object (dest_client, event->comp_data->icalcomp, CALOBJ_MOD_ALL, NULL))
return;
} else {
orig_icalcomp = icalcomponent_new_clone (event->comp_data->icalcomp);
-
+
icalprop = icalproperty_new_x ("1");
icalproperty_set_x_name (icalprop, "X-EVOLUTION-MOVE-CALENDAR");
icalcomponent_add_property (orig_icalcomp, icalprop);
-
+
if (!remove_item) {
/* change the UID to avoid problems with duplicated UIDs */
new_uid = e_cal_component_gen_uid ();
@@ -1198,26 +1194,26 @@ transfer_selected_items (ECalendarView *cal_view, gboolean remove_item)
}
static void
-on_copy_to (EPopup *ep, EPopupItem *pitem, void *data)
+on_copy_to (GtkWidget *widget, gpointer user_data)
{
- ECalendarView *cal_view = data;
+ ECalendarView *cal_view = E_CALENDAR_VIEW (user_data);
transfer_selected_items (cal_view, FALSE);
}
static void
-on_move_to (EPopup *ep, EPopupItem *pitem, void *data)
+on_move_to (GtkWidget *widget, gpointer user_data)
{
- ECalendarView *cal_view = data;
+ ECalendarView *cal_view = E_CALENDAR_VIEW (user_data);
transfer_selected_items (cal_view, TRUE);
}
static void
-on_meeting (EPopup *ep, EPopupItem *pitem, void *data)
+on_meeting (GtkWidget *widget, gpointer user_data)
{
- ECalendarView *cal_view = data;
GList *selected;
+ ECalendarView *cal_view = E_CALENDAR_VIEW (user_data);
selected = e_calendar_view_get_selected_events (cal_view);
if (selected) {
@@ -1229,10 +1225,10 @@ on_meeting (EPopup *ep, EPopupItem *pitem, void *data)
}
static void
-on_forward (EPopup *ep, EPopupItem *pitem, void *data)
+on_forward (GtkWidget *widget, gpointer user_data)
{
- ECalendarView *cal_view = data;
GList *selected;
+ ECalendarView *cal_view = E_CALENDAR_VIEW (user_data);
selected = e_calendar_view_get_selected_events (cal_view);
if (selected) {
@@ -1241,7 +1237,7 @@ on_forward (EPopup *ep, EPopupItem *pitem, void *data)
comp = e_cal_component_new ();
e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
- itip_send_comp (E_CAL_COMPONENT_METHOD_PUBLISH, comp, event->comp_data->client, NULL, NULL);
+ itip_send_comp (E_CAL_COMPONENT_METHOD_PUBLISH, comp, event->comp_data->client, NULL);
g_list_free (selected);
g_object_unref (comp);
@@ -1249,37 +1245,38 @@ on_forward (EPopup *ep, EPopupItem *pitem, void *data)
}
static void
-on_publish (EPopup *ep, EPopupItem *pitem, void *data)
+on_publish (GtkWidget *widget, gpointer user_data)
{
e_pub_publish (TRUE);
}
static void
-on_delete_appointment (EPopup *ep, EPopupItem *pitem, void *data)
+on_delete_appointment (GtkWidget *widget, gpointer user_data)
{
- ECalendarView *cal_view = data;
+ ECalendarView *cal_view;
+ cal_view = E_CALENDAR_VIEW (user_data);
e_calendar_view_delete_selected_event (cal_view);
}
static void
-on_unrecur_appointment (EPopup *ep, EPopupItem *pitem, void *data)
+on_unrecur_appointment (GtkWidget *widget, gpointer user_data)
{
- ECalendarView *cal_view = data;
+ ECalendarView *cal_view;
ECalendarViewEvent *event;
ECalComponent *comp, *new_comp;
ECalComponentDateTime date;
struct icaltimetype itt;
GList *selected;
- ECal *client;
char *new_uid;
+ cal_view = E_CALENDAR_VIEW (user_data);
+
selected = e_calendar_view_get_selected_events (cal_view);
if (!selected)
return;
event = (ECalendarViewEvent *) selected->data;
- client = g_object_ref (event->comp_data->client);
date.value = &itt;
date.tzid = NULL;
@@ -1319,165 +1316,281 @@ on_unrecur_appointment (EPopup *ep, EPopupItem *pitem, void *data)
/* Now update both ECalComponents. Note that we do this last since at
* present the updates happen synchronously so our event may disappear.
*/
- if (!e_cal_modify_object (client, e_cal_component_get_icalcomponent (comp), CALOBJ_MOD_THIS, NULL))
- g_message ("on_unrecur_appointment(): Could not update the object!");
+ if (!e_cal_modify_object (event->comp_data->client, e_cal_component_get_icalcomponent (comp), CALOBJ_MOD_THIS, NULL))
+ g_message ("e_day_view_on_unrecur_appointment(): Could not update the object!");
g_object_unref (comp);
- if (!e_cal_create_object (client, e_cal_component_get_icalcomponent (new_comp), &new_uid, NULL))
- g_message ("on_unrecur_appointment(): Could not update the object!");
+ if (!e_cal_create_object (event->comp_data->client, e_cal_component_get_icalcomponent (new_comp), &new_uid, NULL))
+ g_message ("e_day_view_on_unrecur_appointment(): Could not update the object!");
else
g_free (new_uid);
g_object_unref (new_comp);
- g_object_unref (client);
g_list_free (selected);
}
static void
-on_delete_occurrence (EPopup *ep, EPopupItem *pitem, void *data)
+on_delete_occurrence (GtkWidget *widget, gpointer user_data)
{
- ECalendarView *cal_view = data;
+ ECalendarView *cal_view;
+ cal_view = E_CALENDAR_VIEW (user_data);
e_calendar_view_delete_selected_occurrence (cal_view);
}
static void
-on_cut (EPopup *ep, EPopupItem *pitem, void *data)
+on_cut (GtkWidget *widget, gpointer user_data)
{
- ECalendarView *cal_view = data;
+ ECalendarView *cal_view = E_CALENDAR_VIEW (user_data);
e_calendar_view_cut_clipboard (cal_view);
}
static void
-on_copy (EPopup *ep, EPopupItem *pitem, void *data)
+on_copy (GtkWidget *widget, gpointer user_data)
{
- ECalendarView *cal_view = data;
+ ECalendarView *cal_view = E_CALENDAR_VIEW (user_data);
e_calendar_view_copy_clipboard (cal_view);
}
static void
-on_paste (EPopup *ep, EPopupItem *pitem, void *data)
+on_paste (GtkWidget *widget, gpointer user_data)
{
- ECalendarView *cal_view = data;
+ ECalendarView *cal_view = E_CALENDAR_VIEW (user_data);
e_calendar_view_paste_clipboard (cal_view);
}
-static EPopupItem ecv_main_items [] = {
- { E_POPUP_ITEM, "00.new", N_("New _Appointment..."), on_new_appointment, NULL, "stock_new-appointment", 0, 0 },
- { E_POPUP_ITEM, "10.newallday", N_("New All Day _Event"), on_new_event, NULL, "stock_new-24h-appointment", 0, 0},
- { E_POPUP_ITEM, "20.meeting", N_("New Meeting"), on_new_meeting, NULL, "stock_new-meeting", 0, 0},
- { E_POPUP_ITEM, "30.task", N_("New Task"), on_new_task, NULL, "stock_task", 0, 0},
+enum {
+ /*
+ * This is used to "flag" events that can not be editted
+ */
+ MASK_EDITABLE = 1,
- { E_POPUP_BAR, "40."},
- { E_POPUP_ITEM, "40.print", N_("_Print..."), on_print, NULL, GTK_STOCK_PRINT, 0, 0 },
+ /*
+ * To disable recurring actions to be displayed
+ */
+ MASK_RECURRING = 2,
- { E_POPUP_BAR, "50." },
- { E_POPUP_ITEM, "50.paste", N_("_Paste"), on_paste, NULL, GTK_STOCK_PASTE, 0, E_CAL_POPUP_SELECT_EDITABLE },
+ /*
+ * To disable actions for non-recurring items to be displayed
+ */
+ MASK_SINGLE = 4,
+
+ /*
+ * This is used to when an event is currently being edited
+ * in another window and we want to disable the event
+ * from being edited twice
+ */
+ MASK_EDITING = 8,
+
+ /*
+ * This is used to when an event is already a meeting and
+ * we want to disable the schedule meeting command
+ */
+ MASK_MEETING = 16,
+
+ /*
+ * To disable cut and copy for meetings the user is not the
+ * organizer of
+ */
+ MASK_MEETING_ORGANIZER = 32,
+
+ /*
+ * To disable things not valid for instances
+ */
+ MASK_INSTANCE = 64
+};
- { E_POPUP_BAR, "60." },
- /* FIXME: hook in this somehow */
- { E_POPUP_SUBMENU, "60.view", N_("Current View") },
+static EPopupMenu main_items [] = {
+ E_POPUP_ITEM (N_("New _Appointment..."), GTK_SIGNAL_FUNC (on_new_appointment), 0),
+ E_POPUP_ITEM (N_("New All Day _Event"), GTK_SIGNAL_FUNC (on_new_event), 0),
+ E_POPUP_ITEM (N_("New Meeting"), GTK_SIGNAL_FUNC (on_new_meeting), 0),
+ E_POPUP_ITEM (N_("New Task"), GTK_SIGNAL_FUNC (on_new_task), 0),
+
+ E_POPUP_SEPARATOR,
+
+ E_POPUP_ITEM (N_("_Print..."), GTK_SIGNAL_FUNC (on_print), 0),
+
+ E_POPUP_SEPARATOR,
+
+ E_POPUP_ITEM (N_("_Paste"), GTK_SIGNAL_FUNC (on_paste), MASK_EDITABLE),
+
+ E_POPUP_SEPARATOR,
+
+ E_POPUP_SUBMENU (N_("Current View"), NULL, 0),
- { E_POPUP_ITEM, "61.today", N_("Select _Today"), on_goto_today, NULL, GTK_STOCK_HOME },
- { E_POPUP_ITEM, "62.todate", N_("_Select Date..."), on_goto_date, NULL, GTK_STOCK_JUMP_TO },
+ E_POPUP_ITEM (N_("Select _Today"), GTK_SIGNAL_FUNC (on_goto_today), 0),
+ E_POPUP_ITEM (N_("_Select Date..."), GTK_SIGNAL_FUNC (on_goto_date), 0),
- { E_POPUP_BAR, "70." },
+ E_POPUP_SEPARATOR,
- /* TODO: Why is this in a context menu when it applies globally? */
- { E_POPUP_ITEM, "70.publish", N_("_Publish Free/Busy Information"), on_publish, },
+ E_POPUP_ITEM (N_("_Publish Free/Busy Information"), GTK_SIGNAL_FUNC (on_publish), 0),
+
+ E_POPUP_TERMINATOR
};
-static EPopupItem ecv_child_items [] = {
- { E_POPUP_ITEM, "00.open", N_("_Open"), on_edit_appointment, NULL, GTK_STOCK_OPEN, 0, E_CAL_POPUP_SELECT_NOTEDITING },
- { E_POPUP_ITEM, "10.saveas", N_("_Save As..."), on_save_as, NULL, GTK_STOCK_SAVE_AS, 0, E_CAL_POPUP_SELECT_NOTEDITING },
- { E_POPUP_ITEM, "20.print", N_("_Print..."), on_print_event, NULL, GTK_STOCK_PRINT, 0, E_CAL_POPUP_SELECT_NOTEDITING },
+static EPopupMenu child_items [] = {
+ E_POPUP_ITEM (N_("_Open"), GTK_SIGNAL_FUNC (on_edit_appointment), MASK_EDITING),
+ E_POPUP_ITEM (N_("_Save As..."), GTK_SIGNAL_FUNC (on_save_as), MASK_EDITING),
+ E_POPUP_ITEM (N_("_Print..."), GTK_SIGNAL_FUNC (on_print_event), MASK_EDITING),
+
+ /* Only show this separator if one of the above is shown. */
+ E_POPUP_SEPARATOR,
- { E_POPUP_BAR, "30." },
+ E_POPUP_ITEM (N_("C_ut"), GTK_SIGNAL_FUNC (on_cut), MASK_EDITING | MASK_EDITABLE | MASK_MEETING_ORGANIZER),
+ E_POPUP_ITEM (N_("_Copy"), GTK_SIGNAL_FUNC (on_copy), MASK_EDITING | MASK_MEETING_ORGANIZER),
+ E_POPUP_ITEM (N_("_Paste"), GTK_SIGNAL_FUNC (on_paste), MASK_EDITABLE),
- { E_POPUP_ITEM, "31.cut", N_("C_ut"), on_cut, NULL, GTK_STOCK_CUT, 0, E_CAL_POPUP_SELECT_NOTEDITING|E_CAL_POPUP_SELECT_EDITABLE|E_CAL_POPUP_SELECT_ORGANIZER },
- { E_POPUP_ITEM, "32.copy", N_("_Copy"), on_copy, NULL, GTK_STOCK_COPY, 0, E_CAL_POPUP_SELECT_NOTEDITING|E_CAL_POPUP_SELECT_ORGANIZER },
- { E_POPUP_ITEM, "33.paste", N_("_Paste"), on_paste, NULL, GTK_STOCK_PASTE, 0, E_CAL_POPUP_SELECT_EDITABLE },
+ E_POPUP_SEPARATOR,
- { E_POPUP_BAR, "40." },
+ E_POPUP_ITEM (N_("Cop_y to Calendar..."), GTK_SIGNAL_FUNC (on_copy_to), MASK_EDITING),
+ E_POPUP_ITEM (N_("Mo_ve to Calendar..."), GTK_SIGNAL_FUNC (on_move_to), MASK_EDITING | MASK_EDITABLE),
+ E_POPUP_ITEM (N_("_Schedule Meeting..."), GTK_SIGNAL_FUNC (on_meeting), MASK_EDITABLE | MASK_EDITING | MASK_MEETING),
+ E_POPUP_ITEM (N_("_Forward as iCalendar..."), GTK_SIGNAL_FUNC (on_forward), MASK_EDITING),
- { E_POPUP_ITEM, "41.copyto", N_("Cop_y to Calendar..."), on_copy_to, NULL, NULL, 0, E_CAL_POPUP_SELECT_NOTEDITING },
- { E_POPUP_ITEM, "42.moveto", N_("Mo_ve to Calendar..."), on_move_to, NULL, NULL, 0, E_CAL_POPUP_SELECT_NOTEDITING | E_CAL_POPUP_SELECT_EDITABLE },
- { E_POPUP_ITEM, "43.schedule", N_("_Schedule Meeting..."), on_meeting, NULL, NULL, 0, E_CAL_POPUP_SELECT_NOTEDITING | E_CAL_POPUP_SELECT_EDITABLE | E_CAL_POPUP_SELECT_NOTMEETING },
- { E_POPUP_ITEM, "44.forward", N_("_Forward as iCalendar..."), on_forward, NULL, "stock_mail-forward", 0, E_CAL_POPUP_SELECT_NOTEDITING },
+ E_POPUP_SEPARATOR,
- { E_POPUP_BAR, "50." },
+ E_POPUP_ITEM (N_("_Delete"), GTK_SIGNAL_FUNC (on_delete_appointment), MASK_EDITABLE | MASK_SINGLE | MASK_EDITING),
+ E_POPUP_ITEM (N_("Make this Occurrence _Movable"), GTK_SIGNAL_FUNC (on_unrecur_appointment), MASK_EDITABLE | MASK_RECURRING | MASK_EDITING | MASK_INSTANCE),
+ E_POPUP_ITEM (N_("Delete this _Occurrence"), GTK_SIGNAL_FUNC (on_delete_occurrence), MASK_RECURRING | MASK_EDITING | MASK_EDITABLE),
+ E_POPUP_ITEM (N_("Delete _All Occurrences"), GTK_SIGNAL_FUNC (on_delete_appointment), MASK_RECURRING | MASK_EDITING | MASK_EDITABLE),
- { E_POPUP_ITEM, "51.delete", N_("_Delete"), on_delete_appointment, NULL, GTK_STOCK_DELETE, E_CAL_POPUP_SELECT_NONRECURRING, E_CAL_POPUP_SELECT_NOTEDITING | E_CAL_POPUP_SELECT_EDITABLE },
- { E_POPUP_ITEM, "52.move", N_("Make this Occurrence _Movable"), on_unrecur_appointment, NULL, NULL, E_CAL_POPUP_SELECT_RECURRING | E_CAL_POPUP_SELECT_INSTANCE, E_CAL_POPUP_SELECT_NOTEDITING | E_CAL_POPUP_SELECT_EDITABLE },
- { E_POPUP_ITEM, "53.delete", N_("Delete this _Occurrence"), on_delete_occurrence, NULL, GTK_STOCK_DELETE, E_CAL_POPUP_SELECT_RECURRING, E_CAL_POPUP_SELECT_NOTEDITING | E_CAL_POPUP_SELECT_EDITABLE },
- { E_POPUP_ITEM, "54.delete", N_("Delete _All Occurrences"), on_delete_appointment, NULL, GTK_STOCK_DELETE, E_CAL_POPUP_SELECT_RECURRING, E_CAL_POPUP_SELECT_NOTEDITING | E_CAL_POPUP_SELECT_EDITABLE },
+ E_POPUP_TERMINATOR
};
static void
-ecv_popup_free (EPopup *ep, GSList *list, void *data)
+free_view_popup (GtkWidget *widget, gpointer data)
{
- g_slist_free(list);
+ ECalendarView *cal_view = E_CALENDAR_VIEW (data);
+
+ if (cal_view->priv->view_menu == NULL)
+ return;
+
+ gnome_calendar_discard_view_popup (cal_view->priv->calendar, cal_view->priv->view_menu);
+ cal_view->priv->view_menu = NULL;
+}
+
+static void
+setup_popup_icons (EPopupMenu *context_menu)
+{
+ gint i;
+
+ for (i = 0; context_menu[i].name; i++) {
+ GtkWidget *pixmap_widget = NULL;
+ GdkPixbuf *pixbuf;
+
+ if (!strcmp (context_menu[i].name, _("_Copy")))
+ pixmap_widget = gtk_image_new_from_stock (GTK_STOCK_COPY, GTK_ICON_SIZE_MENU);
+ else if (!strcmp (context_menu[i].name, _("C_ut")))
+ pixmap_widget = gtk_image_new_from_stock (GTK_STOCK_CUT, GTK_ICON_SIZE_MENU);
+ else if (!strcmp (context_menu[i].name, _("_Delete")) ||
+ !strcmp (context_menu[i].name, _("Delete this _Occurrence")) ||
+ !strcmp (context_menu[i].name, _("Delete _All Occurrences")))
+ pixmap_widget = gtk_image_new_from_stock (GTK_STOCK_DELETE, GTK_ICON_SIZE_MENU);
+ else if (!strcmp (context_menu[i].name, _("Go to _Today")))
+ pixmap_widget = gtk_image_new_from_stock (GTK_STOCK_HOME, GTK_ICON_SIZE_MENU);
+ else if (!strcmp (context_menu[i].name, _("_Go to Date...")))
+ pixmap_widget = gtk_image_new_from_stock (GTK_STOCK_JUMP_TO, GTK_ICON_SIZE_MENU);
+ else if (!strcmp (context_menu[i].name, _("New _Appointment..."))) {
+ pixbuf = e_icon_factory_get_icon ("stock_new-appointment", E_ICON_SIZE_MENU);
+ pixmap_widget = gtk_image_new_from_pixbuf (pixbuf);
+ gdk_pixbuf_unref (pixbuf);
+ }
+ else if (!strcmp (context_menu[i].name, _("New All Day _Event"))) {
+ pixbuf = e_icon_factory_get_icon ("stock_new-24h-appointment", E_ICON_SIZE_MENU);
+ pixmap_widget = gtk_image_new_from_pixbuf (pixbuf);
+ gdk_pixbuf_unref (pixbuf);
+ }
+ else if (!strcmp (context_menu[i].name, _("New Meeting"))) {
+ pixbuf = e_icon_factory_get_icon ("stock_new-meeting", E_ICON_SIZE_MENU);
+ pixmap_widget = gtk_image_new_from_pixbuf (pixbuf);
+ gdk_pixbuf_unref (pixbuf);
+ }
+ else if (!strcmp (context_menu[i].name, _("New Task"))) {
+ pixbuf = e_icon_factory_get_icon ("stock_task", E_ICON_SIZE_MENU);
+ pixmap_widget = gtk_image_new_from_pixbuf (pixbuf);
+ gdk_pixbuf_unref (pixbuf);
+ }
+ else if (!strcmp (context_menu[i].name, _("_Open")))
+ pixmap_widget = gtk_image_new_from_stock (GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU);
+ else if (!strcmp (context_menu[i].name, _("_Paste")))
+ pixmap_widget = gtk_image_new_from_stock (GTK_STOCK_PASTE, GTK_ICON_SIZE_MENU);
+ else if (!strcmp (context_menu[i].name, _("_Print...")))
+ pixmap_widget = gtk_image_new_from_stock (GTK_STOCK_PRINT, GTK_ICON_SIZE_MENU);
+ else if (!strcmp (context_menu[i].name, _("_Save As...")))
+ pixmap_widget = gtk_image_new_from_stock (GTK_STOCK_SAVE_AS, GTK_ICON_SIZE_MENU);
+ else if (!strcmp (context_menu[i].name, _("_Settings...")))
+ pixmap_widget = gtk_image_new_from_stock (GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_MENU);
+
+ if (pixmap_widget)
+ gtk_widget_show (pixmap_widget);
+ context_menu[i].pixmap_widget = pixmap_widget;
+ }
}
GtkMenu *
e_calendar_view_create_popup_menu (ECalendarView *cal_view)
{
- ECalPopup *ep;
- GSList *menus = NULL;
- GList *selected, *l;
- int i;
- ECalPopupTargetSelect *t;
- ECalModel *model;
- GPtrArray *events;
-
+ GList *selected;
+ EPopupMenu *context_menu;
+ guint32 disable_mask = 0, hide_mask = 0;
+ GtkMenu *popup;
+ ECal *client = NULL;
+ gboolean read_only = TRUE;
+
g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), NULL);
- /* We could do this using a factory on the ECalPopup class,
- * that way we would get called implicitly whenever a popup
- * menu was created rather than everyone having to call us.
- * We could also have a different menu id for each view */
-
- /** @HookPoint-ECalPopup: Calendar Main View Context Menu
- * @Id: org.gnome.evolution.calendar.view.popup
- * @Class: org.gnome.evolution.calendar.popup:1.0
- * @Target: ECalPopupTargetSelect
- *
- * The context menu on the main calendar view. This menu
- * applies to all view types.
- */
- ep = e_cal_popup_new("org.gnome.evolution.calendar.view.popup");
+ /* get the selection */
+ selected = e_calendar_view_get_selected_events (cal_view);
- model = e_calendar_view_get_model(cal_view);
- events = g_ptr_array_new();
- selected = e_calendar_view_get_selected_events(cal_view);
- for (l=selected;l;l=g_list_next(l)) {
- ECalendarViewEvent *event = l->data;
+ if (selected == NULL) {
+ cal_view->priv->view_menu = gnome_calendar_setup_view_popup (cal_view->priv->calendar);
+ main_items[9].submenu = cal_view->priv->view_menu;
+ context_menu = main_items;
- if (event)
- g_ptr_array_add(events, e_cal_model_copy_component_data(event->comp_data));
- }
- g_list_free(selected);
+ client = e_cal_model_get_default_client (cal_view->priv->model);
+ } else {
+ ECalendarViewEvent *event;
- t = e_cal_popup_target_new_select(ep, model, events);
- t->target.widget = (GtkWidget *)cal_view;
+ context_menu = child_items;
- if (t->events->len == 0) {
- for (i=0;i<sizeof(ecv_main_items)/sizeof(ecv_main_items[0]);i++)
- menus = g_slist_prepend(menus, &ecv_main_items[i]);
+ event = (ECalendarViewEvent *) selected->data;
+ if (e_cal_util_component_has_recurrences (event->comp_data->icalcomp))
+ hide_mask |= MASK_SINGLE;
+ else
+ hide_mask |= MASK_RECURRING;
- gnome_calendar_view_popup_factory(cal_view->priv->calendar, (EPopup *)ep, "60.view");
- } else {
- for (i=0;i<sizeof(ecv_child_items)/sizeof(ecv_child_items[0]);i++)
- menus = g_slist_prepend(menus, &ecv_child_items[i]);
+ if (e_cal_util_component_is_instance (event->comp_data->icalcomp))
+ hide_mask |= MASK_INSTANCE;
+
+ if (e_cal_util_component_has_organizer (event->comp_data->icalcomp)) {
+ ECalComponent *comp;
+
+ disable_mask |= MASK_MEETING;
+
+ comp = e_cal_component_new ();
+ e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
+ if (!itip_organizer_is_user (comp, event->comp_data->client))
+ disable_mask |= MASK_MEETING_ORGANIZER;
+
+ g_object_unref (comp);
+ }
+
+ client = event->comp_data->client;
}
- e_popup_add_items((EPopup *)ep, menus, NULL, ecv_popup_free, cal_view);
+ e_cal_is_read_only (client, &read_only, NULL);
+ if (read_only)
+ disable_mask |= MASK_EDITABLE;
+
+ setup_popup_icons (context_menu);
+ popup = e_popup_menu_create (context_menu, disable_mask, hide_mask, cal_view);
+ g_signal_connect (popup, "selection-done", G_CALLBACK (free_view_popup), cal_view);
- return e_popup_create_menu_once((EPopup *)ep, (EPopupTarget *)t, 0);
+ return popup;
}
void
@@ -1640,7 +1753,7 @@ e_calendar_view_edit_appointment (ECalendarView *cal_view,
if (!ce) {
EventEditor *ee;
- ee = event_editor_new (client, meeting);
+ ee = event_editor_new (client);
ce = COMP_EDITOR (ee);
comp = e_cal_component_new ();
@@ -1667,7 +1780,7 @@ e_calendar_view_modify_and_send (ECalComponent *comp,
if (e_cal_modify_object (client, e_cal_component_get_icalcomponent (comp), mod, NULL)) {
if (itip_organizer_is_user (comp, client) &&
send_component_dialog (toplevel, client, comp, new))
- itip_send_comp (E_CAL_COMPONENT_METHOD_REQUEST, comp, client, NULL, NULL);
+ itip_send_comp (E_CAL_COMPONENT_METHOD_REQUEST, comp, client, NULL);
} else {
g_message (G_STRLOC ": Could not update the object!");
}
diff --git a/calendar/gui/e-day-view-config.c b/calendar/gui/e-day-view-config.c
index 50d4d8eeea..6fa8bd2081 100644
--- a/calendar/gui/e-day-view-config.c
+++ b/calendar/gui/e-day-view-config.c
@@ -30,14 +30,14 @@ struct _EDayViewConfigPrivate {
GList *notifications;
};
+static GObjectClass *parent_class = NULL;
+
/* Property IDs */
enum props {
PROP_0,
PROP_VIEW,
};
-G_DEFINE_TYPE (EDayViewConfig, e_day_view_config, G_TYPE_OBJECT);
-
static void
e_day_view_config_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
{
@@ -86,8 +86,8 @@ e_day_view_config_dispose (GObject *object)
e_day_view_config_set_view (view_config, NULL);
- if (G_OBJECT_CLASS (e_day_view_config_parent_class)->dispose)
- G_OBJECT_CLASS (e_day_view_config_parent_class)->dispose (object);
+ if (G_OBJECT_CLASS (parent_class)->dispose)
+ G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
@@ -100,8 +100,8 @@ e_day_view_config_finalize (GObject *object)
g_free (priv);
- if (G_OBJECT_CLASS (e_day_view_config_parent_class)->finalize)
- G_OBJECT_CLASS (e_day_view_config_parent_class)->finalize (object);
+ if (G_OBJECT_CLASS (parent_class)->finalize)
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
@@ -110,6 +110,8 @@ e_day_view_config_class_init (EDayViewConfigClass *klass)
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GParamSpec *spec;
+ parent_class = g_type_class_peek_parent (klass);
+
/* Method override */
gobject_class->set_property = e_day_view_config_set_property;
gobject_class->get_property = e_day_view_config_get_property;
@@ -122,12 +124,15 @@ e_day_view_config_class_init (EDayViewConfigClass *klass)
}
static void
-e_day_view_config_init (EDayViewConfig *view_config)
+e_day_view_config_init (EDayViewConfig *view_config, EDayViewConfigClass *klass)
{
view_config->priv = g_new0 (EDayViewConfigPrivate, 1);
}
+E_MAKE_TYPE (e_day_view_config, "EDayViewConfig", EDayViewConfig, e_day_view_config_class_init,
+ e_day_view_config_init, G_TYPE_OBJECT);
+
EDayViewConfig *
e_day_view_config_new (EDayView *day_view)
{
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index 73b57432cf..68b0abcdab 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -47,6 +47,7 @@
#include <gal/widgets/e-popup-menu.h>
#include <gal/widgets/e-gui-utils.h>
#include <gal/widgets/e-unicode.h>
+#include <gal/util/e-util.h>
#include <libgnomecanvas/gnome-canvas-rect-ellipse.h>
#include <libgnome/gnome-i18n.h>
#include <libgnome/gnome-exec.h>
@@ -121,9 +122,10 @@ static GtkTargetEntry target_table[] = {
};
static guint n_targets = sizeof(target_table) / sizeof(target_table[0]);
+static void e_day_view_class_init (EDayViewClass *class);
+static void e_day_view_init (EDayView *day_view);
static void e_day_view_destroy (GtkObject *object);
static void e_day_view_realize (GtkWidget *widget);
-static void e_day_view_set_colors(EDayView *day_view, GtkWidget *widget);
static void e_day_view_unrealize (GtkWidget *widget);
static void e_day_view_style_set (GtkWidget *widget,
GtkStyle *previous_style);
@@ -285,9 +287,7 @@ static ECalendarViewPosition e_day_view_convert_position_in_main_canvas (EDayVie
gint *row_return,
gint *event_num_return);
static gboolean e_day_view_find_event_from_uid (EDayView *day_view,
- ECal *client,
const gchar *uid,
- const gchar *rid,
gint *day_return,
gint *event_num_return);
@@ -441,7 +441,10 @@ static void e_day_view_queue_layout (EDayView *day_view);
static void e_day_view_cancel_layout (EDayView *day_view);
static gboolean e_day_view_layout_timeout_cb (gpointer data);
-G_DEFINE_TYPE (EDayView, e_day_view, E_TYPE_CALENDAR_VIEW);
+static GtkTableClass *parent_class;
+
+E_MAKE_TYPE (e_day_view, "EDayView", EDayView, e_day_view_class_init,
+ e_day_view_init, e_calendar_view_get_type ());
static void
e_day_view_class_init (EDayViewClass *class)
@@ -450,6 +453,7 @@ e_day_view_class_init (EDayViewClass *class)
GtkWidgetClass *widget_class;
ECalendarViewClass *view_class;
+ parent_class = g_type_class_peek_parent (class);
object_class = (GtkObjectClass *) class;
widget_class = (GtkWidgetClass *) class;
view_class = (ECalendarViewClass *) class;
@@ -509,7 +513,7 @@ process_component (EDayView *day_view, ECalModelComponent *comp_data)
{
EDayViewEvent *event;
gint day, event_num;
- const char *uid, *rid;
+ const char *uid;
ECalComponent *comp;
AddEventData add_event_data;
@@ -526,20 +530,65 @@ process_component (EDayView *day_view, ECalModelComponent *comp_data)
}
e_cal_component_get_uid (comp, &uid);
- if (e_cal_component_is_instance (comp))
- rid = e_cal_component_get_recurid_as_string (comp);
- else
- rid = NULL;
- /* Add the object */
+ /* If the event already exists and the dates didn't change, we can
+ update the event fairly easily without changing the events arrays
+ or computing a new layout. */
+ if (e_day_view_find_event_from_uid (day_view, uid, &day, &event_num)) {
+ ECalComponent *tmp_comp;
+
+ if (day == E_DAY_VIEW_LONG_EVENT)
+ event = &g_array_index (day_view->long_events,
+ EDayViewEvent, event_num);
+ else
+ event = &g_array_index (day_view->events[day],
+ EDayViewEvent, event_num);
+
+ tmp_comp = e_cal_component_new ();
+ e_cal_component_set_icalcomponent (tmp_comp, icalcomponent_new_clone (event->comp_data->icalcomp));
+ if (!e_cal_util_component_has_recurrences (comp_data->icalcomp)
+ && !e_cal_component_has_recurrences (tmp_comp)
+ && e_cal_component_event_dates_match (comp, tmp_comp)) {
+#if 0
+ g_print ("updated object's dates unchanged\n");
+#endif
+ e_day_view_foreach_event_with_uid (day_view, uid, e_day_view_update_event_cb, comp_data);
+ gtk_widget_queue_draw (day_view->top_canvas);
+ gtk_widget_queue_draw (day_view->main_canvas);
+ return;
+ }
+
+ /* The dates have changed, so we need to remove the
+ old occurrrences before adding the new ones. */
+#if 0
+ g_print ("dates changed - removing occurrences\n");
+#endif
+ e_day_view_foreach_event_with_uid (day_view, uid,
+ e_day_view_remove_event_cb,
+ NULL);
+
+ g_object_unref (tmp_comp);
+ }
+
+ /* Add the occurrences of the event */
add_event_data.day_view = day_view;
add_event_data.comp_data = comp_data;
- e_day_view_add_event (comp, comp_data->instance_start, comp_data->instance_end, &add_event_data);
+ e_cal_generate_instances_for_object (comp_data->client, comp_data->icalcomp, day_view->lower,
+ day_view->upper,
+ e_day_view_add_event, &add_event_data);
g_object_unref (comp);
}
static void
+model_changed_cb (ETableModel *etm, gpointer user_data)
+{
+ EDayView *day_view = E_DAY_VIEW (user_data);
+
+ e_day_view_update_query (day_view);
+}
+
+static void
update_row (EDayView *day_view, int row)
{
ECalModelComponent *comp_data;
@@ -597,35 +646,55 @@ model_rows_inserted_cb (ETableModel *etm, int row, int count, gpointer user_data
}
+static gboolean
+row_deleted_check_cb (EDayView *day_view, gint day, gint event_num, gpointer data)
+{
+ GHashTable *uids = data;
+ EDayViewEvent *event;
+ ECalModel *model;
+ const char *uid;
+
+ if (day == E_DAY_VIEW_LONG_EVENT) {
+ event = &g_array_index (day_view->long_events, EDayViewEvent,
+ event_num);
+ } else {
+ event = &g_array_index (day_view->events[day], EDayViewEvent,
+ event_num);
+ }
+
+ uid = icalcomponent_get_uid (event->comp_data->icalcomp);
+ model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view));
+
+ if (!e_cal_model_get_component_for_uid (model, uid))
+ g_hash_table_insert (uids, g_strdup(uid), GINT_TO_POINTER (1));
+
+ return TRUE;
+}
+
+static void
+remove_uid_cb (gpointer key, gpointer value, gpointer data)
+{
+ EDayView *day_view = data;
+ char *uid = key;
+
+ e_day_view_foreach_event_with_uid (day_view, uid, e_day_view_remove_event_cb, NULL);
+ g_free(uid);
+}
+
static void
model_rows_deleted_cb (ETableModel *etm, int row, int count, gpointer user_data)
{
EDayView *day_view = E_DAY_VIEW (user_data);
- int i;
+ GHashTable *uids;
e_day_view_stop_editing_event (day_view);
- for (i = row + count; i > row; i--) {
- gint day, event_num;
- const char *uid, *rid = NULL;
- ECalModelComponent *comp_data;
-
- comp_data = e_cal_model_get_component_at (E_CAL_MODEL (etm), i - 1);
- if (!comp_data)
- continue;
-
- uid = icalcomponent_get_uid (comp_data->icalcomp);
- if (e_cal_util_component_is_instance (comp_data->icalcomp)) {
- icalproperty *prop;
-
- prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_RECURRENCEID_PROPERTY);
- if (prop)
- rid = icaltime_as_ical_string (icalcomponent_get_recurrenceid (comp_data->icalcomp));
- }
+ uids = g_hash_table_new (g_str_hash, g_str_equal);
+
+ e_day_view_foreach_event (day_view, row_deleted_check_cb, uids);
+ g_hash_table_foreach (uids, remove_uid_cb, day_view);
- if (e_day_view_find_event_from_uid (day_view, comp_data->client, uid, rid, &day, &event_num))
- e_day_view_remove_event_cb (day_view, day, event_num, NULL);
- }
+ g_hash_table_destroy (uids);
gtk_widget_queue_draw (day_view->top_canvas);
gtk_widget_queue_draw (day_view->main_canvas);
@@ -977,6 +1046,8 @@ e_day_view_init (EDayView *day_view)
/* connect to ECalModel's signals */
g_signal_connect (G_OBJECT (model), "time_range_changed",
G_CALLBACK (time_range_changed_cb), day_view);
+ g_signal_connect (G_OBJECT (model), "model_changed",
+ G_CALLBACK (model_changed_cb), day_view);
g_signal_connect (G_OBJECT (model), "model_row_changed",
G_CALLBACK (model_row_changed_cb), day_view);
g_signal_connect (G_OBJECT (model), "model_cell_changed",
@@ -1015,7 +1086,6 @@ e_day_view_new (void)
GObject *day_view;
day_view = g_object_new (e_day_view_get_type (), NULL);
- e_cal_model_set_flags (e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)), E_CAL_MODEL_FLAGS_EXPAND_RECURRENCES);
return GTK_WIDGET (day_view);
}
@@ -1067,7 +1137,7 @@ e_day_view_destroy (GtkObject *object)
}
}
- GTK_OBJECT_CLASS (e_day_view_parent_class)->destroy (object);
+ GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
@@ -1079,8 +1149,8 @@ e_day_view_realize (GtkWidget *widget)
gboolean success[E_DAY_VIEW_COLOR_LAST];
gint nfailed;
- if (GTK_WIDGET_CLASS (e_day_view_parent_class)->realize)
- (*GTK_WIDGET_CLASS (e_day_view_parent_class)->realize)(widget);
+ if (GTK_WIDGET_CLASS (parent_class)->realize)
+ (*GTK_WIDGET_CLASS (parent_class)->realize)(widget);
day_view = E_DAY_VIEW (widget);
day_view->main_gc = gdk_gc_new (widget->window);
@@ -1088,9 +1158,64 @@ e_day_view_realize (GtkWidget *widget)
colormap = gtk_widget_get_colormap (widget);
/* Allocate the colors. */
-
- e_day_view_set_colors(day_view, widget);
-
+ day_view->colors[E_DAY_VIEW_COLOR_BG_WORKING].red = 247 * 257;
+ day_view->colors[E_DAY_VIEW_COLOR_BG_WORKING].green = 247 * 257;
+ day_view->colors[E_DAY_VIEW_COLOR_BG_WORKING].blue = 244 * 257;
+
+ day_view->colors[E_DAY_VIEW_COLOR_BG_NOT_WORKING].red = 216 * 257;
+ day_view->colors[E_DAY_VIEW_COLOR_BG_NOT_WORKING].green = 216 * 257;
+ day_view->colors[E_DAY_VIEW_COLOR_BG_NOT_WORKING].blue = 214 * 257;
+
+ day_view->colors[E_DAY_VIEW_COLOR_BG_SELECTED].red = 0 * 257;
+ day_view->colors[E_DAY_VIEW_COLOR_BG_SELECTED].green = 0 * 257;
+ day_view->colors[E_DAY_VIEW_COLOR_BG_SELECTED].blue = 156 * 257;
+
+ day_view->colors[E_DAY_VIEW_COLOR_BG_SELECTED_UNFOCUSSED].red = 16 * 257;
+ day_view->colors[E_DAY_VIEW_COLOR_BG_SELECTED_UNFOCUSSED].green = 78 * 257;
+ day_view->colors[E_DAY_VIEW_COLOR_BG_SELECTED_UNFOCUSSED].blue = 139 * 257;
+
+ day_view->colors[E_DAY_VIEW_COLOR_BG_GRID].red = 0x8000;
+ day_view->colors[E_DAY_VIEW_COLOR_BG_GRID].green = 0x8000;
+ day_view->colors[E_DAY_VIEW_COLOR_BG_GRID].blue = 0x8000;
+
+ day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS].red = 0x8000;
+ day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS].green = 0x8000;
+ day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS].blue = 0x8000;
+
+ day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS_SELECTED].red = 65535;
+ day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS_SELECTED].green = 65535;
+ day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS_SELECTED].blue = 65535;
+
+ day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS_GRID].red = 0;
+ day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS_GRID].green = 0;
+ day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS_GRID].blue = 0;
+
+ day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR].red = 0;
+ day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR].green = 0;
+ day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR].blue = 65535;
+
+ day_view->colors[E_DAY_VIEW_COLOR_EVENT_BACKGROUND].red = 65535;
+ day_view->colors[E_DAY_VIEW_COLOR_EVENT_BACKGROUND].green = 65535;
+ day_view->colors[E_DAY_VIEW_COLOR_EVENT_BACKGROUND].blue = 65535;
+
+ day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER].red = 0;
+ day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER].green = 0;
+ day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER].blue = 0;
+
+ day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BACKGROUND].red = 213 * 257;
+ day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BACKGROUND].green = 213 * 257;
+ day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BACKGROUND].blue = 213 * 257;
+
+ day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BORDER].red = 0;
+ day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BORDER].green = 0;
+ day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BORDER].blue = 0;
+
+ nfailed = gdk_colormap_alloc_colors (colormap, day_view->colors,
+ E_DAY_VIEW_COLOR_LAST, FALSE,
+ TRUE, success);
+ if (nfailed)
+ g_warning ("Failed to allocate all colors");
+
gdk_gc_set_colormap (day_view->main_gc, colormap);
/* Create the pixmaps. */
@@ -1098,7 +1223,6 @@ e_day_view_realize (GtkWidget *widget)
day_view->recurrence_icon = e_icon_factory_get_icon ("stock_refresh", E_ICON_SIZE_MENU);
day_view->timezone_icon = e_icon_factory_get_icon ("stock_timezone", E_ICON_SIZE_MENU);
day_view->meeting_icon = e_icon_factory_get_icon ("stock_people", E_ICON_SIZE_MENU);
- day_view->attach_icon = e_icon_factory_get_icon ("stock_attach", E_ICON_SIZE_MENU);
/* Set the canvas item colors. */
@@ -1145,23 +1269,6 @@ e_day_view_realize (GtkWidget *widget)
NULL);
}
-static void
-e_day_view_set_colors(EDayView *day_view, GtkWidget *widget)
-{
- day_view->colors[E_DAY_VIEW_COLOR_BG_WORKING] = widget->style->base[GTK_STATE_NORMAL];
- day_view->colors[E_DAY_VIEW_COLOR_BG_NOT_WORKING] = widget->style->bg[GTK_STATE_ACTIVE];
- day_view->colors[E_DAY_VIEW_COLOR_BG_SELECTED] = widget->style->base[GTK_STATE_SELECTED];
- day_view->colors[E_DAY_VIEW_COLOR_BG_SELECTED_UNFOCUSSED] = widget->style->bg[GTK_STATE_SELECTED];
- day_view->colors[E_DAY_VIEW_COLOR_BG_GRID] = widget->style->dark[GTK_STATE_NORMAL];
- day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS] = widget->style->dark[GTK_STATE_NORMAL];
- day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS_SELECTED] = widget->style->bg[GTK_STATE_SELECTED];
- day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS_GRID] = widget->style->light[GTK_STATE_NORMAL];
- day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR] = widget->style->base[GTK_STATE_SELECTED];
- day_view->colors[E_DAY_VIEW_COLOR_EVENT_BACKGROUND] = widget->style->base[GTK_STATE_NORMAL];
- day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER] = widget->style->dark[GTK_STATE_NORMAL];
- day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BACKGROUND] = widget->style->bg[GTK_STATE_ACTIVE];
- day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BORDER] = widget->style->dark[GTK_STATE_NORMAL];
-}
static void
e_day_view_unrealize (GtkWidget *widget)
@@ -1185,11 +1292,9 @@ e_day_view_unrealize (GtkWidget *widget)
day_view->timezone_icon = NULL;
g_object_unref (day_view->meeting_icon);
day_view->meeting_icon = NULL;
- g_object_unref (day_view->attach_icon);
- day_view->attach_icon = NULL;
- if (GTK_WIDGET_CLASS (e_day_view_parent_class)->unrealize)
- (*GTK_WIDGET_CLASS (e_day_view_parent_class)->unrealize)(widget);
+ if (GTK_WIDGET_CLASS (parent_class)->unrealize)
+ (*GTK_WIDGET_CLASS (parent_class)->unrealize)(widget);
}
@@ -1211,39 +1316,11 @@ e_day_view_style_set (GtkWidget *widget,
PangoContext *pango_context;
PangoFontMetrics *font_metrics;
PangoLayout *layout;
- gint week_day, event_num;
- EDayViewEvent *event;
- if (GTK_WIDGET_CLASS (e_day_view_parent_class)->style_set)
- (*GTK_WIDGET_CLASS (e_day_view_parent_class)->style_set)(widget, previous_style);
+ if (GTK_WIDGET_CLASS (parent_class)->style_set)
+ (*GTK_WIDGET_CLASS (parent_class)->style_set)(widget, previous_style);
day_view = E_DAY_VIEW (widget);
- e_day_view_set_colors(day_view, widget);
-
- for (week_day = 0; week_day < E_DAY_VIEW_MAX_DAYS; week_day++){
- for (event_num = 0; event_num < day_view->events[week_day]->len; event_num++) {
- event = &g_array_index (day_view->events[week_day], EDayViewEvent, event_num);
- if (event->canvas_item)
- gnome_canvas_item_set (event->canvas_item,
- "fill_color_gdk", &widget->style->text[GTK_STATE_NORMAL],
- NULL);
- }
- }
- for (event_num = 0; event_num < day_view->long_events->len; event_num++) {
- event = &g_array_index (day_view->long_events, EDayViewEvent, event_num);
- if (event->canvas_item)
- gnome_canvas_item_set (event->canvas_item,
- "fill_color_gdk", &widget->style->text[GTK_STATE_NORMAL],
- NULL);
- }
- gnome_canvas_item_set (day_view->main_canvas_top_resize_bar_item,
- "fill_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR],
- "outline_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER],
- NULL);
- gnome_canvas_item_set (day_view->main_canvas_bottom_resize_bar_item,
- "fill_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR],
- "outline_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER],
- NULL);
/* Set up Pango prerequisites */
font_desc = gtk_widget_get_style (widget)->font_desc;
@@ -1399,7 +1476,7 @@ e_day_view_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
#endif
day_view = E_DAY_VIEW (widget);
- (*GTK_WIDGET_CLASS (e_day_view_parent_class)->size_allocate) (widget, allocation);
+ (*GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation);
e_day_view_recalc_cell_sizes (day_view);
@@ -1717,26 +1794,16 @@ e_day_view_remove_event_cb (EDayView *day_view,
event = &g_array_index (day_view->events[day],
EDayViewEvent, event_num);
- if (!event)
- return TRUE;
-
/* If we were editing this event, set editing_event_day to -1 so
on_editing_stopped doesn't try to update the event. */
- if (day_view->editing_event_num == event_num && day_view->editing_event_day == day) {
- day_view->editing_event_num = -1;
+ if (day_view->editing_event_day == day
+ && day_view->editing_event_num == event_num)
day_view->editing_event_day = -1;
- }
-
- if (day_view->popup_event_num == event_num && day_view->popup_event_day == day) {
- day_view->popup_event_num = -1;
- day_view->popup_event_day = -1;
- }
if (event->canvas_item)
gtk_object_destroy (GTK_OBJECT (event->canvas_item));
e_cal_model_free_component_data (event->comp_data);
- event->comp_data = NULL;
if (day == E_DAY_VIEW_LONG_EVENT) {
g_array_remove_index (day_view->long_events, event_num);
@@ -1918,15 +1985,13 @@ e_day_view_find_event_from_item (EDayView *day_view,
see if any events with the uid exist. */
static gboolean
e_day_view_find_event_from_uid (EDayView *day_view,
- ECal *client,
const gchar *uid,
- const gchar *rid,
gint *day_return,
gint *event_num_return)
{
EDayViewEvent *event;
gint day, event_num;
- const char *u, *r;
+ const char *u;
if (!uid)
return FALSE;
@@ -1937,19 +2002,8 @@ e_day_view_find_event_from_uid (EDayView *day_view,
event = &g_array_index (day_view->events[day],
EDayViewEvent, event_num);
- if (event->comp_data->client != client)
- continue;
-
u = icalcomponent_get_uid (event->comp_data->icalcomp);
if (u && !strcmp (uid, u)) {
- if (rid && *rid) {
- r = icaltime_as_ical_string (icalcomponent_get_recurrenceid (event->comp_data->icalcomp));
- if (!r || !*r)
- continue;
- if (strcmp (rid, r) != 0)
- continue;
- }
-
*day_return = day;
*event_num_return = event_num;
return TRUE;
@@ -2252,6 +2306,8 @@ e_day_view_recalc_day_starts (EDayView *day_view,
day_view->lower = start_time;
day_view->upper = day_view->day_starts[day_view->days_shown];
+
+ e_day_view_update_query (day_view);
}
@@ -2810,7 +2866,7 @@ e_day_view_on_main_canvas_button_press (GtkWidget *widget,
return TRUE;
}
- if (!GTK_WIDGET_HAS_FOCUS (day_view) && !GTK_WIDGET_HAS_FOCUS (day_view->main_canvas))
+ if (!GTK_WIDGET_HAS_FOCUS (day_view))
gtk_widget_grab_focus (GTK_WIDGET (day_view));
if (gdk_pointer_grab (GTK_LAYOUT (widget)->bin_window, FALSE,
@@ -2818,7 +2874,6 @@ e_day_view_on_main_canvas_button_press (GtkWidget *widget,
| GDK_BUTTON_RELEASE_MASK,
FALSE, NULL, event->time) == 0) {
e_day_view_start_selection (day_view, day, row);
- g_signal_emit_by_name (day_view, "selected_time_changed");
}
} else if (event->button == 3) {
if (!GTK_WIDGET_HAS_FOCUS (day_view))
@@ -3197,7 +3252,6 @@ e_day_view_on_event_double_click (EDayView *day_view,
gint event_num)
{
EDayViewEvent *event;
- icalproperty *attendee_prop = NULL;
if (day == -1)
event = &g_array_index (day_view->long_events, EDayViewEvent,
@@ -3208,11 +3262,9 @@ e_day_view_on_event_double_click (EDayView *day_view,
e_day_view_stop_editing_event (day_view);
-
- attendee_prop = icalcomponent_get_first_property (event->comp_data->icalcomp, ICAL_ATTENDEE_PROPERTY);
e_calendar_view_edit_appointment (E_CALENDAR_VIEW (day_view),
event->comp_data->client,
- event->comp_data->icalcomp, attendee_prop ? TRUE:FALSE);
+ event->comp_data->icalcomp, FALSE);
}
static void
@@ -3237,7 +3289,7 @@ e_day_view_show_popup_menu (EDayView *day_view,
popup = e_calendar_view_create_popup_menu (E_CALENDAR_VIEW (day_view));
g_object_weak_ref (G_OBJECT (popup), popup_destroyed_cb, day_view);
- gtk_menu_popup (popup, NULL, NULL, NULL, NULL, gdk_event?gdk_event->button.button:0, gdk_event?gdk_event->button.time:gtk_get_current_event_time());
+ e_popup_menu (popup, gdk_event);
}
static gboolean
@@ -4291,8 +4343,7 @@ e_day_view_reshape_long_event (EDayView *day_view,
num_icons++;
if (e_cal_component_has_organizer (comp))
num_icons++;
- if (e_cal_component_has_attachments (comp))
- num_icons++;
+
e_cal_component_get_categories_list (comp, &categories_list);
for (elem = categories_list; elem; elem = elem->next) {
char *category;
@@ -4307,9 +4358,6 @@ e_day_view_reshape_long_event (EDayView *day_view,
}
if (!event->canvas_item) {
- GtkWidget *widget;
-
- widget = (GtkWidget *)day_view;
event->canvas_item =
gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (day_view->top_canvas)->root),
e_text_get_type (),
@@ -4319,7 +4367,7 @@ e_day_view_reshape_long_event (EDayView *day_view,
"editable", TRUE,
"use_ellipsis", TRUE,
"draw_background", FALSE,
- "fill_color_gdk", &widget->style->text[GTK_STATE_NORMAL],
+ "fill_color_rgba", GNOME_CANVAS_COLOR (0, 0, 0),
"im_context", E_CANVAS (day_view->top_canvas)->im_context,
NULL);
g_signal_connect (event->canvas_item, "event",
@@ -4457,8 +4505,6 @@ e_day_view_reshape_day_event (EDayView *day_view,
num_icons++;
if (e_cal_component_has_recurrences (comp))
num_icons++;
- if (e_cal_component_has_attachments (comp))
- num_icons++;
if (event->different_timezone)
num_icons++;
if (e_cal_component_has_organizer (comp))
@@ -4487,9 +4533,6 @@ e_day_view_reshape_day_event (EDayView *day_view,
}
if (!event->canvas_item) {
- GtkWidget *widget;
-
- widget = (GtkWidget *)day_view;
event->canvas_item =
gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (day_view->main_canvas)->root),
e_text_get_type (),
@@ -4499,7 +4542,7 @@ e_day_view_reshape_day_event (EDayView *day_view,
"clip", TRUE,
"use_ellipsis", TRUE,
"draw_background", FALSE,
- "fill_color_gdk", &widget->style->text[GTK_STATE_NORMAL],
+ "fill_color_rgba", GNOME_CANVAS_COLOR(0, 0, 0),
"im_context", E_CANVAS (day_view->main_canvas)->im_context,
NULL);
g_signal_connect (event->canvas_item, "event",
@@ -4829,7 +4872,7 @@ e_day_view_do_key_press (GtkWidget *widget, GdkEventKey *event)
gtk_widget_queue_draw (day_view->top_canvas);
gtk_widget_queue_draw (day_view->main_canvas);
- if (e_day_view_find_event_from_uid (day_view, ecal, uid, NULL, &day, &event_num)) {
+ if (e_day_view_find_event_from_uid (day_view, uid, &day, &event_num)) {
e_day_view_start_editing_event (day_view, day, event_num,
initial_text);
} else {
@@ -4852,7 +4895,7 @@ e_day_view_key_press (GtkWidget *widget, GdkEventKey *event)
/* if not handled, try key bindings */
if (!handled)
- handled = GTK_WIDGET_CLASS (e_day_view_parent_class)->key_press_event (widget, event);
+ handled = GTK_WIDGET_CLASS (parent_class)->key_press_event (widget, event);
return handled;
}
@@ -5525,7 +5568,6 @@ e_day_view_start_editing_event (EDayView *day_view,
EDayViewEvent *event;
ETextEventProcessor *event_processor = NULL;
ETextEventProcessorCommand command;
- gboolean read_only;
#if 0
g_print ("In e_day_view_start_editing_event\n");
@@ -5544,9 +5586,6 @@ e_day_view_start_editing_event (EDayView *day_view,
event_num);
}
- if (!e_cal_is_read_only (event->comp_data->client, &read_only, NULL) || read_only)
- return;
-
/* If the event is not shown, don't try to edit it. */
if (!event->canvas_item)
return;
@@ -6028,9 +6067,6 @@ e_day_view_on_editing_stopped (EDayView *day_view,
g_message (G_STRLOC ": Could not create the object!");
else
g_signal_emit_by_name (day_view, "user_created");
-
- /* we remove the object since we either got the update from the server or failed */
- e_day_view_remove_event_cb (day_view, day, event_num, NULL);
} else {
CalObjModType mod = CALOBJ_MOD_ALL;
GtkWindow *toplevel;
diff --git a/calendar/gui/e-itip-control.c b/calendar/gui/e-itip-control.c
index 77116834a1..82d90c36fb 100644
--- a/calendar/gui/e-itip-control.c
+++ b/calendar/gui/e-itip-control.c
@@ -43,7 +43,6 @@
#include <gtkhtml/gtkhtml-embedded.h>
#include <gtkhtml/gtkhtml-stream.h>
#include <libedataserver/e-source-list.h>
-#include <libedataserverui/e-source-option-menu.h>
#include <libical/ical.h>
#include <libecal/e-cal-component.h>
#include <libecal/e-cal-time-util.h>
@@ -51,6 +50,7 @@
#include <e-util/e-time-utils.h>
#include <e-util/e-dialog-widgets.h>
#include <e-util/e-html-utils.h>
+#include <widgets/misc/e-source-option-menu.h>
#include "dialogs/delete-error.h"
#include "calendar-config.h"
#include "itip-utils.h"
@@ -104,17 +104,22 @@ struct _EItipControlPrivate {
#define HTML_BODY_END "</body>"
#define HTML_FOOTER "</html>"
-static void e_itip_control_destroy (GtkObject *obj);
+static void class_init (EItipControlClass *klass);
+static void init (EItipControl *itip);
+static void destroy (GtkObject *obj);
static void find_my_address (EItipControl *itip, icalcomponent *ical_comp, icalparameter_partstat *status);
static void url_requested_cb (GtkHTML *html, const gchar *url, GtkHTMLStream *handle, gpointer data);
static gboolean object_requested_cb (GtkHTML *html, GtkHTMLEmbedded *eb, gpointer data);
static void ok_clicked_cb (GtkWidget *widget, gpointer data);
-G_DEFINE_TYPE (EItipControl, e_itip_control, GTK_TYPE_VBOX);
+static GtkVBoxClass *parent_class = NULL;
+
+E_MAKE_TYPE (e_itip_control, "EItipControl", EItipControl, class_init, init,
+ GTK_TYPE_VBOX);
static void
-e_itip_control_class_init (EItipControlClass *klass)
+class_init (EItipControlClass *klass)
{
GObjectClass *object_class;
GtkObjectClass *gtkobject_class;
@@ -122,7 +127,9 @@ e_itip_control_class_init (EItipControlClass *klass)
object_class = G_OBJECT_CLASS (klass);
gtkobject_class = GTK_OBJECT_CLASS (klass);
- gtkobject_class->destroy = e_itip_control_destroy;
+ parent_class = g_type_class_peek_parent (klass);
+
+ gtkobject_class->destroy = destroy;
}
static void
@@ -382,7 +389,7 @@ html_destroyed (gpointer data)
}
static void
-e_itip_control_init (EItipControl *itip)
+init (EItipControl *itip)
{
EItipControlPrivate *priv;
GtkWidget *scrolled_window;
@@ -482,7 +489,7 @@ clean_up (EItipControl *itip)
}
static void
-e_itip_control_destroy (GtkObject *obj)
+destroy (GtkObject *obj)
{
EItipControl *itip = E_ITIP_CONTROL (obj);
EItipControlPrivate *priv;
@@ -512,7 +519,7 @@ e_itip_control_destroy (GtkObject *obj)
itip->priv = NULL;
}
- (* GTK_OBJECT_CLASS (e_itip_control_parent_class)->destroy) (obj);
+ (* GTK_OBJECT_CLASS (parent_class)->destroy) (obj);
}
GtkWidget *
@@ -2024,7 +2031,7 @@ send_item (EItipControl *itip)
comp = get_real_item (itip);
if (comp != NULL) {
- itip_send_comp (E_CAL_COMPONENT_METHOD_REQUEST, comp, priv->current_ecal, NULL, NULL);
+ itip_send_comp (E_CAL_COMPONENT_METHOD_REQUEST, comp, priv->current_ecal, NULL);
g_object_unref (comp);
dialog = gnome_ok_dialog (_("Item sent!\n"));
} else {
@@ -2070,7 +2077,7 @@ send_freebusy (EItipControl *itip)
for (l = comp_list; l; l = l->next) {
ECalComponent *comp = E_CAL_COMPONENT (l->data);
- itip_send_comp (E_CAL_COMPONENT_METHOD_REPLY, comp, priv->current_ecal, NULL, NULL);
+ itip_send_comp (E_CAL_COMPONENT_METHOD_REPLY, comp, priv->current_ecal, NULL);
g_object_unref (comp);
}
@@ -2510,7 +2517,7 @@ ok_clicked_cb (GtkWidget *widget, gpointer data)
g_slist_free (list);
e_cal_component_rescan (comp);
- itip_send_comp (E_CAL_COMPONENT_METHOD_REPLY, comp, priv->current_ecal, priv->top_level, NULL);
+ itip_send_comp (E_CAL_COMPONENT_METHOD_REPLY, comp, priv->current_ecal, priv->top_level);
g_object_unref (comp);
}
diff --git a/calendar/gui/e-meeting-time-sel.c b/calendar/gui/e-meeting-time-sel.c
index 5f92ab6a63..5335fca5d3 100644
--- a/calendar/gui/e-meeting-time-sel.c
+++ b/calendar/gui/e-meeting-time-sel.c
@@ -103,6 +103,8 @@ enum {
static gint mts_signals [LAST_SIGNAL] = { 0 };
+static void e_meeting_time_selector_class_init (EMeetingTimeSelectorClass * klass);
+static void e_meeting_time_selector_init (EMeetingTimeSelector * mts);
static void e_meeting_time_selector_destroy (GtkObject *object);
static void e_meeting_time_selector_alloc_named_color (EMeetingTimeSelector * mts,
const char *name, GdkColor *c);
@@ -207,10 +209,11 @@ static void row_inserted_cb (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter
static void row_changed_cb (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data);
static void row_deleted_cb (GtkTreeModel *model, GtkTreePath *path, gpointer data);
-static void free_busy_template_changed_cb (GConfClient *client, guint cnxn_id,
- GConfEntry *entry, gpointer user_data);
+static GtkTableClass *parent_class;
-G_DEFINE_TYPE (EMeetingTimeSelector, e_meeting_time_selector, GTK_TYPE_TABLE);
+E_MAKE_TYPE (e_meeting_time_selector, "EMeetingTimeSelector", EMeetingTimeSelector,
+ e_meeting_time_selector_class_init, e_meeting_time_selector_init,
+ GTK_TYPE_TABLE);
static void
e_meeting_time_selector_class_init (EMeetingTimeSelectorClass * klass)
@@ -218,6 +221,7 @@ e_meeting_time_selector_class_init (EMeetingTimeSelectorClass * klass)
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
+ parent_class = g_type_class_peek_parent (klass);
object_class = (GtkObjectClass *) klass;
widget_class = (GtkWidgetClass *) klass;
@@ -255,12 +259,6 @@ e_meeting_time_selector_init (EMeetingTimeSelector * mts)
mts->dragging_position = E_MEETING_TIME_SELECTOR_POS_NONE;
mts->list_view = NULL;
-
- mts->fb_uri_not =
- calendar_config_add_notification_free_busy_template ((GConfClientNotifyFunc) free_busy_template_changed_cb,
- mts);
-
- mts->fb_refresh_not = 0;
}
@@ -279,7 +277,6 @@ e_meeting_time_selector_construct (EMeetingTimeSelector * mts, EMeetingStore *em
guchar stipple_bits[] = {
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80,
};
- AtkObject *a11y_label, *a11y_date_edit;
/* The default meeting time is the nearest half-hour interval in the
future, in working hours. */
@@ -594,14 +591,6 @@ e_meeting_time_selector_construct (EMeetingTimeSelector * mts, EMeetingStore *em
gtk_widget_show (table);
mts->start_date_edit = e_date_edit_new ();
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), mts->start_date_edit);
- a11y_label = gtk_widget_get_accessible (label);
- a11y_date_edit = gtk_widget_get_accessible (mts->start_date_edit);
- if (a11y_label != NULL && a11y_date_edit != NULL) {
- atk_object_add_relationship (a11y_date_edit,
- ATK_RELATION_LABELLED_BY,
- a11y_label);
- }
e_date_edit_set_show_time (E_DATE_EDIT (mts->start_date_edit), TRUE);
e_date_edit_set_use_24_hour_format (E_DATE_EDIT (mts->start_date_edit),
calendar_config_get_24_hour_format ());
@@ -621,14 +610,6 @@ e_meeting_time_selector_construct (EMeetingTimeSelector * mts, EMeetingStore *em
gtk_widget_show (label);
mts->end_date_edit = e_date_edit_new ();
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), mts->end_date_edit);
- a11y_label = gtk_widget_get_accessible (label);
- a11y_date_edit = gtk_widget_get_accessible (mts->end_date_edit);
- if (a11y_label != NULL && a11y_date_edit != NULL) {
- atk_object_add_relationship (a11y_date_edit,
- ATK_RELATION_LABELLED_BY,
- a11y_label);
- }
e_date_edit_set_show_time (E_DATE_EDIT (mts->end_date_edit), TRUE);
e_date_edit_set_use_24_hour_format (E_DATE_EDIT (mts->end_date_edit),
calendar_config_get_24_hour_format ());
@@ -834,15 +815,9 @@ e_meeting_time_selector_destroy (GtkObject *object)
mts->display_top = NULL;
mts->display_main = NULL;
-
- calendar_config_remove_notification (mts->fb_uri_not);
-
- if (mts->fb_refresh_not != 0) {
- g_source_remove (mts->fb_refresh_not);
- }
- if (GTK_OBJECT_CLASS (e_meeting_time_selector_parent_class)->destroy)
- (*GTK_OBJECT_CLASS (e_meeting_time_selector_parent_class)->destroy)(object);
+ if (GTK_OBJECT_CLASS (parent_class)->destroy)
+ (*GTK_OBJECT_CLASS (parent_class)->destroy)(object);
}
@@ -851,8 +826,8 @@ e_meeting_time_selector_realize (GtkWidget *widget)
{
EMeetingTimeSelector *mts;
- if (GTK_WIDGET_CLASS (e_meeting_time_selector_parent_class)->realize)
- (*GTK_WIDGET_CLASS (e_meeting_time_selector_parent_class)->realize)(widget);
+ if (GTK_WIDGET_CLASS (parent_class)->realize)
+ (*GTK_WIDGET_CLASS (parent_class)->realize)(widget);
mts = E_MEETING_TIME_SELECTOR (widget);
@@ -870,8 +845,8 @@ e_meeting_time_selector_unrealize (GtkWidget *widget)
gdk_gc_unref (mts->color_key_gc);
mts->color_key_gc = NULL;
- if (GTK_WIDGET_CLASS (e_meeting_time_selector_parent_class)->unrealize)
- (*GTK_WIDGET_CLASS (e_meeting_time_selector_parent_class)->unrealize)(widget);
+ if (GTK_WIDGET_CLASS (parent_class)->unrealize)
+ (*GTK_WIDGET_CLASS (parent_class)->unrealize)(widget);
}
static int
@@ -903,8 +878,8 @@ e_meeting_time_selector_style_set (GtkWidget *widget,
GtkTreePath *path;
GdkRectangle cell_area;
- if (GTK_WIDGET_CLASS (e_meeting_time_selector_parent_class)->style_set)
- (*GTK_WIDGET_CLASS (e_meeting_time_selector_parent_class)->style_set)(widget, previous_style);
+ if (GTK_WIDGET_CLASS (parent_class)->style_set)
+ (*GTK_WIDGET_CLASS (parent_class)->style_set)(widget, previous_style);
mts = E_MEETING_TIME_SELECTOR (widget);
@@ -968,8 +943,8 @@ e_meeting_time_selector_expose_event (GtkWidget *widget,
e_meeting_time_selector_draw_shadow (mts);
- if (GTK_WIDGET_CLASS (e_meeting_time_selector_parent_class)->expose_event)
- (*GTK_WIDGET_CLASS (e_meeting_time_selector_parent_class)->expose_event)(widget, event);
+ if (GTK_WIDGET_CLASS (parent_class)->expose_event)
+ (*GTK_WIDGET_CLASS (parent_class)->expose_event)(widget, event);
return FALSE;
}
@@ -2892,42 +2867,3 @@ row_deleted_cb (GtkTreeModel *model, GtkTreePath *path, gpointer data)
gtk_widget_queue_draw (mts->display_main);
}
-
-#define REFRESH_PAUSE 5000
-
-static gboolean
-free_busy_timeout_refresh (gpointer data)
-{
- char *fb_uri;
-
- EMeetingTimeSelector *mts = E_MEETING_TIME_SELECTOR (data);
-
- fb_uri = calendar_config_get_free_busy_template ();
- e_meeting_store_set_fb_uri (mts->model, fb_uri);
- g_free (fb_uri);
-
- /* Update all free/busy info, so we use the new template uri */
- e_meeting_time_selector_refresh_free_busy (mts, 0, TRUE);
-
- mts->fb_refresh_not = 0;
-
- return FALSE;
-}
-
-static void
-free_busy_template_changed_cb (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer data)
-{
- EMeetingTimeSelector *mts = E_MEETING_TIME_SELECTOR (data);
-
- /* Wait REFRESH_PAUSE before refreshing, using the latest uri value */
- if (mts->fb_refresh_not != 0) {
- g_source_remove (mts->fb_refresh_not);
- }
-
- mts->fb_refresh_not = g_timeout_add (REFRESH_PAUSE,
- free_busy_timeout_refresh,
- data);
-}
diff --git a/calendar/gui/e-week-view-event-item.c b/calendar/gui/e-week-view-event-item.c
index e4ace7961e..abecb745ac 100644
--- a/calendar/gui/e-week-view-event-item.c
+++ b/calendar/gui/e-week-view-event-item.c
@@ -28,9 +28,7 @@
* edit the text.
*/
-#ifdef HAVE_CONFIG_H
#include <config.h>
-#endif
#include "e-util/e-categories-config.h"
#include "e-week-view-event-item.h"
@@ -38,6 +36,9 @@
#include <gtk/gtksignal.h>
#include <gal/e-text/e-text.h>
+static void e_week_view_event_item_class_init (EWeekViewEventItemClass *class);
+static void e_week_view_event_item_init (EWeekViewEventItem *wveitem);
+
static void e_week_view_event_item_set_arg (GtkObject *o,
GtkArg *arg,
guint arg_id);
@@ -88,6 +89,8 @@ static ECalendarViewPosition e_week_view_event_item_get_position (EWeekViewEvent
gdouble y);
+static GnomeCanvasItemClass *parent_class;
+
/* The arguments we take */
enum {
ARG_0,
@@ -95,7 +98,9 @@ enum {
ARG_SPAN_NUM
};
-G_DEFINE_TYPE (EWeekViewEventItem, e_week_view_event_item, GNOME_TYPE_CANVAS_ITEM);
+E_MAKE_TYPE (e_week_view_event_item, "EWeekViewEventItem", EWeekViewEventItem,
+ e_week_view_event_item_class_init, e_week_view_event_item_init,
+ GNOME_TYPE_CANVAS_ITEM);
static void
e_week_view_event_item_class_init (EWeekViewEventItemClass *class)
@@ -103,6 +108,8 @@ e_week_view_event_item_class_init (EWeekViewEventItemClass *class)
GtkObjectClass *object_class;
GnomeCanvasItemClass *item_class;
+ parent_class = g_type_class_peek_parent (class);
+
object_class = (GtkObjectClass *) class;
item_class = (GnomeCanvasItemClass *) class;
@@ -175,8 +182,8 @@ e_week_view_event_item_update (GnomeCanvasItem *item,
week_view = E_WEEK_VIEW (GTK_WIDGET (item->canvas)->parent);
g_return_if_fail (E_IS_WEEK_VIEW (week_view));
- if (GNOME_CANVAS_ITEM_CLASS (e_week_view_event_item_parent_class)->update)
- (* GNOME_CANVAS_ITEM_CLASS (e_week_view_event_item_parent_class)->update) (item, affine, clip_path, flags);
+ if (GNOME_CANVAS_ITEM_CLASS (parent_class)->update)
+ (* GNOME_CANVAS_ITEM_CLASS (parent_class)->update) (item, affine, clip_path, flags);
item->x1 = 0;
item->y1 = 0;
@@ -596,7 +603,7 @@ e_week_view_event_item_draw_icons (EWeekViewEventItem *wveitem,
GdkGC *gc;
gint num_icons = 0, icon_x_inc;
gboolean draw_reminder_icon = FALSE, draw_recurrence_icon = FALSE;
- gboolean draw_timezone_icon = FALSE, draw_attach_icon = FALSE;
+ gboolean draw_timezone_icon = FALSE;
GSList *categories_list, *elem;
week_view = E_WEEK_VIEW (GTK_WIDGET (GNOME_CANVAS_ITEM (wveitem)->canvas)->parent);
@@ -619,12 +626,7 @@ e_week_view_event_item_draw_icons (EWeekViewEventItem *wveitem,
draw_recurrence_icon = TRUE;
num_icons++;
}
-
- if (e_cal_component_has_attachments (comp)) {
- draw_attach_icon = TRUE;
- num_icons++;
- }
-
+
if (event->different_timezone) {
draw_timezone_icon = TRUE;
num_icons++;
@@ -658,18 +660,6 @@ e_week_view_event_item_draw_icons (EWeekViewEventItem *wveitem,
icon_x += icon_x_inc;
}
- if (draw_attach_icon && icon_x + E_WEEK_VIEW_ICON_WIDTH <= x2) {
- gdk_gc_set_clip_mask (gc, NULL);
- gdk_draw_pixbuf (drawable, gc,
- week_view->attach_icon,
- 0, 0, icon_x, icon_y,
- E_WEEK_VIEW_ICON_WIDTH,
- E_WEEK_VIEW_ICON_HEIGHT,
- GDK_RGB_DITHER_NORMAL,
- 0, 0);
- icon_x += icon_x_inc;
- }
-
if (draw_recurrence_icon && icon_x + E_WEEK_VIEW_ICON_WIDTH <= x2) {
gdk_gc_set_clip_mask (gc, NULL);
gdk_draw_pixbuf (drawable, gc,
diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c
index 684d278d84..19455ea9a5 100644
--- a/calendar/gui/e-week-view.c
+++ b/calendar/gui/e-week-view.c
@@ -94,9 +94,10 @@ typedef struct {
ECalModelComponent *comp_data;
} AddEventData;
+static void e_week_view_class_init (EWeekViewClass *class);
+static void e_week_view_init (EWeekView *week_view);
static void e_week_view_destroy (GtkObject *object);
static void e_week_view_realize (GtkWidget *widget);
-static void e_week_view_set_colors(EWeekView *week_view, GtkWidget *widget);
static void e_week_view_unrealize (GtkWidget *widget);
static void e_week_view_style_set (GtkWidget *widget,
GtkStyle *previous_style);
@@ -156,14 +157,14 @@ static void e_week_view_reshape_event_span (EWeekView *week_view,
gint span_num);
static void e_week_view_recalc_day_starts (EWeekView *week_view,
time_t lower);
+static void e_week_view_on_adjustment_changed (GtkAdjustment *adjustment,
+ EWeekView *week_view);
static void e_week_view_on_editing_started (EWeekView *week_view,
GnomeCanvasItem *item);
static void e_week_view_on_editing_stopped (EWeekView *week_view,
GnomeCanvasItem *item);
static gboolean e_week_view_find_event_from_uid (EWeekView *week_view,
- ECal *client,
const gchar *uid,
- const gchar *rid,
gint *event_num_return);
typedef gboolean (* EWeekViewForeachEventCallback) (EWeekView *week_view,
gint event_num,
@@ -208,7 +209,10 @@ static void e_week_view_queue_layout (EWeekView *week_view);
static void e_week_view_cancel_layout (EWeekView *week_view);
static gboolean e_week_view_layout_timeout_cb (gpointer data);
-G_DEFINE_TYPE (EWeekView, e_week_view, E_TYPE_CALENDAR_VIEW);
+static ECalendarViewClass *parent_class;
+
+E_MAKE_TYPE (e_week_view, "EWeekView", EWeekView, e_week_view_class_init,
+ e_week_view_init, e_calendar_view_get_type ());
static void
e_week_view_class_init (EWeekViewClass *class)
@@ -217,6 +221,7 @@ e_week_view_class_init (EWeekViewClass *class)
GtkWidgetClass *widget_class;
ECalendarViewClass *view_class;
+ parent_class = g_type_class_peek_parent (class);
object_class = (GtkObjectClass *) class;
widget_class = (GtkWidgetClass *) class;
view_class = (ECalendarViewClass *) class;
@@ -303,13 +308,24 @@ time_range_changed_cb (ECalModel *model, time_t start_time, time_t end_time, gpo
e_week_view_set_selected_time_range (E_CALENDAR_VIEW (week_view), start_time, start_time);
}
+static gboolean
+process_component_recur_cb (ECalComponent *comp, time_t start, time_t end, gpointer data)
+{
+ AddEventData *add_event_data;
+
+ add_event_data = data;
+
+ return e_week_view_add_event (comp, start, end, FALSE, add_event_data);
+}
+
static void
process_component (EWeekView *week_view, ECalModelComponent *comp_data)
{
- gint num_days;
+ EWeekViewEvent *event;
+ gint event_num, num_days;
ECalComponent *comp = NULL;
AddEventData add_event_data;
- const char *uid, *rid;
+ const char *uid;
/* If we don't have a valid date set yet, just return. */
if (!g_date_valid (&week_view->first_day_shown))
@@ -324,22 +340,65 @@ process_component (EWeekView *week_view, ECalModelComponent *comp_data)
}
e_cal_component_get_uid (comp, &uid);
- if (e_cal_component_is_instance (comp))
- rid = e_cal_component_get_recurid_as_string (comp);
- else
- rid = NULL;
- /* Add the object */
+ /* If the event already exists and the dates didn't change, we can
+ update the event fairly easily without changing the events arrays
+ or computing a new layout. */
+ if (e_week_view_find_event_from_uid (week_view, uid, &event_num)) {
+ ECalComponent *tmp_comp;
+
+ event = &g_array_index (week_view->events, EWeekViewEvent,
+ event_num);
+
+ tmp_comp = e_cal_component_new ();
+ e_cal_component_set_icalcomponent (tmp_comp, icalcomponent_new_clone (event->comp_data->icalcomp));
+ if (!e_cal_component_has_recurrences (comp)
+ && !e_cal_component_has_recurrences (tmp_comp)
+ && e_cal_component_event_dates_match (comp, tmp_comp)) {
+#if 0
+ g_print ("updated object's dates unchanged\n");
+#endif
+ e_week_view_foreach_event_with_uid (week_view, uid, e_week_view_update_event_cb, comp_data);
+ g_object_unref (comp);
+ g_object_unref (tmp_comp);
+ gtk_widget_queue_draw (week_view->main_canvas);
+ return;
+ }
+
+ /* The dates have changed, so we need to remove the
+ old occurrrences before adding the new ones. */
+#if 0
+ g_print ("dates changed - removing occurrences\n");
+#endif
+ e_week_view_foreach_event_with_uid (week_view, uid,
+ e_week_view_remove_event_cb,
+ NULL);
+
+ g_object_unref (tmp_comp);
+ }
+
+ /* Add the occurrences of the event */
num_days = week_view->multi_week_view ? week_view->weeks_shown * 7 : 7;
add_event_data.week_view = week_view;
add_event_data.comp_data = comp_data;
- e_week_view_add_event (comp, comp_data->instance_start, comp_data->instance_end, FALSE, &add_event_data);
+ e_cal_generate_instances_for_object (comp_data->client, comp_data->icalcomp,
+ week_view->day_starts[0],
+ week_view->day_starts[num_days],
+ process_component_recur_cb, &add_event_data);
g_object_unref (comp);
}
static void
+model_changed_cb (ETableModel *etm, gpointer user_data)
+{
+ EWeekView *week_view = E_WEEK_VIEW (user_data);
+
+ e_week_view_update_query (week_view);
+}
+
+static void
update_row (EWeekView *week_view, int row)
{
ECalModelComponent *comp_data;
@@ -378,7 +437,6 @@ model_rows_inserted_cb (ETableModel *etm, int row, int count, gpointer user_data
int i;
model = e_calendar_view_get_model (E_CALENDAR_VIEW (week_view));
-
for (i = 0; i < count; i++) {
ECalModelComponent *comp_data;
@@ -391,36 +449,49 @@ model_rows_inserted_cb (ETableModel *etm, int row, int count, gpointer user_data
e_week_view_queue_layout (week_view);
}
+static gboolean
+row_deleted_check_cb (EWeekView *week_view, gint event_num, gpointer data)
+{
+ GHashTable *uids = data;
+ EWeekViewEvent *event;
+ ECalModel *model;
+ const char *uid;
+
+ event = &g_array_index (week_view->events, EWeekViewEvent, event_num);
+ uid = icalcomponent_get_uid (event->comp_data->icalcomp);
+ model = e_calendar_view_get_model (E_CALENDAR_VIEW (week_view));
+
+ if (!e_cal_model_get_component_for_uid (model, uid))
+ g_hash_table_insert (uids, g_strdup(uid), GINT_TO_POINTER (1));
+
+ return TRUE;
+}
+
+static void
+remove_uid_cb (gpointer key, gpointer value, gpointer data)
+{
+ EWeekView *week_view = data;
+ char *uid = key;
+
+ e_week_view_foreach_event_with_uid (week_view, uid, e_week_view_remove_event_cb, NULL);
+ g_free(uid);
+}
+
static void
model_rows_deleted_cb (ETableModel *etm, int row, int count, gpointer user_data)
{
EWeekView *week_view = E_WEEK_VIEW (user_data);
- int i;
+ GHashTable *uids;
/* FIXME Stop editing? */
-
- for (i = row + count; i > row; i--) {
- gint event_num;
- const char *uid, *rid = NULL;
- ECalModelComponent *comp_data;
- comp_data = e_cal_model_get_component_at (E_CAL_MODEL (etm), i - 1);
- if (!comp_data)
- continue;
-
- uid = icalcomponent_get_uid (comp_data->icalcomp);
- if (e_cal_util_component_is_instance (comp_data->icalcomp)) {
- icalproperty *prop;
-
- prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_RECURRENCEID_PROPERTY);
- if (prop)
- rid = icaltime_as_ical_string (icalcomponent_get_recurrenceid (comp_data->icalcomp));
- }
-
- if (e_week_view_find_event_from_uid (week_view, comp_data->client, uid, rid, &event_num))
- e_week_view_remove_event_cb (week_view, event_num, NULL);
- }
+ uids = g_hash_table_new (g_str_hash, g_str_equal);
+
+ e_week_view_foreach_event (week_view, row_deleted_check_cb, uids);
+ g_hash_table_foreach (uids, remove_uid_cb, week_view);
+ g_hash_table_destroy (uids);
+
gtk_widget_queue_draw (week_view->main_canvas);
e_week_view_queue_layout (week_view);
}
@@ -596,6 +667,8 @@ e_week_view_init (EWeekView *week_view)
/* connect to ECalModel's signals */
g_signal_connect (G_OBJECT (model), "time_range_changed",
G_CALLBACK (time_range_changed_cb), week_view);
+ g_signal_connect (G_OBJECT (model), "model_changed",
+ G_CALLBACK (model_changed_cb), week_view);
g_signal_connect (G_OBJECT (model), "model_row_changed",
G_CALLBACK (model_row_changed_cb), week_view);
g_signal_connect (G_OBJECT (model), "model_cell_changed",
@@ -623,7 +696,6 @@ e_week_view_new (void)
GtkWidget *week_view;
week_view = GTK_WIDGET (g_object_new (e_week_view_get_type (), NULL));
- e_cal_model_set_flags (e_calendar_view_get_model (E_CALENDAR_VIEW (week_view)), E_CAL_MODEL_FLAGS_EXPAND_RECURRENCES);
return week_view;
}
@@ -669,7 +741,7 @@ e_week_view_destroy (GtkObject *object)
week_view->resize_width_cursor = NULL;
}
- GTK_OBJECT_CLASS (e_week_view_parent_class)->destroy (object);
+ GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
@@ -681,8 +753,8 @@ e_week_view_realize (GtkWidget *widget)
gboolean success[E_WEEK_VIEW_COLOR_LAST];
gint nfailed;
- if (GTK_WIDGET_CLASS (e_week_view_parent_class)->realize)
- (*GTK_WIDGET_CLASS (e_week_view_parent_class)->realize)(widget);
+ if (GTK_WIDGET_CLASS (parent_class)->realize)
+ (*GTK_WIDGET_CLASS (parent_class)->realize)(widget);
week_view = E_WEEK_VIEW (widget);
week_view->main_gc = gdk_gc_new (widget->window);
@@ -690,32 +762,64 @@ e_week_view_realize (GtkWidget *widget)
colormap = gtk_widget_get_colormap (widget);
/* Allocate the colors. */
- e_week_view_set_colors(week_view, widget);
-
+ week_view->colors[E_WEEK_VIEW_COLOR_EVEN_MONTHS].red = 0xe0e0;
+ week_view->colors[E_WEEK_VIEW_COLOR_EVEN_MONTHS].green = 0xe0e0;
+ week_view->colors[E_WEEK_VIEW_COLOR_EVEN_MONTHS].blue = 0xe0e0;
+
+ week_view->colors[E_WEEK_VIEW_COLOR_ODD_MONTHS].red = 65535;
+ week_view->colors[E_WEEK_VIEW_COLOR_ODD_MONTHS].green = 65535;
+ week_view->colors[E_WEEK_VIEW_COLOR_ODD_MONTHS].blue = 65535;
+
+ week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND].red = 213 * 257;
+ week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND].green = 213 * 257;
+ week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND].blue = 213 * 257;
+
+ week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BORDER].red = 0;
+ week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BORDER].green = 0;
+ week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BORDER].blue = 0;
+
+ week_view->colors[E_WEEK_VIEW_COLOR_EVENT_TEXT].red = 0;
+ week_view->colors[E_WEEK_VIEW_COLOR_EVENT_TEXT].green = 0;
+ week_view->colors[E_WEEK_VIEW_COLOR_EVENT_TEXT].blue = 0;
+
+ week_view->colors[E_WEEK_VIEW_COLOR_GRID].red = 0 * 257;
+ week_view->colors[E_WEEK_VIEW_COLOR_GRID].green = 0 * 257;
+ week_view->colors[E_WEEK_VIEW_COLOR_GRID].blue = 0 * 257;
+
+ week_view->colors[E_WEEK_VIEW_COLOR_SELECTED].red = 0 * 257;
+ week_view->colors[E_WEEK_VIEW_COLOR_SELECTED].green = 0 * 257;
+ week_view->colors[E_WEEK_VIEW_COLOR_SELECTED].blue = 156 * 257;
+
+ week_view->colors[E_WEEK_VIEW_COLOR_SELECTED_UNFOCUSSED].red = 16 * 257;
+ week_view->colors[E_WEEK_VIEW_COLOR_SELECTED_UNFOCUSSED].green = 78 * 257;
+ week_view->colors[E_WEEK_VIEW_COLOR_SELECTED_UNFOCUSSED].blue = 139 * 257;
+
+ week_view->colors[E_WEEK_VIEW_COLOR_DATES].red = 0 * 257;
+ week_view->colors[E_WEEK_VIEW_COLOR_DATES].green = 0 * 257;
+ week_view->colors[E_WEEK_VIEW_COLOR_DATES].blue = 0 * 257;
+
+ week_view->colors[E_WEEK_VIEW_COLOR_DATES_SELECTED].red = 65535;
+ week_view->colors[E_WEEK_VIEW_COLOR_DATES_SELECTED].green = 65535;
+ week_view->colors[E_WEEK_VIEW_COLOR_DATES_SELECTED].blue = 65535;
+
+ week_view->colors[E_WEEK_VIEW_COLOR_TODAY].red = 65535;
+ week_view->colors[E_WEEK_VIEW_COLOR_TODAY].green = 0;
+ week_view->colors[E_WEEK_VIEW_COLOR_TODAY].blue = 0;
+
+ nfailed = gdk_colormap_alloc_colors (colormap, week_view->colors,
+ E_WEEK_VIEW_COLOR_LAST, FALSE,
+ TRUE, success);
+ if (nfailed)
+ g_warning ("Failed to allocate all colors");
+
gdk_gc_set_colormap (week_view->main_gc, colormap);
/* Create the pixmaps. */
week_view->reminder_icon = e_icon_factory_get_icon ("stock_bell", E_ICON_SIZE_MENU);
week_view->recurrence_icon = e_icon_factory_get_icon ("stock_refresh", E_ICON_SIZE_MENU);
week_view->timezone_icon = e_icon_factory_get_icon ("stock_timezone", E_ICON_SIZE_MENU);
- week_view->attach_icon = e_icon_factory_get_icon ("stock_attach", E_ICON_SIZE_MENU);
}
-static void
-e_week_view_set_colors(EWeekView *week_view, GtkWidget *widget)
-{
- week_view->colors[E_WEEK_VIEW_COLOR_EVEN_MONTHS] = widget->style->base[GTK_STATE_INSENSITIVE];
- week_view->colors[E_WEEK_VIEW_COLOR_ODD_MONTHS] = widget->style->base[GTK_STATE_NORMAL];
- week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND] = widget->style->base[GTK_STATE_NORMAL];
- week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BORDER] = widget->style->dark[GTK_STATE_NORMAL];
- week_view->colors[E_WEEK_VIEW_COLOR_EVENT_TEXT] = widget->style->text[GTK_STATE_NORMAL];
- week_view->colors[E_WEEK_VIEW_COLOR_GRID] = widget->style->dark[GTK_STATE_NORMAL];
- week_view->colors[E_WEEK_VIEW_COLOR_SELECTED] = widget->style->base[GTK_STATE_SELECTED];
- week_view->colors[E_WEEK_VIEW_COLOR_SELECTED_UNFOCUSSED] = widget->style->bg[GTK_STATE_SELECTED];
- week_view->colors[E_WEEK_VIEW_COLOR_DATES] = widget->style->text[GTK_STATE_NORMAL];
- week_view->colors[E_WEEK_VIEW_COLOR_DATES_SELECTED] = widget->style->text[GTK_STATE_SELECTED];
- week_view->colors[E_WEEK_VIEW_COLOR_TODAY] = widget->style->base[GTK_STATE_SELECTED];
-}
static void
e_week_view_unrealize (GtkWidget *widget)
@@ -737,11 +841,9 @@ e_week_view_unrealize (GtkWidget *widget)
week_view->recurrence_icon = NULL;
g_object_unref (week_view->timezone_icon);
week_view->timezone_icon = NULL;
- g_object_unref (week_view->attach_icon);
- week_view->attach_icon = NULL;
- if (GTK_WIDGET_CLASS (e_week_view_parent_class)->unrealize)
- (*GTK_WIDGET_CLASS (e_week_view_parent_class)->unrealize)(widget);
+ if (GTK_WIDGET_CLASS (parent_class)->unrealize)
+ (*GTK_WIDGET_CLASS (parent_class)->unrealize)(widget);
}
static gint
@@ -786,35 +888,19 @@ e_week_view_style_set (GtkWidget *widget,
GtkStyle *style;
gint day, day_width, max_day_width, max_abbr_day_width;
gint month, month_width, max_month_width, max_abbr_month_width;
- gint span_num;
GDate date;
gchar buffer[128];
PangoFontDescription *font_desc;
PangoContext *pango_context;
PangoFontMetrics *font_metrics;
PangoLayout *layout;
- EWeekViewEventSpan *span;
- if (GTK_WIDGET_CLASS (e_week_view_parent_class)->style_set)
- (*GTK_WIDGET_CLASS (e_week_view_parent_class)->style_set)(widget, previous_style);
+ if (GTK_WIDGET_CLASS (parent_class)->style_set)
+ (*GTK_WIDGET_CLASS (parent_class)->style_set)(widget, previous_style);
week_view = E_WEEK_VIEW (widget);
style = gtk_widget_get_style (widget);
- e_week_view_set_colors(week_view, widget);
- if (week_view->spans) {
- for (span_num = 0; span_num < week_view->spans->len;
- span_num++) {
- span = &g_array_index (week_view->spans,
- EWeekViewEventSpan, span_num);
- if (span->text_item){
- gnome_canvas_item_set (span->text_item,
- "fill_color_gdk", &widget->style->text[GTK_STATE_NORMAL],
- NULL);
- }
- }
- }
-
/* Set up Pango prerequisites */
font_desc = style->font_desc;
pango_context = gtk_widget_get_pango_context (widget);
@@ -912,7 +998,7 @@ e_week_view_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
week_view = E_WEEK_VIEW (widget);
- (*GTK_WIDGET_CLASS (e_week_view_parent_class)->size_allocate) (widget, allocation);
+ (*GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation);
e_week_view_recalc_cell_sizes (week_view);
@@ -1114,8 +1200,8 @@ e_week_view_expose_event (GtkWidget *widget,
e_week_view_draw_shadow (week_view);
- if (GTK_WIDGET_CLASS (e_week_view_parent_class)->expose_event)
- (*GTK_WIDGET_CLASS (e_week_view_parent_class)->expose_event)(widget, event);
+ if (GTK_WIDGET_CLASS (parent_class)->expose_event)
+ (*GTK_WIDGET_CLASS (parent_class)->expose_event)(widget, event);
return FALSE;
}
@@ -1548,7 +1634,6 @@ e_week_view_set_first_day_shown (EWeekView *week_view,
if (update_adjustment_value)
gtk_adjustment_set_value (GTK_RANGE (week_view->vscrollbar)->adjustment, 0);
- e_week_view_update_query (week_view);
gtk_widget_queue_draw (week_view->main_canvas);
}
@@ -1905,17 +1990,12 @@ e_week_view_remove_event_cb (EWeekView *week_view,
gint span_num;
event = &g_array_index (week_view->events, EWeekViewEvent, event_num);
- if (!event)
- return TRUE;
/* If we were editing this event, set editing_event_num to -1 so
on_editing_stopped doesn't try to update the event. */
if (week_view->editing_event_num == event_num)
week_view->editing_event_num = -1;
- if (week_view->popup_event_num == event_num)
- week_view->popup_event_num = -1;
-
/* We leave the span elements in the array, but set the canvas item
pointers to NULL. */
for (span_num = 0; span_num < event->num_spans; span_num++) {
@@ -1933,7 +2013,6 @@ e_week_view_remove_event_cb (EWeekView *week_view,
}
e_cal_model_free_component_data (event->comp_data);
- event->comp_data = NULL;
g_array_remove_index (week_view->events, event_num);
week_view->events_need_layout = TRUE;
@@ -2065,7 +2144,7 @@ e_week_view_on_button_press (GtkWidget *widget,
if (event->button == 1) {
/* Start the selection drag. */
- if (!GTK_WIDGET_HAS_FOCUS (week_view) && !GTK_WIDGET_HAS_FOCUS (week_view->main_canvas))
+ if (!GTK_WIDGET_HAS_FOCUS (week_view))
gtk_widget_grab_focus (GTK_WIDGET (week_view));
if (gdk_pointer_grab (GTK_LAYOUT (widget)->bin_window, FALSE,
@@ -2075,7 +2154,6 @@ e_week_view_on_button_press (GtkWidget *widget,
week_view->selection_start_day = day;
week_view->selection_end_day = day;
week_view->selection_drag_pos = E_WEEK_VIEW_DRAG_END;
- g_signal_emit_by_name (week_view, "selected_time_changed");
/* FIXME: Optimise? */
gtk_widget_queue_draw (week_view->main_canvas);
@@ -2583,8 +2661,6 @@ e_week_view_reshape_event_span (EWeekView *week_view,
num_icons++;
if (e_cal_component_has_recurrences (comp))
num_icons++;
- if (e_cal_component_has_attachments (comp))
- num_icons++;
if (event->different_timezone)
num_icons++;
@@ -2618,9 +2694,7 @@ e_week_view_reshape_event_span (EWeekView *week_view,
/* Create the text item if necessary. */
if (!span->text_item) {
ECalComponentText text;
- GtkWidget *widget;
- widget = (GtkWidget *)week_view;
e_cal_component_get_summary (comp, &text);
span->text_item =
gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (week_view->main_canvas)->root),
@@ -2631,7 +2705,7 @@ e_week_view_reshape_event_span (EWeekView *week_view,
"editable", TRUE,
"text", text.value ? text.value : "",
"use_ellipsis", TRUE,
- "fill_color_gdk", &widget->style->text[GTK_STATE_NORMAL],
+ "fill_color_rgba", GNOME_CANVAS_COLOR(0, 0, 0),
"im_context", E_CANVAS (week_view->main_canvas)->im_context,
NULL);
@@ -2794,7 +2868,6 @@ e_week_view_start_editing_event (EWeekView *week_view,
ETextEventProcessor *event_processor = NULL;
ETextEventProcessorCommand command;
ECalModelComponent *comp_data;
- gboolean read_only;
/* If we are already editing the event, just return. */
if (event_num == week_view->editing_event_num
@@ -2805,9 +2878,6 @@ e_week_view_start_editing_event (EWeekView *week_view,
span = &g_array_index (week_view->spans, EWeekViewEventSpan,
event->spans_index + span_num);
- if (!e_cal_is_read_only (event->comp_data->client, &read_only, NULL) || read_only)
- return FALSE;
-
/* If the event is not shown, don't try to edit it. */
if (!span->text_item)
return FALSE;
@@ -3308,10 +3378,7 @@ e_week_view_on_editing_stopped (EWeekView *week_view,
if (!e_cal_create_object (client, icalcomp, NULL, NULL))
g_message (G_STRLOC ": Could not create the object!");
else
- g_signal_emit_by_name (week_view, "user_created");
-
- /* we remove the object since we either got the update from the server or failed */
- e_week_view_remove_event_cb (week_view, event_num, NULL);
+ g_signal_emit_by_name (week_view, "user_created");
} else {
CalObjModType mod = CALOBJ_MOD_ALL;
GtkWindow *toplevel;
@@ -3375,9 +3442,7 @@ e_week_view_find_event_from_item (EWeekView *week_view,
see if any events with the uid exist. */
static gboolean
e_week_view_find_event_from_uid (EWeekView *week_view,
- ECal *client,
const gchar *uid,
- const gchar *rid,
gint *event_num_return)
{
EWeekViewEvent *event;
@@ -3389,24 +3454,13 @@ e_week_view_find_event_from_uid (EWeekView *week_view,
num_events = week_view->events->len;
for (event_num = 0; event_num < num_events; event_num++) {
- const char *u, *r;
+ const char *u;
event = &g_array_index (week_view->events, EWeekViewEvent,
event_num);
- if (event->comp_data->client != client)
- continue;
-
u = icalcomponent_get_uid (event->comp_data->icalcomp);
if (u && !strcmp (uid, u)) {
- if (rid && *rid) {
- r = icaltime_as_ical_string (icalcomponent_get_recurrenceid (event->comp_data->icalcomp));
- if (!r || !*r)
- continue;
- if (strcmp (rid, r) != 0)
- continue;
- }
-
*event_num_return = event_num;
return TRUE;
}
@@ -3451,9 +3505,9 @@ e_week_view_do_cursor_key_up (EWeekView *week_view)
if (week_view->selection_start_day <= 0)
return;
+ g_signal_emit_by_name (week_view, "selected_time_changed");
week_view->selection_start_day--;
week_view->selection_end_day = week_view->selection_start_day;
- g_signal_emit_by_name (week_view, "selected_time_changed");
gtk_widget_queue_draw (week_view->main_canvas);
}
@@ -3464,9 +3518,9 @@ e_week_view_do_cursor_key_down (EWeekView *week_view)
week_view->selection_start_day >= 6)
return;
+ g_signal_emit_by_name (week_view, "selected_time_changed");
week_view->selection_start_day++;
week_view->selection_end_day = week_view->selection_start_day;
- g_signal_emit_by_name (week_view, "selected_time_changed");
gtk_widget_queue_draw (week_view->main_canvas);
}
@@ -3476,9 +3530,9 @@ e_week_view_do_cursor_key_left (EWeekView *week_view)
if (week_view->selection_start_day == -1)
return;
+ g_signal_emit_by_name (week_view, "selected_time_changed");
week_view->selection_start_day = map_left[week_view->selection_start_day];
week_view->selection_end_day = week_view->selection_start_day;
- g_signal_emit_by_name (week_view, "selected_time_changed");
gtk_widget_queue_draw (week_view->main_canvas);
}
@@ -3488,9 +3542,9 @@ e_week_view_do_cursor_key_right (EWeekView *week_view)
if (week_view->selection_start_day == -1)
return;
+ g_signal_emit_by_name (week_view, "selected_time_changed");
week_view->selection_start_day = map_right[week_view->selection_start_day];
week_view->selection_end_day = week_view->selection_start_day;
- g_signal_emit_by_name (week_view, "selected_time_changed");
gtk_widget_queue_draw (week_view->main_canvas);
}
@@ -3500,9 +3554,9 @@ e_month_view_do_cursor_key_up (EWeekView *week_view)
if (week_view->selection_start_day < 7)
return;
+ g_signal_emit_by_name (week_view, "selected_time_changed");
week_view->selection_start_day -= 7;
week_view->selection_end_day = week_view->selection_start_day;
- g_signal_emit_by_name (week_view, "selected_time_changed");
gtk_widget_queue_draw (week_view->main_canvas);
}
@@ -3515,9 +3569,9 @@ e_month_view_do_cursor_key_down (EWeekView *week_view)
week_view->selection_start_day >= (weeks_shown - 1) * 7)
return;
+ g_signal_emit_by_name (week_view, "selected_time_changed");
week_view->selection_start_day += 7;
week_view->selection_end_day = week_view->selection_start_day;
- g_signal_emit_by_name (week_view, "selected_time_changed");
gtk_widget_queue_draw (week_view->main_canvas);
}
@@ -3527,9 +3581,9 @@ e_month_view_do_cursor_key_left (EWeekView *week_view)
if (week_view->selection_start_day <= 0)
return;
+ g_signal_emit_by_name (week_view, "selected_time_changed");
week_view->selection_start_day--;
week_view->selection_end_day = week_view->selection_start_day;
- g_signal_emit_by_name (week_view, "selected_time_changed");
gtk_widget_queue_draw (week_view->main_canvas);
}
@@ -3542,9 +3596,9 @@ e_month_view_do_cursor_key_right (EWeekView *week_view)
week_view->selection_start_day >= weeks_shown * 7 - 1)
return;
+ g_signal_emit_by_name (week_view, "selected_time_changed");
week_view->selection_start_day++;
week_view->selection_end_day = week_view->selection_start_day;
- g_signal_emit_by_name (week_view, "selected_time_changed");
gtk_widget_queue_draw (week_view->main_canvas);
}
@@ -3744,7 +3798,7 @@ e_week_view_do_key_press (GtkWidget *widget, GdkEventKey *event)
e_week_view_check_layout (week_view);
gtk_widget_queue_draw (week_view->main_canvas);
- if (e_week_view_find_event_from_uid (week_view, ecal, uid, NULL, &event_num)) {
+ if (e_week_view_find_event_from_uid (week_view, uid, &event_num)) {
EWeekViewEvent *event;
EWeekViewEventSpan *span;
@@ -3864,7 +3918,7 @@ e_week_view_key_press (GtkWidget *widget, GdkEventKey *event)
/* if not handled, try key bindings */
if (!handled)
- handled = GTK_WIDGET_CLASS (e_week_view_parent_class)->key_press_event (widget, event);
+ handled = GTK_WIDGET_CLASS (parent_class)->key_press_event (widget, event);
return handled;
}
@@ -3887,7 +3941,7 @@ e_week_view_show_popup_menu (EWeekView *week_view,
popup = e_calendar_view_create_popup_menu (E_CALENDAR_VIEW (week_view));
g_object_weak_ref (G_OBJECT (popup), popup_destroyed_cb, week_view);
- gtk_menu_popup (popup, NULL, NULL, NULL, NULL, bevent?bevent->button:0, bevent?bevent->time:gtk_get_current_event_time());
+ e_popup_menu (popup, (GdkEvent *) bevent);
}
static gboolean
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index 3a85a4a89f..1eecebf491 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -42,14 +42,11 @@
#include <libgnomeui/gnome-dialog.h>
#include <libgnomeui/gnome-dialog-util.h>
#include <bonobo/bonobo-exception.h>
-#include <libedataserver/e-categories.h>
-#include <libedataserver/e-url.h>
-#include "e-util/e-config-listener.h"
+#include "e-util/e-url.h"
#include "shell/e-user-creatable-items-handler.h"
#include <libecal/e-cal-time-util.h>
#include <gal/menus/gal-view-factory-etable.h>
#include <gal/menus/gal-view-etable.h>
-#include <gal/menus/gal-define-views-dialog.h>
#include "widgets/menus/gal-view-menus.h"
#include "widgets/misc/e-error.h"
#include "e-comp-editor-registry.h"
@@ -80,8 +77,6 @@
#include "misc.h"
#include "ea-calendar.h"
#include "common/authentication.h"
-#include "e-cal-popup.h"
-#include "e-cal-menu.h"
/* FIXME glib 2.4 and above has this */
#ifndef G_MAXINT32
@@ -97,8 +92,10 @@ struct _GnomeCalendarPrivate {
GHashTable *clients[E_CAL_SOURCE_TYPE_LAST];
GList *clients_list[E_CAL_SOURCE_TYPE_LAST];
ECal *default_client[E_CAL_SOURCE_TYPE_LAST];
-
- EConfigListener *config_listener;
+
+ /* Categories from the calendar clients */
+ /* FIXME are we getting all the categories? */
+ GPtrArray *categories[E_CAL_SOURCE_TYPE_LAST];
/*
* Fields for the calendar view
@@ -128,11 +125,7 @@ struct _GnomeCalendarPrivate {
/* Activity */
EActivityHandler *activity_handler;
-
- /* plugin menu managers */
- ECalMenu *calendar_menu;
- ECalMenu *taskpad_menu;
-
+
/* Calendar query for the date navigator */
GList *dn_queries; /* list of CalQueries */
char *sexp;
@@ -203,6 +196,8 @@ static guint gnome_calendar_signals[LAST_SIGNAL];
+static void gnome_calendar_class_init (GnomeCalendarClass *class);
+static void gnome_calendar_init (GnomeCalendar *gcal);
static void gnome_calendar_destroy (GtkObject *object);
static void gnome_calendar_goto_date (GnomeCalendar *gcal,
GnomeCalendarGotoDateType goto_date);
@@ -226,7 +221,14 @@ static void update_query (GnomeCalendar *gcal);
static void update_todo_view (GnomeCalendar *gcal);
-G_DEFINE_TYPE (GnomeCalendar, gnome_calendar, GTK_TYPE_VBOX);
+
+static GtkVBoxClass *parent_class;
+
+
+
+
+E_MAKE_TYPE (gnome_calendar, "GnomeCalendar", GnomeCalendar, gnome_calendar_class_init,
+ gnome_calendar_init, GTK_TYPE_VBOX);
/* Class initialization function for the gnome calendar */
static void
@@ -237,6 +239,8 @@ gnome_calendar_class_init (GnomeCalendarClass *class)
object_class = (GtkObjectClass *) class;
+ parent_class = g_type_class_peek_parent (class);
+
gnome_calendar_signals[DATES_SHOWN_CHANGED] =
gtk_signal_new ("dates_shown_changed",
GTK_RUN_LAST,
@@ -715,7 +719,7 @@ update_query (GnomeCalendar *gcal)
priv = gcal->priv;
- e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), _("Updating query"));
+ e_calendar_view_set_status_message (priv->week_view, _("Updating query"));
e_calendar_item_clear_marks (priv->date_navigator->calitem);
/* free the previous queries */
@@ -736,7 +740,7 @@ update_query (GnomeCalendar *gcal)
real_sexp = adjust_e_cal_view_sexp (gcal, priv->sexp);
if (!real_sexp) {
- e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), NULL);
+ e_calendar_view_set_status_message (priv->week_view, NULL);
return; /* No time range is set, so don't start a query */
}
@@ -767,9 +771,8 @@ update_query (GnomeCalendar *gcal)
e_cal_view_start (old_query);
}
- /* free memory */
g_free (real_sexp);
- e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), NULL);
+ e_calendar_view_set_status_message (priv->week_view, NULL);
update_todo_view (gcal);
}
@@ -1182,29 +1185,6 @@ month_view_adjustment_changed_cb (GtkAdjustment *adjustment, GnomeCalendar *gcal
}
static void
-config_categories_changed_cb (EConfigListener *config_listener, const char *key, gpointer user_data)
-{
- GList *cat_list;
- GPtrArray *cat_array;
- GnomeCalendarPrivate *priv;
- GnomeCalendar *gcal = user_data;
-
- priv = gcal->priv;
-
- cat_array = g_ptr_array_new ();
- cat_list = e_categories_get_list ();
- while (cat_list != NULL) {
- if (e_categories_is_searchable ((const char *) cat_list->data))
- g_ptr_array_add (cat_array, cat_list->data);
- cat_list = g_list_remove (cat_list, cat_list->data);
- }
-
- cal_search_bar_set_categories (priv->search_bar, cat_array);
-
- g_ptr_array_free (cat_array, TRUE);
-}
-
-static void
setup_widgets (GnomeCalendar *gcal)
{
GnomeCalendarPrivate *priv;
@@ -1221,7 +1201,6 @@ setup_widgets (GnomeCalendar *gcal)
G_CALLBACK (search_bar_sexp_changed_cb), gcal);
g_signal_connect (priv->search_bar, "category_changed",
G_CALLBACK (search_bar_category_changed_cb), gcal);
- config_categories_changed_cb (priv->config_listener, "/apps/evolution/general/category_master_list", gcal);
gtk_widget_show (priv->search_bar);
gtk_box_pack_start (GTK_BOX (gcal), priv->search_bar, FALSE, FALSE, 6);
@@ -1391,18 +1370,12 @@ gnome_calendar_init (GnomeCalendar *gcal)
for (i = 0; i < E_CAL_SOURCE_TYPE_LAST; i++)
priv->clients[i] = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
- priv->config_listener = e_config_listener_new ();
- g_signal_connect (priv->config_listener, "key_changed", G_CALLBACK (config_categories_changed_cb), gcal);
-
priv->current_view_type = GNOME_CAL_DAY_VIEW;
priv->range_selected = FALSE;
setup_config (gcal);
setup_widgets (gcal);
- priv->calendar_menu = e_cal_menu_new("org.gnome.evolution.calendar.view");
- priv->taskpad_menu = e_cal_menu_new("org.gnome.evolution.calendar.taskpad");
-
priv->dn_queries = NULL;
priv->sexp = g_strdup ("#t"); /* Match all */
priv->todo_sexp = g_strdup ("#t");
@@ -1414,6 +1387,21 @@ gnome_calendar_init (GnomeCalendar *gcal)
priv->visible_end = -1;
}
+/* Frees a set of categories */
+static void
+free_categories (GPtrArray *categories)
+{
+ int i;
+
+ if (!categories)
+ return;
+
+ for (i = 0; i < categories->len; i++)
+ g_free (categories->pdata[i]);
+
+ g_ptr_array_free (categories, TRUE);
+}
+
static void
gnome_calendar_destroy (GtkObject *object)
{
@@ -1430,16 +1418,7 @@ gnome_calendar_destroy (GtkObject *object)
if (priv) {
GList *l;
int i;
-
- /* unset the config listener */
- if (priv->config_listener) {
- g_signal_handlers_disconnect_matched (priv->config_listener,
- G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, gcal);
- g_object_unref (priv->config_listener);
- priv->config_listener = NULL;
- }
-
+
/* Clean up the clients */
for (i = 0; i < E_CAL_SOURCE_TYPE_LAST; i++) {
for (l = priv->clients_list[i]; l != NULL; l = l->next) {
@@ -1461,6 +1440,11 @@ gnome_calendar_destroy (GtkObject *object)
}
priv->default_client[i] = NULL;
}
+
+ for (i = 0; i < E_CAL_SOURCE_TYPE_LAST; i++) {
+ free_categories (priv->categories[i]);
+ priv->categories[i] = NULL;
+ }
for (i = 0; i < GNOME_CAL_LAST_VIEW; i++) {
if (priv->configs[i])
@@ -1517,22 +1501,12 @@ gnome_calendar_destroy (GtkObject *object)
priv->view_menus = NULL;
}
- if (priv->calendar_menu) {
- g_object_unref (priv->calendar_menu);
- priv->calendar_menu = NULL;
- }
-
- if (priv->taskpad_menu) {
- g_object_unref (priv->taskpad_menu);
- priv->taskpad_menu = NULL;
- }
-
g_free (priv);
gcal->priv = NULL;
}
- if (GTK_OBJECT_CLASS (gnome_calendar_parent_class)->destroy)
- (* GTK_OBJECT_CLASS (gnome_calendar_parent_class)->destroy) (object);
+ if (GTK_OBJECT_CLASS (parent_class)->destroy)
+ (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
static void
@@ -2014,137 +1988,36 @@ gnome_calendar_discard_view_menus (GnomeCalendar *gcal)
priv->view_menus = NULL;
}
-/* This is copied/moved from gal-view-instance, only the calendar uses this for a popup menu */
-static void
-gc_set_view(EPopup *ep, EPopupItem *pitem, void *data)
-{
- GnomeCalendar *gcal = data;
-
- if (pitem->type & E_POPUP_ACTIVE)
- gal_view_instance_set_current_view_id(gcal->priv->view_instance, (char *)pitem->user_data);
-}
-
-static void
-gc_save_custom_view(EPopup *ep, EPopupItem *pitem, void *data)
-{
- GnomeCalendar *gcal = data;
-
- gal_view_instance_save_as(gcal->priv->view_instance);
-}
-
-static void
-gc_define_views_response(GtkWidget *d, int id, GnomeCalendar *gcal)
+EPopupMenu *
+gnome_calendar_setup_view_popup (GnomeCalendar *gcal)
{
- if (id == GTK_RESPONSE_OK)
- gal_view_collection_save(gcal->priv->view_instance->collection);
-
- gtk_widget_destroy(d);
-}
-
-static void
-gc_define_views(EPopup *ep, EPopupItem *pitem, void *data)
-{
- GnomeCalendar *gcal = data;
- GtkWidget *dialog = gal_define_views_dialog_new(gcal->priv->view_instance->collection);
-
- g_signal_connect(dialog, "response", G_CALLBACK(gc_define_views_response), data);
- gtk_widget_show(dialog);
-}
+ GnomeCalendarPrivate *priv;
-static EPopupItem gc_popups[] = {
- /* Code generates the path to fit */
- { E_POPUP_BAR, NULL },
- { E_POPUP_RADIO|E_POPUP_ACTIVE, NULL, N_("Custom View"), },
- { E_POPUP_ITEM, NULL, N_("Save Custom View"), gc_save_custom_view },
+ g_return_val_if_fail (gcal != NULL, NULL);
+ g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), NULL);
- /* index == 3, when we have non-custom view */
+ priv = gcal->priv;
- { E_POPUP_BAR, NULL },
- { E_POPUP_ITEM, NULL, N_("Define Views..."), gc_define_views },
-};
+ g_return_val_if_fail (priv->view_instance != NULL, NULL);
-static void
-gc_popup_free (EPopup *ep, GSList *list, void *data)
-{
- while (list) {
- GSList *n = list->next;
- EPopupItem *pitem = list->data;
-
- g_free(pitem->path);
- g_free(pitem->label);
- g_free(pitem->user_data);
- g_free(pitem);
- g_slist_free_1(list);
- list = n;
- }
+ return gal_view_instance_get_popup_menu (priv->view_instance);
}
-static void
-gc_popup_free_static (EPopup *ep, GSList *list, void *data)
+void
+gnome_calendar_discard_view_popup (GnomeCalendar *gcal, EPopupMenu *popup)
{
- while (list) {
- GSList *n = list->next;
- EPopupItem *pitem = list->data;
- g_free(pitem->path);
- g_free(pitem);
- g_slist_free_1(list);
- list = n;
- }
-}
-void
-gnome_calendar_view_popup_factory (GnomeCalendar *gcal, EPopup *ep, const char *prefix)
-{
GnomeCalendarPrivate *priv;
- int length;
- int i;
- gboolean found = FALSE;
- char *id;
- GSList *menus = NULL;
- EPopupItem *pitem;
g_return_if_fail (gcal != NULL);
g_return_if_fail (GNOME_IS_CALENDAR (gcal));
- g_return_if_fail (prefix != NULL);
priv = gcal->priv;
g_return_if_fail (priv->view_instance != NULL);
- length = gal_view_collection_get_count(priv->view_instance->collection);
- id = gal_view_instance_get_current_view_id (priv->view_instance);
-
- for (i = 0; i < length; i++) {
- GalViewCollectionItem *item = gal_view_collection_get_view_item(priv->view_instance->collection, i);
-
- pitem = g_malloc0(sizeof(*pitem));
- pitem->type = E_POPUP_RADIO;
- pitem->path = g_strdup_printf("%s/%02d.item", prefix, i);
- pitem->label = g_strdup(item->title);
- pitem->activate = gc_set_view;
- pitem->user_data = g_strdup(item->id);
-
- if (!found && id && !strcmp (id, item->id)) {
- found = TRUE;
- pitem->type |= E_POPUP_ACTIVE;
- }
-
- menus = g_slist_prepend(menus, pitem);
- }
-
- if (menus)
- e_popup_add_items(ep, menus, NULL, gc_popup_free, gcal);
-
- menus = NULL;
- for (i = found?3:0; i<sizeof(gc_popups)/sizeof(gc_popups[0]);i++) {
- pitem = g_malloc0(sizeof(*pitem));
- memcpy(pitem, &gc_popups[i], sizeof(*pitem));
- pitem->path = g_strdup_printf("%s/%02d.item", prefix, i+length);
- menus = g_slist_prepend(menus, pitem);
- }
-
- e_popup_add_items(ep, menus, NULL, gc_popup_free_static, gcal);
+ gal_view_instance_free_popup_menu (priv->view_instance, popup);
}
static void
@@ -2163,6 +2036,22 @@ gnome_calendar_set_pane_positions (GnomeCalendar *gcal)
}
}
+/* Duplicates an array of categories */
+static GPtrArray *
+copy_categories (GPtrArray *categories)
+{
+ GPtrArray *c;
+ int i;
+
+ c = g_ptr_array_new ();
+ g_ptr_array_set_size (c, categories->len);
+
+ for (i = 0; i < categories->len; i++)
+ c->pdata[i] = g_strdup (categories->pdata[i]);
+
+ return c;
+}
+
static void
client_cal_opened_cb (ECal *ecal, ECalendarStatus status, GnomeCalendar *gcal)
{
@@ -2177,39 +2066,24 @@ client_cal_opened_cb (ECal *ecal, ECalendarStatus status, GnomeCalendar *gcal)
source_type = e_cal_get_source_type (ecal);
source = e_cal_get_source (ecal);
- switch (source_type) {
- case E_CAL_SOURCE_TYPE_EVENT:
- e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), NULL);
- break;
- case E_CAL_SOURCE_TYPE_TODO:
+ if (source_type == E_CAL_SOURCE_TYPE_EVENT)
+ e_calendar_view_set_status_message (priv->week_view, NULL);
+ else
e_calendar_table_set_status_message (E_CALENDAR_TABLE (priv->todo), NULL);
- break;
- default:
- break;
- }
- switch (status) {
- case E_CALENDAR_STATUS_OK:
- break;
- case E_CALENDAR_STATUS_BUSY:
+
+ if (status == E_CALENDAR_STATUS_BUSY)
return;
- case E_CALENDAR_STATUS_INVALID_SERVER_VERSION:
- e_error_run (NULL, "calendar:server-version", NULL);
- status = E_CALENDAR_STATUS_OK;
- break;
- case E_CALENDAR_STATUS_REPOSITORY_OFFLINE:
- if (source_type == E_CAL_SOURCE_TYPE_EVENT)
- e_error_run (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (gcal))),
- "calendar:prompt-no-contents-offline-calendar", NULL);
- default:
+ if (status != E_CALENDAR_STATUS_OK) {
/* Make sure the source doesn't disappear on us */
g_object_ref (source);
-
+
priv->clients_list[source_type] = g_list_remove (priv->clients_list[source_type], ecal);
g_hash_table_remove (priv->clients[source_type], e_source_peek_uid (source));
gtk_signal_emit (GTK_OBJECT (gcal), gnome_calendar_signals[SOURCE_REMOVED], source_type, source);
+
g_object_unref (source);
-
+
return;
}
@@ -2220,7 +2094,7 @@ client_cal_opened_cb (ECal *ecal, ECalendarStatus status, GnomeCalendar *gcal)
switch (source_type) {
case E_CAL_SOURCE_TYPE_EVENT :
msg = g_strdup_printf (_("Loading appointments at %s"), e_cal_get_uri (ecal));
- e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), msg);
+ e_calendar_view_set_status_message (priv->week_view, msg);
g_free (msg);
/* add client to the views */
@@ -2234,7 +2108,7 @@ client_cal_opened_cb (ECal *ecal, ECalendarStatus status, GnomeCalendar *gcal)
/* update date navigator query */
update_query (gcal);
- e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), NULL);
+ e_calendar_view_set_status_message (priv->week_view, NULL);
break;
case E_CAL_SOURCE_TYPE_TODO :
@@ -2268,7 +2142,7 @@ default_client_cal_opened_cb (ECal *ecal, ECalendarStatus status, GnomeCalendar
switch (source_type) {
case E_CAL_SOURCE_TYPE_EVENT:
- e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), NULL);
+ e_calendar_view_set_status_message (priv->week_view, NULL);
break;
case E_CAL_SOURCE_TYPE_TODO:
e_calendar_table_set_status_message (E_CALENDAR_TABLE (priv->todo), NULL);
@@ -2277,18 +2151,13 @@ default_client_cal_opened_cb (ECal *ecal, ECalendarStatus status, GnomeCalendar
break;
}
- switch (status) {
- case E_CALENDAR_STATUS_OK:
- break;
- case E_CALENDAR_STATUS_BUSY:
+ if (status == E_CALENDAR_STATUS_BUSY)
return;
- case E_CALENDAR_STATUS_INVALID_SERVER_VERSION :
- e_error_run (NULL, "calendar:server-version", NULL);
- status = E_CALENDAR_STATUS_OK;
- default:
+
+ if (status != E_CALENDAR_STATUS_OK) {
/* Make sure the source doesn't disappear on us */
g_object_ref (source);
-
+
/* FIXME should we do this to prevent multiple error dialogs? */
priv->clients_list[source_type] = g_list_remove (priv->clients_list[source_type], ecal);
g_hash_table_remove (priv->clients[source_type], e_source_peek_uid (source));
@@ -2296,10 +2165,11 @@ default_client_cal_opened_cb (ECal *ecal, ECalendarStatus status, GnomeCalendar
/* FIXME Is there a better way to handle this? */
g_object_unref (priv->default_client[source_type]);
priv->default_client[source_type] = NULL;
-
+
gtk_signal_emit (GTK_OBJECT (gcal), gnome_calendar_signals[SOURCE_REMOVED], source_type, source);
+
g_object_unref (source);
-
+
return;
}
@@ -2338,7 +2208,7 @@ open_ecal (GnomeCalendar *gcal, ECal *cal, gboolean only_if_exists, open_func of
msg = g_strdup_printf (_("Opening %s"), e_cal_get_uri (cal));
switch (e_cal_get_source_type (cal)) {
case E_CAL_SOURCE_TYPE_EVENT :
- e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), msg);
+ e_calendar_view_set_status_message (priv->week_view, msg);
break;
case E_CAL_SOURCE_TYPE_TODO :
e_calendar_table_set_status_message (E_CALENDAR_TABLE (priv->todo), msg);
@@ -2356,6 +2226,83 @@ open_ecal (GnomeCalendar *gcal, ECal *cal, gboolean only_if_exists, open_func of
return TRUE;
}
+/* Adds the categories from an array to a hash table if they don't exist there
+ * already.
+ */
+static void
+add_categories (GHashTable *categories, GPtrArray *c)
+{
+ int i;
+
+ if (!c)
+ return;
+
+ for (i = 0; i < c->len; i++) {
+ const char *cat;
+ const char *str;
+
+ cat = c->pdata[i];
+ str = g_hash_table_lookup (categories, cat);
+
+ if (!str)
+ g_hash_table_insert (categories, (char *) cat, NULL);
+ }
+}
+
+/* Appends a category from the hash table to the array */
+static void
+append_category_cb (gpointer key, gpointer value, gpointer data)
+{
+ GPtrArray *c;
+ const char *category;
+
+ category = key;
+ c = data;
+
+ g_ptr_array_set_size (c, c->len + 1);
+ c->pdata[c->len - 1] = g_strdup (category);
+
+}
+
+/* Callback from the calendar client when the set of categories changes. We
+ * have to merge the categories of the calendar and tasks clients.
+ */
+static void
+client_categories_changed_cb (ECal *ecal, GPtrArray *categories, gpointer data)
+{
+ GnomeCalendar *gcal;
+ GnomeCalendarPrivate *priv;
+ ECalSourceType source_type;
+ GHashTable *cat_hash;
+ GPtrArray *merged;
+ int i;
+
+ gcal = GNOME_CALENDAR (data);
+ priv = gcal->priv;
+
+ source_type = e_cal_get_source_type (ecal);
+
+ free_categories (priv->categories[source_type]);
+ priv->categories[source_type] = copy_categories (categories);
+
+ /* Build a non-duplicate list of the categories */
+ cat_hash = g_hash_table_new (g_str_hash, g_str_equal);
+ for (i = 0; i < E_CAL_SOURCE_TYPE_LAST; i++) {
+ add_categories (cat_hash, priv->categories[i]);
+ }
+
+ /* Build the pointer array */
+ /* We size it maximally and then to 0 to pre-allocate memory */
+ merged = g_ptr_array_sized_new (g_hash_table_size (cat_hash));
+ g_ptr_array_set_size (merged, 0);
+
+ g_hash_table_foreach (cat_hash, append_category_cb, merged);
+ g_hash_table_destroy (cat_hash);
+
+ cal_search_bar_set_categories (CAL_SEARCH_BAR (priv->search_bar), merged);
+ free_categories (merged);
+}
+
/* Callback when we get an error message from the backend */
static void
backend_error_cb (ECal *client, const char *message, gpointer data)
@@ -2384,6 +2331,7 @@ backend_died_cb (ECal *ecal, gpointer data)
ECalSourceType source_type;
ESource *source;
const char *id;
+ int i;
gcal = GNOME_CALENDAR (data);
priv = gcal->priv;
@@ -2401,7 +2349,7 @@ backend_died_cb (ECal *ecal, gpointer data)
case E_CAL_SOURCE_TYPE_EVENT:
id = "calendar:calendar-crashed";
- e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), NULL);
+ e_calendar_view_set_status_message (priv->week_view, NULL);
gtk_signal_emit (GTK_OBJECT (gcal), gnome_calendar_signals[SOURCE_REMOVED], source_type, source);
break;
@@ -2566,6 +2514,7 @@ gnome_calendar_add_source (GnomeCalendar *gcal, ECalSourceType source_type, ESou
}
g_signal_connect (G_OBJECT (client), "backend_error", G_CALLBACK (backend_error_cb), gcal);
+ g_signal_connect (G_OBJECT (client), "categories_changed", G_CALLBACK (client_categories_changed_cb), gcal);
g_signal_connect (G_OBJECT (client), "backend_died", G_CALLBACK (backend_died_cb), gcal);
/* add the client to internal structure */
@@ -2775,7 +2724,7 @@ gnome_calendar_new_task (GnomeCalendar *gcal)
if (!ecal)
return;
- tedit = task_editor_new (ecal, FALSE);
+ tedit = task_editor_new (ecal);
icalcomp = e_cal_model_create_component_with_defaults (model);
comp = e_cal_component_new ();
@@ -3298,17 +3247,3 @@ gnome_calendar_get_view_notebook_widget (GnomeCalendar *gcal)
return GTK_WIDGET(gcal->priv->notebook);
}
-
-ECalMenu *gnome_calendar_get_taskpad_menu (GnomeCalendar *gcal)
-{
- g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), NULL);
-
- return gcal->priv->taskpad_menu;
-}
-
-ECalMenu *gnome_calendar_get_calendar_menu (GnomeCalendar *gcal)
-{
- g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), NULL);
-
- return gcal->priv->calendar_menu;
-}
diff --git a/calendar/gui/itip-utils.c b/calendar/gui/itip-utils.c
index 5b5091206b..b7309a21e8 100644
--- a/calendar/gui/itip-utils.c
+++ b/calendar/gui/itip-utils.c
@@ -30,6 +30,7 @@
#include <libgnome/gnome-i18n.h>
#include <gtk/gtkmessagedialog.h>
#include <gtk/gtkwidget.h>
+#include <gal/util/e-util.h>
#include <libical/ical.h>
#include <Evolution-Composer.h>
#include <e-util/e-dialog-utils.h>
@@ -42,7 +43,6 @@
#include "e-util/e-passwords.h"
#include "calendar-config.h"
#include "itip-utils.h"
-#include "dialogs/cal-attachment.h"
#define GNOME_EVOLUTION_COMPOSER_OAFIID "OAFIID:GNOME_Evolution_Mail_Composer:" BASE_VERSION
@@ -824,64 +824,9 @@ comp_compliant (ECalComponentItipMethod method, ECalComponent *comp, ECal *clien
return clone;
}
-static gboolean
-append_cal_attachments (GNOME_Evolution_Composer composer_server, ECalComponent
- *comp, GSList *attach_list)
-{
- CORBA_char *content_type = NULL, *filename = NULL, *description = NULL;
- CORBA_Environment ev;
- GNOME_Evolution_Composer_AttachmentData *attach_data = NULL;
- struct CalMimeAttach *mime_attach;
- GSList *l;
- gboolean retval = TRUE;
-
- CORBA_exception_init (&ev);
-
- for (l = attach_list; l ; l = l->next) {
- mime_attach = (struct CalMimeAttach *) l->data;
-
- filename = CORBA_string_dup (mime_attach->filename);
- content_type = CORBA_string_dup (mime_attach->content_type);
- description = CORBA_string_dup (mime_attach->description);
-
- attach_data = GNOME_Evolution_Composer_AttachmentData__alloc ();
- attach_data->_length = mime_attach->length;
- attach_data->_maximum = attach_data->_length;
- attach_data->_buffer = CORBA_sequence_CORBA_char_allocbuf (attach_data->_length);
- memcpy (attach_data->_buffer, mime_attach->encoded_data, attach_data->_length);
-
- GNOME_Evolution_Composer_attachData (composer_server,
- content_type, filename, description,
- TRUE, attach_data,
- &ev);
- if (BONOBO_EX (&ev)) {
- g_warning ("Unable to add attachments in composer");
- retval = FALSE;
- }
-
- CORBA_exception_free (&ev);
- if (content_type != NULL)
- CORBA_free (content_type);
- if (filename != NULL)
- CORBA_free (filename);
- if (description != NULL)
- CORBA_free (description);
- if (attach_data != NULL) {
- CORBA_free (attach_data->_buffer);
- CORBA_free (attach_data);
- }
- g_free (mime_attach->filename);
- g_free (mime_attach->content_type);
- g_free (mime_attach->description);
- g_free (mime_attach->encoded_data);
- }
-
- return retval;
-}
-
gboolean
itip_send_comp (ECalComponentItipMethod method, ECalComponent *send_comp,
- ECal *client, icalcomponent *zones, GSList *attachments_list)
+ ECal *client, icalcomponent *zones)
{
GNOME_Evolution_Composer composer_server;
ECalComponent *comp = NULL;
@@ -918,10 +863,6 @@ itip_send_comp (ECalComponentItipMethod method, ECalComponent *send_comp,
retval = TRUE;
goto cleanup;
}
- } else if (to_list == NULL || to_list->_length == 0) {
- /* if we don't have recipients, return */
- retval = FALSE;
- goto cleanup;
}
cc_list = GNOME_Evolution_Composer_RecipientList__alloc ();
@@ -992,12 +933,7 @@ itip_send_comp (ECalComponentItipMethod method, ECalComponent *send_comp,
g_warning ("Unable to place iTip message in composer");
goto cleanup;
}
-
- if (attachments_list) {
- if (append_cal_attachments (composer_server, comp, attachments_list))
- retval = TRUE;
- }
-
+
if (method == E_CAL_COMPONENT_METHOD_PUBLISH) {
GNOME_Evolution_Composer_show (composer_server, &ev);
if (BONOBO_EX (&ev))
@@ -1020,11 +956,6 @@ itip_send_comp (ECalComponentItipMethod method, ECalComponent *send_comp,
if (top_level != NULL)
icalcomponent_free (top_level);
- if (users) {
- g_list_foreach (users, (GFunc) g_free, NULL);
- g_list_free (users);
- }
-
if (to_list != NULL)
CORBA_free (to_list);
if (cc_list != NULL)
@@ -1207,6 +1138,8 @@ itip_publish_comp (ECal *client, gchar *uri, gchar *username,
SoupMessage *msg;
SoupUri *real_uri;
char *ical_string;
+ char *prompt;
+ gboolean remember = FALSE;
toplevel = e_cal_util_new_top_level ();
icalcomponent_set_method (toplevel, ICAL_METHOD_PUBLISH);
diff --git a/calendar/gui/migration.c b/calendar/gui/migration.c
index fb8f0b2f8c..1764c2f6e1 100644
--- a/calendar/gui/migration.c
+++ b/calendar/gui/migration.c
@@ -40,6 +40,7 @@
#include <gtk/gtkmain.h>
#include <gtk/gtklabel.h>
#include <gtk/gtkprogressbar.h>
+#include <gal/util/e-util.h>
#include <libecal/e-cal.h>
#include <e-util/e-bconf-map.h>
#include <e-util/e-folder-map.h>
@@ -47,7 +48,6 @@
#include <libedataserver/e-xml-hash-utils.h>
#include "calendar-config.h"
#include "calendar-config-keys.h"
-#include "e-cal-event.h"
#include "migration.h"
static e_gconf_map_t calendar_display_map[] = {
@@ -708,8 +708,6 @@ migrate_calendars (CalendarComponent *component, int major, int minor, int revis
{
ESourceGroup *on_this_computer = NULL, *on_the_web = NULL, *contacts = NULL;
ESource *personal_source = NULL;
- ECalEvent *ece;
- ECalEventTargetComponent *target;
gboolean retval = FALSE;
/* we call this unconditionally now - create_groups either
@@ -843,21 +841,6 @@ migrate_calendars (CalendarComponent *component, int major, int minor, int revis
}
e_source_list_sync (calendar_component_peek_source_list (component), NULL);
-
- /** @Event: component.migration
- * @Title: Migration step in component initialization
- * @Target: ECalEventTargetComponent
- *
- * component.migration is emitted during the calendar component
- * initialization process. This allows new calendar backend types
- * to be distributed as an e-d-s backend and a plugin without
- * reaching their grubby little fingers into migration.c
- */
- /* Fire off migration event */
- ece = e_cal_event_peek ();
- target = e_cal_event_target_new_component (ece, calendar_component_peek (), 0);
- e_event_emit ((EEvent *) ece, "component.migration", (EEventTarget *) target);
-
retval = TRUE;
fail:
if (on_this_computer)
diff --git a/calendar/gui/print.c b/calendar/gui/print.c
index 9991f2e7cc..68dcd8cba8 100644
--- a/calendar/gui/print.c
+++ b/calendar/gui/print.c
@@ -22,10 +22,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*/
-#ifdef HAVE_CONFIG_H
#include <config.h>
-#endif
-
#include <sys/stat.h>
#include <sys/time.h>
#include <math.h>
@@ -47,7 +44,6 @@
#include <gal/util/e-util.h>
#include <e-util/e-dialog-widgets.h>
#include <e-util/e-time-utils.h>
-#include <e-util/e-print.h>
#include <libecal/e-cal-time-util.h>
#include "calendar-commands.h"
#include "calendar-config.h"
@@ -70,7 +66,6 @@
* gnome-print keys, but it's commented out. The corresponding code here
* doesn't seem to work either (getting zero margins), so we adopt
* gtkhtml's cheat. */
-
#define TEMP_MARGIN .05
/* The fonts to use */
@@ -177,6 +172,8 @@ struct einfo
int count;
};
+static GnomePrintConfig *print_config = NULL;
+
/* Convenience function to help the transition to timezone functions.
It converts a time_t to a struct tm. */
static struct tm*
@@ -2459,34 +2456,28 @@ void
print_calendar (GnomeCalendar *gcal, gboolean preview, time_t date,
PrintView default_view)
{
- GnomePrintConfig *print_config;
GnomePrintJob *gpm;
GnomePrintContext *pc;
+ int copies, collate;
double l, r, t, b;
- char *old_orientation;
-
+
g_return_if_fail (gcal != NULL);
g_return_if_fail (GNOME_IS_CALENDAR (gcal));
- print_config = e_print_load_config ();
+ if (!print_config)
+ print_config = gnome_print_config_default ();
- /* Don't save the orientation if we guessed it to be nice to the user */
- old_orientation = gnome_print_config_get (print_config, GNOME_PRINT_KEY_PAGE_ORIENTATION);
- if (default_view == PRINT_VIEW_MONTH) {
- if (old_orientation && !strcmp (old_orientation, "R90")) {
- g_free (old_orientation);
- old_orientation = NULL;
- }
-
- gnome_print_config_set (print_config, GNOME_PRINT_KEY_PAGE_ORIENTATION, "R90");
- }
+ copies = 1;
+ collate = FALSE;
+
+ gpm = gnome_print_job_new (print_config);
if (!preview) {
GtkWidget *gpd;
GtkWidget *range;
int view;
- gpd = e_print_get_dialog_with_config (_("Print"), GNOME_PRINT_DIALOG_COPIES | GNOME_PRINT_DIALOG_RANGE, print_config);
+ gpd = gnome_print_dialog_new (gpm, _("Print"), 0);
view = (int) default_view;
range = range_selector_new (gpd, date, &view);
@@ -2519,7 +2510,10 @@ print_calendar (GnomeCalendar *gcal, gboolean preview, time_t date,
gtk_widget_destroy (gpd);
}
- gpm = gnome_print_job_new (print_config);
+ if (default_view == PRINT_VIEW_MONTH)
+ gnome_print_config_set (print_config, GNOME_PRINT_KEY_PAGE_ORIENTATION, "R90");
+ else
+ gnome_print_config_set (print_config, GNOME_PRINT_KEY_PAGE_ORIENTATION, "R0");
pc = gnome_print_job_get_context (gpm);
gnome_print_config_get_page_size (print_config, &r, &t);
@@ -2533,7 +2527,7 @@ print_calendar (GnomeCalendar *gcal, gboolean preview, time_t date,
* gnome_print_config_get_double (print_config, GNOME_PRINT_KEY_PAGE_MARGIN_BOTTOM, &b);
* gnome_print_config_get_double (print_config, GNOME_PRINT_KEY_PAGE_MARGIN_LEFT, &l);
* b = l = TEMP_MARGIN; */
-
+
b = t * TEMP_MARGIN;
l = r * TEMP_MARGIN;
t *= (1.0 - TEMP_MARGIN);
@@ -2568,15 +2562,6 @@ print_calendar (GnomeCalendar *gcal, gboolean preview, time_t date,
gnome_print_job_print (gpm);
}
- /* Don't save the orientation if we guessed it to be nice to the user */
- if (old_orientation) {
- gnome_print_config_set (print_config, GNOME_PRINT_KEY_PAGE_ORIENTATION, old_orientation);
-
- e_print_save_config (print_config);
- g_free (old_orientation);
- }
-
- g_object_unref (print_config);
g_object_unref (gpm);
}
@@ -2584,20 +2569,29 @@ print_calendar (GnomeCalendar *gcal, gboolean preview, time_t date,
void
print_comp (ECalComponent *comp, ECal *client, gboolean preview)
{
- GnomePrintConfig *print_config;
GnomePrintJob *gpm;
GnomePrintContext *pc;
+ int copies, collate;
double l, r, t, b;
g_return_if_fail (comp != NULL);
g_return_if_fail (E_IS_CAL_COMPONENT (comp));
- print_config = e_print_load_config ();
+ if (!print_config)
+ print_config = gnome_print_config_default ();
+
+ gnome_print_config_set (print_config, GNOME_PRINT_KEY_PAGE_ORIENTATION, "R0");
+
+ copies = 1;
+ collate = FALSE;
+
+ gpm = gnome_print_job_new (print_config);
if (!preview) {
GtkWidget *gpd;
- gpd = e_print_get_dialog_with_config (_("Print Item"), GNOME_PRINT_DIALOG_COPIES, print_config);
+ gpd = gnome_print_dialog_new (gpm, _("Print Item"),
+ GNOME_PRINT_DIALOG_COPIES);
gtk_dialog_set_default_response (GTK_DIALOG (gpd),
GNOME_PRINT_DIALOG_RESPONSE_PRINT);
@@ -2624,8 +2618,6 @@ print_comp (ECalComponent *comp, ECal *client, gboolean preview)
gtk_widget_destroy (gpd);
}
- gpm = gnome_print_job_new (print_config);
-
pc = gnome_print_job_get_context (gpm);
gnome_print_config_get_page_size (print_config, &r, &t);
@@ -2656,7 +2648,6 @@ print_comp (ECalComponent *comp, ECal *client, gboolean preview)
gnome_print_job_print (gpm);
}
- g_object_unref (print_config);
g_object_unref (gpm);
}
@@ -2683,60 +2674,27 @@ print_title (GnomePrintContext *pc, const char *title,
}
void
-print_table (ETable *etable, const char *dialog_title, const char *print_header, gboolean preview)
+print_table (ETable *etable, const char *title, gboolean preview)
{
EPrintable *printable;
- GnomePrintConfig *print_config;
GnomePrintContext *pc;
GnomePrintJob *gpm;
double l, r, t, b, page_width, page_height, left_margin, bottom_margin;
- print_config = e_print_load_config ();
+ if (!print_config)
+ print_config = gnome_print_config_default ();
+ gnome_print_config_set (print_config, GNOME_PRINT_KEY_PAGE_ORIENTATION, "R0");
printable = e_table_get_printable (etable);
g_object_ref (printable);
gtk_object_sink (GTK_OBJECT (printable));
e_printable_reset (printable);
- if (!preview) {
- GtkWidget *gpd;
-
- gpd = e_print_get_dialog_with_config (dialog_title, GNOME_PRINT_DIALOG_COPIES, print_config);
-
- gtk_dialog_set_default_response (GTK_DIALOG (gpd),
- GNOME_PRINT_DIALOG_RESPONSE_PRINT);
-
- /* Run dialog */
-
- switch (gtk_dialog_run (GTK_DIALOG (gpd))) {
- case GNOME_PRINT_DIALOG_RESPONSE_PRINT:
- break;
-
- case GNOME_PRINT_DIALOG_RESPONSE_PREVIEW:
- preview = TRUE;
- break;
-
- case -1:
- return;
-
- default:
- gtk_widget_destroy (gpd);
- return;
- }
-
- e_dialog_get_values (gpd);
-
- gtk_widget_destroy (gpd);
- }
-
gpm = gnome_print_job_new (print_config);
-
pc = gnome_print_job_get_context (gpm);
gnome_print_config_get_page_size (print_config, &r, &t);
- /* See top of source for an explanation of this */
-
#if 0
gnome_print_config_get_double (print_config, GNOME_PRINT_KEY_PAGE_MARGIN_TOP, &temp_d);
t -= temp_d;
@@ -2762,7 +2720,7 @@ print_table (ETable *etable, const char *dialog_title, const char *print_header,
gnome_print_translate (pc, left_margin, bottom_margin);
- print_title (pc, print_header, page_width, page_height);
+ print_title (pc, title, page_width, page_height);
if (e_printable_data_left (printable))
e_printable_print_page (printable, pc,
@@ -2782,7 +2740,40 @@ print_table (ETable *etable, const char *dialog_title, const char *print_header,
gnome_print_job_print (gpm);
}
- g_object_unref (print_config);
g_object_unref (gpm);
g_object_unref (printable);
}
+
+void
+print_setup (void)
+{
+ GtkWidget *ps;
+
+ if (!print_config)
+ print_config = gnome_print_config_default ();
+
+ ps = gnome_paper_selector_new (print_config);
+ gtk_widget_show (ps);
+
+#if 0
+ dlg = gtk_dialog_new_with_buttons (_("Print Setup"),
+ NULL, /* FIXME: Set a sensible parent */
+ 0,
+ GNOME_STOCK_BUTTON_OK,
+ GNOME_STOCK_BUTTON_CANCEL,
+ NULL);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), ps, TRUE, TRUE, 2);
+
+ btn = gtk_dialog_run (GTK_DIALOG (dlg));
+ if (btn == 0) {
+ gchar *name;
+
+ print_config = gnome_paper_selector_get_config (ps);
+
+ name = gnome_paper_selector_get_name (GNOME_PAPER_SELECTOR (ps));
+ paper_info = gnome_paper_with_name (name);
+ }
+
+ gtk_widget_destroy (dlg);
+#endif
+}
diff --git a/calendar/gui/tasks-component.c b/calendar/gui/tasks-component.c
index 60ac1cd868..a817ca8546 100644
--- a/calendar/gui/tasks-component.c
+++ b/calendar/gui/tasks-component.c
@@ -31,7 +31,6 @@
#include <bonobo/bonobo-exception.h>
#include <gconf/gconf-client.h>
#include <libecal/e-cal.h>
-#include <libedataserverui/e-source-selector.h>
#include <shell/e-user-creatable-items-handler.h>
#include "e-cal-model.h"
#include "e-tasks.h"
@@ -41,14 +40,13 @@
#include "migration.h"
#include "comp-util.h"
#include "calendar-config.h"
-#include "e-cal-popup.h"
#include "common/authentication.h"
#include "dialogs/calendar-setup.h"
#include "dialogs/comp-editor.h"
#include "dialogs/copy-source-dialog.h"
#include "dialogs/task-editor.h"
+#include "widgets/misc/e-source-selector.h"
#include "widgets/misc/e-info-label.h"
-#include "widgets/misc/e-error.h"
#include "e-util/e-icon-factory.h"
#define CREATE_TASK_ID "task"
@@ -254,118 +252,137 @@ update_primary_selection (TasksComponentView *component_view)
/* Callbacks. */
static void
-copy_task_list_cb (EPopup *ep, EPopupItem *pitem, void *data)
+add_popup_menu_item (GtkMenu *menu, const char *label, const char *icon_name,
+ GCallback callback, gpointer user_data, gboolean sensitive)
+{
+ GtkWidget *item, *image;
+ GdkPixbuf *pixbuf;
+
+ if (icon_name) {
+ item = gtk_image_menu_item_new_with_label (label);
+
+ /* load the image */
+ pixbuf = e_icon_factory_get_icon (icon_name, E_ICON_SIZE_MENU);
+ image = gtk_image_new_from_pixbuf (pixbuf);
+
+ if (image) {
+ gtk_widget_show (image);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
+ }
+ } else {
+ item = gtk_menu_item_new_with_label (label);
+ }
+
+ if (callback)
+ g_signal_connect (G_OBJECT (item), "activate", callback, user_data);
+
+ if (!sensitive)
+ gtk_widget_set_sensitive (item, FALSE);
+
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+ gtk_widget_show (item);
+}
+
+static void
+copy_task_list_cb (GtkWidget *widget, TasksComponentView *component_view)
{
- TasksComponentView *component_view = data;
ESource *selected_source;
selected_source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (component_view->source_selector));
if (!selected_source)
return;
- copy_source_dialog (GTK_WINDOW (gtk_widget_get_toplevel(ep->target->widget)), selected_source, E_CAL_SOURCE_TYPE_TODO);
+ copy_source_dialog (GTK_WINDOW (gtk_widget_get_toplevel (widget)), selected_source, E_CAL_SOURCE_TYPE_TODO);
}
static void
-delete_task_list_cb (EPopup *ep, EPopupItem *pitem, void *data)
+delete_task_list_cb (GtkWidget *widget, TasksComponentView *component_view)
{
- TasksComponentView *component_view = data;
ESource *selected_source;
- ECal *cal;
- char *uri;
+ GtkWidget *dialog;
selected_source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (component_view->source_selector));
if (!selected_source)
return;
- if (e_error_run((GtkWindow *)gtk_widget_get_toplevel(ep->target->widget),
- "calendar:prompt-delete-task-list", e_source_peek_name(selected_source)) != GTK_RESPONSE_YES)
- return;
-
- /* first, ask the backend to remove the task list */
- uri = e_source_get_uri (selected_source);
- cal = e_cal_model_get_client_for_uri (
- e_calendar_table_get_model (E_CALENDAR_TABLE (e_tasks_get_calendar_table (component_view->tasks))),
- uri);
- if (!cal)
- cal = e_cal_new_from_uri (uri, E_CAL_SOURCE_TYPE_TODO);
- g_free (uri);
- if (cal) {
- if (e_cal_remove (cal, NULL)) {
- if (e_source_selector_source_is_selected (E_SOURCE_SELECTOR (component_view->source_selector),
- selected_source)) {
- e_tasks_remove_todo_source (component_view->tasks, selected_source);
- e_source_selector_unselect_source (E_SOURCE_SELECTOR (component_view->source_selector),
- selected_source);
+ /* create the confirmation dialog */
+ dialog = gtk_message_dialog_new (
+ GTK_WINDOW (gtk_widget_get_toplevel (widget)),
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_YES_NO,
+ _("Task List '%s' will be removed. Are you sure you want to continue?"),
+ e_source_peek_name (selected_source));
+ if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_YES) {
+ ECal *cal;
+ char *uri;
+
+ /* first, ask the backend to remove the task list */
+ uri = e_source_get_uri (selected_source);
+ cal = e_cal_model_get_client_for_uri (
+ e_calendar_table_get_model (E_CALENDAR_TABLE (e_tasks_get_calendar_table (component_view->tasks))),
+ uri);
+ if (!cal)
+ cal = e_cal_new_from_uri (uri, E_CAL_SOURCE_TYPE_TODO);
+ g_free (uri);
+ if (cal) {
+ if (e_cal_remove (cal, NULL)) {
+ if (e_source_selector_source_is_selected (E_SOURCE_SELECTOR (component_view->source_selector),
+ selected_source)) {
+ e_tasks_remove_todo_source (component_view->tasks, selected_source);
+ e_source_selector_unselect_source (E_SOURCE_SELECTOR (component_view->source_selector),
+ selected_source);
+ }
+
+ e_source_group_remove_source (e_source_peek_group (selected_source), selected_source);
+ e_source_list_sync (component_view->source_list, NULL);
}
-
- e_source_group_remove_source (e_source_peek_group (selected_source), selected_source);
- e_source_list_sync (component_view->source_list, NULL);
}
}
+
+ gtk_widget_destroy (dialog);
}
static void
-new_task_list_cb (EPopup *ep, EPopupItem *pitem, void *data)
+new_task_list_cb (GtkWidget *widget, TasksComponentView *component_view)
{
- calendar_setup_new_task_list (GTK_WINDOW (gtk_widget_get_toplevel(ep->target->widget)));
+ calendar_setup_new_task_list (GTK_WINDOW (gtk_widget_get_toplevel (widget)));
}
static void
-edit_task_list_cb (EPopup *ep, EPopupItem *pitem, void *data)
+edit_task_list_cb (GtkWidget *widget, TasksComponentView *component_view)
{
- TasksComponentView *component_view = data;
ESource *selected_source;
selected_source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (component_view->source_selector));
if (!selected_source)
return;
- calendar_setup_edit_task_list (GTK_WINDOW (gtk_widget_get_toplevel(ep->target->widget)), selected_source);
+ calendar_setup_edit_task_list (GTK_WINDOW (gtk_widget_get_toplevel (widget)), selected_source);
}
-static EPopupItem etc_source_popups[] = {
- { E_POPUP_ITEM, "10.new", N_("New Task List"), new_task_list_cb, NULL, "stock_todo", 0, 0 },
- { E_POPUP_ITEM, "15.copy", N_("Copy"), copy_task_list_cb, NULL, "stock_folder-copy", 0, E_CAL_POPUP_SOURCE_PRIMARY },
- { E_POPUP_ITEM, "20.delete", N_("Delete"), delete_task_list_cb, NULL, "stock_delete", 0, E_CAL_POPUP_SOURCE_USER|E_CAL_POPUP_SOURCE_PRIMARY },
- { E_POPUP_ITEM, "30.properties", N_("Properties..."), edit_task_list_cb, NULL, "stock_folder-properties", 0, E_CAL_POPUP_SOURCE_PRIMARY },
-};
-
static void
-etc_source_popup_free(EPopup *ep, GSList *list, void *data)
+fill_popup_menu_cb (ESourceSelector *selector, GtkMenu *menu, TasksComponentView *component_view)
{
- g_slist_free(list);
-}
-
-static gboolean
-popup_event_cb(ESourceSelector *selector, ESource *insource, GdkEventButton *event, TasksComponentView *component_view)
-{
- ECalPopup *ep;
- ECalPopupTargetSource *t;
- GSList *menus = NULL;
- int i;
- GtkMenu *menu;
-
- /** @HookPoint-ECalPopup: Tasks Source Selector Context Menu
- * @Id: org.gnome.evolution.tasks.source.popup
- * @Class: org.gnome.evolution.calendar.popup:1.0
- * @Target: ECalPopupTargetSource
- *
- * The context menu on the source selector in the tasks window.
- */
- ep = e_cal_popup_new("org.gnome.evolution.tasks.source.popup");
- t = e_cal_popup_target_new_source(ep, selector);
- t->target.widget = (GtkWidget *)component_view->tasks;
-
- for (i=0;i<sizeof(etc_source_popups)/sizeof(etc_source_popups[0]);i++)
- menus = g_slist_prepend(menus, &etc_source_popups[i]);
-
- e_popup_add_items((EPopup *)ep, menus, NULL,etc_source_popup_free, component_view);
-
- menu = e_popup_create_menu_once((EPopup *)ep, (EPopupTarget *)t, 0);
- gtk_menu_popup(menu, NULL, NULL, NULL, NULL, event?event->button:0, event?event->time:gtk_get_current_event_time());
-
- return TRUE;
+ ESource *source;
+ gboolean sensitive, system;
+ const char *source_uri;
+
+ source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (component_view->source_selector));
+ sensitive = source ? TRUE : FALSE;
+
+ /* FIXME Gross hack, should have a property or something */
+ source_uri = e_source_peek_relative_uri (source);
+ system = source_uri && !strcmp ("system", source_uri);
+
+ add_popup_menu_item (menu, _("New Task List"), "stock_todo",
+ G_CALLBACK (new_task_list_cb), component_view, TRUE);
+ add_popup_menu_item (menu, _("Copy"), "stock_folder-copy",
+ G_CALLBACK (copy_task_list_cb), component_view, sensitive);
+ add_popup_menu_item (menu, _("Delete"), "stock_delete", G_CALLBACK (delete_task_list_cb),
+ component_view, sensitive && !system);
+ add_popup_menu_item (menu, _("Properties..."), NULL, G_CALLBACK (edit_task_list_cb),
+ component_view, sensitive);
}
static void
@@ -791,7 +808,7 @@ create_new_todo (TasksComponent *task_component, gboolean is_assigned, TasksComp
if (!ecal)
return FALSE;
- editor = task_editor_new (ecal, is_assigned);
+ editor = task_editor_new (ecal);
comp = cal_comp_task_new_with_defaults (ecal);
comp_editor_edit_comp (COMP_EDITOR (editor), comp);
@@ -839,7 +856,6 @@ create_component_view (TasksComponent *tasks_component)
TasksComponentView *component_view;
GtkWidget *selector_scrolled_window, *vbox;
GtkWidget *statusbar_widget;
- AtkObject *a11y;
priv = tasks_component->priv;
@@ -851,9 +867,7 @@ create_component_view (TasksComponent *tasks_component)
/* Create sidebar selector */
component_view->source_selector = e_source_selector_new (tasks_component->priv->source_list);
- e_source_selector_set_select_new ((ESourceSelector *)component_view->source_selector, TRUE);
- a11y = gtk_widget_get_accessible (GTK_WIDGET (component_view->source_selector));
- atk_object_set_name (a11y, _("Task Source Selector"));
+ e_source_selector_set_select_new (component_view->source_selector, TRUE);
g_signal_connect (component_view->source_selector, "drag-motion", G_CALLBACK (selector_tree_drag_motion),
tasks_component);
@@ -922,8 +936,8 @@ create_component_view (TasksComponent *tasks_component)
G_CALLBACK (source_selection_changed_cb), component_view);
g_signal_connect (component_view->source_selector, "primary_selection_changed",
G_CALLBACK (primary_source_selection_changed_cb), component_view);
- g_signal_connect (component_view->source_selector, "popup_event",
- G_CALLBACK (popup_event_cb), component_view);
+ g_signal_connect (component_view->source_selector, "fill_popup_menu",
+ G_CALLBACK (fill_popup_menu_cb), component_view);
/* Set up the "new" item handler */
component_view->creatable_items_handler = e_user_creatable_items_handler_new ("tasks", create_local_item_cb, tasks_component);